PK!ߦ6GGdiff_1c/__about__.py__version__ = '6.2.5' APP_AUTHOR = 'util-1c' APP_NAME = 'diff-1c' PK!٪MDDdiff_1c/__init__.py# -*- coding: utf-8 -*- import logging # noinspection PyUnresolvedReferences from diff_1c.__about__ import __version__ # noinspection PyUnresolvedReferences from diff_1c.main import Processor # noinspection PyUnresolvedReferences logging.getLogger().setLevel(logging.DEBUG) logger = logging.getLogger(__name__) PK![?diff_1c/__main__.py# -*- coding: utf-8 -*- from pathlib import Path import sys from diff_1c.core import run sys.path.insert(0, Path(__file__).parent.parent) if __name__ == '__main__': run() PK!diff_1c/cli.py# -*- coding: utf-8 -*- from argparse import ArgumentParser from cjk_commons.logging_ import add_logging_arguments from diff_1c import __version__ from diff_1c.main import run def get_argparser() -> ArgumentParser: parser = ArgumentParser( prog='diff1c', description='Diff utility for 1C:Enterprise files', add_help=False) parser.set_defaults(func=run) 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) parser.add_argument( '--bname', help='the window title for the base file' ) parser.add_argument( '--yname', help='the window title for your file' ) parser.add_argument( '--name-format', choices=['TortoiseGit'], default='TortoiseGit', help='name format' ) parser.add_argument( '--tool', choices=['KDiff3', 'AraxisMerge', 'WinMerge', 'ExamDiff'], default='KDiff3', help='external diff program' ) parser.add_argument( 'base', help='the original file without your changes' ) parser.add_argument( 'mine', help='your own file, with your changes' ) return parser PK!xIjXXdiff_1c/core.py# -*- coding: utf-8 -*- import sys from cjk_commons.logging_ import add_loggers from diff_1c import logger as main_logger from diff_1c.cli import get_argparser def run() -> None: argparser = get_argparser() args = argparser.parse_args(sys.argv[1:]) add_loggers(args, main_logger, argparser.prog) args.func(args) PK!gxxdiff_1c/main.py# -*- coding: utf-8 -*- import logging import os from pathlib import Path import subprocess import tempfile import shutil from cjk_commons.settings import SettingsError, get_attribute, get_path_attribute, get_settings from diff_1c.__about__ import APP_AUTHOR, APP_NAME from parse_1c_build import Parser logger = logging.getLogger(__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.tool = get_attribute(kwargs, 'tool', self.settings, 'default_tool', 'kdiff3').lower() if self.tool not in self.settings['tools']: raise SettingsError('Tool Incorrect') self.tool_path = Path(self.settings['tools'][self.tool]) if not self.tool_path.is_file(): raise SettingsError('Tool Not Exists') self.exclude_file_names = get_attribute(kwargs, 'exclude_file_names', self.settings, 'exclude_file_names', []) self.name_format = get_attribute(kwargs, 'name_format', self.settings, 'name_format', 'tortoisegit').lower() def run(self, base_file_fullpath: Path, mine_file_fullpath: Path, bname: str = '', yname: str = '') -> None: # base base_is_excluded = False if bname: if self.name_format == 'tortoisegit': bname_file_fullpath = Path(bname.split(':')[0]) else: bname_file_fullpath = Path(bname.split(':')[0]) else: bname_file_fullpath = Path.cwd() base_source_dir_fullpath = None if bname_file_fullpath.name not in self.exclude_file_names: base_file_fullpath_suffix = base_file_fullpath.suffix base_temp_file, base_temp_file_fullname = tempfile.mkstemp(base_file_fullpath_suffix) os.close(base_temp_file) shutil.copyfile(str(base_file_fullpath), base_temp_file_fullname) base_source_dir_fullpath = Path(tempfile.mkdtemp()) Parser().run(Path(base_temp_file_fullname), base_source_dir_fullpath) Path(base_temp_file_fullname).unlink() else: base_is_excluded = True # mine mine_is_excluded = False if yname: if self.name_format == 'tortoisegit': yname_file_fullpath = Path(yname.split(':')[0]) else: yname_file_fullpath = Path(yname.split(':')[0]) else: yname_file_fullpath = Path.cwd() mine_source_dir_fullpath = None if yname_file_fullpath.name not in self.exclude_file_names: mine_file_fullpath_suffix = mine_file_fullpath.suffix mine_temp_file, mine_temp_file_fullname = tempfile.mkstemp(mine_file_fullpath_suffix) os.close(mine_temp_file) shutil.copyfile(str(mine_file_fullpath), mine_temp_file_fullname) mine_source_dir_fullpath = Path(tempfile.mkdtemp()) Parser().run(Path(mine_temp_file_fullname), mine_source_dir_fullpath) Path(mine_temp_file_fullname).unlink() else: mine_is_excluded = True tool_args = [str(self.tool_path)] if self.tool == 'kdiff3': # base if base_is_excluded: tool_args += ['--cs', 'EncodingForA=UTF-8', str(base_file_fullpath)] else: tool_args += ['--cs', 'EncodingForA=windows-1251', str(base_source_dir_fullpath)] if bname is not None: tool_args += ['--L1', bname] # mine if mine_is_excluded: tool_args += ['--cs', 'EncodingForB=UTF-8', str(mine_file_fullpath)] else: tool_args += ['--cs', 'EncodingForB=windows-1251', str(mine_source_dir_fullpath)] if yname is not None: tool_args += ['--L2', yname] exit_code = subprocess.check_call(tool_args) if not exit_code == 0: raise Exception('Diff files \'{0}\' and \'{1}\' failed'.format(base_file_fullpath, mine_file_fullpath)) def run(args) -> None: try: processor = Processor(name_format=args.name_format, tool=args.tool) base_file_fullpath = Path(args.base) mine_file_fullpath = Path(args.mine) bname = args.bname yname = args.yname processor.run(base_file_fullpath, mine_file_fullpath, bname, yname) except Exception as e: logger.exception(e) PK!H ./(diff_1c-6.2.5.dist-info/entry_points.txtN+I/N.,()JLK3LQz񹉙yVEy\\PK!HڽTUdiff_1c-6.2.5.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]\fi4WZ^EgM_-]#0(q7PK!Ha  diff_1c-6.2.5.dist-info/METADATAVnESVӳl'h# +vlQu;?[BYdcC%.aA7?.'gƳr ꫪJ^G\sPL;>E@#NH[ lq pO -Rh7UMP `m~_l D>Yo{wn>sٕ-=OX$njI Հ@I$"XDR$@5.GD|BL{`}xW@)Q5OucX(+޿ݰJ3f\UHC.54fgA?4؃9ӃqWuDžG; PPԩxeJf4͖Rlf[ ħŁnwt?!d|:~|vtr4>˼퇋s:>~=?)* bJebUVƥFf}0\\.qt7.mGCn C S<>zN,F?/k7=崅˩@lA_W,F]itm׊2.CF?͜U:'NYaSղd(I-5y;hp= mH}֩vsg 5\oiJׯ97ˉ4 thR l֣`Rn* 'bɌPK!HV'diff_1c-6.2.5.dist-info/RECORDuɒ@}= XZ$ʤ" &%QVt |'N'HIյ1_B 4VM! j^3]|R-BΓ{bmQhTMɋgc3uA MMw-IѤT\yʡ)'Mm%}qvoM(NZ`z8Xk\@ЬDꞽ9S(i+M ePHo".)"+_syT\qc$TF`