Added option positivecountsonly to gam <UserTypeEntity> print|show filecomments

This commit is contained in:
Ross Scroggs
2024-11-26 13:09:44 -08:00
parent 4dfdc3a717
commit a1238c6397
3 changed files with 35 additions and 13 deletions

View File

@@ -1059,6 +1059,7 @@ Specify a collection of items by directly specifying them; the item type is dete
all_shortcuts | all_shortcuts |
all_3p_shortcuts | all_3p_shortcuts |
all_items | all_items |
my_commentable_items |
my_docs | my_docs |
my_files | my_files |
my_folders | my_folders |
@@ -6779,12 +6780,12 @@ gam print ownership <DriveFileID>|(drivefilename <DriveFileName>) [todrive <ToDr
gam <UserTypeEntity> show filecomments <DriveFileEntity> gam <UserTypeEntity> show filecomments <DriveFileEntity>
[showdeleted] [start <Date>|<Time>] [showdeleted] [start <Date>|<Time>]
[fields <CommentsFieldNameList>] [showphotolinks] [fields <CommentsFieldNameList>] [showphotolinks]
[countsonly] [countsonly|positivecountsonly]
[formatjson] [formatjson]
gam <UserTypeEntity> print filecomments <DriveFileEntity> [todrive <ToDriveAttribute>*] gam <UserTypeEntity> print filecomments <DriveFileEntity> [todrive <ToDriveAttribute>*]
[showdeleted] [start <Date>|<Time>] [showdeleted] [start <Date>|<Time>]
[fields <CommentsFieldNameList>] [showphotolinks] [fields <CommentsFieldNameList>] [showphotolinks]
[countsonly] [countsonly|positivecountsonly]
(addcsvdata <FieldName> <String>)* (addcsvdata <FieldName> <String>)*
[formatjson [quotechar <Character>]] [formatjson [quotechar <Character>]]

View File

@@ -1,3 +1,19 @@
7.01.02
Added option `positivecountsonly` to `gam <UserTypeEntity> print|show filecomments` that causes
GAM to display the number of comments and replies only for files that have comments.
Added `my_commentable_items` to `<DriveFileQueryShortcut>` that can be used with
`gam <UserTypeEntity> print|show filecomments my_commentable_items` to speed up processing.
Updated code that uses the Domain Shared Contacts API with an HTTPS proxy to avoid a trap:
```
Traceback (most recent call last):
...
File "atom/http.py", line 250, in _prepare_connection
AttributeError: module 'ssl' has no attribute 'wrap_socket'
```
7.01.01 7.01.01
Fixed bug in `gam <UserTypeEntity> print|show filetree` where no error message was generated Fixed bug in `gam <UserTypeEntity> print|show filetree` where no error message was generated

View File

@@ -25,7 +25,7 @@ https://github.com/GAM-team/GAM/wiki
""" """
__author__ = 'GAM Team <google-apps-manager@googlegroups.com>' __author__ = 'GAM Team <google-apps-manager@googlegroups.com>'
__version__ = '7.01.01' __version__ = '7.01.02'
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)' __license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
#pylint: disable=wrong-import-position #pylint: disable=wrong-import-position
@@ -51946,6 +51946,7 @@ QUERY_SHORTCUTS_MAP = {
'allshortcuts': f"mimeType = '{MIMETYPE_GA_SHORTCUT}'", 'allshortcuts': f"mimeType = '{MIMETYPE_GA_SHORTCUT}'",
'all3pshortcuts': f"mimeType = '{MIMETYPE_GA_3P_SHORTCUT}'", 'all3pshortcuts': f"mimeType = '{MIMETYPE_GA_3P_SHORTCUT}'",
'allitems': 'allitems', 'allitems': 'allitems',
'mycommentableitems': ME_IN_OWNERS_AND+f"(mimeType = '{MIMETYPE_GA_DOCUMENT}' or mimeType = '{MIMETYPE_GA_SPREADSHEET}' or mimeType = '{MIMETYPE_GA_PRESENTATION}')",
'mydocs': ME_IN_OWNERS_AND+f"mimeType = '{MIMETYPE_GA_DOCUMENT}'", 'mydocs': ME_IN_OWNERS_AND+f"mimeType = '{MIMETYPE_GA_DOCUMENT}'",
'myfiles': ME_IN_OWNERS_AND+f"mimeType != '{MIMETYPE_GA_FOLDER}'", 'myfiles': ME_IN_OWNERS_AND+f"mimeType != '{MIMETYPE_GA_FOLDER}'",
'myfolders': ME_IN_OWNERS_AND+f"mimeType = '{MIMETYPE_GA_FOLDER}'", 'myfolders': ME_IN_OWNERS_AND+f"mimeType = '{MIMETYPE_GA_FOLDER}'",
@@ -56233,14 +56234,14 @@ def _showComment(comment, stripPhotoLinks, timeObjects, i=0, count=0, FJQC=None)
Ind.Decrement() Ind.Decrement()
# gam <UserTypeEntity> show filecomments <DriveFileEntity> # gam <UserTypeEntity> show filecomments <DriveFileEntity>
# [showdeleted] [start <Date>|<Time>] [countsonly] # [showdeleted] [start <Date>|<Time>] [countsonly|positivecountsonly]
# [fields <CommentsFieldNameList>] [showphotolinks] # [fields <CommentsFieldNameList>] [showphotolinks]
# [countsonly] # [countsonly]
# [formatjson] # [formatjson]
# gam <UserTypeEntity> print filecomments <DriveFileEntity> [todrive <ToDriveAttribute>*] # gam <UserTypeEntity> print filecomments <DriveFileEntity> [todrive <ToDriveAttribute>*]
# [showdeleted] [start <Date>|<Time>] # [showdeleted] [start <Date>|<Time>]
# [fields <CommentsFieldNameList>] [showphotolinks] # [fields <CommentsFieldNameList>] [showphotolinks]
# [countsonly] # [countsonly|positivecountsonly]
# (addcsvdata <FieldName> <String>)* # (addcsvdata <FieldName> <String>)*
# [formatjson [quotechar <Character>]] # [formatjson [quotechar <Character>]]
def printShowFileComments(users): def printShowFileComments(users):
@@ -56265,7 +56266,7 @@ def printShowFileComments(users):
FJQC = FormatJSONQuoteChar(csvPF) FJQC = FormatJSONQuoteChar(csvPF)
fieldsList = [] fieldsList = []
fileIdEntity = getDriveFileEntity() fileIdEntity = getDriveFileEntity()
countsOnly = False countsOnly = positiveCountsOnly = False
stripPhotoLinks = True stripPhotoLinks = True
kwargs = {} kwargs = {}
addCSVData = {} addCSVData = {}
@@ -56286,6 +56287,8 @@ def printShowFileComments(users):
addCSVData[k] = getString(Cmd.OB_STRING, minLen=0) addCSVData[k] = getString(Cmd.OB_STRING, minLen=0)
elif myarg == 'countsonly': elif myarg == 'countsonly':
countsOnly = True countsOnly = True
elif myarg == 'positivecountsonly':
countsOnly = positiveCountsOnly = True
else: else:
FJQC.GetFormatJSONQuoteChar(myarg) FJQC.GetFormatJSONQuoteChar(myarg)
if csvPF: if csvPF:
@@ -56339,7 +56342,8 @@ def printShowFileComments(users):
numReplies += len(comment['replies']) numReplies += len(comment['replies'])
if not csvPF: if not csvPF:
if countsOnly: if countsOnly:
printKeyValueList([Ent.Singular(Ent.DRIVE_FILE_ID), fileId, 'comments', kcount, 'replies', numReplies]) if not positiveCountsOnly or kcount > 0:
printKeyValueList([Ent.Singular(Ent.DRIVE_FILE_ID), fileId, 'comments', kcount, 'replies', numReplies])
else: else:
if not FJQC.formatJSON: if not FJQC.formatJSON:
entityPerformActionNumItems([Ent.DRIVE_FILE_ID, fileId], kcount, Ent.DRIVE_FILE_COMMENT, j, jcount) entityPerformActionNumItems([Ent.DRIVE_FILE_ID, fileId], kcount, Ent.DRIVE_FILE_COMMENT, j, jcount)
@@ -56351,12 +56355,13 @@ def printShowFileComments(users):
_showComment(comment, stripPhotoLinks, timeObjects, k, kcount, FJQC) _showComment(comment, stripPhotoLinks, timeObjects, k, kcount, FJQC)
Ind.Decrement() Ind.Decrement()
elif countsOnly: elif countsOnly:
row = {'User': user, 'fileId': fileId} if not positiveCountsOnly or kcount > 0:
if addCSVData: row = {'User': user, 'fileId': fileId}
row.update(addCSVData) if addCSVData:
row['comments'] = kcount row.update(addCSVData)
row['replies'] = numReplies row['comments'] = kcount
csvPF.WriteRowTitles(row) row['replies'] = numReplies
csvPF.WriteRowTitles(row)
elif comments: elif comments:
baserow = {'User': user, 'fileId': fileId} baserow = {'User': user, 'fileId': fileId}
if addCSVData: if addCSVData: