Permalink
Browse files

Look for easy-install comment in the first 10 lines (up from 1)

  • Loading branch information...
1 parent 040d824 commit 0db090a8ca918758c108a7fa93d0b8f2765700be @kislyuk committed Feb 3, 2013
Showing with 12 additions and 11 deletions.
  1. +12 −11 scripts/python-argcomplete-check-easy-install-script
@@ -15,18 +15,19 @@ parser.add_argument("wrapper_script", help="Wrapper script to examine")
args = parser.parse_args()
with open(args.wrapper_script) as fh:
- line1, line2 = fh.read(1024).split("\n", 2)[:2]
+ line1, lines = fh.read(1024).split("\n", 2)[:2]
assert(line1.startswith('#') and 'py' in line1)
- if line2.startswith("# EASY-INSTALL-SCRIPT"):
- dist, script = re.match("# EASY-INSTALL-SCRIPT: '(.+)','(.+)'", line2).groups()
- if "PYTHON_ARGCOMPLETE_OK" in pkg_resources.get_distribution(dist).get_metadata('scripts/'+script):
- exit(0)
- elif line2.startswith("# EASY-INSTALL-ENTRY-SCRIPT"):
- dist, group, name = re.match("# EASY-INSTALL-ENTRY-SCRIPT: '(.+)','(.+)','(.+)'", line2).groups()
- import pkgutil
- module_name = pkg_resources.get_distribution(dist).get_entry_info(group, name).module_name
- with open(pkgutil.get_loader(module_name).filename) as mod_fh:
- if "PYTHON_ARGCOMPLETE_OK" in mod_fh.read(1024):
+ for line in lines.split("\n", 10):
+ if line.startswith("# EASY-INSTALL-SCRIPT"):
+ 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 pkgutil
+ module_name = pkg_resources.get_distribution(dist).get_entry_info(group, name).module_name
+ with open(pkgutil.get_loader(module_name).filename) as mod_fh:
+ if "PYTHON_ARGCOMPLETE_OK" in mod_fh.read(1024):
+ exit(0)
exit(1)

0 comments on commit 0db090a

Please sign in to comment.