Not-Grim-Refer commited on
Commit
eebbcf7
·
1 Parent(s): ac7f34a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -9,11 +9,14 @@ 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, 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):
19
  g = Github(access_token)
@@ -22,8 +25,7 @@ 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,
 
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, filename):
13
+ contents = repo.get_contents("", ref=repo.default_branch)
14
+ while contents:
15
+ content = contents.pop(0)
16
  if content.type == "file" and content.name == filename:
17
  return content
18
+ elif content.type == "dir":
19
+ contents.extend(repo.get_contents(content.path))
20
 
21
  def get_repositories_with_file(filename):
22
  g = Github(access_token)
 
25
 
26
  for repo in repositories:
27
  try:
28
+ content = find_file(repo, filename)
 
29
  if content:
30
  repo_info.append({
31
  "name": repo.name,