Spaces:
Runtime error
Runtime error
add streamlit integration
Browse files
Makefile
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
run:
|
2 |
-
pipenv run
|
3 |
|
4 |
format:
|
5 |
-
pipenv run black py_code_analyzer && \
|
6 |
-
pipenv run isort py_code_analyzer && \
|
7 |
-
pipenv run flake8 py_code_analyzer && \
|
8 |
-
pipenv run mypy py_code_analyzer
|
9 |
|
10 |
test:
|
11 |
pipenv run pytest --cov
|
|
|
1 |
run:
|
2 |
+
pipenv run streamlit run app.py
|
3 |
|
4 |
format:
|
5 |
+
pipenv run black py_code_analyzer app.py && \
|
6 |
+
pipenv run isort py_code_analyzer app.py && \
|
7 |
+
pipenv run flake8 py_code_analyzer app.py && \
|
8 |
+
pipenv run mypy py_code_analyzer app.py
|
9 |
|
10 |
test:
|
11 |
pipenv run pytest --cov
|
README.md
CHANGED
@@ -33,7 +33,7 @@ input to one GitHub public repo's URL(input)
|
|
33 |
- [x] Use `ast` to parse imports among given python files
|
34 |
- [x] Generate a basic `networkx` graph given python imports
|
35 |
- [x] Visualize a basic `networkx` graph using `pyvis`
|
36 |
-
- [
|
37 |
## References
|
38 |
|
39 |
- [How to set up a perfect Python project](https://sourcery.ai/blog/python-best-practices/)
|
|
|
33 |
- [x] Use `ast` to parse imports among given python files
|
34 |
- [x] Generate a basic `networkx` graph given python imports
|
35 |
- [x] Visualize a basic `networkx` graph using `pyvis`
|
36 |
+
- [x] Build a `streamlit` app
|
37 |
## References
|
38 |
|
39 |
- [How to set up a perfect Python project](https://sourcery.ai/blog/python-best-practices/)
|
app.py
CHANGED
@@ -1,7 +1,30 @@
|
|
|
|
|
|
|
|
1 |
from py_code_analyzer import CodeFetcher, CodeImportsAnalyzer, ImportsGraphVisualizer
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
)
|
|
|
|
|
6 |
imports_graph = CodeImportsAnalyzer(python_files).analyze().generate_imports_graph()
|
7 |
ImportsGraphVisualizer().visualize(imports_graph)
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import streamlit.components.v1 as components
|
3 |
+
|
4 |
from py_code_analyzer import CodeFetcher, CodeImportsAnalyzer, ImportsGraphVisualizer
|
5 |
|
6 |
+
TITLE = "Python Code Analyzer"
|
7 |
+
st.set_page_config(page_title=TITLE, layout="wide")
|
8 |
+
st.title(TITLE)
|
9 |
+
st.markdown(
|
10 |
+
"The main purpose of the app is to allow Python developers navigate Python code base much "
|
11 |
+
+ "easier by showing dependencies among files included in the directory with better visualization."
|
12 |
+
)
|
13 |
+
st.markdown(
|
14 |
+
"**Checkout the source code [here](https://github.com/cyyeh/py-code-analyzer)**"
|
15 |
+
)
|
16 |
+
|
17 |
+
owner = st.text_input("Enter GitHub username", value="cyyeh")
|
18 |
+
repo = st.text_input("Enter GitHib repo name", value="py-code-analyzer")
|
19 |
+
path = st.text_input(
|
20 |
+
"Enter target directory path, if the value is empty, then the target directory will be the root directory",
|
21 |
+
value="py_code_analyzer",
|
22 |
)
|
23 |
+
|
24 |
+
python_files = CodeFetcher().get_python_files(owner, repo, path)
|
25 |
imports_graph = CodeImportsAnalyzer(python_files).analyze().generate_imports_graph()
|
26 |
ImportsGraphVisualizer().visualize(imports_graph)
|
27 |
+
|
28 |
+
imports_graph_html = open("nx.html", "r", encoding="utf-8")
|
29 |
+
imports_graph_html_text = imports_graph_html.read()
|
30 |
+
components.html(imports_graph_html_text, height=800)
|