lists.arthurdejong.org
RSS feed

python-pskc branch master updated. 0.5-13-g6028b8e

[Date Prev][Date Next] [Thread Prev][Thread Next]

python-pskc branch master updated. 0.5-13-g6028b8e



This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "python-pskc".

The branch, master has been updated
       via  6028b8e1f0bc2e5aa5486152a03a1856f226d507 (commit)
      from  eef681bfda4692ff5b232d319773482196a5a7ec (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://arthurdejong.org/git/python-pskc/commit/?id=6028b8e1f0bc2e5aa5486152a03a1856f226d507

commit 6028b8e1f0bc2e5aa5486152a03a1856f226d507
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Fri Sep 22 13:17:39 2017 +0200

    Support adding custom CSV file headers
    
    This allows adding an optional label to the --columns option that can be
    used to output a label different from the key property name in the CSV
    file header.

diff --git a/pskc2csv.py b/pskc2csv.py
index 7a7ed32..6830d28 100755
--- a/pskc2csv.py
+++ b/pskc2csv.py
@@ -81,8 +81,9 @@ parser.add_argument(
     '-o', '--output', metavar='FILE',
     help='write CSV to file instead of stdout')
 parser.add_argument(
-    '-c', '--columns', metavar='COL,COL', type=lambda x: x.split(','),
-    help='list of columns to export',
+    '-c', '--columns', metavar='COL:LABEL,COL,..',
+    type=lambda x: [column.split(':', 1) for column in x.split(',')],
+    help='list of columns with optional labels to export',
     default='serial,secret,algorithm,response_length,time_interval')
 parser.add_argument(
     '-p', '--password', '--passwd', metavar='PASS/FILE',
@@ -149,8 +150,8 @@ if __name__ == '__main__':
     # open output CSV file, write header and keys
     with open(args.output, 'wb') if args.output else sys.stdout as output:
         csvfile = csv.writer(output, quoting=csv.QUOTE_MINIMAL)
-        csvfile.writerow(args.columns)
+        csvfile.writerow([column[-1] for column in args.columns])
         for key in pskcfile.keys:
             csvfile.writerow([
-                get_column(key, column, args.secret_encoding)
+                get_column(key, column[0], args.secret_encoding)
                 for column in args.columns])

-----------------------------------------------------------------------

Summary of changes:
 pskc2csv.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
python-pskc
-- 
To unsubscribe send an email to
python-pskc-commits-unsubscribe@lists.arthurdejong.org or see
https://lists.arthurdejong.org/python-pskc-commits/