![Gerald Combs](/assets/img/avatar_default.png)
PEP 394[1] says, "In cases where the script is expected to be executed outside virtual environments, developers will need to be aware of the following discrepancies across platforms and installation methods: * Older Linux distributions will provide a python command that refers to Python 2, and will likely not provide a python2 command. * Some newer Linux distributions will provide a python command that refers to Python 3. * Some Linux distributions will not provide a python command at all by default, but will provide a python3 command by default." Debian has forced the issue by choosing the third option[2]: "NOTE: Debian testing (bullseye) has removed the "python" package and the '/usr/bin/python' symlink due to the deprecation of Python 2." Switch our shebang from "#!/usr/bin/env python" to "#!/usr/bin/env python3" in some places. Remove some 2/3 version checks if we know we're running under Python 3. Remove the "coding: utf-8" in a bunch of places since that's the default in Python 3. [1]https://www.python.org/dev/peps/pep-0394/#for-python-script-publishers [2]https://wiki.debian.org/Python
60 lines
1.2 KiB
Python
Executable file
60 lines
1.2 KiB
Python
Executable file
#!/bin/env python3
|
|
#
|
|
# Wireshark - Network traffic analyzer
|
|
# By Gerald Combs <gerald@wireshark.org>
|
|
# Copyright 1998 Gerald Combs
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
import sys
|
|
import os
|
|
import fnmatch
|
|
|
|
IGNORE_CONF = "pre-commit-ignore.conf"
|
|
|
|
if len(sys.argv) > 2:
|
|
print("Usage: {0} [path/to/ignore.conf]".format(sys.argv[0]))
|
|
sys.exit(1)
|
|
|
|
if len(sys.argv) == 2:
|
|
ignore_path = sys.argv[1]
|
|
else:
|
|
ignore_path = IGNORE_CONF
|
|
|
|
# Function to load our patterns from 'path' for modified files
|
|
# to be ignored (skipping any comments)
|
|
def load_checkignore(path):
|
|
try:
|
|
with open(path) as f:
|
|
patterns = f.read()
|
|
except OSError as err:
|
|
sys.exit(str(err))
|
|
ign = [l.strip() for l in patterns.splitlines()]
|
|
ign = [l for l in ign if l and not l.startswith("#")]
|
|
return ign
|
|
|
|
ignore_list = load_checkignore(ignore_path)
|
|
|
|
def ignore_match(f):
|
|
for p in ignore_list:
|
|
if fnmatch.fnmatchcase(f, p):
|
|
return True
|
|
return False
|
|
|
|
for line in sys.stdin:
|
|
line = line.strip()
|
|
if not ignore_match(line):
|
|
print(line)
|
|
|
|
#
|
|
# Editor modelines
|
|
#
|
|
# Local Variables:
|
|
# c-basic-offset: 4
|
|
# indent-tabs-mode: nil
|
|
# End:
|
|
#
|
|
# ex: set shiftwidth=4 expandtab:
|
|
# :indentSize=4:noTabs=true:
|
|
#
|