Utilities/ModuleParser.py

changeset 1358
c1622c708cd9
parent 1350
f21bedbb0c6f
child 1509
c0b5e693b0eb
equal deleted inserted replaced
1357:68fb0a7677ff 1358:c1622c708cd9
23 23
24 import Utilities 24 import Utilities
25 from functools import reduce 25 from functools import reduce
26 import Preferences 26 import Preferences
27 27
28 __all__ = ["Module", "Class", "Function", "RbModule", "readModule"] 28 __all__ = ["Module", "Class", "Function", "Attribute", "RbModule", "readModule",
29 "getTypeFromTypeName"]
29 30
30 TABWIDTH = 4 31 TABWIDTH = 4
31 32
32 PTL_SOURCE = 128 33 PTL_SOURCE = 128
33 RB_SOURCE = 129 34 RB_SOURCE = 129
34 35
35 SUPPORTED_TYPES = [imp.PY_SOURCE, PTL_SOURCE, RB_SOURCE] 36 SUPPORTED_TYPES = [imp.PY_SOURCE, PTL_SOURCE, RB_SOURCE]
37 PARSEABLE_TYPES = ["Python", "Python2", "Python3", "Ruby"]
38 TYPE_MAPPING = {
39 "Python": imp.PY_SOURCE,
40 "Python2": imp.PY_SOURCE,
41 "Python3": imp.PY_SOURCE,
42 "Ruby": RB_SOURCE,
43 }
44
45
46 def getTypeFromTypeName(name):
47 """
48 Module function to determine the module type given the module type name.
49
50 @param name module type name (string)
51 @return module type or -1 for failure (integer)
52 """
53 if name in TYPE_MAPPING:
54 return TYPE_MAPPING[name]
55 else:
56 return -1
57
36 58
37 _py_getnext = re.compile(r""" 59 _py_getnext = re.compile(r"""
38 (?P<String> 60 (?P<String>
39 \""" (?P<StringContents1> 61 \""" (?P<StringContents1>
40 [^"\\]* (?: 62 [^"\\]* (?:

eric ide

mercurial