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

fix bugs related to get_module_name and resolve_imports #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,4 @@ htmlcov
.idea/
.history/
.vscode/
*.swp
2 changes: 1 addition & 1 deletion pyan/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def resolve_imports(self):
and from_node.flavor == Flavor.IMPORTEDITEM
):
# use define edges as potential candidates
for candidate_to_node in self.defines_edges[to_node]: #
for candidate_to_node in self.defines_edges.get(to_node, []): # [to_node]: #
if candidate_to_node.name == node.name:
attribute_import_mapping[node] = candidate_to_node
break
Expand Down
2 changes: 1 addition & 1 deletion pyan/anutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get_module_name(filename, root: str = None):
module_path = os.path.dirname(filename)
else:
# otherwise it is the filename without extension
module_path = filename.replace(".py", "")
module_path = filename.rstrip(".py")

# find the module root - walk up the tree and check if it contains .py files - if yes. it is the new root
directories = [(module_path, True)]
Expand Down