cyyeh commited on
Commit
cb4a67f
1 Parent(s): a7a3247
Files changed (2) hide show
  1. app.py +3 -3
  2. py_code_analyzer/code_imports_analyzer.py +13 -12
app.py CHANGED
@@ -42,8 +42,8 @@ def get_python_files(owner: str, repo: str, tree_sha: str):
42
 
43
 
44
  @conditonal_decorator(time_function, DEV)
45
- async def parse_python_files(analyzer: CodeImportsAnalyzer):
46
- _ = await analyzer.parse_python_files()
47
 
48
 
49
  @conditonal_decorator(time_function, DEV)
@@ -67,7 +67,7 @@ if clicked_ok_button and owner and repo:
67
 
68
  analyzer = CodeImportsAnalyzer(python_files)
69
  with st.spinner("Parsing python files..."):
70
- asyncio.run(parse_python_files(analyzer))
71
 
72
  with st.spinner("Generating imports graph..."):
73
  imports_graph = generate_imports_graph(analyzer)
 
42
 
43
 
44
  @conditonal_decorator(time_function, DEV)
45
+ def parse_python_files(analyzer: CodeImportsAnalyzer):
46
+ asyncio.run(analyzer.parse_python_files())
47
 
48
 
49
  @conditonal_decorator(time_function, DEV)
 
67
 
68
  analyzer = CodeImportsAnalyzer(python_files)
69
  with st.spinner("Parsing python files..."):
70
+ parse_python_files(analyzer)
71
 
72
  with st.spinner("Generating imports graph..."):
73
  imports_graph = generate_imports_graph(analyzer)
py_code_analyzer/code_imports_analyzer.py CHANGED
@@ -77,18 +77,19 @@ class CodeImportsAnalyzer:
77
  )
78
 
79
  results = await asyncio.gather(*tasks)
80
- for base64_program_text, python_file_path in results:
81
- if base64_program_text:
82
- self.python_imports += [
83
- {
84
- "file_name": python_file_path.split("/")[-1],
85
- "file_path": python_file_path,
86
- "imports": [],
87
- }
88
- ]
89
- program = pybase64.b64decode(base64_program_text)
90
- tree = ast.parse(program)
91
- self._node_visitor.visit(tree)
 
92
 
93
  def generate_imports_graph(self):
94
  # TODO: thought on how to improve the graph generation logic
 
77
  )
78
 
79
  results = await asyncio.gather(*tasks)
80
+ if results:
81
+ for base64_program_text, python_file_path in results:
82
+ if base64_program_text:
83
+ self.python_imports += [
84
+ {
85
+ "file_name": python_file_path.split("/")[-1],
86
+ "file_path": python_file_path,
87
+ "imports": [],
88
+ }
89
+ ]
90
+ program = pybase64.b64decode(base64_program_text)
91
+ tree = ast.parse(program)
92
+ self._node_visitor.visit(tree)
93
 
94
  def generate_imports_graph(self):
95
  # TODO: thought on how to improve the graph generation logic