Better check for failed GPG decryption.

This commit is contained in:
Nolan Darilek 2019-05-18 09:11:58 -05:00
parent c54ff5d948
commit 39f79aacd2

View file

@ -88,7 +88,6 @@ class CSVExporter():
return (user, url, '\n'.join(notes).strip()) return (user, url, '\n'.join(notes).strip())
def parse(self, basepath, path, data): def parse(self, basepath, path, data):
name = os.path.splitext(os.path.basename(path))[0] name = os.path.splitext(os.path.basename(path))[0]
group = os.path.dirname(os.path.os.path.relpath(path, basepath)) group = os.path.dirname(os.path.os.path.relpath(path, basepath))
split_data = data.split('\n', maxsplit=1) split_data = data.split('\n', maxsplit=1)
@ -116,7 +115,7 @@ def main(kpx_format, gpgbinary, use_agent, pass_path):
if os.path.splitext(file_path)[1] == '.gpg': if os.path.splitext(file_path)[1] == '.gpg':
with open(file_path, 'rb') as f: with open(file_path, 'rb') as f:
data = str(gpg.decrypt_file(f)) data = str(gpg.decrypt_file(f))
if str == "": if len(data) == 0:
raise ValueError("The password file is empty") raise ValueError("The password file is empty")
csv_data.append(exporter.parse(pass_path, file_path, data)) csv_data.append(exporter.parse(pass_path, file_path, data))