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:
ExceptionBase class for sidecar parser exceptions.
- Parameters:
message – (optional) Human readable string describing the exception.
- exception darkbridge.sidecar.nikon.NikonMissingTagError(name: str | None)
Bases:
NikonErrorRaised when an expected tag is missing.
- Parameters:
name – name of the missing tag.
- exception darkbridge.sidecar.nikon.NikonResourceError(prop_name: str | None, tag_name: str | None)
Bases:
NikonErrorRaised when a resource is erroneous (unknown tag).
- Parameters:
prop_name – name of the property
tag_name – name of the erroneous tag.
- exception darkbridge.sidecar.nikon.NikonResourceTypeError(prop_name: str | None, type_name: str | None)
Bases:
NikonErrorRaised when a resource is erroneous (unknown type).
- Parameters:
prop_name – name of the property
type_name – name of the erroneous type.
- exception darkbridge.sidecar.nikon.NikonTagValueError(name: str, value: str | None)
Bases:
NikonErrorRaised when a tag value is not expected.
- Parameters:
name – name of the tag.
value – value of the erroneous tag.
- class darkbridge.sidecar.nikon.NikonAsteroidProperties(element: Element)
Bases:
NikonBasePropertiesNikon Asteroid properties container.
This class parse a sidecar file and extract
asttags (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:
NikonError – generic error, the
NikonError.messagedetails the error.NikonMissingTagError – a tag value is not expected.
NikonTagValueError – an expected tag is missing
- about
identifier of the sidecar file format. The identifier have to be ‘core-asteroid-tags’.
- Type:
str | None
- xml_packets
https://www.exiftool.org/TagNames/XMP.html
- Type:
str | None
- iptc
https://www.exiftool.org/TagNames/IPTC.html
- Type:
str | None
- class darkbridge.sidecar.nikon.NikonBaseProperties(element: Element)
Bases:
objectBase class for Nikon Properties class.
- Parameters:
element – XML element containing the metadata.
- Raises:
NikonError – generic error, the
NikonError.messagedetails the error.NikonMissingTagError – a tag value is not expected.
NikonTagValueError – an expected tag is missing
- _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 asshort_namereturn 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 asexpanded_namereturn the unchanged value.
- class darkbridge.sidecar.nikon.NikonNineProperties(element: Element)
Bases:
NikonBasePropertiesNikon Nine properties container.
This class parse a sidecar file and extract
ninetags (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:
NikonError – generic error, the
NikonError.messagedetails the error.NikonMissingTagError – a tag value is not expected.
NikonTagValueError – an expected tag is missing
- about
identifier of the sidecar file format. The identifier have to be ‘nine-tags’.
- Type:
str | None
- nine_edits
https://www.exiftool.org/TagNames/Nikon.html#NineEdits
- Type:
str | None
- class darkbridge.sidecar.nikon.NikonRDF(element: Element)
Bases:
NikonBasePropertiesNikon RDF container.
This class parse a sidecar file and extract
rdf:RDFtags.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:
NikonError – generic error, the
NikonError.messagedetails the error.NikonMissingTagError – a tag value is not expected.
NikonTagValueError – an expected tag is missing
- about
not relevant here.
- version
not relevant here.
- class darkbridge.sidecar.nikon.NikonRDFDescription(element: Element)
Bases:
NikonBasePropertiesNikon RDF Description container. (NOT USEFUL)
This class parse a sidecar file and extract
rdf:Descriptiontags.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:
NikonError – generic error, the
NikonError.messagedetails the error.NikonMissingTagError – a tag value is not expected.
NikonTagValueError – an expected tag is missing
- about
not relevant here.
- version
not relevant here.
- class darkbridge.sidecar.nikon.NikonSDCProperties(element: Element)
Bases:
NikonBasePropertiesNikon SDC properties container.
This class parse a sidecar file and extract
sdctags (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:
NikonError – generic error, the
NikonError.messagedetails the error.NikonMissingTagError – a tag value is not expected.
NikonTagValueError – an expected tag is missing
- class darkbridge.sidecar.nikon.NikonSideCar(element: Element)
Bases:
objectNikon 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
xmpmetatags.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:
NikonError – generic error, the
NikonError.messagedetails the error.NikonMissingTagError – a tag value is not expected.
NikonTagValueError – an expected tag is missing
- Public Methods
This class has a number of public methods listed below in alphabetical order.
Using NikonSideCar…
- parse()
Parse the XMP tree and populate metadata and filters dictionaries
- Raises:
NikonMissingTagError – a tag value is not expected.
NikonTagValueError – an expected tag is missing
- Returns:
Trueif the execution went well. In case of failure, an error log is written on the standard error (stderr).- Return type:
- class darkbridge.sidecar.nikon.NikonXMPMeta(element: Element)
Bases:
NikonBasePropertiesNikon XMP Meta container.
This class parse a sidecar file and extract
xmpmetatags.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:
NikonError – generic error, the
NikonError.messagedetails the error.NikonMissingTagError – a tag value is not expected.
NikonTagValueError – an expected tag is missing
- about
not relevant here.
- version
not relevant here.
- class darkbridge.sidecar.nikon.NikonXMPProperty(element: Element)
Bases:
NikonBasePropertiesNikon XMP property.
This class parses an XML element as a
XMPproperty and decode the resource. The resource may be a simple text or a structured data identified with therdf:parseTypeattribute.The article named “Inside Nikon Sidecar file” details the data structure and tags used by Nikon.
- Parameters:
element – element containing the property.
- Raises:
NikonResourceError – a resource is erroneous (unknown tag).
NikonResourceTypeError – a resource is erroneous (unknown type)
- 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