knd_klinteplo/classes/users.py

28 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import os
class Users:
def __init__(self):
self.data = []
self.path = os.path.join(os.path.abspath('.'), 'data')
def get_users(self):
self.logins = []
main_dir = os.walk(self.path)
for d, dirs, files in main_dir:
self.logins.append(dirs)
return self.logins[0]
def get_passwords(self):
if not os.path.exists(self.path):
return "Папка data не существует. Создайте папку с необходимыми параметрами и запустите программу снова!"
self.emails = self.get_users()
if len(self.emails) > 0:
for user in self.emails:
with open(os.path.join(self.path, user, 'pass.txt'), 'r') as f:
log_pass = {'email': user, 'password': f.readline().split('\n')[0]}
self.data.append(log_pass)
else:
return "Нет ни одного пользователя! Заполните папку и запустите программу снова!"
return self.data