Omnibus commited on
Commit
6f4dbd0
·
1 Parent(s): cd61055

Update dl.py

Browse files
Files changed (1) hide show
  1. dl.py +5 -2
dl.py CHANGED
@@ -33,6 +33,7 @@ def show_f(repo,name,token):
33
  f_ist = (api.list_repo_files(repo_id=f'{repo}/{name}', repo_type="space"))
34
  print (f_ist)
35
  file_list = []
 
36
  if not os.path.exists(name):
37
  os.makedirs(name)
38
 
@@ -49,12 +50,13 @@ def show_f(repo,name,token):
49
  file.writelines(r.text)
50
  file.close()
51
  file_list.append(Path(f'{name}/{f_name}'))
 
52
  with ZipFile(f"{name}.zip", "w") as zipObj:
53
  for idx, file in enumerate(f_ist):
54
  zipObj.write(f'{name}/{file}')
55
  file_list.append(f'{name}.zip')
56
 
57
- return(gr.Dropdown.update(label="Spaces", choices=[f for f in f_ist]), file_list)
58
 
59
  def show_all(author,token):
60
  spaces=[]
@@ -62,6 +64,7 @@ def show_all(author,token):
62
  #author=name
63
  s_ist = (api.list_spaces(author=author))
64
  file_list = []
 
65
  for i,space in enumerate(s_ist):
66
  space_ea = space.id.split("/",1)[1]
67
  spaces.append(space_ea)
@@ -83,7 +86,7 @@ def show_all(author,token):
83
  file = open(f'{space_ea}/{f_name}','w')
84
  file.writelines(r.text)
85
  file.close()
86
- #file_list.append(Path(f'{space}/{f_name}'))
87
  except Exception:
88
  pass
89
  with ZipFile(f"{space_ea}.zip", "w") as zipObj:
 
33
  f_ist = (api.list_repo_files(repo_id=f'{repo}/{name}', repo_type="space"))
34
  print (f_ist)
35
  file_list = []
36
+ f_ist = []
37
  if not os.path.exists(name):
38
  os.makedirs(name)
39
 
 
50
  file.writelines(r.text)
51
  file.close()
52
  file_list.append(Path(f'{name}/{f_name}'))
53
+ f_ist.append(Path(f'{name}/{f_name}'))
54
  with ZipFile(f"{name}.zip", "w") as zipObj:
55
  for idx, file in enumerate(f_ist):
56
  zipObj.write(f'{name}/{file}')
57
  file_list.append(f'{name}.zip')
58
 
59
+ return(gr.Dropdown.update(label="Files", choices=[f for f in f_ist]), file_list)
60
 
61
  def show_all(author,token):
62
  spaces=[]
 
64
  #author=name
65
  s_ist = (api.list_spaces(author=author))
66
  file_list = []
67
+ file_list_ea=[]
68
  for i,space in enumerate(s_ist):
69
  space_ea = space.id.split("/",1)[1]
70
  spaces.append(space_ea)
 
86
  file = open(f'{space_ea}/{f_name}','w')
87
  file.writelines(r.text)
88
  file.close()
89
+ #file_list_ea.append(Path(f'{space}/{f_name}'))
90
  except Exception:
91
  pass
92
  with ZipFile(f"{space_ea}.zip", "w") as zipObj: