-
Notifications
You must be signed in to change notification settings - Fork 0
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
Exclusively build for pwdata and filter out modules #3
Changes from 15 commits
fcefe35
bc8ec6c
4484b96
332ed7e
9145079
3fbb617
09ace52
8f2107b
227325d
4668151
0c7f1ec
165a26d
9d70e92
0f498e2
d150cb5
712ebb1
0f25a10
cdf8c30
a478da3
7f944eb
7270fe7
9482506
3c36d6f
0036baf
9a5ce92
c482243
5713719
5d950da
a159b35
dc182c7
c5319c5
48f5731
b57b4c3
8946577
5cb4728
7daf94e
697c4ad
b2a5d15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,8 @@ | |
self, | ||
filename, | ||
modname, | ||
exclusives, | ||
ignored_mods, | ||
import_manager, | ||
scope_manager, | ||
def_manager, | ||
|
@@ -40,6 +42,8 @@ | |
super().__init__(filename, modname, modules_analyzed) | ||
|
||
self.modname = modname | ||
self.exclusives = exclusives | ||
self.ignored_mods = ignored_mods | ||
self.mod_dir = "/".join(self.filename.split("/")[:-1]) | ||
|
||
self.import_manager = import_manager | ||
|
@@ -71,6 +75,8 @@ | |
super().analyze_submodule( | ||
PreProcessor, | ||
modname, | ||
self.exclusives, | ||
self.ignored_mods, | ||
self.import_manager, | ||
self.scope_manager, | ||
self.def_manager, | ||
|
@@ -81,6 +87,10 @@ | |
|
||
def visit_Module(self, node): | ||
def iterate_mod_items(items, const): | ||
items = [ | ||
i for i in items if not \ | ||
any(ignored_mod in i for ignored_mod in self.ignored_mods) | ||
] | ||
for item in items: | ||
defi = self.def_manager.get(item) | ||
if not defi: | ||
|
@@ -205,6 +215,14 @@ | |
tgt_name = import_item.asname if import_item.asname else import_item.name | ||
imported_name = self.import_manager.handle_import(src_name, level) | ||
|
||
# Limit to exclusive module | ||
if src_name.split(".")[0] not in self.exclusives: | ||
continue | ||
|
||
# Skip ignored modules | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to skip ignored modules down here and remove them from times above? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Below is what happens when PyCG looks at an import declaration, the other |
||
if tgt_name in self.ignored_mods: | ||
continue | ||
|
||
if not imported_name: | ||
add_external_def(src_name, tgt_name) | ||
continue | ||
|
@@ -223,6 +241,9 @@ | |
|
||
# handle all modules that were not analyzed | ||
for modname in self.import_manager.get_imports(self.modname): | ||
if modname.split(".")[0] not in self.exclusives: | ||
continue | ||
|
||
fname = self.import_manager.get_filepath(modname) | ||
|
||
if not fname: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens here if self.exclusives is None?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I'll add their default to be an empty array.