text stringlengths 81 112k |
|---|
Use one column of data, to write one line of data in the variables section.
:return none:
def __write_variables_2(self, col):
"""
Use one column of data, to write one line of data in the variables section.
:return none:
"""
col = self.__convert_keys_1("Variables", col)
... |
Read numeric data from csv and write to the bottom section of the txt file.
:param dict table: Paleodata dictionary
:return none:
def __write_columns(self, pc, table):
"""
Read numeric data from csv and write to the bottom section of the txt file.
:param dict table: Paleodata di... |
Write a key value pair to the output file. If v is a list, write multiple lines.
:param k: Key
:param v: Value
:param bool top: Write preceding empty line
:param bool bot: Write following empty line
:param bool multi: v is a list
:return none:
def __write_k_v(self, k, v,... |
Write a divider line
:return none:
def __write_divider(self, top=False, bot=False, nl=True):
"""
Write a divider line
:return none:
"""
if top:
self.noaa_txt += "\n#"
if nl:
self.noaa_txt += "\n"
self.noaa_txt += "#----------------... |
Write the variableNames that are the column header in the "Data" section
:param list l: variableNames
:return none:
def __write_data_col_header(self, l, pc):
"""
Write the variableNames that are the column header in the "Data" section
:param list l: variableNames
:return... |
Loop over value arrays and write index by index, to correspond to the rows of a txt file
:param list ll: List of lists, column data
:return:
def __write_data_col_vals(self, ll, pc):
"""
Loop over value arrays and write index by index, to correspond to the rows of a txt file
:par... |
Copies the value of one need option to another
.. code-block:: jinja
.. req:: copy-example
:id: copy_1
:tags: tag_1, tag_2, tag_3
:status: open
.. spec:: copy-example implementation
:id: copy_2
:status: [[copy("status", "copy_1")]]
... |
Returns a specific value, if for all linked needs a given option has a given value.
The linked needs can be filtered by using the ``filter`` option.
If ``one_hit`` is set to True, only one linked need must have a positive match for the searched value.
**Examples**
**Needs used as input data**
.... |
Sums the values of a given option in filtered needs up to single number.
Useful e.g. for calculating the amount of needed hours for implementation of all linked
specification needs.
**Input data**
.. spec:: Do this
:id: sum_input_1
:hours: 7
:collapse: False
.. spec:: Do th... |
Convert between NOAA and LiPD file formats.
:return:
def noaa_prompt():
"""
Convert between NOAA and LiPD file formats.
:return:
"""
logger_noaa.info("enter noaa")
# Run lpd_noaa or noaa_lpd ?
print("Which conversion?\n1. LPD to NOAA\n2. NOAA to LPD\n")
mode = input("Option: ")
... |
For converting LiPD files to NOAA, we need a couple more pieces of information to create the WDS links
:return str _project: Project name
:return float _version: Version number
def noaa_prompt_1():
"""
For converting LiPD files to NOAA, we need a couple more pieces of information to create the WDS lin... |
Convert NOAA format to LiPD format
:param dict files: Files metadata
:return None:
def noaa_to_lpd(files):
"""
Convert NOAA format to LiPD format
:param dict files: Files metadata
:return None:
"""
logger_noaa.info("enter process_noaa")
# only continue if the user selected a mode co... |
Convert a LiPD format to NOAA format
:param dict D: Metadata
:return dict D: Metadata
def lpd_to_noaa(D, wds_url, lpd_url, version, path=""):
"""
Convert a LiPD format to NOAA format
:param dict D: Metadata
:return dict D: Metadata
"""
logger_noaa.info("enter process_lpd")
d = D
... |
Use the filename - text data pairs to write the data as NOAA text files
:param dict dat: NOAA data to be written
:return none:
def __write_noaas(dat, path):
"""
Use the filename - text data pairs to write the data as NOAA text files
:param dict dat: NOAA data to be written
:return none:
"... |
Return the version number found in the first line of `java -version`
>>> _parse_java_version('openjdk version "11.0.2" 2018-10-16')
(11, 0, 2)
def _parse_java_version(line: str) -> tuple:
""" Return the version number found in the first line of `java -version`
>>> _parse_java_version('openjdk version... |
Return a path to a JAVA_HOME suites for the given CrateDB version
def find_java_home(cratedb_version: tuple) -> str:
""" Return a path to a JAVA_HOME suites for the given CrateDB version """
if MIN_VERSION_FOR_JVM11 <= cratedb_version < (4, 0):
# Supports 8 to 11+, use whatever is set
return os... |
Zips up directory back to the original location
:param str root_dir: Root directory of the archive
:param str name: <datasetname>.lpd
:param str path_name_ext: /path/to/filename.lpd
def zipper(root_dir="", name="", path_name_ext=""):
"""
Zips up directory back to the original location
:param st... |
Unzip .lpd file contents to tmp directory.
:param str filename: filename.lpd
:param str dir_tmp: Tmp folder to extract contents to
:return None:
def unzipper(filename, dir_tmp):
"""
Unzip .lpd file contents to tmp directory.
:param str filename: filename.lpd
:param str dir_tmp: Tmp folder t... |
Calculate the percentile using the nearest rank method.
>>> percentile([15, 20, 35, 40, 50], 50)
35
>>> percentile([15, 20, 35, 40, 50], 40)
20
>>> percentile([], 90)
Traceback (most recent call last):
...
ValueError: Too few data points (0) for 90th percentile
def percentile(sor... |
Return a sampler constructor
>>> get_sampler('all')
<class 'cr8.metrics.All'>
>>> get_sampler('reservoir')
<class 'cr8.metrics.UniformReservoir'>
>>> get_sampler('reservoir:100')
functools.partial(<class 'cr8.metrics.UniformReservoir'>, size=100)
def get_sampler(sample_mode: str):
"""Ret... |
Returns a dict of the query, including the results
:param critera: string of search criteria
:param **opts:
:formats: json/xml (default: json)
:timezone: timezone to use (default: UTC)
:time_from: 15m ago from now (datetime)
:time_t... |
Parse data from Excel spreadsheets into LiPD files.
:param dict file: File metadata (source, name, etc)
:return str dsn: Dataset name
def excel_main(file):
"""
Parse data from Excel spreadsheets into LiPD files.
:param dict file: File metadata (source, name, etc)
:return str dsn: Dataset name... |
Get worksheet metadata. The sheet names tell us what type of table it is and where in the LiPD structure the data
should be placed.
Example VALID sheet name:
paleo1measurement1
paleo1model1ensemble1
paleo1model1distribution1
Example INVALID sheet names:
paleo1measurement
paleo1ensemble... |
Guide the user to create a proper, standardized sheet name
:param list sheets: Running list of sheet metadata
:param str old_name: Original sheet name
:param str name: Data set name
:param int ct_paleo: Running count of paleoData tables
:param int ct_chron: Running count of chronData tables
:ret... |
Build metadata for a sheet. Receive valid regex match object and use that to create metadata.
:param obj m: Regex match object
:param list sheets: Running list of sheet metadata
:param str old_name: Original sheet name
:param str name: Data set name
:param int ct_paleo: Running count of paleoData ta... |
Place data into skeleton for either a paleo or chron section.
:param dict skeleton_section: Empty or current progress of skeleton w/ data
:param dict sheet: Sheet metadata
:param list keys_section: Paleo or Chron specific keys
:return dict: Skeleton section full of data
def _place_tables_section(skelet... |
All the data has been parsed, skeletons have been created, now put the data into the skeletons.
:param list sheets: All metadata needed to place sheet data into the LiPD structure
:param list skeleton_paleo: The empty skeleton where we will place data
:param list skeleton_chron: The empty skeleton where we ... |
Loop through sheet metadata and count how many of each table type is needed at each index.
Example: 'paleo 1' needs {'2 measurement tables', '1 model table, with 1 summary, 1 ensemble, and 3 distributions'}
:param dict sheet: Sheet metadata
:param dict num_section: Rolling number counts of table types for e... |
Bottom level: {"measurement": [], "model": [{summary, distributions, ensemble}]}
Fill in measurement and model tables with N number of EMPTY meas, summary, ensemble, and distributions.
:param str pc: Paleo or Chron "mode"
:param list l:
:param dict num_section:
:return dict:
def _create_skeleton_3(... |
Mid level: {"measurement", "model"}
Fill in paleoData tables with N number of EMPTY measurement and models.
:param list l: paleoData or chronData list of tables
:param dict num_section: Number of tables needed for each table type
:param dict template: The empty template for the measurement and model to... |
Top level: {"chronData", "paleoData"}
Fill in paleoData/chronData tables with N number of EMPTY measurement and models.
:return list: Blank list of N indices
def _create_skeleton_1(sheets):
"""
Top level: {"chronData", "paleoData"}
Fill in paleoData/chronData tables with N number of EMPTY measurem... |
The universal spreadsheet parser. Parse chron or paleo tables of type ensemble/model/summary.
:param str name: Filename
:param obj workbook: Excel Workbook
:param dict sheet: Sheet path and naming info
:return dict dict: Table metadata and numeric data
def _parse_sheet(workbook, sheet):
"""
The... |
Parse a row from the data section of the sheet. Add the cleaned row data to the overall table data.
:param obj temp_sheet: Excel sheet
:param int num_row: Current sheet row
:param int col_total: Number of column variables in this sheet
:param dict table_data: Running record of table data
:param str ... |
Replace Missing Values in the data rows where applicable
:param list row: Row
:return list: Modified row
def _replace_mvs(row, mv):
"""
Replace Missing Values in the data rows where applicable
:param list row: Row
:return list: Modified row
"""
for idx, v in enumerate(row):
try:... |
Get the variable header keys from this special row
:return list: Header keys
def _get_header_keys(row):
"""
Get the variable header keys from this special row
:return list: Header keys
"""
# Swap out NOAA keys for LiPD keys
for idx, key in enumerate(row):
key_low = key.value.lower()... |
NOTE: USE THIS FOR SINGLE CELLS ONLY
When parsing sheets, all variable names be exact matches when cross-referenceing the metadata and data sections
However, sometimes people like to put "age (years BP)" in one section, and "age" in the other. This causes problems.
We're using this regex to match all variab... |
Wrapper around "_rm_units_from_var_name_single" for doing a list instead of a single cell.
:param list row: Variable names
:return list: Variable names
def _rm_units_from_var_names_multi(row):
"""
Wrapper around "_rm_units_from_var_name_single" for doing a list instead of a single cell.
:param list... |
Compile the interpretation data into a list of multiples, based on the keys provided.
Disassemble the key to figure out how to place the data
:param dict data: Interpretation data (unsorted)
:return dict: Interpretation data (sorted)
def _compile_interpretation(data):
"""
Compile the interpretation... |
Compile column metadata from one excel row ("9 part data")
:param list row: Row of cells
:param list keys: Variable header keys
:return dict: Column metadata
def _compile_column_metadata(row, keys, number):
"""
Compile column metadata from one excel row ("9 part data")
:param list row: Row of c... |
Remove the cells that are empty or template in reverse order. Stop when you hit data.
:param list l: One row from the spreadsheet
:return list: Modified row
def _rm_cells_reverse(l):
"""
Remove the cells that are empty or template in reverse order. Stop when you hit data.
:param list l: One row fro... |
CSV data has been parsed by this point, so take it and write it file by file.
:return:
def _write_data_csv(csv_data):
"""
CSV data has been parsed by this point, so take it and write it file by file.
:return:
"""
logger_excel.info("enter write_data_csv")
# Loop for each file and data that i... |
GeoJSON Linestring. Latitude and Longitude have 2 values each.
:param list lat: Latitude values
:param list lon: Longitude values
:return dict:
def geometry_linestring(lat, lon, elev):
"""
GeoJSON Linestring. Latitude and Longitude have 2 values each.
:param list lat: Latitude values
:para... |
Range of coordinates. (e.g. 2 latitude coordinates, and 0 longitude coordinates)
:param crd_range: Latitude or Longitude values
:param elev: Elevation value
:param crd_type: Coordinate type, lat or lon
:return dict:
def geometry_range(crd_range, elev, crd_type):
"""
Range of coordinates. (e.g. ... |
GeoJSON point. Latitude and Longitude only have one value each
:param list lat: Latitude values
:param list lon: Longitude values
:param float elev: Elevation value
:return dict:
def geometry_point(lat, lon, elev):
"""
GeoJSON point. Latitude and Longitude only have one value each
:param li... |
Take in lists of lat and lon coordinates, and determine what geometry to create
:param list lat: Latitude values
:param list lon: Longitude values
:param float elev: Elevation value
:return dict:
def compile_geometry(lat, lon, elev):
"""
Take in lists of lat and lon coordinates, and determine w... |
Compile top-level Geography dictionary.
:param d:
:return:
def compile_geo(d):
"""
Compile top-level Geography dictionary.
:param d:
:return:
"""
logger_excel.info("enter compile_geo")
d2 = OrderedDict()
# get max number of sites, or number of coordinate points given.
num_l... |
Find out how many locations are being parsed. Compare lengths of each
coordinate list and return the max
:param dict d: Geo metadata
:return int: Max number of locations
def _get_num_locations(d):
"""
Find out how many locations are being parsed. Compare lengths of each
coordinate list and retu... |
Parse one geo location
:param d:
:return:
def _parse_geo_location(d):
"""
Parse one geo location
:param d:
:return:
"""
d2 = OrderedDict()
filt = {}
d2['type'] = 'Feature'
# If the necessary keys are missing, put in placeholders so there's no KeyErrors.
for key in EXCEL_... |
Parse one geo location
:param d:
:return:
def _parse_geo_locations(d, idx):
"""
Parse one geo location
:param d:
:return:
"""
d2 = OrderedDict()
filt = {}
d2['type'] = 'Feature'
# If the necessary keys are missing, put in placeholders so there's no KeyErrors.
for key in ... |
Split the string of author names into the BibJSON format.
:param str cell: Data from author cell
:return: (list of dicts) Author names
def compile_authors(cell):
"""
Split the string of author names into the BibJSON format.
:param str cell: Data from author cell
:return: (list of dicts) Author ... |
Compiles temporary dictionaries for metadata. Adds a new entry to an existing dictionary.
:param dict d:
:param str key:
:param any value:
:return dict:
def compile_temp(d, key, value):
"""
Compiles temporary dictionaries for metadata. Adds a new entry to an existing dictionary.
:param dict... |
Compile funding entries. Iter both rows at the same time. Keep adding entries until both cells are empty.
:param obj workbook:
:param str sheet:
:param int row:
:param int col:
:return list of dict: l
def compile_fund(workbook, sheet, row, col):
"""
Compile funding entries. Iter both rows a... |
Check that the metadata variable names are the same as the data header variable names
:param list a1: Variable names
:param list a2: Variable names
:param str name: Sheet name
:return bool: Truth
def __compare_vars(a1, a2, name):
"""
Check that the metadata variable names are the same as the da... |
Get the filename based on the dataset name in the metadata
:param str filename: Filename.lpd
:return str: Filename
def __get_datasetname(d, filename):
"""
Get the filename based on the dataset name in the metadata
:param str filename: Filename.lpd
:return str: Filename
"""
try:
... |
Use the dataset name to build the filenames in the sheets metadata
:param list sheets: Sheet metadata
:param str n: Dataset Name
:return list: Sheet metadata
def __set_sheet_filenames(sheets, n):
"""
Use the dataset name to build the filenames in the sheets metadata
:param list sheets: Sheet me... |
Convert formal titles to camelcase json_ld text that matches our context file
Keep a growing list of all titles that are being used in the json_ld context
:param str title_in:
:return str:
def name_to_jsonld(title_in):
"""
Convert formal titles to camelcase json_ld text that matches our context fil... |
Match data type and return string
:param any cell:
:return str:
def instance_str(cell):
"""
Match data type and return string
:param any cell:
:return str:
"""
if isinstance(cell, str):
return 'str'
elif isinstance(cell, int):
return 'int'
elif isinstance(cell, f... |
Extract units from parenthesis in a string. i.e. "elevation (meters)"
:param str string_in:
:return str:
def extract_units(string_in):
"""
Extract units from parenthesis in a string. i.e. "elevation (meters)"
:param str string_in:
:return str:
"""
start = '('
stop = ')'
return s... |
Publication section is special. It's possible there's more than one publication.
:param obj workbook:
:param str sheet:
:param int row:
:param int col:
:param int pub_qty: Number of distinct publication sections in this file
:return list: Cell data for a specific row
def cells_rt_meta_pub(workb... |
Traverse all cells in a row. If you find new data in a cell, add it to the list.
:param obj workbook:
:param str sheet:
:param int row:
:param int col:
:return list: Cell data for a specific row
def cells_rt_meta(workbook, sheet, row, col):
"""
Traverse all cells in a row. If you find new d... |
Traverse all cells in a column moving downward. Primarily created for the metadata sheet, but may use elsewhere.
Check the cell title, and switch it to.
:param obj workbook:
:param str sheet:
:param int row:
:param int col:
:param dict final_dict:
:return: none
def cells_dn_meta(workbook, s... |
Count the number of chron variables
:param obj temp_sheet:
:return int: variable count
def count_chron_variables(temp_sheet):
"""
Count the number of chron variables
:param obj temp_sheet:
:return int: variable count
"""
total_count = 0
start_row = traverse_to_chron_var(temp_sheet)
... |
Capture all the vars in the chron sheet (for json-ld output)
:param obj temp_sheet:
:param int start_row:
:return: (list of dict) column data
def get_chron_var(temp_sheet, start_row):
"""
Capture all the vars in the chron sheet (for json-ld output)
:param obj temp_sheet:
:param int start_ro... |
Traverse down to the first row that has chron data
:param obj temp_sheet:
:return int: traverse_row
def traverse_to_chron_data(temp_sheet):
"""
Traverse down to the first row that has chron data
:param obj temp_sheet:
:return int: traverse_row
"""
traverse_row = traverse_to_chron_var(te... |
Traverse down to the row that has the first variable
:param obj temp_sheet:
:return int:
def traverse_to_chron_var(temp_sheet):
"""
Traverse down to the row that has the first variable
:param obj temp_sheet:
:return int:
"""
row = 0
while row < temp_sheet.nrows - 1:
if 'Para... |
Capture all data in for a specific chron data row (for csv output)
:param obj temp_sheet:
:param int row:
:param int total_vars:
:return list: data_row
def get_chron_data(temp_sheet, row, total_vars):
"""
Capture all data in for a specific chron data row (for csv output)
:param obj temp_she... |
Remove placeholders from coordinate lists and sort
:param list l: Lat or long list
:return list: Modified list
def _remove_geo_placeholders(l):
"""
Remove placeholders from coordinate lists and sort
:param list l: Lat or long list
:return list: Modified list
"""
vals = []
for i in l... |
Find jsonld file in the cwd (or within a 2 levels below cwd), and load it in.
:return dict: Jsonld data
def read_jsonld():
"""
Find jsonld file in the cwd (or within a 2 levels below cwd), and load it in.
:return dict: Jsonld data
"""
_d = {}
try:
# Find a jsonld file in cwd. If no... |
Import the JSON data from target file.
:param str filename: Target File
:return dict: JSON data
def read_json_from_file(filename):
"""
Import the JSON data from target file.
:param str filename: Target File
:return dict: JSON data
"""
logger_jsons.info("enter read_json_from_file")
d... |
Switch from index-by-number to index-by-name.
:param dict L: Metadata
:return dict L: Metadata
def idx_num_to_name(L):
"""
Switch from index-by-number to index-by-name.
:param dict L: Metadata
:return dict L: Metadata
"""
logger_jsons.info("enter idx_num_to_name")
try:
if... |
Import the section metadata and change it to index-by-name.
:param list sections: Metadata
:param str pc: paleo or chron
:return dict _sections: Metadata
def _import_data(sections, crumbs):
"""
Import the section metadata and change it to index-by-name.
:param list sections: Metadata
:par... |
Change the nested items of the paleoModel data. Overwrite the data in-place.
:param list models: Metadata
:param str crumbs: Crumbs
:return dict _models: Metadata
def _import_model(models, crumbs):
"""
Change the nested items of the paleoModel data. Overwrite the data in-place.
:param list mo... |
Import summary, ensemble, or distribution data.
:param list tables: Metadata
:return dict _tables: Metadata
def _idx_table_by_name(tables, crumbs):
"""
Import summary, ensemble, or distribution data.
:param list tables: Metadata
:return dict _tables: Metadata
"""
_tables = OrderedDict... |
Iter over columns list. Turn indexed-by-num list into an indexed-by-name dict. Keys are the variable names.
:param dict table: Metadata
:return dict _table: Metadata
def _idx_col_by_name(table):
"""
Iter over columns list. Turn indexed-by-num list into an indexed-by-name dict. Keys are the variable na... |
Get CSV values when mixed into json data. Pull out the CSV data and put it into a dictionary.
:param dict d: JSON with CSV values
:return dict: CSV values. (i.e. { CSVFilename1: { Column1: [Values], Column2: [Values] }, CSVFilename2: ... }
def get_csv_from_json(d):
"""
Get CSV values when mixed into js... |
Get csv from paleo and chron sections
:param dict d: Metadata
:param str pc: Paleo or chron
:return dict: running csv data
def _get_csv_from_section(d, pc, csv_data):
"""
Get csv from paleo and chron sections
:param dict d: Metadata
:param str pc: Paleo or chron
:return dict: running cs... |
Remove all CSV data 'values' entries from paleoData table in the JSON structure.
:param dict d: JSON data - old structure
:return dict: Metadata dictionary without CSV values
def remove_csv_from_json(d):
"""
Remove all CSV data 'values' entries from paleoData table in the JSON structure.
:param dic... |
Remove CSV from metadata in this section
:param dict d: Metadata
:param str pc: Paleo or chron
:return dict: Modified metadata
def _remove_csv_from_section(d, pc):
"""
Remove CSV from metadata in this section
:param dict d: Metadata
:param str pc: Paleo or chron
:return dict: Modified m... |
Write all JSON in python dictionary to a new json file.
:param dict json_data: JSON data
:param str filename: Target filename (defaults to 'metadata.jsonld')
:return None:
def write_json_to_file(json_data, filename="metadata"):
"""
Write all JSON in python dictionary to a new json file.
:param ... |
Switch from index-by-name to index-by-number.
:param dict L: Metadata
:return dict: Modified metadata
def idx_name_to_num(L):
"""
Switch from index-by-name to index-by-number.
:param dict L: Metadata
:return dict: Modified metadata
"""
logger_jsons.info("enter idx_name_to_num")
# P... |
Switch chron data to index-by-number
:param dict sections: Metadata
:return list _sections: Metadata
def _export_section(sections, pc):
"""
Switch chron data to index-by-number
:param dict sections: Metadata
:return list _sections: Metadata
"""
logger_jsons.info("enter export_data: {}".... |
Switch model tables to index-by-number
:param dict models: Metadata
:return dict _models: Metadata
def _export_model(models):
"""
Switch model tables to index-by-number
:param dict models: Metadata
:return dict _models: Metadata
"""
logger_jsons.info("enter export_model")
_models ... |
Switch tables to index-by-number
:param dict tables: Metadata
:return list _tables: Metadata
def _idx_table_by_num(tables):
"""
Switch tables to index-by-number
:param dict tables: Metadata
:return list _tables: Metadata
"""
logger_jsons.info("enter idx_table_by_num")
_tables = []... |
Index columns by number instead of by name. Use "number" key in column to maintain order
:param dict table: Metadata
:return list _table: Metadata
def _idx_col_by_num(table):
"""
Index columns by number instead of by name. Use "number" key in column to maintain order
:param dict table: Metadata
... |
Convert a given directory into a bag. You can pass in arbitrary
key/value pairs to put into the bag-info.txt metadata file as
the bag_info dictionary.
def make_bag(bag_dir, bag_info=None, processes=1, checksum=None):
"""
Convert a given directory into a bag. You can pass in arbitrary
key/value pair... |
Returns a dictionary of (algorithm, hexdigest) values for the provided
filename
def _calculate_file_hashes(full_path, f_hashers):
"""
Returns a dictionary of (algorithm, hexdigest) values for the provided
filename
"""
if not os.path.exists(full_path):
raise BagValidationError("%s does n... |
Parses a tag file, according to RFC 2822. This
includes line folding, permitting extra-long
field values.
See http://www.faqs.org/rfcs/rfc2822.html for
more information.
def _parse_tags(tag_file):
"""Parses a tag file, according to RFC 2822. This
includes line folding, permitt... |
returns (unwriteable files/folders)
def _can_bag(test_dir):
"""returns (unwriteable files/folders)
"""
unwriteable = []
for inode in os.listdir(test_dir):
if not os.access(os.path.join(test_dir, inode), os.W_OK):
unwriteable.append(os.path.join(os.path.abspath(test_dir), inode))
... |
returns ((unreadable_dirs), (unreadable_files))
def _can_read(test_dir):
"""
returns ((unreadable_dirs), (unreadable_files))
"""
unreadable_dirs = []
unreadable_files = []
for dirpath, dirnames, filenames in os.walk(test_dir):
for dn in dirnames:
if not os.access(os.path.joi... |
Compares the fetch entries with the files actually
in the payload, and returns a list of all the files
that still need to be fetched.
def compare_fetch_with_fs(self):
"""Compares the fetch entries with the files actually
in the payload, and returns a list of all the files
... |
save will persist any changes that have been made to the bag
metadata (self.info).
If you have modified the payload of the bag (added, modified,
removed files in the data directory) and want to regenerate manifests
set the manifests parameter to True. The default is False since you
... |
From v0.97 we need to validate any tagfiles listed
in the optional tagmanifest(s). As there is no mandatory
directory structure for additional tagfiles we can
only check for entries with missing files (not missing
entries for existing files).
def missing_optional_tagfiles(self):
... |
Checks the structure and contents are valid. If you supply
the parameter fast=True the Payload-Oxum (if present) will
be used to check that the payload files are present and
accounted for, instead of re-calculating fixities and
comparing them against the manifest. By default validate()
... |
Returns validation success or failure as boolean.
Optional fast parameter passed directly to validate().
def is_valid(self, fast=False):
"""Returns validation success or failure as boolean.
Optional fast parameter passed directly to validate().
"""
try:
self.validate... |
Verify that the actual file contents match the recorded hashes stored in the manifest files
def _validate_entries(self, processes):
"""
Verify that the actual file contents match the recorded hashes stored in the manifest files
"""
errors = list()
# First we'll make sure there'... |
Verify that bagit.txt conforms to specification
def _validate_bagittxt(self):
"""
Verify that bagit.txt conforms to specification
"""
bagit_file_path = os.path.join(self.path, "bagit.txt")
with open(bagit_file_path, 'r') as bagit_file:
first_line = bagit_file.readlin... |
Fix any numpy data types that didn't map back to python data types properly
:param dict c: Columns of data
:return dict c: Columns of data
def _fix_numeric_types(c):
"""
Fix any numpy data types that didn't map back to python data types properly
:param dict c: Columns of data
:return dict c: Co... |
Sift through table column data and find the "age" or "year" column. Return its "values" data.
:param dict columns: Column data
:return list age: Age values
def _get_age(columns):
"""
Sift through table column data and find the "age" or "year" column. Return its "values" data.
:param dict columns: C... |
Calculates the resolution (res)
Thanks Deborah!
def _get_resolution(age, values):
"""
Calculates the resolution (res)
Thanks Deborah!
"""
res = []
try:
# Get the nan index from the values and remove from age
# age2 = age[np.where(~np.isnan(values))[0]]
# res = np.dif... |
Use a list of values to calculate m/m/m/m. Resolution values or otherwise.
:param numpy array v: Values
:param bool calc: If false, we don't need calculations
:return dict: Results of calculation
def __get_inferred_data_res_2(v=None, calc=True):
"""
Use a list of values to calculate m/m/m/m. Resol... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.