eric6/Utilities/ClassBrowsers/pyclbr.py

changeset 7690
a59680062837
parent 7685
0b6e8c0d6403
child 7698
12cb12380a6a
equal deleted inserted replaced
7689:147236d850a4 7690:a59680062837
23 23
24 SUPPORTED_TYPES = [ClassBrowsers.PY_SOURCE, ClassBrowsers.PTL_SOURCE] 24 SUPPORTED_TYPES = [ClassBrowsers.PY_SOURCE, ClassBrowsers.PTL_SOURCE]
25 25
26 _getnext = re.compile( 26 _getnext = re.compile(
27 r""" 27 r"""
28 (?P<String> 28 (?P<CodingLine>
29 ^ \# \s* [*_-]* \s* coding[:=] \s* (?P<Coding> [-\w_.]+ ) \s* [*_-]* $
30 )
31
32 | (?P<String>
29 \# .*? $ # ignore everything in comments 33 \# .*? $ # ignore everything in comments
30 | 34 |
31 \""" [^"\\]* (?: 35 \""" [^"\\]* (?:
32 (?: \\. | "(?!"") ) 36 (?: \\. | "(?!"") )
33 [^"\\]* 37 [^"\\]*
125 import [ \t]+ 129 import [ \t]+
126 (?P<ImportFromList> 130 (?P<ImportFromList>
127 (?: \( \s* .*? \s* \) ) 131 (?: \( \s* .*? \s* \) )
128 | 132 |
129 (?: [^#;\\\n]* (?: \\\n )* )* ) 133 (?: [^#;\\\n]* (?: \\\n )* )* )
130 )
131
132 | (?P<CodingLine>
133 ^ \# \s* [*_-]* \s* coding[:=] \s* (?P<Coding> [-\w_.]+ ) \s* [*_-]* $
134 )""", 134 )""",
135 re.VERBOSE | re.DOTALL | re.MULTILINE).search 135 re.VERBOSE | re.DOTALL | re.MULTILINE).search
136 136
137 _commentsub = re.compile(r"""#[^\n]*\n|#[^\n]*$""").sub 137 _commentsub = re.compile(r"""#[^\n]*\n|#[^\n]*$""").sub
138 138
333 333
334 Search for MODULE in PATH and sys.path, read and parse the 334 Search for MODULE in PATH and sys.path, read and parse the
335 module and return a dictionary with one entry for each class 335 module and return a dictionary with one entry for each class
336 found in the module. 336 found in the module.
337 337
338 @param module name of the module file (string) 338 @param module name of the module file
339 @param path path the module should be searched in (list of strings) 339 @type str
340 @param path path the module should be searched in
341 @type list of str
340 @param inpackage flag indicating a module inside a package is scanned 342 @param inpackage flag indicating a module inside a package is scanned
341 @param isPyFile flag indicating a Python file (boolean) 343 @type bool
344 @param isPyFile flag indicating a Python file
345 @type bool
342 @return the resulting dictionary 346 @return the resulting dictionary
347 @rtype dict
343 """ 348 """
344 global _modules 349 global _modules
345 350
346 if module in _modules: 351 if module in _modules:
347 # we've seen this module before... 352 # we've seen this module before...

eric ide

mercurial