pyan
pyan copied to clipboard
Fixed anutils.get_module_name
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.
@Technologicat @jdb78 Tested this via the https://github.com/aurelg/pyan/commits/master fork and can confirm it is working.