feat(mma): Add dependency mapping to mma-exec
This commit is contained in:
@@ -126,4 +126,23 @@ def main():
|
||||
print(result)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
import ast
|
||||
def get_dependencies(filepath):
|
||||
with open(filepath, 'r', encoding='utf-8') as f:
|
||||
tree = ast.parse(f.read())
|
||||
dependencies = []
|
||||
for node in tree.body:
|
||||
if isinstance(node, ast.Import):
|
||||
for alias in node.names:
|
||||
dependencies.append(alias.name.split('.')[0])
|
||||
elif isinstance(node, ast.ImportFrom):
|
||||
if node.module:
|
||||
dependencies.append(node.module.split('.')[0])
|
||||
seen = set()
|
||||
result = []
|
||||
for d in dependencies:
|
||||
if d not in seen:
|
||||
result.append(d)
|
||||
seen.add(d)
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user