Skip to content

Commit

Permalink
Only consider files in fix-requires-by-path
Browse files Browse the repository at this point in the history
This makes it practical to use complex regex e.g. ending with a negative
lookahead.
  • Loading branch information
jon-turney committed Mar 31, 2024
1 parent 10a4242 commit 56719ce
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions calm/fix-requires-by-path.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
def fix_one_hint(args, dirpath, hintfile, tf):
pn = os.path.join(dirpath, hintfile)

# avoid pointlessly checking to add a self-dependency
if pn == args.requires:
return

hints = hint.hint_file_parse(pn, hint.pvr)

hints.pop('parse-warnings', None)
Expand All @@ -57,13 +61,13 @@ def fix_one_hint(args, dirpath, hintfile, tf):
if args.requires in requires:
return

# check if this package installs anything with the specified path, and if
# check if this package installs any files with the specified path, and if
# so, add to the requires, if not already present
ivp = False

try:
with xtarfile.open(os.path.join(dirpath, tf), mode='r') as a:
ivp = any(re.match(args.path, m) for m in a.getnames())
ivp = any((m.isfile() and re.match(args.path, m.name)) for m in a.getmembers())
except tarfile.ReadError:
pass

Expand Down

0 comments on commit 56719ce

Please sign in to comment.