Skip to content

Commit

Permalink
Updated processing of <DriveFileURL>
Browse files Browse the repository at this point in the history
  • Loading branch information
taers232c committed Jun 22, 2021
1 parent 676a967 commit de1e062
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 15 deletions.
21 changes: 14 additions & 7 deletions src/GamCommands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,16 @@ If an item contains spaces, it should be surrounded by ".
<DriveFileACLType> ::= anyone|domain|group|user
<DriveFileID> ::= <String>
<DriveFileURL> ::=
https://docs.google.com/a/<DomainName>/document/d/<DriveFileID>/<String>
https://drive.google.com/open?id=<DriveFileID>
https://www.googleapis.com/drive/v2/files/<DriveFileID>
https://www.googleapis.com/drive/v2/folders/<DriveFileID>
https://drive.google.com/drive/files/<DriveFileID>
https://drive.google.com/drive/folders/<DriveFileID>
https://drive.google.com/drive/folders/<DriveFileID>?resourcekey=<String>
https://drive.google.com/file/d/<DriveFileID>/<String>
https://docs.google.com>/document/d/<DriveFileID>/<String>
https://docs.google.com>/drawings/d/<DriveFileID>/<String>
https://docs.google.com>/forms/d/<DriveFileID>/<String>
https://docs.google.com>/presentation/d/<DriveFileID>/<String>
https://docs.google.com>/spreadsheets/d/<DriveFileID>/<String>
<DriveFileItem> ::= <DriveFileID>|<DriveFileURL>
<DriveFileName> ::= <String>
<DriveFolderID> ::= <String>
Expand Down Expand Up @@ -1513,9 +1519,9 @@ gam print chatmembers [todrive <ToDriveAttribute>*] space <ChatSpace>
[formatjson [quotechar <Character>]]

gam create chatmessage space <ChatSpace> [thread <ChatThread>]
(text <String>)|(textfile <FileName> [charset <CharSet>])
(text <String>)|(textfile <FileName> [charset <CharSet>])
gam update chatmessage name <ChatMessage>
(text <String>)|(textfile <FileName> [charset <CharSet>])
(text <String>)|(textfile <FileName> [charset <CharSet>])
gam delete chatmessage name <ChatMessage>
gam info chatmessage name <ChatMessage>
[formatjson]
Expand Down Expand Up @@ -5447,8 +5453,9 @@ gam <UserTypeEntity> print sendas [compact]
gam <UserTypeEntity> signature|sig
<String>|(htmlsig <String>)|(file|htmlfile <FileName> [charset <Charset>])|(gdoc|ghtml <UserGoogleDoc>)
(replace <Tag> <UserReplacement>)*
[html [<Boolean>]] [name <String>] [replyto <EmailAddress>]
[default] [primary] [treatasalias <Boolean>]
[html [<Boolean>]] [replyto <EmailAddress>] [default] [treatasalias <Boolean>]
[name <String>]
[primary]
gam <UserTypeEntity> show signature|sig [compact|format|html]
[primary|default] [verifyonly]
gam <UserTypeEntity> print signature [compact]
Expand Down
18 changes: 13 additions & 5 deletions src/GamUpdate.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
6.04.08

Updated processing of `<DriveFileURL>` as Google introduced this new form
of a folder URL that GAM didn't recognize and thus couldn't isolate `<DriveFileID>`.
```
https://drive.google.com/drive/folders/<DriveFileID>?resourcekey=<String>
```

6.04.07

Changed `config csv_input_row_filter|csv_output_row_filter` processing of blank fields
for `count<Operator><Number>` and `boolean:<Boolean>`. Previously, a blank field was
always treated a mismatch; now a blank field will be interpreted as `False` for `<Boolean>`
and `0` for `<Number>` and the match test will be performed.

Added options `primary` and `default`` to the following commands
Added options `primary` and `default` to the following commands
so that only the primary or default sendas is displayed
for each user in `<UserTypeEntity>` rather than all sendas.
```
Expand All @@ -15,7 +23,7 @@ gam <UserTypeEntity> print sendas [compact]
[primary] [default] [verifyonly] [todrive <ToDriveAttribute>*]
```

Added options `primary` and `default`` to the following commands
Added options `primary` and `default` to the following commands
so that the primary or default signature is displayed
for each user in `<UserTypeEntity>` rather than the current signature.
```
Expand All @@ -25,21 +33,21 @@ gam <UserTypeEntity> print signature [compact]
[primary] [default] [verifyonly] [todrive <ToDriveAttribute>*]
```

Added option `verifyonly` to the commands show above; it causes a Boolean
Added option `verifyonly` to the commands shown above; it causes a Boolean
to be displayed in the `signature` field rather that the signature text;
this simplifies checking for users with undefined signatures.

For example, this command will display a list of users without a primary email address signature (wrapped for readability):
```
gam config csv_output_row_filter "signature:boolean:false" csv_output_header_filter "User,displayName,signature"
auto_batch_min 1 num_threads 10 redirect csv ./NoPrimarySignature.txt multiprocess
auto_batch_min 1 num_threads 10 redirect csv ./NoPrimarySignature.csv multiprocess
all users print signature primary verifyonly

Explanation:
config csv_output_row_filter "signature:boolean:false" - Output rows that indicate no signature
csv_output_header_filter "User,displayName,signature" - Output basic headers
auto_batch_min 1 num_threads 10 - Turn on parallel processing
redirect csv ./NoPrimarySignature.txt multiprocess - Intelligently combine output from all processes
redirect csv ./NoPrimarySignature.csv multiprocess - Intelligently combine output from all processes
all users - Process all non-suspended users
print signature primary verifyonly - Display state of primary email address signature
```
Expand Down
13 changes: 10 additions & 3 deletions src/gam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"""

__author__ = 'Ross Scroggs <[email protected]>'
__version__ = '6.04.07'
__version__ = '6.04.08'
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'

import base64
Expand Down Expand Up @@ -39020,11 +39020,17 @@ def _getFileIdFromURL(fileId):
if loc > 0:
fileId = fileId[loc+7:]
loc = fileId.find('&')
if loc > 0:
return fileId[:loc]
loc = fileId.find('?')
return fileId[:loc] if loc != -1 else fileId
loc = fileId.find('/folders/')
if loc > 0:
fileId = fileId[loc+9:]
loc = fileId.find('&')
if loc > 0:
return fileId[:loc]
loc = fileId.find('?')
return fileId[:loc] if loc != -1 else fileId
return None

Expand Down Expand Up @@ -53765,8 +53771,9 @@ def printShowSmimes(users):
# gam <UserTypeEntity> signature|sig
# <String>|(file|htmlfile <FileName> [charset <CharSet>])|(gdoc|ghtml <UserGoogleDoc>)
# (replace <Tag> <String>)*
# [html [<Boolean>]] [name <String>] [replyto <EmailAddress>]
# [default] [treatasalias <Boolean>]
# [html [<Boolean>]] [replyto <EmailAddress>] [default] [treatasalias <Boolean>]
# [name <String>]
# [primary]
def setSignature(users):
tagReplacements = _initTagReplacements()
signature, _, html = getStringOrFile('sig')
Expand Down

0 comments on commit de1e062

Please sign in to comment.