Added option showmimetype category <MimeTypeNameList> to gam <UserTypeEntity> print|show filecounts|filelist|filetree

This commit is contained in:
Ross Scroggs
2024-03-06 17:13:01 -08:00
parent 63d7b5568b
commit 623ff1fae9
8 changed files with 73 additions and 35 deletions

View File

@@ -10,6 +10,16 @@ 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.71.12
Added option `showmimetype category <MimeTypeNameList>` to `gam <UserTypeEntity> print|show filecounts|filelist|filetree`
```
<MimeTypeName> ::= application|audio|font|image|message|model|multipart|text|video
<MimeTypeNameList> ::= "<MimeTypeName>(,<MimeTypeName>)*"
gam user user@domain.com print filelist fields id,name,mimetype showmimetype prefixes audio,video
```
### 6.71.11
Added option `addcsvdata <FieldName> <String>` to `gam print cros` that adds

View File

@@ -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.71.11 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
GAMADV-XTD3 6.71.12 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com>
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.71.11 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
GAMADV-XTD3 6.71.12 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.2 64-bit final
Windows-10-10.0.17134 AMD64

View File

@@ -69,6 +69,7 @@
<MatterStateList> ::= "<MatterState>(,<MatterState>)*"
<MessageIDList> ::= "<MessageID>(,<MessageID>)*"
<MimeTypeList> ::= "<MimeType>(,<MimeType>)*"
<MimeTypeNameList> ::= "<MimeTypeName>(,<MimeTypeName>)*"
<NamespaceList> ::= "<Namespace>(,<Namespace>)*"
<NotesNameList> ::= "<NotesName>(,<NotesName>)*"
<OrgUnitList> ::= "<OrgUnitItem>(,<OrgUnitItem>)*"

View File

@@ -71,6 +71,7 @@
g3pshortcut|
gsite
<MimeTypeName> ::= application|audio|font|image|message|model|multipart|text|video
<MimeTypeNameList> ::= "<MimeTypeName>(,<MimeTypeName>)*"
<MimeType> ::= <MimeTypeShortcut>|(<MimeTypeName>/<String>)
<MimeTypeList> ::= "<MimeType>(,<MimeType>)*"
```
@@ -611,9 +612,11 @@ By default, all types of files and folders are selected. You can specify a list
This option updates the current query.
```
showmimetype [not] <MimeTypeList>
showmimetype category <MimeTypeNameList>
```
* `showmimetype <MimeTypeList>` - Select files and folders with the specified MIME types
* `showmimetype not <MimeTypeList>` - Select files and folders with MIME types other than those specified
* `showmimetype category <MimeTypeNameList>` - Select files and folders with the specified MIME type categories
## File selection by file size
These options would typically be used with `showmimetype` to select files of a particular type. This
@@ -649,7 +652,7 @@ gam <UserTypeEntity> print filecounts [todrive <ToDriveAttribute>*]
[corpora <CorporaAttribute>]
[select <SharedDriveEntity>]
[anyowner|(showownedby any|me|others)]
[showmimetype [not] <MimeTypeList>]
[showmimetype [not] <MimeTypeList>] [showmimetype category <MimeTypeNameList>]
[sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[filenamematchpattern <RegularExpression>]
<PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
@@ -662,7 +665,7 @@ gam <UserTypeEntity> show filecounts
[corpora <CorporaAttribute>]
[select <SharedDriveEntity>]
[anyowner|(showownedby any|me|others)]
[showmimetype [not] <MimeTypeList>]
[showmimetype [not] <MimeTypeList>] [showmimetype category <MimeTypeNameList>]
[sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[filenamematchpattern <RegularExpression>]
<PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
@@ -894,7 +897,7 @@ gam <UserTypeEntity> print filetree [todrive <ToDriveAttribute>*]
[select <DriveFileEntity> [selectsubquery <QueryDriveFile>]
[depth <Number>]]
[anyowner|(showownedby any|me|others)]
[showmimetype [not] <MimeTypeList>]
[showmimetype [not] <MimeTypeList>] [showmimetype category <MimeTypeNameList>]
[sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[filenamematchpattern <RegularExpression>]
<PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
@@ -906,7 +909,7 @@ gam <UserTypeEntity> show filetree
[select <DriveFileEntity> [selectsubquery <QueryDriveFile>]
[depth <Number>]]
[anyowner|(showownedby any|me|others)]
[showmimetype [not] <MimeTypeList>]
[showmimetype [not] <MimeTypeList>] [showmimetype category <MimeTypeNameList>]
[sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[filenamematchpattern <RegularExpression>]
<PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
@@ -999,7 +1002,7 @@ gam <UserTypeEntity> print|show filelist [todrive <ToDriveAttribute>*]
[select <DriveFileEntity> [selectsubquery <QueryDriveFile>]
[(norecursion [<Boolean>])|(depth <Number>)] [showparent]]
[anyowner|(showownedby any|me|others)]
[showmimetype [not] <MimeTypeList>] [mimetypeinquery [<Boolean>]]
[showmimetype [not] <MimeTypeList>] [showmimetype category <MimeTypeNameList>] [mimetypeinquery [<Boolean>]]
[sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[filenamematchpattern <RegularExpression>]
<PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>] [pmfilter] [oneitemperrow]

View File

@@ -3,7 +3,7 @@
Print the current version of Gam with details
```
gam version
GAMADV-XTD3 6.71.11 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
GAMADV-XTD3 6.71.12 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com>
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.71.11 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
GAMADV-XTD3 6.71.12 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com>
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.71.11 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
GAMADV-XTD3 6.71.12 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com>
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.71.11
Latest: 6.71.12
echo $?
1
```
@@ -72,7 +72,7 @@ echo $?
Print the current version number without details
```
gam version simple
6.71.11
6.71.12
```
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.71.11 - https://github.com/taers232c/GAMADV-XTD3
GAM 6.71.12 - https://github.com/taers232c/GAMADV-XTD3
Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.2 64-bit final
MacOS Sonoma 14.2.1 x86_64

View File

@@ -709,6 +709,7 @@ If an item contains spaces, it should be surrounded by ".
<MatterStateList> ::= "<MatterState>(,<MatterState>)*"
<MessageIDList> ::= "<MessageID>(,<MessageID>)*"
<MimeTypeList> ::= "<MimeType>(,<MimeType>)*"
<MimeTypeNameList> ::= "<MimeTypeName>(,<MimeTypeName>)*"
<NamespaceList> ::= "<Namespace>(,<Namespace>)*"
<NotesNameList> ::= "<NotesName>(,<NotesName>)*"
<OrgUnitList> ::= "<OrgUnitItem>(,<OrgUnitItem>)*"
@@ -6676,7 +6677,7 @@ gam <UserTypeEntity> print filecounts [todrive <ToDriveAttribute>*]
[corpora <CorporaAttribute>]
[select <SharedDriveEntity>]
[anyowner|(showownedby any|me|others)]
[showmimetype [not] <MimeTypeList>]
[showmimetype [not] <MimeTypeList>] [showmimetype category <MimeTypeNameList>]
[sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[filenamematchpattern <RegularExpression>]
<PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
@@ -6689,7 +6690,7 @@ gam <UserTypeEntity> show filecounts
[corpora <CorporaAttribute>]
[select <SharedDriveEntity>]
[anyowner|(showownedby any|me|others)]
[showmimetype [not] <MimeTypeList>]
[showmimetype [not] <MimeTypeList>] [`<showmimetype category <MimeTypeNameList>]
[sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[filenamematchpattern <RegularExpression>]
<PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
@@ -6721,7 +6722,7 @@ gam <UserTypeEntity> print filetree [todrive <ToDriveAttribute>*]
[select <DriveFileEntity> [selectsubquery <QueryDriveFile>]
[depth <Number>]]
[anyowner|(showownedby any|me|others)]
[showmimetype [not] <MimeTypeList>]
[showmimetype [not] <MimeTypeList>] [showmimetype category <MimeTypeNameList>]
[sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[filenamematchpattern <RegularExpression>]
<PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
@@ -6733,7 +6734,7 @@ gam <UserTypeEntity> show filetree
[select <DriveFileEntity> [selectsubquery <QueryDriveFile>]
[depth <Number>]]
[anyowner|(showownedby any|me|others)]
[showmimetype [not] <MimeTypeList>]
[showmimetype [not] <MimeTypeList>] [showmimetype category <MimeTypeNameList>]
[sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[filenamematchpattern <RegularExpression>]
<PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
@@ -6753,7 +6754,7 @@ gam <UserTypeEntity> print filelist [todrive <ToDriveAttribute>*]
[select <DriveFileEntity> [selectsubquery <QueryDriveFile>]
[(norecursion [<Boolean>])|(depth <Number>)] [showparent]]
[anyowner|(showownedby any|me|others)]
[showmimetype [not] <MimeTypeList>] [mimetypeinquery [<Boolean>]]
[showmimetype [not] <MimeTypeList>] [showmimetype category <MimeTypeNameList>] [mimetypeinquery [<Boolean>]]
[sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[filenamematchpattern <RegularExpression>]
<PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>] [pmfilter] [oneitemperrow]

View File

@@ -2,6 +2,18 @@
Merged GAM-Team version
6.71.12
Added option `showmimetype category <MimeTypeNameList>` to `gam <UserTypeEntity> print|show filecounts|filelist|filetree`
```
<MimeTypeName> ::= application|audio|font|image|message|model|multipart|text|video
<MimeTypeNameList> ::= "<MimeTypeName>(,<MimeTypeName>)*"
gam user user@domain.com print filelist fields id,name,mimetype showmimetype prefixes audio,video
```
Fix bug in `gam <UserTypeEntity> info|show sheet <DriveFileEntity>` that caused a trap.
6.71.11
Added option `addcsvdata <FieldName> <String>` to `gam print cros` that adds

View File

@@ -8887,8 +8887,7 @@ def flattenJSON(topStructure, flattened=None,
# Show a json object
def showJSON(showName, showValue, skipObjects=None, timeObjects=None,
simpleLists=None, dictObjectsKey=None, sortDictKeys=True,
noIndents=False):
simpleLists=None, dictObjectsKey=None, sortDictKeys=True):
def _show(objectName, objectValue, subObjectKey, level, subSkipObjects):
if objectName in subSkipObjects:
return
@@ -8920,7 +8919,7 @@ def showJSON(showName, showValue, skipObjects=None, timeObjects=None,
if objectName is not None:
printBlankLine()
Ind.Increment()
elif (level > 0) and not noIndents:
elif level > 0:
indentAfterFirst = unindentAfterLast = True
subObjects = sorted(objectValue) if sortDictKeys else objectValue.keys()
if subObjectKey and (subObjectKey in subObjects):
@@ -21336,8 +21335,7 @@ def _showPerson(userEntityType, user, entityType, person, i, count, FJQC, parame
if not FJQC.formatJSON:
printEntity([userEntityType, user, entityType, person['resourceName']], i, count)
Ind.Increment()
# showJSON(None, person, noIndents=True)
showJSON(None, person, noIndents=False)
showJSON(None, person)
Ind.Decrement()
else:
printLine(json.dumps(cleanJSON(person), ensure_ascii=False, sort_keys=True))
@@ -22410,7 +22408,7 @@ def _showContactGroup(userEntityType, user, entityType, contactGroup, i, count,
normalizedContactGroup = _normalizeContactGroupMetadata(contactGroup)
printEntity([userEntityType, user, entityType, contactGroup['resourceName']], i, count)
Ind.Increment()
showJSON(None, normalizedContactGroup, timeObjects=PEOPLE_GROUP_TIME_OBJECTS, noIndents=True)
showJSON(None, normalizedContactGroup, timeObjects=PEOPLE_GROUP_TIME_OBJECTS)
Ind.Decrement()
def _printContactGroup(entityTypeName, user, contactGroup, csvPF, FJQC):
@@ -50576,8 +50574,16 @@ class MimeTypeCheck():
def __init__(self):
self.mimeTypes = set()
self.reverse = False
self.category = set()
def Get(self):
if checkArgumentPresent('category'):
for mimeType in getString(Cmd.OB_MIMETYPE_LIST).lower().replace(',', ' ').split():
if mimeType in MIMETYPE_TYPES:
self.category.add(mimeType)
else:
invalidChoiceExit(mimeType, MIMETYPE_TYPES, True)
return
self.reverse = checkArgumentPresent('not')
for mimeType in getString(Cmd.OB_MIMETYPE_LIST).lower().replace(',', ' ').split():
self.mimeTypes.add(validateMimeType(mimeType))
@@ -50590,6 +50596,8 @@ class MimeTypeCheck():
if not self.reverse:
for mimeType in self.mimeTypes:
query += f"mimeType = '{mimeType}' or "
for mimeType in self.category:
query += f"mimeType contains '{mimeType}' or "
query = query[:-4]
else:
for mimeType in self.mimeTypes:
@@ -50599,8 +50607,11 @@ class MimeTypeCheck():
return query
def Check(self, fileEntry):
if not self.mimeTypes:
if not self.mimeTypes and not self.category:
return True
for mimeType in self.category:
if fileEntry['mimeType'].startswith(mimeType):
return True
if not self.reverse:
return fileEntry['mimeType'] in self.mimeTypes
return fileEntry['mimeType'] not in self.mimeTypes
@@ -53178,7 +53189,7 @@ class DriveListParameters():
def AddMimeTypeToQuery(self):
if not self.fileIdEntity:
self.fileIdEntity = initDriveFileEntity()
if self.mimeTypeCheck.mimeTypes:
if self.mimeTypeCheck.mimeTypes or self.mimeTypeCheck.category:
self.fileIdEntity['query'] = self.mimeTypeCheck.AddMimeTypeToQuery(self.fileIdEntity['query'])
def Finalize(self, fileIdEntity):
@@ -53273,7 +53284,7 @@ SIZE_FIELD_CHOICE_MAP = {
# [select <DriveFileEntity> [selectsubquery <QueryDriveFile>]
# [(norecursion [<Boolean>])|(depth <Number>)] [showparent]]
# [anyowner|(showownedby any|me|others)]
# [showmimetype [not] <MimeTypeList>] [mimetypeinquery [<Boolean>]]
# [showmimetype [not] <MimeTypeList>] [showmimetype category <MimeTypeNameList>] [mimetypeinquery [<Boolean>]]
# [sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
# [filenamematchpattern <RegularExpression>]
# <PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>] [pmfilter] [oneitemperrow]
@@ -54090,7 +54101,7 @@ def printFileParentTree(users):
# [corpora <CorporaAttribute>]
# [select <SharedDriveEntity>]
# [anyowner|(showownedby any|me|others)]
# [showmimetype [not] <MimeTypeList>]
# [showmimetype [not] <MimeTypeList>] [showmimetype category <MimeTypeNameList>]
# [sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
# [filenamematchpattern <RegularExpression>]
# <PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
@@ -54101,7 +54112,7 @@ def printFileParentTree(users):
# [corpora <CorporaAttribute>]
# [select <SharedDriveEntity>]
# [anyowner|(showownedby any|me|others)]
# [showmimetype [not] <MimeTypeList>]
# [showmimetype [not] <MimeTypeList>] [showmimetype category <MimeTypeNameList>]
# [sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
# [filenamematchpattern <RegularExpression>]
# <PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
@@ -54638,7 +54649,7 @@ FILETREE_FIELDS_PRINT_ORDER = ['id', 'parents', 'owners', 'mimeType', 'size', 'e
# gam <UserTypeEntity> print filetree [todrive <ToDriveAttribute>*]
# [select <DriveFileEntity> [selectsubquery <QueryDriveFile>] [depth <Number>]]
# [anyowner|(showownedby any|me|others)]
# [showmimetype [not] <MimeTypeList>]
# [showmimetype [not] <MimeTypeList>] [showmimetype category <MimeTypeNameList>]
# [sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
# [filenamematchpattern <RegularExpression>]
# <PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
@@ -54649,7 +54660,7 @@ FILETREE_FIELDS_PRINT_ORDER = ['id', 'parents', 'owners', 'mimeType', 'size', 'e
# gam <UserTypeEntity> show filetree
# [select <DriveFileEntity> [selectsubquery <QueryDriveFile>] [depth <Number>]]
# [anyowner|(showownedby any|me|others)]
# [showmimetype [not] <MimeTypeList>]
# [showmimetype [not] <MimeTypeList>] [showmimetype category <MimeTypeNameList>]
# [sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
# [filenamematchpattern <RegularExpression>]
# <PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
@@ -64928,18 +64939,18 @@ def infoPrintShowSheets(users):
Ind.Increment()
if 'spreadsheetUrl' in result:
printKeyValueList(['spreadsheetUrl', result['spreadsheetUrl']])
for field in ['properties', 'sheets', 'namedRanges', 'developerMetadata']:
for field in ['properties', 'sheets', 'namedRanges', 'developerMetadata', 'dataSources', 'dataSourceSchedules']:
if field in result:
if field != 'sheets':
showJSON(field, result[field])
else:
jcount = len(result[field])
j = 0
for sheet in result[field]:
for usheet in result[field]:
j += 1
printEntity([Ent.SHEET, sheet.get('properties', {}).get('title', '')], j, jcount)
printEntity([Ent.SHEET, usheet.get('properties', {}).get('title', '')], j, jcount)
Ind.Increment()
showJSON(None, sheet, noIndents=True)
showJSON(None, usheet)
Ind.Decrement()
Ind.Decrement()
else: