Update app.py
Browse files
app.py
CHANGED
|
@@ -44,7 +44,7 @@ def show_s(name,d_app,token):
|
|
| 44 |
line = line.split("/",1)[1]
|
| 45 |
line2 = line.replace("'","").replace(",","").replace("\n","")
|
| 46 |
spaces.append(line2)
|
| 47 |
-
print(f"{line2}")
|
| 48 |
return(gr.update(label="Spaces", choices=[s for s in spaces]),gr.update(label="Spaces", choices=[s for s in spaces]))
|
| 49 |
|
| 50 |
def show_f(repo,name,token):
|
|
@@ -55,16 +55,22 @@ def show_f(repo,name,token):
|
|
| 55 |
def load_space(r_name,s_name,d_app):
|
| 56 |
print(f'https://huggingface.co/spaces/{r_name}/{s_name}/raw/main/{d_app}')
|
| 57 |
r = requests.get(f'https://huggingface.co/spaces/{r_name}/{s_name}/raw/main/{d_app}')
|
| 58 |
-
#sf=d_app.split(".",1)[1]
|
| 59 |
-
#pf=d_app.split(".",1)[0]
|
| 60 |
-
#f_name=f'{pf}.{sf}'
|
| 61 |
-
|
| 62 |
file = open(f'{uid}/{d_app}','w')
|
| 63 |
file.writelines(r.text)
|
| 64 |
file.close()
|
| 65 |
o_file = open(f'{uid}/mod_{d_app}','w')
|
| 66 |
o_file.writelines(r.text)
|
| 67 |
return r.text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
def repl(rs,rt,d_app):
|
| 69 |
file = open(f'{uid}/{d_app}','r')
|
| 70 |
r_file = file.read()
|
|
@@ -149,13 +155,16 @@ with gr.Blocks() as build:
|
|
| 149 |
r_name = gr.Textbox(label="Source Repo")
|
| 150 |
s_name = gr.Dropdown(label="Spaces", choices=[])
|
| 151 |
d_app = gr.Dropdown(label="Files", choices=[])
|
|
|
|
|
|
|
| 152 |
with gr.Column():
|
| 153 |
rd_name = gr.Textbox(label="Dest Repo")
|
| 154 |
sd_name = gr.Dropdown(label="Spaces", choices=[])
|
| 155 |
dd_app = gr.Dropdown(label="Files", choices=[])
|
|
|
|
|
|
|
| 156 |
with gr.Row():
|
| 157 |
-
|
| 158 |
-
l_btn = gr.Button("Load")
|
| 159 |
with gr.Box():
|
| 160 |
r_s = gr.Textbox(label="Replace")
|
| 161 |
r_w = gr.Textbox(label="with:")
|
|
@@ -176,10 +185,14 @@ with gr.Blocks() as build:
|
|
| 176 |
with gr.Row():
|
| 177 |
a_files=gr.File()
|
| 178 |
z_files=gr.File()
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
au=gr.Textbox(visible=False)
|
| 184 |
uu=gr.Textbox(visible=False)
|
| 185 |
|
|
@@ -188,6 +201,11 @@ with gr.Blocks() as build:
|
|
| 188 |
|
| 189 |
f_btn.click(get_f,[r_name,ss_name,token],[a_files,z_files])
|
| 190 |
r_t.change(cyc,r_t,[m_t,files])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
|
| 192 |
s_btn.click(show_s,r_name,[s_name,ss_name])
|
| 193 |
s_name.change(show_f,[r_name,s_name],d_app)
|
|
|
|
| 44 |
line = line.split("/",1)[1]
|
| 45 |
line2 = line.replace("'","").replace(",","").replace("\n","")
|
| 46 |
spaces.append(line2)
|
| 47 |
+
#print(f"{line2}")
|
| 48 |
return(gr.update(label="Spaces", choices=[s for s in spaces]),gr.update(label="Spaces", choices=[s for s in spaces]))
|
| 49 |
|
| 50 |
def show_f(repo,name,token):
|
|
|
|
| 55 |
def load_space(r_name,s_name,d_app):
|
| 56 |
print(f'https://huggingface.co/spaces/{r_name}/{s_name}/raw/main/{d_app}')
|
| 57 |
r = requests.get(f'https://huggingface.co/spaces/{r_name}/{s_name}/raw/main/{d_app}')
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
file = open(f'{uid}/{d_app}','w')
|
| 59 |
file.writelines(r.text)
|
| 60 |
file.close()
|
| 61 |
o_file = open(f'{uid}/mod_{d_app}','w')
|
| 62 |
o_file.writelines(r.text)
|
| 63 |
return r.text
|
| 64 |
+
def load_space_d(r_name,s_name,d_app):
|
| 65 |
+
print(f'https://huggingface.co/spaces/{r_name}/{s_name}/raw/main/{d_app}')
|
| 66 |
+
r = requests.get(f'https://huggingface.co/spaces/{r_name}/{s_name}/raw/main/{d_app}')
|
| 67 |
+
file = open(f'{uid}/d{d_app}','w')
|
| 68 |
+
file.writelines(r.text)
|
| 69 |
+
file.close()
|
| 70 |
+
o_file = open(f'{uid}/mod_d_{d_app}','w')
|
| 71 |
+
o_file.writelines(r.text)
|
| 72 |
+
return r.text
|
| 73 |
+
|
| 74 |
def repl(rs,rt,d_app):
|
| 75 |
file = open(f'{uid}/{d_app}','r')
|
| 76 |
r_file = file.read()
|
|
|
|
| 155 |
r_name = gr.Textbox(label="Source Repo")
|
| 156 |
s_name = gr.Dropdown(label="Spaces", choices=[])
|
| 157 |
d_app = gr.Dropdown(label="Files", choices=[])
|
| 158 |
+
s_btn = gr.Button("Show")
|
| 159 |
+
l_btn = gr.Button("Load")
|
| 160 |
with gr.Column():
|
| 161 |
rd_name = gr.Textbox(label="Dest Repo")
|
| 162 |
sd_name = gr.Dropdown(label="Spaces", choices=[])
|
| 163 |
dd_app = gr.Dropdown(label="Files", choices=[])
|
| 164 |
+
sd_btn = gr.Button("Show")
|
| 165 |
+
ld_btn = gr.Button("Load")
|
| 166 |
with gr.Row():
|
| 167 |
+
|
|
|
|
| 168 |
with gr.Box():
|
| 169 |
r_s = gr.Textbox(label="Replace")
|
| 170 |
r_w = gr.Textbox(label="with:")
|
|
|
|
| 185 |
with gr.Row():
|
| 186 |
a_files=gr.File()
|
| 187 |
z_files=gr.File()
|
| 188 |
+
with gr.Tab("Source")
|
| 189 |
+
with gr.Row():
|
| 190 |
+
r_t=gr.Textbox(max_lines=100)
|
| 191 |
+
m_t=gr.Textbox(max_lines=100)
|
| 192 |
+
with gr.Tab("Dest")
|
| 193 |
+
with gr.Row():
|
| 194 |
+
rd_t=gr.Textbox(max_lines=100)
|
| 195 |
+
md_t=gr.Textbox(max_lines=100)
|
| 196 |
au=gr.Textbox(visible=False)
|
| 197 |
uu=gr.Textbox(visible=False)
|
| 198 |
|
|
|
|
| 201 |
|
| 202 |
f_btn.click(get_f,[r_name,ss_name,token],[a_files,z_files])
|
| 203 |
r_t.change(cyc,r_t,[m_t,files])
|
| 204 |
+
|
| 205 |
+
sd_btn.click(show_s,rd_name,[sd_name])
|
| 206 |
+
sd_name.change(show_f,[rd_name,sd_name],dd_app)
|
| 207 |
+
ld_btn.click(load_space_d,[rd_name,sd_name,dd_app],[rd_t])
|
| 208 |
+
|
| 209 |
|
| 210 |
s_btn.click(show_s,r_name,[s_name,ss_name])
|
| 211 |
s_name.change(show_f,[r_name,s_name],d_app)
|