repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
nickmckay/LiPD-utilities | Python/lipd/lpd_noaa.py | LPD_NOAA.__write_variables_2 | 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)
# Write one line for each column. One line has all metadata for one column.
for ent... | python | 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)
# Write one line for each column. One line has all metadata for one column.
for ent... | [
"def",
"__write_variables_2",
"(",
"self",
",",
"col",
")",
":",
"col",
"=",
"self",
".",
"__convert_keys_1",
"(",
"\"Variables\"",
",",
"col",
")",
"# Write one line for each column. One line has all metadata for one column.",
"for",
"entry",
"in",
"NOAA_KEYS_BY_SECTION"... | Use one column of data, to write one line of data in the variables section.
:return none: | [
"Use",
"one",
"column",
"of",
"data",
"to",
"write",
"one",
"line",
"of",
"data",
"in",
"the",
"variables",
"section",
".",
":",
"return",
"none",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/lpd_noaa.py#L1344-L1406 |
nickmckay/LiPD-utilities | Python/lipd/lpd_noaa.py | LPD_NOAA.__write_columns | 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 dictionary
:return none:
"""
logger_lpd_noaa.info("writing section: data, csv values from file")
# get filename for t... | python | 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 dictionary
:return none:
"""
logger_lpd_noaa.info("writing section: data, csv values from file")
# get filename for t... | [
"def",
"__write_columns",
"(",
"self",
",",
"pc",
",",
"table",
")",
":",
"logger_lpd_noaa",
".",
"info",
"(",
"\"writing section: data, csv values from file\"",
")",
"# get filename for this table's csv data",
"# filename = self.__get_filename(table)",
"# logger_lpd_noaa.info(\"... | Read numeric data from csv and write to the bottom section of the txt file.
:param dict table: Paleodata dictionary
:return none: | [
"Read",
"numeric",
"data",
"from",
"csv",
"and",
"write",
"to",
"the",
"bottom",
"section",
"of",
"the",
"txt",
"file",
".",
":",
"param",
"dict",
"table",
":",
"Paleodata",
"dictionary",
":",
"return",
"none",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/lpd_noaa.py#L1408-L1443 |
nickmckay/LiPD-utilities | Python/lipd/lpd_noaa.py | LPD_NOAA.__write_k_v | def __write_k_v(self, k, v, top=False, bot=False, multi=False, indent=False):
"""
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 em... | python | def __write_k_v(self, k, v, top=False, bot=False, multi=False, indent=False):
"""
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 em... | [
"def",
"__write_k_v",
"(",
"self",
",",
"k",
",",
"v",
",",
"top",
"=",
"False",
",",
"bot",
"=",
"False",
",",
"multi",
"=",
"False",
",",
"indent",
"=",
"False",
")",
":",
"if",
"top",
":",
"self",
".",
"noaa_txt",
"+=",
"\"\\n#\"",
"if",
"mult... | 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: | [
"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",
... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/lpd_noaa.py#L1499-L1524 |
nickmckay/LiPD-utilities | Python/lipd/lpd_noaa.py | LPD_NOAA.__write_divider | 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 += "#------------------\n"
if bot:
self.noaa_... | python | 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 += "#------------------\n"
if bot:
self.noaa_... | [
"def",
"__write_divider",
"(",
"self",
",",
"top",
"=",
"False",
",",
"bot",
"=",
"False",
",",
"nl",
"=",
"True",
")",
":",
"if",
"top",
":",
"self",
".",
"noaa_txt",
"+=",
"\"\\n#\"",
"if",
"nl",
":",
"self",
".",
"noaa_txt",
"+=",
"\"\\n\"",
"se... | Write a divider line
:return none: | [
"Write",
"a",
"divider",
"line",
":",
"return",
"none",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/lpd_noaa.py#L1534-L1546 |
nickmckay/LiPD-utilities | Python/lipd/lpd_noaa.py | LPD_NOAA.__write_data_col_header | 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 none:
"""
count = len(l)
if pc == "chron":
self.noaa_txt += "# "
for name in l:
... | python | 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 none:
"""
count = len(l)
if pc == "chron":
self.noaa_txt += "# "
for name in l:
... | [
"def",
"__write_data_col_header",
"(",
"self",
",",
"l",
",",
"pc",
")",
":",
"count",
"=",
"len",
"(",
"l",
")",
"if",
"pc",
"==",
"\"chron\"",
":",
"self",
".",
"noaa_txt",
"+=",
"\"# \"",
"for",
"name",
"in",
"l",
":",
"# last column - spacing not imp... | Write the variableNames that are the column header in the "Data" section
:param list l: variableNames
:return none: | [
"Write",
"the",
"variableNames",
"that",
"are",
"the",
"column",
"header",
"in",
"the",
"Data",
"section",
":",
"param",
"list",
"l",
":",
"variableNames",
":",
"return",
"none",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/lpd_noaa.py#L1548-L1566 |
nickmckay/LiPD-utilities | Python/lipd/lpd_noaa.py | LPD_NOAA.__write_data_col_vals | 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
:param list ll: List of lists, column data
:return:
"""
# all columns should have the same amount of values. grab that number
try... | python | 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
:param list ll: List of lists, column data
:return:
"""
# all columns should have the same amount of values. grab that number
try... | [
"def",
"__write_data_col_vals",
"(",
"self",
",",
"ll",
",",
"pc",
")",
":",
"# all columns should have the same amount of values. grab that number",
"try",
":",
"_items_in_cols",
"=",
"len",
"(",
"ll",
"[",
"0",
"]",
"[",
"\"values\"",
"]",
")",
"for",
"idx",
"... | 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: | [
"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",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/lpd_noaa.py#L1568-L1591 |
useblocks/sphinxcontrib-needs | sphinxcontrib/needs/functions/common.py | copy | def copy(app, need, needs, option, need_id=None):
"""
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... | python | def copy(app, need, needs, option, need_id=None):
"""
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... | [
"def",
"copy",
"(",
"app",
",",
"need",
",",
"needs",
",",
"option",
",",
"need_id",
"=",
"None",
")",
":",
"if",
"need_id",
"is",
"not",
"None",
":",
"need",
"=",
"needs",
"[",
"need_id",
"]",
"return",
"need",
"[",
"option",
"]"
] | 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")]]
... | [
"Copies",
"the",
"value",
"of",
"one",
"need",
"option",
"to",
"another"
] | train | https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/functions/common.py#L33-L92 |
useblocks/sphinxcontrib-needs | sphinxcontrib/needs/functions/common.py | check_linked_values | def check_linked_values(app, need, needs, result, search_option, search_value, filter_string=None, one_hit=False):
"""
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, onl... | python | def check_linked_values(app, need, needs, result, search_option, search_value, filter_string=None, one_hit=False):
"""
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, onl... | [
"def",
"check_linked_values",
"(",
"app",
",",
"need",
",",
"needs",
",",
"result",
",",
"search_option",
",",
"search_value",
",",
"filter_string",
"=",
"None",
",",
"one_hit",
"=",
"False",
")",
":",
"links",
"=",
"need",
"[",
"\"links\"",
"]",
"if",
"... | 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**
.... | [
"Returns",
"a",
"specific",
"value",
"if",
"for",
"all",
"linked",
"needs",
"a",
"given",
"option",
"has",
"a",
"given",
"value",
"."
] | train | https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/functions/common.py#L95-L244 |
useblocks/sphinxcontrib-needs | sphinxcontrib/needs/functions/common.py | calc_sum | def calc_sum(app, need, needs, option, filter=None, links_only=False):
"""
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
... | python | def calc_sum(app, need, needs, option, filter=None, links_only=False):
"""
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
... | [
"def",
"calc_sum",
"(",
"app",
",",
"need",
",",
"needs",
",",
"option",
",",
"filter",
"=",
"None",
",",
"links_only",
"=",
"False",
")",
":",
"if",
"not",
"links_only",
":",
"check_needs",
"=",
"needs",
".",
"values",
"(",
")",
"else",
":",
"check_... | 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... | [
"Sums",
"the",
"values",
"of",
"a",
"given",
"option",
"in",
"filtered",
"needs",
"up",
"to",
"single",
"number",
"."
] | train | https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/functions/common.py#L247-L350 |
nickmckay/LiPD-utilities | Python/lipd/noaa.py | noaa_prompt | 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: ")
logger_noaa.info("chose option: {}".format(mode))
ret... | python | 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: ")
logger_noaa.info("chose option: {}".format(mode))
ret... | [
"def",
"noaa_prompt",
"(",
")",
":",
"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: \"",
")",
"logger_noaa",
"... | Convert between NOAA and LiPD file formats.
:return: | [
"Convert",
"between",
"NOAA",
"and",
"LiPD",
"file",
"formats",
".",
":",
"return",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa.py#L16-L27 |
nickmckay/LiPD-utilities | Python/lipd/noaa.py | noaa_prompt_1 | def noaa_prompt_1():
"""
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
"""
print("Enter the project information below. We'll use this to create the WDS URL")
pr... | python | def noaa_prompt_1():
"""
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
"""
print("Enter the project information below. We'll use this to create the WDS URL")
pr... | [
"def",
"noaa_prompt_1",
"(",
")",
":",
"print",
"(",
"\"Enter the project information below. We'll use this to create the WDS URL\"",
")",
"print",
"(",
"\"What is the project name?\"",
")",
"_project",
"=",
"input",
"(",
"\">\"",
")",
"print",
"(",
"\"What is the project v... | 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 | [
"For",
"converting",
"LiPD",
"files",
"to",
"NOAA",
"we",
"need",
"a",
"couple",
"more",
"pieces",
"of",
"information",
"to",
"create",
"the",
"WDS",
"links"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa.py#L30-L42 |
nickmckay/LiPD-utilities | Python/lipd/noaa.py | noaa_to_lpd | 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 correctly
logger_noaa.info("Found {} NOAA txt file(s)".format(str(len(files[".txt"]))))
... | python | 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 correctly
logger_noaa.info("Found {} NOAA txt file(s)".format(str(len(files[".txt"]))))
... | [
"def",
"noaa_to_lpd",
"(",
"files",
")",
":",
"logger_noaa",
".",
"info",
"(",
"\"enter process_noaa\"",
")",
"# only continue if the user selected a mode correctly",
"logger_noaa",
".",
"info",
"(",
"\"Found {} NOAA txt file(s)\"",
".",
"format",
"(",
"str",
"(",
"len"... | Convert NOAA format to LiPD format
:param dict files: Files metadata
:return None: | [
"Convert",
"NOAA",
"format",
"to",
"LiPD",
"format",
":",
"param",
"dict",
"files",
":",
"Files",
"metadata",
":",
"return",
"None",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa.py#L45-L81 |
nickmckay/LiPD-utilities | Python/lipd/noaa.py | lpd_to_noaa | 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
try:
dsn = get_dsn(D)
# Remove all the characters that are not allowed here. ... | python | 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
try:
dsn = get_dsn(D)
# Remove all the characters that are not allowed here. ... | [
"def",
"lpd_to_noaa",
"(",
"D",
",",
"wds_url",
",",
"lpd_url",
",",
"version",
",",
"path",
"=",
"\"\"",
")",
":",
"logger_noaa",
".",
"info",
"(",
"\"enter process_lpd\"",
")",
"d",
"=",
"D",
"try",
":",
"dsn",
"=",
"get_dsn",
"(",
"D",
")",
"# Rem... | Convert a LiPD format to NOAA format
:param dict D: Metadata
:return dict D: Metadata | [
"Convert",
"a",
"LiPD",
"format",
"to",
"NOAA",
"format"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa.py#L84-L114 |
nickmckay/LiPD-utilities | Python/lipd/noaa.py | __write_noaas | 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:
"""
for filename, text in dat.items():
try:
with open(os.path.join(path, filename), "w+") as f:
f.... | python | 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:
"""
for filename, text in dat.items():
try:
with open(os.path.join(path, filename), "w+") as f:
f.... | [
"def",
"__write_noaas",
"(",
"dat",
",",
"path",
")",
":",
"for",
"filename",
",",
"text",
"in",
"dat",
".",
"items",
"(",
")",
":",
"try",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"filename",
")",
",",
"\"w+\""... | Use the filename - text data pairs to write the data as NOAA text files
:param dict dat: NOAA data to be written
:return none: | [
"Use",
"the",
"filename",
"-",
"text",
"data",
"pairs",
"to",
"write",
"the",
"data",
"as",
"NOAA",
"text",
"files"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa.py#L128-L141 |
mfussenegger/cr8 | cr8/java_magic.py | _parse_java_version | def _parse_java_version(line: str) -> tuple:
""" 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)
"""
m = VERSION_RE.search(line)
version_str = m and m.group(0).replace('"', '') or '0.0.0'
if '_' i... | python | def _parse_java_version(line: str) -> tuple:
""" 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)
"""
m = VERSION_RE.search(line)
version_str = m and m.group(0).replace('"', '') or '0.0.0'
if '_' i... | [
"def",
"_parse_java_version",
"(",
"line",
":",
"str",
")",
"->",
"tuple",
":",
"m",
"=",
"VERSION_RE",
".",
"search",
"(",
"line",
")",
"version_str",
"=",
"m",
"and",
"m",
".",
"group",
"(",
"0",
")",
".",
"replace",
"(",
"'\"'",
",",
"''",
")",
... | 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) | [
"Return",
"the",
"version",
"number",
"found",
"in",
"the",
"first",
"line",
"of",
"java",
"-",
"version"
] | train | https://github.com/mfussenegger/cr8/blob/a37d6049f1f9fee2d0556efae2b7b7f8761bffe8/cr8/java_magic.py#L20-L33 |
mfussenegger/cr8 | cr8/java_magic.py | find_java_home | 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.environ.get('JAVA_HOME', '')
if cratedb_version < MIN_VERSION_... | python | 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.environ.get('JAVA_HOME', '')
if cratedb_version < MIN_VERSION_... | [
"def",
"find_java_home",
"(",
"cratedb_version",
":",
"tuple",
")",
"->",
"str",
":",
"if",
"MIN_VERSION_FOR_JVM11",
"<=",
"cratedb_version",
"<",
"(",
"4",
",",
"0",
")",
":",
"# Supports 8 to 11+, use whatever is set",
"return",
"os",
".",
"environ",
".",
"get... | Return a path to a JAVA_HOME suites for the given CrateDB version | [
"Return",
"a",
"path",
"to",
"a",
"JAVA_HOME",
"suites",
"for",
"the",
"given",
"CrateDB",
"version"
] | train | https://github.com/mfussenegger/cr8/blob/a37d6049f1f9fee2d0556efae2b7b7f8761bffe8/cr8/java_magic.py#L57-L65 |
nickmckay/LiPD-utilities | Python/lipd/zips.py | zipper | def zipper(root_dir="", name="", path_name_ext=""):
"""
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
"""
logger_zips.info("re_zip: name: {}, dir_tmp: {}".f... | python | def zipper(root_dir="", name="", path_name_ext=""):
"""
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
"""
logger_zips.info("re_zip: name: {}, dir_tmp: {}".f... | [
"def",
"zipper",
"(",
"root_dir",
"=",
"\"\"",
",",
"name",
"=",
"\"\"",
",",
"path_name_ext",
"=",
"\"\"",
")",
":",
"logger_zips",
".",
"info",
"(",
"\"re_zip: name: {}, dir_tmp: {}\"",
".",
"format",
"(",
"path_name_ext",
",",
"root_dir",
")",
")",
"# cre... | 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 | [
"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_ex... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/zips.py#L10-L22 |
nickmckay/LiPD-utilities | Python/lipd/zips.py | unzipper | def unzipper(filename, dir_tmp):
"""
Unzip .lpd file contents to tmp directory.
:param str filename: filename.lpd
:param str dir_tmp: Tmp folder to extract contents to
:return None:
"""
logger_zips.info("enter unzip")
# Unzip contents to the tmp directory
try:
with zipfile.Zi... | python | def unzipper(filename, dir_tmp):
"""
Unzip .lpd file contents to tmp directory.
:param str filename: filename.lpd
:param str dir_tmp: Tmp folder to extract contents to
:return None:
"""
logger_zips.info("enter unzip")
# Unzip contents to the tmp directory
try:
with zipfile.Zi... | [
"def",
"unzipper",
"(",
"filename",
",",
"dir_tmp",
")",
":",
"logger_zips",
".",
"info",
"(",
"\"enter unzip\"",
")",
"# Unzip contents to the tmp directory",
"try",
":",
"with",
"zipfile",
".",
"ZipFile",
"(",
"filename",
")",
"as",
"f",
":",
"f",
".",
"ex... | Unzip .lpd file contents to tmp directory.
:param str filename: filename.lpd
:param str dir_tmp: Tmp folder to extract contents to
:return None: | [
"Unzip",
".",
"lpd",
"file",
"contents",
"to",
"tmp",
"directory",
".",
":",
"param",
"str",
"filename",
":",
"filename",
".",
"lpd",
":",
"param",
"str",
"dir_tmp",
":",
"Tmp",
"folder",
"to",
"extract",
"contents",
"to",
":",
"return",
"None",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/zips.py#L25-L41 |
mfussenegger/cr8 | cr8/metrics.py | percentile | def percentile(sorted_values, p):
"""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... | python | def percentile(sorted_values, p):
"""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... | [
"def",
"percentile",
"(",
"sorted_values",
",",
"p",
")",
":",
"size",
"=",
"len",
"(",
"sorted_values",
")",
"idx",
"=",
"(",
"p",
"/",
"100.0",
")",
"*",
"size",
"-",
"0.5",
"if",
"idx",
"<",
"0",
"or",
"idx",
">",
"size",
":",
"raise",
"ValueE... | 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 | [
"Calculate",
"the",
"percentile",
"using",
"the",
"nearest",
"rank",
"method",
"."
] | train | https://github.com/mfussenegger/cr8/blob/a37d6049f1f9fee2d0556efae2b7b7f8761bffe8/cr8/metrics.py#L10-L28 |
mfussenegger/cr8 | cr8/metrics.py | get_sampler | def get_sampler(sample_mode: str):
"""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)
... | python | def get_sampler(sample_mode: str):
"""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",
")",
":",
"if",
"sample_mode",
"==",
"'all'",
":",
"return",
"All",
"mode",
"=",
"sample_mode",
".",
"split",
"(",
"':'",
")",
"if",
"mode",
"[",
"0",
"]",
"==",
"'reservoir'",
":",
"if",
"len",
"... | 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) | [
"Return",
"a",
"sampler",
"constructor"
] | train | https://github.com/mfussenegger/cr8/blob/a37d6049f1f9fee2d0556efae2b7b7f8761bffe8/cr8/metrics.py#L67-L87 |
sijis/sumologic-python | src/sumologic/search.py | Search.query | def query(self, criteria, **opts):
""" 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 ... | python | def query(self, criteria, **opts):
""" 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 ... | [
"def",
"query",
"(",
"self",
",",
"criteria",
",",
"*",
"*",
"opts",
")",
":",
"time_now",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
".",
"replace",
"(",
"second",
"=",
"0",
",",
"microsecond",
"=",
"0",
")",
"right_now",
"=",
"time_n... | 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... | [
"Returns",
"a",
"dict",
"of",
"the",
"query",
"including",
"the",
"results",
":",
"param",
"critera",
":",
"string",
"of",
"search",
"criteria",
":",
"param",
"**",
"opts",
":",
":",
"formats",
":",
"json",
"/",
"xml",
"(",
"default",
":",
"json",
")",... | train | https://github.com/sijis/sumologic-python/blob/b50200907837f0d452d14ead5e647b8e24e2e9e5/src/sumologic/search.py#L28-L69 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | excel_main | 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
"""
os.chdir(file["dir"])
name_ext = file["filename_ext"]
# Filename without extension
name = file["filename_no_ext"]
... | python | 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
"""
os.chdir(file["dir"])
name_ext = file["filename_ext"]
# Filename without extension
name = file["filename_no_ext"]
... | [
"def",
"excel_main",
"(",
"file",
")",
":",
"os",
".",
"chdir",
"(",
"file",
"[",
"\"dir\"",
"]",
")",
"name_ext",
"=",
"file",
"[",
"\"filename_ext\"",
"]",
"# Filename without extension",
"name",
"=",
"file",
"[",
"\"filename_no_ext\"",
"]",
"# remove foreig... | Parse data from Excel spreadsheets into LiPD files.
:param dict file: File metadata (source, name, etc)
:return str dsn: Dataset name | [
"Parse",
"data",
"from",
"Excel",
"spreadsheets",
"into",
"LiPD",
"files",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L26-L162 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | _get_sheet_metadata | def _get_sheet_metadata(workbook, 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 ... | python | def _get_sheet_metadata(workbook, 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 ... | [
"def",
"_get_sheet_metadata",
"(",
"workbook",
",",
"name",
")",
":",
"ct_paleo",
"=",
"1",
"ct_chron",
"=",
"1",
"metadata_str",
"=",
"\"\"",
"sheets",
"=",
"[",
"]",
"skip_sheets",
"=",
"[",
"\"example\"",
",",
"\"sample\"",
",",
"\"lists\"",
",",
"\"gui... | 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... | [
"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",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L167-L253 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | _sheet_meta_from_prompts | def _sheet_meta_from_prompts(sheets, old_name, name, ct_paleo, ct_chron):
"""
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 o... | python | def _sheet_meta_from_prompts(sheets, old_name, name, ct_paleo, ct_chron):
"""
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 o... | [
"def",
"_sheet_meta_from_prompts",
"(",
"sheets",
",",
"old_name",
",",
"name",
",",
"ct_paleo",
",",
"ct_chron",
")",
":",
"cont",
"=",
"True",
"# Loop until valid sheet name is built, or user gives up",
"while",
"cont",
":",
"try",
":",
"pc",
"=",
"input",
"(",
... | 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... | [
"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... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L256-L312 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | _sheet_meta_from_regex | def _sheet_meta_from_regex(m, sheets, old_name, name, ct_paleo, ct_chron):
"""
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
... | python | def _sheet_meta_from_regex(m, sheets, old_name, name, ct_paleo, ct_chron):
"""
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
... | [
"def",
"_sheet_meta_from_regex",
"(",
"m",
",",
"sheets",
",",
"old_name",
",",
"name",
",",
"ct_paleo",
",",
"ct_chron",
")",
":",
"try",
":",
"idx_model",
"=",
"None",
"idx_table",
"=",
"None",
"pc",
"=",
"m",
".",
"group",
"(",
"1",
")",
"# Get the ... | 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... | [
"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... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L315-L374 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | _place_tables_section | def _place_tables_section(skeleton_section, sheet, keys_section):
"""
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
... | python | def _place_tables_section(skeleton_section, sheet, keys_section):
"""
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
... | [
"def",
"_place_tables_section",
"(",
"skeleton_section",
",",
"sheet",
",",
"keys_section",
")",
":",
"logger_excel",
".",
"info",
"(",
"\"enter place_tables_section\"",
")",
"try",
":",
"logger_excel",
".",
"info",
"(",
"\"excel: place_tables_section: placing table: {}\"... | 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 | [
"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",
":",
... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L377-L426 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | _place_tables_main | def _place_tables_main(sheets, skeleton_paleo, skeleton_chron):
"""
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 ... | python | def _place_tables_main(sheets, skeleton_paleo, skeleton_chron):
"""
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 ... | [
"def",
"_place_tables_main",
"(",
"sheets",
",",
"skeleton_paleo",
",",
"skeleton_chron",
")",
":",
"logger_excel",
".",
"info",
"(",
"\"enter place_tables_main\"",
")",
"for",
"sheet",
"in",
"sheets",
":",
"pc",
"=",
"sheet",
"[",
"\"paleo_chron\"",
"]",
"if",
... | 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 ... | [
"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",
... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L429-L448 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | _get_table_counts | def _get_table_counts(sheet, num_section):
"""
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 ... | python | def _get_table_counts(sheet, num_section):
"""
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 ... | [
"def",
"_get_table_counts",
"(",
"sheet",
",",
"num_section",
")",
":",
"tt",
"=",
"sheet",
"[",
"\"table_type\"",
"]",
"idx_pc",
"=",
"sheet",
"[",
"\"idx_pc\"",
"]",
"idx_table",
"=",
"sheet",
"[",
"\"idx_table\"",
"]",
"idx_model",
"=",
"sheet",
"[",
"\... | 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... | [
"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"... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L451-L512 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | _create_skeleton_3 | def _create_skeleton_3(pc, l, num_section):
"""
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... | python | def _create_skeleton_3(pc, l, num_section):
"""
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... | [
"def",
"_create_skeleton_3",
"(",
"pc",
",",
"l",
",",
"num_section",
")",
":",
"logger_excel",
".",
"info",
"(",
"\"enter create_skeleton_inner_2\"",
")",
"# Table Template: Model",
"template_model",
"=",
"{",
"\"summaryTable\"",
":",
"{",
"}",
",",
"\"ensembleTabl... | 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: | [
"Bottom",
"level",
":",
"{",
"measurement",
":",
"[]",
"model",
":",
"[",
"{",
"summary",
"distributions",
"ensemble",
"}",
"]",
"}",
"Fill",
"in",
"measurement",
"and",
"model",
"tables",
"with",
"N",
"number",
"of",
"EMPTY",
"meas",
"summary",
"ensemble"... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L515-L558 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | _create_skeleton_2 | def _create_skeleton_2(l, pc, num_section, template):
"""
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 ... | python | def _create_skeleton_2(l, pc, num_section, template):
"""
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 ... | [
"def",
"_create_skeleton_2",
"(",
"l",
",",
"pc",
",",
"num_section",
",",
"template",
")",
":",
"logger_excel",
".",
"info",
"(",
"\"enter create_skeleton_inner_1\"",
")",
"try",
":",
"# Create N number of paleoData/chronData tables.",
"l",
"=",
"[",
"copy",
".",
... | 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... | [
"Mid",
"level",
":",
"{",
"measurement",
"model",
"}",
"Fill",
"in",
"paleoData",
"tables",
"with",
"N",
"number",
"of",
"EMPTY",
"measurement",
"and",
"models",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L561-L580 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | _create_skeleton_1 | def _create_skeleton_1(sheets):
"""
Top level: {"chronData", "paleoData"}
Fill in paleoData/chronData tables with N number of EMPTY measurement and models.
:return list: Blank list of N indices
"""
logger_excel.info("enter create_skeleton_main")
# Table template: paleoData
template_pal... | python | def _create_skeleton_1(sheets):
"""
Top level: {"chronData", "paleoData"}
Fill in paleoData/chronData tables with N number of EMPTY measurement and models.
:return list: Blank list of N indices
"""
logger_excel.info("enter create_skeleton_main")
# Table template: paleoData
template_pal... | [
"def",
"_create_skeleton_1",
"(",
"sheets",
")",
":",
"logger_excel",
".",
"info",
"(",
"\"enter create_skeleton_main\"",
")",
"# Table template: paleoData",
"template_paleo",
"=",
"{",
"\"paleoMeasurementTable\"",
":",
"[",
"]",
",",
"\"paleoModel\"",
":",
"[",
"]",
... | Top level: {"chronData", "paleoData"}
Fill in paleoData/chronData tables with N number of EMPTY measurement and models.
:return list: Blank list of N indices | [
"Top",
"level",
":",
"{",
"chronData",
"paleoData",
"}",
"Fill",
"in",
"paleoData",
"/",
"chronData",
"tables",
"with",
"N",
"number",
"of",
"EMPTY",
"measurement",
"and",
"models",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L583-L617 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | _parse_sheet | def _parse_sheet(workbook, sheet):
"""
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
... | python | def _parse_sheet(workbook, sheet):
"""
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",
")",
":",
"logger_excel",
".",
"info",
"(",
"\"enter parse_sheet: {}\"",
".",
"format",
"(",
"sheet",
"[",
"\"old_name\"",
"]",
")",
")",
"# Markers to track where we are on the sheet",
"ensemble_on",
"=",
"False... | 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 | [
"The",
"universal",
"spreadsheet",
"parser",
".",
"Parse",
"chron",
"or",
"paleo",
"tables",
"of",
"type",
"ensemble",
"/",
"model",
"/",
"summary",
".",
":",
"param",
"str",
"name",
":",
"Filename",
":",
"param",
"obj",
"workbook",
":",
"Excel",
"Workbook... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L623-L841 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | _parse_sheet_data_row | def _parse_sheet_data_row(temp_sheet, num_row, col_total, table_data, filename, mv):
"""
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... | python | def _parse_sheet_data_row(temp_sheet, num_row, col_total, table_data, filename, mv):
"""
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... | [
"def",
"_parse_sheet_data_row",
"(",
"temp_sheet",
",",
"num_row",
",",
"col_total",
",",
"table_data",
",",
"filename",
",",
"mv",
")",
":",
"# Get row of data",
"row",
"=",
"temp_sheet",
".",
"row",
"(",
"num_row",
")",
"# In case our row holds more cells than 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 ... | [
"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_... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L844-L868 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | _replace_mvs | 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:
if v.value.lower() in EMPTY or v.value.lower() == mv:
row[idx] = "nan"
el... | python | 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:
if v.value.lower() in EMPTY or v.value.lower() == mv:
row[idx] = "nan"
el... | [
"def",
"_replace_mvs",
"(",
"row",
",",
"mv",
")",
":",
"for",
"idx",
",",
"v",
"in",
"enumerate",
"(",
"row",
")",
":",
"try",
":",
"if",
"v",
".",
"value",
".",
"lower",
"(",
")",
"in",
"EMPTY",
"or",
"v",
".",
"value",
".",
"lower",
"(",
"... | Replace Missing Values in the data rows where applicable
:param list row: Row
:return list: Modified row | [
"Replace",
"Missing",
"Values",
"in",
"the",
"data",
"rows",
"where",
"applicable",
":",
"param",
"list",
"row",
":",
"Row",
":",
"return",
"list",
":",
"Modified",
"row"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L871-L889 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | _get_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()
# Simple case: Nothing fancy here, just map to the LiPD key counterpart.... | python | 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()
# Simple case: Nothing fancy here, just map to the LiPD key counterpart.... | [
"def",
"_get_header_keys",
"(",
"row",
")",
":",
"# Swap out NOAA keys for LiPD keys",
"for",
"idx",
",",
"key",
"in",
"enumerate",
"(",
"row",
")",
":",
"key_low",
"=",
"key",
".",
"value",
".",
"lower",
"(",
")",
"# Simple case: Nothing fancy here, just map to t... | Get the variable header keys from this special row
:return list: Header keys | [
"Get",
"the",
"variable",
"header",
"keys",
"from",
"this",
"special",
"row",
":",
"return",
"list",
":",
"Header",
"keys"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L892-L918 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | _rm_units_from_var_name_single | def _rm_units_from_var_name_single(var):
"""
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 pro... | python | def _rm_units_from_var_name_single(var):
"""
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 pro... | [
"def",
"_rm_units_from_var_name_single",
"(",
"var",
")",
":",
"# Use the regex to match the cell",
"m",
"=",
"re",
".",
"match",
"(",
"re_var_w_units",
",",
"var",
")",
"# Should always get a match, but be careful anyways.",
"if",
"m",
":",
"# m.group(1): variableName",
... | 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... | [
"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... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L921-L943 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | _rm_units_from_var_names_multi | 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 row: Variable names
:return list: Variable names
"""
l2 = []
# Check each var in the row
for idx, var in enumerate(row):
l2.append(_... | python | 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 row: Variable names
:return list: Variable names
"""
l2 = []
# Check each var in the row
for idx, var in enumerate(row):
l2.append(_... | [
"def",
"_rm_units_from_var_names_multi",
"(",
"row",
")",
":",
"l2",
"=",
"[",
"]",
"# Check each var in the row",
"for",
"idx",
",",
"var",
"in",
"enumerate",
"(",
"row",
")",
":",
"l2",
".",
"append",
"(",
"_rm_units_from_var_name_single",
"(",
"row",
"[",
... | 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 | [
"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"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L946-L956 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | _compile_interpretation | def _compile_interpretation(data):
"""
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)
"""
# KEY FORMAT : ... | python | def _compile_interpretation(data):
"""
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)
"""
# KEY FORMAT : ... | [
"def",
"_compile_interpretation",
"(",
"data",
")",
":",
"# KEY FORMAT : \"interpretation1_somekey\"",
"_count",
"=",
"0",
"# Determine how many entries we are going to need, by checking the interpretation index in the string",
"for",
"_key",
"in",
"data",
".",
"keys",
"(",
")",
... | 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) | [
"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",
":",
... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L959-L999 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | _compile_column_metadata | def _compile_column_metadata(row, keys, number):
"""
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
"""
# Store the variable keys by index in a dictionary
_column = {}
_inte... | python | def _compile_column_metadata(row, keys, number):
"""
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
"""
# Store the variable keys by index in a dictionary
_column = {}
_inte... | [
"def",
"_compile_column_metadata",
"(",
"row",
",",
"keys",
",",
"number",
")",
":",
"# Store the variable keys by index in a dictionary",
"_column",
"=",
"{",
"}",
"_interpretation",
"=",
"{",
"}",
"_calibration",
"=",
"{",
"}",
"_physical",
"=",
"{",
"}",
"# U... | 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 | [
"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"... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1002-L1080 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | _rm_cells_reverse | 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 from the spreadsheet
:return list: Modified row
"""
rm = []
# Iter the list in reverse, and get rid of empty and template cells
for idx, key in rever... | python | 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 from the spreadsheet
:return list: Modified row
"""
rm = []
# Iter the list in reverse, and get rid of empty and template cells
for idx, key in rever... | [
"def",
"_rm_cells_reverse",
"(",
"l",
")",
":",
"rm",
"=",
"[",
"]",
"# Iter the list in reverse, and get rid of empty and template cells",
"for",
"idx",
",",
"key",
"in",
"reversed",
"(",
"list",
"(",
"enumerate",
"(",
"l",
")",
")",
")",
":",
"if",
"key",
... | 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 | [
"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",
":",
"Modif... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1083-L1101 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | _write_data_csv | 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 is stored
for file in csv_data:
for filename, data in file.items():
#... | python | 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 is stored
for file in csv_data:
for filename, data in file.items():
#... | [
"def",
"_write_data_csv",
"(",
"csv_data",
")",
":",
"logger_excel",
".",
"info",
"(",
"\"enter write_data_csv\"",
")",
"# Loop for each file and data that is stored",
"for",
"file",
"in",
"csv_data",
":",
"for",
"filename",
",",
"data",
"in",
"file",
".",
"items",
... | CSV data has been parsed by this point, so take it and write it file by file.
:return: | [
"CSV",
"data",
"has",
"been",
"parsed",
"by",
"this",
"point",
"so",
"take",
"it",
"and",
"write",
"it",
"file",
"by",
"file",
".",
":",
"return",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1107-L1127 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | geometry_linestring | def geometry_linestring(lat, lon, elev):
"""
GeoJSON Linestring. Latitude and Longitude have 2 values each.
:param list lat: Latitude values
:param list lon: Longitude values
:return dict:
"""
logger_excel.info("enter geometry_linestring")
d = OrderedDict()
coordinates = []
temp... | python | def geometry_linestring(lat, lon, elev):
"""
GeoJSON Linestring. Latitude and Longitude have 2 values each.
:param list lat: Latitude values
:param list lon: Longitude values
:return dict:
"""
logger_excel.info("enter geometry_linestring")
d = OrderedDict()
coordinates = []
temp... | [
"def",
"geometry_linestring",
"(",
"lat",
",",
"lon",
",",
"elev",
")",
":",
"logger_excel",
".",
"info",
"(",
"\"enter geometry_linestring\"",
")",
"d",
"=",
"OrderedDict",
"(",
")",
"coordinates",
"=",
"[",
"]",
"temp",
"=",
"[",
"\"\"",
",",
"\"\"",
"... | GeoJSON Linestring. Latitude and Longitude have 2 values each.
:param list lat: Latitude values
:param list lon: Longitude values
:return dict: | [
"GeoJSON",
"Linestring",
".",
"Latitude",
"and",
"Longitude",
"have",
"2",
"values",
"each",
".",
":",
"param",
"list",
"lat",
":",
"Latitude",
"values",
":",
"param",
"list",
"lon",
":",
"Longitude",
"values",
":",
"return",
"dict",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1132-L1166 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | geometry_range | def geometry_range(crd_range, elev, crd_type):
"""
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:
"""
d = OrderedDict(... | python | def geometry_range(crd_range, elev, crd_type):
"""
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:
"""
d = OrderedDict(... | [
"def",
"geometry_range",
"(",
"crd_range",
",",
"elev",
",",
"crd_type",
")",
":",
"d",
"=",
"OrderedDict",
"(",
")",
"coordinates",
"=",
"[",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"crd_range",
")",
")",
"]",
"# latitude",
"if",
"crd_... | 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: | [
"Range",
"of",
"coordinates",
".",
"(",
"e",
".",
"g",
".",
"2",
"latitude",
"coordinates",
"and",
"0",
"longitude",
"coordinates",
")",
":",
"param",
"crd_range",
":",
"Latitude",
"or",
"Longitude",
"values",
":",
"param",
"elev",
":",
"Elevation",
"value... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1169-L1198 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | geometry_point | def geometry_point(lat, lon, elev):
"""
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:
"""
logger_excel.info("enter geometry_point")
coordinates = []
... | python | def geometry_point(lat, lon, elev):
"""
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:
"""
logger_excel.info("enter geometry_point")
coordinates = []
... | [
"def",
"geometry_point",
"(",
"lat",
",",
"lon",
",",
"elev",
")",
":",
"logger_excel",
".",
"info",
"(",
"\"enter geometry_point\"",
")",
"coordinates",
"=",
"[",
"]",
"point_dict",
"=",
"OrderedDict",
"(",
")",
"for",
"idx",
",",
"val",
"in",
"enumerate"... | 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: | [
"GeoJSON",
"point",
".",
"Latitude",
"and",
"Longitude",
"only",
"have",
"one",
"value",
"each",
":",
"param",
"list",
"lat",
":",
"Latitude",
"values",
":",
"param",
"list",
"lon",
":",
"Longitude",
"values",
":",
"param",
"float",
"elev",
":",
"Elevation... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1201-L1224 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | compile_geometry | def compile_geometry(lat, lon, elev):
"""
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:
"""
logger_excel.info("enter compile_geometry")
... | python | def compile_geometry(lat, lon, elev):
"""
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:
"""
logger_excel.info("enter compile_geometry")
... | [
"def",
"compile_geometry",
"(",
"lat",
",",
"lon",
",",
"elev",
")",
":",
"logger_excel",
".",
"info",
"(",
"\"enter compile_geometry\"",
")",
"lat",
"=",
"_remove_geo_placeholders",
"(",
"lat",
")",
"lon",
"=",
"_remove_geo_placeholders",
"(",
"lon",
")",
"# ... | 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: | [
"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",... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1227-L1269 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | compile_geo | 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_loc = _get_num_locations(d)
# if there's one more than one locat... | python | 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_loc = _get_num_locations(d)
# if there's one more than one locat... | [
"def",
"compile_geo",
"(",
"d",
")",
":",
"logger_excel",
".",
"info",
"(",
"\"enter compile_geo\"",
")",
"d2",
"=",
"OrderedDict",
"(",
")",
"# get max number of sites, or number of coordinate points given.",
"num_loc",
"=",
"_get_num_locations",
"(",
"d",
")",
"# if... | Compile top-level Geography dictionary.
:param d:
:return: | [
"Compile",
"top",
"-",
"level",
"Geography",
"dictionary",
".",
":",
"param",
"d",
":",
":",
"return",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1272-L1299 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | _get_num_locations | def _get_num_locations(d):
"""
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
"""
lengths = []
for key in EXCEL_GEO:
try:
if key != "siteName":
... | python | def _get_num_locations(d):
"""
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
"""
lengths = []
for key in EXCEL_GEO:
try:
if key != "siteName":
... | [
"def",
"_get_num_locations",
"(",
"d",
")",
":",
"lengths",
"=",
"[",
"]",
"for",
"key",
"in",
"EXCEL_GEO",
":",
"try",
":",
"if",
"key",
"!=",
"\"siteName\"",
":",
"lengths",
".",
"append",
"(",
"len",
"(",
"d",
"[",
"key",
"]",
")",
")",
"except"... | 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 | [
"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",
"numbe... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1302-L1321 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | _parse_geo_location | 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_GEO:
if key not in d:
d[key] = ... | python | 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_GEO:
if key not in d:
d[key] = ... | [
"def",
"_parse_geo_location",
"(",
"d",
")",
":",
"d2",
"=",
"OrderedDict",
"(",
")",
"filt",
"=",
"{",
"}",
"d2",
"[",
"'type'",
"]",
"=",
"'Feature'",
"# If the necessary keys are missing, put in placeholders so there's no KeyErrors.",
"for",
"key",
"in",
"EXCEL_G... | Parse one geo location
:param d:
:return: | [
"Parse",
"one",
"geo",
"location",
":",
"param",
"d",
":",
":",
"return",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1324-L1342 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | _parse_geo_locations | 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 EXCEL_GEO:
if key not in d:
d[k... | python | 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 EXCEL_GEO:
if key not in d:
d[k... | [
"def",
"_parse_geo_locations",
"(",
"d",
",",
"idx",
")",
":",
"d2",
"=",
"OrderedDict",
"(",
")",
"filt",
"=",
"{",
"}",
"d2",
"[",
"'type'",
"]",
"=",
"'Feature'",
"# If the necessary keys are missing, put in placeholders so there's no KeyErrors.",
"for",
"key",
... | Parse one geo location
:param d:
:return: | [
"Parse",
"one",
"geo",
"location",
":",
"param",
"d",
":",
":",
"return",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1345-L1374 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | compile_authors | 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 names
"""
logger_excel.info("enter compile_authors")
author_lst = []
s = cell.split(';')
for w in s:
author_lst.appe... | python | 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 names
"""
logger_excel.info("enter compile_authors")
author_lst = []
s = cell.split(';')
for w in s:
author_lst.appe... | [
"def",
"compile_authors",
"(",
"cell",
")",
":",
"logger_excel",
".",
"info",
"(",
"\"enter compile_authors\"",
")",
"author_lst",
"=",
"[",
"]",
"s",
"=",
"cell",
".",
"split",
"(",
"';'",
")",
"for",
"w",
"in",
"s",
":",
"author_lst",
".",
"append",
... | Split the string of author names into the BibJSON format.
:param str cell: Data from author cell
:return: (list of dicts) Author names | [
"Split",
"the",
"string",
"of",
"author",
"names",
"into",
"the",
"BibJSON",
"format",
".",
":",
"param",
"str",
"cell",
":",
"Data",
"from",
"author",
"cell",
":",
"return",
":",
"(",
"list",
"of",
"dicts",
")",
"Author",
"names"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1377-L1389 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | compile_temp | def compile_temp(d, key, value):
"""
Compiles temporary dictionaries for metadata. Adds a new entry to an existing dictionary.
:param dict d:
:param str key:
:param any value:
:return dict:
"""
if not value:
d[key] = None
elif len(value) == 1:
d[key] = value[0]
el... | python | def compile_temp(d, key, value):
"""
Compiles temporary dictionaries for metadata. Adds a new entry to an existing dictionary.
:param dict d:
:param str key:
:param any value:
:return dict:
"""
if not value:
d[key] = None
elif len(value) == 1:
d[key] = value[0]
el... | [
"def",
"compile_temp",
"(",
"d",
",",
"key",
",",
"value",
")",
":",
"if",
"not",
"value",
":",
"d",
"[",
"key",
"]",
"=",
"None",
"elif",
"len",
"(",
"value",
")",
"==",
"1",
":",
"d",
"[",
"key",
"]",
"=",
"value",
"[",
"0",
"]",
"else",
... | Compiles temporary dictionaries for metadata. Adds a new entry to an existing dictionary.
:param dict d:
:param str key:
:param any value:
:return dict: | [
"Compiles",
"temporary",
"dictionaries",
"for",
"metadata",
".",
"Adds",
"a",
"new",
"entry",
"to",
"an",
"existing",
"dictionary",
".",
":",
"param",
"dict",
"d",
":",
":",
"param",
"str",
"key",
":",
":",
"param",
"any",
"value",
":",
":",
"return",
... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1395-L1409 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | compile_fund | def compile_fund(workbook, sheet, row, col):
"""
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
"""
logger_excel.info("enter compi... | python | def compile_fund(workbook, sheet, row, col):
"""
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
"""
logger_excel.info("enter compi... | [
"def",
"compile_fund",
"(",
"workbook",
",",
"sheet",
",",
"row",
",",
"col",
")",
":",
"logger_excel",
".",
"info",
"(",
"\"enter compile_fund\"",
")",
"l",
"=",
"[",
"]",
"temp_sheet",
"=",
"workbook",
".",
"sheet_by_name",
"(",
"sheet",
")",
"while",
... | 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 | [
"Compile",
"funding",
"entries",
".",
"Iter",
"both",
"rows",
"at",
"the",
"same",
"time",
".",
"Keep",
"adding",
"entries",
"until",
"both",
"cells",
"are",
"empty",
".",
":",
"param",
"obj",
"workbook",
":",
":",
"param",
"str",
"sheet",
":",
":",
"p... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1412-L1450 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | __compare_vars | def __compare_vars(a1, a2, name):
"""
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
"""
try:
a1 = [i for i in a1 if i]
a2 ... | python | def __compare_vars(a1, a2, name):
"""
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
"""
try:
a1 = [i for i in a1 if i]
a2 ... | [
"def",
"__compare_vars",
"(",
"a1",
",",
"a2",
",",
"name",
")",
":",
"try",
":",
"a1",
"=",
"[",
"i",
"for",
"i",
"in",
"a1",
"if",
"i",
"]",
"a2",
"=",
"[",
"i",
"for",
"i",
"in",
"a2",
"if",
"i",
"]",
"a3",
"=",
"set",
"(",
"a1",
")",
... | 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 | [
"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",
"... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1453-L1469 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | __get_datasetname | 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:
filename = d["dataSetName"]
except KeyError:
logger_excel.info("get_datasetname: KeyError: No dataSetName found.... | python | 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:
filename = d["dataSetName"]
except KeyError:
logger_excel.info("get_datasetname: KeyError: No dataSetName found.... | [
"def",
"__get_datasetname",
"(",
"d",
",",
"filename",
")",
":",
"try",
":",
"filename",
"=",
"d",
"[",
"\"dataSetName\"",
"]",
"except",
"KeyError",
":",
"logger_excel",
".",
"info",
"(",
"\"get_datasetname: KeyError: No dataSetName found. Reverting to: {}\"",
".",
... | Get the filename based on the dataset name in the metadata
:param str filename: Filename.lpd
:return str: Filename | [
"Get",
"the",
"filename",
"based",
"on",
"the",
"dataset",
"name",
"in",
"the",
"metadata",
":",
"param",
"str",
"filename",
":",
"Filename",
".",
"lpd",
":",
"return",
"str",
":",
"Filename"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1472-L1482 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | __set_sheet_filenames | def __set_sheet_filenames(sheets, n):
"""
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
"""
try:
for idx, sheet in enumerate(sheets):
try:
sheet... | python | def __set_sheet_filenames(sheets, n):
"""
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
"""
try:
for idx, sheet in enumerate(sheets):
try:
sheet... | [
"def",
"__set_sheet_filenames",
"(",
"sheets",
",",
"n",
")",
":",
"try",
":",
"for",
"idx",
",",
"sheet",
"in",
"enumerate",
"(",
"sheets",
")",
":",
"try",
":",
"sheets",
"[",
"idx",
"]",
"[",
"\"filename\"",
"]",
"=",
"\"{}.{}\"",
".",
"format",
"... | 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 | [
"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",
"metad... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1485-L1500 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | name_to_jsonld | def name_to_jsonld(title_in):
"""
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:
"""
title_out = ''
try:
title_in = title_in.lower()
... | python | def name_to_jsonld(title_in):
"""
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:
"""
title_out = ''
try:
title_in = title_in.lower()
... | [
"def",
"name_to_jsonld",
"(",
"title_in",
")",
":",
"title_out",
"=",
"''",
"try",
":",
"title_in",
"=",
"title_in",
".",
"lower",
"(",
")",
"title_out",
"=",
"EXCEL_LIPD_MAP_FLAT",
"[",
"title_in",
"]",
"except",
"(",
"KeyError",
",",
"AttributeError",
")",... | 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: | [
"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",
... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1503-L1530 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | instance_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, float):
return 'float'
else:
return 'unknown' | python | 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, float):
return 'float'
else:
return 'unknown' | [
"def",
"instance_str",
"(",
"cell",
")",
":",
"if",
"isinstance",
"(",
"cell",
",",
"str",
")",
":",
"return",
"'str'",
"elif",
"isinstance",
"(",
"cell",
",",
"int",
")",
":",
"return",
"'int'",
"elif",
"isinstance",
"(",
"cell",
",",
"float",
")",
... | Match data type and return string
:param any cell:
:return str: | [
"Match",
"data",
"type",
"and",
"return",
"string",
":",
"param",
"any",
"cell",
":",
":",
"return",
"str",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1533-L1546 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | extract_units | 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 string_in[string_in.index(start) + 1:string_in.index(stop)] | python | 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 string_in[string_in.index(start) + 1:string_in.index(stop)] | [
"def",
"extract_units",
"(",
"string_in",
")",
":",
"start",
"=",
"'('",
"stop",
"=",
"')'",
"return",
"string_in",
"[",
"string_in",
".",
"index",
"(",
"start",
")",
"+",
"1",
":",
"string_in",
".",
"index",
"(",
"stop",
")",
"]"
] | Extract units from parenthesis in a string. i.e. "elevation (meters)"
:param str string_in:
:return str: | [
"Extract",
"units",
"from",
"parenthesis",
"in",
"a",
"string",
".",
"i",
".",
"e",
".",
"elevation",
"(",
"meters",
")",
":",
"param",
"str",
"string_in",
":",
":",
"return",
"str",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1568-L1576 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | cells_rt_meta_pub | def cells_rt_meta_pub(workbook, sheet, row, col, pub_qty):
"""
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
... | python | def cells_rt_meta_pub(workbook, sheet, row, col, pub_qty):
"""
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
... | [
"def",
"cells_rt_meta_pub",
"(",
"workbook",
",",
"sheet",
",",
"row",
",",
"col",
",",
"pub_qty",
")",
":",
"logger_excel",
".",
"info",
"(",
"\"enter cells_rt_meta_pub\"",
")",
"col_loop",
"=",
"0",
"cell_data",
"=",
"[",
"]",
"temp_sheet",
"=",
"workbook"... | 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 | [
"Publication",
"section",
"is",
"special",
".",
"It",
"s",
"possible",
"there",
"s",
"more",
"than",
"one",
"publication",
".",
":",
"param",
"obj",
"workbook",
":",
":",
"param",
"str",
"sheet",
":",
":",
"param",
"int",
"row",
":",
":",
"param",
"int... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1592-L1611 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | cells_rt_meta | def cells_rt_meta(workbook, sheet, row, col):
"""
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
"""
logger_excel.info("enter cells_rt_m... | python | def cells_rt_meta(workbook, sheet, row, col):
"""
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
"""
logger_excel.info("enter cells_rt_m... | [
"def",
"cells_rt_meta",
"(",
"workbook",
",",
"sheet",
",",
"row",
",",
"col",
")",
":",
"logger_excel",
".",
"info",
"(",
"\"enter cells_rt_meta\"",
")",
"col_loop",
"=",
"0",
"cell_data",
"=",
"[",
"]",
"temp_sheet",
"=",
"workbook",
".",
"sheet_by_name",
... | 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 | [
"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",
... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1614-L1636 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | cells_dn_meta | def cells_dn_meta(workbook, sheet, row, col, final_dict):
"""
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:
:p... | python | def cells_dn_meta(workbook, sheet, row, col, final_dict):
"""
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:
:p... | [
"def",
"cells_dn_meta",
"(",
"workbook",
",",
"sheet",
",",
"row",
",",
"col",
",",
"final_dict",
")",
":",
"logger_excel",
".",
"info",
"(",
"\"enter cells_dn_meta\"",
")",
"row_loop",
"=",
"0",
"pub_cases",
"=",
"[",
"'id'",
",",
"'year'",
",",
"'author'... | 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 | [
"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",
... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1639-L1734 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | count_chron_variables | 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)
while temp_sheet.cell_value(start_row, 0) != '':
total_count += 1
start_row ... | python | 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)
while temp_sheet.cell_value(start_row, 0) != '':
total_count += 1
start_row ... | [
"def",
"count_chron_variables",
"(",
"temp_sheet",
")",
":",
"total_count",
"=",
"0",
"start_row",
"=",
"traverse_to_chron_var",
"(",
"temp_sheet",
")",
"while",
"temp_sheet",
".",
"cell_value",
"(",
"start_row",
",",
"0",
")",
"!=",
"''",
":",
"total_count",
... | Count the number of chron variables
:param obj temp_sheet:
:return int: variable count | [
"Count",
"the",
"number",
"of",
"chron",
"variables",
":",
"param",
"obj",
"temp_sheet",
":",
":",
"return",
"int",
":",
"variable",
"count"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1740-L1751 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | get_chron_var | 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_row:
:return: (list of dict) column data
"""
col_dict = OrderedDict()
out_list = []
column = 1
while (temp_sheet.cell_value(start_ro... | python | 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_row:
:return: (list of dict) column data
"""
col_dict = OrderedDict()
out_list = []
column = 1
while (temp_sheet.cell_value(start_ro... | [
"def",
"get_chron_var",
"(",
"temp_sheet",
",",
"start_row",
")",
":",
"col_dict",
"=",
"OrderedDict",
"(",
")",
"out_list",
"=",
"[",
"]",
"column",
"=",
"1",
"while",
"(",
"temp_sheet",
".",
"cell_value",
"(",
"start_row",
",",
"0",
")",
"!=",
"''",
... | 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 | [
"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",... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1754-L1779 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | traverse_to_chron_data | 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(temp_sheet)
reference_var = temp_sheet.cell_value(traverse_row, 0)
# Traverse past all the short_names... | python | 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(temp_sheet)
reference_var = temp_sheet.cell_value(traverse_row, 0)
# Traverse past all the short_names... | [
"def",
"traverse_to_chron_data",
"(",
"temp_sheet",
")",
":",
"traverse_row",
"=",
"traverse_to_chron_var",
"(",
"temp_sheet",
")",
"reference_var",
"=",
"temp_sheet",
".",
"cell_value",
"(",
"traverse_row",
",",
"0",
")",
"# Traverse past all the short_names, until you h... | Traverse down to the first row that has chron data
:param obj temp_sheet:
:return int: traverse_row | [
"Traverse",
"down",
"to",
"the",
"first",
"row",
"that",
"has",
"chron",
"data",
":",
"param",
"obj",
"temp_sheet",
":",
":",
"return",
"int",
":",
"traverse_row"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1782-L1802 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | traverse_to_chron_var | 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 'Parameter' in temp_sheet.cell_value(row, 0):
row += 1
break
row += 1
... | python | 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 'Parameter' in temp_sheet.cell_value(row, 0):
row += 1
break
row += 1
... | [
"def",
"traverse_to_chron_var",
"(",
"temp_sheet",
")",
":",
"row",
"=",
"0",
"while",
"row",
"<",
"temp_sheet",
".",
"nrows",
"-",
"1",
":",
"if",
"'Parameter'",
"in",
"temp_sheet",
".",
"cell_value",
"(",
"row",
",",
"0",
")",
":",
"row",
"+=",
"1",
... | Traverse down to the row that has the first variable
:param obj temp_sheet:
:return int: | [
"Traverse",
"down",
"to",
"the",
"row",
"that",
"has",
"the",
"first",
"variable",
":",
"param",
"obj",
"temp_sheet",
":",
":",
"return",
"int",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1805-L1818 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | get_chron_data | 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_sheet:
:param int row:
:param int total_vars:
:return list: data_row
"""
data_row = []
missing_val_list = ['none', 'na', '', '-']
for i in range... | python | 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_sheet:
:param int row:
:param int total_vars:
:return list: data_row
"""
data_row = []
missing_val_list = ['none', 'na', '', '-']
for i in range... | [
"def",
"get_chron_data",
"(",
"temp_sheet",
",",
"row",
",",
"total_vars",
")",
":",
"data_row",
"=",
"[",
"]",
"missing_val_list",
"=",
"[",
"'none'",
",",
"'na'",
",",
"''",
",",
"'-'",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"total_vars",
"... | 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 | [
"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",
... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1821-L1838 |
nickmckay/LiPD-utilities | Python/lipd/excel.py | _remove_geo_placeholders | 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:
if isinstance(i, list):
for k in i:
if isinstance(k, float) or isinstance(k, int):... | python | 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:
if isinstance(i, list):
for k in i:
if isinstance(k, float) or isinstance(k, int):... | [
"def",
"_remove_geo_placeholders",
"(",
"l",
")",
":",
"vals",
"=",
"[",
"]",
"for",
"i",
"in",
"l",
":",
"if",
"isinstance",
"(",
"i",
",",
"list",
")",
":",
"for",
"k",
"in",
"i",
":",
"if",
"isinstance",
"(",
"k",
",",
"float",
")",
"or",
"i... | Remove placeholders from coordinate lists and sort
:param list l: Lat or long list
:return list: Modified list | [
"Remove",
"placeholders",
"from",
"coordinate",
"lists",
"and",
"sort",
":",
"param",
"list",
"l",
":",
"Lat",
"or",
"long",
"list",
":",
"return",
"list",
":",
"Modified",
"list"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/excel.py#L1841-L1856 |
nickmckay/LiPD-utilities | Python/lipd/jsons.py | read_jsonld | 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 none, fallback for a json file. If neither found, return empty.
_filename = [file for file in os.listdi... | python | 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 none, fallback for a json file. If neither found, return empty.
_filename = [file for file in os.listdi... | [
"def",
"read_jsonld",
"(",
")",
":",
"_d",
"=",
"{",
"}",
"try",
":",
"# Find a jsonld file in cwd. If none, fallback for a json file. If neither found, return empty.",
"_filename",
"=",
"[",
"file",
"for",
"file",
"in",
"os",
".",
"listdir",
"(",
")",
"if",
"file",... | Find jsonld file in the cwd (or within a 2 levels below cwd), and load it in.
:return dict: Jsonld data | [
"Find",
"jsonld",
"file",
"in",
"the",
"cwd",
"(",
"or",
"within",
"a",
"2",
"levels",
"below",
"cwd",
")",
"and",
"load",
"it",
"in",
".",
":",
"return",
"dict",
":",
"Jsonld",
"data"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/jsons.py#L14-L48 |
nickmckay/LiPD-utilities | Python/lipd/jsons.py | read_json_from_file | 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 = OrderedDict()
try:
# Load and decode
d = demjson.decode_file(filename, decode_floa... | python | 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 = OrderedDict()
try:
# Load and decode
d = demjson.decode_file(filename, decode_floa... | [
"def",
"read_json_from_file",
"(",
"filename",
")",
":",
"logger_jsons",
".",
"info",
"(",
"\"enter read_json_from_file\"",
")",
"d",
"=",
"OrderedDict",
"(",
")",
"try",
":",
"# Load and decode",
"d",
"=",
"demjson",
".",
"decode_file",
"(",
"filename",
",",
... | Import the JSON data from target file.
:param str filename: Target File
:return dict: JSON data | [
"Import",
"the",
"JSON",
"data",
"from",
"target",
"file",
".",
":",
"param",
"str",
"filename",
":",
"Target",
"File",
":",
"return",
"dict",
":",
"JSON",
"data"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/jsons.py#L51-L77 |
nickmckay/LiPD-utilities | Python/lipd/jsons.py | idx_num_to_name | 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 "paleoData" in L:
L["paleoData"] = _import_data(L["paleoData"], "paleo")
if "chronDa... | python | 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 "paleoData" in L:
L["paleoData"] = _import_data(L["paleoData"], "paleo")
if "chronDa... | [
"def",
"idx_num_to_name",
"(",
"L",
")",
":",
"logger_jsons",
".",
"info",
"(",
"\"enter idx_num_to_name\"",
")",
"try",
":",
"if",
"\"paleoData\"",
"in",
"L",
":",
"L",
"[",
"\"paleoData\"",
"]",
"=",
"_import_data",
"(",
"L",
"[",
"\"paleoData\"",
"]",
"... | Switch from index-by-number to index-by-name.
:param dict L: Metadata
:return dict L: Metadata | [
"Switch",
"from",
"index",
"-",
"by",
"-",
"number",
"to",
"index",
"-",
"by",
"-",
"name",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/jsons.py#L80-L99 |
nickmckay/LiPD-utilities | Python/lipd/jsons.py | _import_data | def _import_data(sections, crumbs):
"""
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
"""
logger_jsons.info("enter import_data: {}".format(crumbs))
_sections = OrderedDict()
t... | python | def _import_data(sections, crumbs):
"""
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
"""
logger_jsons.info("enter import_data: {}".format(crumbs))
_sections = OrderedDict()
t... | [
"def",
"_import_data",
"(",
"sections",
",",
"crumbs",
")",
":",
"logger_jsons",
".",
"info",
"(",
"\"enter import_data: {}\"",
".",
"format",
"(",
"crumbs",
")",
")",
"_sections",
"=",
"OrderedDict",
"(",
")",
"try",
":",
"for",
"_idx",
",",
"section",
"i... | 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 | [
"Import",
"the",
"section",
"metadata",
"and",
"change",
"it",
"to",
"index",
"-",
"by",
"-",
"name",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/jsons.py#L102-L139 |
nickmckay/LiPD-utilities | Python/lipd/jsons.py | _import_model | def _import_model(models, crumbs):
"""
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
"""
logger_jsons.info("enter import_model".format(crumbs))
_models = OrderedDict()
... | python | def _import_model(models, crumbs):
"""
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
"""
logger_jsons.info("enter import_model".format(crumbs))
_models = OrderedDict()
... | [
"def",
"_import_model",
"(",
"models",
",",
"crumbs",
")",
":",
"logger_jsons",
".",
"info",
"(",
"\"enter import_model\"",
".",
"format",
"(",
"crumbs",
")",
")",
"_models",
"=",
"OrderedDict",
"(",
")",
"try",
":",
"for",
"_idx",
",",
"model",
"in",
"e... | 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 | [
"Change",
"the",
"nested",
"items",
"of",
"the",
"paleoModel",
"data",
".",
"Overwrite",
"the",
"data",
"in",
"-",
"place",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/jsons.py#L142-L171 |
nickmckay/LiPD-utilities | Python/lipd/jsons.py | _idx_table_by_name | def _idx_table_by_name(tables, crumbs):
"""
Import summary, ensemble, or distribution data.
:param list tables: Metadata
:return dict _tables: Metadata
"""
_tables = OrderedDict()
try:
for _idx, _table in enumerate(tables):
# Use "name" as tableName
_name = "... | python | def _idx_table_by_name(tables, crumbs):
"""
Import summary, ensemble, or distribution data.
:param list tables: Metadata
:return dict _tables: Metadata
"""
_tables = OrderedDict()
try:
for _idx, _table in enumerate(tables):
# Use "name" as tableName
_name = "... | [
"def",
"_idx_table_by_name",
"(",
"tables",
",",
"crumbs",
")",
":",
"_tables",
"=",
"OrderedDict",
"(",
")",
"try",
":",
"for",
"_idx",
",",
"_table",
"in",
"enumerate",
"(",
"tables",
")",
":",
"# Use \"name\" as tableName",
"_name",
"=",
"\"{}{}\"",
".",
... | Import summary, ensemble, or distribution data.
:param list tables: Metadata
:return dict _tables: Metadata | [
"Import",
"summary",
"ensemble",
"or",
"distribution",
"data",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/jsons.py#L174-L196 |
nickmckay/LiPD-utilities | Python/lipd/jsons.py | _idx_col_by_name | 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 names.
:param dict table: Metadata
:return dict _table: Metadata
"""
_columns = OrderedDict()
# Iter for each column in the list
try:
for _colum... | python | 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 names.
:param dict table: Metadata
:return dict _table: Metadata
"""
_columns = OrderedDict()
# Iter for each column in the list
try:
for _colum... | [
"def",
"_idx_col_by_name",
"(",
"table",
")",
":",
"_columns",
"=",
"OrderedDict",
"(",
")",
"# Iter for each column in the list",
"try",
":",
"for",
"_column",
"in",
"table",
"[",
"\"columns\"",
"]",
":",
"try",
":",
"_name",
"=",
"_column",
"[",
"\"variableN... | 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 | [
"Iter",
"over",
"columns",
"list",
".",
"Turn",
"indexed",
"-",
"by",
"-",
"num",
"list",
"into",
"an",
"indexed",
"-",
"by",
"-",
"name",
"dict",
".",
"Keys",
"are",
"the",
"variable",
"names",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/jsons.py#L199-L225 |
nickmckay/LiPD-utilities | Python/lipd/jsons.py | get_csv_from_json | def get_csv_from_json(d):
"""
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: ... }
"""
logger_jsons.info("ent... | python | def get_csv_from_json(d):
"""
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: ... }
"""
logger_jsons.info("ent... | [
"def",
"get_csv_from_json",
"(",
"d",
")",
":",
"logger_jsons",
".",
"info",
"(",
"\"enter get_csv_from_json\"",
")",
"csv_data",
"=",
"OrderedDict",
"(",
")",
"if",
"\"paleoData\"",
"in",
"d",
":",
"csv_data",
"=",
"_get_csv_from_section",
"(",
"d",
",",
"\"p... | 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: ... } | [
"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",
":"... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/jsons.py#L231-L247 |
nickmckay/LiPD-utilities | Python/lipd/jsons.py | _get_csv_from_section | 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 csv data
"""
logger_jsons.info("enter get_csv_from_section: {}".format(pc))
for table, table_content in d[pc].items():
... | python | 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 csv data
"""
logger_jsons.info("enter get_csv_from_section: {}".format(pc))
for table, table_content in d[pc].items():
... | [
"def",
"_get_csv_from_section",
"(",
"d",
",",
"pc",
",",
"csv_data",
")",
":",
"logger_jsons",
".",
"info",
"(",
"\"enter get_csv_from_section: {}\"",
".",
"format",
"(",
"pc",
")",
")",
"for",
"table",
",",
"table_content",
"in",
"d",
"[",
"pc",
"]",
"."... | Get csv from paleo and chron sections
:param dict d: Metadata
:param str pc: Paleo or chron
:return dict: running csv data | [
"Get",
"csv",
"from",
"paleo",
"and",
"chron",
"sections",
":",
"param",
"dict",
"d",
":",
"Metadata",
":",
"param",
"str",
"pc",
":",
"Paleo",
"or",
"chron",
":",
"return",
"dict",
":",
"running",
"csv",
"data"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/jsons.py#L250-L268 |
nickmckay/LiPD-utilities | Python/lipd/jsons.py | remove_csv_from_json | def remove_csv_from_json(d):
"""
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
"""
logger_jsons.info("enter remove_csv_from_json")
# Check both sections
if "p... | python | def remove_csv_from_json(d):
"""
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
"""
logger_jsons.info("enter remove_csv_from_json")
# Check both sections
if "p... | [
"def",
"remove_csv_from_json",
"(",
"d",
")",
":",
"logger_jsons",
".",
"info",
"(",
"\"enter remove_csv_from_json\"",
")",
"# Check both sections",
"if",
"\"paleoData\"",
"in",
"d",
":",
"d",
"=",
"_remove_csv_from_section",
"(",
"d",
",",
"\"paleoData\"",
")",
"... | 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 | [
"Remove",
"all",
"CSV",
"data",
"values",
"entries",
"from",
"paleoData",
"table",
"in",
"the",
"JSON",
"structure",
".",
":",
"param",
"dict",
"d",
":",
"JSON",
"data",
"-",
"old",
"structure",
":",
"return",
"dict",
":",
"Metadata",
"dictionary",
"withou... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/jsons.py#L271-L287 |
nickmckay/LiPD-utilities | Python/lipd/jsons.py | _remove_csv_from_section | 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 metadata
"""
logger_jsons.info("enter remove_csv_from_json: {}".format(pc))
for table, table_content in d[pc].items():
f... | python | 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 metadata
"""
logger_jsons.info("enter remove_csv_from_json: {}".format(pc))
for table, table_content in d[pc].items():
f... | [
"def",
"_remove_csv_from_section",
"(",
"d",
",",
"pc",
")",
":",
"logger_jsons",
".",
"info",
"(",
"\"enter remove_csv_from_json: {}\"",
".",
"format",
"(",
"pc",
")",
")",
"for",
"table",
",",
"table_content",
"in",
"d",
"[",
"pc",
"]",
".",
"items",
"("... | Remove CSV from metadata in this section
:param dict d: Metadata
:param str pc: Paleo or chron
:return dict: Modified metadata | [
"Remove",
"CSV",
"from",
"metadata",
"in",
"this",
"section",
":",
"param",
"dict",
"d",
":",
"Metadata",
":",
"param",
"str",
"pc",
":",
"Paleo",
"or",
"chron",
":",
"return",
"dict",
":",
"Modified",
"metadata"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/jsons.py#L290-L309 |
nickmckay/LiPD-utilities | Python/lipd/jsons.py | write_json_to_file | def write_json_to_file(json_data, filename="metadata"):
"""
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:
"""
logger_jsons.info("enter write_json_to_file")
json_d... | python | def write_json_to_file(json_data, filename="metadata"):
"""
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:
"""
logger_jsons.info("enter write_json_to_file")
json_d... | [
"def",
"write_json_to_file",
"(",
"json_data",
",",
"filename",
"=",
"\"metadata\"",
")",
":",
"logger_jsons",
".",
"info",
"(",
"\"enter write_json_to_file\"",
")",
"json_data",
"=",
"rm_empty_fields",
"(",
"json_data",
")",
"# Use demjson to maintain unicode characters ... | 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: | [
"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",
".",
"json... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/jsons.py#L315-L334 |
nickmckay/LiPD-utilities | Python/lipd/jsons.py | idx_name_to_num | 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")
# Process the paleoData section
if "paleoData" in L:
L["paleoData"] = _export_section(L["paleoData"], ... | python | 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")
# Process the paleoData section
if "paleoData" in L:
L["paleoData"] = _export_section(L["paleoData"], ... | [
"def",
"idx_name_to_num",
"(",
"L",
")",
":",
"logger_jsons",
".",
"info",
"(",
"\"enter idx_name_to_num\"",
")",
"# Process the paleoData section",
"if",
"\"paleoData\"",
"in",
"L",
":",
"L",
"[",
"\"paleoData\"",
"]",
"=",
"_export_section",
"(",
"L",
"[",
"\"... | Switch from index-by-name to index-by-number.
:param dict L: Metadata
:return dict: Modified metadata | [
"Switch",
"from",
"index",
"-",
"by",
"-",
"name",
"to",
"index",
"-",
"by",
"-",
"number",
".",
":",
"param",
"dict",
"L",
":",
"Metadata",
":",
"return",
"dict",
":",
"Modified",
"metadata"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/jsons.py#L337-L354 |
nickmckay/LiPD-utilities | Python/lipd/jsons.py | _export_section | 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: {}".format(pc))
_sections = []
for name, section in sections.items():
# Process chron models
... | python | 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: {}".format(pc))
_sections = []
for name, section in sections.items():
# Process chron models
... | [
"def",
"_export_section",
"(",
"sections",
",",
"pc",
")",
":",
"logger_jsons",
".",
"info",
"(",
"\"enter export_data: {}\"",
".",
"format",
"(",
"pc",
")",
")",
"_sections",
"=",
"[",
"]",
"for",
"name",
",",
"section",
"in",
"sections",
".",
"items",
... | Switch chron data to index-by-number
:param dict sections: Metadata
:return list _sections: Metadata | [
"Switch",
"chron",
"data",
"to",
"index",
"-",
"by",
"-",
"number",
":",
"param",
"dict",
"sections",
":",
"Metadata",
":",
"return",
"list",
"_sections",
":",
"Metadata"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/jsons.py#L357-L380 |
nickmckay/LiPD-utilities | Python/lipd/jsons.py | _export_model | 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 = []
try:
for name, model in models.items():
if "summaryTable" in model:
... | python | 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 = []
try:
for name, model in models.items():
if "summaryTable" in model:
... | [
"def",
"_export_model",
"(",
"models",
")",
":",
"logger_jsons",
".",
"info",
"(",
"\"enter export_model\"",
")",
"_models",
"=",
"[",
"]",
"try",
":",
"for",
"name",
",",
"model",
"in",
"models",
".",
"items",
"(",
")",
":",
"if",
"\"summaryTable\"",
"i... | Switch model tables to index-by-number
:param dict models: Metadata
:return dict _models: Metadata | [
"Switch",
"model",
"tables",
"to",
"index",
"-",
"by",
"-",
"number"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/jsons.py#L383-L411 |
nickmckay/LiPD-utilities | Python/lipd/jsons.py | _idx_table_by_num | 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 = []
for name, table in tables.items():
try:
# Get the modified table data
... | python | 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 = []
for name, table in tables.items():
try:
# Get the modified table data
... | [
"def",
"_idx_table_by_num",
"(",
"tables",
")",
":",
"logger_jsons",
".",
"info",
"(",
"\"enter idx_table_by_num\"",
")",
"_tables",
"=",
"[",
"]",
"for",
"name",
",",
"table",
"in",
"tables",
".",
"items",
"(",
")",
":",
"try",
":",
"# Get the modified tabl... | Switch tables to index-by-number
:param dict tables: Metadata
:return list _tables: Metadata | [
"Switch",
"tables",
"to",
"index",
"-",
"by",
"-",
"number"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/jsons.py#L414-L432 |
nickmckay/LiPD-utilities | Python/lipd/jsons.py | _idx_col_by_num | 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
:return list _table: Metadata
"""
_columns = []
try:
# Create an empty list that matches the length of the column dictionary
_... | python | 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
:return list _table: Metadata
"""
_columns = []
try:
# Create an empty list that matches the length of the column dictionary
_... | [
"def",
"_idx_col_by_num",
"(",
"table",
")",
":",
"_columns",
"=",
"[",
"]",
"try",
":",
"# Create an empty list that matches the length of the column dictionary",
"_columns",
"=",
"[",
"None",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"table",
"[",
... | Index columns by number instead of by name. Use "number" key in column to maintain order
:param dict table: Metadata
:return list _table: Metadata | [
"Index",
"columns",
"by",
"number",
"instead",
"of",
"by",
"name",
".",
"Use",
"number",
"key",
"in",
"column",
"to",
"maintain",
"order"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/jsons.py#L435-L470 |
nickmckay/LiPD-utilities | Matlab/bagit.py | make_bag | 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 pairs to put into the bag-info.txt metadata file as
the bag_info dictionary.
"""
bag_dir = os.path.abspath(bag_dir)
logger.info("creating bag for di... | python | 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 pairs to put into the bag-info.txt metadata file as
the bag_info dictionary.
"""
bag_dir = os.path.abspath(bag_dir)
logger.info("creating bag for di... | [
"def",
"make_bag",
"(",
"bag_dir",
",",
"bag_info",
"=",
"None",
",",
"processes",
"=",
"1",
",",
"checksum",
"=",
"None",
")",
":",
"bag_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"bag_dir",
")",
"logger",
".",
"info",
"(",
"\"creating bag for... | 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. | [
"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",
... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Matlab/bagit.py#L76-L156 |
nickmckay/LiPD-utilities | Matlab/bagit.py | _calculate_file_hashes | 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 not exist" % full_path)
try:
with open(full_path, 'rb') as f:
... | python | 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 not exist" % full_path)
try:
with open(full_path, 'rb') as f:
... | [
"def",
"_calculate_file_hashes",
"(",
"full_path",
",",
"f_hashers",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"full_path",
")",
":",
"raise",
"BagValidationError",
"(",
"\"%s does not exist\"",
"%",
"full_path",
")",
"try",
":",
"with",
... | Returns a dictionary of (algorithm, hexdigest) values for the provided
filename | [
"Returns",
"a",
"dictionary",
"of",
"(",
"algorithm",
"hexdigest",
")",
"values",
"for",
"the",
"provided",
"filename"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Matlab/bagit.py#L624-L647 |
nickmckay/LiPD-utilities | Matlab/bagit.py | _parse_tags | def _parse_tags(tag_file):
"""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.
"""
tag_name = None
tag_value = None
# Line folding is handled by yi... | python | def _parse_tags(tag_file):
"""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.
"""
tag_name = None
tag_value = None
# Line folding is handled by yi... | [
"def",
"_parse_tags",
"(",
"tag_file",
")",
":",
"tag_name",
"=",
"None",
"tag_value",
"=",
"None",
"# Line folding is handled by yielding values only after we encounter",
"# the start of a new tag, or if we pass the EOF.",
"for",
"num",
",",
"line",
"in",
"enumerate",
"(",
... | 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. | [
"Parses",
"a",
"tag",
"file",
"according",
"to",
"RFC",
"2822",
".",
"This",
"includes",
"line",
"folding",
"permitting",
"extra",
"-",
"long",
"field",
"values",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Matlab/bagit.py#L667-L706 |
nickmckay/LiPD-utilities | Matlab/bagit.py | _can_bag | 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))
return tuple(unwriteable) | python | 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))
return tuple(unwriteable) | [
"def",
"_can_bag",
"(",
"test_dir",
")",
":",
"unwriteable",
"=",
"[",
"]",
"for",
"inode",
"in",
"os",
".",
"listdir",
"(",
"test_dir",
")",
":",
"if",
"not",
"os",
".",
"access",
"(",
"os",
".",
"path",
".",
"join",
"(",
"test_dir",
",",
"inode",... | returns (unwriteable files/folders) | [
"returns",
"(",
"unwriteable",
"files",
"/",
"folders",
")"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Matlab/bagit.py#L795-L802 |
nickmckay/LiPD-utilities | Matlab/bagit.py | _can_read | 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.join(dirpath, dn), os.R_OK):
unreada... | python | 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.join(dirpath, dn), os.R_OK):
unreada... | [
"def",
"_can_read",
"(",
"test_dir",
")",
":",
"unreadable_dirs",
"=",
"[",
"]",
"unreadable_files",
"=",
"[",
"]",
"for",
"dirpath",
",",
"dirnames",
",",
"filenames",
"in",
"os",
".",
"walk",
"(",
"test_dir",
")",
":",
"for",
"dn",
"in",
"dirnames",
... | returns ((unreadable_dirs), (unreadable_files)) | [
"returns",
"((",
"unreadable_dirs",
")",
"(",
"unreadable_files",
"))"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Matlab/bagit.py#L805-L818 |
nickmckay/LiPD-utilities | Matlab/bagit.py | Bag.compare_fetch_with_fs | 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
that still need to be fetched.
"""
files_on_fs = set(self.payload_files())
files_in_fetch = set(self.files_to_be_fetched())
... | python | 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
that still need to be fetched.
"""
files_on_fs = set(self.payload_files())
files_in_fetch = set(self.files_to_be_fetched())
... | [
"def",
"compare_fetch_with_fs",
"(",
"self",
")",
":",
"files_on_fs",
"=",
"set",
"(",
"self",
".",
"payload_files",
"(",
")",
")",
"files_in_fetch",
"=",
"set",
"(",
"self",
".",
"files_to_be_fetched",
"(",
")",
")",
"return",
"list",
"(",
"files_in_fetch",... | 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. | [
"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",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Matlab/bagit.py#L236-L245 |
nickmckay/LiPD-utilities | Matlab/bagit.py | Bag.save | def save(self, processes=1, manifests=False):
"""
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 th... | python | def save(self, processes=1, manifests=False):
"""
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 th... | [
"def",
"save",
"(",
"self",
",",
"processes",
"=",
"1",
",",
"manifests",
"=",
"False",
")",
":",
"# Error checking",
"if",
"not",
"self",
".",
"path",
":",
"raise",
"BagError",
"(",
"\"Bag does not have a path.\"",
")",
"# Change working directory to bag director... | 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
... | [
"save",
"will",
"persist",
"any",
"changes",
"that",
"have",
"been",
"made",
"to",
"the",
"bag",
"metadata",
"(",
"self",
".",
"info",
")",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Matlab/bagit.py#L263-L319 |
nickmckay/LiPD-utilities | Matlab/bagit.py | Bag.missing_optional_tagfiles | def missing_optional_tagfiles(self):
"""
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 exist... | python | def missing_optional_tagfiles(self):
"""
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 exist... | [
"def",
"missing_optional_tagfiles",
"(",
"self",
")",
":",
"for",
"tagfilepath",
"in",
"list",
"(",
"self",
".",
"tagfile_entries",
"(",
")",
".",
"keys",
"(",
")",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"os",
".",
"path",
".",... | 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). | [
"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"... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Matlab/bagit.py#L325-L335 |
nickmckay/LiPD-utilities | Matlab/bagit.py | Bag.validate | def validate(self, processes=1, fast=False):
"""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
comp... | python | def validate(self, processes=1, fast=False):
"""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
comp... | [
"def",
"validate",
"(",
"self",
",",
"processes",
"=",
"1",
",",
"fast",
"=",
"False",
")",
":",
"self",
".",
"_validate_structure",
"(",
")",
"self",
".",
"_validate_bagittxt",
"(",
")",
"self",
".",
"_validate_contents",
"(",
"processes",
"=",
"processes... | 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()
... | [
"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",... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Matlab/bagit.py#L353-L364 |
nickmckay/LiPD-utilities | Matlab/bagit.py | Bag.is_valid | def is_valid(self, fast=False):
"""Returns validation success or failure as boolean.
Optional fast parameter passed directly to validate().
"""
try:
self.validate(fast=fast)
except BagError:
return False
return True | python | def is_valid(self, fast=False):
"""Returns validation success or failure as boolean.
Optional fast parameter passed directly to validate().
"""
try:
self.validate(fast=fast)
except BagError:
return False
return True | [
"def",
"is_valid",
"(",
"self",
",",
"fast",
"=",
"False",
")",
":",
"try",
":",
"self",
".",
"validate",
"(",
"fast",
"=",
"fast",
")",
"except",
"BagError",
":",
"return",
"False",
"return",
"True"
] | Returns validation success or failure as boolean.
Optional fast parameter passed directly to validate(). | [
"Returns",
"validation",
"success",
"or",
"failure",
"as",
"boolean",
".",
"Optional",
"fast",
"parameter",
"passed",
"directly",
"to",
"validate",
"()",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Matlab/bagit.py#L366-L374 |
nickmckay/LiPD-utilities | Matlab/bagit.py | Bag._validate_entries | 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's no mismatch between the filesystem
# and the list of files in the manifest(s)
... | python | 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's no mismatch between the filesystem
# and the list of files in the manifest(s)
... | [
"def",
"_validate_entries",
"(",
"self",
",",
"processes",
")",
":",
"errors",
"=",
"list",
"(",
")",
"# First we'll make sure there's no mismatch between the filesystem",
"# and the list of files in the manifest(s)",
"only_in_manifests",
",",
"only_on_fs",
"=",
"self",
".",
... | Verify that the actual file contents match the recorded hashes stored in the manifest files | [
"Verify",
"that",
"the",
"actual",
"file",
"contents",
"match",
"the",
"recorded",
"hashes",
"stored",
"in",
"the",
"manifest",
"files"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Matlab/bagit.py#L474-L540 |
nickmckay/LiPD-utilities | Matlab/bagit.py | Bag._validate_bagittxt | 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.readline()
if first_line.startswith(BOM):
... | python | 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.readline()
if first_line.startswith(BOM):
... | [
"def",
"_validate_bagittxt",
"(",
"self",
")",
":",
"bagit_file_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"path",
",",
"\"bagit.txt\"",
")",
"with",
"open",
"(",
"bagit_file_path",
",",
"'r'",
")",
"as",
"bagit_file",
":",
"first_line",... | Verify that bagit.txt conforms to specification | [
"Verify",
"that",
"bagit",
".",
"txt",
"conforms",
"to",
"specification"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Matlab/bagit.py#L542-L550 |
nickmckay/LiPD-utilities | Python/lipd/inferred_data.py | _fix_numeric_types | 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: Columns of data
"""
try:
for var, data in c.items():
for k, v in data.items():
if k in ["hasMeanValue", "h... | python | 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: Columns of data
"""
try:
for var, data in c.items():
for k, v in data.items():
if k in ["hasMeanValue", "h... | [
"def",
"_fix_numeric_types",
"(",
"c",
")",
":",
"try",
":",
"for",
"var",
",",
"data",
"in",
"c",
".",
"items",
"(",
")",
":",
"for",
"k",
",",
"v",
"in",
"data",
".",
"items",
"(",
")",
":",
"if",
"k",
"in",
"[",
"\"hasMeanValue\"",
",",
"\"h... | 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 | [
"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"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/inferred_data.py#L11-L41 |
nickmckay/LiPD-utilities | Python/lipd/inferred_data.py | _get_age | def _get_age(columns):
"""
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
"""
# Need to check multiple places for age, year, or yrbp
# 1. Check the column variable name
# 2. Chec... | python | def _get_age(columns):
"""
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
"""
# Need to check multiple places for age, year, or yrbp
# 1. Check the column variable name
# 2. Chec... | [
"def",
"_get_age",
"(",
"columns",
")",
":",
"# Need to check multiple places for age, year, or yrbp",
"# 1. Check the column variable name",
"# 2. Check for an \"inferredVariableType",
"age",
"=",
"[",
"]",
"try",
":",
"# Step 1:",
"# Check for age first (exact match)",
"if",
"\... | 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 | [
"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"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/inferred_data.py#L44-L110 |
nickmckay/LiPD-utilities | Python/lipd/inferred_data.py | _get_resolution | 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.diff(age2)
# Make sure that age and values are ... | python | 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.diff(age2)
# Make sure that age and values are ... | [
"def",
"_get_resolution",
"(",
"age",
",",
"values",
")",
":",
"res",
"=",
"[",
"]",
"try",
":",
"# Get the nan index from the values and remove from age",
"# age2 = age[np.where(~np.isnan(values))[0]]",
"# res = np.diff(age2)",
"# Make sure that age and values are numpy arrays",
... | Calculates the resolution (res)
Thanks Deborah! | [
"Calculates",
"the",
"resolution",
"(",
"res",
")",
"Thanks",
"Deborah!"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/inferred_data.py#L113-L136 |
nickmckay/LiPD-utilities | Python/lipd/inferred_data.py | __get_inferred_data_res_2 | def __get_inferred_data_res_2(v=None, calc=True):
"""
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
"""
# Base: If something goes wrong, or i... | python | def __get_inferred_data_res_2(v=None, calc=True):
"""
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
"""
# Base: If something goes wrong, or i... | [
"def",
"__get_inferred_data_res_2",
"(",
"v",
"=",
"None",
",",
"calc",
"=",
"True",
")",
":",
"# Base: If something goes wrong, or if there are no values, then use \"NaN\" placeholders.",
"d",
"=",
"{",
"\"hasMinValue\"",
":",
"\"nan\"",
",",
"\"hasMaxValue\"",
":",
"\"n... | 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 | [
"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... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/inferred_data.py#L139-L184 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.