Repository navigation
Expand file tree
/
Copy pathdefaultconfig.py
More file actions
171 lines (141 loc) · 5.26 KB
/
Copy pathdefaultconfig.py
File metadata and controls
171 lines (141 loc) · 5.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/usr/bin/env python
# -*- coding: utf-8 -*-
## number of spaces to indent each block
indent = 4
## prefix for comments
commentPrefix = '##'
## move inner class definitions to the top of their outer class.
## allows the outer class to reference the inner class definition
## later in its definition.
bubbleInnerClasses = True
## if True, classes are scanned for methods that look like accessors.
## Matching methods are renamed and declared as properties.
fixPropMethods = True
## if True, classes are scanned for duplicate method names. Matching
## methods are augmented with the '@overloaded' decorator.
fixOverloadMethods = True
## if True, class methods are sorted by name before output.
sortClassMethods = False
## if True, method modifiers are written as comments prior to method
## declarations.
writeModifiersComments = False
## if True, a default docstring is generated for class statements.
writeClassDocString = True
## if True, a default docstring is generated for method statements.
writeMethodDocString = False
## if True, and if input source contains a "public static void main"
## method, a block is written to the end of the file to call the class
## method with sys.argv.
writeMainMethodScript = True
## if True, classes without base classes will instead inherit from
## object.
classesInheritObject = True
## minimum parameter count to trigger indentation of parameter names
## in method declarations. set to 0 to disable.
minIndentParams = 5
## Note about modulePreamble and moduleEpilogue:
##
## Items in both of these lists may be strings or callables. If
## they're callables, they should take a single argument. The Module
## object will be passed as this single argument in the case of
## callables.
## lines written at the beginning of each generated module. this value
## is cumulative, so when user-defined configuration modules specify
## this value, those lines are written after these.
modulePreamble = [
'#!/usr/bin/env python',
'# -*- coding: utf-8 -*-',
'',
]
## lines written at the end of each generated module. this value is
## cumulative, so user-defined configuration modules may specify
## additional values.
moduleEpilogue = [
]
## regular expression substitutions performed on source after
## generation but before final output. this value is cumulative, so
## user-defined configuration modules can add augment these with their
## own. each value in this list is a two-tuple of (pattern, repl).
## see the 're' module docs, specifically the re.sub function.
outputSubs = [
(r'(\.self\.)', '.'),
(r'String\.valueOf\((.*?)\)', r'str(\1)'),
(r'System\.out\.println\((.*?)\)', r'print \1'),
(r'(.*?)\.equals\((.*?)\)', r'\1 == \2'),
(r'(.*?)\.equalsIgnoreCase\((.*?)\)', r'\1.lower() == \2.lower()'),
(r'([\w.]+)\.size\(\)', r'len(\1)'),
(r'(\w+)\.get\((.*?)\)', r'\1[\2]'),
(r'(\s)(\S*?)(\.toString\(\))', r'\1str(\2)'),
(r'(\s)(\S*?)(\.length\(\))', r'\1len(\2)'),
]
## mapping of java type names to python type names. user-defined
## configuration modules can replace and/or augment this mapping.
typeTypeMap = {
'String':'str',
'int':'int',
'double':'float',
'Vector':'list',
'boolean':'bool',
'char':'str',
}
## mapping of java type values to python type values. user-defined
## configuration modules can replace and/or augment this mapping.
typeValueMap = {
'String':'""',
'int':'0',
'double':'0.0',
'Vector':'[]',
'boolean':'False',
'str':'""',
}
## method name mapping. user-defined configuration modules can
## replace and/or augment this with their own.
renameMethodMap = {
'equals':'__eq__',
'is':'is_',
}
## generic name mapping. user-defined configuration modules can
## replace and/or augment this with their own.
renameAnyMap = {
'this':'self',
'null':'None',
'false':'False',
'true':'True',
'is':'is_',
'str':'strval',
}
## method type modifier mapping. when input methods have modifiers
## with matching names, those names are replaced with their
## corresponding statements from this mapping. this value can be
## replaced and/or augmented via user-defined configuration modules.
modifierDecoratorMap = {
'synchronized':'@synchronized(mlock)',
'static':'@classmethod',
}
baseClassMembers = {
'Thread':['MAX_PRIORITY', 'MIN_PRIORITY', 'NORM_PRIORITY',
'activeCount', 'checkAccess', 'countStackFrames',
'currentThread', 'destroy', 'dumpStack',
'enumerate', 'getContextClassLoader', 'getName',
'getPriority', 'getThreadGroup', 'holdsLock',
'interrupt', 'interrupted', 'isAlive',
'isDaemon', 'isInterrupted', 'join',
'resume', 'run', 'setContextClassLoader',
'setDaemon', 'setName', 'setPriority',
'sleep', 'start', 'stop', 'suspend', 'toString', 'yield',
],
}
variableNameMapping = {
'str':'strval',
'is':'is_',
}
exceptionTypeMapping = {
'NoSuchFieldError':'AttributeError',
'NoSuchMethodException':'AttributeError',
}
## define this name in your configuration modules to sort decorators
## before they're output. example follows.
methodPreambleSorter = None
## use a block like this to sort decorators by name.
## def methodPreambleSorter(a, b):
## return cmp(a, b)