-
-
Notifications
You must be signed in to change notification settings - Fork 7
Closed
Description
The following illustrates the issue:
import datetime
import dateutil.tz
import libcombine
import os
import zipfile
location = 'README.md'
filename = os.path.abspath(location)
format = 'http://purl.org/NET/mediatypes/text/plain'
master = False
updated = datetime.datetime(2020, 1, 1, 1, 1, 1, tzinfo=dateutil.tz.tzutc())
archive_filename = 'archive.omex'
# create archive without only updated date
archive = libcombine.CombineArchive()
archive.addFile(
filename,
location,
format,
master)
desc = libcombine.OmexDescription()
desc.setAbout(location)
date = libcombine.Date()
date.setDateAsString(updated.strftime('%Y-%m-%dT%H:%M:%SZ'))
desc.getModified().append(date)
archive.addMetadata(location, desc)
archive.writeToFile(archive_filename)
# metadata isn't saved
with zipfile.ZipFile(archive_filename, 'r') as zip_file:
assert 'metadata.rdf' not in zip_file.namelist()
# create save archive, now also with a description
archive = libcombine.CombineArchive()
archive.addFile(
filename,
location,
format,
master)
desc = libcombine.OmexDescription()
desc.setAbout(location)
desc.setDescription('Description')
date = libcombine.Date()
date.setDateAsString(updated.strftime('%Y-%m-%dT%H:%M:%SZ'))
desc.getModified().append(date)
archive.addMetadata(location, desc)
archive.writeToFile(archive_filename)
# metadata is saved
with zipfile.ZipFile(archive_filename, 'r') as zip_file:
assert 'metadata.rdf' in zip_file.namelist()Metadata
Metadata
Assignees
Labels
No labels