Manifest

Declare the version of the format that a document uses.

Manifest

class creator_studio_doc_format.core.Manifest(package_version=None)[source]

The package manifest, which records the version of the package format.

Saving writes the package format version this library supports, whatever package_version holds, so the attribute reports the version that was read, and a round trip doesn’t preserve it.

Parameters:
package_version : str | None

The package format version, in major.minor form.

Raises:

ValueError – package_version has a newer major version than this library supports.

classmethod parse(data)[source]

Creates a manifest from the decoded contents of a manifest file.

parse reads a package_version written as a JSON number, such as 1.0, or as a {"major": ..., "minor": ...} object as the "major.minor" string it spells, and checks it the same way.

Parameters:
data : object

The decoded manifest.json value, which can be None or malformed.

Returns:

The parsed manifest, or a default one when data is missing, is malformed, or has no package_version.

Return type:

Manifest

Raises:

DocumentVersionError – the package_version in data has a newer major version than this library supports.

to_dict()[source]

Returns the manifest in the form that the manifest file stores.

Returns:

The manifest.json object, with the package format version that this library writes.

Return type:

dict[str, str]

Version

class creator_studio_doc_format.core.Version(major, minor=0)[source]

A version number in major.minor form, as the file writes it.

The value is either an object’s version or the manifest’s package_version. parse accepts a "major.minor" or "major" string, a {"major": ..., "minor": ...} mapping, where minor is optional, or a Version. A missing minor reads as 0, and parse ignores leading zeros.

Parameters:
major : int

The major version, which a reader must implement to read the value.

minor : int

The minor version, which a reader can be older than.

classmethod parse(value)[source]

Returns the version that a value spells.

Parameters:
value : Any

A version in one of the forms the class accepts.

Returns:

The version, or None if value isn’t in an accepted form.

Return type:

Version | None