bg dZddlZddlZddlmZddlmZmZddlm Z m Z m Z dee de fdZ dee dee fd Z dd ed edede deee def dZdS)zDefines a git hook to allow pre-commit warnings and errors about import order. usage: exit_code = git_hook(strict=True|False, modify=True|False) N)Path)ListOptional)Configapi exceptionscommandreturncvtj|tjd}|jS)zRun a command and return raw output :param str command: the command to run :returns: the stdout output of the command T)stdoutcheck) subprocessrunPIPEr decode)r results \/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/isort/hooks.py get_outputrs0 ^GJO4 H H HF =   ! !!c\t|}d|DS)zRun a command and return lines of output :param str command: the command to run :returns: list of whitespace-stripped lines output by command c6g|]}|S)strip).0lines r zget_lines..s 9 9 9TDJJLL 9 9 9r)r splitlines)r r s r get_linesrs1  F 9 9V%6%6%8%8 9 9 99rFstrictmodifylazy settings_file directoriesc Pgd}|r|d|r||t|}|sdSd}t|tjtj|d}|D]} | droddd| g} t| } tj | t| | s|d z }|rtj | | q#tj$rYwxYw|r|ndS) a;Git pre-commit hook to check staged files for isort errors :param bool strict - if True, return number of errors on exit, causing the hook to fail. If False, return zero so it will just act as a warning. :param bool modify - if True, fix the sources if they are not sorted properly. If False, only report result without modifying anything. :param bool lazy - if True, also check/fix unstaged files. This is useful if you frequently use ``git commit -a`` for example. If False, only check/fix the staged files for isort errors. :param str settings_file - A path to a file to be used as the configuration file for this run. When settings_file is the empty string, the configuration file will be searched starting at the directory containing the first staged file, if any, and going upward in the directory structure. :param list[str] directories - A list of directories to restrict the hook to. :return number of errors if in strict mode, 0 otherwise. )gitz diff-index--cachedz --name-onlyz--diff-filter=ACMRTUXBHEADr'r)r# settings_pathz.pyr&show:) file_pathconfig)r-)removeextendrrospathdirnameabspathendswithrrcheck_code_stringr sort_filer FileSkipped) r r!r"r#r$diff_cmdfiles_modifiederrorsr-filename staged_cmdstaged_contentss rgit_hookr?"sr8baaH $ ###% $$$x((N q F #goobgoonQ6G&H&HIIF#   U # # X8J(44O ,#tH~~f?aKF? hv>>>>)      "66"s AD  DD)FFFrN)__doc__r1rpathlibrtypingrrisortrrrstrrrboolintr?rrrrGs3  !!!!!!!!))))))))))"S "c"""":tCy:T#Y::::'+ ;#;# ;# ;# ;# ;# $s)$ ;#  ;#;#;#;#;#;#r