Add show counts argument to show labels to get message counts

This commit is contained in:
Ross Scroggs
2016-05-23 16:39:00 -07:00
parent 1145faef56
commit 9b9aea9841
2 changed files with 15 additions and 5 deletions

View File

@ -4674,10 +4674,14 @@ def gmail_del_result(request_id, response, exception):
def showLabels(users):
i = 5
show_system = True
onlyUser = showCounts = False
while i < len(sys.argv):
if sys.argv[i].lower().replace(u'_', u'') == u'onlyuser':
show_system = False
myarg = sys.argv[i].lower().replace(u'_', u'')
if myarg == u'onlyuser':
onlyUser = True
i += 1
elif myarg == u'showcounts':
showCounts = True
i += 1
else:
print u'ERROR: %s is not a valid argument for "gam <users> show labels"' % sys.argv[i]
@ -4687,13 +4691,19 @@ def showLabels(users):
labels = callGAPI(gmail.users().labels(), u'list', userId=user, soft_errors=True)
if labels:
for label in labels[u'labels']:
if label[u'type'] == u'system' and not show_system:
if onlyUser and (label[u'type'] == u'system'):
continue
print convertUTF8(label[u'name'])
for a_key in label:
if a_key == u'name':
continue
print u' %s: %s' % (a_key, label[a_key])
if showCounts:
counts = callGAPI(gmail.users().labels(), u'get',
userId=user, id=label[u'id'],
fields=u'messagesTotal,messagesUnread,threadsTotal,threadsUnread')
for a_key in counts:
print u' %s: %s' % (a_key, counts[a_key])
print u''
def showGmailProfile(users):