Skip to content

Commit

Permalink
Added option shownames to gam <UserTypeEntity> print|show sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
taers232c committed Sep 15, 2024
1 parent da266d2 commit 46aa87b
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 29 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,8 @@ jobs:
goal: build
arch: arm64
openssl_archs: darwin64-arm64
# - os: macos-14
# jid: 6
# goal: build
# arch: universal2
# openssl_archs: darwin64-arm64 darwin64-x86_64
- os: windows-2022
jid: 7
jid: 6
goal: build
arch: Win64
openssl_archs: VC-WIN64A
Expand All @@ -74,7 +69,7 @@ jobs:
with:
path: |
cache.tar.xz
key: gam-${{ matrix.jid }}-20240905
key: gam-${{ matrix.jid }}-20240914

- name: Untar Cache archive
if: matrix.goal == 'build' && steps.cache-python-ssl.outputs.cache-hit == 'true'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/winget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: vedantmgoyal2009/winget-releaser@v2
with:
identifier: taers232c.GAMADV-XTD3
release-tag: v7.00.00
release-tag: v7.00.01
max-versions-to-keep: 1 # keep only latest versions
installers-regex: '\.msi$'
token: ${{ secrets.WINGET_TOKEN }}
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ deploy:
file: gamadv-xtd3-$GAMVERSION-*
skip_cleanup: true
draft: true
# edge: true
edge: true
# Linux Xenial and Trusty
edge:
branch: v2.0.3-beta.4
# edge:
# branch: v2.0.3-beta.4
on:
repo: taers232c/GAMADV-XTD3

4 changes: 2 additions & 2 deletions src/GamCommands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8244,12 +8244,12 @@ gam <UserTypeEntity> update sheet <DriveFileEntity>
gam <UserTypeEntity> info|show sheet <DriveFileEntity>
[fields <SpreadsheetFieldList>] [sheetsfields <SpreadsheetSheetsFieldList>]
(range <SpreadsheetRange>)* (rangelist <SpreadsheetRangeList>)*
[includegriddata [<Boolean>]]
[includegriddata [<Boolean>]] [shownames]
[formatjson]
gam <UserTypeEntity> print sheet <DriveFileEntity> [todrive <ToDriveAttribute>*]
[fields <SpreadsheetFieldList>] [sheetsfields <SpreadsheetSheetsFieldList>]
(range <SpreadsheetRange>)* (rangelist <SpreadsheetRangeList>)*
[includegriddata [<Boolean>]]
[includegriddata [<Boolean>]] [shownames]
[formatjson [quotechar <Character>]]

See: https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values#ValueRange
Expand Down
5 changes: 5 additions & 0 deletions src/GamUpdate.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
7.00.01

Added option `shownames` to `gam <UserTypeEntity> print|show sheet` that causes GAM
to make an additional API call to get and display the sheet file name that is not supplied by the Sheets API.

7.00.00

Merged GAM-Team version
Expand Down
9 changes: 4 additions & 5 deletions src/gam-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ adminuser=""
regularuser=""
gam_x86_64_glibc_vers="2.35 2.31 2.27 2.23 2.19"
gam_arm64_glibc_vers="2.31 2.27 2.23"
strip_gamadv_xtd3="--strip-components 0"
strip_gam="--strip-components 0"

while getopts "hd:a:o:b:lp:u:r:v:s" OPTION
do
Expand All @@ -47,7 +47,7 @@ do
u) adminuser="$OPTARG";;
r) regularuser="$OPTARG";;
v) gamversion="$OPTARG";;
s) strip_gamadv_xtd3="--strip-components 1"; target_gam="gam";;
s) strip_gam="--strip-components 1"; target_gam="gam";;
?) usage; exit;;
esac
done
Expand Down Expand Up @@ -156,7 +156,6 @@ case $gamos in
;;
arm|arm64|aarch64)
gamfile="macos-arm64.tar.xz";;
# gamfile="macos-universal2.tar.xz";;
*)
echo_red "ERROR: this installer currently only supports x86_64 and arm64 MacOS. Looks like you're running on $gamarch. Exiting."
exit
Expand Down Expand Up @@ -273,9 +272,9 @@ mkdir -p "$target_dir"

