From f4e6cdf0d0c5586d77f04495308d39556245a213 Mon Sep 17 00:00:00 2001 From: Davide Alberani Date: Sun, 15 Oct 2017 11:18:24 +0200 Subject: [PATCH] add -s to just have the count --- tools/duplicates.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/duplicates.py b/tools/duplicates.py index 6d424de..62a6c1a 100755 --- a/tools/duplicates.py +++ b/tools/duplicates.py @@ -5,7 +5,7 @@ import sys import monco -def info(event, key): +def info(event, key, short=False): tickets = event['tickets'] data = {} for ticket in tickets: @@ -19,7 +19,10 @@ def info(event, key): for key, value in data.items(): if len(value) < 2: continue - print('%s : %s' % (key, ', '.join(value))) + output = '%s (%d persons)' % (key, len(value)) + if not short: + output += ': %s' % ', '.join(value) + print(output) print('') @@ -27,7 +30,7 @@ def run(): try: db = monco.Monco(dbName='eventman') events = db.query('events', {'title': sys.argv[1]}) - info(events[0], sys.argv[2]) + info(events[0], sys.argv[2], short='-s' in sys.argv[1:]) except: print('duplicates.py "title of event" key') sys.exit(1)