You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "exceptionfactory (via GitHub)" <gi...@apache.org> on 2026/01/15 19:39:29 UTC
Re: [PR] NIFI-14233 - Fix Python Processor imported property dependencies [nifi]
exceptionfactory commented on code in PR #10616:
URL: https://github.com/apache/nifi/pull/10616#discussion_r2695703090
##########
nifi-framework-bundle/nifi-framework-extensions/nifi-py4j-framework-bundle/nifi-python-framework/src/main/python/framework/ProcessorInspection.py:
##########
@@ -121,6 +126,138 @@ def get_module_string_constants(module_file: str) -> dict:
return visitor.string_assignments
+def get_imports_from_module(module_file: str) -> dict:
+ """
+ Parse a module file and return a mapping of imported names to their source module files.
+
+ This function extracts import statements from the given module file and resolves
+ them to actual file paths. It handles:
+ - 'from module import name' style imports
+ - Relative imports within the same directory
+
+ :param module_file: Path to the Python module file to parse
+ :return: Dictionary mapping imported names to their source file paths
+ e.g., {'SHARED_PROPERTY': '/path/to/SharedModule.py'}
+ """
+ with open(module_file) as file:
+ root_node = ast.parse(file.read())
Review Comment:
Instead of reading the file and parsing it multiple times, it would be helpful to refactor the approach to read and parse once, then pass the parsed tree around
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org