Spaces:
Runtime error
Runtime error
Commit
·
ac7f34a
1
Parent(s):
e5ed1bd
Update app.py
Browse files
app.py
CHANGED
@@ -9,22 +9,10 @@ logger = logging.getLogger(__name__)
|
|
9 |
st.set_page_config(page_title="GitHub File Search", page_icon=":mag_right:")
|
10 |
access_token = "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"
|
11 |
|
12 |
-
def find_file(repo,
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
return None
|
17 |
-
|
18 |
-
for content in contents:
|
19 |
-
if content.type == "dir":
|
20 |
-
result = find_file(repo, content.path, filename)
|
21 |
-
if result:
|
22 |
-
return result
|
23 |
-
elif content.name == filename:
|
24 |
-
return content
|
25 |
-
except Exception as e:
|
26 |
-
logger.warning(f"Error while searching for '{filename}' in repository '{repo.full_name}': {str(e)}")
|
27 |
-
st.warning(f"Error while searching for '{filename}' in repository '{repo.full_name}': {str(e)}")
|
28 |
return None
|
29 |
|
30 |
def get_repositories_with_file(filename):
|
@@ -34,7 +22,8 @@ def get_repositories_with_file(filename):
|
|
34 |
|
35 |
for repo in repositories:
|
36 |
try:
|
37 |
-
|
|
|
38 |
if content:
|
39 |
repo_info.append({
|
40 |
"name": repo.name,
|
@@ -70,4 +59,4 @@ def app():
|
|
70 |
st.sidebar.text(logs)
|
71 |
|
72 |
if __name__ == "__main__":
|
73 |
-
app()
|
|
|
9 |
st.set_page_config(page_title="GitHub File Search", page_icon=":mag_right:")
|
10 |
access_token = "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"
|
11 |
|
12 |
+
def find_file(repo, contents, filename):
|
13 |
+
for content in contents:
|
14 |
+
if content.type == "file" and content.name == filename:
|
15 |
+
return content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
return None
|
17 |
|
18 |
def get_repositories_with_file(filename):
|
|
|
22 |
|
23 |
for repo in repositories:
|
24 |
try:
|
25 |
+
contents = repo.get_contents("", ref=repo.default_branch, recursive=True)
|
26 |
+
content = find_file(repo, contents, filename)
|
27 |
if content:
|
28 |
repo_info.append({
|
29 |
"name": repo.name,
|
|
|
59 |
st.sidebar.text(logs)
|
60 |
|
61 |
if __name__ == "__main__":
|
62 |
+
app()
|