ó ˯t_c@sŒddlZddd„ƒYZddd„ƒYZdefd„ƒYZdefd „ƒYZd Zd Zd Zd Z dZ dZ dZ dS(iÿÿÿÿNtLinkcBs eZdZd„Zd„ZRS(s This class represents a file link from within a string given by the output of some software tool. A link contains a reference to a file, the line number within the file and the boundaries within the given output string that should be marked as a link. cCs=||_t|ƒ|_t|ƒ|_||_||_dS(s6 path -- the path of the file (that could be extracted) line_nr -- the line nr of the specified file col_nr -- the col nr of the specific file start -- the index within the string that the link starts at end -- the index within the string where the link ends at N(tpathtinttline_nrtcol_nrtstarttend(tselfRRRRR((s5/usr/lib64/gedit/plugins/externaltools/linkparsing.pyt__init__s   cCs&d|j|j|j|j|jfS(Ns%s[%s][%s](%s:%s)(RRRRR(R((s5/usr/lib64/gedit/plugins/externaltools/linkparsing.pyt__repr__,s(t__name__t __module__t__doc__RR (((s5/usr/lib64/gedit/plugins/externaltools/linkparsing.pyRs t LinkParsercBs2eZdZd„Zd„Zd„Zd„ZRS(sL Parses a text using different parsing providers with the goal of finding one or more file links within the text. A typical example could be the output from a compiler that specifies an error in a specific file. The path of the file, the line nr and some more info is then returned so that it can be used to be able to navigate from the error output in to the specific file. The actual work of parsing the text is done by instances of classes that inherits from AbstractLinkParser or by regular expressions. To add a new parser just create a class that inherits from AbstractLinkParser and then register in this class cunstructor using the method add_parser. If you want to add a regular expression then just call add_regexp in this class constructor and provide your regexp string as argument. cCshg|_|jtƒ|jtƒ|jtƒ|jtƒ|jtƒ|jtƒ|jtƒdS(N( t _providerst add_regexptREGEXP_STANDARDt REGEXP_PYTHONt REGEXP_VALACt REGEXP_BASHt REGEXP_RUBYt REGEXP_PERLt REGEXP_MCS(R((s5/usr/lib64/gedit/plugins/externaltools/linkparsing.pyRAs       cCs|jj|ƒdS(N(Rtappend(Rtparser((s5/usr/lib64/gedit/plugins/externaltools/linkparsing.pyt add_parserKscCs|jt|ƒƒdS(s® Adds a regular expression string that should match a link using re.MULTILINE and re.VERBOSE regexp. The area marked as a link should be captured by a group named lnk. The path of the link should be captured by a group named pth. The line number should be captured by a group named ln. To read more about this look at the documentation for the RegexpLinkParser constructor. N(RtRegexpLinkParser(Rtregexp((s5/usr/lib64/gedit/plugins/externaltools/linkparsing.pyRNs cCsO|dkrtdƒ‚ng}x'|jD]}|j|j|ƒƒq+W|S(s[ Parses the given text and returns a list of links that are parsed from the text. This method delegates to parser providers that can parse output from different kinds of formats. If no links are found then an empty list is returned. text -- the text to scan for file links. 'text' can not be None. stext can not be NoneN(tNonet ValueErrorRtextendtparse(Rttexttlinkstprovider((s5/usr/lib64/gedit/plugins/externaltools/linkparsing.pyRYs (R R R RRRR(((s5/usr/lib64/gedit/plugins/externaltools/linkparsing.pyR 1s   tAbstractLinkParsercBseZdZd„ZRS(s)The "abstract" base class for link parsescCstdƒ‚dS(s£ This method should be implemented by subclasses. It takes a text as argument (never None) and then returns a list of Link objects. If no links are found then an empty list is expected. The Link class is defined in this module. If you do not override this method then a NotImplementedError will be thrown. text -- the text to parse. This argument is never None. s need to implement a parse methodN(tNotImplementedError(RR ((s5/usr/lib64/gedit/plugins/externaltools/linkparsing.pyRps (R R R R(((s5/usr/lib64/gedit/plugins/externaltools/linkparsing.pyR#msRcBs eZdZd„Zd„ZRS(sÞ A class that represents parsers that only use one single regular expression. It can be used by subclasses or by itself. See the constructor documentation for details about the rules surrouning the regexp. cCs#tj|tjtjBƒ|_dS(sÍ Creates a new RegexpLinkParser based on the given regular expression. The regular expression is multiline and verbose (se python docs on compilation flags). The regular expression should contain three named capturing groups 'lnk', 'pth' and 'ln'. 'lnk' represents the area wich should be marked as a link in the text. 'pth' is the path that should be looked for and 'ln' is the line number in that file. N(tretcompilet MULTILINEtVERBOSE(Rtregex((s5/usr/lib64/gedit/plugins/externaltools/linkparsing.pyR„s c CsÑg}xÄtj|j|ƒD]­}|jƒ}|jdƒ}|jdƒ}|jdƒ}|jdƒ}t|ƒdkrž|ddkrž|jdƒ} nd} t||| ||ƒ} |j | ƒqW|S(Ntpthtlntlnkitcoli( R%tfinditertgroupstgroupRRtlenRRR( RR R!tmR/RRRRRtlink((s5/usr/lib64/gedit/plugins/externaltools/linkparsing.pyRs "(R R R RR(((s5/usr/lib64/gedit/plugins/externaltools/linkparsing.pyR}s sv ^ (?:\[(?:error|warn)\]\ )? (?P (?P [^ \:\n]* ) \: (?P \d+) \:? (?P \d+)? ) \:sV ^\s\sFile\s (?P \" (?P [^\"]+ ) \",\sline\s (?P \d+ ) )sA ^(?P (?P .* ) \:\sline\s (?P \d+ ) )\:sj ^(?P (?P .*vala ) \: (?P \d+ ) \.\d+-\d+\.\d+ )\: sZ ^\s+from\s (?P (?P .* ) \: (?P \d+ ) )sC \sat\s (?P (?P .* ) \sline\s (?P \d+ ) )sK ^ (?P (?P \S+ ) \( (?P \d+ ) ,\d+\) ) \:?\s ((( R%RR tobjectR#RRRRRRRR(((s5/usr/lib64/gedit/plugins/externaltools/linkparsing.pyts <8