From 2ef7aafc89776176d121de937016a328575b785a Mon Sep 17 00:00:00 2001 From: Thibaut Giroud Date: Thu, 24 Mar 2022 13:31:10 +0100 Subject: [PATCH 1/3] feat: added support for export of one file/item --- pass2csv | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pass2csv b/pass2csv index 71bcdf5..9deefa9 100755 --- a/pass2csv +++ b/pass2csv @@ -96,7 +96,12 @@ def main(store_path, grouping_base, outfile, gpgbinary, use_agent, encodings, path = pathlib.Path(store_path) grouping_path = pathlib.Path(grouping_base) gpg = gnupg.GPG(gpgbinary=gpgbinary, use_agent=use_agent) - for file in path.glob('**/*.gpg'): + if not path.is_dir(): + if store_path[-4:] == '.gpg': + files = [path] + else: + files = path.glob('**/*.gpg') + for file in files: logging.info("Processing %s", file) with open(file, 'rb') as fp: decrypted = gpg.decrypt_file(fp) From 8c545b27af08a0d89d222e33f4b38fb95de278a6 Mon Sep 17 00:00:00 2001 From: Thibaut Giroud Date: Tue, 29 Mar 2022 16:26:06 +0200 Subject: [PATCH 2/3] fix: issue when you submit wrong file name, error was misleading --- pass2csv | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pass2csv b/pass2csv index 9deefa9..6729479 100755 --- a/pass2csv +++ b/pass2csv @@ -96,11 +96,10 @@ def main(store_path, grouping_base, outfile, gpgbinary, use_agent, encodings, path = pathlib.Path(store_path) grouping_path = pathlib.Path(grouping_base) gpg = gnupg.GPG(gpgbinary=gpgbinary, use_agent=use_agent) + files = path.glob('**/*.gpg') if not path.is_dir(): - if store_path[-4:] == '.gpg': - files = [path] - else: - files = path.glob('**/*.gpg') + #if store_path[-4:] == '.gpg': + files = [path] for file in files: logging.info("Processing %s", file) with open(file, 'rb') as fp: From e4788b98ca9406835f3a3739e974762d79451e0c Mon Sep 17 00:00:00 2001 From: Thibaut Giroud Date: Tue, 29 Mar 2022 16:48:14 +0200 Subject: [PATCH 3/3] fix: added relevant error message if file is missing --- pass2csv | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pass2csv b/pass2csv index 6729479..4d1b9aa 100755 --- a/pass2csv +++ b/pass2csv @@ -98,8 +98,12 @@ def main(store_path, grouping_base, outfile, gpgbinary, use_agent, encodings, gpg = gnupg.GPG(gpgbinary=gpgbinary, use_agent=use_agent) files = path.glob('**/*.gpg') if not path.is_dir(): - #if store_path[-4:] == '.gpg': - files = [path] + if path.is_file(): + files = [path] + else: + err="No shuch file or directory: {}".format(path) + logging.error(err) + exit(1) for file in files: logging.info("Processing %s", file) with open(file, 'rb') as fp: