darkbridge.sidecar.nikon - Handle Nikon sidecar files (read only)

Handle Nikon sidecar files (read only)

The sidecar.nikon module implements handlers for the Nikon sidecar file. The article named “Inside Nikon Sidecar file” details the data structure and tags used by Nikon.

The exported classes, exceptions and functions (and any other objects) are as follows:

sidecar.nikon exceptions

sidecar.nikon classes

sidecar.nikon constants

Todo

review the list after the completion of implement

Using sidecar.nikon

Todo

describe how using the module

sidecar.nikon reference manual

exception darkbridge.sidecar.nikon.NikonError(message: str | None = '')

Bases: Exception

Base class for sidecar parser exceptions.

Parameters:

message – (optional) Human readable string describing the exception.

message

Human readable string describing the exception.

Type:

str | None

exception darkbridge.sidecar.nikon.NikonMissingTagError(name: str | None)

Bases: NikonError

Raised when an expected tag is missing.

Parameters:

name – name of the missing tag.

name

name of the missing tag.

Type:

str | None

exception darkbridge.sidecar.nikon.NikonResourceError(prop_name: str | None, tag_name: str | None)

Bases: NikonError

Raised when a resource is erroneous (unknown tag).

Parameters:
  • prop_name – name of the property

  • tag_name – name of the erroneous tag.

prop_name

name of the property

Type:

str | None

tag_name

name of the erroneous tag.

Type:

str | None

exception darkbridge.sidecar.nikon.NikonResourceTypeError(prop_name: str | None, type_name: str | None)

Bases: NikonError

Raised when a resource is erroneous (unknown type).

Parameters:
  • prop_name – name of the property

  • type_name – name of the erroneous type.

prop_name

name of the property

Type:

str | None

type_name

name of the erroneous type.

Type:

str | None

exception darkbridge.sidecar.nikon.NikonTagValueError(name: str, value: str | None)

Bases: NikonError

Raised when a tag value is not expected.

Parameters:
  • name – name of the tag.

  • value – value of the erroneous tag.

name

name of the tag.

Type:

str | None

value

value of the erroneous tag.

Type:

str | None

class darkbridge.sidecar.nikon.NikonAsteroidProperties(element: Element)

Bases: NikonBaseProperties

Nikon Asteroid properties container.

