diff --git a/PassgenCLI.py b/PassgenCLI.py index dfaf3c7..ac605ea 100644 --- a/PassgenCLI.py +++ b/PassgenCLI.py @@ -4,20 +4,29 @@ from logics.qr import generate_qr_text from logics.generate import alph_generate,pass_generate soglasie=["yes","y","д","да"] -nigative=["no","n","н","нет"] -lineal=int(input("Длина пароля: ")) -number=input("Использовать числа? [Д/н] ") -letterB=input("Использовать большие буквы? [Д/н] ") -letterS=input("Использовать маленькие буквы? [Д/н] ") -spec=input("Использовать спец символы? [Д/н] ") -variables=[number.lower(),letterB.lower(),letterS.lower(),spec.lower()] +while True: + try: + lineal=int(input("Длина пароля: ")) + break + except ValueError: + print("Это должно быть число!") +while True: + number=input("Использовать числа? [Д/н] ") + letterB=input("Использовать большие буквы? [Д/н] ") + letterS=input("Использовать маленькие буквы? [Д/н] ") + spec=input("Использовать спец символы? [Д/н] ") + variables=[number.lower(),letterB.lower(),letterS.lower(),spec.lower()] -for i in range(len(variables)): - if variables[i] in soglasie: - variables[i]=True - if variables[i] in nigative: + for i in range(len(variables)): + if variables[i] in soglasie: + variables[i]=True + else: variables[i]=False -number,letterB,letterS,spec=variables[0],variables[1],variables[2],variables[3] + number,letterB,letterS,spec=variables[0],variables[1],variables[2],variables[3] + if True in variables: + break + else: + print("Пустой пароль!") password_lst=alph_generate(number,letterB,letterS,spec) password=pass_generate(password_lst,lineal) print(password) diff --git a/logics/graph.py b/logics/graph.py index 4ddbdba..360257b 100644 --- a/logics/graph.py +++ b/logics/graph.py @@ -8,24 +8,22 @@ def graph(x,y): #Создаём двумерный массив, заполне return a def ggraph(n,xn,yn): - m = 0 + m = 1 b = graph(xn, yn) - av = [[-1,-1]] - masx = [i for i in range(0,xn)] - masy = [i for i in range(0,yn)] - timing = time.time() + x0 = 0 + y0 = 0 + from time import time + timing = time() while m < n+1: x = random.randint(0, xn-1) y = random.randint(0, yn-1) - x0 = av[len(av)-1][0] - y0 = av[len(av)-1][1] - a = [x0,y0,x,y] - if not((abs(x-x0)==abs(y-y0) and abs(y-y0)!=1)or (y==y0 and abs(x-x0)!=1) or (x==x0 and abs(y-y0)!=1)) and x0 in masx and y0 in masy and x in masx and y in masy and (b[y][x] == 0) or (x0==-1 and y0==-1): + if not((abs(x-x0) == abs(y-y0) and abs(y-y0) != 1)or (y == y0 and abs(x-x0) != 1) or (x == x0 and abs(y-y0) != 1)) and (b[y][x] == 0) or (m == 1): b[y][x] = m - av.append([x,y]) + x0 = x + y0 = y m += 1 - - if time.time() - timing > 0.06: + + if time() - timing > 0.06: b = None break else: @@ -34,6 +32,7 @@ def ggraph(n,xn,yn): return b + def find(matrix, value): value_indexs = [ ( matrix.index(row), row.index(value) ) for row in matrix if value in row] return value_indexs