Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed anutils.get_module_name #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

charmoniumQ
Copy link

Before this commit, I would get the following error:

Traceback (most recent call last):
  File "/home/sam/.local/share/virtualenvs/.repos-OcsR-W1w/bin/pyan3", line 33, in <module>
    sys.exit(load_entry_point('pyan3', 'console_scripts', 'pyan3')())
  File "/home/sam/box/charmonium.cache/benchmark/.repos/pyan/pyan/main.py", line 206, in main
    v = CallGraphVisitor(filenames, logger=logger, root=root)
  File "/home/sam/box/charmonium.cache/benchmark/.repos/pyan/pyan/analyzer.py", line 60, in __init__
    mod_name = get_module_name(filename)
  File "/home/sam/box/charmonium.cache/benchmark/.repos/pyan/pyan/anutils.py", line 43, in get_module_name
    is_root = any([f == "__init__.py" for f in os.listdir(potential_root)])
FileNotFoundError: [Errno 2] No such file or directory: ''

because directories[0][0] was:

./pudl/src/pudl/cli.py None
./pudl/src/pudl
./pudl/src
./pudl
.

After this commit, the code works as expected, because the loop stops when it finds the root.

@lofidevops
Copy link

@Technologicat @jdb78 Tested this via the https://github.com/aurelg/pyan/commits/master fork and can confirm it is working.

Copy link

@EmileDqy EmileDqy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found your PR too late and I had the same fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants