11# -*- coding: utf-8 -*-
2+ """Simple Python console app for storing passwords."""
23import base64
34import os
45import random
1516
1617
1718class Color :
19+ """Python specified values used for text formatting"""
1820 # Sources:
1921 # https://stackoverflow.com/questions/8924173/how-do-i-print-bold-text-in-python
2022 # http://ascii-table.com/ansi-escape-sequences.php
@@ -31,6 +33,7 @@ class Color:
3133
3234
3335class Program :
36+ """Infos about the program"""
3437 name = 'Python Password' # Work in progress
3538 version = '0.1' # Alpha
3639 author = 'Jakub S.'
@@ -39,6 +42,10 @@ class Program:
3942
4043
4144def header ():
45+ """
46+ Shows welcome text
47+ :return: Formatted text
48+ """
4249 foo = ''
4350 for i in range (len (Program .name ) + len (Program .version ) + 10 ):
4451 foo += '-'
@@ -61,11 +68,12 @@ def clear():
6168
6269
6370def confirm ():
71+ """Prints confirmation and waits for ENTER"""
6472 input ('\n ---\n \n Press ENTER to continue...' )
6573
6674
6775def show_records (records = None ):
68- # Default query - passwords' names
76+ """Shows specified values from database, for default passwords' names"""
6977 if records is None :
7078 records = query ('SELECT `name` FROM `passwords`;' )
7179
@@ -115,7 +123,7 @@ def check_files():
115123
116124 # ``key`` file
117125 try :
118- open (file ('master.key' ), 'r' )
126+ open (file ('master.key' ))
119127 except FileNotFoundError :
120128 print ('Key file not found! Creating one...' )
121129 generate_key ()
@@ -166,6 +174,7 @@ def rand_password(length: int = 16):
166174
167175# Option 1
168176def generate_key ():
177+ """Generates salt.key file based on user input"""
169178 password_input = input ('Provide master password: ' )
170179 password = password_input .encode ()
171180
@@ -199,6 +208,7 @@ def generate_key():
199208
200209# Option 2
201210def get_password ():
211+ """Decrypts password from database and saves it to clipboard"""
202212 print ('Available passwords:\n ' )
203213 show_records ()
204214
@@ -229,6 +239,7 @@ def get_password():
229239
230240# Option 3
231241def set_password ():
242+ """Saves encrypted and salted password to database"""
232243 password_name = input ('Provide password name (visible): ' )
233244 password_value = getpass ('Provide password value (or leave empty for random): ' )
234245
@@ -249,6 +260,7 @@ def set_password():
249260
250261# Option 4
251262def del_password ():
263+ """Deletes password from database, require confirmation"""
252264 print ('Available passwords:\n ' )
253265 show_records ()
254266
@@ -274,6 +286,7 @@ def del_password():
274286
275287# Option 5
276288def quick_start ():
289+ """Shows general info about the program"""
277290 print (f'Program name: { Program .name } \n '
278291 f'Current version: { Program .version } \n '
279292 f'Author: { Program .author } \n '
0 commit comments