Skip to content

Commit

Permalink
Update test.py
Browse files Browse the repository at this point in the history
  • Loading branch information
kotazzz committed Jan 28, 2021
1 parent 82c1bab commit 0c19762
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
from NewLifeUtils.RequestModule import req_get

counter = 0
current = ''
current = ""


def complete(readed, completes):
print(f'{ACC.CLEARSCREEN}')
print(f"{ACC.CLEARSCREEN}")
next = False
if len(readed) > 0:
if readed[-1] == ' ':
if readed[-1] == " ":
next = True

def build_readed(args, ins_spase=False):
new_readed = ' '.join(args)
new_readed = " ".join(args)
if ins_spase:
new_readed += ' '
new_readed += " "
return new_readed

def find_aval(word, possible):
Expand Down Expand Up @@ -51,32 +51,32 @@ def next_layer(complete_words, key):
for argnum, arg in enumerate(parsed_readed, start=0):
if len(find_aval(arg, complete_words)) == 0:
aval = []
predict_curr = ''
predict_curr = ""
else:
for argnum, arg in enumerate(parsed_readed, start=0):
aval = find_aval(arg, complete_words)
global current
print(f'{FGC.BBLUE}{aval} ({current})')
print(f"{FGC.BBLUE}{aval} ({current})")
if len(aval) == 1:
parsed_readed[argnum] = aval[0]
predict_curr = ''
predict_curr = ""
if len(aval) > 1:
predict_curr = predict(arg, aval, next)
if next:
predict_curr = predict(aval)
return build_readed(parsed_readed, True), '', complete_words
return build_readed(parsed_readed, True), "", complete_words
complete_words = next_layer(complete_words, predict_curr)
print(f'{FGC.BYELLOW}aval - {aval}')
print(f'{FGC.BYELLOW}gen complete_words - {complete_words}')
print(f"{FGC.BYELLOW}aval - {aval}")
print(f"{FGC.BYELLOW}gen complete_words - {complete_words}")

print(f'{FGC.RED} RES: {predict_curr} / {" ".join(aval)}')
print(ACC.RESET)
return build_readed(parsed_readed, False), predict_curr, aval


def smart_input(text='', completes={}, end='\n'):
readed = ''
print(text + MCC.save_cursor, end='')
def smart_input(text="", completes={}, end="\n"):
readed = ""
print(text + MCC.save_cursor, end="")
sys.stdout.flush()
while True:
key = getwch()
Expand All @@ -87,21 +87,21 @@ def smart_input(text='', completes={}, end='\n'):
else:
if ord(key) == 8:
readed = readed[:-1]
print(MCC.load_cursor + MCC.erase_nxt_line + readed, end='')
print(MCC.load_cursor + MCC.erase_nxt_line + readed, end="")

elif ord(key) == 13:
break
elif ord(key) == 9:
readed, predict, aval = complete(readed, completes)
complete(readed, completes)
print(MCC.load_cursor + MCC.erase_nxt_line + readed, end='')
print(MCC.load_cursor + MCC.erase_nxt_line + readed, end="")
else:
readed += key
print(MCC.load_cursor + MCC.erase_nxt_window + readed, end='')
print(MCC.load_cursor + MCC.erase_nxt_window + readed, end="")
sys.stdout.flush()
print(end)
return readed


if __name__ == '__main__':
print('Hello World')
if __name__ == "__main__":
print("Hello World")

0 comments on commit 0c19762

Please sign in to comment.