PK!ضgit_hooks_1c/__init__.py# -*- coding: utf-8 -*- import logging # noinspection PyUnresolvedReferences from git_hooks_1c.__about__ import __version__ # noinspection PyUnresolvedReferences logging.getLogger().setLevel(logging.DEBUG) logger = logging.getLogger(__name__) PK!git_hooks_1c/__main__.py# -*- coding: utf-8 -*- from pathlib import Path import sys from git_hooks_1c.core import run sys.path.insert(0, Path(__file__).parent.parent) if __name__ == '__main__': run() PK!m5git_hooks_1c/cli.py# -*- coding: utf-8 -*- from argparse import ArgumentParser from cjk_commons.logging_ import add_logging_arguments from git_hooks_1c import __version__, install, pre_commit, uninstall def get_argparser() -> ArgumentParser: parser = ArgumentParser( prog='gh1c', description='Git hooks 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') install.add_subparser(subparsers) pre_commit.add_subparser(subparsers) uninstall.add_subparser(subparsers) return parser PK!KURRgit_hooks_1c/core.py# -*- coding: utf-8 -*- import sys from cjk_commons.logging_ import add_loggers from git_hooks_1c import logger as main_logger from git_hooks_1c.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! e11git_hooks_1c/install.py# -*- coding: utf-8 -*- import logging from pathlib import Path import subprocess import shutil logger = logging.getLogger(__name__) # noinspection PyUnusedLocal def run(args) -> None: try: script_dir_fullpath = Path(__file__).parent.absolute() current_dir_fullpath = Path('.git', 'hooks').absolute() pre_commit_file_fullpath = Path(script_dir_fullpath, 'pre-commit.sample') pre_commit_symbolic_fullpath = Path(current_dir_fullpath, 'pre-commit') if pre_commit_symbolic_fullpath.exists() and not args.force: print('git-hooks-1c already exist') else: shutil.copyfile(str(pre_commit_file_fullpath), str(pre_commit_symbolic_fullpath)) print('git-hooks-1c installed') args_au = [ 'cmd.exe', '/C', 'git', 'config', '--local', 'core.quotepath', 'false' ] subprocess.call(args_au) except Exception as e: logger.exception(e) def add_subparser(subparsers) -> None: decs = 'Install hooks' subparser = subparsers.add_parser( Path(__file__).stem, help=decs, description=decs, add_help=False ) subparser.set_defaults(func=run) subparser.add_argument( '-h', '--help', action='help', help='Show this help message and exit' ) subparser.add_argument( '-f', '--force', action='store_true', help='Install hooks anyway' ) PK!=OSSgit_hooks_1c/pre-commit.sample#!/bin/sh cmd //C "workon git-hooks-1c & cd- & gh1c.exe pre_commit & deactivate" PK!y / / git_hooks_1c/pre_commit.py# -*- coding: utf-8 -*- import logging from pathlib import Path import subprocess from typing import List import re import shutil from parse_1c_build import Parser logger = logging.getLogger(__name__) added_or_modified = re.compile(r'^\s*[AM]\s+"?(?P[^"]*)"?') def get_added_or_modified_file_fullpaths() -> List[Path]: result = [] try: args_au = [ 'git', 'status', '--porcelain' ] output = subprocess.check_output(args_au).decode('utf-8') except subprocess.CalledProcessError: return result for line in output.split('\n'): if line != '': match = added_or_modified.match(line) if match: added_or_modified_file_fullname = Path(match.group('rel_name')).absolute() if added_or_modified_file_fullname.name.lower() != 'readme.md': result.append(added_or_modified_file_fullname) return result def get_for_processing_file_fullpaths(file_fullpaths: List[Path]) -> List[Path]: result = [] for file_fullpath in file_fullpaths: if file_fullpath.suffix.lower() in ['.epf', '.erf', '.ert', '.md']: result.append(file_fullpath) return result def parse(file_fullpaths: List[Path]) -> List[Path]: result = [] parser = Parser() for file_fullpath in file_fullpaths: source_dir_fullpath = Path( file_fullpath.parent, file_fullpath.stem + '_' + file_fullpath.suffix[1:] + '_src') if not source_dir_fullpath.exists(): source_dir_fullpath.mkdir(parents=True) else: shutil.rmtree(source_dir_fullpath) parser.run(file_fullpath, source_dir_fullpath) result.append(source_dir_fullpath) return result def add_to_index(dir_fullpaths: List[Path]) -> None: for dir_fullpath in dir_fullpaths: args_au = [ 'git', 'add', '--all', str(dir_fullpath) ] exit_code = subprocess.check_call(args_au) if exit_code != 0: exit(exit_code) # noinspection PyUnusedLocal def run(args) -> None: try: added_or_modified_file_fullpaths = get_added_or_modified_file_fullpaths() for_processing_file_fullpaths = get_for_processing_file_fullpaths(added_or_modified_file_fullpaths) if len(for_processing_file_fullpaths) == 0: exit(0) for_indexing_source_dir_fullpaths = parse(for_processing_file_fullpaths) add_to_index(for_indexing_source_dir_fullpaths) except Exception as e: logger.exception(e) def add_subparser(subparsers) -> None: decs = 'Pre-commit for 1C:Enterprise files' subparser = subparsers.add_parser( Path(__file__).stem, help=decs, description=decs, add_help=False ) subparser.set_defaults(func=run) subparser.add_argument( '-h', '--help', action='help', help='Show this help message and exit' ) PK!Umgit_hooks_1c/uninstall.py# -*- coding: utf-8 -*- import logging from pathlib import Path logger = logging.getLogger(__name__) # noinspection PyUnusedLocal def run(args) -> None: try: current_dir_fullpath = Path('.git', 'hooks').absolute() pre_commit_symbolic_fullpath = Path(current_dir_fullpath, 'pre-commit') if pre_commit_symbolic_fullpath.exists(): pre_commit_symbolic_fullpath.unlink() print('git-hooks-1c uninstalled') else: print('git-hooks-1c not installed') except Exception as e: logger.exception(e) def add_subparser(subparsers) -> None: decs = 'Uninstall hooks' subparser = subparsers.add_parser( Path(__file__).stem, help=decs, description=decs, add_help=False ) subparser.set_defaults(func=run) subparser.add_argument( '-h', '--help', action='help', help='Show this help message and exit' ) PK!Hr42-git_hooks_1c-8.0.1.dist-info/entry_points.txtN+I/N.,()J0LM,.7L֋M̋**PK!HڽTU"git_hooks_1c-8.0.1.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]\fi4WZ^EgM_-]#0(q7PK!Htժ %git_hooks_1c-8.0.1.dist-info/METADATAWMOFW1lI U)T-*IEv ;C !VEm\襇M%~Iyg|DzH_~ M*-ImXiyE+{ $nG A!%d)1} c$:2'-"NzE׏t9Z3L/X߰ZěG~ j1ghvqg8"syraS`ڮĝ\ш~&rY3_\݄v+cm+fɰF!]ܗxSE*l:k}yjl/N ~6m)jaE#(XօC{|ԯɮg5'<WoJRz*_ 2iO7,'5y,Ml3s+eGV,?IPK!HqA#git_hooks_1c-8.0.1.dist-info/RECORD}r@} rU.nB+nbIUg3D`^7 A!35w !/1B{hYr"@dm3H`=+CTx xFp2.S}\E."B5v?8 r?NV̹.0Ic 3JdoTݥ_,D- E7X}Nq ^/!ه]2ő8B&aQ|Myv=$Šu9{"iw֫CŦ/^ӥt\%"3M>ٴܬZyjJ^Z0E+mκ[ɅQL C/ͽK ׼KKOAݶn(쫟i=!>T i,kuCa}e'D/0cf` LhT]"65XmH"1`*dqD(3k'-+Q(/PK!ضgit_hooks_1c/__init__.pyPK!4git_hooks_1c/__main__.pyPK!m5+git_hooks_1c/cli.pyPK!KURRgit_hooks_1c/core.pyPK! e11dgit_hooks_1c/install.pyPK!=OSS git_hooks_1c/pre-commit.samplePK!y / / Ygit_hooks_1c/pre_commit.pyPK!Umgit_hooks_1c/uninstall.pyPK!Hr42-git_hooks_1c-8.0.1.dist-info/entry_points.txtPK!HڽTU"Ngit_hooks_1c-8.0.1.dist-info/WHEELPK!Htժ %git_hooks_1c-8.0.1.dist-info/METADATAPK!HqA#1%git_hooks_1c-8.0.1.dist-info/RECORDPK ~'