minsci.xmu.containers package¶
Submodules¶
minsci.xmu.containers.auditrecord module¶
Subclass of DeepDict with methods specific to eaudits
-
class
minsci.xmu.containers.auditrecord.AuditRecord(*args)[source]¶ Bases:
minsci.xmu.containers.xmurecord.XMuRecordContains methods for reading data from EMu XML exports
minsci.xmu.containers.bibliorecord module¶
Subclass of XMuRecord with methods specific to emultimedia
-
class
minsci.xmu.containers.bibliorecord.BiblioRecord(*args, **kwargs)[source]¶ Bases:
minsci.xmu.containers.xmurecord.XMuRecordSubclass of XMuRecord with methods specific to ebibliography
-
static
clean_reference(ref)[source]¶ Cleans punctuation, etc. left behind when ref has empty fields FIXME: This is horrible
-
static
format_name(last, first, middle, use_initials=True, mask='{last}, {first} {middle}')[source]¶ Formats a name according to the given mask
Formats a list of author names
-
static
minsci.xmu.containers.mediarecord module¶
Subclass of XMuRecord with methods specific to emultimedia
-
class
minsci.xmu.containers.mediarecord.EmbedFromEMu(*args, **kwargs)[source]¶ Bases:
minsci.xmu.tools.multimedia.embedder.EmbedderTools to embed metadata into a file based on existing data in EMu
-
get_object_name(rec, mask='include_code')[source]¶ Returns the photo identifier or list of pictured objects
-
get_object_sources(rec, source='NMNH-Smithsonian Institution')[source]¶ Returns list with museum name
-
-
class
minsci.xmu.containers.mediarecord.MediaFile(irn, filename, path, hash, size, width, height, is_image, row)¶ Bases:
tuple-
filename¶ Alias for field number 1
-
hash¶ Alias for field number 3
-
height¶ Alias for field number 6
-
irn¶ Alias for field number 0
-
is_image¶ Alias for field number 7
-
path¶ Alias for field number 2
-
row¶ Alias for field number 8
-
size¶ Alias for field number 4
-
width¶ Alias for field number 5
-
-
class
minsci.xmu.containers.mediarecord.MediaRecord(*args)[source]¶ Bases:
minsci.xmu.containers.xmurecord.XMuRecordSubclass of XMuRecord with methods specific to emultimedia
-
copy_to(path, overwrite=False, verify_image=False)[source]¶ Copies the primary file to a new location
Parameters: - path (str) – the directory to copy the image to
- overwrite (bool) – specifies whether to overwrite existing file
- verify_master (bool) – specifies whether to verify copied file
Populates DetRelation_tab with info about matching catalog records
-
minsci.xmu.containers.minscirecord module¶
Subclass of XMuRecord with methods specific to Mineral Sciences
-
class
minsci.xmu.containers.minscirecord.MinSciRecord(*args)[source]¶ Bases:
minsci.xmu.containers.xmurecord.XMuRecordSubclass of XMuRecord with methods specific to Mineral Sciences
-
antmet= <_sre.SRE_Pattern object>¶
-
geotree= None¶
-
get_catalog_number(include_code=True, include_div=False)[source]¶ Returns the catalog number of the current object
-
get_catnum(include_code=True, include_div=False)[source]¶ Returns the catalog number of the current object
-
get_classification(standardized=True)[source]¶ Gets classification of object based on record
Parameters: standardized (bool) – if True, use GeoTaxa to try to group and standardize classification terms Returns: List of classification terms
-
get_guid(kind='EZID', allow_multiple=False)[source]¶ Gets value from the GUID table for a given key
Parameters: - kind (str) – name of GUID
- allow_multiple (bool) – if False, raises error if multiple values with same type are found
Returns: First match from the GUID table for the key (if allow_multiple is False) or the full set of matches (if allow_multiple is True)
-
get_identifier(include_code=True, include_div=False, force_catnum=False)[source]¶ Derives sample identifier based on record
Parameters: - include_code (bool) – specifies whether to include museum code
- include_div (bool) – specifies whetehr to include division
Returns: String of NMNH catalog number or Antarctic meteorite number
-
get_name(taxa=None, force_derived=False)[source]¶ Derives object name based on record
Parameters: taxa (list) – list of taxa. Determined automatically if omitted. Returns: String with object name
-
get_political_geography()[source]¶ Gets political geographic info for an object
Returns: List of place names in order of decreasing specificity
-
minsci.xmu.containers.taxonrecord module¶
minsci.xmu.containers.xmurecord module¶
Subclass of DeepDict with methods specific to XMu
-
class
minsci.xmu.containers.xmurecord.Row(irn, field, row, val)¶ Bases:
tuple-
field¶ Alias for field number 1
-
irn¶ Alias for field number 0
-
row¶ Alias for field number 2
-
val¶ Alias for field number 3
-
-
class
minsci.xmu.containers.xmurecord.XMuRecord(*args)[source]¶ Bases:
minsci.dicts.deepdict.DeepDictContains methods for reading data from EMu XML exports
-
delete_rows(key, indexes=None, conditions=None)[source]¶ Deletes any rows matching the given conditions from a table
-
get_current_weight(decimal_places=2)[source]¶ Gets the current weight of the object
Parameters: decimal_places (int) – the number of decimal places to which to round the weight Returns: Unicode-encoded string with the weight and unit, if any
-
get_date(date_from, date_to=None, date_format='%Y-%m-%d')[source]¶ Returns dates and date ranges
Parameters: - date_from (mixed) – path to date from field
- date_to (mixed) – path to date to field
- date_format (str) – formatting mask for date
Returns: Date or date range as a string
-
get_datetime(date_from, date_to=None, date_modifier=None, time_from=None, time_to=None, time_modifier=None, conjunction=' to ', format='%Y%m%dT%H%M%S')[source]¶
-
get_guid(kind='EZID', allow_multiple=False)[source]¶ Gets value from the GUID table for a given key
Parameters: - kind (str) – name of GUID
- allow_multiple (bool) – if False, raises error if multiple values with same type are found
Returns: First match from the GUID table for the key (if allow_multiple is False) or the full set of matches (if allow_multiple is True)
-
get_location(current=False, keyword=None)[source]¶ Returns the current or permanent location of a specimen
-
get_matching_rows(match, label_field, value_field)[source]¶ Helper function to find rows in any table matching a kind/label
Parameters: - match (str) – the name of the label to match
- label_field (str) – field in a table containing the label
- value_field (str) – field in a table containing the value
Returns: List of values matching the match string
-
get_reference(*args)[source]¶ Returns a list of values corresponding to the table rows
Parameters: *args – the path to a value in the dictionary, with one component of that path per arg. Returns: If the last arg is a field (as opposed to a reference table), this function will return a list of values, one per row. If the last arg is a reference table, it will return a list of XMuRecords.
-
get_rows(*args)[source]¶ Returns a list of values corresponding to the table rows
Parameters: *args – the path to a value in the dictionary, with one component of that path per arg Returns: List of values, one per row
-
is_new(found)[source]¶ Checks if current module:irn exists in found
Parameters: found (dict) – marks irns already found as True Returns: Boolean expressing if the current record has already been seen This method can be invoked manually inside the XMu subclass when reading XML exports from a directory containing multiple, potentially overlapping record sets to prevent (a) the same record from being read twice or (b) an older version of a record from overwriting a more recent one.
-
simple_pull(path)[source]¶ Returns data from path in DeepDict
Parameters: path (mixed) – the path to an EMu field as a string or list Returns: Value for the given path
-
smart_pull(*args, **kwargs)[source]¶ Pull data from the record, formatting the result based on the path
Parameters: *args – the path to a value in the dictionary, with one component of that path per arg. If args[0] contains one or more dots, the path will be expanded from that and ignore subsequent args. Returns: An atomic field returns a string A reference pointing to a single field returns a string A simple table returns a list of values A reference table that specifies a field returns a list A reference table returns a list of XMuRecord objects A nested table returns a list of lists Return type: Value for the given path, formatted as follows
-
unwrap()[source]¶ Removes outermost level of XMuRecord
This simplifies the paths needed to pull data from the record. The record will need to be wrapped again before writing to XML.
Returns: Unwrapped XMuRecord. In a typical use case, this means the paths used to retrieve data do not need to include the module name.
-
Module contents¶
Defines module-specific containers for working with EMu data