From ef10b07896f9c5e145c01d9808287e9b7e6086cb Mon Sep 17 00:00:00 2001 From: "Michael C. Grant" Date: Tue, 18 Jun 2019 09:11:03 -0500 Subject: [PATCH] Further relaxation --- project_inspect/imports.py | 4 +--- project_inspect/project.py | 29 ++++++++++++++++------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/project_inspect/imports.py b/project_inspect/imports.py index b57f95e..865466c 100644 --- a/project_inspect/imports.py +++ b/project_inspect/imports.py @@ -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: diff --git a/project_inspect/project.py b/project_inspect/project.py index e543823..47b6ce5 100644 --- a/project_inspect/project.py +++ b/project_inspect/project.py @@ -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)