echo_yellow "Extracting archive to $target_dir"
if [[ "${name}" == *.tar.xz ]]; then
tar $strip_gamadv_xtd3 -xf "$temp_archive_dir"/"$name" -C "$target_dir"
tar $strip_gam -xf "$temp_archive_dir"/"$name" -C "$target_dir"
elif [[ "${name}" == *.tar ]]; then
tar $strip_gamadv_xtd3 -xf "$temp_archive_dir"/"$name" -C "$target_dir"
tar $strip_gam -xf "$temp_archive_dir"/"$name" -C "$target_dir"
else
unzip "${temp_archive_dir}/${name}" -d "${target_dir}"
fi
Expand Down
51 changes: 40 additions & 11 deletions src/gam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"""

__author__ = 'Ross Scroggs <ross.scroggs@gmail.com>'
__version__ = '7.00.00'
__version__ = '7.00.01'
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'

#pylint: disable=wrong-import-position
Expand Down Expand Up @@ -66995,22 +66995,22 @@ def updateSheets(users):
}

# gam <UserTypeEntity> info|show sheet <DriveFileEntity>
# [fields <SpreadsheetFieldList>]
# [fields <SpreadsheetFieldList>] [sheetsfields <SpreadsheetSheetsFieldList>]
# (range <SpreadsheetRange>)* (rangelist <SpreadsheetRangeList>)*
# [includegriddata [<Boolean>]]
# [includegriddata [<Boolean>]] [shownames]
# [formatjson]
# gam <UserTypeEntity> print sheet <DriveFileEntity> [todrive <ToDriveAttribute>*]
# [fields <SpreadsheetFieldList>]
# [fields <SpreadsheetFieldList>] [sheetsfields <SpreadsheetSheetsFieldList>]
# (range <SpreadsheetRange>)* (rangelist <SpreadsheetRangeList>)*
# [includegriddata [<Boolean>]]
# [includegriddata [<Boolean>]] [shownames]
# [formatjson [quotechar <Character>]]
def infoPrintShowSheets(users):
csvPF = CSVPrintFile(['User', 'spreadsheetId'], 'sortall') if Act.csvFormat() else None
FJQC = FormatJSONQuoteChar(csvPF)
spreadsheetIdEntity = getDriveFileEntity()
fieldsList = []
ranges = []
includeGridData = False
includeGridData = showSheetNames = False
while Cmd.ArgumentsRemaining():
myarg = getArgument()
if csvPF and myarg == 'todrive':
Expand All @@ -67029,8 +67029,16 @@ def infoPrintShowSheets(users):
fieldsList.append(SPREADSHEET_SHEETS_SUBFIELDS_CHOICE_MAP[field])
else:
invalidChoiceExit(field, SPREADSHEET_SHEETS_SUBFIELDS_CHOICE_MAP, True)
elif myarg == 'shownames':
showSheetNames = True
else:
FJQC.GetFormatJSONQuoteChar(myarg, True)
if csvPF and showSheetNames:
csvPF.AddTitles('spreadsheetName')
csvPF.SetSortAllTitles()
if FJQC.formatJSON:
csvPF.AddJSONTitles('spreadsheetName')
csvPF.MoveJSONTitlesToEnd(['JSON'])
if includeGridData and fieldsList:
fieldsList.append(SPREADSHEET_SHEETS_SUBFIELDS_CHOICE_MAP['data'])
fields = getFieldsFromFieldsList(fieldsList)
Expand All @@ -67040,6 +67048,10 @@ def infoPrintShowSheets(users):
user, sheet, jcount = _validateUserGetSpreadsheetIDs(user, i, count, spreadsheetIdEntity, not FJQC.formatJSON)
if jcount == 0:
continue
if showSheetNames:
_, drive = buildGAPIServiceObject(API.DRIVE3, user, i, count)
if not drive:
continue
Ind.Increment()
j = 0
for spreadsheetId in spreadsheetIdEntity['list']:
Expand All @@ -67051,11 +67063,25 @@ def infoPrintShowSheets(users):
if not includeGridData and 'sheets' in result:
for usheet in result['sheets']:
usheet.pop('data', None)
if showSheetNames:
try:
spreadsheetName = callGAPI(drive.files(), 'get',
throwReasons=GAPI.DRIVE_GET_THROW_REASONS,
fileId=spreadsheetId, fields='name', supportsAllDrives=True)['name']
except (GAPI.fileNotFound, GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy):
spreadsheetName = spreadsheetId
if not csvPF:
if FJQC.formatJSON:
printLine('{'+f'"User": "{user}", "spreadsheetId": "{spreadsheetId}", "JSON": {json.dumps(result, ensure_ascii=False, sort_keys=False)}'+'}')
baserow = {'User': user, 'spreadsheetId': spreadsheetId}
if showSheetNames:
baserow['spreadsheetName'] = spreadsheetName
baserow['JSON'] = result
printLine(json.dumps(baserow, ensure_ascii=False, sort_keys=False)+'\n')
continue
printEntity([Ent.SPREADSHEET, spreadsheetId], j, jcount)
if showSheetNames:
printEntity([Ent.SPREADSHEET, f'{spreadsheetName}({spreadsheetId})'], j, jcount)
else:
printEntity([Ent.SPREADSHEET, spreadsheetId], j, jcount)
Ind.Increment()
if 'spreadsheetUrl' in result:
printKeyValueList(['spreadsheetUrl', result['spreadsheetUrl']])
Expand All @@ -67074,12 +67100,15 @@ def infoPrintShowSheets(users):
Ind.Decrement()
Ind.Decrement()
else:
row = flattenJSON(result, flattened={'User': user, 'spreadsheetId': spreadsheetId})
baserow = {'User': user, 'spreadsheetId': spreadsheetId}
if showSheetNames:
baserow['spreadsheetName'] = spreadsheetName
row = flattenJSON(result, flattened=baserow.copy())
if not FJQC.formatJSON:
csvPF.WriteRowTitles(row)
elif csvPF.CheckRowTitles(row):
csvPF.WriteRowNoFilter({'User': user, 'spreadsheetId': spreadsheetId,
'JSON': json.dumps(result, ensure_ascii=False, sort_keys=False)})
baserow['JSON'] = json.dumps(cleanJSON(result), ensure_ascii=False, sort_keys=False)
csvPF.WriteRowNoFilter(baserow)
except (GAPI.notFound, GAPI.forbidden, GAPI.permissionDenied,
GAPI.internalError, GAPI.insufficientFilePermissions, GAPI.badRequest,
GAPI.invalid, GAPI.invalidArgument, GAPI.failedPrecondition) as e:
Expand Down

0 comments on commit 46aa87b

Please sign in to comment.