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.4.dist-info/entry_points.txtN+I/N.,()JLK3LQz񹉙yVEy\\PK!HڽTUdiff_1c-6.2.4.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]\fi4WZ^EgM_-]#0(q7PK!H#D¦ diff_1c-6.2.4.dist-info/METADATAUMoFWH ⢮F԰!WGKۺj$p\zU˕c[ 7+*5 hɝ7ofn7ygcz[FZvvXk)h2%s|xLZgylv.a7t7mjP$9k+[=OUpVGBH2dbS)[艘nB{m!~*}0v_9K]-ؖŞY,65E΂3}j̛D"bE$E BVf$+l1TN= R]ʓN) Q ̓n]X&v:(_f2f\*}ZCe]$g_˸=)d7"M{A1`c,ͥNU^[ydio)jo|Z&̽˾33u̱9+_|jfh.1"k7<W5̘5ᕿ : `bx`Fe<?*wUGe*%ͤ|Q,_| 4.G &ޛK'j|ZC%Rg!$B :#vNzPs'<:Ah +Vk̼ETBZ7|Mpee?|Հbu-]l.m@%>6s*#ItȯUЮ If+g@4߈FS9h03]U*Y ˣA7eiR3FO};˗rL0 4Ɔ$6mm0DŽፓ:ed >&[i t?ҩ$yWqPK!HI땫diff_1c-6.2.4.dist-info/RECORDuϹ@Ѽl@"ZT!)veg&ж_8|"K"'Ie,ڱ} ȦԼOymuJi5=H2G]7𖷷=͞Cj_rAIEQkNxcƌ.CQ`YJ3u㨠C]@QHvU4ޟ=˛Y"PK!٪MDDdiff_1c/__init__.pyPK![?udiff_1c/__main__.pyPK!bdiff_1c/cli.pyPK!xIjXX`diff_1c/core.pyPK!gxx diff_1c/main.pyPK!H ./(diff_1c-6.2.4.dist-info/entry_points.txtPK!HڽTUdiff_1c-6.2.4.dist-info/WHEELPK!H#D¦ diff_1c-6.2.4.dist-info/METADATAPK!HI땫q!diff_1c-6.2.4.dist-info/RECORDPK sX#