vanessa-behavior 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CONTRIBUTORS.md +4 -0
- data/LICENSE +202 -0
- data/README.md +101 -0
- data/ROADMAP.md +18 -0
- data/bin/keep.me +0 -0
- data/bin/vanessa-behavior.exe +0 -0
- data/config/cucumber.yml +7 -0
- data/features/EpfBehavePleer.feature +5 -0
- data/features/step_definitions/ones_remote_tests.wire +2 -0
- data/features/step_definitions/wire_protocol.epf +0 -0
- data/features/support/env.rb +1 -0
- data/features/wire_protocol.feature +337 -0
- data/lib/TemplateEpf/Temp/ObjectModule_ExampleAccounting.txt +0 -0
- data/lib/TemplateEpf/Temp/ObjectModule_example-accounting.txt +0 -0
- data/lib/TemplateEpf/Temp/ObjectModule_wire_protocol.txt +0 -0
- data/lib/TemplateEpf/Temp/keep.me +0 -0
- data/lib/TemplateEpf/renames.txt +7 -0
- data/lib/TemplateEpf/und/79a499cc-1782-4a2f-abe7-61ea4d49fd5a +37 -0
- data/lib/TemplateEpf/und/7a39ab7a-5023-41fd-ae4c-8d0e903c5cba.0/info +1 -0
- data/lib/TemplateEpf/und/8aa13ab8-188a-4f59-be4f-031aa5450c90.0/info +1 -0
- data/lib/TemplateEpf/und/copyinfo +7 -0
- data/lib/TemplateEpf/und/d4666efc-32c5-4cbe-a642-505988996654 +17 -0
- data/lib/TemplateEpf/und/root +1 -0
- data/lib/TemplateEpf/und/version +3 -0
- data/lib/TemplateEpf/und/versions +1 -0
- data/lib/UnpackV8.exe +0 -0
- data/tasks/developers.start.cmd +13 -0
- data/vanessa-behavior.os +1278 -0
- data/vendor/precommit1c/README.md +89 -0
- data/vendor/precommit1c/copy-to-hook.cmd +11 -0
- data/vendor/precommit1c/ibService/1Cv8.1CD +0 -0
- data/vendor/precommit1c/pre-commit +4 -0
- data/vendor/precommit1c/precommit1c.ini.example +3 -0
- data/vendor/precommit1c/pyv8unpack.py +370 -0
- data/vendor/precommit1c/tests/Fixture.epf +0 -0
- data/vendor/precommit1c/tests/TestFixture.cmd +13 -0
- data/vendor/precommit1c/tests/test_compile.py +113 -0
- data/vendor/precommit1c/v8Reader/LICENSE +202 -0
- data/vendor/precommit1c/v8Reader/README.md +35 -0
- data/vendor/precommit1c/v8Reader/V8Reader.epf +0 -0
- metadata +114 -0
@@ -0,0 +1,89 @@
|
|
1
|
+
## Набор утилит для автоматической разборки/сборки внешних обработок и отчетов, при помещении(commit) в git.
|
2
|
+
|
3
|
+
### Что к чему
|
4
|
+
----
|
5
|
+
* pyv8unpack.py - python скрипт, получающий список помещаемых файлов при коммите, фильтрующий по расширению только внешние обработки/отчеты и запускающий внешнюю обработку для распаковки этих файлов.
|
6
|
+
* [V8Reader.epf](http://infostart.ru/public/106310/) - внешняя обработка 1С, которая с помощью [v8unpack](http://svn2.assembla.com/svn/V8Unpack/track/) разбирает внешние обработки, определяет нормальные наименования для каталогов форм, файлов модулей объектов и т.д. и раскладывает их в нормальную структуру папок.
|
7
|
+
* ibService - сервисная база данных на 1С, для запуска V8Reader.epf
|
8
|
+
* pre-commit - собственно командный файл вызываемый git перед каждым помещением. Выполняет роль простой запускалки скрипта pyv8unpack.py
|
9
|
+
|
10
|
+
### Установка
|
11
|
+
|
12
|
+
1. Зависимости:
|
13
|
+
* python 3.3
|
14
|
+
* установленная платформа 1С предприятия.
|
15
|
+
* git
|
16
|
+
* в случаии запуска из под wine, необходим и msscriptcontrol.
|
17
|
+
|
18
|
+
2. По умолчанию считается, что пути к python.exe и git.exe находятса в переменной path, иначе необходимо указать явный путь в файлах pre-commit(для python) и pyv8unpack.py(для git)
|
19
|
+
|
20
|
+
3. Путь к платформе находит автоматически, в случаии стандатной установки 1С. Если необходимо указать явно путь к платформе, необходимо: Указать переменную окружения PATH1C c путем к каталогу, где установленна 1С
|
21
|
+
```
|
22
|
+
set PATH1C = d:\program\
|
23
|
+
```
|
24
|
+
или создать файл ini рядом с файлом скрипта pyv8unpack.py или в домашней папке в корне, с именем precommit1c.ini и содеражнием:
|
25
|
+
```
|
26
|
+
[DEFAULT]
|
27
|
+
onecplatfrorms = c:\program\1cv8\8.3.5.823\bin\1cv8.exe
|
28
|
+
```
|
29
|
+
|
30
|
+
4. Путь хранения исходных текстово разобранных обработок поумолчанию используется как **src** (для обеспечения совместимости со старыми версиями обработки), однако его можно переназначить в ini файле
|
31
|
+
```
|
32
|
+
[DEFAULT]
|
33
|
+
source = plugin_source
|
34
|
+
```
|
35
|
+
|
36
|
+
5. Флажок изменеяющий корневую папку хранения исходных текстово разобранных обработок поумолчанию используется как корневая папка (для обеспечения совместимости со старыми версиями обработки), однако его можно переназначить в ini файле. Если изменить флажок на True - в каждой корневой папаке внешних обработок будет создан подкаталог текстово разобранных обработок.
|
37
|
+
```
|
38
|
+
[DEFAULT]
|
39
|
+
source_in_source = False
|
40
|
+
```
|
41
|
+
|
42
|
+
6. Наконец содержимое каталога необходимо скопировать в каталог .git/hooks/ вашего проекта.
|
43
|
+
> *Примечание:* каталог .git по умолчанию скрыт.
|
44
|
+
|
45
|
+
```
|
46
|
+
.git\
|
47
|
+
hooks\
|
48
|
+
pre-commit
|
49
|
+
V8Reader.epf
|
50
|
+
ibService
|
51
|
+
pyv8unpack.py
|
52
|
+
```
|
53
|
+
|
54
|
+
##Запуск
|
55
|
+
|
56
|
+
После установки достаточно для проверки сделать commit для любого файла epf и в вашем репозитарии автоматически должна создаться папка *src* повторяющая полностью структуру проекта, те файлы которые были измененны или же добавленны распакуются в папки с аналогичным наименованием.
|
57
|
+
|
58
|
+
##Командная строка запуска
|
59
|
+
|
60
|
+
```
|
61
|
+
python pyv8unpack.py [-h] [--version] [-v] [--index] [--g] [--compile]
|
62
|
+
[--type TYPE] [--platform PLATFORM]
|
63
|
+
[inputPath] [output]
|
64
|
+
|
65
|
+
Утилита для автоматической распаковки внешних обработок
|
66
|
+
|
67
|
+
positional arguments:
|
68
|
+
inputPath Путь к файлам необходимым для распаковки
|
69
|
+
output Путь к каталогу, куда распаковывать
|
70
|
+
|
71
|
+
optional arguments:
|
72
|
+
-h, --help show this help message and exit
|
73
|
+
--version show program's version number and exit
|
74
|
+
-v, --verbose increases log verbosity for each occurence.
|
75
|
+
--index Добавляем в индекс исходники
|
76
|
+
--g Запуситить чтение индекса из git и определить список
|
77
|
+
файлов для разбора
|
78
|
+
--compile Собрать внешний файл/обработку
|
79
|
+
--type TYPE Тип файла для сборки epf, erf. По умолчанию авто epf
|
80
|
+
--platform PLATFORM Путь к платформе 1С
|
81
|
+
```
|
82
|
+
|
83
|
+
##Ограничения
|
84
|
+
|
85
|
+
Одинковыми именами файлы с разным расширением epf и erf называть не надо, т.к. каталоги с исходниками создаются только по наименованию без учета расширения и возможен конфликт.
|
86
|
+
Дополнительно необходима настройка git для возможности использования кирилических наименований внешних обработок ```git config --local core.quotepath false```
|
87
|
+
##Что внутри
|
88
|
+
|
89
|
+
как это работает: pyv8unpack.py повторяет полностью иерархию папок относительно корня репозитария только в папке SRC (от слова source) или ту которую вы определили в конфигурационном файлу , каждая для каждой измененной внешней обработки создается своя папка и туда с помощью v8unpack распаковывается помещаемая обработка, с помощью v8reader определяютса наименования макетов, форм, модуля обработки и переименовываются, переименования сохраняютса в служебном файле renames.txt , те файлы, которые невозмонжно определить или же носят чисто служебный характер, переносятса в каталог *und*
|
@@ -0,0 +1,11 @@
|
|
1
|
+
@echo off
|
2
|
+
|
3
|
+
@echo copy current version in bootstrap https://github.com/xUnitFor1C/xdd-bootstrap-1C
|
4
|
+
|
5
|
+
xcopy .\ibService .\..\..\.git\hooks\ibService\ /Y /E /F
|
6
|
+
xcopy .\pre-commit .\..\..\.git\hooks\ /Y /F
|
7
|
+
xcopy .\v8Reader.epf .\..\..\.git\hooks\ /Y /F
|
8
|
+
xcopy .\pyv8unpack.py .\..\..\.git\hooks\ /Y /F
|
9
|
+
|
10
|
+
cd .\..\..\
|
11
|
+
git config --local core.quotepath false
|
Binary file
|
@@ -0,0 +1,370 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
import os
|
5
|
+
import sys
|
6
|
+
import subprocess
|
7
|
+
import shutil
|
8
|
+
import logging
|
9
|
+
import tempfile
|
10
|
+
import re
|
11
|
+
import platform
|
12
|
+
import argparse
|
13
|
+
from subprocess import PIPE
|
14
|
+
|
15
|
+
__version__ = "0.0.3"
|
16
|
+
|
17
|
+
logging.basicConfig(level=logging.INFO) # DEBUG => print ALL msgs
|
18
|
+
log = logging.getLogger("pyv8unpack")
|
19
|
+
|
20
|
+
modified = re.compile('^(?:M|A)(\s+)(?P<name>.*)')
|
21
|
+
|
22
|
+
|
23
|
+
def get_config_param(param):
|
24
|
+
'''
|
25
|
+
parse config file and find in them source dir
|
26
|
+
'''
|
27
|
+
|
28
|
+
curdir = os.curdir
|
29
|
+
if '__file__' in globals():
|
30
|
+
curdir = os.path.dirname(os.path.abspath(__file__))
|
31
|
+
|
32
|
+
|
33
|
+
config = None
|
34
|
+
for loc in curdir, os.curdir, os.path.expanduser("~"):
|
35
|
+
try:
|
36
|
+
with open(os.path.join(loc, "precommit1c.ini")) as source:
|
37
|
+
if sys.version_info<(3,0,0):
|
38
|
+
from ConfigParser import ConfigParser # @NoMove @UnusedImport
|
39
|
+
else:
|
40
|
+
from configparser import ConfigParser
|
41
|
+
|
42
|
+
config = ConfigParser()
|
43
|
+
config.read_file(source)
|
44
|
+
break
|
45
|
+
except IOError:
|
46
|
+
pass
|
47
|
+
|
48
|
+
if not config is None and config.has_option("DEFAULT", param):
|
49
|
+
value = config.get("DEFAULT", param)
|
50
|
+
return value
|
51
|
+
|
52
|
+
|
53
|
+
return None
|
54
|
+
|
55
|
+
|
56
|
+
def get_path_to_1c():
|
57
|
+
"""
|
58
|
+
get path to 1c binary.
|
59
|
+
fist env, "PATH1C"
|
60
|
+
two env "PROGRAMFILES" on windows
|
61
|
+
three /opt/1c - only linux
|
62
|
+
|
63
|
+
"""
|
64
|
+
|
65
|
+
cmd = os.getenv("PATH1C")
|
66
|
+
if not cmd is None:
|
67
|
+
cmd = os.path.join(cmd, "1cv8")
|
68
|
+
maxversion = max(list(filter((lambda x: '8.' in x), os.listdir(cmd))))
|
69
|
+
if maxversion is None:
|
70
|
+
raise Exception("not found verion dirs")
|
71
|
+
cmd = os.path.join(cmd, maxversion+os.path.sep+"bin"+os.path.sep+"1cv8.exe")
|
72
|
+
|
73
|
+
if not os.path.isfile(cmd):
|
74
|
+
raise Exception("file not found %s" % (cmd))
|
75
|
+
|
76
|
+
return cmd
|
77
|
+
|
78
|
+
#read config
|
79
|
+
|
80
|
+
curdir = os.curdir
|
81
|
+
if '__file__' in globals():
|
82
|
+
curdir = os.path.dirname(os.path.abspath(__file__))
|
83
|
+
|
84
|
+
|
85
|
+
onecplatfrorm_config = get_config_param("onecplatfrorm")
|
86
|
+
if not onecplatfrorm_config is None:
|
87
|
+
return onecplatfrorm_config
|
88
|
+
|
89
|
+
if platform.system() == "Darwin":
|
90
|
+
raise Exception("MacOS not run 1C")
|
91
|
+
elif platform.system() == "Windows":
|
92
|
+
program_files = os.getenv("PROGRAMFILES(X86)")
|
93
|
+
if program_files is None:
|
94
|
+
#FIXME: проверить архетиктуру.
|
95
|
+
program_files = os.getenv("PROGRAMFILES")
|
96
|
+
if program_files is None:
|
97
|
+
raise "path to Program files not found";
|
98
|
+
cmd = os.path.join(program_files, "1cv8")
|
99
|
+
maxversion = max(list(filter((lambda x: '8.' in x), os.listdir(cmd))))
|
100
|
+
if maxversion is None:
|
101
|
+
raise Exception("not found verion dirs")
|
102
|
+
cmd = os.path.join(cmd, maxversion + os.path.sep + "bin"+os.path.sep+"1cv8.exe")
|
103
|
+
|
104
|
+
if not os.path.isfile(cmd):
|
105
|
+
raise Exception("file not found %s" % (cmd))
|
106
|
+
|
107
|
+
else:
|
108
|
+
cmd = subprocess.Popen(["which", "1cv8"], stdout=PIPE).communicate()[0].strip()
|
109
|
+
|
110
|
+
return cmd
|
111
|
+
|
112
|
+
def get_list_of_comitted_files():
|
113
|
+
"""
|
114
|
+
Retun a list of files abouts to be decompile
|
115
|
+
"""
|
116
|
+
files = []
|
117
|
+
output = []
|
118
|
+
try:
|
119
|
+
output = subprocess.check_output(['git','diff-index', '--name-status', '--cached','HEAD']
|
120
|
+
).decode("utf-8")
|
121
|
+
except subprocess.CalledProcessError:
|
122
|
+
try:
|
123
|
+
output = subprocess.check_output(['git', 'status', '--porcelain']).decode("utf-8")
|
124
|
+
except subprocess.CalledProcessError:
|
125
|
+
print("Error diff files get")
|
126
|
+
return files
|
127
|
+
|
128
|
+
for result in output.split("\n"):
|
129
|
+
logging.info(result)
|
130
|
+
if result != '':
|
131
|
+
match = modified.match(result)
|
132
|
+
if match:
|
133
|
+
files.append(match.group('name'))
|
134
|
+
|
135
|
+
return files
|
136
|
+
|
137
|
+
def decompile(list_of_files, source=None, platform=None):
|
138
|
+
"""
|
139
|
+
Main functions doing be decompile
|
140
|
+
возвращает list
|
141
|
+
"""
|
142
|
+
|
143
|
+
#list of files to decompile and results decompile
|
144
|
+
dataprocessor_files = []
|
145
|
+
|
146
|
+
#set the exit code
|
147
|
+
exit_code = 0
|
148
|
+
|
149
|
+
#Find datapocessor files
|
150
|
+
for filename in list_of_files:
|
151
|
+
#Check the file extensions
|
152
|
+
logging.debug("file to check %s" % filename)
|
153
|
+
if filename[-3:] in ['epf', 'erf']:
|
154
|
+
dataprocessor_files.append(filename)
|
155
|
+
logging.debug("file %s" % filename)
|
156
|
+
continue
|
157
|
+
if len(dataprocessor_files) == 0:
|
158
|
+
exit(exit_code)
|
159
|
+
|
160
|
+
source_dir = source or get_config_param("source")
|
161
|
+
if source_dir is None:
|
162
|
+
source_dir = "src"
|
163
|
+
|
164
|
+
#получаем флажок того, что исходники располагаются в подпапке источника
|
165
|
+
source_in_source = get_config_param("source_in_source")
|
166
|
+
if source_in_source is None:
|
167
|
+
source_in_source = False
|
168
|
+
else:
|
169
|
+
if source_in_source == "True":
|
170
|
+
source_in_source = True
|
171
|
+
else:
|
172
|
+
source_in_source = False
|
173
|
+
|
174
|
+
dirsource = os.path.abspath(os.path.join(os.path.curdir, source_dir))
|
175
|
+
curabsdirpath = os.path.abspath(os.path.curdir)
|
176
|
+
pathbin1c = platform or get_path_to_1c()
|
177
|
+
returnlist = []
|
178
|
+
|
179
|
+
for filename in dataprocessor_files:
|
180
|
+
logging.info("file %s" % filename)
|
181
|
+
|
182
|
+
fullpathfile = os.path.abspath(filename)
|
183
|
+
basename = os.path.splitext(os.path.basename(filename))[0]
|
184
|
+
fullbasename = os.path.basename(filename)
|
185
|
+
newdirname = os.path.dirname(filename)
|
186
|
+
|
187
|
+
#если исходники в подпаке источника, меняем путь
|
188
|
+
if source_in_source:
|
189
|
+
dirsource = os.path.abspath(os.path.join(os.path.curdir, newdirname, source_dir))
|
190
|
+
|
191
|
+
|
192
|
+
#Скопируем сначало просто структуру каталогов.
|
193
|
+
if not os.path.exists(dirsource):
|
194
|
+
os.makedirs(dirsource)
|
195
|
+
#для каждого файла определим новую папку.
|
196
|
+
if source_in_source:
|
197
|
+
logging.debug("{} {}".format(dirsource, basename))
|
198
|
+
newsourcepath = os.path.join(dirsource, basename)
|
199
|
+
else:
|
200
|
+
logging.debug("{} {} {}".format(dirsource, newdirname, basename))
|
201
|
+
newsourcepath = os.path.join(dirsource, newdirname, basename)
|
202
|
+
|
203
|
+
if(os.path.isabs(newdirname)):
|
204
|
+
newsourcepath = os.path.join(dirsource, basename)
|
205
|
+
if not os.path.exists(newsourcepath):
|
206
|
+
logging.debug("create new dir %s" % newsourcepath)
|
207
|
+
os.makedirs(newsourcepath)
|
208
|
+
else:
|
209
|
+
shutil.rmtree(newsourcepath, ignore_errors=True)
|
210
|
+
|
211
|
+
logging.debug("file to copy %s, new path %s, new file %s"
|
212
|
+
% (filename, newsourcepath, os.path.join(newsourcepath, fullbasename))
|
213
|
+
)
|
214
|
+
|
215
|
+
formatstring = format('/C"decompile;pathtocf;%s;pathout;%s;ЗавершитьРаботуПосле;"' % (fullpathfile, newsourcepath))
|
216
|
+
base = '/F"'+os.path.join(curabsdirpath,".git", "hooks","ibService")+'"'
|
217
|
+
V8Reader = '/execute"'+os.path.join(curabsdirpath,".git", "hooks", "v8Reader", "V8Reader.epf")+'"'
|
218
|
+
tempbat = tempfile.mktemp(".bat")
|
219
|
+
logging.debug("formatstring is %s , base is %s, V8Reader is %s, temp \
|
220
|
+
is %s" % (formatstring, base, V8Reader, tempbat))
|
221
|
+
|
222
|
+
with open(tempbat, 'w', encoding='cp866') as temp:
|
223
|
+
temp.write('@echo off\n')
|
224
|
+
temp.write(format('"%s" %s /DisableStartupMessages %s %s' % (pathbin1c,
|
225
|
+
base, V8Reader, formatstring))
|
226
|
+
)
|
227
|
+
temp.close()
|
228
|
+
result = subprocess.check_call(['cmd.exe', '/C', tempbat])
|
229
|
+
assert result == 0, format("Не удалось разобрать\
|
230
|
+
обработку %s" % (fullpathfile))
|
231
|
+
if not result == 0:
|
232
|
+
logging.error(format("Не удалось разобрать \
|
233
|
+
обработку %s" % (fullpathfile)))
|
234
|
+
raise format("Не удалось разобрать\
|
235
|
+
обработку %s" % (fullpathfile))
|
236
|
+
returnlist.append(newsourcepath)
|
237
|
+
logging.info("Разобран в %s" % (newsourcepath))
|
238
|
+
|
239
|
+
return returnlist
|
240
|
+
|
241
|
+
def add_to_git(pathlists):
|
242
|
+
|
243
|
+
for l in pathlists:
|
244
|
+
result = subprocess.check_call(['git', 'add', '--all', l])
|
245
|
+
if not result == 0:
|
246
|
+
logging.error(result)
|
247
|
+
exit(result)
|
248
|
+
|
249
|
+
def compilefromsource(input, output, ext):
|
250
|
+
import codecs
|
251
|
+
|
252
|
+
assert not input is None, "Не указан путь к входящему каталогу"
|
253
|
+
assert not output is None, "Не указан путь к исходящему файлу"
|
254
|
+
|
255
|
+
extfile = "epf" if ext == "auto" else ext
|
256
|
+
|
257
|
+
dirsource = os.path.abspath(os.path.join(os.path.curdir, input))
|
258
|
+
if not os.path.exists(dirsource) or not os.path.isdir(dirsource):
|
259
|
+
raise "Не существует входящего каталога"
|
260
|
+
|
261
|
+
renamesFile = os.path.join(dirsource, "renames.txt")
|
262
|
+
if not os.path.exists(renamesFile):
|
263
|
+
raise "Не существует файла {}".format(renamesFile)
|
264
|
+
tempPath = tempfile.mkdtemp()
|
265
|
+
|
266
|
+
with codecs.open(renamesFile, "rb", encoding='utf-8') as r:
|
267
|
+
lines = r.read()
|
268
|
+
lines = lines.split('\r\n')
|
269
|
+
for l in lines:
|
270
|
+
if l.startswith(u'\ufeff'):
|
271
|
+
l = l[1:]
|
272
|
+
listline = l.split("-->")
|
273
|
+
if len(listline) < 2:
|
274
|
+
continue
|
275
|
+
log.debug(l)
|
276
|
+
newPath = os.path.join(tempPath, listline[0])
|
277
|
+
dirname = os.path.dirname(newPath)
|
278
|
+
if not os.path.exists(dirname):
|
279
|
+
os.mkdir(dirname)
|
280
|
+
oldPath = os.path.join(dirsource,
|
281
|
+
listline[1].replace(
|
282
|
+
"\\", os.path.sep)
|
283
|
+
)
|
284
|
+
|
285
|
+
if os.path.isdir(oldPath):
|
286
|
+
#tempFile = tempfile.mkstemp()
|
287
|
+
newPath = os.path.join(tempPath, listline[0])
|
288
|
+
shutil.copytree(oldPath, newPath)
|
289
|
+
else:
|
290
|
+
log.debug(oldPath)
|
291
|
+
shutil.copy(
|
292
|
+
os.path.normpath(oldPath),
|
293
|
+
newPath
|
294
|
+
)
|
295
|
+
|
296
|
+
#вызовем v8unpack, для сборки файла из исходников.
|
297
|
+
tempFile = tempfile.mktemp("."+extfile)
|
298
|
+
log.debug('unpackv8 -B "{}" "{}"'.format('{}'.format(tempPath), tempFile))
|
299
|
+
result = subprocess.check_call(
|
300
|
+
['unpackv8',
|
301
|
+
'-B',
|
302
|
+
'{}'.format(tempPath),
|
303
|
+
tempFile]
|
304
|
+
)
|
305
|
+
|
306
|
+
log.debug("copy from {} to {}".format(tempFile, output))
|
307
|
+
assert result == 0, "Не удалось упаковать каталог {}".format(tempPath)
|
308
|
+
shutil.move(tempFile, output)
|
309
|
+
|
310
|
+
return output
|
311
|
+
|
312
|
+
def main():
|
313
|
+
|
314
|
+
parser = argparse.ArgumentParser(description="Утилита \
|
315
|
+
для автоматической распаковки внешних обработок")
|
316
|
+
parser.add_argument("--version", action="version",
|
317
|
+
version="%(prog)s {}".format(__version__))
|
318
|
+
parser.add_argument("-v", "--verbose", dest="verbose_count",
|
319
|
+
action="count", default=0,
|
320
|
+
help="increases log verbosity for each occurence.")
|
321
|
+
parser.add_argument("--index", action="store_true",
|
322
|
+
default=False, help="Добавляем в индекс исходники")
|
323
|
+
parser.add_argument("--g", action="store_true", default=False,
|
324
|
+
help="Запуситить чтение индекса из git и определить\
|
325
|
+
список файлов для разбора")
|
326
|
+
parser.add_argument("--compile", action="store_true", default=False,
|
327
|
+
help = "Собрать внешний файл/обработку")
|
328
|
+
parser.add_argument("--type", action="store", default="auto",
|
329
|
+
help="Тип файла для сборки epf, erf. По умолчанию авто epf")
|
330
|
+
parser.add_argument("--platform", action="store", help="Путь \
|
331
|
+
к платформе 1С")
|
332
|
+
parser.add_argument("inputPath", nargs="?", help="Путь к \
|
333
|
+
файлам необходимым для распаковки")
|
334
|
+
parser.add_argument("output", nargs="?", help="Путь к \
|
335
|
+
каталогу, куда распаковывать")
|
336
|
+
|
337
|
+
args = parser.parse_args()
|
338
|
+
|
339
|
+
log.setLevel(max(3 - args.verbose_count, 0) * 10)
|
340
|
+
|
341
|
+
if args.g is True:
|
342
|
+
files = get_list_of_comitted_files()
|
343
|
+
indexes = decompile(files, args.output, args.platform)
|
344
|
+
if args.index is True:
|
345
|
+
add_to_git(indexes)
|
346
|
+
|
347
|
+
if(args.compile):
|
348
|
+
compilefromsource(args.inputPath, args.output, args.type)
|
349
|
+
if args.inputPath is not None:
|
350
|
+
files = [os.path.abspath(
|
351
|
+
os.path.join(os.path.curdir, args.inputPath))]
|
352
|
+
if os.path.isdir(files[0]):
|
353
|
+
rootDir = os.path.abspath(
|
354
|
+
os.path.join(os.path.curdir, args.inputPath));
|
355
|
+
files=[]
|
356
|
+
for dirName, subdirList, fileList in os.walk(rootDir):
|
357
|
+
absdir = dirName[len(rootDir)+1:]
|
358
|
+
if '.git' in subdirList:
|
359
|
+
subdirList.remove('.git')
|
360
|
+
if 'src' in subdirList:
|
361
|
+
subdirList.remove('src')
|
362
|
+
for fname in fileList:
|
363
|
+
files.append(os.path.join(absdir,fname))
|
364
|
+
|
365
|
+
decompile(
|
366
|
+
files, args.output, args.platform)
|
367
|
+
|
368
|
+
|
369
|
+
if __name__ == '__main__':
|
370
|
+
sys.exit(main())
|
Binary file
|
@@ -0,0 +1,13 @@
|
|
1
|
+
@echo off
|
2
|
+
setlocal
|
3
|
+
|
4
|
+
set mainDir=C:\Projects\xDD\precommit1c
|
5
|
+
rem set mainDir=%CD%
|
6
|
+
set path1Cbin="C:\Program Files (x86)\1cv82\8.2.19.68\bin\1cv8.exe"
|
7
|
+
set testName=Fixture
|
8
|
+
|
9
|
+
set testDir=%mainDir%\tests
|
10
|
+
|
11
|
+
rd /S /Q %testDir%\testSrc\%testName%
|
12
|
+
%path1Cbin% /F"%mainDir%\ibService" /DisableStartupMessages /execute "%mainDir%\V8Reader.epf" /C"decompile;pathtocf;%testDir%\%testName%.epf;pathout;%testDir%\testSrc\%testName%;�������쐠���㏮;"
|
13
|
+
endlocal
|
@@ -0,0 +1,113 @@
|
|
1
|
+
import unittest
|
2
|
+
import pyv8unpack
|
3
|
+
from os import path as path
|
4
|
+
import os
|
5
|
+
import tempfile
|
6
|
+
import shutil
|
7
|
+
from pathlib import Path
|
8
|
+
import subprocess
|
9
|
+
|
10
|
+
|
11
|
+
class TestV8Unpack(unittest.TestCase):
|
12
|
+
|
13
|
+
def setUp(self):
|
14
|
+
|
15
|
+
unittest.TestCase.setUp(self)
|
16
|
+
self.tpath = tempfile.mkdtemp()
|
17
|
+
self.tfile = tempfile.mktemp()
|
18
|
+
|
19
|
+
pathIb = path.join(path.curdir, ".git", "hooks", "ibService")
|
20
|
+
if (path.exists(pathIb)):
|
21
|
+
shutil.rmtree(pathIb)
|
22
|
+
shutil.copytree(path.join(path.curdir, "ibService"),
|
23
|
+
pathIb)
|
24
|
+
os.mkdir(path.join(path.curdir, ".git", "hooks", "v8Reader"))
|
25
|
+
shutil.copy(path.join(path.curdir, "v8Reader", "V8Reader.epf"),
|
26
|
+
path.join(path.curdir, ".git", "hooks", "v8Reader", "V8Reader.epf"))
|
27
|
+
|
28
|
+
def tearDown(self):
|
29
|
+
|
30
|
+
if os.path.exists(self.tfile):
|
31
|
+
os.remove(self.tfile)
|
32
|
+
shutil.rmtree(self.tpath)
|
33
|
+
shutil.rmtree(path.join(path.curdir, ".git", "hooks", "ibService"))
|
34
|
+
os.remove(path.join(path.curdir, ".git", "hooks", "v8Reader", "V8Reader.epf"))
|
35
|
+
shutil.rmtree(path.join(path.curdir, ".git", "hooks", "v8Reader"))
|
36
|
+
|
37
|
+
|
38
|
+
def test_compile_from_source(self):
|
39
|
+
|
40
|
+
self.tpath = tempfile.mkdtemp()
|
41
|
+
file = path.join(path.curdir, "tests", "Fixture.epf")
|
42
|
+
assert pyv8unpack.decompile([file], self.tpath)
|
43
|
+
tpath = path.join(self.tpath, "tests", "Fixture")
|
44
|
+
assert pyv8unpack.compilefromsource(tpath, self.tfile, "epf") == self.tfile
|
45
|
+
self.assertTrue(path.exists(self.tfile), "Собранный файл не существует {}".format(self.tfile))
|
46
|
+
|
47
|
+
|
48
|
+
def test_decompile(self):
|
49
|
+
|
50
|
+
self.tpath = tempfile.mkdtemp()
|
51
|
+
file = path.join(path.curdir, "tests", "Fixture.epf")
|
52
|
+
assert pyv8unpack.decompile([file], self.tpath)
|
53
|
+
|
54
|
+
def test_decompile_checkfullpath(self):
|
55
|
+
|
56
|
+
self.tpath = tempfile.mkdtemp()
|
57
|
+
file = path.join(path.curdir, "tests", "Fixture.epf")
|
58
|
+
assert pyv8unpack.decompile([file], self.tpath);
|
59
|
+
|
60
|
+
|
61
|
+
class TestGitInit(unittest.TestCase):
|
62
|
+
|
63
|
+
def setUp(self):
|
64
|
+
unittest.TestCase.setUp(self)
|
65
|
+
self.tpath = tempfile.mkdtemp()
|
66
|
+
self.curdir = os.path.abspath(os.curdir);
|
67
|
+
|
68
|
+
print("cur dir {}, temp path {}".format(self.curdir, self.tpath))
|
69
|
+
|
70
|
+
os.chdir(self.tpath)
|
71
|
+
|
72
|
+
try:
|
73
|
+
output = subprocess.check_output(['git','init', self.tpath]
|
74
|
+
).decode("utf-8")
|
75
|
+
except subprocess.CalledProcessError:
|
76
|
+
print("Error diff files get: trace %s" % subprocess.CalledProcessError.output)
|
77
|
+
|
78
|
+
pathIb = path.join(self.tpath, ".git", "hooks", "ibService")
|
79
|
+
if (path.exists(pathIb)):
|
80
|
+
shutil.rmtree(pathIb)
|
81
|
+
shutil.copytree(path.join(self.curdir, "ibService"),
|
82
|
+
pathIb)
|
83
|
+
os.mkdir(path.join(self.tpath, ".git", "hooks", "v8Reader"))
|
84
|
+
shutil.copy(path.join(self.curdir, "v8Reader", "V8Reader.epf"),
|
85
|
+
path.join(self.tpath, ".git", "hooks", "v8Reader", "V8Reader.epf"))
|
86
|
+
shutil.copy(path.join(self.curdir,"pre-commit"),
|
87
|
+
path.join(self.tpath, ".git", "hooks", "pre-commit"))
|
88
|
+
shutil.copy(path.join(self.curdir,"pyv8unpack.py"),
|
89
|
+
path.join(self.tpath, ".git", "hooks", "pyv8unpack.py"))
|
90
|
+
|
91
|
+
|
92
|
+
def tearDown(self):
|
93
|
+
|
94
|
+
#shutil.rmtree(self.tpath)
|
95
|
+
os.chdir(self.curdir)
|
96
|
+
print("cur dir {}".format(os.curdir))
|
97
|
+
|
98
|
+
def test_firstadd(self):
|
99
|
+
file = path.join(self.curdir, "tests", "Fixture.epf")
|
100
|
+
shutil.copy(file,
|
101
|
+
path.join(self.tpath, "Fixture.epf"))
|
102
|
+
|
103
|
+
|
104
|
+
output = subprocess.check_output(['git','add', "-A", "."]
|
105
|
+
).decode("utf-8")
|
106
|
+
print("output {}".format(output))
|
107
|
+
output = subprocess.check_output(['git','commit', "-m", "'init commit'"]
|
108
|
+
).decode("utf-8")
|
109
|
+
print("output {}".format(output))
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|