Update app.py
Browse files
app.py
CHANGED
|
@@ -29,13 +29,15 @@ def init(filename=filename,save_data=save_data):
|
|
| 29 |
return lod
|
| 30 |
|
| 31 |
|
| 32 |
-
def sort_doc(in_list,
|
| 33 |
-
|
| 34 |
-
lod=init()
|
| 35 |
control_json={'control':'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','char':'','leng':62}
|
| 36 |
-
text=str(in_list)
|
| 37 |
key_cnt=len(in_list)
|
| 38 |
print(key_cnt)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
control_char=list(control_json['control'])
|
| 40 |
char_len=len(control_char)
|
| 41 |
if not steps_in:
|
|
@@ -46,34 +48,30 @@ def sort_doc(in_list,file_state=None,steps_in=0,control=None):
|
|
| 46 |
n_cnt+=1
|
| 47 |
nx = nx/char_len
|
| 48 |
else:
|
| 49 |
-
print("#######")
|
| 50 |
-
print(n_cnt)
|
| 51 |
-
print(nx)
|
| 52 |
-
print("#######")
|
| 53 |
steps=n_cnt
|
| 54 |
break
|
| 55 |
if steps_in:
|
| 56 |
steps=steps_in
|
| 57 |
-
|
| 58 |
if control:
|
| 59 |
-
control_len=control_json['leng']-
|
| 60 |
-
|
| 61 |
control_val=list(control_json['control'][control_len:])
|
| 62 |
val_len=len(control_val)
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
|
|
|
|
|
|
| 67 |
|
| 68 |
big_cnt=0
|
| 69 |
cnt=0
|
| 70 |
go=True
|
| 71 |
-
|
| 72 |
-
|
| 73 |
step_cont_box=[]
|
| 74 |
-
|
|
|
|
| 75 |
print("LOD")
|
| 76 |
-
last_key=list(
|
| 77 |
print(last_key)
|
| 78 |
for ea_dig in last_key:
|
| 79 |
ea_dig=control_json['control'].index(ea_dig)
|
|
@@ -83,19 +81,16 @@ def sort_doc(in_list,file_state=None,steps_in=0,control=None):
|
|
| 83 |
step_cont_box.append(ea_dig)
|
| 84 |
print(step_cont_box)
|
| 85 |
cnt=int(step_cont_box[-1])+1
|
| 86 |
-
if not
|
| 87 |
print("NOT LOD")
|
| 88 |
for ii in range(steps):
|
| 89 |
print(ii)
|
| 90 |
step_cont_box.append(0)
|
| 91 |
-
#print (step_cont_box)
|
| 92 |
-
mod=0
|
| 93 |
-
pos=len(step_cont_box)-1
|
| 94 |
|
|
|
|
| 95 |
if go:
|
| 96 |
for i, ea in enumerate(in_list):
|
| 97 |
-
|
| 98 |
-
if go and ea not in list(lod.values()):
|
| 99 |
if cnt > char_len-1:
|
| 100 |
#print(step_cont_box)
|
| 101 |
go1=True
|
|
@@ -113,21 +108,13 @@ def sort_doc(in_list,file_state=None,steps_in=0,control=None):
|
|
| 113 |
#print(step_cont_box)
|
| 114 |
out_js=""
|
| 115 |
for iii,j in enumerate(step_cont_box):
|
| 116 |
-
print(j)
|
| 117 |
out_js = out_js+control_char[j]
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
json_out[out_js]=sen_obj
|
| 121 |
-
#print ("#################")
|
| 122 |
-
#print (out_js)
|
| 123 |
-
#print (sen_obj)
|
| 124 |
-
#print ("#################")
|
| 125 |
-
|
| 126 |
big_cnt+=1
|
| 127 |
if big_cnt==key_cnt:
|
| 128 |
print("DONE")
|
| 129 |
go=False
|
| 130 |
-
#noun_list=proc_nouns(json_out)
|
| 131 |
return json_out
|
| 132 |
|
| 133 |
|
|
|
|
| 29 |
return lod
|
| 30 |
|
| 31 |
|
| 32 |
+
def sort_doc(in_list: list, steps_in: int, control: int, prev_list: str):
|
| 33 |
+
prev_list=init()
|
|
|
|
| 34 |
control_json={'control':'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','char':'','leng':62}
|
|
|
|
| 35 |
key_cnt=len(in_list)
|
| 36 |
print(key_cnt)
|
| 37 |
+
|
| 38 |
+
#if isinstance(in_list, str):
|
| 39 |
+
# in_list=eval(in_list)
|
| 40 |
+
|
| 41 |
control_char=list(control_json['control'])
|
| 42 |
char_len=len(control_char)
|
| 43 |
if not steps_in:
|
|
|
|
| 48 |
n_cnt+=1
|
| 49 |
nx = nx/char_len
|
| 50 |
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
steps=n_cnt
|
| 52 |
break
|
| 53 |
if steps_in:
|
| 54 |
steps=steps_in
|
|
|
|
| 55 |
if control:
|
| 56 |
+
control_len=control_json['leng']-control
|
| 57 |
+
control_char=list(control_json['control'][:control_len])
|
| 58 |
control_val=list(control_json['control'][control_len:])
|
| 59 |
val_len=len(control_val)
|
| 60 |
+
control_val_box=[]
|
| 61 |
+
for ea in control_val:
|
| 62 |
+
control_val_box.append(ea)
|
| 63 |
+
print(f'CONTROL_VAL_BOX:: {control_val_box}')
|
| 64 |
+
#prev_list=control_val_box
|
| 65 |
+
json_out={}
|
| 66 |
|
| 67 |
big_cnt=0
|
| 68 |
cnt=0
|
| 69 |
go=True
|
|
|
|
|
|
|
| 70 |
step_cont_box=[]
|
| 71 |
+
|
| 72 |
+
if prev_list:
|
| 73 |
print("LOD")
|
| 74 |
+
last_key=list(prev_list.keys())[-1]
|
| 75 |
print(last_key)
|
| 76 |
for ea_dig in last_key:
|
| 77 |
ea_dig=control_json['control'].index(ea_dig)
|
|
|
|
| 81 |
step_cont_box.append(ea_dig)
|
| 82 |
print(step_cont_box)
|
| 83 |
cnt=int(step_cont_box[-1])+1
|
| 84 |
+
if not prev_list:
|
| 85 |
print("NOT LOD")
|
| 86 |
for ii in range(steps):
|
| 87 |
print(ii)
|
| 88 |
step_cont_box.append(0)
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
+
pos=len(step_cont_box)-1
|
| 91 |
if go:
|
| 92 |
for i, ea in enumerate(in_list):
|
| 93 |
+
if go:
|
|
|
|
| 94 |
if cnt > char_len-1:
|
| 95 |
#print(step_cont_box)
|
| 96 |
go1=True
|
|
|
|
| 108 |
#print(step_cont_box)
|
| 109 |
out_js=""
|
| 110 |
for iii,j in enumerate(step_cont_box):
|
| 111 |
+
#print(j)
|
| 112 |
out_js = out_js+control_char[j]
|
| 113 |
+
json_out[out_js]=in_list[i]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
big_cnt+=1
|
| 115 |
if big_cnt==key_cnt:
|
| 116 |
print("DONE")
|
| 117 |
go=False
|
|
|
|
| 118 |
return json_out
|
| 119 |
|
| 120 |
|