add -s to just have the count

This commit is contained in:
Davide Alberani 2017-10-15 11:18:24 +02:00
parent d22ea9a0d6
commit f4e6cdf0d0

View file

@ -5,7 +5,7 @@ import sys
import monco import monco
def info(event, key): def info(event, key, short=False):
tickets = event['tickets'] tickets = event['tickets']
data = {} data = {}
for ticket in tickets: for ticket in tickets:
@ -19,7 +19,10 @@ def info(event, key):
for key, value in data.items(): for key, value in data.items():
if len(value) < 2: if len(value) < 2:
continue continue
print('%s : %s' % (key, ', '.join(value))) output = '%s (%d persons)' % (key, len(value))
if not short:
output += ': %s' % ', '.join(value)
print(output)
print('') print('')
@ -27,7 +30,7 @@ def run():
try: try:
db = monco.Monco(dbName='eventman') db = monco.Monco(dbName='eventman')
events = db.query('events', {'title': sys.argv[1]}) 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: except:
print('duplicates.py "title of event" key') print('duplicates.py "title of event" key')
sys.exit(1) sys.exit(1)