Skip to content

Commit d388b34

Browse files
committed
Рефакторинг. Исправление мелких ошибок.
1 parent ecf3517 commit d388b34

File tree

3 files changed

+32
-33
lines changed

3 files changed

+32
-33
lines changed

pre-commit

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
#!/bin/sh
2-
32
echo "Start hooks before commit for v8unpack erf and epf"
43
python.exe .git/hooks/pyv8unpack.py --g --index

precommit1c.ini.example

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[DEFAULT]
2-
onecplatfrorms = D:\environ\onec\1cv8\8.3.4.465\bin\1cv8.exe
3-
source = plugin_source
1+
[default]
2+
onec_platform=D:\environ\onec\1cv8\8.3.4.465\bin\1cv8.exe
3+
source=plugin_source

pyv8unpack.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
def get_config_param(param):
2222
"""
23-
Parse config file and find in them source dir
23+
Parse config file and find source dir in it
2424
"""
2525
curdir = os.curdir
2626
if '__file__' in globals():
@@ -41,8 +41,8 @@ def get_config_param(param):
4141
except IOError:
4242
pass
4343

44-
if config is not None and config.has_option('DEFAULT', param):
45-
value = config.get('DEFAULT', param)
44+
if config is not None and config.has_option('default', param):
45+
value = config.get('default', param)
4646
return value
4747

4848
return None
@@ -52,19 +52,19 @@ def get_path_to_1c():
5252
"""
5353
Get path to 1c binary.
5454
First env, 'PATH1C'
55-
Second env 'PROGRAMFILES' on windows
56-
Third /opt/1c - only linux
55+
Second env 'PROGRAMFILES' (only Windows)
56+
Third '/opt/1c' (only Linux)
5757
"""
5858
cmd = os.getenv('PATH1C')
5959
if cmd is not None:
6060
cmd = os.path.join(cmd, '1cv8')
6161
maxversion = max(list(filter((lambda x: '8.' in x), os.listdir(cmd))))
6262
if maxversion is None:
63-
raise Exception('Not found verion dirs')
63+
raise Exception('Not found version dirs')
6464
cmd = os.path.join(cmd, maxversion + os.path.sep + 'bin' + os.path.sep + '1cv8.exe')
6565

6666
if not os.path.isfile(cmd):
67-
raise Exception('File not found %s' % cmd)
67+
raise Exception('File not found {}'.format(cmd))
6868

6969
return cmd
7070

@@ -73,27 +73,27 @@ def get_path_to_1c():
7373
if '__file__' in globals():
7474
curdir = os.path.dirname(os.path.abspath(__file__))
7575

76-
onecplatfrorm_config = get_config_param('onecplatfrorm')
77-
if onecplatfrorm_config is not None:
78-
return onecplatfrorm_config
76+
onec_platform_config = get_config_param('onec_platform')
77+
if onec_platform_config is not None:
78+
return onec_platform_config
7979

8080
if platform.system() == 'Darwin':
8181
raise Exception('MacOS not run 1C')
8282
elif platform.system() == 'Windows':
8383
program_files = os.getenv('PROGRAMFILES(X86)')
8484
if program_files is None:
85-
# FIXME: проверить архитектуру
85+
# fixme Проверить архитектуру
8686
program_files = os.getenv('PROGRAMFILES')
8787
if program_files is None:
88-
raise Exception('Path to Program files not found')
88+
raise Exception('Path to "Program files" not found')
8989
cmd = os.path.join(program_files, '1cv8')
9090
maxversion = max(list(filter((lambda x: '8.' in x), os.listdir(cmd))))
9191
if maxversion is None:
92-
raise Exception('Not found verion dirs')
92+
raise Exception('Not found version dirs')
9393
cmd = os.path.join(cmd, maxversion + os.path.sep + 'bin' + os.path.sep + '1cv8.exe')
9494

9595
if not os.path.isfile(cmd):
96-
raise Exception('file not found %s' % cmd)
96+
raise Exception('File not found {}'.format(cmd))
9797

9898
else:
9999
cmd = subprocess.Popen(['which', '1cv8'], stdout=subprocess.PIPE).communicate()[0].strip()
@@ -103,7 +103,7 @@ def get_path_to_1c():
103103

