diff --git a/docs/GamUpdates.md b/docs/GamUpdates.md index 97ea9f70..dfb9ff7a 100644 --- a/docs/GamUpdates.md +++ b/docs/GamUpdates.md @@ -10,6 +10,11 @@ Add the `-s` option to the end of the above commands to suppress creating the `g See [Downloads](https://github.com/taers232c/GAMADV-XTD3/wiki/Downloads) for Windows or other options, including manual installation +### 6.72.08 + +Added option `countsonly` to `gam print|show notes` that displays +the number of notes a user owns and the number of notes of user can edit. + ### 6.72.07 Updated commands that send emails to not downshift `'First Last'` to `'first last'`. diff --git a/docs/How-to-Upgrade-from-Standard-GAM.md b/docs/How-to-Upgrade-from-Standard-GAM.md index 2a1a89e2..82d8914e 100644 --- a/docs/How-to-Upgrade-from-Standard-GAM.md +++ b/docs/How-to-Upgrade-from-Standard-GAM.md @@ -334,7 +334,7 @@ writes the credentials into the file oauth2.txt. admin@server:/Users/admin/bin/gamadv-xtd3$ rm -f /Users/admin/GAMConfig/oauth2.txt admin@server:/Users/admin/bin/gamadv-xtd3$ ./gam version WARNING: Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: /Users/admin/GAMConfig/oauth2.txt, Not Found -GAMADV-XTD3 6.72.07 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.72.08 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.2 64-bit final MacOS Sonoma 14.2.1 x86_64 @@ -1006,7 +1006,7 @@ writes the credentials into the file oauth2.txt. C:\GAMADV-XTD3>del C:\GAMConfig\oauth2.txt C:\GAMADV-XTD3>gam version WARNING: Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: C:\GAMConfig\oauth2.txt, Not Found -GAMADV-XTD3 6.72.07 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.72.08 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.2 64-bit final Windows-10-10.0.17134 AMD64 diff --git a/docs/Users-Keep.md b/docs/Users-Keep.md index f4c868cf..fb1136f2 100644 --- a/docs/Users-Keep.md +++ b/docs/Users-Keep.md @@ -131,13 +131,17 @@ Display all notes ``` gam show notes [fields ] [filter ] - [role owner|writwer] + [role owner|writer] + [countsonly] [compact|formatjson] ``` By default, GAM displays all non-trashed notes: * `filter trashed` - Display notes in the trash * `role owner|writer` - Display notes where the user has the specified role +When option `countsonly` is specified, the number of notes a user owns and the number of notes of user can edit +if displayed. + By default, Gam displays the information as an indented list of keys and values; the note text is displayed as individual lines. * `compact` - Display the note text with escaped carriage returns as \r and newlines as \n * `formatjson` - Display the note in JSON format @@ -145,7 +149,8 @@ By default, Gam displays the information as an indented list of keys and values; ``` gam print notes [todrive *] [fields ] [filter ] - [role owner|writwer] + [role owner|writer] + [countsonly] [formatjson [quotechar ]] ``` @@ -153,6 +158,9 @@ By default, GAM displays all non-trashed notes: * `filter trashed` - Display notes in the trash * `role owner|writer` - Display notes where the user has the specified role +When option `countsonly` is specified, the number of notes a user owns and the number of notes of user can edit +if displayed. + By default, when writing CSV files, Gam uses a quote character of double quote `"`. The quote character is used to enclose columns that contain the quote character itself, the column delimiter (comma by default) and new-line characters. Any quote characters within the column are doubled. When using the `formatjson` option, double quotes are used extensively in the data resulting in hard to read/process output. diff --git a/docs/Version-and-Help.md b/docs/Version-and-Help.md index 219db774..55e1c677 100644 --- a/docs/Version-and-Help.md +++ b/docs/Version-and-Help.md @@ -3,7 +3,7 @@ Print the current version of Gam with details ``` gam version -GAMADV-XTD3 6.72.07 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.72.08 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.2 64-bit final MacOS Sonoma 14.2.1 x86_64 @@ -15,7 +15,7 @@ Time: 2023-06-02T21:10:00-07:00 Print the current version of Gam with details and time offset information ``` gam version timeoffset -GAMADV-XTD3 6.72.07 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.72.08 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.2 64-bit final MacOS Sonoma 14.2.1 x86_64 @@ -27,7 +27,7 @@ Your system time differs from www.googleapis.com by less than 1 second Print the current version of Gam with extended details and SSL information ``` gam version extended -GAMADV-XTD3 6.72.07 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.72.08 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.2 64-bit final MacOS Sonoma 14.2.1 x86_64 @@ -64,7 +64,7 @@ MacOS High Sierra 10.13.6 x86_64 Path: /Users/Admin/bin/gamadv-xtd3 Version Check: Current: 5.35.08 - Latest: 6.72.07 + Latest: 6.72.08 echo $? 1 ``` @@ -72,7 +72,7 @@ echo $? Print the current version number without details ``` gam version simple -6.72.07 +6.72.08 ``` In Linux/MacOS you can do: ``` @@ -82,7 +82,7 @@ echo $VER Print the current version of Gam and address of this Wiki ``` gam help -GAM 6.72.07 - https://github.com/taers232c/GAMADV-XTD3 +GAM 6.72.08 - https://github.com/taers232c/GAMADV-XTD3 Ross Scroggs Python 3.12.2 64-bit final MacOS Sonoma 14.2.1 x86_64 diff --git a/src/GamCommands.txt b/src/GamCommands.txt index e4190794..ca993081 100644 --- a/src/GamCommands.txt +++ b/src/GamCommands.txt @@ -7391,10 +7391,12 @@ gam info note gam show notes [fields ] [filter ] [role owner|writer] + [countsonly] [compact|formatjson] gam print notes [todrive *] [fields ] [filter ] [role owner|writer] + [countsonly] [formatjson [quotechar ]] gam get noteattachments diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index 864be73b..88173760 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -2,6 +2,11 @@ Merged GAM-Team version +6.72.08 + +Added option `countsonly` to `gam print|show notes` that displays +the number of notes a user owns and the number of notes of user can edit. + 6.72.07 Updated commands that send emails to not downshift `'First Last'` to `'first last'`. diff --git a/src/gam/__init__.py b/src/gam/__init__.py index b1f8469e..27296f16 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -70998,7 +70998,7 @@ def _assignNoteOwner(note, user): note['ownedByMe'] = noteOwner == user break -def _checkNoteUserkRole(note, user, role): +def _checkNoteUserRole(note, user, role): for permission in note['permissions']: if permission['role'] == role and permission.get('user', {}).get('email', '').lower() == user: return True @@ -71295,20 +71295,27 @@ NOTES_ROLE_CHOICE_MAP = { 'writer': 'WRITER', } +NOTES_COUNTS_MAP = { + 'OWNER': 'noteOwner', + 'WRITER': 'noteWriter', + } + # gam show notes # [fields ] [filter ] # [role owner|writer] +# [countsonly] # [compact] [formatjson] # gam print notes [todrive *] # [fields ] [filter ] # [role owner|writer] +# [countsonly] # [formatjson [quotechar ]] def printShowNotes(users): csvPF = CSVPrintFile(['User', 'name', 'title', 'owner', 'ownedByMe']) if Act.csvFormat() else None if csvPF: csvPF.SetNoEscapeChar(True) FJQC = FormatJSONQuoteChar(csvPF) - compact = False + compact = countsOnly = False fieldsList = [] noteFilter = None role = None @@ -71325,6 +71332,8 @@ def printShowNotes(users): role = getChoice(NOTES_ROLE_CHOICE_MAP, mapChoice=True) elif not csvPF and myarg == 'compact': compact = True + elif myarg == 'countsonly': + countsOnly = True else: FJQC.GetFormatJSONQuoteChar(myarg, True) if FJQC.formatJSON: @@ -71333,10 +71342,16 @@ def printShowNotes(users): showPermissions = False fieldsList.append('permissions') if csvPF: - if not FJQC.formatJSON: - csvPF.RemoveTitles(['owner', 'ownedByMe']) - else: - csvPF.RemoveJSONTitles(['owner', 'ownedByMe']) + if not countsOnly: + if not FJQC.formatJSON: + csvPF.RemoveTitles(['owner', 'ownedByMe']) + else: + csvPF.RemoveJSONTitles(['owner', 'ownedByMe']) + if countsOnly and csvPF: + if not FJQC.formatJSON: + csvPF.SetTitles(['User', 'noteOwner', 'noteWriter']) + else: + csvPF.SetJSONTitles(['User', 'JSON']) fields = getItemFieldsFromFieldsList('notes', fieldsList, returnItemIfNoneList=False) i, count, users = getEntityArgument(users) for user in users: @@ -71354,6 +71369,27 @@ def printShowNotes(users): pageMessage=pageMessage, throwReasons=GAPI.KEEP_THROW_REASONS, filter=noteFilter, fields=fields) + if countsOnly: + noteCounts = {'User': user, 'noteOwner': 0, 'noteWriter': 0} + for note in notes: + for permission in note['permissions']: + if permission.get('user', {}).get('email', '').lower() == user: + noteCounts[NOTES_COUNTS_MAP[permission['role']]] += 1 + break + if not csvPF: + if not FJQC.formatJSON: + printEntityKVList([Ent.USER, user], ['noteOwner', noteCounts['noteOwner'], 'noteWriter', noteCounts['noteWriter']], i, count) + else: + printLine(json.dumps(cleanJSON(noteCounts), ensure_ascii=False, sort_keys=True)) + else: + row = {'User': user, 'noteOwner': noteCounts['noteOwner'], 'noteWriter': noteCounts['noteWriter']} + if not FJQC.formatJSON: + csvPF.WriteRowTitles(row) + elif csvPF.CheckRowTitles(row): + row = {'User': noteCounts.pop('User')} + row['JSON'] = json.dumps(cleanJSON(noteCounts), ensure_ascii=False, sort_keys=True) + csvPF.WriteRowNoFilter(row) + continue if not csvPF: jcount = len(notes) if not FJQC.formatJSON: @@ -71364,7 +71400,7 @@ def printShowNotes(users): j += 1 if showPermissions: _assignNoteOwner(note, user) - if role is None or _checkNoteUserkRole(note, user, role): + if role is None or _checkNoteUserRole(note, user, role): if not showPermissions: note.pop('permissions', None) _showNote(note, j, jcount, FJQC, compact) @@ -71373,7 +71409,7 @@ def printShowNotes(users): for note in notes: if showPermissions: _assignNoteOwner(note, user) - if role is None or _checkNoteUserkRole(note, user, role): + if role is None or _checkNoteUserRole(note, user, role): if not showPermissions: note.pop('permissions', None) row = flattenJSON(note, flattened={'User': user}, timeObjects=NOTES_TIME_OBJECTS)