Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -116,41 +116,36 @@ vCARD_data = {
|
|
116 |
def test_fn(fill, back, v_data_0,v_data_1,v_data_2,v_data_3,v_data_4,v_data_5,v_data_6,v_data_7,v_data_8,v_data_9,v_data_10,v_data_11):
|
117 |
out_vcard = """BEGIN:VCARD
|
118 |
VERSION:4.0"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
try:
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
out_vcard = f"{out_vcard}\n{list(vCARD_data.values())[1]}{v_data_1}"
|
125 |
-
if v_data_2 != "":
|
126 |
-
out_vcard = f"{out_vcard}\n{list(vCARD_data.values())[2]}{v_data_2}"
|
127 |
-
if v_data_3 != "":
|
128 |
-
out_vcard = f"{out_vcard}\n{list(vCARD_data.values())[3]}{v_data_3}"
|
129 |
-
if v_data_4 != "":
|
130 |
-
out_vcard = f"{out_vcard}\n{list(vCARD_data.values())[4]}{v_data_4}"
|
131 |
-
if v_data_5 != "":
|
132 |
-
out_vcard = f"{out_vcard}\n{list(vCARD_data.values())[5]}{v_data_5}"
|
133 |
-
if v_data_6 != "":
|
134 |
-
out_vcard = f"{out_vcard}\n{list(vCARD_data.values())[6]}{v_data_6}"
|
135 |
-
if v_data_7 != "":
|
136 |
-
out_vcard = f"{out_vcard}\n{list(vCARD_data.values())[7]}{v_data_7}"
|
137 |
-
if v_data_8 != "":
|
138 |
-
out_vcard = f"{out_vcard}\n{list(vCARD_data.values())[8]}{v_data_8}"
|
139 |
-
if v_data_9 != "":
|
140 |
-
out_vcard = f"{out_vcard}\n{list(vCARD_data.values())[9]}{v_data_9}"
|
141 |
-
if v_data_10 != "":
|
142 |
-
out_vcard = f"{out_vcard}\n{list(vCARD_data.values())[10]}{v_data_10}"
|
143 |
-
if v_data_11 != "":
|
144 |
-
out_vcard = f"{out_vcard}\n{list(vCARD_data.values())[11]}{v_data_11}"
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
out_vcard = f"{out_vcard}\nEND:VCARD"
|
151 |
-
out_qr = init_fn(fill, back, out_vcard)
|
152 |
-
|
153 |
-
return out_qr
|
154 |
|
155 |
|
156 |
with gr.Blocks() as app:
|
@@ -188,7 +183,7 @@ with gr.Blocks() as app:
|
|
188 |
with gr.Row(visible=False):
|
189 |
txt_cnt=gr.Textbox(value=0)
|
190 |
im_cnt=gr.Textbox(value=0)
|
191 |
-
init_btn.click(test_fn, [fill, back, v_data_0,v_data_1,v_data_2,v_data_3,v_data_4,v_data_5,v_data_6,v_data_7,v_data_8,v_data_9,v_data_10,v_data_11], qr_out)
|
192 |
#im_size.change(cnt_im_bytes,[data_box,txt_cnt,im_size],[im_cnt,tot_cnt],show_progress=False)
|
193 |
#data_box.change(cnt_im_bytes,[data_box,txt_cnt,im_size],[im_cnt,tot_cnt],show_progress=False)
|
194 |
txt_box.change(cnt_bytes,[txt_box,im_cnt],[txt_cnt,tot_cnt],show_progress=False)
|
|
|
116 |
def test_fn(fill, back, v_data_0,v_data_1,v_data_2,v_data_3,v_data_4,v_data_5,v_data_6,v_data_7,v_data_8,v_data_9,v_data_10,v_data_11):
|
117 |
out_vcard = """BEGIN:VCARD
|
118 |
VERSION:4.0"""
|
119 |
+
if v_data_0 != "":
|
120 |
+
out_vcard = f"{out_vcard}\n{list(vCARD_data.values())[0]}{v_data_0}"
|
121 |
+
if v_data_1 != "":
|
122 |
+
out_vcard = f"{out_vcard}\n{list(vCARD_data.values())[1]}{v_data_1}"
|
123 |
+
if v_data_2 != "":
|
124 |
+
out_vcard = f"{out_vcard}\n{list(vCARD_data.values())[2]}{v_data_2}"
|
125 |
+
if v_data_3 != "":
|
126 |
+
out_vcard = f"{out_vcard}\n{list(vCARD_data.values())[3]}{v_data_3}"
|
127 |
+
if v_data_4 != "":
|
128 |
+
out_vcard = f"{out_vcard}\n{list(vCARD_data.values())[4]}{v_data_4}"
|
129 |
+
if v_data_5 != "":
|
130 |
+
out_vcard = f"{out_vcard}\n{list(vCARD_data.values())[5]}{v_data_5}"
|
131 |
+
if v_data_6 != "":
|
132 |
+
out_vcard = f"{out_vcard}\n{list(vCARD_data.values())[6]}{v_data_6}"
|
133 |
+
if v_data_7 != "":
|
134 |
+
out_vcard = f"{out_vcard}\n{list(vCARD_data.values())[7]}{v_data_7}"
|
135 |
+
if v_data_8 != "":
|
136 |
+
out_vcard = f"{out_vcard}\n{list(vCARD_data.values())[8]}{v_data_8}"
|
137 |
+
if v_data_9 != "":
|
138 |
+
out_vcard = f"{out_vcard}\n{list(vCARD_data.values())[9]}{v_data_9}"
|
139 |
+
if v_data_10 != "":
|
140 |
+
out_vcard = f"{out_vcard}\n{list(vCARD_data.values())[10]}{v_data_10}"
|
141 |
+
if v_data_11 != "":
|
142 |
+
out_vcard = f"{out_vcard}\n{list(vCARD_data.values())[11]}{v_data_11}"
|
143 |
+
out_vcard = f"{out_vcard}\nEND:VCARD"
|
144 |
try:
|
145 |
+
out_qr = init_fn(out_vcard, fill, back)
|
146 |
+
except Exception:
|
147 |
+
out_qr = None
|
148 |
+
return out_vcard, out_qr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
|
150 |
|
151 |
with gr.Blocks() as app:
|
|
|
183 |
with gr.Row(visible=False):
|
184 |
txt_cnt=gr.Textbox(value=0)
|
185 |
im_cnt=gr.Textbox(value=0)
|
186 |
+
init_btn.click(test_fn, [fill, back, v_data_0,v_data_1,v_data_2,v_data_3,v_data_4,v_data_5,v_data_6,v_data_7,v_data_8,v_data_9,v_data_10,v_data_11], [txt_box,qr_out])
|
187 |
#im_size.change(cnt_im_bytes,[data_box,txt_cnt,im_size],[im_cnt,tot_cnt],show_progress=False)
|
188 |
#data_box.change(cnt_im_bytes,[data_box,txt_cnt,im_size],[im_cnt,tot_cnt],show_progress=False)
|
189 |
txt_box.change(cnt_bytes,[txt_box,im_cnt],[txt_cnt,tot_cnt],show_progress=False)
|