104104
def get_list_of_comitted_files():
105105
"""
106-
Return a list of files abouts to be decompile
106+
Return the list of files to be decompiled
107107
"""
108108
files = []
109109
output = []
@@ -140,10 +140,10 @@ def decompile(list_of_files, source=None, platform_=None):
140140
# Find datapocessor files
141141
for filename in list_of_files:
142142
# Check the file extensions
143-
logging.debug('File to check %s' % filename)
143+
logging.debug('File to check {}'.format(filename))
144144
if filename[-3:] in ['epf', 'erf']:
145145
dataprocessor_files.append(filename)
146-
logging.debug('File %s' % filename)
146+
logging.debug('File {}'.format(filename))
147147
continue
148148
if len(dataprocessor_files) == 0:
149149
exit(exit_code)
@@ -168,7 +168,7 @@ def decompile(list_of_files, source=None, platform_=None):
168168
returnlist = []
169169

170170
for filename in dataprocessor_files:
171-
logging.info('File %s' % filename)
171+
logging.info('File {}'.format(filename))
172172

173173
fullpathfile = os.path.abspath(filename)
174174
basename = os.path.splitext(os.path.basename(filename))[0]
@@ -193,33 +193,33 @@ def decompile(list_of_files, source=None, platform_=None):
193193
if os.path.isabs(newdirname):
194194
newsourcepath = os.path.join(dirsource, basename)
195195
if not os.path.exists(newsourcepath):
196-
logging.debug('create new dir %s' % newsourcepath)
196+
logging.debug('create new dir {}'.format(newsourcepath))
197197
os.makedirs(newsourcepath)
198198
else:
199199
shutil.rmtree(newsourcepath, ignore_errors=True)
200200

201-
logging.debug('file to copy %s, new path %s, new file %s' % (filename, newsourcepath,
201+
logging.debug('File to copy {}, new path {}, new file {}'.format(filename, newsourcepath,
202202
os.path.join(newsourcepath, fullbasename)))
203203

204-
formatstring = format('/C"decompile;pathtocf;%s;pathout;%s;ЗавершитьРаботуПосле;"' %
205-
(fullpathfile, newsourcepath))
204+
formatstring = format('/C"decompile;pathtocf;{};pathout;{};ЗавершитьРаботуПосле;"'.format(fullpathfile,
205+
newsourcepath))
206206
base = '/F"' + os.path.join(curabsdirpath, '.git', 'hooks', 'ibService') + '"'
207207
v8_reader = '/execute"' + os.path.join(curabsdirpath, '.git', 'hooks', 'v8Reader', 'V8Reader.epf') + '"'
208208
tempbat = tempfile.mktemp('.bat')
209-
logging.debug('formatstring is %s , base is %s, V8Reader is %s, temp is %s' % (formatstring, base, v8_reader,
210-
tempbat))
209+
logging.debug('Formatstring is {} , base is {}, V8Reader is {}, temp is {}'.format(formatstring,
210+
base, v8_reader, tempbat))
211211

212212
with open(tempbat, 'w', encoding='cp866') as temp:
213213
temp.write('@echo off\n')
214-
temp.write(format('"%s" %s /DisableStartupMessages %s %s' % (pathbin1c, base, v8_reader, formatstring)))
214+
temp.write(format('"{}" {} /DisableStartupMessages {} {}'.format(pathbin1c, base, v8_reader, formatstring)))
215215
temp.close()
216216
result = subprocess.check_call(['cmd.exe', '/C', tempbat])
217-
assert result == 0, format('Не удалось разобрать обработку %s' % fullpathfile)
217+
assert result == 0, format('Не удалось разобрать обработку {}'.format(fullpathfile))
218218
if not result == 0:
219-
logging.error(format('Не удалось разобрать обработку %s' % fullpathfile))
220-
raise format('Не удалось разобрать обработку %s' % fullpathfile)
219+
logging.error(format('Не удалось разобрать обработку {}'.format(fullpathfile)))
220+
raise format('Не удалось разобрать обработку {}'.format(fullpathfile))
221221
returnlist.append(newsourcepath)
222-
logging.info('Разобран в %s' % newsourcepath)
222+
logging.info('Разобран в {}'.format(newsourcepath))
223223

224224
return returnlist
225225

0 commit comments

Comments
 (0)