Browse Source

Add --jsonl option

master
JustAnotherArchivist 2 years ago
parent
commit
ce7a069af5
1 changed files with 9 additions and 1 deletions
  1. +9
    -1
      azure-storage-list

+ 9
- 1
azure-storage-list View File

@@ -1,6 +1,7 @@
#!/usr/bin/env python3
import html
import http.client
import json
import os
import shlex
import ssl
@@ -14,6 +15,7 @@ withListUrls = False
listUrlsFD = None
startMarker = None
format = '{url}'
jsonl = False
args = []
while i < len(sys.argv):
arg = sys.argv[i]
@@ -22,6 +24,7 @@ while i < len(sys.argv):
print('', file = sys.stderr)
print('Options:', file = sys.stderr)
print(f' --format FORMAT Modify the output format; FORMAT defaults to {format!r}; available fields: name, url, and all fields returned by Azure (e.g. Content-Length, Last-Modified)', file = sys.stderr)
print( ' --jsonl Output JSONL instead of formatted lines', file = sys.stderr)
print( ' --marker MARKER Start with a marker instead of from the beginning', file = sys.stderr)
print( ' --with-list-urls Enables printing the list URLs retrieved to FD 3', file = sys.stderr)
sys.exit(1)
@@ -38,6 +41,8 @@ while i < len(sys.argv):
elif arg == '--format':
format = sys.argv[i + 1]
i += 1
elif arg == '--jsonl':
jsonl = True
else:
args.append(arg)
i += 1
@@ -101,7 +106,10 @@ while True:
assert False

try:
print(format.format(**fields, name = name, url = url))
if not jsonl:
print(format.format(**fields, name = name, url = url))
else:
print(json.dumps({'name': name, 'url': url, **fields}))
except BrokenPipeError:
sys.exit(0)



Loading…
Cancel
Save