dwca package#
Package for reading Darwin Core Archive (DwCA) files.
Darwin Core Base Class#
- class dwca.base.darwincore.DarwinCore#
Bases:
ABCBase class of this package.
Methods
from_file(path_to_archive)Generate a Darwin Core Standard from a file.
to_file(path_to_archive[, encoding])Generate a Darwin Core file using the information of this instance.
- abstract classmethod from_file(path_to_archive: str) DarwinCore#
Generate a Darwin Core Standard from a file.
- Parameters:
- path_to_archivestr
Path of the archive file.
- Returns:
- DarwinCore
Instance of the Darwin Core Standard.
- abstract to_file(path_to_archive: str, encoding: str = 'utf-8') None#
Generate a Darwin Core file using the information of this instance.
- Parameters:
- path_to_archivestr
Path of the archive to generate.
- encodingstr, optional
Encoding of the corresponding files. Default “utf-8”.
Darwin Core Archive Class#
- class dwca.base.darwincore_archive.DarwinCoreArchive(_id: str = None)#
Bases:
DarwinCoreRepresent a Darwin Core Archive file with all its elements.
- Parameters:
- _idstr, optional
A unique id for this Darwin Core Archive.
- Attributes:
coreDataFile: The file with the core of the archive.
dataset_metadataDict[str, EML]: Metadata instances for each dataset present on DWC-A.
extensionsList[DataFile]: A list with the extension of the archive.
idstr: A unique identifier for this DarwinCoreArchive.
languageLanguage: Language of the Darwin Core Archive register on metadata.
metadataEML: Metadata instance, currently supported EML.
metadata_filenamestr: The filename of the metadata file.
Methods
Metadata([metadata])Metadata class of the Darwin Core Archive storing the file name of the archive elements.
from_file(path_to_archive[, lazy])Generate a Darwin Core Archive instance from an archive file (.zip).
generate_eml([filename])Generate an EML file on the archive
to_file(path_to_archive[, encoding, ...])Generate a Darwin Core Archive file (.zip file) using the information of this instance.
merge
- class Metadata(metadata: str = None)#
Bases:
XMLObjectMetadata class of the Darwin Core Archive storing the file name of the archive elements.
- Parameters:
- metadatastr, optional
Name of the metadata file (e.g.: eml.xml)
- Attributes:
- NAMESPACE_TAG
Methods
add_namespace(prefix, uri)Add a namespace to the XML object.
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.
get_dwc_class(element)Extract the row type from an XML element instance.
get_principal_tag()Returns the principal tag with namespaces if it is present.
object_to_element(tag[, prefix])Generates an element using tag, adding namespace tag.
parse(element, nmap)Parses an lxml.etree.Element in a Metadata instance.
Generate an element from a Metadata instance.
to_xml()Generates text of an XML file.
- PRINCIPAL_TAG = 'archive'#
str : The principal tag of the XML document.
- classmethod get_dwc_class(element: Element) Type[DataFile]#
Extract the row type from an XML element instance.
- Parameters:
- elementlxml.etree.Element
XML element instance.
- Returns:
- Type[DataFile]
The Python
classrepresenting the class term.
- classmethod parse(element: Element, nmap: Dict) Metadata#
Parses an lxml.etree.Element in a Metadata instance.
- Parameters:
- elementlxml.etree.Element
XML element to be parsed.
- nmapDict
Namespace prefix:uri.
- Returns:
- Metadata
New Metadata instance with the data from the element.
- to_element() Element#
Generate an element from a Metadata instance.
- Returns:
- lxml.etree.Element
XML element from Metadata instance
- xmlns = 'http://rs.tdwg.org/dwc/text/'#
str : Require tag of the metadata
- property dataset_metadata: Dict[str, EML]#
Dict[str, EML]: Metadata instances for each dataset present on DWC-A.
- classmethod from_file(path_to_archive: str, lazy: bool = False) DarwinCoreArchive#
Generate a Darwin Core Archive instance from an archive file (.zip).
- Parameters:
- path_to_archivestr
Path of the archive file.
- lazybool, optional
Read the archive lazy. Default False.
- Returns:
- DarwinCoreArchive
Instance of the Darwin Core Archive.
- generate_eml(filename: str = 'eml.xml') None#
Generate an EML file on the archive
- Parameters:
- filenamestr
Filename for the EML file to be generated
- property id: str#
str: A unique identifier for this DarwinCoreArchive.
- classmethod merge(first_archive: DarwinCoreArchive, second_archive: DarwinCoreArchive, _id: str = None, eml: EML = None, eml_filename: str = 'eml.xml') DarwinCoreArchive#
- property metadata_filename: str#
str: The filename of the metadata file.
- to_file(path_to_archive: str, encoding: str = 'utf-8', compression: int = 8, compression_level: int = 6) None#
Generate a Darwin Core Archive file (.zip file) using the information of this instance.
- Parameters:
- path_to_archivestr
Path of the archive to generate.
- encodingstr, optional
Encoding of the corresponding files. Default “utf-8”.
- compressionint, optional
The ZIP compression method to use. Default zipfile.ZIP_DEFLATED.
- compression_levelint, optional
Compression level to use when writing files to the archive. Default 6.
Simple Darwin Core Class#
- class dwca.base.simple_darwincore.SimpleDarwinCore#
Bases:
DarwinCoreClass representing a Simple Darwin Core standard.
Methods
from_file(path_to_archive)Generate a Darwin Core Standard from a file.
to_file(path_to_archive[, encoding])Generate a Darwin Core file using the information of this instance.
- classmethod from_file(path_to_archive: str) SimpleDarwinCore#
Generate a Darwin Core Standard from a file.
- Parameters:
- path_to_archivestr
Path of the archive file.
- Returns:
- DarwinCore
Instance of the Darwin Core Standard.
- to_file(path_to_archive: str, encoding: str = 'utf-8') None#
Generate a Darwin Core file using the information of this instance.
- Parameters:
- path_to_archivestr
Path of the archive to generate.
- encodingstr, optional
Encoding of the corresponding files. Default “utf-8”.
Subpackages#
- dwca.classes package
- dwca.terms package
- Field Class
- OutsideTerm Class
- ChronometricAge module
ChronometricAgeConversionProtocolChronometricAgeDeterminedByChronometricAgeDeterminedDateChronometricAgeIDChronometricAgeProtocolChronometricAgeReferencesChronometricAgeRemarksChronometricAgeUncertaintyInYearsChronometricAgeUncertaintyMethodEarliestChronometricAgeEarliestChronometricAgeReferenceSystemLatestChronometricAgeLatestChronometricAgeReferenceSystemMaterialDatedMaterialDatedIDMaterialDatedRelationshipUncalibratedChronometricAgeVerbatimChronometricAge
- Event module
- GeologicalContext module
EarliestAgeOrLowestStageEarliestEonOrLowestEonothemEarliestEpochOrLowestSeriesEarliestEraOrLowestErathemEarliestPeriodOrLowestSystemGeologicalContextIDHighestBiostratigraphicZoneLatestAgeOrHighestStageLatestEonOrHighestEonothemLatestEpochOrHighestSeriesLatestEraOrHighestErathemLatestPeriodOrHighestSystemLithostratigraphicBedLithostratigraphicFormationLithostratigraphicGroupLithostratigraphicMemberLithostratigraphicTermsLowestBiostratigraphicZone
- Identification module
- Location module
ContinentCoordinatePrecisionCoordinateUncertaintyInMetersCountryCountryCodeCountyDWCLocalityTermDecimalLatitudeDecimalLongitudeFootprintSRSFootprintSpatialFitFootprintWKTGeodeticDatumGeoreferenceProtocolGeoreferenceRemarksGeoreferenceSourcesGeoreferencedByGeoreferencedDateHigherGeographyHigherGeographyIDIslandIslandGroupLocationAccordingToLocationIDLocationRemarksMaximumDepthInMetersMaximumDistanceAboveSurfaceInMetersMaximumElevationInMetersMinimumDepthInMetersMinimumDistanceAboveSurfaceInMetersMinimumElevationInMetersMunicipalityPointRadiusSpatialFitStateProvinceVerbatimCoordinateSystemVerbatimCoordinatesVerbatimDepthVerbatimElevationVerbatimLatitudeVerbatimLocalityVerbatimLongitudeVerbatimSRSVerticalDatumWaterBody
- MaterialEntity module
- MaterialSample module
- MeasurementOrFact module
- Occurrence module
AssociatedMediaAssociatedOccurrencesAssociatedReferencesAssociatedTaxaBehaviorCasteCatalogNumberDWCDegreeOfEstablishmentDWCEstablishmentMeansGeoreferenceVerificationStatusIndividualCountLifeStageOccurrenceIDOccurrenceRemarksOccurrenceSexOccurrenceStatusOrganismQuantityOrganismQuantityTypeOtherCatalogNumbersPathwayRecordNumberRecordedByRecordedByIDReproductiveConditionVitality
- Organism module
- RecordLevel module
DWCAccessRightsDWCBasisOfRecordDWCBibliographicCitationDWCCollectionDWCCollectionCodeDWCDataGeneralizationsDWCDatasetDWCDatasetNameDWCDynamicPropertiesDWCInformationWithheldDWCInstitutionDWCInstitutionCodeDWCLanguageDWCLicenseDWCModifiedDWCOwnerInstitutionCodeDWCReferencesDWCRightsHolderDWCType
- ResourceRelationship module
- Taxon module
AcceptedNameUsageAcceptedNameUsageIDCultivarEpithetDWCClassFamilyGenericNameGenusHigherClassificationInfragenericEpithetInfraspecificEpithetKingdomNameAccordingToNameAccordingToIDNamePublishedInNamePublishedInIDNamePublishedInYearNomenclaturalCodeNomenclaturalStatusOrderOriginalNameUsageOriginalNameUsageIDParentNameUsageParentNameUsageIDPhylumScientificNameScientificNameAuthorshipScientificNameIDSpecificEpithetSubfamilySubgenusSubtribeSuperfamilyTaxonConceptIDTaxonIDTaxonRankTaxonRemarksTaxonomicStatusTribeVerbatimTaxonRankVernacularName