Skip to content

Commit

Permalink
Merge pull request #9 from mcg1969/relax
Browse files Browse the repository at this point in the history
Further relaxations
  • Loading branch information
mcg1969 authored Jun 18, 2019
2 parents b392dea + ef10b07 commit 4a23738
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
4 changes: 1 addition & 3 deletions project_inspect/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ def find_notebook_imports(ndata):


def find_file_imports(fpath, submodules=False, locals=False):
if not isfile(fpath):
raise RuntimeError('Not a file: {}'.format(fpath))
if not fpath.endswith(('.ipynb', '.py', '.R')):
if not isfile(fpath) or not fpath.endswith(('.ipynb', '.py', '.R')):
return set(), None
data = load_file(fpath)
if data is None:
Expand Down
29 changes: 16 additions & 13 deletions project_inspect/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,21 +352,24 @@ def build_project_inventory(owner_name, project_name=None, project_root=None, re
extra = set(packages) - required
required -= imported
for pkg in sorted(imported):
pdata = packages[pkg]
records.append((owner_name, project_name, envname, pkg, pdata['version'], pdata['build'], True, True, ''))
if pkg in packages:
pdata = packages[pkg]
records.append((owner_name, project_name, envname, pkg, pdata['version'], pdata['build'], True, True, ''))
for pkg in sorted(required):
pdata = packages[pkg]
# If a package depends on another package transitively through one of the base
# packages (python, r-base), we don't want it to show up in this list. This
# reduces the noise in this list considerably.
revs = all_children(packages, pdata['reverse'], 'reverse', bases)
if not revs:
revs = all_children(packages, pdata['reverse'], 'reverse', imported)
revs = ', '.join(sorted(revs))
records.append((owner_name, project_name, envname, pkg, pdata['version'], pdata['build'], True, False, revs))
if pkg in packages:
pdata = packages[pkg]
# If a package depends on another package transitively through one of the base
# packages (python, r-base), we don't want it to show up in this list. This
# reduces the noise in this list considerably.
revs = all_children(packages, pdata['reverse'], 'reverse', bases)
if not revs:
revs = all_children(packages, pdata['reverse'], 'reverse', imported)
revs = ', '.join(sorted(revs))
records.append((owner_name, project_name, envname, pkg, pdata['version'], pdata['build'], True, False, revs))
for pkg in sorted(extra):
pdata = packages[pkg]
records.append((owner_name, project_name, envname, pkg, pdata['version'], pdata['build'], False, False, ''))
if pkg in packages:
pdata = packages[pkg]
records.append((owner_name, project_name, envname, pkg, pdata['version'], pdata['build'], False, False, ''))
return records if records_only else _build_df(records)


Expand Down

0 comments on commit 4a23738

Please sign in to comment.