PK!z⍡parse_1c_build/__init__.py# -*- coding: utf-8 -*- import logging # noinspection PyUnresolvedReferences from parse_1c_build.__about__ import __version__ # noinspection PyUnresolvedReferences from parse_1c_build.build import Builder # noinspection PyUnresolvedReferences from parse_1c_build.parse import Parser # noinspection PyUnresolvedReferences logging.getLogger().setLevel(logging.DEBUG) logger = logging.getLogger(__name__) PK!q!parse_1c_build/__main__.py# -*- coding: utf-8 -*- from pathlib import Path import sys from parse_1c_build.core import run sys.path.insert(0, Path(__file__).parent.parent) if __name__ == '__main__': run() PK!,IAAparse_1c_build/base.py# -*- coding: utf-8 -*- from pathlib import Path from cjk_commons.settings import get_attribute, get_path_attribute, get_settings from parse_1c_build.__about__ import APP_AUTHOR, APP_NAME class Processor(object): def __init__(self, **kwargs): settings_file_path = get_path_attribute( kwargs, 'settings_file_path', default_path=Path('settings.yaml'), is_dir=False, check_if_exists=False) self.settings = get_settings(settings_file_path, app_name=APP_NAME, app_author=APP_AUTHOR) self.unpack_only = get_attribute(kwargs, 'unpack_only', self.settings, 'unpack_only', default=False) def get_v8_unpack_file_fullpath(self, **kwargs) -> Path: return get_path_attribute( kwargs, 'v8unpack_file_path', self.settings, 'v8unpack_file', Path('V8Unpack/V8Unpack.exe'), False) def get_gcomp_file_fullpath(self, **kwargs) -> Path: return get_path_attribute( kwargs, 'gcomp_file_path', self.settings, 'gcomp_file', Path('GComp/Release/gcomp.exe'), False) def add_generic_arguments(subparser) -> None: subparser.add_argument( '-h', '--help', action='help', help='Show this help message and exit' ) subparser.add_argument( '-uo', '--unpack-only', action='store_true', help='Parse or build with V8Unpack only' ) # todo Добавить help subparser.add_argument( 'input', nargs=1 ) # todo Добавить help subparser.add_argument( 'output', nargs='?' ) PK!ԁ!parse_1c_build/build.py# -*- coding: utf-8 -*- import logging from pathlib import Path import subprocess import tempfile import shutil from parse_1c_build.base import Processor, add_generic_arguments logger = logging.getLogger(__name__) class Builder(Processor): @staticmethod def get_temp_source_dir_fullpath(input_dir_fullpath: Path) -> Path: temp_source_dir_fullpath = Path(tempfile.mkdtemp()) renames_file_fullpath = Path(input_dir_fullpath, 'renames.txt') with renames_file_fullpath.open(encoding='utf-8-sig') as renames_file: for line in renames_file: names = line.split('-->') new_fullpath = temp_source_dir_fullpath / names[0].strip() new_dir_fullpath = Path(new_fullpath).parent.absolute() if not new_dir_fullpath.is_dir(): new_dir_fullpath.mkdir(parents=True) old_fullpath = Path(input_dir_fullpath, names[1].strip()) if old_fullpath.is_dir(): new_fullpath = Path(temp_source_dir_fullpath, names[0].strip()) shutil.copytree(old_fullpath, new_fullpath) else: shutil.copy(old_fullpath, new_fullpath) return temp_source_dir_fullpath def run(self, input_dir_fullpath: Path, output_file_fullpath: Path) -> None: output_file_fullpath_suffix_lower = output_file_fullpath.suffix.lower() if output_file_fullpath_suffix_lower in ['.epf', '.erf']: args_au = [ str(self.get_v8_unpack_file_fullpath()), '-B' ] if self.unpack_only: args_au += [ str(input_dir_fullpath) ] else: temp_source_dir_fullpath = Builder.get_temp_source_dir_fullpath(input_dir_fullpath) args_au += [ str(temp_source_dir_fullpath) ] args_au += [ str(output_file_fullpath) ] exit_code = subprocess.check_call(args_au) if exit_code != 0: raise Exception('Building \'{0}\' is failed'.format(output_file_fullpath)) elif output_file_fullpath_suffix_lower in ['.ert', '.md']: # todo Может быть такое, что md-файл будет занят, тогда при его записи возникнет ошибка args_au = [ str(self.get_gcomp_file_fullpath()) ] if output_file_fullpath_suffix_lower == '.ert': args_au += [ '--external-report' ] elif output_file_fullpath_suffix_lower == '.md': args_au += [ '--meta-data' ] args_au += [ '-c', '-F', str(output_file_fullpath), '-DD', str(input_dir_fullpath) ] exit_code = subprocess.check_call(args_au) if exit_code != 0: raise Exception('Building \'{0}\' is failed'.format(output_file_fullpath)) def run(args) -> None: try: processor = Builder() # Args input_dir_fullpath = Path(args.input[0]).absolute() if args.output is None: output_file_name_and_extension_str = input_dir_fullpath.name.rpartition('_')[0] output_file_name_and_extension = output_file_name_and_extension_str.rpartition('_') output_file_fullpath = Path( '{0}.{1}'.format(output_file_name_and_extension[0], output_file_name_and_extension[2])).absolute() else: output_file_fullpath = Path(args.output).absolute() processor.run(input_dir_fullpath, output_file_fullpath) except Exception as e: logger.exception(e) def add_subparser(subparsers) -> None: desc = 'Build files in a directory to 1C:Enterprise file' subparser = subparsers.add_parser( Path(__file__).stem, help=desc, description=desc, add_help=False ) subparser.set_defaults(func=run) add_generic_arguments(subparser) PK!%iJJparse_1c_build/cli.py# -*- coding: utf-8 -*- from argparse import ArgumentParser from cjk_commons.logging_ import add_logging_arguments from parse_1c_build import __version__, build, parse def get_argparser() -> ArgumentParser: parser = ArgumentParser( prog='p1cb', description='Parse and build utilities for 1C:Enterprise', add_help=False) parser.add_argument( '-h', '--help', action='help', help='Show this help message and exit' ) parser.add_argument( '-v', '--version', action='version', version='%(prog)s, ver. {0}'.format(__version__), help='Show version' ) add_logging_arguments(parser) subparsers = parser.add_subparsers(dest='subparser_name') build.add_subparser(subparsers) parse.add_subparser(subparsers) return parser PK!ȑVVparse_1c_build/core.py# -*- coding: utf-8 -*- import sys from cjk_commons.logging_ import add_loggers from parse_1c_build import logger as main_logger from parse_1c_build.cli import get_argparser def run() -> None: argparser = get_argparser() args = argparser.parse_args(sys.argv[1:]) add_loggers(args, main_logger) args.func(args) PK!]parse_1c_build/parse.py# -*- coding: utf-8 -*- import logging from pathlib import Path import subprocess import tempfile import shutil from cjk_commons.settings import get_path_attribute from commons_1c import platform_ from parse_1c_build.base import Processor, add_generic_arguments logger = logging.getLogger(__name__) class Parser(Processor): def get_1c_exe_file_fullpath(self, **kwargs) -> Path: return get_path_attribute( kwargs, '1c_file_path', default_path=platform_.get_last_1c_exe_file_fullpath(), is_dir=False) def get_ib_dir_fullpath(self, **kwargs) -> Path: return get_path_attribute( kwargs, 'ib_dir_path', self.settings, 'ib_dir', Path('IB'), create_dir=False) def get_v8_reader_file_fullpath(self, **kwargs) -> Path: return get_path_attribute( kwargs, 'v8reader_file_path', self.settings, 'v8reader_file', Path('V8Reader/V8Reader.epf'), False) def run(self, input_file_fullpath: Path, output_dir_fullpath: Path) -> None: input_file_fullpath_suffix_lower = input_file_fullpath.suffix.lower() if input_file_fullpath_suffix_lower in ['.epf', '.erf']: if self.unpack_only: exit_code = subprocess.check_call([ str(self.get_v8_unpack_file_fullpath()), '-P', str(input_file_fullpath), str(output_dir_fullpath) ]) if exit_code != 0: raise Exception('Parsing \'{0}\' is failed'.format(input_file_fullpath)) else: with tempfile.NamedTemporaryFile('w', suffix='.bat', delete=False, encoding='cp866') as bat_file: bat_file.write('@echo off\n') bat_file.write('"{0}" /F "{1}" /DisableStartupMessages /Execute "{2}" {3}'.format( self.get_1c_exe_file_fullpath(), self.get_ib_dir_fullpath(), self.get_v8_reader_file_fullpath(), '/C "decompile;pathToCF;{0};pathOut;{1};shutdown;convert-mxl2txt;"'.format( input_file_fullpath, output_dir_fullpath ) )) Path(bat_file.name).unlink() elif input_file_fullpath_suffix_lower in ['.ert', '.md']: input_file_fullpath_ = input_file_fullpath # todo if input_file_fullpath_suffix_lower == '.md': temp_dir_fullpath = Path(tempfile.mkdtemp()) input_file_fullpath_ = Path(temp_dir_fullpath, input_file_fullpath_.name) shutil.copyfile(str(input_file_fullpath), str(input_file_fullpath_)) exit_code = subprocess.check_call([ str(self.get_gcomp_file_fullpath()), '-d', '-F', str(input_file_fullpath_), '-DD', str(output_dir_fullpath) ]) if exit_code != 0: raise Exception('Parsing \'{0}\' is failed'.format(input_file_fullpath)) def run(args) -> None: try: processor = Parser() # Args input_file_fullpath = Path(args.input[0]).absolute() if args.output is None: output_dir_fullpath = Path( input_file_fullpath.parent, input_file_fullpath.stem + '_' + input_file_fullpath.suffix[1:] + '_src') else: output_dir_fullpath = Path(args.output).absolute() processor.run(input_file_fullpath, output_dir_fullpath) except Exception as e: logger.exception(e) def add_subparser(subparsers) -> None: desc = 'Parse 1C:Enterprise file in a directory' subparser = subparsers.add_parser( Path(__file__).stem, help=desc, description=desc, add_help=False ) subparser.set_defaults(func=run) add_generic_arguments(subparser) PK!Hp 64/parse_1c_build-5.5.3.dist-info/entry_points.txtN+I/N.,()*0LN-H,*N7LO*IыM̋**PK!HڽTU$parse_1c_build-5.5.3.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]\fi4WZ^EgM_-]#0(q7PK!HP- 'parse_1c_build-5.5.3.dist-info/METADATAVMSVWeXr LLIf!ؒ*=~00a覛LE`?OA`t30{yGzɅU tM2|83 uch\CRETBz*DilM|*h YFY*`^IJTJU{ZMOui:n/xw*[L͐>dr|ն*iښɖJJͮC~ tl6>f;>>RAS}nl_;. ()c8?XDLCM4G~^wo}vmê'+>YD%YдPK!HT w%parse_1c_build-5.5.3.dist-info/RECORDeI@|phv.#44*æ- ߒLK%uRu6 Ƀ'Ƥ"Ƴȴ_DWԕӱ[sa;$.cD|ܧb?1~֗iB]g*u;<Ud&M$n5`YVLFZ ^<. s[_lQE 뮕t`6עºZ.{Xo9YRFxC@\4ja77 [hl Ee6e4fi;T'W]3;%Uκ]m`BASU] 뛑SKQ{:|jnO NZfY\q FmƨWzkVыP~[Rԣ Kg貪*ë|d!27PK!z⍡parse_1c_build/__init__.pyPK!q!parse_1c_build/__main__.pyPK!,IAAparse_1c_build/base.pyPK!ԁ!I parse_1c_build/build.pyPK!%iJJ^parse_1c_build/cli.pyPK!ȑVVparse_1c_build/core.pyPK!]eparse_1c_build/parse.pyPK!Hp 64/_/parse_1c_build-5.5.3.dist-info/entry_points.txtPK!HڽTU$/parse_1c_build-5.5.3.dist-info/WHEELPK!HP- 'x0parse_1c_build-5.5.3.dist-info/METADATAPK!HT w%5parse_1c_build-5.5.3.dist-info/RECORDPK < 8