Программа должна выводить меня и после вызывать def в соответствии с выбором пользователя. Но 2 и 4 не вызывается.
import zipfile
import time
import os
class Archive:
def __init__(self, path, description):
self.path = path
self.description = description
self.password = None
def getinfo(self):
print("Path: " + self.path + "\nDesc:" + self.description + "\nPassword:" + str(self.password))
class Bruteforce:
def __init__(self, dictionary):
self.dictionary = dictionary
def hack(self, archive):
zip_file = zipfile.ZipFile(archive)
password = None
f = open(self.dictionary, 'r')
for line in f.readlines():
password = line.strip('\n')
try:
zip_file.extractall(pwd=password.encode())
print("-------------------")
print("RESULT: " + password)
f.close()
return (True, password)
except:
print(password)
f.close()
return (False, None)
class Library:
def __init__(self, bruteforce):
self.bruteforce = bruteforce
self.archives = []
def addarchives():
print("Введите название архива: ")
name = input()
arc = zipfile.ZipFile(f'{name}.zip', 'w')
arc.close()
def showarchives(self):
for archive in self.archives:
archive.getinfo()
print("")
def delarchives(self):
pass
def hackall(self):
for archive in self.archives:
if archive.password == None:
res = self.bruteforce.hack(archive.path)
if res[0] == True:
archive.password = res[1]
class Menu:
def start():
print("1.Add archive\n2.Show archive\n3.Delete archive\n4.Hack archive\n---------------")
num = int(input())
if num == 1:
Library.addarchives()
elif num == 2:
Library.showarchives()
elif num == 3:
Library.delarchives()
elif num == 4:
Library.hackall()
else:
time.sleep(0.2)
print("Error\n---------------")
time.sleep(0.2)
Menu.start()
Menu.start()
Ошибка:
TypeError: Library.showarchives() missing 1 required positional argument: 'self'