Skip to content

BUG: libCOMBINE does not save metadata when only some meta attributes are set #43

@jonrkarr

Description

@jonrkarr

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions