mirror of
https://github.com/GAM-team/GAM.git
synced 2026-06-28 09:51:36 +00:00
Added commands to display drive file comments
This commit is contained in:
@@ -10,6 +10,12 @@ 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.00
|
||||
|
||||
Added commands to display drive file comments.
|
||||
|
||||
* See: https://github.com/taers232c/GAMADV-XTD3/wiki/Users-Drive-Comments
|
||||
|
||||
### 6.71.18
|
||||
|
||||
Updated `<CrOSFieldName>` to include `cpuinfo` and `backlightinfo`.
|
||||
|
||||
@@ -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.18 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
|
||||
GAMADV-XTD3 6.72.00 - 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.18 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
|
||||
GAMADV-XTD3 6.72.00 - 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
|
||||
|
||||
@@ -6,6 +6,7 @@ Thank you.
|
||||
|
||||
* Gabriel Clifton - https://docs.google.com/document/d/1p32QOBTr89GaG7RfCafSbFuhlUQ9r3qBM_666E0xvQM/edit
|
||||
* Steve Larsen - https://docs.google.com/spreadsheets/d/1MzzA-u-cmoQcJnQOovCnZcEKMjvOyFhfkdFdf10X_GI/edit
|
||||
* Iain Macleod - https://docs.google.com/document/d/1QxWAPdhROcx70OXLpSD9Trh3vs-nJKSMiaMZCTwOOTg/edit?pli=1#heading=h.2a2azzpy36k0
|
||||
* Kevin Melillo - https://github.com/KevinMelilloIEEE/gam-script
|
||||
* James Seymour - https://sites.google.com/jis.edu.bn/gam-commands/home
|
||||
* Amado Tejada - https://github.com/amadotejada/GAMpass
|
||||
|
||||
102
docs/Users-Drive-Comments.md
Normal file
102
docs/Users-Drive-Comments.md
Normal file
@@ -0,0 +1,102 @@
|
||||
# Users - Drive - Comments
|
||||
- [API documentation](#api-documentation)
|
||||
- [Query documentation](Users-Drive-Query)
|
||||
- [Definitions](#definitions)
|
||||
- [Display file comments](#display-file-comments)
|
||||
|
||||
## API documentation
|
||||
* https://developers.google.com/drive/api/v3/reference/comments
|
||||
|
||||
## Definitions
|
||||
* [`<DriveFileEntity>`](Drive-File-Selection)
|
||||
* [`<UserTypeEntity>`](Collections-of-Users)
|
||||
|
||||
```
|
||||
<DomainName> ::= <String>(.<String>)+
|
||||
<EmailAddress> ::= <String>@<DomainName>
|
||||
<UniqueID> ::= id:<String>
|
||||
<UserItem> ::= <EmailAddress>|<UniqueID>|<String>
|
||||
|
||||
<CommentsAuthorSubfieldName> ::=
|
||||
author.displayname|
|
||||
author.emailaddress|
|
||||
author.me|
|
||||
author.permissionid|
|
||||
author.photolink
|
||||
|
||||
<CommentsRepliesSubfieldName> ::=
|
||||
replies.action|
|
||||
replies.author|
|
||||
replies.author.<CommentsAuthorSubfieldName>|
|
||||
replies.content|
|
||||
replies.createddate|createdtime|
|
||||
replies.deleted|
|
||||
replies.htmlcontent|
|
||||
replies.id|
|
||||
replies.modifieddate|modifiedtime
|
||||
|
||||
<CommentsFieldName> ::=
|
||||
action|
|
||||
author|
|
||||
content|
|
||||
<CommentsAuthorSubfieldName>|
|
||||
<CommentsRepliesSubfieldName>|
|
||||
createddate|createdtime|
|
||||
deleted|
|
||||
htmlcontent|
|
||||
id|
|
||||
modifieddate|modifiedtime|
|
||||
quotedfilecontent|
|
||||
replies|
|
||||
resolved
|
||||
<CommentsFieldNameList> ::= "<CommentsFieldName>(,<CommentsFieldName>)*"
|
||||
```
|
||||
|
||||
## Display file comments
|
||||
### Display as an indented list of keys and values.
|
||||
```
|
||||
gam <UserTypeEntity> show filecomments <DriveFileEntity>
|
||||
[showdeleted] [start <Date>|<Time>]
|
||||
[fields <CommentsFieldNameList>] [showphotolinks]
|
||||
[countsonly]
|
||||
[formatjson]
|
||||
```
|
||||
By default, all non-deleted comments for a file are displayed; use these options to modify that behavior.
|
||||
* `showdeleted` - Display deleted comments
|
||||
* `start <Date>|<Time>` - Display comments modified on or after `<Date>|<Time>`
|
||||
|
||||
By default, all comment and reply fields except author photolinks are displayed; use these options to modify that behavior.
|
||||
* `fields <CommentsFieldNameList>` - Select fields to display
|
||||
* `showphotolinks` - Display author photolinks
|
||||
* `countsonly` - Display just the number of comments and replies; no fields
|
||||
|
||||
By default, Gam displays the information as an indented list of keys and values.
|
||||
* `formatjson` - Display the fields in JSON format.
|
||||
|
||||
### Display as a CSV file.
|
||||
Each comment/reply pair is output on a separate CSV file row.
|
||||
```
|
||||
gam <UserTypeEntity> print filecomments <DriveFileEntity> [todrive <ToDriveAttribute>*]
|
||||
[showdeleted] [start <Date>|<Time>] [countsonly]
|
||||
[fields <CommentsFieldNameList>] [showphotolinks]
|
||||
(addcsvdata <FieldName> <String>)*
|
||||
[formatjson [quotechar <Character>]]
|
||||
```
|
||||
By default, all non-deleted comments for a file are displayed; use these options to modify that behavior.
|
||||
Files with no comments will not be displayed.
|
||||
* `showdeleted` - Display deleted comments
|
||||
* `start <Date>|<Time>` - Display comments modified on or after `<Date>|<Time>`
|
||||
|
||||
By default, all comment and reply fields except author photolinks are displayed; use these options to modify that behavior.
|
||||
* `fields <CommentsFieldNameList>` - Select fields to display
|
||||
* `showphotolinks` - Display author photolinks
|
||||
* `countsonly` - Display just the number of comments and replies; no fields. Files with no comments will display zero counts.
|
||||
|
||||
Add additional columns of data from the command line to the output:
|
||||
* `addcsvdata <FieldName> <String>`
|
||||
|
||||
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.
|
||||
The `quotechar <Character>` option allows you to choose an alternate quote character, single quote for instance, that makes for readable/processable output.
|
||||
`quotechar` defaults to `gam.cfg/csv_output_quote_char`. When uploading CSV files to Google, double quote `"` should be used.
|
||||
@@ -3,7 +3,7 @@
|
||||
Print the current version of Gam with details
|
||||
```
|
||||
gam version
|
||||
GAMADV-XTD3 6.71.18 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
|
||||
GAMADV-XTD3 6.72.00 - 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.18 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
|
||||
GAMADV-XTD3 6.72.00 - 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.18 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
|
||||
GAMADV-XTD3 6.72.00 - 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.18
|
||||
Latest: 6.72.00
|
||||
echo $?
|
||||
1
|
||||
```
|
||||
@@ -72,7 +72,7 @@ echo $?
|
||||
Print the current version number without details
|
||||
```
|
||||
gam version simple
|
||||
6.71.18
|
||||
6.72.00
|
||||
```
|
||||
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.18 - https://github.com/taers232c/GAMADV-XTD3
|
||||
GAM 6.72.00 - 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
|
||||
|
||||
@@ -129,6 +129,7 @@ Service Account Access
|
||||
* [Users - Drive - File Selection](Drive-File-Selection)
|
||||
* [Users - Drive - Activity/Settings](Users-Drive-Activity-Settings)
|
||||
* [Users - Drive - Cleanup](Users-Drive-Cleanup)
|
||||
* [Users - Drive - Comments](Users-Drive-Comments)
|
||||
* [Users - Drive - Copy/Move](Users-Drive-Copy-Move)
|
||||
* [Users - Drive - Files-Display](Users-Drive-Files-Display)
|
||||
* [Users - Drive - Files-Manage](Users-Drive-Files-Manage)
|
||||
|
||||
@@ -471,7 +471,7 @@ section
|
||||
Default section of gam.cfg.
|
||||
Default: DEFAULT
|
||||
show_api_calls_retry_data
|
||||
Enable/disable display of Google API calls retry data and end of processing
|
||||
Enable/disable display of Google API calls retry data at end of processing
|
||||
Default: False
|
||||
show_commands
|
||||
Enable/disable display of commands to stderr when executing `gam batch|tbatch|csv|loop`.
|
||||
|
||||
@@ -6354,6 +6354,52 @@ gam print ownership <DriveFileID>|(drivefilename <DriveFileName>) [todrive <ToDr
|
||||
(addcsvdata <FieldName> <String>)*
|
||||
[formatjson [quotechar <Character>]]
|
||||
|
||||
<CommentsAuthorSubfieldName> ::=
|
||||
author.displayname|
|
||||
author.emailaddress|
|
||||
author.me|
|
||||
author.permissionid|
|
||||
author.photolink
|
||||
|
||||
<CommentsRepliesSubfieldName> ::=
|
||||
replies.action|
|
||||
replies.author|
|
||||
replies.author.<CommentsAuthorSubfieldName>|
|
||||
replies.content|
|
||||
replies.createddate|createdtime|
|
||||
replies.deleted|
|
||||
replies.htmlcontent|
|
||||
replies.id|
|
||||
replies.modifieddate|modifiedtime
|
||||
|
||||
<CommentsFieldName> ::=
|
||||
action|
|
||||
author|
|
||||
content|
|
||||
<CommentsAuthorSubfieldName>|
|
||||
<CommentsRepliesSubfieldName>|
|
||||
createddate|createdtime|
|
||||
deleted|
|
||||
htmlcontent|
|
||||
id|
|
||||
modifieddate|modifiedtime|
|
||||
quotedfilecontent|
|
||||
replies|
|
||||
resolved
|
||||
<CommentsFieldNameList> ::= "<CommentsFieldName>(,<CommentsFieldName>)*"
|
||||
|
||||
gam <UserTypeEntity> show filecomments <DriveFileEntity>
|
||||
[showdeleted] [start <Date>|<Time>]
|
||||
[fields <CommentsFieldNameList>] [showphotolinks]
|
||||
[countsonly]
|
||||
[formatjson]
|
||||
gam <UserTypeEntity> print filecomments <DriveFileEntity> [todrive <ToDriveAttribute>*]
|
||||
[showdeleted] [start <Date>|<Time>]
|
||||
[fields <CommentsFieldNameList>] [showphotolinks]
|
||||
[countsonly]
|
||||
(addcsvdata <FieldName> <String>)*
|
||||
[formatjson [quotechar <Character>]]
|
||||
|
||||
<RevisionsFieldName> ::=
|
||||
filesize|
|
||||
id|
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
Merged GAM-Team version
|
||||
|
||||
6.72.00
|
||||
|
||||
Added commands to display drive file comments.
|
||||
|
||||
* See: https://github.com/taers232c/GAMADV-XTD3/wiki/Users-Drive-Comments
|
||||
|
||||
6.71.18
|
||||
|
||||
Updated `<CrOSFieldName>` to include `cpuinfo` and `backlightinfo`.
|
||||
|
||||
@@ -11491,7 +11491,7 @@ def getGCPOrg(crm, login_hint, login_domain):
|
||||
try:
|
||||
getorg = callGAPI(crm.organizations(), 'search',
|
||||
throwReasons=[GAPI.INVALID_ARGUMENT, GAPI.PERMISSION_DENIED],
|
||||
query=f'domain:{login_domain}')
|
||||
query=f'domain:{login_domain}')
|
||||
except (GAPI.invalidArgument, GAPI.permissionDenied) as e:
|
||||
entityActionFailedExit([Ent.USER, login_hint, Ent.DOMAIN, login_domain], str(e))
|
||||
try:
|
||||
@@ -53924,6 +53924,239 @@ def printFileList(users):
|
||||
else:
|
||||
csvPFco.writeCSVfile('Drive File Counts')
|
||||
|
||||
FILECOMMENTS_FIELDS_CHOICE_MAP = {
|
||||
'action': 'action',
|
||||
'author': 'author',
|
||||
'content': 'content',
|
||||
'createddate': 'createdTime',
|
||||
'createdtime': 'createdTime',
|
||||
'deleted': 'deleted',
|
||||
'htmlcontent': 'htmlContent',
|
||||
'id': 'id',
|
||||
'modifieddate': 'modifiedTime',
|
||||
'modifiedtime': 'modifiedTime',
|
||||
'quotedfilecontent': 'quotedFileContent',
|
||||
'replies': 'replies',
|
||||
'resolved': 'resolved',
|
||||
}
|
||||
|
||||
FILECOMMENTS_AUTHOR_SUBFIELDS_CHOICE_MAP = {
|
||||
'displayname': 'displayName',
|
||||
'emailaddress': 'emailAddress',
|
||||
'me': 'me',
|
||||
'permissionid': 'permissionId',
|
||||
'photolink': 'photoLink',
|
||||
}
|
||||
|
||||
FILECOMMENTS_REPLIES_SUBFIELDS_CHOICE_MAP = {
|
||||
'action': 'action',
|
||||
'author': 'author',
|
||||
'content': 'content',
|
||||
'createddate': 'createdTime',
|
||||
'createdtime': 'createdTime',
|
||||
'deleted': 'deleted',
|
||||
'htmlcontent': 'htmlContent',
|
||||
'id': 'id',
|
||||
'modifieddate': 'modifiedTime',
|
||||
'modifiedtime': 'modifiedTime',
|
||||
}
|
||||
|
||||
FILECOMMENTS_SUBFIELDS_CHOICE_MAP = {
|
||||
'author': FILECOMMENTS_AUTHOR_SUBFIELDS_CHOICE_MAP,
|
||||
'replies': FILECOMMENTS_REPLIES_SUBFIELDS_CHOICE_MAP,
|
||||
}
|
||||
|
||||
def _getCommentFields(fieldsList):
|
||||
for field in _getFieldsList():
|
||||
if field.find('.') == -1:
|
||||
if field in FILECOMMENTS_FIELDS_CHOICE_MAP:
|
||||
addFieldToFieldsList(field, FILECOMMENTS_FIELDS_CHOICE_MAP, fieldsList)
|
||||
else:
|
||||
invalidChoiceExit(field, FILECOMMENTS_FIELDS_CHOICE_MAP, True)
|
||||
else:
|
||||
field, subField = field.split('.', 1)
|
||||
if field in FILECOMMENTS_SUBFIELDS_CHOICE_MAP:
|
||||
if subField.find('.') == -1:
|
||||
if subField in FILECOMMENTS_SUBFIELDS_CHOICE_MAP[field]:
|
||||
fieldsList.append(f'{FILECOMMENTS_FIELDS_CHOICE_MAP[field]}.{FILECOMMENTS_SUBFIELDS_CHOICE_MAP[field][subField]}')
|
||||
else:
|
||||
invalidChoiceExit(subField, FILECOMMENTS_SUBFIELDS_CHOICE_MAP[field], True)
|
||||
else:
|
||||
subField, subSubField = subField.split('.', 1)
|
||||
if subField in FILECOMMENTS_SUBFIELDS_CHOICE_MAP[field]:
|
||||
if subSubField in FILECOMMENTS_SUBFIELDS_CHOICE_MAP[subField]:
|
||||
fieldsList.append(f'{FILECOMMENTS_FIELDS_CHOICE_MAP[field]}.{FILECOMMENTS_SUBFIELDS_CHOICE_MAP[field][subField]}.{FILECOMMENTS_SUBFIELDS_CHOICE_MAP[subField][subSubField]}')
|
||||
else:
|
||||
invalidChoiceExit(subSubField, FILECOMMENTS_SUBFIELDS_CHOICE_MAP[subField], True)
|
||||
else:
|
||||
invalidChoiceExit(subField, FILECOMMENTS_SUBFIELDS_CHOICE_MAP[field], True)
|
||||
else:
|
||||
invalidChoiceExit(field, FILECOMMENTS_SUBFIELDS_CHOICE_MAP, True)
|
||||
|
||||
FILECOMMENTS_INDEXED_TITLES = ['replies']
|
||||
FILECOMMENTS_TIME_OBJECTS = {'createdTime', 'modifiedTime'}
|
||||
|
||||
def _stripCommentPhotoLinks(comment):
|
||||
if 'author' in comment:
|
||||
comment['author'].pop('photoLink', None)
|
||||
for reply in comment.get('replies', []):
|
||||
if 'author' in reply:
|
||||
reply['author'].pop('photoLink', None)
|
||||
|
||||
def _showComment(comment, stripPhotoLinks, timeObjects, i=0, count=0, FJQC=None):
|
||||
if stripPhotoLinks:
|
||||
_stripCommentPhotoLinks(comment)
|
||||
if FJQC is not None and FJQC.formatJSON:
|
||||
printLine(json.dumps(cleanJSON(comment, timeObjects=FILECOMMENTS_TIME_OBJECTS), ensure_ascii=False, sort_keys=True))
|
||||
return
|
||||
printEntity([Ent.DRIVE_FILE_COMMENT, comment['id']], i, count)
|
||||
Ind.Increment()
|
||||
showJSON(None, comment, ['id'], timeObjects)
|
||||
Ind.Decrement()
|
||||
|
||||
# gam <UserTypeEntity> show filecomments <DriveFileEntity>
|
||||
# [showdeleted] [start <Date>|<Time>] [countsonly]
|
||||
# [fields <CommentsFieldNameList>] [showphotolinks]
|
||||
# [countsonly]
|
||||
# (addcsvdata <FieldName> <String>)*
|
||||
# [formatjson]
|
||||
# gam <UserTypeEntity> print filecomments <DriveFileEntity> [todrive <ToDriveAttribute>*]
|
||||
# [showdeleted] [start <Date>|<Time>]
|
||||
# [fields <CommentsFieldNameList>] [showphotolinks]
|
||||
# [countsonly]
|
||||
# (addcsvdata <FieldName> <String>)*
|
||||
# [formatjson [quotechar <Character>]]
|
||||
def printShowFileComments(users):
|
||||
def _printComment(comment, commentId, baserow):
|
||||
row = flattenJSON(comment, flattened=baserow.copy(), timeObjects=timeObjects)
|
||||
row['commentId'] = commentId
|
||||
if not FJQC.formatJSON:
|
||||
csvPF.WriteRowTitles(row)
|
||||
elif csvPF.CheckRowTitles(row):
|
||||
row = baserow.copy()
|
||||
row['commentId'] = commentId
|
||||
comment['id'] = commentId
|
||||
row['JSON'] = json.dumps(cleanJSON(comment, timeObjects=timeObjects),
|
||||
ensure_ascii=False, sort_keys=True)
|
||||
csvPF.WriteRowNoFilter(row)
|
||||
|
||||
csvPF = CSVPrintFile(['User', 'fileId']) if Act.csvFormat() else None
|
||||
FJQC = FormatJSONQuoteChar(csvPF)
|
||||
fieldsList = []
|
||||
fileIdEntity = getDriveFileEntity()
|
||||
countsOnly = False
|
||||
stripPhotoLinks = True
|
||||
kwargs = {}
|
||||
addCSVData = {}
|
||||
while Cmd.ArgumentsRemaining():
|
||||
myarg = getArgument()
|
||||
if csvPF and myarg == 'todrive':
|
||||
csvPF.GetTodriveParameters()
|
||||
elif myarg == 'showdeleted':
|
||||
kwargs['includeDeleted'] = True
|
||||
elif myarg == 'start':
|
||||
kwargs['startModifiedTime'] = getTimeOrDeltaFromNow()
|
||||
elif myarg == 'showphotolinks':
|
||||
stripPhotoLinks = False
|
||||
elif myarg == 'fields':
|
||||
_getCommentFields(fieldsList)
|
||||
elif myarg == 'addcsvdata':
|
||||
k = getString(Cmd.OB_STRING)
|
||||
addCSVData[k] = getString(Cmd.OB_STRING, minLen=0)
|
||||
elif myarg == 'countsonly':
|
||||
countsOnly = True
|
||||
else:
|
||||
FJQC.GetFormatJSONQuoteChar(myarg)
|
||||
if csvPF:
|
||||
if addCSVData:
|
||||
csvPF.AddTitles(sorted(addCSVData.keys()))
|
||||
if not countsOnly:
|
||||
csvPF.AddTitles(['commentId', 'replyId'])
|
||||
else:
|
||||
csvPF.AddTitles(['comments', 'replies'])
|
||||
if FJQC.formatJSON:
|
||||
csvPF.AddTitles(['JSON'])
|
||||
csvPF.SetJSONTitles(csvPF.titlesList)
|
||||
if fieldsList:
|
||||
if 'id' not in fieldsList:
|
||||
fieldsList.append('id')
|
||||
if 'replies' not in fieldsList:
|
||||
for field in fieldsList.copy():
|
||||
if field.startswith('replies.'):
|
||||
fieldsList.append('replies.id')
|
||||
break
|
||||
fields = getItemFieldsFromFieldsList('comments', fieldsList)
|
||||
else:
|
||||
fields = '*'
|
||||
timeObjects = FILECOMMENTS_TIME_OBJECTS
|
||||
i, count, users = getEntityArgument(users)
|
||||
for user in users:
|
||||
i += 1
|
||||
user, drive, jcount = _validateUserGetFileIDs(user, i, count, fileIdEntity,
|
||||
entityType=[Ent.DRIVE_FILE_COMMENT, None][csvPF is not None])
|
||||
if jcount == 0:
|
||||
continue
|
||||
Ind.Increment()
|
||||
j = 0
|
||||
for fileId in fileIdEntity['list']:
|
||||
j += 1
|
||||
try:
|
||||
comments = callGAPIpages(drive.comments(), 'list', 'comments',
|
||||
throwReasons=GAPI.DRIVE_ACCESS_THROW_REASONS+[GAPI.BAD_REQUEST],
|
||||
fileId=fileId, fields=fields, **kwargs)
|
||||
except (GAPI.fileNotFound, GAPI.forbidden, GAPI.internalError, GAPI.insufficientFilePermissions, GAPI.unknownError,
|
||||
GAPI.badRequest) as e:
|
||||
entityActionFailedWarning([Ent.USER, user, Ent.DRIVE_FILE_ID, fileId], str(e), j, jcount)
|
||||
continue
|
||||
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy) as e:
|
||||
userSvcNotApplicableOrDriveDisabled(user, str(e), i, count)
|
||||
break
|
||||
kcount = len(comments)
|
||||
if countsOnly:
|
||||
numReplies = 0
|
||||
for comment in comments:
|
||||
numReplies += len(comment['replies'])
|
||||
if not csvPF:
|
||||
if countsOnly:
|
||||
printKeyValueList([Ent.Singular(Ent.DRIVE_FILE_ID), fileId, 'comments', kcount, 'replies', numReplies])
|
||||
else:
|
||||
if not FJQC.formatJSON:
|
||||
entityPerformActionNumItems([Ent.DRIVE_FILE_ID, fileId], kcount, Ent.DRIVE_FILE_COMMENT, j, jcount)
|
||||
Ind.Increment()
|
||||
if not countsOnly:
|
||||
k = 0
|
||||
for comment in comments:
|
||||
k += 1
|
||||
_showComment(comment, stripPhotoLinks, timeObjects, k, kcount, FJQC)
|
||||
Ind.Decrement()
|
||||
elif countsOnly:
|
||||
row = {'User': user, 'fileId': fileId}
|
||||
if addCSVData:
|
||||
row.update(addCSVData)
|
||||
row['comments'] = kcount
|
||||
row['replies'] = numReplies
|
||||
csvPF.WriteRowTitles(row)
|
||||
elif comments:
|
||||
baserow = {'User': user, 'fileId': fileId}
|
||||
if addCSVData:
|
||||
baserow.update(addCSVData)
|
||||
for comment in comments:
|
||||
if stripPhotoLinks:
|
||||
_stripCommentPhotoLinks(comment)
|
||||
commentId = comment.pop('id')
|
||||
replies = comment.pop('replies')
|
||||
if not replies:
|
||||
_printComment(comment, commentId, baserow)
|
||||
else:
|
||||
for reply in replies:
|
||||
comment['reply'] = reply
|
||||
baserow['replyId'] = reply['id']
|
||||
_printComment(comment, commentId, baserow)
|
||||
Ind.Decrement()
|
||||
if csvPF:
|
||||
csvPF.SetIndexedTitles(FILECOMMENTS_INDEXED_TITLES)
|
||||
csvPF.writeCSVfile('Drive File Comments')
|
||||
|
||||
# gam <UserTypeEntity> print filepaths <DriveFileEntity> [todrive <ToDriveAttribute>*]
|
||||
# (orderby <DriveFileOrderByFieldName> [ascending|descending])*
|
||||
# [oneitemperrow]
|
||||
@@ -73578,6 +73811,7 @@ USER_COMMANDS_WITH_OBJECTS = {
|
||||
Cmd.ARG_DRIVESETTINGS: printShowDriveSettings,
|
||||
Cmd.ARG_EMPTYDRIVEFOLDERS: printEmptyDriveFolders,
|
||||
Cmd.ARG_EVENT: printShowCalendarEvents,
|
||||
Cmd.ARG_FILECOMMENT: printShowFileComments,
|
||||
Cmd.ARG_FILECOUNT: printShowFileCounts,
|
||||
Cmd.ARG_FILEINFO: showFileInfo,
|
||||
Cmd.ARG_FILELIST: printFileList,
|
||||
@@ -73678,6 +73912,7 @@ USER_COMMANDS_WITH_OBJECTS = {
|
||||
Cmd.ARG_DRIVELABELPERMISSION: printShowDriveLabelPermissions,
|
||||
Cmd.ARG_DRIVESETTINGS: printShowDriveSettings,
|
||||
Cmd.ARG_EVENT: printShowCalendarEvents,
|
||||
Cmd.ARG_FILECOMMENT: printShowFileComments,
|
||||
Cmd.ARG_FILECOUNT: printShowFileCounts,
|
||||
Cmd.ARG_FILEINFO: showFileInfo,
|
||||
Cmd.ARG_FILELIST: printFileList,
|
||||
@@ -73894,6 +74129,7 @@ USER_COMMANDS_OBJ_ALIASES = {
|
||||
Cmd.ARG_DRIVELABELS: Cmd.ARG_DRIVELABEL,
|
||||
Cmd.ARG_DRIVELABELPERMISSIONS: Cmd.ARG_DRIVELABELPERMISSION,
|
||||
Cmd.ARG_EVENTS: Cmd.ARG_EVENT,
|
||||
Cmd.ARG_FILECOMMENTS: Cmd.ARG_FILECOMMENT,
|
||||
Cmd.ARG_FILECOUNTS: Cmd.ARG_FILECOUNT,
|
||||
Cmd.ARG_FILEPATHS: Cmd.ARG_FILEPATH,
|
||||
Cmd.ARG_FILEREVISIONS: Cmd.ARG_FILEREVISION,
|
||||
|
||||
@@ -578,6 +578,8 @@ class GamCLArgs():
|
||||
ARG_EXPORTS = 'exports'
|
||||
ARG_FEATURE = 'feature'
|
||||
ARG_FEATURES = 'features'
|
||||
ARG_FILECOMMENT = 'filecomment'
|
||||
ARG_FILECOMMENTS = 'filecomments'
|
||||
ARG_FILECOUNT = 'filecount'
|
||||
ARG_FILECOUNTS = 'filecounts'
|
||||
ARG_FILEDRIVELABEL = 'filedrivelabel'
|
||||
|
||||
@@ -173,6 +173,7 @@ class GamEntity():
|
||||
DOMAIN_PROFILE = 'dopr'
|
||||
DRIVE_DISK_USAGE = 'drdu'
|
||||
DRIVE_FILE = 'dfil'
|
||||
DRIVE_FILE_COMMENT = 'filc'
|
||||
DRIVE_FILE_ID = 'fili'
|
||||
DRIVE_FILE_NAME = 'filn'
|
||||
DRIVE_FILE_RENAMED = 'firn'
|
||||
@@ -290,6 +291,7 @@ class GamEntity():
|
||||
PERSONAL_DEVICE = 'pedv'
|
||||
PHOTO = 'phot'
|
||||
POP_ENABLED = 'popa'
|
||||
PRESENTATION = 'pres'
|
||||
PRINTER = 'prin'
|
||||
PRINTER_ID = 'prid'
|
||||
PRINTER_MODEL = 'prmd'
|
||||
@@ -510,6 +512,7 @@ class GamEntity():
|
||||
DOMAIN_PROFILE: ['Domain Profiles', 'Domain Profile'],
|
||||
DRIVE_DISK_USAGE: ['Drive Disk Usages', 'Drive Disk Usage'],
|
||||
DRIVE_FILE: ['Drive Files', 'Drive File'],
|
||||
DRIVE_FILE_COMMENT: ['Drive File Comments', 'Drive File Comment'],
|
||||
DRIVE_FILE_ID: ['Drive File IDs', 'Drive File ID'],
|
||||
DRIVE_FILE_NAME: ['Drive File Names', 'Drive File Name'],
|
||||
DRIVE_FILE_REVISION: ['Drive File Revisions', 'Drive File Revision'],
|
||||
@@ -627,6 +630,7 @@ class GamEntity():
|
||||
PERSONAL_DEVICE: ['Personal Devices', 'Personal Device'],
|
||||
PHOTO: ['Photos', 'Photo'],
|
||||
POP_ENABLED: ['POP Enabled', 'POP Enabled'],
|
||||
PRESENTATION: ['Presentations', 'Presentation'],
|
||||
PRINTER: ['Printers', 'Printer'],
|
||||
PRINTER_ID: ['Printer IDs', 'Printer ID'],
|
||||
PRINTER_MODEL: ['Printer Models', 'Printer Model'],
|
||||
|
||||
Reference in New Issue
Block a user