1414
1515modified = re .compile ('^(?:M|A)(\s+)(?P<name>.*)' )
1616
17- def get_path_to_1c ():
17+
18+ def get_config_param (param ):
1819 '''
20+ parse config file and find in them source dir
21+ '''
22+
23+ curdir = os .curdir
24+ if '__file__' in globals ():
25+ curdir = os .path .dirname (os .path .abspath (__file__ ))
26+
27+
28+ config = None
29+ for loc in curdir , os .curdir , os .path .expanduser ("~" ):
30+ try :
31+ with open (os .path .join (loc , "precommit1c.ini" )) as source :
32+ if sys .version_info < (3 ,0 ,0 ):
33+ from ConfigParser import ConfigParser
34+ else :
35+ from configparser import ConfigParser
36+
37+ config = ConfigParser ()
38+ config .read_file (source )
39+ break
40+ except IOError :
41+ pass
42+
43+ if not config is None and config .has_option ("DEFAULT" , param ):
44+ value = config .get ("DEFAULT" , param )
45+ return value
46+
47+
48+ return None
49+
50+
51+ def get_path_to_1c ():
52+ """
1953 get path to 1c binary.
2054 fist env, "PATH1C"
2155 two env "PROGRAMFILES" on windows
2256 three /opt/1c - only linux
2357
24- '''
58+ """
2559
2660 cmd = os .getenv ("PATH1C" )
2761 if not cmd is None :
@@ -37,29 +71,16 @@ def get_path_to_1c():
3771 return cmd
3872
3973 #read config
74+
75+
4076 curdir = os .curdir
4177 if '__file__' in globals ():
4278 curdir = os .path .dirname (os .path .abspath (__file__ ))
4379
44- config = None
45- for loc in curdir , os .curdir , os .path .expanduser ("~" ):
46- try :
47- with open (os .path .join (loc , "precommit1c.ini" )) as source :
48- if sys .version_info < (3 ,0 ,0 ):
49- from ConfigParser import ConfigParser
50- else :
51- from configparser import ConfigParser
52-
53- config = ConfigParser ()
54- config .read_file (source )
55- break
56- except IOError :
57- pass
58-
59- if not config is None and config .has_option ("DEFAULT" , "onecplatfrorm" ):
60- cmd = config .get ("DEFAULT" , "onecplatfrorm" )
61- return cmd
6280
81+ onecplatfrorm_config = get_config_param ("onecplatfrorm" )
82+ if not onecplatfrorm_config is None :
83+ return onecplatfrorm_config
6384
6485 if platform .system () == "Darwin" :
6586 raise Exception ("MacOS not run 1C" )
@@ -128,8 +149,12 @@ def decompile():
128149 continue
129150 if len (dataprocessor_files ) == 0 :
130151 exit (exit_code )
152+
153+ source_dir = get_config_param ("source" )
154+ if source_dir is None :
155+ source_dir = "src"
131156
132- dirsource = os .path .abspath (os .path .join (os .path .curdir , "plugins-source" ))
157+ dirsource = os .path .abspath (os .path .join (os .path .curdir , source_dir ))
133158 curabsdirpath = os .path .abspath (os .path .curdir )
134159 #pathbin1c = "C:\\Program Files\\1cv82\8.2.17.153\\bin\\1cv8.exe"
135160 #pathbin1c = "c:\\Program Files (x86)\\1cv8\\8.3.4.304\\bin\\1cv8.exe"
0 commit comments