This class parse a sidecar file and extract ast tags (namespace ‘http://ns.nikon.com/asteroid/1.0/’).

The article named “Inside Nikon Sidecar file” details the data structure and tags used by Nikon.

Parameters:

element – XML element containing the ‘rdf:Description’ tag.

Raises:
about

identifier of the sidecar file format. The identifier have to be ‘core-asteroid-tags’.

Type:

str | None

version

version identifier of the sidecar format (currently 11.0.0.3000)

Type:

str | None

xml_packets

https://www.exiftool.org/TagNames/XMP.html

Type:

str | None

gps_version_id

todo

Type:

str | None

gps_latitude_ref

0 = North, 1 = South

Type:

str | None

gps_latitude
Type:

str | None

gps_longitude_ref

2 = East, 3 = West

Type:

str | None

gps_longitude
Type:

str | None

gps_map_datum
Type:

str | None

iptc

https://www.exiftool.org/TagNames/IPTC.html

Type:

str | None

class darkbridge.sidecar.nikon.NikonBaseProperties(element: Element)

Bases: object

Base class for Nikon Properties class.

Parameters:

element – XML element containing the metadata.

Raises:
_expand_name(short_name: str) str

Expand a tag or attribute name based on the namespace table.

Parameters:

short_name – name of the tag or attribute in short format (i.e. prefix:tag). An empty string or without prefix is accepted.

Returns:

name in a expanded format (i.e. {uri}tag). An empty string or without uri as short_name return the unchanged value.

_shorten_name(expanded_name: str) str

Shorten a tag or attribute name based on the namespace table.

Parameters:

expanded_name – name of the tag or attribute in expanded format (i.e. {uri}tag). An empty string or without uri is accepted.

Returns:

name in a short format (i.e. prefix:tag). An empty string or without uri as expanded_name return the unchanged value.

class darkbridge.sidecar.nikon.NikonNineProperties(element: Element)

Bases: NikonBaseProperties

Nikon Nine properties container.

This class parse a sidecar file and extract nine tags (namespace ‘http://ns.nikon.com/nine/1.0/’).

The article named “Inside Nikon Sidecar file” details the data structure and tags used by Nikon.

Parameters:

element – XML element containing the ‘rdf:Description’ tag.

Raises:
about

identifier of the sidecar file format. The identifier have to be ‘nine-tags’.

Type:

str | None

version

version identifier of the sidecar format (currently 2.0.0)

Type:

str | None

nine_edits

https://www.exiftool.org/TagNames/Nikon.html#NineEdits

Type:

str | None

label
Type:

str | None

rating
Type:

str | None

class darkbridge.sidecar.nikon.NikonRDF(element: Element)

Bases: NikonBaseProperties

Nikon RDF container.

This class parse a sidecar file and extract rdf:RDF tags.

The article named “Inside Nikon Sidecar file” details the data structure and tags used by Nikon.

Parameters:

element – XML element containing the ‘rdf:RDF’ tag.

Raises:
about

not relevant here.

version

not relevant here.

class darkbridge.sidecar.nikon.NikonRDFDescription(element: Element)

Bases: NikonBaseProperties

Nikon RDF Description container. (NOT USEFUL)

This class parse a sidecar file and extract rdf:Description tags.

The article named “Inside Nikon Sidecar file” details the data structure and tags used by Nikon.

Parameters:

element – XML element containing the ‘rdf:Description’ tag.

Raises:
about

not relevant here.

version

not relevant here.

class darkbridge.sidecar.nikon.NikonSDCProperties(element: Element)

Bases: NikonBaseProperties

Nikon SDC properties container.

This class parse a sidecar file and extract sdc tags (namespace ‘http://ns.nikon.com/sdc/1.0/’).

The article named “Inside Nikon Sidecar file” details the data structure and tags used by Nikon.

Parameters:

element – XML element containing the ‘rdf:Description’ tag.

Raises:
about

identifier of the sidecar file format. The identifier have to be ‘nikon sidecar/1.0’.

Type:

str | None

version

version identifier of the sidecar format

Type:

str | None

app_name

name of the application that created the sidecar file.

Type:

str | None

app_version

version of the application that created the sidecar file.

Type:

str | None

class darkbridge.sidecar.nikon.NikonSideCar(element: Element)

Bases: object

Nikon Side car file.

This class parses a sidecar file to extract the metadata of the image on the one hand, and the image processing stack on the other. The NKSC files are in XML/XMP, so we walk in the RDF tree.

The article named “Inside Nikon Sidecar file” details the data structure and tags used by Nikon.

This class parse a sidecar file and extract xmpmeta tags.

The article named “Inside Nikon Sidecar file” details the data structure and tags used by Nikon.

Parameters:

element – XML element containing the XMP Packet element.

Raises:
Public Methods

This class has a number of public methods listed below in alphabetical order.

parse

Using NikonSideCar…

parse()

Parse the XMP tree and populate metadata and filters dictionaries

Raises:
Returns:

True if the execution went well. In case of failure, an error log is written on the standard error (stderr).

Return type:

bool

class darkbridge.sidecar.nikon.NikonXMPMeta(element: Element)

Bases: NikonBaseProperties

Nikon XMP Meta container.

This class parse a sidecar file and extract xmpmeta tags.

The article named “Inside Nikon Sidecar file” details the data structure and tags used by Nikon.

Parameters:

element – XML element containing the ‘x:xmpmeta’ element.

Raises:
about

not relevant here.

version

not relevant here.

xmptk

the toolkit name (‘XMP Core 5.5.0’ for example)

Type:

str | None

class darkbridge.sidecar.nikon.NikonXMPProperty(element: Element)

Bases: NikonBaseProperties

Nikon XMP property.

This class parses an XML element as a XMP property and decode the resource. The resource may be a simple text or a structured data identified with the rdf:parseType attribute.

The article named “Inside Nikon Sidecar file” details the data structure and tags used by Nikon.

Parameters:

element – element containing the property.

Raises:
name

not relevant here.

Type:

str

value

property’s value, the type of the attribute depends on the resource type (binary, double,…).

Type:

None | str | float | int | bytes

darkbridge.sidecar.nikon.NIKON_LABEL_MAP = {'0': '(Aucune)', '1': 'Rouge', '2': 'Orange', '3': 'Jaune', '4': 'Vert', '5': 'Cyan', '6': 'Bleu', '7': 'Violet', '8': 'Magenta', '9': 'Rose'}

Correspondence label couleur Nikon → label XMP (texte) Nikon encode les labels par numéro dans nksc

darkbridge.sidecar.nikon.NIKON_NKSC_EXT = '.nksc'

file extension of Nikon sidecar files

darkbridge.sidecar.nikon.NIKON_NKSC_SUBFOLDER = 'NKSC_PARAM'

subfolder storing the Nikon sidecar files

darkbridge.sidecar.nikon.NIKON_RATING_MAP = {'-1': '-1', '0': '0', '1': '1', '2': '2', '3': '3', '4': '4', '5': '5'}

Correspondence note Nikon → note XMP (0-5) Nikon stocke la note sous forme entière 0–5 directement compatible XMP

darkbridge.sidecar.nikon.NIKON_SUPPORTED_FORMAT = ['.nef', '.nrw', '.jpg', '.jpeg', '.tif', '.tiff', '.hif', '.nefx', '.mpo']

file extension of the supported image file