forked from QQuick/Opy
-
Notifications
You must be signed in to change notification settings - Fork 2
/
settings.py
100 lines (94 loc) · 3.37 KB
/
settings.py
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
import io
import six
isPython2 = six.PY2
isLibraryInvoked = False
printHelp = False
sourceRootDirectory = None
targetRootDirectory = None
configFilePath = None # None == default, False == use configSettings
class ConfigSettings :
"""
See opy_config.txt for details on these settings.
"""
def __init__( self ) :
self.obfuscate_strings = True
self.obfuscated_name_tail = '_opy_'
self.plain_marker = '_opy_'
self.pep8_comments = False
self.source_extensions = [ 'py', 'pyx' ]
self.skip_extensions = [
'pyc'
,'txt'
,'project' # Eclipse/PyDev IDE files/folders
,'pydevproject'
,'settings'
]
self.skip_path_fragments = [
'opy_config.txt'
,'opy_config.py'
]
self.external_modules = [
're'
,'os'
,'sys'
,'io'
,'errno'
,'keyword'
,'importlib'
,'random'
,'codecs'
,'shutil'
,'traceback'
,"collections"
,"json"
,"datetime"
]
self.replacement_modules = {}
self.plain_files = []
self.plain_names = []
self.mask_external_modules = True
self.skip_public = False
self.subset_files = []
self.dry_run = False
self.prepped_only = False
def __str__( self ):
# TODO : rewrite this in a more clean/clever manner...
text = (
"obfuscate_strings = %s\n" % str(self.obfuscate_strings)
+ "obfuscated_name_tail = '%s'\n" % self.obfuscated_name_tail
+ "plain_marker = '%s'\n" % self.plain_marker
+ "pep8_comments = %s\n" % str(self.pep8_comments)
+ "mask_external_modules = %s\n" % str(self.mask_external_modules)
+ "skip_public = %s\n" % str(self.skip_public)
+ "dry_run = %s\n" % str(self.dry_run)
+ "prepped_only = %s\n" % str(self.prepped_only)
)
text += "source_extensions ='''\n"
for item in self.source_extensions : text += "%s\n" % item
text += "'''\n"
text += "skip_extensions ='''\n"
for item in self.skip_extensions : text += "%s\n" % item
text += "'''\n"
text += "skip_path_fragments ='''\n"
for item in self.skip_path_fragments : text += "%s\n" % item
text += "'''\n"
text += "external_modules ='''\n"
for item in self.external_modules : text += "%s\n" % item
text += "'''\n"
text += "replacement_modules ='''\n"
for k,v in six.iteritems( self.replacement_modules ) :
text += "%s:%s\n" % (k,v)
text += "'''\n"
text += "plain_files ='''\n"
for item in self.plain_files : text += "%s\n" % item
text += "'''\n"
text += "plain_names ='''\n"
for item in self.plain_names : text += "%s\n" % item
text += "'''\n"
text += "subset_files ='''\n"
for item in self.subset_files : text += "%s\n" % item
text += "'''\n"
return text
def toVirtualFile( self ):
return io.StringIO( unicode(str(self)) if six.PY2 else str(self) )
configSettings = ConfigSettings()