eric6/Utilities/ModuleParser.py

Sat, 19 Dec 2020 15:22:26 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 19 Dec 2020 15:22:26 +0100
changeset 7900
72b88fb20261
parent 7836
2f0d208b8137
child 7923
91e843545d9a
permissions
-rw-r--r--

Corrected the use of '@keyparam' in the source documentation.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7259
diff changeset
3 # Copyright (c) 2003 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Parse a Python module file.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9 <b>BUGS</b> (from pyclbr.py)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 <ul>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 <li>Code that doesn't pass tabnanny or python -t will confuse it, unless
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 you set the module TABWIDTH variable (default 8) to the correct tab width
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 for the file.</li>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 </ul>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 import sys
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 import os
7585
749c6871f4ef ModuleParser: fixed an issue related to a wrong import statement.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7400
diff changeset
19 import importlib.machinery
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 import re
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 import Utilities
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
23 from functools import reduce
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
25 __all__ = ["Module", "Class", "Function", "Attribute", "RbModule",
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
26 "readModule", "getTypeFromTypeName"]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 TABWIDTH = 4
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
7400
e5d62581d002 Removed use of deprecated 'imp' module in the frontend.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
30 SEARCH_ERROR = 0
e5d62581d002 Removed use of deprecated 'imp' module in the frontend.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
31 PY_SOURCE = 1
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 PTL_SOURCE = 128
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 RB_SOURCE = 129
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
7400
e5d62581d002 Removed use of deprecated 'imp' module in the frontend.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
35 SUPPORTED_TYPES = [PY_SOURCE, PTL_SOURCE, RB_SOURCE]
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1350
diff changeset
36 TYPE_MAPPING = {
7400
e5d62581d002 Removed use of deprecated 'imp' module in the frontend.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
37 "Python": PY_SOURCE,
e5d62581d002 Removed use of deprecated 'imp' module in the frontend.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
38 "Python3": PY_SOURCE,
e5d62581d002 Removed use of deprecated 'imp' module in the frontend.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
39 "MicroPython": PY_SOURCE,
1358
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1350
diff changeset
40 "Ruby": RB_SOURCE,
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1350
diff changeset
41 }
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1350
diff changeset
42
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1350
diff changeset
43
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1350
diff changeset
44 def getTypeFromTypeName(name):
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1350
diff changeset
45 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1350
diff changeset
46 Module function to determine the module type given the module type name.
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1350
diff changeset
47
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1350
diff changeset
48 @param name module type name (string)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1350
diff changeset
49 @return module type or -1 for failure (integer)
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1350
diff changeset
50 """
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1350
diff changeset
51 if name in TYPE_MAPPING:
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1350
diff changeset
52 return TYPE_MAPPING[name]
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1350
diff changeset
53 else:
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1350
diff changeset
54 return -1
c1622c708cd9 Added source navigation function for Python 2, Python 3 and Ruby sources.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1350
diff changeset
55
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2997
diff changeset
57 _py_getnext = re.compile(
4830
f609a22f43bd Fixed a few code style issues detected by the updated pep8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
58 r"""
6813
7f4cfe76b90c Ignore triple quotes in comments.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6735
diff changeset
59 (?P<Comment>
6815
b1b833693a38 pyclbr, ModuleParser: reworked the fix contributed by Tobias and fixed an issue introduced by it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6813
diff changeset
60 \# .*? $ # ignore everything in comments
6813
7f4cfe76b90c Ignore triple quotes in comments.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6735
diff changeset
61 )
7f4cfe76b90c Ignore triple quotes in comments.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6735
diff changeset
62
7f4cfe76b90c Ignore triple quotes in comments.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6735
diff changeset
63 | (?P<String>
7f4cfe76b90c Ignore triple quotes in comments.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6735
diff changeset
64 \""" (?P<StringContents1>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 [^"\\]* (?:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 (?: \\. | "(?!"") )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 [^"\\]*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 )*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 )
6813
7f4cfe76b90c Ignore triple quotes in comments.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6735
diff changeset
70 \"""
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 | ''' (?P<StringContents2>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 [^'\\]* (?:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 (?: \\. | '(?!'') )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 [^'\\]*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 )*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 '''
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 | " [^"\\\n]* (?: \\. [^"\\\n]*)* "
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 | ' [^'\\\n]* (?: \\. [^'\\\n]*)* '
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 | \#\#\# (?P<StringContents3>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 [^#\\]* (?:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 (?: \\. | \#(?!\#\#) )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 [^#\\]*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 )*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 \#\#\#
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 | (?P<Docstring>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 (?<= :) \s*
2922
16905f0f48be Fixed an issue in the module parser not recognizing docstrings using r""" or u""".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
95 [ru]? \""" (?P<DocstringContents1>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 [^"\\]* (?:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 (?: \\. | "(?!"") )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 [^"\\]*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 )*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 )
2922
16905f0f48be Fixed an issue in the module parser not recognizing docstrings using r""" or u""".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
101 \"""
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 | (?<= :) \s*
2922
16905f0f48be Fixed an issue in the module parser not recognizing docstrings using r""" or u""".
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2768
diff changeset
104 [ru]? ''' (?P<DocstringContents2>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 [^'\\]* (?:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 (?: \\. | '(?!'') )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 [^'\\]*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 )*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 '''
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 | (?<= :) \s*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 \#\#\# (?P<DocstringContents3>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 [^#\\]* (?:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 (?: \\. | \#(?!\#\#) )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 [^#\\]*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 )*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 \#\#\#
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121
1227
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
122 | (?P<MethodModifier>
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
123 ^
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
124 (?P<MethodModifierIndent> [ \t]* )
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
125 (?P<MethodModifierType> @classmethod | @staticmethod )
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
126 )
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
127
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 | (?P<Method>
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
129 (^ [ \t]* @ (?: PyQt[45] \. )? (?: QtCore \. )?
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
130 (?: pyqtSignature | pyqtSlot )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 [ \t]* \(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 (?P<MethodPyQtSignature> [^)]* )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 \) \s*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 )?
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 ^
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 (?P<MethodIndent> [ \t]* )
4465
2fbb5bdb8ddf Prepared eric for Python 3.5 to support the new 'async def' function definition.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4461
diff changeset
137 (?: async [ \t]+ )? def [ \t]+
444
6f3b2099858e Fixed an issue handling Python identifiers with non-ASCII letters in the module parser and class browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 428
diff changeset
138 (?P<MethodName> \w+ )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 (?: [ \t]* \[ (?: plain | html ) \] )?
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 [ \t]* \(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 (?P<MethodSignature> (?: [^)] | \)[ \t]*,? )*? )
3966
969a3d41c402 Added code to correctly parse Python methods/functions containing return annotations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
142 \) [ \t]*
969a3d41c402 Added code to correctly parse Python methods/functions containing return annotations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
143 (?P<MethodReturnAnnotation> (?: -> [ \t]* [^:]+ )? )
969a3d41c402 Added code to correctly parse Python methods/functions containing return annotations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
144 [ \t]* :
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 | (?P<Class>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 ^
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 (?P<ClassIndent> [ \t]* )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 class [ \t]+
444
6f3b2099858e Fixed an issue handling Python identifiers with non-ASCII letters in the module parser and class browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 428
diff changeset
151 (?P<ClassName> \w+ )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 [ \t]*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 (?P<ClassSupers> \( [^)]* \) )?
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 [ \t]* :
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 | (?P<Attribute>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 ^
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 (?P<AttributeIndent> [ \t]* )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 self [ \t]* \. [ \t]*
444
6f3b2099858e Fixed an issue handling Python identifiers with non-ASCII letters in the module parser and class browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 428
diff changeset
161 (?P<AttributeName> \w+ )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 [ \t]* =
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 | (?P<Variable>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 ^
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 (?P<VariableIndent> [ \t]* )
444
6f3b2099858e Fixed an issue handling Python identifiers with non-ASCII letters in the module parser and class browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 428
diff changeset
168 (?P<VariableName> \w+ )
766
0940de08fa75 Modified module parser to flag PyQt signal definitions and the module documentor to exclude these from the list of attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 444
diff changeset
169 [ \t]* = [ \t]* (?P<VariableSignal> (?:pyqtSignal)? )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171
6552
ea16b851fdab ModuleParser, pyclbr: fixed an issue parsing Python source files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
172 | (?P<Main>
ea16b851fdab ModuleParser, pyclbr: fixed an issue parsing Python source files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
173 ^
ea16b851fdab ModuleParser, pyclbr: fixed an issue parsing Python source files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
174 if \s+ __name__ \s* == \s* [^:]+ : $
ea16b851fdab ModuleParser, pyclbr: fixed an issue parsing Python source files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
175 )
ea16b851fdab ModuleParser, pyclbr: fixed an issue parsing Python source files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
176
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 | (?P<Import>
2396
89475661e400 Fixed an issue in the module parser causing some imports not to be recognised.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
178 ^ [ \t]* (?: import | from [ \t]+ \. [ \t]+ import ) [ \t]+
4182
a84cadf71513 Modified module parser to improve parsing of import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
179 (?P<ImportList> (?: [^#;\\\n]* (?: \\\n )* )* )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 | (?P<ImportFrom>
2396
89475661e400 Fixed an issue in the module parser causing some imports not to be recognised.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
183 ^ [ \t]* from [ \t]+
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 (?P<ImportFromPath>
1350
f21bedbb0c6f Fixed some issues in the Python parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1302
diff changeset
185 \.* \w+
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 (?:
444
6f3b2099858e Fixed an issue handling Python identifiers with non-ASCII letters in the module parser and class browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 428
diff changeset
187 [ \t]* \. [ \t]* \w+
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 )*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 [ \t]+
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 import [ \t]+
4182
a84cadf71513 Modified module parser to improve parsing of import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
192 (?P<ImportFromList>
a84cadf71513 Modified module parser to improve parsing of import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
193 (?: \( \s* .*? \s* \) )
a84cadf71513 Modified module parser to improve parsing of import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
194 |
a84cadf71513 Modified module parser to improve parsing of import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
195 (?: [^#;\\\n]* (?: \\\n )* )* )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 | (?P<ConditionalDefine>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 ^
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 (?P<ConditionalDefineIndent> [ \t]* )
4465
2fbb5bdb8ddf Prepared eric for Python 3.5 to support the new 'async def' function definition.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4461
diff changeset
201 (?: (?: if | elif ) [ \t]+ [^:]* | else [ \t]* ) :
2fbb5bdb8ddf Prepared eric for Python 3.5 to support the new 'async def' function definition.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4461
diff changeset
202 (?= \s* (?: async [ \t]+ )? def)
4435
9f6555d3c3c0 Fixed some code style issues and removed code no longer needed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4182
diff changeset
203 )""",
9f6555d3c3c0 Fixed some code style issues and removed code no longer needed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4182
diff changeset
204 re.VERBOSE | re.DOTALL | re.MULTILINE).search
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2997
diff changeset
206 _rb_getnext = re.compile(
4830
f609a22f43bd Fixed a few code style issues detected by the updated pep8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
207 r"""
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 (?P<Docstring>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 =begin [ \t]+ edoc (?P<DocstringContents> .*? ) =end
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 | (?P<String>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 =begin .*? =end
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 | <<-? (?P<HereMarker1> [a-zA-Z0-9_]+? ) [ \t]* .*? (?P=HereMarker1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 | <<-? ['"] (?P<HereMarker2> .*? ) ['"] [ \t]* .*? (?P=HereMarker2)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 | " [^"\\\n]* (?: \\. [^"\\\n]*)* "
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 | ' [^'\\\n]* (?: \\. [^'\\\n]*)* '
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 | (?P<Comment>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 ^
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 [ \t]* \#+ .*? $
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 | (?P<Method>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 ^
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 (?P<MethodIndent> [ \t]* )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 def [ \t]+
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 (?:
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
234 (?P<MethodName2> [a-zA-Z0-9_]+ (?: \. | :: )
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
235 [a-zA-Z_] [a-zA-Z0-9_?!=]* )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 |
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 (?P<MethodName> [a-zA-Z_] [a-zA-Z0-9_?!=]* )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 |
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 (?P<MethodName3> [^( \t]{1,3} )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 )
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 841
diff changeset
241 [ \t]*
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 841
diff changeset
242 (?:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 \( (?P<MethodSignature> (?: [^)] | \)[ \t]*,? )*? ) \)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 )?
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 [ \t]*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 | (?P<Class>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 ^
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 (?P<ClassIndent> [ \t]* )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 class
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 (?:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 [ \t]+
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 (?P<ClassName> [A-Z] [a-zA-Z0-9_]* )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 [ \t]*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 (?P<ClassSupers> < [ \t]* [A-Z] [a-zA-Z0-9_]* )?
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 |
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 841
diff changeset
258 [ \t]* << [ \t]*
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 (?P<ClassName2> [a-zA-Z_] [a-zA-Z0-9_]* )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 [ \t]*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 | (?P<ClassIgnored>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 \(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 [ \t]*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 class
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 .*?
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 end
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 [ \t]*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 \)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 | (?P<Module>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 ^
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 (?P<ModuleIndent> [ \t]* )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 module [ \t]+
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 (?P<ModuleName> [A-Z] [a-zA-Z0-9_]* )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 [ \t]*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 | (?P<AccessControl>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 ^
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 (?P<AccessControlIndent> [ \t]* )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 (?:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 (?P<AccessControlType> private | public | protected ) [^_]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 |
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
288 (?P<AccessControlType2>
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
289 private_class_method | public_class_method )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 \(?
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 [ \t]*
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
293 (?P<AccessControlList> (?: : [a-zA-Z0-9_]+ , \s* )*
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
294 (?: : [a-zA-Z0-9_]+ )+ )?
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 [ \t]*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 \)?
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 | (?P<Attribute>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 ^
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 (?P<AttributeIndent> [ \t]* )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 (?P<AttributeName> (?: @ | @@ | [A-Z]) [a-zA-Z0-9_]* )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 [ \t]* =
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 | (?P<Attr>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 ^
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 (?P<AttrIndent> [ \t]* )
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 841
diff changeset
309 attr
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 (?P<AttrType> (?: _accessor | _reader | _writer ) )?
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 \(?
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 [ \t]*
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
313 (?P<AttrList> (?: : [a-zA-Z0-9_]+ , \s* )*
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
314 (?: : [a-zA-Z0-9_]+ | true | false )+ )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 [ \t]*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 \)?
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 | (?P<Begin>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 ^
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 [ \t]*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 (?: if | unless | case | while | until | for | begin ) \b [^_]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 |
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 [ \t]* do [ \t]* (?: \| .*? \| )? [ \t]* $
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 | (?P<BeginEnd>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 \b (?: if ) \b [^_] .*? $
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 |
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 \b (?: if ) \b [^_] .*? end [ \t]* $
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 | (?P<End>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 [ \t]*
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 (?:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 end [ \t]* $
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 |
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 end \b [^_]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 )
4435
9f6555d3c3c0 Fixed some code style issues and removed code no longer needed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4182
diff changeset
340 )""",
9f6555d3c3c0 Fixed some code style issues and removed code no longer needed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4182
diff changeset
341 re.VERBOSE | re.DOTALL | re.MULTILINE).search
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 _hashsub = re.compile(r"""^([ \t]*)#[ \t]?""", re.MULTILINE).sub
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 _commentsub = re.compile(r"""#[^\n]*\n|#[^\n]*$""").sub
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 _modules = {} # cache of modules we've seen
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 841
diff changeset
349
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 class VisibilityBase(object):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 Class implementing the visibility aspect of all objects.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 def isPrivate(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 Public method to check, if the visibility is Private.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 @return flag indicating Private visibility (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 return self.visibility == 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 def isProtected(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 Public method to check, if the visibility is Protected.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 @return flag indicating Protected visibility (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 return self.visibility == 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 def isPublic(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 Public method to check, if the visibility is Public.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 @return flag indicating Public visibility (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 return self.visibility == 2
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378 def setPrivate(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 Public method to set the visibility to Private.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 self.visibility = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 def setProtected(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 Public method to set the visibility to Protected.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 self.visibility = 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 def setPublic(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 Public method to set the visibility to Public.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 self.visibility = 2
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 841
diff changeset
396
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 class Module(object):
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2922
diff changeset
398 """
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 Class to represent a Python module.
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2922
diff changeset
400 """
5604
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
401 def __init__(self, name, file=None, moduleType=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 @param name name of this module (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 @param file filename of file containing this module (string)
5604
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
407 @param moduleType type of this module
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 self.name = name
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410 self.file = file
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 self.modules = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 self.modules_counts = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413 self.classes = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414 self.classes_counts = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 self.functions = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 self.functions_counts = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 self.description = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418 self.globals = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 self.imports = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420 self.from_imports = {}
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421 self.package = '.'.join(name.split('.')[:-1])
5604
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
422 self.type = moduleType
7400
e5d62581d002 Removed use of deprecated 'imp' module in the frontend.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
423 if moduleType in [PY_SOURCE, PTL_SOURCE]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424 self._getnext = _py_getnext
5604
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
425 elif moduleType == RB_SOURCE:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 self._getnext = _rb_getnext
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 self._getnext = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
430 def addClass(self, name, _class):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432 Public method to add information about a class.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434 @param name name of class to be added (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435 @param _class Class object to be added
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436 """
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
437 if name in self.classes:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438 self.classes_counts[name] += 1
428
58405c24aa09 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
439 name = "{0}_{1:d}".format(name, self.classes_counts[name])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
441 self.classes_counts[name] = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442 self.classes[name] = _class
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 def addModule(self, name, module):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 Public method to add information about a Ruby module.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448 @param name name of module to be added (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449 @param module Module object to be added
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450 """
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
451 if name in self.modules:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452 self.modules_counts[name] += 1
428
58405c24aa09 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
453 name = "{0}_{1:d}".format(name, self.modules_counts[name])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 self.modules_counts[name] = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 self.modules[name] = module
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 def addFunction(self, name, function):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 Public method to add information about a function.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 @param name name of function to be added (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463 @param function Function object to be added
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464 """
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
465 if name in self.functions:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466 self.functions_counts[name] += 1
428
58405c24aa09 Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
467 name = "{0}_{1:d}".format(name, self.functions_counts[name])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469 self.functions_counts[name] = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 self.functions[name] = function
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472 def addGlobal(self, name, attr):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474 Public method to add information about global variables.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476 @param name name of the global to add (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477 @param attr Attribute object to be added
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
478 """
3621
15f23ed3f216 Fixed a few source code style issues found by the updated pe8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
479 if name not in self.globals:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480 self.globals[name] = attr
1302
95538c8d07c1 Extended the module parser to record each line a variable/attribute is assigned to.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1229
diff changeset
481 else:
95538c8d07c1 Extended the module parser to record each line a variable/attribute is assigned to.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1229
diff changeset
482 self.globals[name].addAssignment(attr.lineno)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
484 def addDescription(self, description):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
485 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3539
diff changeset
486 Public method to store the modules docstring.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
487
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
488 @param description the docstring to be stored (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490 self.description = description
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
492 def scan(self, src):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
493 """
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
494 Public method to scan the source text and retrieve the relevant
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
495 information.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
497 @param src the source text to be scanned (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
498 """
7676
0f67b4562d98 ClassBrowsers: added code to treat source texts like Python (universal newline).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
499 # convert eol markers the Python style
0f67b4562d98 ClassBrowsers: added code to treat source texts like Python (universal newline).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7639
diff changeset
500 src = src.replace("\r\n", "\n").replace("\r", "\n")
7400
e5d62581d002 Removed use of deprecated 'imp' module in the frontend.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
501 if self.type in [PY_SOURCE, PTL_SOURCE]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 self.__py_scan(src)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503 elif self.type == RB_SOURCE:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504 self.__rb_scan(src)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505
5604
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
506 def __py_setVisibility(self, objectRef):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
508 Private method to set the visibility of an object.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
509
5604
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
510 @param objectRef reference to the object (Attribute, Class or Function)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
511 """
5604
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
512 if objectRef.name.startswith('__'):
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
513 objectRef.setPrivate()
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
514 elif objectRef.name.startswith('_'):
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
515 objectRef.setProtected()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
516 else:
5604
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
517 objectRef.setPublic()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
518
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
519 def __py_scan(self, src):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
520 """
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
521 Private method to scan the source text of a Python module and retrieve
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
522 the relevant information.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
523
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
524 @param src the source text to be scanned (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525 """
7706
0c6d32ec64f1 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7699
diff changeset
526 # __IGNORE_WARNING_D234__
7699
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
527 def calculateEndline(lineno, lines, indent):
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
528 """
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
529 Function to calculate the end line of a class or method/function.
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
530
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
531 @param lineno line number to start at (one based)
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
532 @type int
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
533 @param lines list of source lines
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
534 @type list of str
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
535 @param indent indent length the class/method/function definition
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
536 @type int
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
537 @return end line of the class/method/function (one based)
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
538 @rtype int
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
539 """
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
540 # start with zero based line after start line
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
541 while lineno < len(lines):
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
542 line = lines[lineno]
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
543 if line.strip():
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
544 # line contains some text
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
545 lineIndent = _indent(line.replace(line.lstrip(), ""))
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
546 if lineIndent <= indent:
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
547 return lineno
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
548 lineno += 1
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
549
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
550 # nothing found
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
551 return -1
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
552
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
553 srcLines = src.splitlines()
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
554
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
555 lineno, last_lineno_pos = 1, 0
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 841
diff changeset
556 classstack = [] # stack of (class, indent) pairs
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 841
diff changeset
557 conditionalsstack = [] # stack of indents of conditional defines
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
558 deltastack = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
559 deltaindent = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
560 deltaindentcalculated = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
561 i = 0
6815
b1b833693a38 pyclbr, ModuleParser: reworked the fix contributed by Tobias and fixed an issue introduced by it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6813
diff changeset
562 modulelevel = True
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
563 cur_obj = self
1227
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
564 modifierType = Function.General
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
565 modifierIndent = -1
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
566 while True:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
567 m = self._getnext(src, i)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
568 if not m:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
569 break
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
570 start, i = m.span()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
571
1227
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
572 if m.start("MethodModifier") >= 0:
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
573 modifierIndent = _indent(m.group("MethodModifierIndent"))
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
574 modifierType = m.group("MethodModifierType")
1229
a8207dc73672 Fixed an issue in the source documentor and regenerated the source docu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1227
diff changeset
575
1227
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
576 elif m.start("Method") >= 0:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
577 # found a method definition or function
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
578 thisindent = _indent(m.group("MethodIndent"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
579 meth_name = m.group("MethodName")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
580 meth_sig = m.group("MethodSignature")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
581 meth_sig = meth_sig.replace('\\\n', '')
3966
969a3d41c402 Added code to correctly parse Python methods/functions containing return annotations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
582 meth_ret = m.group("MethodReturnAnnotation")
969a3d41c402 Added code to correctly parse Python methods/functions containing return annotations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
583 meth_ret = meth_ret.replace('\\\n', '')
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
584 if m.group("MethodPyQtSignature") is not None:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
585 meth_pyqtSig = (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
586 m.group("MethodPyQtSignature")
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
587 .replace('\\\n', '')
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
588 .split('result')[0]
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
589 .split('name')[0]
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
590 .strip("\"', \t")
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
591 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
592 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
593 meth_pyqtSig = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
594 lineno = lineno + src.count('\n', last_lineno_pos, start)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
595 last_lineno_pos = start
1227
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
596 if modifierType and modifierIndent == thisindent:
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
597 if modifierType == "@staticmethod":
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
598 modifier = Function.Static
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
599 elif modifierType == "@classmethod":
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
600 modifier = Function.Class
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
601 else:
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
602 modifier = Function.General
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
603 else:
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
604 modifier = Function.General
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
605 # modify indentation level for conditional defines
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
606 if conditionalsstack:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
607 if thisindent > conditionalsstack[-1]:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
608 if not deltaindentcalculated:
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
609 deltastack.append(
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
610 thisindent - conditionalsstack[-1])
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
611 deltaindent = reduce(
3539
0c2dc1446ebf Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
612 lambda x, y: x + y, deltastack)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
613 deltaindentcalculated = 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
614 thisindent -= deltaindent
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
615 else:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
616 while (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
617 conditionalsstack and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
618 conditionalsstack[-1] >= thisindent
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
619 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
620 del conditionalsstack[-1]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
621 if deltastack:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
622 del deltastack[-1]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
623 deltaindentcalculated = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
624 # close all classes indented at least as much
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
625 while classstack and classstack[-1][1] >= thisindent:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
626 del classstack[-1]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
627 if classstack:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
628 csi = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
629 while csi >= -len(classstack):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
630 # nested defs are added to the class
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
631 cur_class = classstack[csi][0]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
632 csi -= 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
633 if cur_class is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
634 continue
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
635
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
636 if isinstance(cur_class, Class):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
637 # it's a class method
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
638 f = Function(
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
639 None, meth_name, None, lineno,
3966
969a3d41c402 Added code to correctly parse Python methods/functions containing return annotations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
640 meth_sig, meth_pyqtSig, modifierType=modifier,
969a3d41c402 Added code to correctly parse Python methods/functions containing return annotations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
641 annotation=meth_ret)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
642 self.__py_setVisibility(f)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
643 cur_class.addMethod(meth_name, f)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
644 break
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
645 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
646 # it's a nested function of a module function
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
647 f = Function(
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
648 self.name, meth_name, self.file, lineno,
3966
969a3d41c402 Added code to correctly parse Python methods/functions containing return annotations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
649 meth_sig, meth_pyqtSig, modifierType=modifier,
969a3d41c402 Added code to correctly parse Python methods/functions containing return annotations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
650 annotation=meth_ret)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
651 self.__py_setVisibility(f)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
652 self.addFunction(meth_name, f)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
653 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
654 # it's a module function
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 841
diff changeset
655 f = Function(self.name, meth_name, self.file, lineno,
3966
969a3d41c402 Added code to correctly parse Python methods/functions containing return annotations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
656 meth_sig, meth_pyqtSig, modifierType=modifier,
969a3d41c402 Added code to correctly parse Python methods/functions containing return annotations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
657 annotation=meth_ret)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
658 self.__py_setVisibility(f)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
659 self.addFunction(meth_name, f)
7699
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
660 endlineno = calculateEndline(lineno, srcLines, thisindent)
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
661 f.setEndLine(endlineno)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
662 cur_obj = f
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 841
diff changeset
663 classstack.append((None, thisindent)) # Marker for nested fns
1227
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
664
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
665 # reset the modifier settings
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
666 modifierType = Function.General
c5db073a124f Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
667 modifierIndent = -1
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
668
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
669 elif m.start("Docstring") >= 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
670 contents = m.group("DocstringContents3")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
671 if contents is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
672 contents = _hashsub(r"\1", contents)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
673 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
674 if self.file.lower().endswith('.ptl'):
6735
31e263d49c04 Fixed some code style issues detected by the updated style checker (over-indented lines).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
675 contents = ""
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
676 else:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
677 contents = (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
678 m.group("DocstringContents1") or
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
679 m.group("DocstringContents2")
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
680 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
681 if cur_obj:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
682 cur_obj.addDescription(contents)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
683
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
684 elif m.start("String") >= 0:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
685 if (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
686 modulelevel and (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
687 src[start - len('\r\n'):start] == '\r\n' or
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
688 src[start - len('\n'):start] == '\n' or
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
689 src[start - len('\r'):start] == '\r'
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
690 )
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
691 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
692 contents = m.group("StringContents3")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
693 if contents is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
694 contents = _hashsub(r"\1", contents)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
695 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
696 if self.file.lower().endswith('.ptl'):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
697 contents = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
698 else:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
699 contents = (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
700 m.group("StringContents1") or
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
701 m.group("StringContents2")
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
702 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
703 if cur_obj:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
704 cur_obj.addDescription(contents)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
705
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
706 elif m.start("Class") >= 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
707 # we found a class definition
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
708 thisindent = _indent(m.group("ClassIndent"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
709 lineno = lineno + src.count('\n', last_lineno_pos, start)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
710 last_lineno_pos = start
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
711 # close all classes indented at least as much
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
712 while classstack and classstack[-1][1] >= thisindent:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
713 del classstack[-1]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
714 class_name = m.group("ClassName")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
715 inherit = m.group("ClassSupers")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
716 if inherit:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
717 # the class inherits from other classes
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
718 inherit = inherit[1:-1].strip()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
719 inherit = _commentsub('', inherit)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
720 names = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
721 for n in inherit.split(','):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
722 n = n.strip()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
723 if n:
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
724 if n in self.classes:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
725 # we know this super class
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
726 n = self.classes[n].name
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
727 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
728 c = n.split('.')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
729 if len(c) > 1:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
730 # super class is of the
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
731 # form module.class:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
732 # look in module for class
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
733 m = c[-2]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
734 c = c[-1]
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
735 if m in _modules:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
736 m = _modules[m]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
737 n = m.name
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
738 names.append(n)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
739 inherit = names
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
740 # remember this class
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
741 cur_class = Class(self.name, class_name, inherit,
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
742 self.file, lineno)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
743 self.__py_setVisibility(cur_class)
7699
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
744 endlineno = calculateEndline(lineno, srcLines, thisindent)
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
745 cur_class.setEndLine(endlineno)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
746 cur_obj = cur_class
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
747 self.addClass(class_name, cur_class)
7699
d338c533f5f0 Class browsers: improved endline detection for the Python, IDL and ProtoBuf source code browsers and the Python module parser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7676
diff changeset
748 # add nested classes to the module
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
749 classstack.append((cur_class, thisindent))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
750
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
751 elif m.start("Attribute") >= 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
752 lineno = lineno + src.count('\n', last_lineno_pos, start)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
753 last_lineno_pos = start
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
754 index = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
755 while index >= -len(classstack):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
756 if classstack[index][0] is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
757 attrName = m.group("AttributeName")
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
758 attr = Attribute(
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
759 self.name, attrName, self.file, lineno)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
760 self.__py_setVisibility(attr)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
761 classstack[index][0].addAttribute(attrName, attr)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
762 break
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
763 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
764 index -= 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
765
6552
ea16b851fdab ModuleParser, pyclbr: fixed an issue parsing Python source files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
766 elif m.start("Main") >= 0:
ea16b851fdab ModuleParser, pyclbr: fixed an issue parsing Python source files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
767 # 'main' part of the script, reset class stack
ea16b851fdab ModuleParser, pyclbr: fixed an issue parsing Python source files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
768 lineno = lineno + src.count('\n', last_lineno_pos, start)
ea16b851fdab ModuleParser, pyclbr: fixed an issue parsing Python source files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
769 last_lineno_pos = start
ea16b851fdab ModuleParser, pyclbr: fixed an issue parsing Python source files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
770 classstack = []
ea16b851fdab ModuleParser, pyclbr: fixed an issue parsing Python source files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
771
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
772 elif m.start("Variable") >= 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
773 thisindent = _indent(m.group("VariableIndent"))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
774 variable_name = m.group("VariableName")
766
0940de08fa75 Modified module parser to flag PyQt signal definitions and the module documentor to exclude these from the list of attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 444
diff changeset
775 isSignal = m.group("VariableSignal") != ""
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
776 lineno = lineno + src.count('\n', last_lineno_pos, start)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
777 last_lineno_pos = start
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
778 if thisindent == 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
779 # global variable
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
780 attr = Attribute(
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
781 self.name, variable_name, self.file, lineno,
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
782 isSignal=isSignal)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
783 self.__py_setVisibility(attr)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
784 self.addGlobal(variable_name, attr)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
785 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
786 index = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
787 while index >= -len(classstack):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
788 if classstack[index][1] >= thisindent:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
789 index -= 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
790 else:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
791 if (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
792 classstack[index][0] is not None and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
793 isinstance(classstack[index][0], Class)
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
794 ):
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
795 attr = Attribute(
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
796 self.name, variable_name, self.file,
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
797 lineno, isSignal=isSignal)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
798 self.__py_setVisibility(attr)
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
799 classstack[index][0].addGlobal(
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
800 variable_name, attr)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
801 break
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
802
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
803 elif m.start("Import") >= 0:
7249
0bf517e60f54 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
804 ## import module
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
805 names = [n.strip() for n in
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
806 "".join(m.group("ImportList").splitlines())
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
807 .replace("\\", "").split(',')]
4182
a84cadf71513 Modified module parser to improve parsing of import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
808 self.imports.extend(
a84cadf71513 Modified module parser to improve parsing of import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
809 [name for name in names
a84cadf71513 Modified module parser to improve parsing of import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
810 if name not in self.imports])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
811
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
812 elif m.start("ImportFrom") >= 0:
7249
0bf517e60f54 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
813 ## from module import stuff
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
814 mod = m.group("ImportFromPath")
4182
a84cadf71513 Modified module parser to improve parsing of import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
815 namesLines = (m.group("ImportFromList")
a84cadf71513 Modified module parser to improve parsing of import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
816 .replace("(", "").replace(")", "")
a84cadf71513 Modified module parser to improve parsing of import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
817 .replace("\\", "")
a84cadf71513 Modified module parser to improve parsing of import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
818 .strip().splitlines())
a84cadf71513 Modified module parser to improve parsing of import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
819 namesLines = [line.split("#")[0].strip()
a84cadf71513 Modified module parser to improve parsing of import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
820 for line in namesLines]
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
821 names = [n.strip() for n in
4182
a84cadf71513 Modified module parser to improve parsing of import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
822 "".join(namesLines)
a84cadf71513 Modified module parser to improve parsing of import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
823 .split(',')]
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
824 if mod not in self.from_imports:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
825 self.from_imports[mod] = []
4182
a84cadf71513 Modified module parser to improve parsing of import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
826 self.from_imports[mod].extend(
a84cadf71513 Modified module parser to improve parsing of import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
827 [name for name in names
a84cadf71513 Modified module parser to improve parsing of import statements.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
828 if name not in self.from_imports[mod]])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
829
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
830 elif m.start("ConditionalDefine") >= 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
831 # a conditional function/method definition
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
832 thisindent = _indent(m.group("ConditionalDefineIndent"))
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
833 while (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
834 conditionalsstack and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
835 conditionalsstack[-1] >= thisindent
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
836 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
837 del conditionalsstack[-1]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
838 if deltastack:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
839 del deltastack[-1]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
840 conditionalsstack.append(thisindent)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
841 deltaindentcalculated = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
842
6813
7f4cfe76b90c Ignore triple quotes in comments.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6735
diff changeset
843 elif m.start("Comment") >= 0:
6815
b1b833693a38 pyclbr, ModuleParser: reworked the fix contributed by Tobias and fixed an issue introduced by it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6813
diff changeset
844 if modulelevel:
b1b833693a38 pyclbr, ModuleParser: reworked the fix contributed by Tobias and fixed an issue introduced by it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6813
diff changeset
845 continue
6813
7f4cfe76b90c Ignore triple quotes in comments.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6735
diff changeset
846
6815
b1b833693a38 pyclbr, ModuleParser: reworked the fix contributed by Tobias and fixed an issue introduced by it.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6813
diff changeset
847 modulelevel = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
848
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
849 def __rb_scan(self, src):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
850 """
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
851 Private method to scan the source text of a Python module and retrieve
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
852 the relevant information.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
853
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
854 @param src the source text to be scanned (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
855 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
856 lineno, last_lineno_pos = 1, 0
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 841
diff changeset
857 classstack = [] # stack of (class, indent) pairs
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
858 acstack = [] # stack of (access control, indent) pairs
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
859 indent = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
860 i = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
861 cur_obj = self
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
862 lastGlobalEntry = None
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
863 while True:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
864 m = self._getnext(src, i)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
865 if not m:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
866 break
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
867 start, i = m.span()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
868
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
869 if m.start("Method") >= 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
870 # found a method definition or function
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
871 thisindent = indent
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
872 indent += 1
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
873 meth_name = (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
874 m.group("MethodName") or
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
875 m.group("MethodName2") or
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
876 m.group("MethodName3")
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
877 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
878 meth_sig = m.group("MethodSignature")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
879 meth_sig = meth_sig and meth_sig.replace('\\\n', '') or ''
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
880 lineno = lineno + src.count('\n', last_lineno_pos, start)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
881 last_lineno_pos = start
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
882 if meth_name.startswith('self.'):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
883 meth_name = meth_name[5:]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
884 elif meth_name.startswith('self::'):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
885 meth_name = meth_name[6:]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
886 # close all classes/modules indented at least as much
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
887 while classstack and classstack[-1][1] >= thisindent:
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
888 if (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
889 classstack[-1][0] is not None and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
890 isinstance(classstack[-1][0],
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
891 (Class, Function, RbModule))
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
892 ):
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
893 # record the end line of this class, function or module
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
894 classstack[-1][0].setEndLine(lineno - 1)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
895 del classstack[-1]
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
896 while acstack and acstack[-1][1] >= thisindent:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
897 del acstack[-1]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
898 if classstack:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
899 csi = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
900 while csi >= -len(classstack):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
901 # nested defs are added to the class
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
902 cur_class = classstack[csi][0]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
903 csi -= 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
904 if cur_class is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
905 continue
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
906
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
907 if (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
908 isinstance(cur_class, Class) or
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
909 isinstance(cur_class, RbModule)
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
910 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
911 # it's a class/module method
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
912 f = Function(None, meth_name,
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
913 None, lineno, meth_sig)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
914 cur_class.addMethod(meth_name, f)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
915 break
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
916 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
917 # it's a nested function of a module function
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
918 f = Function(
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
919 self.name, meth_name, self.file, lineno, meth_sig)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
920 self.addFunction(meth_name, f)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
921 # set access control
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
922 if acstack:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
923 accesscontrol = acstack[-1][0]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
924 if accesscontrol == "private":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
925 f.setPrivate()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
926 elif accesscontrol == "protected":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
927 f.setProtected()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
928 elif accesscontrol == "public":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
929 f.setPublic()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
930 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
931 # it's a function
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
932 f = Function(
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
933 self.name, meth_name, self.file, lineno, meth_sig)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
934 self.addFunction(meth_name, f)
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
935 if not classstack:
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
936 if lastGlobalEntry:
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
937 lastGlobalEntry.setEndLine(lineno - 1)
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
938 lastGlobalEntry = f
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
939 if cur_obj and isinstance(cur_obj, Function):
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
940 cur_obj.setEndLine(lineno - 1)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
941 cur_obj = f
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 841
diff changeset
942 classstack.append((None, thisindent)) # Marker for nested fns
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
943
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
944 elif m.start("Docstring") >= 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
945 contents = m.group("DocstringContents")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
946 if contents is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
947 contents = _hashsub(r"\1", contents)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
948 if cur_obj:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
949 cur_obj.addDescription(contents)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
950
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
951 elif m.start("String") >= 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
952 pass
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
953
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
954 elif m.start("Comment") >= 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
955 pass
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
956
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
957 elif m.start("ClassIgnored") >= 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
958 pass
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
959
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
960 elif m.start("Class") >= 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
961 # we found a class definition
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
962 thisindent = indent
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
963 indent += 1
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
964 lineno = lineno + src.count('\n', last_lineno_pos, start)
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
965 last_lineno_pos = start
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
966 # close all classes/modules indented at least as much
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
967 while classstack and classstack[-1][1] >= thisindent:
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
968 if (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
969 classstack[-1][0] is not None and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
970 isinstance(classstack[-1][0],
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
971 (Class, Function, RbModule))
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
972 ):
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
973 # record the end line of this class, function or module
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
974 classstack[-1][0].setEndLine(lineno - 1)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
975 del classstack[-1]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
976 class_name = m.group("ClassName") or m.group("ClassName2")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
977 inherit = m.group("ClassSupers")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
978 if inherit:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
979 # the class inherits from other classes
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
980 inherit = inherit[1:].strip()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
981 inherit = [_commentsub('', inherit)]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
982 # remember this class
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
983 cur_class = Class(self.name, class_name, inherit,
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
984 self.file, lineno)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
985 # add nested classes to the file
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
986 if classstack and isinstance(classstack[-1][0], RbModule):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
987 parent_obj = classstack[-1][0]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
988 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
989 parent_obj = self
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
990 if class_name in parent_obj.classes:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
991 cur_class = parent_obj.classes[class_name]
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
992 elif (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
993 classstack and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
994 isinstance(classstack[-1][0], Class) and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
995 class_name == "self"
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
996 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
997 cur_class = classstack[-1][0]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
998 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
999 parent_obj.addClass(class_name, cur_class)
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
1000 if not classstack:
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
1001 if lastGlobalEntry:
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
1002 lastGlobalEntry.setEndLine(lineno - 1)
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
1003 lastGlobalEntry = cur_class
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1004 cur_obj = cur_class
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1005 classstack.append((cur_class, thisindent))
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1006 while acstack and acstack[-1][1] >= thisindent:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1007 del acstack[-1]
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
1008 acstack.append(["public", thisindent])
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
1009 # default access control is 'public'
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1010
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1011 elif m.start("Module") >= 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1012 # we found a module definition
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1013 thisindent = indent
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1014 indent += 1
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
1015 lineno = lineno + src.count('\n', last_lineno_pos, start)
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
1016 last_lineno_pos = start
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1017 # close all classes/modules indented at least as much
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1018 while classstack and classstack[-1][1] >= thisindent:
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1019 if (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1020 classstack[-1][0] is not None and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1021 isinstance(classstack[-1][0],
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1022 (Class, Function, RbModule))
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1023 ):
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
1024 # record the end line of this class, function or module
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
1025 classstack[-1][0].setEndLine(lineno - 1)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1026 del classstack[-1]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1027 module_name = m.group("ModuleName")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1028 # remember this class
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1029 cur_class = RbModule(self.name, module_name,
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2997
diff changeset
1030 self.file, lineno)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1031 # add nested Ruby modules to the file
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
1032 if module_name in self.modules:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1033 cur_class = self.modules[module_name]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1034 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1035 self.addModule(module_name, cur_class)
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
1036 if not classstack:
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
1037 if lastGlobalEntry:
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
1038 lastGlobalEntry.setEndLine(lineno - 1)
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
1039 lastGlobalEntry = cur_class
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1040 cur_obj = cur_class
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1041 classstack.append((cur_class, thisindent))
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1042 while acstack and acstack[-1][1] >= thisindent:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1043 del acstack[-1]
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
1044 acstack.append(["public", thisindent])
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
1045 # default access control is 'public'
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1046
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1047 elif m.start("AccessControl") >= 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1048 aclist = m.group("AccessControlList")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1049 if aclist is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1050 index = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1051 while index >= -len(acstack):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1052 if acstack[index][1] < indent:
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1053 actype = (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1054 m.group("AccessControlType") or
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
1055 m.group("AccessControlType2").split('_')[0]
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1056 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1057 acstack[index][0] = actype.lower()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1058 break
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1059 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1060 index -= 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1061 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1062 index = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1063 while index >= -len(classstack):
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1064 if (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1065 classstack[index][0] is not None and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1066 not isinstance(classstack[index][0], Function) and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1067 not classstack[index][1] >= indent
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1068 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1069 parent = classstack[index][0]
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1070 actype = (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1071 m.group("AccessControlType") or
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
1072 m.group("AccessControlType2").split('_')[0]
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1073 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1074 actype = actype.lower()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1075 for name in aclist.split(","):
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
1076 # get rid of leading ':'
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
1077 name = name.strip()[1:]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1078 acmeth = parent.getMethod(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1079 if acmeth is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1080 continue
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1081 if actype == "private":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1082 acmeth.setPrivate()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1083 elif actype == "protected":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1084 acmeth.setProtected()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1085 elif actype == "public":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1086 acmeth.setPublic()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1087 break
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1088 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1089 index -= 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1090
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1091 elif m.start("Attribute") >= 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1092 lineno = lineno + src.count('\n', last_lineno_pos, start)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1093 last_lineno_pos = start
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1094 index = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1095 while index >= -len(classstack):
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1096 if (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1097 classstack[index][0] is not None and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1098 not isinstance(classstack[index][0], Function) and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1099 not classstack[index][1] >= indent
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1100 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1101 attrName = m.group("AttributeName")
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
1102 attr = Attribute(
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
1103 self.name, attrName, self.file, lineno)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1104 if attrName.startswith("@@") or attrName[0].isupper():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1105 classstack[index][0].addGlobal(attrName, attr)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1106 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1107 classstack[index][0].addAttribute(attrName, attr)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1108 break
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1109 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1110 index -= 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1111 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1112 attrName = m.group("AttributeName")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1113 if attrName[0] != "@":
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
1114 attr = Attribute(
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
1115 self.name, attrName, self.file, lineno)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1116 self.addGlobal(attrName, attr)
2768
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
1117 if lastGlobalEntry:
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
1118 lastGlobalEntry.setEndLine(lineno - 1)
eab35f6e709f Added support to show the current class/method name in the combo boxes at the top of the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2396
diff changeset
1119 lastGlobalEntry = None
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1120
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1121 elif m.start("Attr") >= 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1122 lineno = lineno + src.count('\n', last_lineno_pos, start)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1123 last_lineno_pos = start
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1124 index = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1125 while index >= -len(classstack):
7259
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1126 if (
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1127 classstack[index][0] is not None and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1128 not isinstance(classstack[index][0], Function) and
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1129 not classstack[index][1] >= indent
7c017076c12e Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1130 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1131 parent = classstack[index][0]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1132 if m.group("AttrType") is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1133 nv = m.group("AttrList").split(",")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1134 if not nv:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1135 break
2997