eml package#
Package for reading and writing Ecological Metadata Language.
Subpackages#
Module contents#
EML Class#
- class eml.base.eml.EML(package_id: str, system: str, resource_type: EMLResource, version: EMLVersion = EMLVersion.VERSION_2_2_0, language: Language = Language.ENG, access: AccessType = None, additional_metadata: List[Any] = None, annotation: List[Tuple[SemanticAnnotation, str]] = None)#
Bases:
EMLObject
Class representing an Ecological Metadata Language
- Parameters:
- package_idstr
A globally unique identifier for the data package described by this EML that can be used to cite it elsewhere.
- systemstr
The data management system within which an identifier is in scope and therefore unique.
- resource_typeEMLResource
Type of the resource: dataset, citation, protocol or software.
- version: EMLVersion, optional
Version of the EML standard. Default: latest (2.2.0).
- languageLanguage, optional
Language abbreviation to be used, defaults to “eng”
- accessAccessType, optional
Access control rules for the entire resource, which can be overridden by access rules in distribution trees.
- additional_metadataList[None], optional
A flexible field for including any other relevant metadata that pertains to the resource being described.
- annotation: List[Tuple[SemanticAnnotation, str]], optional
A list of precisely-defined semantic statements about this resource.
- Attributes:
access
None: Access control rules for the entire resource.
additional_metadata
List[Any]: A flexible field for including any other relevant metadata.
annotations
Annotation: A list of precisely-defined semantic statements about this resource.
id
str: Unique identifier of the resource
language
Language: The language of the resource.
package_id
str: A globally unique identifier for the data package described by this EML that can be used to cite it.
references
bool: Whether the resource is referencing another or is being defined
referencing
bool: Whether the resource is referencing another or is being defined
resource
Resource: The resource instance.
resource_type
EMLResource: The type of the resource.
scope
Scope: The scope of the identifier.
system
str: The data management system within which an identifier is in scope and therefore unique.
Methods
Annotation
(semantic_annotation, references)A precisely-defined semantic statement about an element in the EML document.
add_additional_info
(additional_info)Add additional info to the resource in the EML.
Add an alternative identifier to the EML.
add_annotation
(annotation)Add annotation to the resource in the EML.
add_associated_party
(associated_party, role)Add metadata provider to the EML.
add_creator
(creator)Add a new creator to the EML.
add_distribution
(distribution)Add distribution to the resource in the EML.
add_keyword_set
(keyword_set)Add keyword set to the resource in the EML.
add_licensed
(licensed)Add licensed to the resource in the EML.
add_metadata_provider
(metadata_provider)Add metadata provider to the EML.
add_title
(title[, language])Add a new title to the EML.
check_principal_tag
(tag, nmap)Checks if the tag is the Principal tag of the object.
from_string
(text)Generates XML Object from a string of an XML file.
from_xml
(file[, encoding])Generates an XML Object from an XML file.
generate_references_element
()Generate the <references> element.
get_no_referrer
(element, nmap)Generate an EML instance object using an XML element.
get_principal_tag
()Returns the principal tag with namespaces if it is present.
get_referrer
(element, nmap)EML cannot have references.
get_scope
(element)Get the scope from the element.
initialize_resource
(titles, creators, **kwargs)Initialize the resource instance of this EML.
object_to_element
(tag[, prefix])Generates an element using tag, adding namespace tag.
parse
(element, nmap)Common parse of an EML object
set_abstract
(abstract)Set abstract of the resource in the EML.
set_coverage
(coverage)Set coverage of the resource in the EML.
set_intellectual_rights
(intellectual_rights)Set intellectual rights of the resource in the EML.
set_language
(language)Set language of the resource in the EML.
set_pub_date
(date)Set publication date of the resource in the EML.
set_series
(series)Set series of the resource in the EML.
set_short_name
(short_name)Set short name of Resource in the EML.
Generate an XML element instance using the EML information.
to_xml
()Generates text of an XML file.
- class Annotation(semantic_annotation: SemanticAnnotation, references: str)#
Bases:
object
A precisely-defined semantic statement about an element in the EML document.
- Parameters:
- semantic_annotation: SemanticAnnotation
A semantically-precise statement about an EML element.
- referencesstr
The id of the element being annotated.
- Attributes:
annotation
SemanticAnnotation: A semantically-precise statement about an EML element.
references
str: The id of the element being annotated.
- property annotation: SemanticAnnotation#
SemanticAnnotation: A semantically-precise statement about an EML element.
- property references: str#
str: The id of the element being annotated.
- NAMESPACE_TAG = 'eml'#
str: Namespace tag eml, to be replace for {uri}tag
- PRINCIPAL_TAG = 'eml'#
str : The principal tag of the XML document.
- property access: AccessType#
None: Access control rules for the entire resource.
- add_additional_info(additional_info: EMLTextType) None #
Add additional info to the resource in the EML.
- Parameters:
- additional_infoEMLTextType
Additional info in the required
eml.types.text_type.EMLTextType
instance format.
- add_alternative_identifier(alternative_identifier: str | ExtensionString) None #
Add an alternative identifier to the EML.
- Parameters:
- alternative_identifierstr | ExtensionString
An alternative identifier.
- add_annotation(annotation: SemanticAnnotation) None #
Add annotation to the resource in the EML.
- Parameters:
- annotationSemanticAnnotation
An annotation in the
eml.types.semantic_annotation.SemanticAnnotation
instance format.
- add_associated_party(associated_party: ResponsibleParty, role: Role) None #
Add metadata provider to the EML.
- Parameters:
- associated_partyResponsibleParty
An Associated Party of the resource in the EML.
- roleRole
The role of the Associated Party.
- add_creator(creator: ResponsibleParty) None #
Add a new creator to the EML.
- Parameters:
- creatorResponsibleParty
The creator to be added to the resource.
- add_distribution(distribution: EMLDistribution) None #
Add distribution to the resource in the EML.
- Parameters:
- distributionEMLDistribution
An instance of
eml.resources.distribution.distribution.EMLDistribution
.
- add_keyword_set(keyword_set: EMLKeywordSet) None #
Add keyword set to the resource in the EML.
- Parameters:
- keyword_setEMLKeywordSet
An instance of
eml.resources.keyword_set.EMLKeywordSet
.
- add_licensed(licensed: EMLLicense) None #
Add licensed to the resource in the EML.
- Parameters:
- licensedEMLLicense
An license instance.
- add_metadata_provider(metadata_provider: ResponsibleParty) None #
Add metadata provider to the EML.
- Parameters:
- metadata_providerResponsibleParty
A Metadata Provider of the resource in the EML.
- add_title(title: str | I18nString, language: Language = Language.ENG) None #
Add a new title to the EML.
- Parameters:
- titlestr | I18nString
The title as string or with language already
- languageLanguage, optional
The language of the title. If the title given is a I18nString, this argument is discarded.
- property additional_metadata: List[Any]#
List[Any]: A flexible field for including any other relevant metadata.
- property annotations: List[Annotation]#
Annotation: A list of precisely-defined semantic statements about this resource.
- classmethod get_no_referrer(element: Element, nmap: Dict) EML #
Generate an EML instance object using an XML element.
- Parameters:
- elementlxml.etree.Element
XML element to parse.
- nmapDict
Namespace.
- Returns:
- EML
EML instance.
- classmethod get_referrer(element: Element, nmap: Dict) EMLObject #
EML cannot have references.
- Parameters:
- elementlxml.etree.Element
An XML element instance.
- nmapDict
Namespace.
- Raises:
- ValueError
EML cannot reference another EML.
- initialize_resource(titles: str | I18nString | List[str | I18nString], creators: ResponsibleParty | List[ResponsibleParty], **kwargs) None #
Initialize the resource instance of this EML.
- Parameters:
- titlesstr | I18nString | List[str | I18nString]
The titles to initialize the resource with.
- creatorsResponsibleParty | List[ResponsibleParty]+
The creators to initialize the resource with.
- Other Parameters:
- **kwargsParameters given in
eml.resources.resource.Resource
or any subclass.
- **kwargsParameters given in
- property package_id: str#
str: A globally unique identifier for the data package described by this EML that can be used to cite it.
- property resource_type: EMLResource#
EMLResource: The type of the resource.
- set_abstract(abstract: EMLTextType) None #
Set abstract of the resource in the EML.
- Parameters:
- abstractEMLTextType
An abstract in the required
eml.types.text_type.EMLTextType
instance format.
- set_coverage(coverage: EMLCoverage) None #
Set coverage of the resource in the EML.
- Parameters:
- coverageEMLCoverage
An instance of
eml.resources.coverage.coverage.EMLCoverage
.
- set_intellectual_rights(intellectual_rights: EMLTextType) None #
Set intellectual rights of the resource in the EML.
- Parameters:
- intellectual_rightsEMLTextType
The intellectual rights in the required
eml.types.text_type.EMLTextType
instance format.
- set_language(language: Language) None #
Set language of the resource in the EML.
- Parameters:
- languageLanguage
A Language enum instance.
- set_pub_date(date: date) None #
Set publication date of the resource in the EML.
- Parameters:
- datedatetime.date
Publication date.
- set_series(series: str) None #
Set series of the resource in the EML.
- Parameters:
- seriesstr
The series from which the resource came.
- set_short_name(short_name: str) None #
Set short name of Resource in the EML.
- Parameters:
- short_namestr
A short name for the resource.
- property system: str#
str: The data management system within which an identifier is in scope and therefore unique.
- to_element() Element #
Generate an XML element instance using the EML information.
- Returns:
lxml.etree.Element
XML element instance.
EMLVersion Class#
- class eml.base.version.EMLVersion(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
Enum
Version of the specification of the EML used.
- LATEST = (2, 2, 0)#
- VERSION_2_1_1 = (2, 1, 1)#
- VERSION_2_2_0 = (2, 2, 0)#
- get_namespace() Dict[Any, str] #
Get namespace of the given version.
- Returns:
- Dict[Any, str]
Namespace as a dictionary of value:uri.
- classmethod get_version(schema_location: str) EMLVersion #
Get version of EML parsing the schema location provided.
- Parameters:
- schema_locationstr
Schema location text.
- Returns:
- EMLVersion
Version of the EML.
- schema_location() List[str] #
The schema location of the given version.
- Returns:
- List[str]
A list of url where the schema of the XML version is located.
- Raises:
- NotImplementedError
Version not implemented or not existing.
EMLObject Base Class#
- class eml.types.eml_object.EMLObject(_id: str = None, scope: Scope = Scope.DOCUMENT, system: str = None, referencing: bool = False, references_system: str = None)#
Bases:
XMLObject
,ABC
Abstract class representing most of the EML document
- Parameters:
- _idstr, optional
Unique identifier within the scope.
- scopeScope, default DOCUMENT
The scope of the identifier.
- systemstr, optional
The data management system within which an identifier is in scope and therefore unique.
- referencingbool, optional, default=False
Whether the resource is referencing another or is being defined.
- references_systemstr, optional
System attribute of reference.
- Attributes:
- NAMESPACE_TAG
id
str: Unique identifier of the resource
references
bool: Whether the resource is referencing another or is being defined
referencing
bool: Whether the resource is referencing another or is being defined
scope
Scope: The scope of the identifier.
system
str: The data management system within which an identifier is in scope and therefore unique.
Methods
check_principal_tag
(tag, nmap)Checks if the tag is the Principal tag of the object.
from_string
(text)Generates XML Object from a string of an XML file.
from_xml
(file[, encoding])Generates an XML Object from an XML file.
Generate the <references> element.
get_no_referrer
(element, nmap)Generate an EML Object that do not reference another.
get_principal_tag
()Returns the principal tag with namespaces if it is present.
get_referrer
(element, nmap)Generate an EML Object referencing another EML Object.
get_scope
(element)Get the scope from the element.
object_to_element
(tag[, prefix])Generates an element using tag, adding namespace tag.
parse
(element, nmap)Common parse of an EML object
to_element
()Generates a lxml.tree.Element from the object.
to_xml
()Generates text of an XML file.
- generate_references_element() Element #
Generate the <references> element.
- Returns:
- xml.etree.Element
XML Element representing the references of referrer resource.
- abstract classmethod get_no_referrer(element: Element, nmap: Dict) EMLObject #
Generate an EML Object that do not reference another.
- Parameters:
- elementlxml.etree.Element
XML element to parse.
- nmapDict
Namespace.
- Returns:
- EMLObject
Object parsed.
- abstract classmethod get_referrer(element: Element, nmap: Dict) EMLObject #
Generate an EML Object referencing another EML Object.
- Parameters:
- elementlxml.etree.Element
XML element to parse with references object.
- nmapDict
Namespace.
- Returns:
- EMLObject
Object parsed that reference another.
- static get_scope(element: Element) Scope #
Get the scope from the element.
- Parameters:
- elementlxml.etree.Element
XML Element to find scope.
- Returns:
- Scope
A valid Scope.
- Raises:
- ValueError
Not a valid scope string.
- property id: str#
str: Unique identifier of the resource
- classmethod parse(element: Element, nmap: Dict) EMLObject | None #
Common parse of an EML object
- Parameters:
- elementlxml.etree.Element
XML Element to parse
- nmapDict
Namespace
- Returns:
- EMLObject
Parsed EML Object
- property references: ExtensionString#
bool: Whether the resource is referencing another or is being defined
- property referencing: bool#
bool: Whether the resource is referencing another or is being defined
- property system: str#
str: The data management system within which an identifier is in scope and therefore unique.