From 4a0e61a385a00aa62888d5e1395d10b3d8a89eb0 Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Wed, 21 May 2025 16:42:54 -0700 Subject: [PATCH] Added eventrowfilter to print events ... countsonly --- src/GamCommands.txt | 4 ++-- src/GamUpdate.txt | 11 +++++++++++ src/gam/__init__.py | 45 +++++++++++++++++++++++++++++++++++++-------- 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/src/GamCommands.txt b/src/GamCommands.txt index e3e88943..11df3333 100644 --- a/src/GamCommands.txt +++ b/src/GamCommands.txt @@ -1862,7 +1862,7 @@ gam calendar|calendars show events [] print events [] * [fields ] [showdayofweek] - [countsonly] + [countsonly [eventrowfilter]] [formatjson [quotechar ]] [todrive *] gam calendar addevent + [] @@ -6099,7 +6099,7 @@ gam show events [] print events [] * [fields ] [showdayofweek] - [countsonly] + [countsonly [eventrowfilter]] [formatjson [quotechar ]] [todrive *] gam update calattendees [anyorganizer] diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index 0e9c6700..537159f3 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -1,3 +1,14 @@ +7.07.06 + +Added option `eventrowfilter` to `gam calendars print events ... countsonly` +and `gam print events ... countsonly` that causes +GAM to apply `config csv_output_row_filter` to the event details rather than the event counts. +This will be useful when `` and `` do not have the +capabilty to select the events of interest; e.g., you want to filter based on the event `created` property. + +Dropped the extraneous `id` column for `gam calendars print events ... countsonly` +and `gam print events ... countsonly`. + 7.07.05 Updated `gam move drivefile` to recognize the API error: `ERROR: 400: shareOutWarning`. diff --git a/src/gam/__init__.py b/src/gam/__init__.py index 2b1e85b3..81cc180c 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -25,7 +25,7 @@ https://github.com/GAM-team/GAM/wiki """ __author__ = 'GAM Team ' -__version__ = '7.07.05' +__version__ = '7.07.06' __license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)' #pylint: disable=wrong-import-position @@ -38592,7 +38592,8 @@ def _getCalendarListEventsDisplayProperty(myarg, calendarEventEntity): def initCalendarEventEntity(): return {'list': [], 'queries': [], 'kwargs': {}, 'dict': None, - 'matches': [], 'maxinstances': -1, 'countsOnly': False, 'showDayOfWeek': False} + 'matches': [], 'maxinstances': -1, 'showDayOfWeek': False, + 'countsOnly': False, 'eventRowFilter': False, 'countsOnlyTitles': []} def getCalendarEventEntity(): calendarEventEntity = initCalendarEventEntity() @@ -39637,11 +39638,25 @@ def _printShowCalendarEvents(origUser, user, origCal, calIds, count, calendarEve elif GC.Values[GC.CSV_OUTPUT_USERS_AUDIT] and user: csvPF.WriteRowNoFilter({'calendarId': calId, 'primaryEmail': user, 'id': ''}) else: + if calendarEventEntity['eventRowFilter']: + jcount = 0 + for event in events: + if calendarEventEntity['showDayOfWeek']: + _getEventDaysOfWeek(event) + row = {'calendarId': calId, 'id': event['id']} + if user: + row['primaryEmail'] = user + flattenJSON(event, flattened=row, timeObjects=EVENT_TIME_OBJECTS) + if csvPF.CheckRowTitles(row): + jcount += 1 row = {'calendarId': calId} if user: row['primaryEmail'] = user row['events'] = jcount - csvPF.WriteRow(row) + if not calendarEventEntity['eventRowFilter']: + csvPF.WriteRow(row) + else: + csvPF.WriteRowNoFilter(row) EVENT_FIELDS_CHOICE_MAP = { 'anyonecanaddself': 'anyoneCanAddSelf', @@ -39879,13 +39894,17 @@ def _getCalendarPrintShowEventOptions(calendarEventEntity, entityType): calendarEventEntity['countsOnly'] = True elif myarg == 'showdayofweek': calendarEventEntity['showDayOfWeek'] = True + elif myarg == 'eventrowfilter': + calendarEventEntity['eventRowFilter'] = True else: FJQC.GetFormatJSONQuoteChar(myarg, True) - if calendarEventEntity['countsOnly']: + if calendarEventEntity['countsOnly'] and not calendarEventEntity['eventRowFilter']: fieldsList = ['id'] if csvPF: if calendarEventEntity['countsOnly']: + csvPF.RemoveTitles(['id']) csvPF.AddTitles(['events']) + calendarEventEntity['countsOnlyTitles'] = csvPF.titlesList[:] elif not FJQC.formatJSON and not fieldsList: csvPF.AddSortTitles(EVENT_PRINT_ORDER) _addEventEntitySelectFields(calendarEventEntity, fieldsList) @@ -39893,16 +39912,21 @@ def _getCalendarPrintShowEventOptions(calendarEventEntity, entityType): # gam calendars print events * # [fields ] [showdayofweek] -# [countsonly] [formatjson [quotechar ]] [todrive *] +# [countsonly [eventrowfilter]] +# [formatjson [quotechar ]] [todrive *] # gam calendars show events * # [fields ] [showdayofweek] -# [countsonly] [formatjson] +# [countsonly] +# [formatjson] def doCalendarsPrintShowEvents(calIds): calendarEventEntity = getCalendarEventEntity() csvPF, FJQC, fieldsList = _getCalendarPrintShowEventOptions(calendarEventEntity, Ent.CALENDAR) _printShowCalendarEvents(None, None, None, calIds, len(calIds), calendarEventEntity, csvPF, FJQC, fieldsList) if csvPF: + if calendarEventEntity['countsOnly'] and calendarEventEntity['eventRowFilter']: + csvPF.SetRowFilter([], GC.Values[GC.CSV_OUTPUT_ROW_FILTER_MODE]) + csvPF.SetTitles(calendarEventEntity['countsOnlyTitles']) csvPF.writeCSVfile('Calendar Events') # ::== @@ -51371,10 +51395,12 @@ def infoCalendarEvents(users): # gam print events * # [fields ] [showdayofweek] -# [countsonly] [formatjson [quotechar ]] [todrive *] +# [countsonly [eventrowfilter]] +# [formatjson [quotechar ]] [todrive *] # gam show events * # [fields ] [showdayofweek] -# [countsonly] [formatjson] +# [countsonly]] +# [formatjson] def printShowCalendarEvents(users): calendarEntity = getUserCalendarEntity() calendarEventEntity = getCalendarEventEntity() @@ -51392,6 +51418,9 @@ def printShowCalendarEvents(users): csvPF, FJQC, fieldsList) Ind.Decrement() if csvPF: + if calendarEventEntity['countsOnly'] and calendarEventEntity['eventRowFilter']: + csvPF.SetRowFilter([], GC.Values[GC.CSV_OUTPUT_ROW_FILTER_MODE]) + csvPF.SetTitles(calendarEventEntity['countsOnlyTitles']) csvPF.writeCSVfile('Calendar Events') def getStatusEventDateTime(dateType, dateList):