55import pyperclip
66
77from pw_config import CREDS_DIR , CREDS_FILE_PATH , ENCRYPTION_KEY
8- from pw_client import PasswordClient
8+ from pw_client import SecretsDataJSONClient
99from pw_encryption import SynchronousEncryption
1010from pw_utils import generate_random_password
1111from pw_utils import HelpTexts as h
1414def main ():
1515 args = parse_args ()
1616 crypto = SynchronousEncryption (ENCRYPTION_KEY )
17- pw_client = PasswordClient (CREDS_DIR , CREDS_FILE_PATH )
18- pw = PasswordCommand (pw_client , crypto , args )
17+ pw_json_client = SecretsDataJSONClient (CREDS_DIR , CREDS_FILE_PATH )
18+ pw = PasswordCommand (pw_json_client , crypto , args )
1919
2020 # pw -d
2121 if args .debug :
@@ -121,22 +121,22 @@ def parse_args():
121121 return args
122122
123123class PasswordCommand :
124- def __init__ (self , pw_client : PasswordClient ,
124+ def __init__ (self , pw_client : SecretsDataJSONClient ,
125125 crypto : SynchronousEncryption ,
126126 args : argparse .ArgumentParser ):
127- self .pw = pw_client
127+ self .pw_client = pw_client
128128 self .crypto = crypto
129129 self .args = args
130130
131131 def print_sections (self ):
132- pprint (self .pw .get_sections ())
132+ pprint (self .pw_client .get_sections ())
133133 return True
134134
135135 def print_keys_of_section (self ):
136- self .pw .print_keys_of_section (self .args .section )
136+ self .pw_client .print_keys_of_section (self .args .section )
137137
138138 def create_section (self ):
139- return self .pw .create_section (self .args .section )
139+ return self .pw_client .create_section (self .args .section )
140140
141141 def add_new_secrets_data (self ):
142142 args = self .args
@@ -146,7 +146,7 @@ def add_new_secrets_data(self):
146146 if args .set_password :
147147 new_password = args .set_password
148148 else :
149- new_password = self .pw .generate_random_password (
149+ new_password = self .pw_client .generate_random_password (
150150 password_length = args .random_password_length ,
151151 special_characters = args .no_special_characters )
152152 pyperclip .copy (new_password )
@@ -173,30 +173,30 @@ def add_new_secrets_data(self):
173173 encrypted_value = self .crypto .encrypt (value )
174174 secrets_data [key ] = encrypted_value
175175
176- self .pw .add_new_secrets_data (entity = args .new_secrets_data ,
176+ self .pw_client .add_new_secrets_data (entity = args .new_secrets_data ,
177177 secrets_data = secrets_data ,
178178 section = args .section ,
179179 overwrite = args .overwrite )
180180
181181 return True
182182
183183 def get_secrets_data (self ):
184- secrets_data = self .pw .get_secrets_data (
184+ secrets_data = self .pw_client .get_secrets_data (
185185 entity = self .args .entity ,
186186 section = self .args .section )
187187 return secrets_data
188188
189189 def remove_secrets_data (self ):
190190 key = self .args .remove_entity
191- self .pw .remove_secrets_data (key , self .args .section )
191+ self .pw_client .remove_secrets_data (key , self .args .section )
192192 return True
193193
194194 def remove_section (self ):
195- self .pw .remove_section (self .args .remove_section )
195+ self .pw_client .remove_section (self .args .remove_section )
196196 return True
197197
198198 def find_secrets_data (self ):
199- results_as_generator = self .pw .find_key (self .args .find )
199+ results_as_generator = self .pw_client .find_key (self .args .find )
200200 results = list (results_as_generator )
201201 for result in results :
202202 print (f'Found "{ result ["entity" ]} " in section "{ result ["section" ]} ".' )
0 commit comments