/usr/bin/python-argcomplete-check-easy-install-script is in python-argcomplete 0.6.9-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | #! /usr/bin/python
# Copyright 2012-2013, Andrey Kislyuk and argcomplete contributors.
# Licensed under the Apache License. See https://github.com/kislyuk/argcomplete for more info.
'''
Check if an EASY-INSTALL-SCRIPT wrapper redirects to a script that contains "PYTHON_ARGCOMPLETE_OK"
'''
import re, argparse
parser = argparse.ArgumentParser(description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("wrapper_script", help="Wrapper script to examine")
args = parser.parse_args()
with open(args.wrapper_script) as fh:
line1, head = fh.read(1024).split("\n", 1)[:2]
if line1.startswith('#') and ('py' in line1 or 'Py' in line1):
lines = head.split("\n", 12)
for line in lines:
if line.startswith("# EASY-INSTALL-SCRIPT"):
import pkg_resources
dist, script = re.match("# EASY-INSTALL-SCRIPT: '(.+)','(.+)'", line).groups()
if "PYTHON_ARGCOMPLETE_OK" in pkg_resources.get_distribution(dist).get_metadata('scripts/'+script):
exit(0)
elif line.startswith("# EASY-INSTALL-ENTRY-SCRIPT"):
dist, group, name = re.match("# EASY-INSTALL-ENTRY-SCRIPT: '(.+)','(.+)','(.+)'", line).groups()
import pkg_resources, pkgutil
module_name = pkg_resources.get_distribution(dist).get_entry_info(group, name).module_name
with open(pkgutil.get_loader(module_name).get_filename()) as mod_fh:
if "PYTHON_ARGCOMPLETE_OK" in mod_fh.read(1024):
exit(0)
elif line.startswith("# EASY-INSTALL-DEV-SCRIPT"):
for line2 in lines:
if line2.startswith('__file__'):
filename = re.match("__file__ = '(.+)'", line2).group(1)
with open(filename) as mod_fh:
if "PYTHON_ARGCOMPLETE_OK" in mod_fh.read(1024):
exit(0)
elif line.startswith("# PBR Generated"):
module = re.search("from (.*) import", head).groups()[0]
import pkg_resources, pkgutil
with open(pkgutil.get_loader(module).get_filename()) as mod_fh:
if "PYTHON_ARGCOMPLETE_OK" in mod_fh.read(1024):
exit(0)
exit(1)
|