Skip to content

Commit

Permalink
Support for archive requests in json format
Browse files Browse the repository at this point in the history
  • Loading branch information
gmertes committed Apr 23, 2024
1 parent c8bed62 commit 87d3114
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion ai_models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,35 @@ def collect_archive_requests(self, written):
def finalise(self):
if self.archive_requests:
with open(self.archive_requests, "w") as f:
json_requests = []

for path, archive in self.archiving.items():
request = dict(source=f'"{path}"', expect=archive.expect)
request.update(archive.request)
request.update(self._requests_extra)
self._print_request("archive", request, file=f)

if self.json:
json_requests.append(request)
else:
self._print_request("archive", request, file=f)

if json_requests:

def json_default(obj):
if isinstance(obj, set):
if len(obj) > 1:
return list(obj)
else:
return obj.pop()
return obj

print(
json.dumps(
json_requests, separators=(",", ":"), default=json_default
),
file=f,
end="",
)

def download_assets(self, **kwargs):
for file in self.download_files:
Expand Down

0 comments on commit 87d3114

Please sign in to comment.