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/inferred_data.py | _get_inferred_data_res | def _get_inferred_data_res(column, age):
"""
Calculate Resolution and m/m/m/m for column values.
:param dict column: Column data
:param list age: Age values
:return dict column: Column data - modified
"""
try:
with warnings.catch_warnings():
warnings.simplefilter("ignore"... | python | def _get_inferred_data_res(column, age):
"""
Calculate Resolution and m/m/m/m for column values.
:param dict column: Column data
:param list age: Age values
:return dict column: Column data - modified
"""
try:
with warnings.catch_warnings():
warnings.simplefilter("ignore"... | [
"def",
"_get_inferred_data_res",
"(",
"column",
",",
"age",
")",
":",
"try",
":",
"with",
"warnings",
".",
"catch_warnings",
"(",
")",
":",
"warnings",
".",
"simplefilter",
"(",
"\"ignore\"",
")",
"# Get the values for this column",
"values",
"=",
"column",
"[",... | Calculate Resolution and m/m/m/m for column values.
:param dict column: Column data
:param list age: Age values
:return dict column: Column data - modified | [
"Calculate",
"Resolution",
"and",
"m",
"/",
"m",
"/",
"m",
"/",
"m",
"for",
"column",
"values",
".",
":",
"param",
"dict",
"column",
":",
"Column",
"data",
":",
"param",
"list",
"age",
":",
"Age",
"values",
":",
"return",
"dict",
"column",
":",
"Colu... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/inferred_data.py#L187-L223 |
nickmckay/LiPD-utilities | Python/lipd/inferred_data.py | _get_inferred_data_column | def _get_inferred_data_column(column):
"""
Calculate the m/m/m/m for column values.
:param dict column: Column data
:return dict column: Column data - modified
"""
try:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
# Get the values for this colum... | python | def _get_inferred_data_column(column):
"""
Calculate the m/m/m/m for column values.
:param dict column: Column data
:return dict column: Column data - modified
"""
try:
with warnings.catch_warnings():
warnings.simplefilter("ignore")
# Get the values for this colum... | [
"def",
"_get_inferred_data_column",
"(",
"column",
")",
":",
"try",
":",
"with",
"warnings",
".",
"catch_warnings",
"(",
")",
":",
"warnings",
".",
"simplefilter",
"(",
"\"ignore\"",
")",
"# Get the values for this column",
"values",
"=",
"column",
"[",
"\"values\... | Calculate the m/m/m/m for column values.
:param dict column: Column data
:return dict column: Column data - modified | [
"Calculate",
"the",
"m",
"/",
"m",
"/",
"m",
"/",
"m",
"for",
"column",
"values",
".",
":",
"param",
"dict",
"column",
":",
"Column",
"data",
":",
"return",
"dict",
"column",
":",
"Column",
"data",
"-",
"modified"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/inferred_data.py#L226-L254 |
nickmckay/LiPD-utilities | Python/lipd/inferred_data.py | get_inferred_data_table | def get_inferred_data_table(table, pc):
"""
Table level: Dive down, calculate data, then return the new table with the inferred data.
:param str pc: paleo or chron
:param dict table: Metadata
:return dict table: Metadata
"""
age = None
if pc == "paleo":
# Get the age values data... | python | def get_inferred_data_table(table, pc):
"""
Table level: Dive down, calculate data, then return the new table with the inferred data.
:param str pc: paleo or chron
:param dict table: Metadata
:return dict table: Metadata
"""
age = None
if pc == "paleo":
# Get the age values data... | [
"def",
"get_inferred_data_table",
"(",
"table",
",",
"pc",
")",
":",
"age",
"=",
"None",
"if",
"pc",
"==",
"\"paleo\"",
":",
"# Get the age values data first, since it's needed to calculate the other column data.",
"age",
"=",
"_get_age",
"(",
"table",
"[",
"\"columns\"... | Table level: Dive down, calculate data, then return the new table with the inferred data.
:param str pc: paleo or chron
:param dict table: Metadata
:return dict table: Metadata | [
"Table",
"level",
":",
"Dive",
"down",
"calculate",
"data",
"then",
"return",
"the",
"new",
"table",
"with",
"the",
"inferred",
"data",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/inferred_data.py#L257-L305 |
useblocks/sphinxcontrib-needs | sphinxcontrib/needs/functions/functions.py | register_func | def register_func(env, need_function):
"""
Registers a new sphinx-needs function for the given sphinx environment.
:param env: Sphinx environment
:param need_function: Python method
:return: None
"""
if not hasattr(env, 'needs_functions'):
env.needs_functions = {}
func_name = n... | python | def register_func(env, need_function):
"""
Registers a new sphinx-needs function for the given sphinx environment.
:param env: Sphinx environment
:param need_function: Python method
:return: None
"""
if not hasattr(env, 'needs_functions'):
env.needs_functions = {}
func_name = n... | [
"def",
"register_func",
"(",
"env",
",",
"need_function",
")",
":",
"if",
"not",
"hasattr",
"(",
"env",
",",
"'needs_functions'",
")",
":",
"env",
".",
"needs_functions",
"=",
"{",
"}",
"func_name",
"=",
"need_function",
".",
"__name__",
"if",
"func_name",
... | Registers a new sphinx-needs function for the given sphinx environment.
:param env: Sphinx environment
:param need_function: Python method
:return: None | [
"Registers",
"a",
"new",
"sphinx",
"-",
"needs",
"function",
"for",
"the",
"given",
"sphinx",
"environment",
".",
":",
"param",
"env",
":",
"Sphinx",
"environment",
":",
"param",
"need_function",
":",
"Python",
"method",
":",
"return",
":",
"None"
] | train | https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/functions/functions.py#L26-L45 |
useblocks/sphinxcontrib-needs | sphinxcontrib/needs/functions/functions.py | execute_func | def execute_func(env, need, func_string):
"""
Executes a given function string.
:param env: Sphinx environment
:param need: Actual need, which contains the found function string
:param func_string: string of the found function. Without [[ ]]
:return: return value of executed function
"""
... | python | def execute_func(env, need, func_string):
"""
Executes a given function string.
:param env: Sphinx environment
:param need: Actual need, which contains the found function string
:param func_string: string of the found function. Without [[ ]]
:return: return value of executed function
"""
... | [
"def",
"execute_func",
"(",
"env",
",",
"need",
",",
"func_string",
")",
":",
"func_name",
",",
"func_args",
",",
"func_kwargs",
"=",
"_analyze_func_string",
"(",
"func_string",
")",
"if",
"func_name",
"not",
"in",
"env",
".",
"needs_functions",
".",
"keys",
... | Executes a given function string.
:param env: Sphinx environment
:param need: Actual need, which contains the found function string
:param func_string: string of the found function. Without [[ ]]
:return: return value of executed function | [
"Executes",
"a",
"given",
"function",
"string",
".",
":",
"param",
"env",
":",
"Sphinx",
"environment",
":",
"param",
"need",
":",
"Actual",
"need",
"which",
"contains",
"the",
"found",
"function",
"string",
":",
"param",
"func_string",
":",
"string",
"of",
... | train | https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/functions/functions.py#L48-L73 |
useblocks/sphinxcontrib-needs | sphinxcontrib/needs/functions/functions.py | find_and_replace_node_content | def find_and_replace_node_content(node, env, need):
"""
Search inside a given node and its children for nodes of type Text,
if found check if it contains a function string and run/replace it.
:param node: Node to analyse
:return: None
"""
new_children = []
if not node.children:
... | python | def find_and_replace_node_content(node, env, need):
"""
Search inside a given node and its children for nodes of type Text,
if found check if it contains a function string and run/replace it.
:param node: Node to analyse
:return: None
"""
new_children = []
if not node.children:
... | [
"def",
"find_and_replace_node_content",
"(",
"node",
",",
"env",
",",
"need",
")",
":",
"new_children",
"=",
"[",
"]",
"if",
"not",
"node",
".",
"children",
":",
"if",
"isinstance",
"(",
"node",
",",
"nodes",
".",
"Text",
")",
":",
"func_match",
"=",
"... | Search inside a given node and its children for nodes of type Text,
if found check if it contains a function string and run/replace it.
:param node: Node to analyse
:return: None | [
"Search",
"inside",
"a",
"given",
"node",
"and",
"its",
"children",
"for",
"nodes",
"of",
"type",
"Text",
"if",
"found",
"check",
"if",
"it",
"contains",
"a",
"function",
"string",
"and",
"run",
"/",
"replace",
"it",
"."
] | train | https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/functions/functions.py#L79-L118 |
useblocks/sphinxcontrib-needs | sphinxcontrib/needs/functions/functions.py | resolve_dynamic_values | def resolve_dynamic_values(env):
"""
Resolve dynamic values inside need data.
Rough workflow:
#. Parse all needs and their data for a string like [[ my_func(a,b,c) ]]
#. Extract function name and call parameters
#. Execute registered function name with extracted call parameters
#. Replace ... | python | def resolve_dynamic_values(env):
"""
Resolve dynamic values inside need data.
Rough workflow:
#. Parse all needs and their data for a string like [[ my_func(a,b,c) ]]
#. Extract function name and call parameters
#. Execute registered function name with extracted call parameters
#. Replace ... | [
"def",
"resolve_dynamic_values",
"(",
"env",
")",
":",
"# Only perform calculation if not already done yet",
"if",
"env",
".",
"needs_workflow",
"[",
"'dynamic_values_resolved'",
"]",
":",
"return",
"needs",
"=",
"env",
".",
"needs_all_needs",
"for",
"key",
",",
"need... | Resolve dynamic values inside need data.
Rough workflow:
#. Parse all needs and their data for a string like [[ my_func(a,b,c) ]]
#. Extract function name and call parameters
#. Execute registered function name with extracted call parameters
#. Replace original string with return value
:param... | [
"Resolve",
"dynamic",
"values",
"inside",
"need",
"data",
"."
] | train | https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/functions/functions.py#L121-L191 |
useblocks/sphinxcontrib-needs | sphinxcontrib/needs/functions/functions.py | _analyze_func_string | def _analyze_func_string(func_string):
"""
Analyze given functiion string an extract:
* function name
* function arguments
* function keyword arguments
All given arguments must by of type string, int/float or list.
:param func_string: string of the function
:return: function name, arg... | python | def _analyze_func_string(func_string):
"""
Analyze given functiion string an extract:
* function name
* function arguments
* function keyword arguments
All given arguments must by of type string, int/float or list.
:param func_string: string of the function
:return: function name, arg... | [
"def",
"_analyze_func_string",
"(",
"func_string",
")",
":",
"func",
"=",
"ast",
".",
"parse",
"(",
"func_string",
")",
"try",
":",
"func_call",
"=",
"func",
".",
"body",
"[",
"0",
"]",
".",
"value",
"func_name",
"=",
"func_call",
".",
"func",
".",
"id... | Analyze given functiion string an extract:
* function name
* function arguments
* function keyword arguments
All given arguments must by of type string, int/float or list.
:param func_string: string of the function
:return: function name, arguments, keyword arguments | [
"Analyze",
"given",
"functiion",
"string",
"an",
"extract",
":"
] | train | https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/functions/functions.py#L210-L272 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | run | def run():
"""
Initialize and start objects. This is called automatically when importing the package.
:return none:
"""
# GLOBALS
global cwd, files, logger_start, logger_benchmark, settings, _timeseries_data
_timeseries_data = {}
# files = {".lpd": [ {"full_path", "filename_ext", "filen... | python | def run():
"""
Initialize and start objects. This is called automatically when importing the package.
:return none:
"""
# GLOBALS
global cwd, files, logger_start, logger_benchmark, settings, _timeseries_data
_timeseries_data = {}
# files = {".lpd": [ {"full_path", "filename_ext", "filen... | [
"def",
"run",
"(",
")",
":",
"# GLOBALS",
"global",
"cwd",
",",
"files",
",",
"logger_start",
",",
"logger_benchmark",
",",
"settings",
",",
"_timeseries_data",
"_timeseries_data",
"=",
"{",
"}",
"# files = {\".lpd\": [ {\"full_path\", \"filename_ext\", \"filename_no_ext\... | Initialize and start objects. This is called automatically when importing the package.
:return none: | [
"Initialize",
"and",
"start",
"objects",
".",
"This",
"is",
"called",
"automatically",
"when",
"importing",
"the",
"package",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L28-L45 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | readLipd | def readLipd(usr_path=""):
"""
Read LiPD file(s).
Enter a file path, directory path, or leave args blank to trigger gui.
:param str usr_path: Path to file / directory (optional)
:return dict _d: Metadata
"""
global cwd, settings, files
if settings["verbose"]:
__disclaimer(opt="u... | python | def readLipd(usr_path=""):
"""
Read LiPD file(s).
Enter a file path, directory path, or leave args blank to trigger gui.
:param str usr_path: Path to file / directory (optional)
:return dict _d: Metadata
"""
global cwd, settings, files
if settings["verbose"]:
__disclaimer(opt="u... | [
"def",
"readLipd",
"(",
"usr_path",
"=",
"\"\"",
")",
":",
"global",
"cwd",
",",
"settings",
",",
"files",
"if",
"settings",
"[",
"\"verbose\"",
"]",
":",
"__disclaimer",
"(",
"opt",
"=",
"\"update\"",
")",
"start",
"=",
"clock",
"(",
")",
"files",
"["... | Read LiPD file(s).
Enter a file path, directory path, or leave args blank to trigger gui.
:param str usr_path: Path to file / directory (optional)
:return dict _d: Metadata | [
"Read",
"LiPD",
"file",
"(",
"s",
")",
".",
"Enter",
"a",
"file",
"path",
"directory",
"path",
"or",
"leave",
"args",
"blank",
"to",
"trigger",
"gui",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L48-L65 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | readExcel | def readExcel(usr_path=""):
"""
Read Excel file(s)
Enter a file path, directory path, or leave args blank to trigger gui.
:param str usr_path: Path to file / directory (optional)
:return str cwd: Current working directory
"""
global cwd, files
start = clock()
files[".xls"] = []
... | python | def readExcel(usr_path=""):
"""
Read Excel file(s)
Enter a file path, directory path, or leave args blank to trigger gui.
:param str usr_path: Path to file / directory (optional)
:return str cwd: Current working directory
"""
global cwd, files
start = clock()
files[".xls"] = []
... | [
"def",
"readExcel",
"(",
"usr_path",
"=",
"\"\"",
")",
":",
"global",
"cwd",
",",
"files",
"start",
"=",
"clock",
"(",
")",
"files",
"[",
"\".xls\"",
"]",
"=",
"[",
"]",
"__read",
"(",
"usr_path",
",",
"\".xls\"",
")",
"end",
"=",
"clock",
"(",
")"... | Read Excel file(s)
Enter a file path, directory path, or leave args blank to trigger gui.
:param str usr_path: Path to file / directory (optional)
:return str cwd: Current working directory | [
"Read",
"Excel",
"file",
"(",
"s",
")",
"Enter",
"a",
"file",
"path",
"directory",
"path",
"or",
"leave",
"args",
"blank",
"to",
"trigger",
"gui",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L68-L82 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | excel | def excel():
"""
Convert Excel files to LiPD files. LiPD data is returned directly from this function.
| Example
| 1: lipd.readExcel()
| 2: D = lipd.excel()
:return dict _d: Metadata
"""
global files, cwd, settings
_d = {}
# Turn off verbose. We don't want to clutter the consol... | python | def excel():
"""
Convert Excel files to LiPD files. LiPD data is returned directly from this function.
| Example
| 1: lipd.readExcel()
| 2: D = lipd.excel()
:return dict _d: Metadata
"""
global files, cwd, settings
_d = {}
# Turn off verbose. We don't want to clutter the consol... | [
"def",
"excel",
"(",
")",
":",
"global",
"files",
",",
"cwd",
",",
"settings",
"_d",
"=",
"{",
"}",
"# Turn off verbose. We don't want to clutter the console with extra reading/writing output statements",
"settings",
"[",
"\"verbose\"",
"]",
"=",
"False",
"# Find excel fi... | Convert Excel files to LiPD files. LiPD data is returned directly from this function.
| Example
| 1: lipd.readExcel()
| 2: D = lipd.excel()
:return dict _d: Metadata | [
"Convert",
"Excel",
"files",
"to",
"LiPD",
"files",
".",
"LiPD",
"data",
"is",
"returned",
"directly",
"from",
"this",
"function",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L125-L161 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | noaa | def noaa(D="", path="", wds_url="", lpd_url="", version=""):
"""
Convert between NOAA and LiPD files
| Example: LiPD to NOAA converter
| 1: L = lipd.readLipd()
| 2: lipd.noaa(L, "/Users/someuser/Desktop", "https://www1.ncdc.noaa.gov/pub/data/paleo/pages2k/NAm2kHydro-2017/noaa-templates/data-version... | python | def noaa(D="", path="", wds_url="", lpd_url="", version=""):
"""
Convert between NOAA and LiPD files
| Example: LiPD to NOAA converter
| 1: L = lipd.readLipd()
| 2: lipd.noaa(L, "/Users/someuser/Desktop", "https://www1.ncdc.noaa.gov/pub/data/paleo/pages2k/NAm2kHydro-2017/noaa-templates/data-version... | [
"def",
"noaa",
"(",
"D",
"=",
"\"\"",
",",
"path",
"=",
"\"\"",
",",
"wds_url",
"=",
"\"\"",
",",
"lpd_url",
"=",
"\"\"",
",",
"version",
"=",
"\"\"",
")",
":",
"global",
"files",
",",
"cwd",
"# When going from NOAA to LPD, use the global \"files\" variable.",... | Convert between NOAA and LiPD files
| Example: LiPD to NOAA converter
| 1: L = lipd.readLipd()
| 2: lipd.noaa(L, "/Users/someuser/Desktop", "https://www1.ncdc.noaa.gov/pub/data/paleo/pages2k/NAm2kHydro-2017/noaa-templates/data-version-1.0.0", "https://www1.ncdc.noaa.gov/pub/data/paleo/pages2k/NAm2kHydro-20... | [
"Convert",
"between",
"NOAA",
"and",
"LiPD",
"files"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L164-L229 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | validate | def validate(D, detailed=True):
"""
Use the Validator API for lipd.net to validate all LiPD files in the LiPD Library.
Display the PASS/FAIL results. Display detailed results if the option is chosen.
:param dict D: Metadata (single or multiple datasets)
:param bool detailed: Show or hide the detail... | python | def validate(D, detailed=True):
"""
Use the Validator API for lipd.net to validate all LiPD files in the LiPD Library.
Display the PASS/FAIL results. Display detailed results if the option is chosen.
:param dict D: Metadata (single or multiple datasets)
:param bool detailed: Show or hide the detail... | [
"def",
"validate",
"(",
"D",
",",
"detailed",
"=",
"True",
")",
":",
"start",
"=",
"clock",
"(",
")",
"print",
"(",
"\"\\n\"",
")",
"# Fetch new results by calling lipd.net/api/validator (costly, may take a while)",
"print",
"(",
"\"Fetching results from validator at lipd... | Use the Validator API for lipd.net to validate all LiPD files in the LiPD Library.
Display the PASS/FAIL results. Display detailed results if the option is chosen.
:param dict D: Metadata (single or multiple datasets)
:param bool detailed: Show or hide the detailed results of each LiPD file. Shows warnings... | [
"Use",
"the",
"Validator",
"API",
"for",
"lipd",
".",
"net",
"to",
"validate",
"all",
"LiPD",
"files",
"in",
"the",
"LiPD",
"Library",
".",
"Display",
"the",
"PASS",
"/",
"FAIL",
"results",
".",
"Display",
"detailed",
"results",
"if",
"the",
"option",
"i... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L262-L293 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | tsToDf | def tsToDf(tso):
"""
Create Pandas DataFrame from TimeSeries object.
Use: Must first extractTs to get a time series. Then pick one item from time series and pass it through
:param dict tso: Time series entry
:return dict dfs: Pandas dataframes
"""
dfs = {}
try:
dfs = ts_to_df(ts... | python | def tsToDf(tso):
"""
Create Pandas DataFrame from TimeSeries object.
Use: Must first extractTs to get a time series. Then pick one item from time series and pass it through
:param dict tso: Time series entry
:return dict dfs: Pandas dataframes
"""
dfs = {}
try:
dfs = ts_to_df(ts... | [
"def",
"tsToDf",
"(",
"tso",
")",
":",
"dfs",
"=",
"{",
"}",
"try",
":",
"dfs",
"=",
"ts_to_df",
"(",
"tso",
")",
"except",
"Exception",
"as",
"e",
":",
"print",
"(",
"\"Error: Unable to create data frame\"",
")",
"logger_start",
".",
"warn",
"(",
"\"ts_... | Create Pandas DataFrame from TimeSeries object.
Use: Must first extractTs to get a time series. Then pick one item from time series and pass it through
:param dict tso: Time series entry
:return dict dfs: Pandas dataframes | [
"Create",
"Pandas",
"DataFrame",
"from",
"TimeSeries",
"object",
".",
"Use",
":",
"Must",
"first",
"extractTs",
"to",
"get",
"a",
"time",
"series",
".",
"Then",
"pick",
"one",
"item",
"from",
"time",
"series",
"and",
"pass",
"it",
"through"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L357-L371 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | extractTs | def extractTs(d, whichtables="meas", mode="paleo"):
"""
Create a time series using LiPD data (uses paleoData by default)
| Example : (default) paleoData and meas tables
| 1. D = lipd.readLipd()
| 2. ts = lipd.extractTs(D)
| Example : chronData and all tables
| 1. D = lipd.readLipd()
| ... | python | def extractTs(d, whichtables="meas", mode="paleo"):
"""
Create a time series using LiPD data (uses paleoData by default)
| Example : (default) paleoData and meas tables
| 1. D = lipd.readLipd()
| 2. ts = lipd.extractTs(D)
| Example : chronData and all tables
| 1. D = lipd.readLipd()
| ... | [
"def",
"extractTs",
"(",
"d",
",",
"whichtables",
"=",
"\"meas\"",
",",
"mode",
"=",
"\"paleo\"",
")",
":",
"# instead of storing each raw dataset per tso, store it once in the global scope. saves memory",
"global",
"_timeseries_data",
"_l",
"=",
"[",
"]",
"start",
"=",
... | Create a time series using LiPD data (uses paleoData by default)
| Example : (default) paleoData and meas tables
| 1. D = lipd.readLipd()
| 2. ts = lipd.extractTs(D)
| Example : chronData and all tables
| 1. D = lipd.readLipd()
| 2. ts = lipd.extractTs(D, "all", "chron")
:param dict d: Me... | [
"Create",
"a",
"time",
"series",
"using",
"LiPD",
"data",
"(",
"uses",
"paleoData",
"by",
"default",
")"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L393-L455 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | collapseTs | def collapseTs(ts=None):
"""
Collapse a time series back into LiPD record form.
| Example
| 1. D = lipd.readLipd()
| 2. ts = lipd.extractTs(D)
| 3. New_D = lipd.collapseTs(ts)
_timeseries_data is sorted by time_id, and then by dataSetName
_timeseries_data[10103341]["ODP1098B"] = {data}... | python | def collapseTs(ts=None):
"""
Collapse a time series back into LiPD record form.
| Example
| 1. D = lipd.readLipd()
| 2. ts = lipd.extractTs(D)
| 3. New_D = lipd.collapseTs(ts)
_timeseries_data is sorted by time_id, and then by dataSetName
_timeseries_data[10103341]["ODP1098B"] = {data}... | [
"def",
"collapseTs",
"(",
"ts",
"=",
"None",
")",
":",
"# Retrieve the associated raw data according to the \"time_id\" found in each object. Match it in _timeseries_data",
"global",
"_timeseries_data",
"_d",
"=",
"{",
"}",
"if",
"not",
"ts",
":",
"print",
"(",
"\"Error: Ti... | Collapse a time series back into LiPD record form.
| Example
| 1. D = lipd.readLipd()
| 2. ts = lipd.extractTs(D)
| 3. New_D = lipd.collapseTs(ts)
_timeseries_data is sorted by time_id, and then by dataSetName
_timeseries_data[10103341]["ODP1098B"] = {data}
:param list ts: Time series
... | [
"Collapse",
"a",
"time",
"series",
"back",
"into",
"LiPD",
"record",
"form",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L458-L488 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | filterTs | def filterTs(ts, expressions):
"""
Create a new time series that only contains entries that match the given expression.
| Example:
| D = lipd.loadLipd()
| ts = lipd.extractTs(D)
| new_ts = filterTs(ts, "archiveType == marine sediment")
| new_ts = filterTs(ts, ["paleoData_variableName == sst... | python | def filterTs(ts, expressions):
"""
Create a new time series that only contains entries that match the given expression.
| Example:
| D = lipd.loadLipd()
| ts = lipd.extractTs(D)
| new_ts = filterTs(ts, "archiveType == marine sediment")
| new_ts = filterTs(ts, ["paleoData_variableName == sst... | [
"def",
"filterTs",
"(",
"ts",
",",
"expressions",
")",
":",
"# Make a copy of the ts. We're going to work directly on it.",
"new_ts",
"=",
"ts",
"[",
":",
"]",
"# User provided a single query string",
"if",
"isinstance",
"(",
"expressions",
",",
"str",
")",
":",
"# Us... | Create a new time series that only contains entries that match the given expression.
| Example:
| D = lipd.loadLipd()
| ts = lipd.extractTs(D)
| new_ts = filterTs(ts, "archiveType == marine sediment")
| new_ts = filterTs(ts, ["paleoData_variableName == sst", "archiveType == marine sediment"])
|... | [
"Create",
"a",
"new",
"time",
"series",
"that",
"only",
"contains",
"entries",
"that",
"match",
"the",
"given",
"expression",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L491-L532 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | queryTs | def queryTs(ts, expression):
"""
Find the indices of the time series entries that match the given expression.
| Example:
| D = lipd.loadLipd()
| ts = lipd.extractTs(D)
| matches = queryTs(ts, "archiveType == marine sediment")
| matches = queryTs(ts, "geo_meanElev <= 2000")
:param str e... | python | def queryTs(ts, expression):
"""
Find the indices of the time series entries that match the given expression.
| Example:
| D = lipd.loadLipd()
| ts = lipd.extractTs(D)
| matches = queryTs(ts, "archiveType == marine sediment")
| matches = queryTs(ts, "geo_meanElev <= 2000")
:param str e... | [
"def",
"queryTs",
"(",
"ts",
",",
"expression",
")",
":",
"# Make a copy of the ts. We're going to work directly on it.",
"_idx",
"=",
"[",
"]",
"# User provided a single query string",
"if",
"isinstance",
"(",
"expressions",
",",
"str",
")",
":",
"# Use some magic to tur... | Find the indices of the time series entries that match the given expression.
| Example:
| D = lipd.loadLipd()
| ts = lipd.extractTs(D)
| matches = queryTs(ts, "archiveType == marine sediment")
| matches = queryTs(ts, "geo_meanElev <= 2000")
:param str expression: Expression
:param list ts:... | [
"Find",
"the",
"indices",
"of",
"the",
"time",
"series",
"entries",
"that",
"match",
"the",
"given",
"expression",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L535-L573 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | viewTs | def viewTs(ts):
"""
View the contents of one time series entry in a nicely formatted way
| Example
| 1. D = lipd.readLipd()
| 2. ts = lipd.extractTs(D)
| 3. viewTs(ts[0])
:param dict ts: One time series entry
:return none:
"""
_ts = ts
if isinstance(ts, list):
_ts =... | python | def viewTs(ts):
"""
View the contents of one time series entry in a nicely formatted way
| Example
| 1. D = lipd.readLipd()
| 2. ts = lipd.extractTs(D)
| 3. viewTs(ts[0])
:param dict ts: One time series entry
:return none:
"""
_ts = ts
if isinstance(ts, list):
_ts =... | [
"def",
"viewTs",
"(",
"ts",
")",
":",
"_ts",
"=",
"ts",
"if",
"isinstance",
"(",
"ts",
",",
"list",
")",
":",
"_ts",
"=",
"ts",
"[",
"0",
"]",
"print",
"(",
"\"It looks like you input a full time series. It's best to view one entry at a time.\\n\"",
"\"I'll show y... | View the contents of one time series entry in a nicely formatted way
| Example
| 1. D = lipd.readLipd()
| 2. ts = lipd.extractTs(D)
| 3. viewTs(ts[0])
:param dict ts: One time series entry
:return none: | [
"View",
"the",
"contents",
"of",
"one",
"time",
"series",
"entry",
"in",
"a",
"nicely",
"formatted",
"way"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L576-L626 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | showLipds | def showLipds(D=None):
"""
Display the dataset names of a given LiPD data
| Example
| lipd.showLipds(D)
:pararm dict D: LiPD data
:return none:
"""
if not D:
print("Error: LiPD data not provided. Pass LiPD data into the function.")
else:
print(json.dumps(D.keys(), ... | python | def showLipds(D=None):
"""
Display the dataset names of a given LiPD data
| Example
| lipd.showLipds(D)
:pararm dict D: LiPD data
:return none:
"""
if not D:
print("Error: LiPD data not provided. Pass LiPD data into the function.")
else:
print(json.dumps(D.keys(), ... | [
"def",
"showLipds",
"(",
"D",
"=",
"None",
")",
":",
"if",
"not",
"D",
":",
"print",
"(",
"\"Error: LiPD data not provided. Pass LiPD data into the function.\"",
")",
"else",
":",
"print",
"(",
"json",
".",
"dumps",
"(",
"D",
".",
"keys",
"(",
")",
",",
"i... | Display the dataset names of a given LiPD data
| Example
| lipd.showLipds(D)
:pararm dict D: LiPD data
:return none: | [
"Display",
"the",
"dataset",
"names",
"of",
"a",
"given",
"LiPD",
"data"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L649-L665 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | showMetadata | def showMetadata(dat):
"""
Display the metadata specified LiPD in pretty print
| Example
| showMetadata(D["Africa-ColdAirCave.Sundqvist.2013"])
:param dict dat: Metadata
:return none:
"""
_tmp = rm_values_fields(copy.deepcopy(dat))
print(json.dumps(_tmp, indent=2))
return | python | def showMetadata(dat):
"""
Display the metadata specified LiPD in pretty print
| Example
| showMetadata(D["Africa-ColdAirCave.Sundqvist.2013"])
:param dict dat: Metadata
:return none:
"""
_tmp = rm_values_fields(copy.deepcopy(dat))
print(json.dumps(_tmp, indent=2))
return | [
"def",
"showMetadata",
"(",
"dat",
")",
":",
"_tmp",
"=",
"rm_values_fields",
"(",
"copy",
".",
"deepcopy",
"(",
"dat",
")",
")",
"print",
"(",
"json",
".",
"dumps",
"(",
"_tmp",
",",
"indent",
"=",
"2",
")",
")",
"return"
] | Display the metadata specified LiPD in pretty print
| Example
| showMetadata(D["Africa-ColdAirCave.Sundqvist.2013"])
:param dict dat: Metadata
:return none: | [
"Display",
"the",
"metadata",
"specified",
"LiPD",
"in",
"pretty",
"print"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L668-L680 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | showDfs | def showDfs(d):
"""
Display the available data frame names in a given data frame collection
:param dict d: Dataframe collection
:return none:
"""
if "metadata" in d:
print("metadata")
if "paleoData" in d:
try:
for k, v in d["paleoData"].items():
p... | python | def showDfs(d):
"""
Display the available data frame names in a given data frame collection
:param dict d: Dataframe collection
:return none:
"""
if "metadata" in d:
print("metadata")
if "paleoData" in d:
try:
for k, v in d["paleoData"].items():
p... | [
"def",
"showDfs",
"(",
"d",
")",
":",
"if",
"\"metadata\"",
"in",
"d",
":",
"print",
"(",
"\"metadata\"",
")",
"if",
"\"paleoData\"",
"in",
"d",
":",
"try",
":",
"for",
"k",
",",
"v",
"in",
"d",
"[",
"\"paleoData\"",
"]",
".",
"items",
"(",
")",
... | Display the available data frame names in a given data frame collection
:param dict d: Dataframe collection
:return none: | [
"Display",
"the",
"available",
"data",
"frame",
"names",
"in",
"a",
"given",
"data",
"frame",
"collection"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L683-L709 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | getLipdNames | def getLipdNames(D=None):
"""
Get a list of all LiPD names in the library
| Example
| names = lipd.getLipdNames(D)
:return list f_list: File list
"""
_names = []
try:
if not D:
print("Error: LiPD data not provided. Pass LiPD data into the function.")
else:
... | python | def getLipdNames(D=None):
"""
Get a list of all LiPD names in the library
| Example
| names = lipd.getLipdNames(D)
:return list f_list: File list
"""
_names = []
try:
if not D:
print("Error: LiPD data not provided. Pass LiPD data into the function.")
else:
... | [
"def",
"getLipdNames",
"(",
"D",
"=",
"None",
")",
":",
"_names",
"=",
"[",
"]",
"try",
":",
"if",
"not",
"D",
":",
"print",
"(",
"\"Error: LiPD data not provided. Pass LiPD data into the function.\"",
")",
"else",
":",
"_names",
"=",
"D",
".",
"keys",
"(",
... | Get a list of all LiPD names in the library
| Example
| names = lipd.getLipdNames(D)
:return list f_list: File list | [
"Get",
"a",
"list",
"of",
"all",
"LiPD",
"names",
"in",
"the",
"library"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L714-L731 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | getMetadata | def getMetadata(L):
"""
Get metadata from a LiPD data in memory
| Example
| m = lipd.getMetadata(D["Africa-ColdAirCave.Sundqvist.2013"])
:param dict L: One LiPD record
:return dict d: LiPD record (metadata only)
"""
_l = {}
try:
# Create a copy. Do not affect the original d... | python | def getMetadata(L):
"""
Get metadata from a LiPD data in memory
| Example
| m = lipd.getMetadata(D["Africa-ColdAirCave.Sundqvist.2013"])
:param dict L: One LiPD record
:return dict d: LiPD record (metadata only)
"""
_l = {}
try:
# Create a copy. Do not affect the original d... | [
"def",
"getMetadata",
"(",
"L",
")",
":",
"_l",
"=",
"{",
"}",
"try",
":",
"# Create a copy. Do not affect the original data.",
"_l",
"=",
"copy",
".",
"deepcopy",
"(",
"L",
")",
"# Remove values fields",
"_l",
"=",
"rm_values_fields",
"(",
"_l",
")",
"except"... | Get metadata from a LiPD data in memory
| Example
| m = lipd.getMetadata(D["Africa-ColdAirCave.Sundqvist.2013"])
:param dict L: One LiPD record
:return dict d: LiPD record (metadata only) | [
"Get",
"metadata",
"from",
"a",
"LiPD",
"data",
"in",
"memory"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L734-L753 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | getCsv | def getCsv(L=None):
"""
Get CSV from LiPD metadata
| Example
| c = lipd.getCsv(D["Africa-ColdAirCave.Sundqvist.2013"])
:param dict L: One LiPD record
:return dict d: CSV data
"""
_c = {}
try:
if not L:
print("Error: LiPD data not provided. Pass LiPD data into th... | python | def getCsv(L=None):
"""
Get CSV from LiPD metadata
| Example
| c = lipd.getCsv(D["Africa-ColdAirCave.Sundqvist.2013"])
:param dict L: One LiPD record
:return dict d: CSV data
"""
_c = {}
try:
if not L:
print("Error: LiPD data not provided. Pass LiPD data into th... | [
"def",
"getCsv",
"(",
"L",
"=",
"None",
")",
":",
"_c",
"=",
"{",
"}",
"try",
":",
"if",
"not",
"L",
":",
"print",
"(",
"\"Error: LiPD data not provided. Pass LiPD data into the function.\"",
")",
"else",
":",
"_j",
",",
"_c",
"=",
"get_csv_from_metadata",
"... | Get CSV from LiPD metadata
| Example
| c = lipd.getCsv(D["Africa-ColdAirCave.Sundqvist.2013"])
:param dict L: One LiPD record
:return dict d: CSV data | [
"Get",
"CSV",
"from",
"LiPD",
"metadata"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L756-L777 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | writeLipd | def writeLipd(dat, path=""):
"""
Write LiPD data to file(s)
:param dict dat: Metadata
:param str path: Destination (optional)
:return none:
"""
global settings
start = clock()
__write_lipd(dat, path)
end = clock()
logger_benchmark.info(log_benchmark("writeLipd", start, end))... | python | def writeLipd(dat, path=""):
"""
Write LiPD data to file(s)
:param dict dat: Metadata
:param str path: Destination (optional)
:return none:
"""
global settings
start = clock()
__write_lipd(dat, path)
end = clock()
logger_benchmark.info(log_benchmark("writeLipd", start, end))... | [
"def",
"writeLipd",
"(",
"dat",
",",
"path",
"=",
"\"\"",
")",
":",
"global",
"settings",
"start",
"=",
"clock",
"(",
")",
"__write_lipd",
"(",
"dat",
",",
"path",
")",
"end",
"=",
"clock",
"(",
")",
"logger_benchmark",
".",
"info",
"(",
"log_benchmark... | Write LiPD data to file(s)
:param dict dat: Metadata
:param str path: Destination (optional)
:return none: | [
"Write",
"LiPD",
"data",
"to",
"file",
"(",
"s",
")"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L782-L795 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | __universal_read | def __universal_read(file_path, file_type):
"""
Use a file path to create file metadata and load a file in the appropriate way, according to the provided file type.
:param str file_path: Path to file
:param str file_type: One of approved file types: xls, xlsx, txt, lpd
:return none:
"""
glo... | python | def __universal_read(file_path, file_type):
"""
Use a file path to create file metadata and load a file in the appropriate way, according to the provided file type.
:param str file_path: Path to file
:param str file_type: One of approved file types: xls, xlsx, txt, lpd
:return none:
"""
glo... | [
"def",
"__universal_read",
"(",
"file_path",
",",
"file_type",
")",
":",
"global",
"files",
",",
"cwd",
",",
"settings",
"# check that we are using the correct function to load this file type. (i.e. readNoaa for a .txt file)",
"correct_ext",
"=",
"load_fn_matches_ext",
"(",
"fi... | Use a file path to create file metadata and load a file in the appropriate way, according to the provided file type.
:param str file_path: Path to file
:param str file_type: One of approved file types: xls, xlsx, txt, lpd
:return none: | [
"Use",
"a",
"file",
"path",
"to",
"create",
"file",
"metadata",
"and",
"load",
"a",
"file",
"in",
"the",
"appropriate",
"way",
"according",
"to",
"the",
"provided",
"file",
"type",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L801-L843 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | __read | def __read(usr_path, file_type):
"""
Determine what path needs to be taken to read in file(s)
:param str usr_path: Path (optional)
:param str file_type: File type to read
:return none:
"""
# is there a file path specified ?
if usr_path:
# Is this a URL? Download the file and re... | python | def __read(usr_path, file_type):
"""
Determine what path needs to be taken to read in file(s)
:param str usr_path: Path (optional)
:param str file_type: File type to read
:return none:
"""
# is there a file path specified ?
if usr_path:
# Is this a URL? Download the file and re... | [
"def",
"__read",
"(",
"usr_path",
",",
"file_type",
")",
":",
"# is there a file path specified ?",
"if",
"usr_path",
":",
"# Is this a URL? Download the file and return the local path",
"is_url",
"=",
"re",
".",
"match",
"(",
"re_url",
",",
"usr_path",
")",
"if",
"is... | Determine what path needs to be taken to read in file(s)
:param str usr_path: Path (optional)
:param str file_type: File type to read
:return none: | [
"Determine",
"what",
"path",
"needs",
"to",
"be",
"taken",
"to",
"read",
"in",
"file",
"(",
"s",
")"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L846-L897 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | __read_lipd_contents | def __read_lipd_contents():
"""
Use the file metadata to read in the LiPD file contents as a dataset library
:return dict: Metadata
"""
global files, settings
_d = {}
try:
if len(files[".lpd"]) == 1:
_d = lipd_read(files[".lpd"][0]["full_path"])
if settings["... | python | def __read_lipd_contents():
"""
Use the file metadata to read in the LiPD file contents as a dataset library
:return dict: Metadata
"""
global files, settings
_d = {}
try:
if len(files[".lpd"]) == 1:
_d = lipd_read(files[".lpd"][0]["full_path"])
if settings["... | [
"def",
"__read_lipd_contents",
"(",
")",
":",
"global",
"files",
",",
"settings",
"_d",
"=",
"{",
"}",
"try",
":",
"if",
"len",
"(",
"files",
"[",
"\".lpd\"",
"]",
")",
"==",
"1",
":",
"_d",
"=",
"lipd_read",
"(",
"files",
"[",
"\".lpd\"",
"]",
"["... | Use the file metadata to read in the LiPD file contents as a dataset library
:return dict: Metadata | [
"Use",
"the",
"file",
"metadata",
"to",
"read",
"in",
"the",
"LiPD",
"file",
"contents",
"as",
"a",
"dataset",
"library"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L900-L920 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | __read_file | def __read_file(usr_path, file_type):
"""
Universal read file. Given a path and a type, it will do the appropriate read actions
:param str usr_path: Path to file
:param str file_type: One of approved file types: xls, xlsx, txt, lpd
:return none:
"""
global files
# no path provided. sta... | python | def __read_file(usr_path, file_type):
"""
Universal read file. Given a path and a type, it will do the appropriate read actions
:param str usr_path: Path to file
:param str file_type: One of approved file types: xls, xlsx, txt, lpd
:return none:
"""
global files
# no path provided. sta... | [
"def",
"__read_file",
"(",
"usr_path",
",",
"file_type",
")",
":",
"global",
"files",
"# no path provided. start gui browse",
"if",
"not",
"usr_path",
":",
"# src files could be a list of one, or a list of many. depending how many files the user selects",
"src_dir",
",",
"src_fil... | Universal read file. Given a path and a type, it will do the appropriate read actions
:param str usr_path: Path to file
:param str file_type: One of approved file types: xls, xlsx, txt, lpd
:return none: | [
"Universal",
"read",
"file",
".",
"Given",
"a",
"path",
"and",
"a",
"type",
"it",
"will",
"do",
"the",
"appropriate",
"read",
"actions"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L923-L946 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | __read_directory | def __read_directory(usr_path, file_type):
"""
Universal read directory. Given a path and a type, it will do the appropriate read actions
:param str usr_path: Path to directory
:param str file_type: .xls, .xlsx, .txt, .lpd
:return none:
"""
# no path provided. start gui browse
if not us... | python | def __read_directory(usr_path, file_type):
"""
Universal read directory. Given a path and a type, it will do the appropriate read actions
:param str usr_path: Path to directory
:param str file_type: .xls, .xlsx, .txt, .lpd
:return none:
"""
# no path provided. start gui browse
if not us... | [
"def",
"__read_directory",
"(",
"usr_path",
",",
"file_type",
")",
":",
"# no path provided. start gui browse",
"if",
"not",
"usr_path",
":",
"# got dir path",
"usr_path",
",",
"src_files",
"=",
"get_src_or_dst",
"(",
"\"read\"",
",",
"\"directory\"",
")",
"# Check if... | Universal read directory. Given a path and a type, it will do the appropriate read actions
:param str usr_path: Path to directory
:param str file_type: .xls, .xlsx, .txt, .lpd
:return none: | [
"Universal",
"read",
"directory",
".",
"Given",
"a",
"path",
"and",
"a",
"type",
"it",
"will",
"do",
"the",
"appropriate",
"read",
"actions"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L949-L981 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | __write_lipd | def __write_lipd(dat, usr_path):
"""
Write LiPD data to file, provided an output directory and dataset name.
:param dict dat: Metadata
:param str usr_path: Destination path
:param str dsn: Dataset name of one specific file to write
:return none:
"""
global settings
# no path provide... | python | def __write_lipd(dat, usr_path):
"""
Write LiPD data to file, provided an output directory and dataset name.
:param dict dat: Metadata
:param str usr_path: Destination path
:param str dsn: Dataset name of one specific file to write
:return none:
"""
global settings
# no path provide... | [
"def",
"__write_lipd",
"(",
"dat",
",",
"usr_path",
")",
":",
"global",
"settings",
"# no path provided. start gui browse",
"if",
"not",
"usr_path",
":",
"# got dir path",
"usr_path",
",",
"_ignore",
"=",
"get_src_or_dst",
"(",
"\"write\"",
",",
"\"directory\"",
")"... | Write LiPD data to file, provided an output directory and dataset name.
:param dict dat: Metadata
:param str usr_path: Destination path
:param str dsn: Dataset name of one specific file to write
:return none: | [
"Write",
"LiPD",
"data",
"to",
"file",
"provided",
"an",
"output",
"directory",
"and",
"dataset",
"name",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L984-L1023 |
nickmckay/LiPD-utilities | Python/lipd/__init__.py | __disclaimer | def __disclaimer(opt=""):
"""
Print the disclaimers once. If they've already been shown, skip over.
:return none:
"""
global settings
if opt is "update":
print("Disclaimer: LiPD files may be updated and modified to adhere to standards\n")
settings["note_update"] = False
if o... | python | def __disclaimer(opt=""):
"""
Print the disclaimers once. If they've already been shown, skip over.
:return none:
"""
global settings
if opt is "update":
print("Disclaimer: LiPD files may be updated and modified to adhere to standards\n")
settings["note_update"] = False
if o... | [
"def",
"__disclaimer",
"(",
"opt",
"=",
"\"\"",
")",
":",
"global",
"settings",
"if",
"opt",
"is",
"\"update\"",
":",
"print",
"(",
"\"Disclaimer: LiPD files may be updated and modified to adhere to standards\\n\"",
")",
"settings",
"[",
"\"note_update\"",
"]",
"=",
"... | Print the disclaimers once. If they've already been shown, skip over.
:return none: | [
"Print",
"the",
"disclaimers",
"once",
".",
"If",
"they",
"ve",
"already",
"been",
"shown",
"skip",
"over",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/__init__.py#L1026-L1040 |
useblocks/sphinxcontrib-needs | sphinxcontrib/needs/environment.py | safe_add_file | def safe_add_file(filename, app):
"""
Adds files to builder resources only, if the given filename was not already registered.
Needed mainly for tests to avoid multiple registration of the same file and therefore also multiple execution
of e.g. a javascript file during page load.
:param filename: fi... | python | def safe_add_file(filename, app):
"""
Adds files to builder resources only, if the given filename was not already registered.
Needed mainly for tests to avoid multiple registration of the same file and therefore also multiple execution
of e.g. a javascript file during page load.
:param filename: fi... | [
"def",
"safe_add_file",
"(",
"filename",
",",
"app",
")",
":",
"data_file",
"=",
"filename",
"static_data_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"\"_static\"",
",",
"data_file",
")",
"if",
"data_file",
".",
"split",
"(",
"\".\"",
")",
"[",
"-",... | Adds files to builder resources only, if the given filename was not already registered.
Needed mainly for tests to avoid multiple registration of the same file and therefore also multiple execution
of e.g. a javascript file during page load.
:param filename: filename to remove
:param app: app object
... | [
"Adds",
"files",
"to",
"builder",
"resources",
"only",
"if",
"the",
"given",
"filename",
"was",
"not",
"already",
"registered",
".",
"Needed",
"mainly",
"for",
"tests",
"to",
"avoid",
"multiple",
"registration",
"of",
"the",
"same",
"file",
"and",
"therefore",... | train | https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/environment.py#L19-L39 |
useblocks/sphinxcontrib-needs | sphinxcontrib/needs/environment.py | safe_remove_file | def safe_remove_file(filename, app):
"""
Removes a given resource file from builder resources.
Needed mostly during test, if multiple sphinx-build are started.
During these tests js/cass-files are not cleaned, so a css_file from run A is still registered in run B.
:param filename: filename to remov... | python | def safe_remove_file(filename, app):
"""
Removes a given resource file from builder resources.
Needed mostly during test, if multiple sphinx-build are started.
During these tests js/cass-files are not cleaned, so a css_file from run A is still registered in run B.
:param filename: filename to remov... | [
"def",
"safe_remove_file",
"(",
"filename",
",",
"app",
")",
":",
"data_file",
"=",
"filename",
"static_data_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"\"_static\"",
",",
"data_file",
")",
"if",
"data_file",
".",
"split",
"(",
"\".\"",
")",
"[",
"... | Removes a given resource file from builder resources.
Needed mostly during test, if multiple sphinx-build are started.
During these tests js/cass-files are not cleaned, so a css_file from run A is still registered in run B.
:param filename: filename to remove
:param app: app object
:return: None | [
"Removes",
"a",
"given",
"resource",
"file",
"from",
"builder",
"resources",
".",
"Needed",
"mostly",
"during",
"test",
"if",
"multiple",
"sphinx",
"-",
"build",
"are",
"started",
".",
"During",
"these",
"tests",
"js",
"/",
"cass",
"-",
"files",
"are",
"no... | train | https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/environment.py#L42-L60 |
dchaplinsky/unshred | unshred/sheet.py | Sheet.get_shreds | def get_shreds(self, feature_extractors, sheet_name):
"""Detects shreds in the current sheet and constructs Shred instances.
Caches the results for further invocations.
Args:
feature_extractors: iterable of AbstractShredFeature instances to
use for shreds feature as... | python | def get_shreds(self, feature_extractors, sheet_name):
"""Detects shreds in the current sheet and constructs Shred instances.
Caches the results for further invocations.
Args:
feature_extractors: iterable of AbstractShredFeature instances to
use for shreds feature as... | [
"def",
"get_shreds",
"(",
"self",
",",
"feature_extractors",
",",
"sheet_name",
")",
":",
"if",
"self",
".",
"_shreds",
"is",
"None",
":",
"shreds",
"=",
"[",
"]",
"_",
",",
"contours",
",",
"_",
"=",
"cv2",
".",
"findContours",
"(",
"self",
".",
"_f... | Detects shreds in the current sheet and constructs Shred instances.
Caches the results for further invocations.
Args:
feature_extractors: iterable of AbstractShredFeature instances to
use for shreds feature assignment.
sheet_name: string, included in shred attri... | [
"Detects",
"shreds",
"in",
"the",
"current",
"sheet",
"and",
"constructs",
"Shred",
"instances",
"."
] | train | https://github.com/dchaplinsky/unshred/blob/ca9cd6a1c6fb8c77d5424dd660ff5d2f3720c0f8/unshred/sheet.py#L78-L102 |
dchaplinsky/unshred | unshred/sheet.py | Sheet._make_shred | def _make_shred(self, c, name, feature_extractors, sheet_name):
"""Creates a Shred instances from a given contour.
Args:
c: cv2 contour object.
name: string shred name within a sheet.
feature_extractors: iterable of AbstractShredFeature instances.
Returns:
... | python | def _make_shred(self, c, name, feature_extractors, sheet_name):
"""Creates a Shred instances from a given contour.
Args:
c: cv2 contour object.
name: string shred name within a sheet.
feature_extractors: iterable of AbstractShredFeature instances.
Returns:
... | [
"def",
"_make_shred",
"(",
"self",
",",
"c",
",",
"name",
",",
"feature_extractors",
",",
"sheet_name",
")",
":",
"height",
",",
"width",
",",
"channels",
"=",
"self",
".",
"orig_img",
".",
"shape",
"# bounding rect of currrent contour",
"r_x",
",",
"r_y",
"... | Creates a Shred instances from a given contour.
Args:
c: cv2 contour object.
name: string shred name within a sheet.
feature_extractors: iterable of AbstractShredFeature instances.
Returns:
A new Shred instance or None on failure. | [
"Creates",
"a",
"Shred",
"instances",
"from",
"a",
"given",
"contour",
"."
] | train | https://github.com/dchaplinsky/unshred/blob/ca9cd6a1c6fb8c77d5424dd660ff5d2f3720c0f8/unshred/sheet.py#L244-L375 |
mfussenegger/cr8 | cr8/fake_providers.py | GeoSpatialProvider.geo_shape | def geo_shape(self, sides=5, center=None, distance=None):
"""
Return a WKT string for a POLYGON with given amount of sides.
The polygon is defined by its center (random point if not provided) and
the distance (random distance if not provided; in km) of the points to
its center.
... | python | def geo_shape(self, sides=5, center=None, distance=None):
"""
Return a WKT string for a POLYGON with given amount of sides.
The polygon is defined by its center (random point if not provided) and
the distance (random distance if not provided; in km) of the points to
its center.
... | [
"def",
"geo_shape",
"(",
"self",
",",
"sides",
"=",
"5",
",",
"center",
"=",
"None",
",",
"distance",
"=",
"None",
")",
":",
"assert",
"isinstance",
"(",
"sides",
",",
"int",
")",
"if",
"distance",
"is",
"None",
":",
"distance",
"=",
"self",
".",
"... | Return a WKT string for a POLYGON with given amount of sides.
The polygon is defined by its center (random point if not provided) and
the distance (random distance if not provided; in km) of the points to
its center. | [
"Return",
"a",
"WKT",
"string",
"for",
"a",
"POLYGON",
"with",
"given",
"amount",
"of",
"sides",
".",
"The",
"polygon",
"is",
"defined",
"by",
"its",
"center",
"(",
"random",
"point",
"if",
"not",
"provided",
")",
"and",
"the",
"distance",
"(",
"random",... | train | https://github.com/mfussenegger/cr8/blob/a37d6049f1f9fee2d0556efae2b7b7f8761bffe8/cr8/fake_providers.py#L106-L139 |
mfussenegger/cr8 | cr8/run_track.py | run_track | def run_track(track,
result_hosts=None,
crate_root=None,
output_fmt=None,
logfile_info=None,
logfile_result=None,
failfast=False,
sample_mode='reservoir'):
"""Execute a track file"""
with Logger(output_fmt=output_f... | python | def run_track(track,
result_hosts=None,
crate_root=None,
output_fmt=None,
logfile_info=None,
logfile_result=None,
failfast=False,
sample_mode='reservoir'):
"""Execute a track file"""
with Logger(output_fmt=output_f... | [
"def",
"run_track",
"(",
"track",
",",
"result_hosts",
"=",
"None",
",",
"crate_root",
"=",
"None",
",",
"output_fmt",
"=",
"None",
",",
"logfile_info",
"=",
"None",
",",
"logfile_result",
"=",
"None",
",",
"failfast",
"=",
"False",
",",
"sample_mode",
"="... | Execute a track file | [
"Execute",
"a",
"track",
"file"
] | train | https://github.com/mfussenegger/cr8/blob/a37d6049f1f9fee2d0556efae2b7b7f8761bffe8/cr8/run_track.py#L104-L126 |
nickmckay/LiPD-utilities | Python/lipd/noaa_lpd.py | NOAA_LPD.main | def main(self):
"""
Convert a NOAA text file into a lipds file.
CSV files will be created if chronology or data sections are available.
:return dict: Metadata Dictionary
"""
logger_noaa_lpd.info("enter main")
# Run the file through the parser
# Sets self.m... | python | def main(self):
"""
Convert a NOAA text file into a lipds file.
CSV files will be created if chronology or data sections are available.
:return dict: Metadata Dictionary
"""
logger_noaa_lpd.info("enter main")
# Run the file through the parser
# Sets self.m... | [
"def",
"main",
"(",
"self",
")",
":",
"logger_noaa_lpd",
".",
"info",
"(",
"\"enter main\"",
")",
"# Run the file through the parser",
"# Sets self.metadata, Creates CSVs in dir_tmp",
"os",
".",
"chdir",
"(",
"self",
".",
"dir_tmp",
")",
"os",
".",
"mkdir",
"(",
"... | Convert a NOAA text file into a lipds file.
CSV files will be created if chronology or data sections are available.
:return dict: Metadata Dictionary | [
"Convert",
"a",
"NOAA",
"text",
"file",
"into",
"a",
"lipds",
"file",
".",
"CSV",
"files",
"will",
"be",
"created",
"if",
"chronology",
"or",
"data",
"sections",
"are",
"available",
".",
":",
"return",
"dict",
":",
"Metadata",
"Dictionary"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa_lpd.py#L29-L48 |
nickmckay/LiPD-utilities | Python/lipd/noaa_lpd.py | NOAA_LPD.__parse | def __parse(self):
"""
Parse
Accept the text file. We'll open it, read it, and return a compiled dictionary to write to a json file
May write a chronology CSV and a data CSV if those sections are available
:return:
"""
logger_noaa_lpd.info("enter parse")
... | python | def __parse(self):
"""
Parse
Accept the text file. We'll open it, read it, and return a compiled dictionary to write to a json file
May write a chronology CSV and a data CSV if those sections are available
:return:
"""
logger_noaa_lpd.info("enter parse")
... | [
"def",
"__parse",
"(",
"self",
")",
":",
"logger_noaa_lpd",
".",
"info",
"(",
"\"enter parse\"",
")",
"# Strings",
"missing_str",
"=",
"''",
"data_filename",
"=",
"''",
"# Counters",
"grant_id",
"=",
"0",
"funding_id",
"=",
"0",
"data_col_ct",
"=",
"1",
"lin... | Parse
Accept the text file. We'll open it, read it, and return a compiled dictionary to write to a json file
May write a chronology CSV and a data CSV if those sections are available
:return: | [
"Parse",
"Accept",
"the",
"text",
"file",
".",
"We",
"ll",
"open",
"it",
"read",
"it",
"and",
"return",
"a",
"compiled",
"dictionary",
"to",
"write",
"to",
"a",
"json",
"file",
"May",
"write",
"a",
"chronology",
"CSV",
"and",
"a",
"data",
"CSV",
"if",
... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa_lpd.py#L50-L492 |
nickmckay/LiPD-utilities | Python/lipd/noaa_lpd.py | NOAA_LPD.__create_paleo_col | def __create_paleo_col(l, col_count):
"""
Receive split list from separate_data_vars, and turn it into a dictionary for that column
:param list l:
:param int col_count:
:return dict:
"""
# Format: what, material, error, units, seasonality, archive, detail, method,... | python | def __create_paleo_col(l, col_count):
"""
Receive split list from separate_data_vars, and turn it into a dictionary for that column
:param list l:
:param int col_count:
:return dict:
"""
# Format: what, material, error, units, seasonality, archive, detail, method,... | [
"def",
"__create_paleo_col",
"(",
"l",
",",
"col_count",
")",
":",
"# Format: what, material, error, units, seasonality, archive, detail, method,",
"# C or N for Character or Numeric data, direction of relation to climate (positive or negative)",
"d",
"=",
"OrderedDict",
"(",
")",
"d",... | Receive split list from separate_data_vars, and turn it into a dictionary for that column
:param list l:
:param int col_count:
:return dict: | [
"Receive",
"split",
"list",
"from",
"separate_data_vars",
"and",
"turn",
"it",
"into",
"a",
"dictionary",
"for",
"that",
"column",
":",
"param",
"list",
"l",
":",
":",
"param",
"int",
"col_count",
":",
":",
"return",
"dict",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa_lpd.py#L495-L519 |
nickmckay/LiPD-utilities | Python/lipd/noaa_lpd.py | NOAA_LPD.__separate_data_vars | def __separate_data_vars(line):
"""
For the variables section, clean up the line and return a list of each of the 10 items
:param str line:
:return str:
"""
combine = []
if '#' in line:
line = line.replace("#", "")
line = line.lstrip()
... | python | def __separate_data_vars(line):
"""
For the variables section, clean up the line and return a list of each of the 10 items
:param str line:
:return str:
"""
combine = []
if '#' in line:
line = line.replace("#", "")
line = line.lstrip()
... | [
"def",
"__separate_data_vars",
"(",
"line",
")",
":",
"combine",
"=",
"[",
"]",
"if",
"'#'",
"in",
"line",
":",
"line",
"=",
"line",
".",
"replace",
"(",
"\"#\"",
",",
"\"\"",
")",
"line",
"=",
"line",
".",
"lstrip",
"(",
")",
"if",
"line",
"not",
... | For the variables section, clean up the line and return a list of each of the 10 items
:param str line:
:return str: | [
"For",
"the",
"variables",
"section",
"clean",
"up",
"the",
"line",
"and",
"return",
"a",
"list",
"of",
"each",
"of",
"the",
"10",
"items",
":",
"param",
"str",
"line",
":",
":",
"return",
"str",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa_lpd.py#L522-L543 |
nickmckay/LiPD-utilities | Python/lipd/noaa_lpd.py | NOAA_LPD.__convert_num | def __convert_num(number):
"""
All path items are automatically strings. If you think it's an int or float, this attempts to convert it.
:param str number:
:return float or str:
"""
try:
return float(number)
except ValueError as e:
logger_n... | python | def __convert_num(number):
"""
All path items are automatically strings. If you think it's an int or float, this attempts to convert it.
:param str number:
:return float or str:
"""
try:
return float(number)
except ValueError as e:
logger_n... | [
"def",
"__convert_num",
"(",
"number",
")",
":",
"try",
":",
"return",
"float",
"(",
"number",
")",
"except",
"ValueError",
"as",
"e",
":",
"logger_noaa_lpd",
".",
"warn",
"(",
"\"convert_num: ValueError: {}\"",
".",
"format",
"(",
"e",
")",
")",
"return",
... | All path items are automatically strings. If you think it's an int or float, this attempts to convert it.
:param str number:
:return float or str: | [
"All",
"path",
"items",
"are",
"automatically",
"strings",
".",
"If",
"you",
"think",
"it",
"s",
"an",
"int",
"or",
"float",
"this",
"attempts",
"to",
"convert",
"it",
".",
":",
"param",
"str",
"number",
":",
":",
"return",
"float",
"or",
"str",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa_lpd.py#L546-L556 |
nickmckay/LiPD-utilities | Python/lipd/noaa_lpd.py | NOAA_LPD.__camel_case | def __camel_case(word):
"""
Convert underscore naming into camel case naming
:param str word:
:return str:
"""
word = word.lower()
if '_' in word:
split_word = word.split('_')
else:
split_word = word.split()
if len(split_wor... | python | def __camel_case(word):
"""
Convert underscore naming into camel case naming
:param str word:
:return str:
"""
word = word.lower()
if '_' in word:
split_word = word.split('_')
else:
split_word = word.split()
if len(split_wor... | [
"def",
"__camel_case",
"(",
"word",
")",
":",
"word",
"=",
"word",
".",
"lower",
"(",
")",
"if",
"'_'",
"in",
"word",
":",
"split_word",
"=",
"word",
".",
"split",
"(",
"'_'",
")",
"else",
":",
"split_word",
"=",
"word",
".",
"split",
"(",
")",
"... | Convert underscore naming into camel case naming
:param str word:
:return str: | [
"Convert",
"underscore",
"naming",
"into",
"camel",
"case",
"naming",
":",
"param",
"str",
"word",
":",
":",
"return",
"str",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa_lpd.py#L559-L575 |
nickmckay/LiPD-utilities | Python/lipd/noaa_lpd.py | NOAA_LPD.__name_unit_regex | def __name_unit_regex(word):
"""
Split a name and unit that are bunched together (i.e. '250m')
:param str word:
:return str str:
"""
value = ""
unit = ""
r = re.findall(re_name_unit, word)
try:
value = r[0][0]
except IndexError ... | python | def __name_unit_regex(word):
"""
Split a name and unit that are bunched together (i.e. '250m')
:param str word:
:return str str:
"""
value = ""
unit = ""
r = re.findall(re_name_unit, word)
try:
value = r[0][0]
except IndexError ... | [
"def",
"__name_unit_regex",
"(",
"word",
")",
":",
"value",
"=",
"\"\"",
"unit",
"=",
"\"\"",
"r",
"=",
"re",
".",
"findall",
"(",
"re_name_unit",
",",
"word",
")",
"try",
":",
"value",
"=",
"r",
"[",
"0",
"]",
"[",
"0",
"]",
"except",
"IndexError"... | Split a name and unit that are bunched together (i.e. '250m')
:param str word:
:return str str: | [
"Split",
"a",
"name",
"and",
"unit",
"that",
"are",
"bunched",
"together",
"(",
"i",
".",
"e",
".",
"250m",
")",
":",
"param",
"str",
"word",
":",
":",
"return",
"str",
"str",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa_lpd.py#L578-L603 |
nickmckay/LiPD-utilities | Python/lipd/noaa_lpd.py | NOAA_LPD.__split_name_unit | def __split_name_unit(self, line):
"""
Split a string that has value and unit as one.
:param str line:
:return str str:
"""
vals = []
unit = ''
if line != '' or line != ' ':
# If there are parenthesis, remove them
line = line.replac... | python | def __split_name_unit(self, line):
"""
Split a string that has value and unit as one.
:param str line:
:return str str:
"""
vals = []
unit = ''
if line != '' or line != ' ':
# If there are parenthesis, remove them
line = line.replac... | [
"def",
"__split_name_unit",
"(",
"self",
",",
"line",
")",
":",
"vals",
"=",
"[",
"]",
"unit",
"=",
"''",
"if",
"line",
"!=",
"''",
"or",
"line",
"!=",
"' '",
":",
"# If there are parenthesis, remove them",
"line",
"=",
"line",
".",
"replace",
"(",
"'('"... | Split a string that has value and unit as one.
:param str line:
:return str str: | [
"Split",
"a",
"string",
"that",
"has",
"value",
"and",
"unit",
"as",
"one",
".",
":",
"param",
"str",
"line",
":",
":",
"return",
"str",
"str",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa_lpd.py#L614-L644 |
nickmckay/LiPD-utilities | Python/lipd/noaa_lpd.py | NOAA_LPD.__str_cleanup | def __str_cleanup(line):
"""
Remove the unnecessary characters in the line that we don't want
:param str line:
:return str:
"""
if '#' in line:
line = line.replace("#", "")
line = line.strip()
if '-----------' in line:
line = ''... | python | def __str_cleanup(line):
"""
Remove the unnecessary characters in the line that we don't want
:param str line:
:return str:
"""
if '#' in line:
line = line.replace("#", "")
line = line.strip()
if '-----------' in line:
line = ''... | [
"def",
"__str_cleanup",
"(",
"line",
")",
":",
"if",
"'#'",
"in",
"line",
":",
"line",
"=",
"line",
".",
"replace",
"(",
"\"#\"",
",",
"\"\"",
")",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"if",
"'-----------'",
"in",
"line",
":",
"line",
"=",
... | Remove the unnecessary characters in the line that we don't want
:param str line:
:return str: | [
"Remove",
"the",
"unnecessary",
"characters",
"in",
"the",
"line",
"that",
"we",
"don",
"t",
"want",
":",
"param",
"str",
"line",
":",
":",
"return",
"str",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa_lpd.py#L647-L658 |
nickmckay/LiPD-utilities | Python/lipd/noaa_lpd.py | NOAA_LPD.__slice_key_val | def __slice_key_val(line):
"""
Get the key and value items from a line by looking for and lines that have a ":"
:param str line:
:return str str: Key, Value
"""
position = line.find(":")
# If value is -1, that means the item was not found in the string.
if... | python | def __slice_key_val(line):
"""
Get the key and value items from a line by looking for and lines that have a ":"
:param str line:
:return str str: Key, Value
"""
position = line.find(":")
# If value is -1, that means the item was not found in the string.
if... | [
"def",
"__slice_key_val",
"(",
"line",
")",
":",
"position",
"=",
"line",
".",
"find",
"(",
"\":\"",
")",
"# If value is -1, that means the item was not found in the string.",
"if",
"position",
"!=",
"-",
"1",
":",
"key",
"=",
"line",
"[",
":",
"position",
"]",
... | Get the key and value items from a line by looking for and lines that have a ":"
:param str line:
:return str str: Key, Value | [
"Get",
"the",
"key",
"and",
"value",
"items",
"from",
"a",
"line",
"by",
"looking",
"for",
"and",
"lines",
"that",
"have",
"a",
":",
":",
"param",
"str",
"line",
":",
":",
"return",
"str",
"str",
":",
"Key",
"Value"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa_lpd.py#L661-L677 |
nickmckay/LiPD-utilities | Python/lipd/noaa_lpd.py | NOAA_LPD.__create_coordinates | def __create_coordinates(self, lat, lon, elev):
"""
GeoJSON standard:
Use to determine 2-point or 4-point coordinates
:param list lat:
:param list lon:
:return dict:
"""
# Sort lat an lon in numerical order
lat.sort()
lon.sort()
geo... | python | def __create_coordinates(self, lat, lon, elev):
"""
GeoJSON standard:
Use to determine 2-point or 4-point coordinates
:param list lat:
:param list lon:
:return dict:
"""
# Sort lat an lon in numerical order
lat.sort()
lon.sort()
geo... | [
"def",
"__create_coordinates",
"(",
"self",
",",
"lat",
",",
"lon",
",",
"elev",
")",
":",
"# Sort lat an lon in numerical order",
"lat",
".",
"sort",
"(",
")",
"lon",
".",
"sort",
"(",
")",
"geo_dict",
"=",
"{",
"}",
"# 4 coordinate values",
"if",
"len",
... | GeoJSON standard:
Use to determine 2-point or 4-point coordinates
:param list lat:
:param list lon:
:return dict: | [
"GeoJSON",
"standard",
":",
"Use",
"to",
"determine",
"2",
"-",
"point",
"or",
"4",
"-",
"point",
"coordinates",
":",
"param",
"list",
"lat",
":",
":",
"param",
"list",
"lon",
":",
":",
"return",
"dict",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa_lpd.py#L679-L713 |
nickmckay/LiPD-utilities | Python/lipd/noaa_lpd.py | NOAA_LPD.__geo_multipoint | def __geo_multipoint(lat, lon, elev):
"""
GeoJSON standard:
Create a geoJson MultiPoint-type dictionary
:param list lat:
:param list lon:
:return dict:
"""
logger_noaa_lpd.info("enter geo_multipoint")
geo_dict = OrderedDict()
geometry_dict ... | python | def __geo_multipoint(lat, lon, elev):
"""
GeoJSON standard:
Create a geoJson MultiPoint-type dictionary
:param list lat:
:param list lon:
:return dict:
"""
logger_noaa_lpd.info("enter geo_multipoint")
geo_dict = OrderedDict()
geometry_dict ... | [
"def",
"__geo_multipoint",
"(",
"lat",
",",
"lon",
",",
"elev",
")",
":",
"logger_noaa_lpd",
".",
"info",
"(",
"\"enter geo_multipoint\"",
")",
"geo_dict",
"=",
"OrderedDict",
"(",
")",
"geometry_dict",
"=",
"OrderedDict",
"(",
")",
"coordinates",
"=",
"[",
... | GeoJSON standard:
Create a geoJson MultiPoint-type dictionary
:param list lat:
:param list lon:
:return dict: | [
"GeoJSON",
"standard",
":",
"Create",
"a",
"geoJson",
"MultiPoint",
"-",
"type",
"dictionary",
":",
"param",
"list",
"lat",
":",
":",
"param",
"list",
"lon",
":",
":",
"return",
"dict",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa_lpd.py#L716-L752 |
nickmckay/LiPD-utilities | Python/lipd/noaa_lpd.py | NOAA_LPD.__geo_point | def __geo_point(lat, lon, elev):
"""
GeoJSON standard:
Create a geoJson Point-type dictionary
:param list lat:
:param list lon:
:return dict:
"""
logger_noaa_lpd.info("enter geo_point")
coordinates = []
geo_dict = OrderedDict()
geom... | python | def __geo_point(lat, lon, elev):
"""
GeoJSON standard:
Create a geoJson Point-type dictionary
:param list lat:
:param list lon:
:return dict:
"""
logger_noaa_lpd.info("enter geo_point")
coordinates = []
geo_dict = OrderedDict()
geom... | [
"def",
"__geo_point",
"(",
"lat",
",",
"lon",
",",
"elev",
")",
":",
"logger_noaa_lpd",
".",
"info",
"(",
"\"enter geo_point\"",
")",
"coordinates",
"=",
"[",
"]",
"geo_dict",
"=",
"OrderedDict",
"(",
")",
"geometry_dict",
"=",
"OrderedDict",
"(",
")",
"fo... | GeoJSON standard:
Create a geoJson Point-type dictionary
:param list lat:
:param list lon:
:return dict: | [
"GeoJSON",
"standard",
":",
"Create",
"a",
"geoJson",
"Point",
"-",
"type",
"dictionary",
":",
"param",
"list",
"lat",
":",
":",
"param",
"list",
"lon",
":",
":",
"return",
"dict",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa_lpd.py#L755-L776 |
nickmckay/LiPD-utilities | Python/lipd/noaa_lpd.py | NOAA_LPD.__reorganize_doi | def __reorganize_doi(temp_pub):
"""
Create a valid bib json entry for the DOI information.
"DOI" is technically the only valid DOI key, but there are sometimes a doi_id and doi_url entry.
Check for all three and compare them, then keep whichever seems best.
:param dict temp_pub:
... | python | def __reorganize_doi(temp_pub):
"""
Create a valid bib json entry for the DOI information.
"DOI" is technically the only valid DOI key, but there are sometimes a doi_id and doi_url entry.
Check for all three and compare them, then keep whichever seems best.
:param dict temp_pub:
... | [
"def",
"__reorganize_doi",
"(",
"temp_pub",
")",
":",
"doi_out",
"=",
"\"\"",
"doi_list",
"=",
"[",
"]",
"rm",
"=",
"[",
"\"doiId\"",
",",
"\"doi\"",
",",
"\"doiUrl\"",
"]",
"# Check if both entries exist",
"if",
"\"doi\"",
"and",
"\"doiId\"",
"in",
"temp_pub"... | Create a valid bib json entry for the DOI information.
"DOI" is technically the only valid DOI key, but there are sometimes a doi_id and doi_url entry.
Check for all three and compare them, then keep whichever seems best.
:param dict temp_pub:
:return dict: | [
"Create",
"a",
"valid",
"bib",
"json",
"entry",
"for",
"the",
"DOI",
"information",
".",
"DOI",
"is",
"technically",
"the",
"only",
"valid",
"DOI",
"key",
"but",
"there",
"are",
"sometimes",
"a",
"doi_id",
"and",
"doi_url",
"entry",
".",
"Check",
"for",
... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa_lpd.py#L779-L833 |
nickmckay/LiPD-utilities | Python/lipd/noaa_lpd.py | NOAA_LPD.__create_chron_cols | def __create_chron_cols(metadata):
"""
Use to collected chron metadata to create the chron columns
:param dict metadata: key: variable, val: unit (optional)
:return list: list of one dict per column
"""
chron_col_list = []
chron_col_ct = 1
for variableName... | python | def __create_chron_cols(metadata):
"""
Use to collected chron metadata to create the chron columns
:param dict metadata: key: variable, val: unit (optional)
:return list: list of one dict per column
"""
chron_col_list = []
chron_col_ct = 1
for variableName... | [
"def",
"__create_chron_cols",
"(",
"metadata",
")",
":",
"chron_col_list",
"=",
"[",
"]",
"chron_col_ct",
"=",
"1",
"for",
"variableName",
",",
"unit",
"in",
"metadata",
".",
"items",
"(",
")",
":",
"temp_dict",
"=",
"OrderedDict",
"(",
")",
"temp_dict",
"... | Use to collected chron metadata to create the chron columns
:param dict metadata: key: variable, val: unit (optional)
:return list: list of one dict per column | [
"Use",
"to",
"collected",
"chron",
"metadata",
"to",
"create",
"the",
"chron",
"columns",
":",
"param",
"dict",
"metadata",
":",
"key",
":",
"variable",
"val",
":",
"unit",
"(",
"optional",
")",
":",
"return",
"list",
":",
"list",
"of",
"one",
"dict",
... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa_lpd.py#L851-L867 |
nickmckay/LiPD-utilities | Python/lipd/noaa_lpd.py | NOAA_LPD.__reorganize_chron_header | def __reorganize_chron_header(line):
"""
Reorganize the list of variables. If there are units given, log them.
:param str line:
:return dict: key: variable, val: units (optional)
"""
d = {}
# Header variables should be tab-delimited. Use regex to split by tabs
... | python | def __reorganize_chron_header(line):
"""
Reorganize the list of variables. If there are units given, log them.
:param str line:
:return dict: key: variable, val: units (optional)
"""
d = {}
# Header variables should be tab-delimited. Use regex to split by tabs
... | [
"def",
"__reorganize_chron_header",
"(",
"line",
")",
":",
"d",
"=",
"{",
"}",
"# Header variables should be tab-delimited. Use regex to split by tabs",
"m",
"=",
"re",
".",
"split",
"(",
"re_tab_split",
",",
"line",
")",
"# If there was an output match from the line, then ... | Reorganize the list of variables. If there are units given, log them.
:param str line:
:return dict: key: variable, val: units (optional) | [
"Reorganize",
"the",
"list",
"of",
"variables",
".",
"If",
"there",
"are",
"units",
"given",
"log",
"them",
".",
":",
"param",
"str",
"line",
":",
":",
"return",
"dict",
":",
"key",
":",
"variable",
"val",
":",
"units",
"(",
"optional",
")"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa_lpd.py#L870-L894 |
nickmckay/LiPD-utilities | Python/lipd/noaa_lpd.py | NOAA_LPD.__reorganize_authors | def __reorganize_authors(authors):
"""
Separate the string of authors and put it into a BibJSON compliant list
:param str authors:
:return list: List of dictionaries of author names.
"""
# String SHOULD be semi-colon separated names.
l = []
s = authors.spl... | python | def __reorganize_authors(authors):
"""
Separate the string of authors and put it into a BibJSON compliant list
:param str authors:
:return list: List of dictionaries of author names.
"""
# String SHOULD be semi-colon separated names.
l = []
s = authors.spl... | [
"def",
"__reorganize_authors",
"(",
"authors",
")",
":",
"# String SHOULD be semi-colon separated names.",
"l",
"=",
"[",
"]",
"s",
"=",
"authors",
".",
"split",
"(",
"\";\"",
")",
"for",
"author",
"in",
"s",
":",
"try",
":",
"l",
".",
"append",
"(",
"{",
... | Separate the string of authors and put it into a BibJSON compliant list
:param str authors:
:return list: List of dictionaries of author names. | [
"Separate",
"the",
"string",
"of",
"authors",
"and",
"put",
"it",
"into",
"a",
"BibJSON",
"compliant",
"list",
":",
"param",
"str",
"authors",
":",
":",
"return",
"list",
":",
"List",
"of",
"dictionaries",
"of",
"author",
"names",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/noaa_lpd.py#L897-L911 |
nickmckay/LiPD-utilities | Python/lipd/versions.py | fix_doi | def fix_doi(L):
"""
DOIs are commonly stored in the BibJson format under "identifier". We want to move these to the root
of the publication under "doi". Make the reassignments necessary and also remove duplicate and unwanted
Doi/DOI keys.
:param dict L: Metadata
:return dict L: Metdata
"... | python | def fix_doi(L):
"""
DOIs are commonly stored in the BibJson format under "identifier". We want to move these to the root
of the publication under "doi". Make the reassignments necessary and also remove duplicate and unwanted
Doi/DOI keys.
:param dict L: Metadata
:return dict L: Metdata
"... | [
"def",
"fix_doi",
"(",
"L",
")",
":",
"# Keys that we don't want. Reassign data to 'doi' key",
"_dois",
"=",
"[",
"\"DOI\"",
",",
"\"Doi\"",
"]",
"# Loop for each publication entry",
"for",
"pub",
"in",
"L",
"[",
"\"pub\"",
"]",
":",
"try",
":",
"# Is there an ident... | DOIs are commonly stored in the BibJson format under "identifier". We want to move these to the root
of the publication under "doi". Make the reassignments necessary and also remove duplicate and unwanted
Doi/DOI keys.
:param dict L: Metadata
:return dict L: Metdata | [
"DOIs",
"are",
"commonly",
"stored",
"in",
"the",
"BibJson",
"format",
"under",
"identifier",
".",
"We",
"want",
"to",
"move",
"these",
"to",
"the",
"root",
"of",
"the",
"publication",
"under",
"doi",
".",
"Make",
"the",
"reassignments",
"necessary",
"and",
... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/versions.py#L7-L45 |
nickmckay/LiPD-utilities | Python/lipd/versions.py | get_lipd_version | def get_lipd_version(L):
"""
Check what version of LiPD this file is using. If none is found, assume it's using version 1.0
:param dict L: Metadata
:return float:
"""
version = 1.0
_keys = ["LipdVersion", "LiPDVersion", "lipdVersion", "liPDVersion"]
for _key in _keys:
if _key in ... | python | def get_lipd_version(L):
"""
Check what version of LiPD this file is using. If none is found, assume it's using version 1.0
:param dict L: Metadata
:return float:
"""
version = 1.0
_keys = ["LipdVersion", "LiPDVersion", "lipdVersion", "liPDVersion"]
for _key in _keys:
if _key in ... | [
"def",
"get_lipd_version",
"(",
"L",
")",
":",
"version",
"=",
"1.0",
"_keys",
"=",
"[",
"\"LipdVersion\"",
",",
"\"LiPDVersion\"",
",",
"\"lipdVersion\"",
",",
"\"liPDVersion\"",
"]",
"for",
"_key",
"in",
"_keys",
":",
"if",
"_key",
"in",
"L",
":",
"versi... | Check what version of LiPD this file is using. If none is found, assume it's using version 1.0
:param dict L: Metadata
:return float: | [
"Check",
"what",
"version",
"of",
"LiPD",
"this",
"file",
"is",
"using",
".",
"If",
"none",
"is",
"found",
"assume",
"it",
"s",
"using",
"version",
"1",
".",
"0",
":",
"param",
"dict",
"L",
":",
"Metadata",
":",
"return",
"float",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/versions.py#L47-L65 |
nickmckay/LiPD-utilities | Python/lipd/versions.py | update_lipd_version | def update_lipd_version(L):
"""
Metadata is indexed by number at this step.
Use the current version number to determine where to start updating from. Use "chain versioning" to make it
modular. If a file is a few versions behind, convert to EACH version until reaching current. If a file is one
versi... | python | def update_lipd_version(L):
"""
Metadata is indexed by number at this step.
Use the current version number to determine where to start updating from. Use "chain versioning" to make it
modular. If a file is a few versions behind, convert to EACH version until reaching current. If a file is one
versi... | [
"def",
"update_lipd_version",
"(",
"L",
")",
":",
"# Get the lipd version number.",
"L",
",",
"version",
"=",
"get_lipd_version",
"(",
"L",
")",
"# Update from (N/A or 1.0) to 1.1",
"if",
"version",
"in",
"[",
"1.0",
",",
"\"1.0\"",
"]",
":",
"L",
"=",
"update_l... | Metadata is indexed by number at this step.
Use the current version number to determine where to start updating from. Use "chain versioning" to make it
modular. If a file is a few versions behind, convert to EACH version until reaching current. If a file is one
version behind, it will only convert once to ... | [
"Metadata",
"is",
"indexed",
"by",
"number",
"at",
"this",
"step",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/versions.py#L101-L129 |
nickmckay/LiPD-utilities | Python/lipd/versions.py | update_lipd_v1_1 | def update_lipd_v1_1(d):
"""
Update LiPD v1.0 to v1.1
- chronData entry is a list that allows multiple tables
- paleoData entry is a list that allows multiple tables
- chronData now allows measurement, model, summary, modelTable, ensemble, calibratedAges tables
- Added 'lipdVersion' key
:pa... | python | def update_lipd_v1_1(d):
"""
Update LiPD v1.0 to v1.1
- chronData entry is a list that allows multiple tables
- paleoData entry is a list that allows multiple tables
- chronData now allows measurement, model, summary, modelTable, ensemble, calibratedAges tables
- Added 'lipdVersion' key
:pa... | [
"def",
"update_lipd_v1_1",
"(",
"d",
")",
":",
"logger_versions",
".",
"info",
"(",
"\"enter update_lipd_v1_1\"",
")",
"tmp_all",
"=",
"[",
"]",
"try",
":",
"# ChronData is the only structure update",
"if",
"\"chronData\"",
"in",
"d",
":",
"# As of v1.1, ChronData sho... | Update LiPD v1.0 to v1.1
- chronData entry is a list that allows multiple tables
- paleoData entry is a list that allows multiple tables
- chronData now allows measurement, model, summary, modelTable, ensemble, calibratedAges tables
- Added 'lipdVersion' key
:param dict d: Metadata v1.0
:return... | [
"Update",
"LiPD",
"v1",
".",
"0",
"to",
"v1",
".",
"1",
"-",
"chronData",
"entry",
"is",
"a",
"list",
"that",
"allows",
"multiple",
"tables",
"-",
"paleoData",
"entry",
"is",
"a",
"list",
"that",
"allows",
"multiple",
"tables",
"-",
"chronData",
"now",
... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/versions.py#L132-L169 |
nickmckay/LiPD-utilities | Python/lipd/versions.py | update_lipd_v1_3 | def update_lipd_v1_3(d):
"""
Update LiPD v1.2 to v1.3
- Added 'createdBy' key
- Top-level folder inside LiPD archives are named "bag". (No longer <datasetname>)
- .jsonld file is now generically named 'metadata.jsonld' (No longer <datasetname>.lpd )
- All "paleo" and "chron" prefixes are removed... | python | def update_lipd_v1_3(d):
"""
Update LiPD v1.2 to v1.3
- Added 'createdBy' key
- Top-level folder inside LiPD archives are named "bag". (No longer <datasetname>)
- .jsonld file is now generically named 'metadata.jsonld' (No longer <datasetname>.lpd )
- All "paleo" and "chron" prefixes are removed... | [
"def",
"update_lipd_v1_3",
"(",
"d",
")",
":",
"# sub routine (recursive): changes all the key names and merges interpretation",
"d",
"=",
"update_lipd_v1_3_names",
"(",
"d",
")",
"# sub routine: changes ensemble and summary table structure",
"d",
"=",
"update_lipd_v1_3_structure",
... | Update LiPD v1.2 to v1.3
- Added 'createdBy' key
- Top-level folder inside LiPD archives are named "bag". (No longer <datasetname>)
- .jsonld file is now generically named 'metadata.jsonld' (No longer <datasetname>.lpd )
- All "paleo" and "chron" prefixes are removed from "paleoMeasurementTable", "paleo... | [
"Update",
"LiPD",
"v1",
".",
"2",
"to",
"v1",
".",
"3",
"-",
"Added",
"createdBy",
"key",
"-",
"Top",
"-",
"level",
"folder",
"inside",
"LiPD",
"archives",
"are",
"named",
"bag",
".",
"(",
"No",
"longer",
"<datasetname",
">",
")",
"-",
".",
"jsonld",... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/versions.py#L209-L229 |
nickmckay/LiPD-utilities | Python/lipd/versions.py | update_lipd_v1_3_names | def update_lipd_v1_3_names(d):
"""
Update the key names and merge interpretation data
:param dict d: Metadata
:return dict d: Metadata
"""
try:
if isinstance(d, dict):
for k, v in d.items():
# dive down for dictionaries
d[k] = update_lipd_v1_3_... | python | def update_lipd_v1_3_names(d):
"""
Update the key names and merge interpretation data
:param dict d: Metadata
:return dict d: Metadata
"""
try:
if isinstance(d, dict):
for k, v in d.items():
# dive down for dictionaries
d[k] = update_lipd_v1_3_... | [
"def",
"update_lipd_v1_3_names",
"(",
"d",
")",
":",
"try",
":",
"if",
"isinstance",
"(",
"d",
",",
"dict",
")",
":",
"for",
"k",
",",
"v",
"in",
"d",
".",
"items",
"(",
")",
":",
"# dive down for dictionaries",
"d",
"[",
"k",
"]",
"=",
"update_lipd_... | Update the key names and merge interpretation data
:param dict d: Metadata
:return dict d: Metadata | [
"Update",
"the",
"key",
"names",
"and",
"merge",
"interpretation",
"data",
":",
"param",
"dict",
"d",
":",
"Metadata",
":",
"return",
"dict",
"d",
":",
"Metadata"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/versions.py#L232-L262 |
nickmckay/LiPD-utilities | Python/lipd/versions.py | update_lipd_v1_3_structure | def update_lipd_v1_3_structure(d):
"""
Update the structure for summary and ensemble tables
:param dict d: Metadata
:return dict d: Metadata
"""
for key in ["paleoData", "chronData"]:
if key in d:
for entry1 in d[key]:
if "model" in entry1:
... | python | def update_lipd_v1_3_structure(d):
"""
Update the structure for summary and ensemble tables
:param dict d: Metadata
:return dict d: Metadata
"""
for key in ["paleoData", "chronData"]:
if key in d:
for entry1 in d[key]:
if "model" in entry1:
... | [
"def",
"update_lipd_v1_3_structure",
"(",
"d",
")",
":",
"for",
"key",
"in",
"[",
"\"paleoData\"",
",",
"\"chronData\"",
"]",
":",
"if",
"key",
"in",
"d",
":",
"for",
"entry1",
"in",
"d",
"[",
"key",
"]",
":",
"if",
"\"model\"",
"in",
"entry1",
":",
... | Update the structure for summary and ensemble tables
:param dict d: Metadata
:return dict d: Metadata | [
"Update",
"the",
"structure",
"for",
"summary",
"and",
"ensemble",
"tables",
":",
"param",
"dict",
"d",
":",
"Metadata",
":",
"return",
"dict",
"d",
":",
"Metadata"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/versions.py#L265-L285 |
nickmckay/LiPD-utilities | Python/lipd/csvs.py | merge_csv_metadata | def merge_csv_metadata(d, csvs):
"""
Using the given metadata dictionary, retrieve CSV data from CSV files, and insert the CSV
values into their respective metadata columns. Checks for both paleoData and chronData tables.
:param dict d: Metadata
:return dict: Modified metadata dictionary
"""
... | python | def merge_csv_metadata(d, csvs):
"""
Using the given metadata dictionary, retrieve CSV data from CSV files, and insert the CSV
values into their respective metadata columns. Checks for both paleoData and chronData tables.
:param dict d: Metadata
:return dict: Modified metadata dictionary
"""
... | [
"def",
"merge_csv_metadata",
"(",
"d",
",",
"csvs",
")",
":",
"logger_csvs",
".",
"info",
"(",
"\"enter merge_csv_metadata\"",
")",
"# Add CSV to paleoData",
"if",
"\"paleoData\"",
"in",
"d",
":",
"d",
"[",
"\"paleoData\"",
"]",
"=",
"_merge_csv_section",
"(",
"... | Using the given metadata dictionary, retrieve CSV data from CSV files, and insert the CSV
values into their respective metadata columns. Checks for both paleoData and chronData tables.
:param dict d: Metadata
:return dict: Modified metadata dictionary | [
"Using",
"the",
"given",
"metadata",
"dictionary",
"retrieve",
"CSV",
"data",
"from",
"CSV",
"files",
"and",
"insert",
"the",
"CSV",
"values",
"into",
"their",
"respective",
"metadata",
"columns",
".",
"Checks",
"for",
"both",
"paleoData",
"and",
"chronData",
... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/csvs.py#L18-L37 |
nickmckay/LiPD-utilities | Python/lipd/csvs.py | _merge_csv_section | def _merge_csv_section(sections, pc, csvs):
"""
Add csv data to all paleo data tables
:param dict sections: Metadata
:return dict sections: Metadata
"""
logger_csvs.info("enter merge_csv_section")
try:
# Loop through each table_data in paleoData
for _name, _section in secti... | python | def _merge_csv_section(sections, pc, csvs):
"""
Add csv data to all paleo data tables
:param dict sections: Metadata
:return dict sections: Metadata
"""
logger_csvs.info("enter merge_csv_section")
try:
# Loop through each table_data in paleoData
for _name, _section in secti... | [
"def",
"_merge_csv_section",
"(",
"sections",
",",
"pc",
",",
"csvs",
")",
":",
"logger_csvs",
".",
"info",
"(",
"\"enter merge_csv_section\"",
")",
"try",
":",
"# Loop through each table_data in paleoData",
"for",
"_name",
",",
"_section",
"in",
"sections",
".",
... | Add csv data to all paleo data tables
:param dict sections: Metadata
:return dict sections: Metadata | [
"Add",
"csv",
"data",
"to",
"all",
"paleo",
"data",
"tables"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/csvs.py#L40-L64 |
nickmckay/LiPD-utilities | Python/lipd/csvs.py | _merge_csv_model | def _merge_csv_model(models, pc, csvs):
"""
Add csv data to each column in chron model
:param dict models: Metadata
:return dict models: Metadata
"""
logger_csvs.info("enter merge_csv_model")
try:
for _name, _model in models.items():
if "summaryTable" in _model:
... | python | def _merge_csv_model(models, pc, csvs):
"""
Add csv data to each column in chron model
:param dict models: Metadata
:return dict models: Metadata
"""
logger_csvs.info("enter merge_csv_model")
try:
for _name, _model in models.items():
if "summaryTable" in _model:
... | [
"def",
"_merge_csv_model",
"(",
"models",
",",
"pc",
",",
"csvs",
")",
":",
"logger_csvs",
".",
"info",
"(",
"\"enter merge_csv_model\"",
")",
"try",
":",
"for",
"_name",
",",
"_model",
"in",
"models",
".",
"items",
"(",
")",
":",
"if",
"\"summaryTable\"",... | Add csv data to each column in chron model
:param dict models: Metadata
:return dict models: Metadata | [
"Add",
"csv",
"data",
"to",
"each",
"column",
"in",
"chron",
"model"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/csvs.py#L67-L92 |
nickmckay/LiPD-utilities | Python/lipd/csvs.py | _merge_csv_column | def _merge_csv_column(table, csvs):
"""
Add csv data to each column in a list of columns
:param dict table: Table metadata
:param str crumbs: Hierarchy crumbs
:param str pc: Paleo or Chron table type
:return dict: Table metadata with csv "values" entry
:return bool ensemble: Ensemble data o... | python | def _merge_csv_column(table, csvs):
"""
Add csv data to each column in a list of columns
:param dict table: Table metadata
:param str crumbs: Hierarchy crumbs
:param str pc: Paleo or Chron table type
:return dict: Table metadata with csv "values" entry
:return bool ensemble: Ensemble data o... | [
"def",
"_merge_csv_column",
"(",
"table",
",",
"csvs",
")",
":",
"# Start putting CSV data into corresponding column \"values\" key",
"try",
":",
"ensemble",
"=",
"is_ensemble",
"(",
"table",
"[",
"\"columns\"",
"]",
")",
"if",
"ensemble",
":",
"# realization columns",
... | Add csv data to each column in a list of columns
:param dict table: Table metadata
:param str crumbs: Hierarchy crumbs
:param str pc: Paleo or Chron table type
:return dict: Table metadata with csv "values" entry
:return bool ensemble: Ensemble data or not ensemble data | [
"Add",
"csv",
"data",
"to",
"each",
"column",
"in",
"a",
"list",
"of",
"columns"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/csvs.py#L140-L188 |
nickmckay/LiPD-utilities | Python/lipd/csvs.py | read_csv_from_file | def read_csv_from_file(filename):
"""
Opens the target CSV file and creates a dictionary with one list for each CSV column.
:param str filename:
:return list of lists: column values
"""
logger_csvs.info("enter read_csv_from_file")
d = {}
l = []
try:
logger_csvs.info("open fi... | python | def read_csv_from_file(filename):
"""
Opens the target CSV file and creates a dictionary with one list for each CSV column.
:param str filename:
:return list of lists: column values
"""
logger_csvs.info("enter read_csv_from_file")
d = {}
l = []
try:
logger_csvs.info("open fi... | [
"def",
"read_csv_from_file",
"(",
"filename",
")",
":",
"logger_csvs",
".",
"info",
"(",
"\"enter read_csv_from_file\"",
")",
"d",
"=",
"{",
"}",
"l",
"=",
"[",
"]",
"try",
":",
"logger_csvs",
".",
"info",
"(",
"\"open file: {}\"",
".",
"format",
"(",
"fil... | Opens the target CSV file and creates a dictionary with one list for each CSV column.
:param str filename:
:return list of lists: column values | [
"Opens",
"the",
"target",
"CSV",
"file",
"and",
"creates",
"a",
"dictionary",
"with",
"one",
"list",
"for",
"each",
"CSV",
"column",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/csvs.py#L208-L241 |
nickmckay/LiPD-utilities | Python/lipd/csvs.py | write_csv_to_file | def write_csv_to_file(d):
"""
Writes columns of data to a target CSV file.
:param dict d: A dictionary containing one list for every data column. Keys: int, Values: list
:return None:
"""
logger_csvs.info("enter write_csv_to_file")
try:
for filename, data in d.items():
... | python | def write_csv_to_file(d):
"""
Writes columns of data to a target CSV file.
:param dict d: A dictionary containing one list for every data column. Keys: int, Values: list
:return None:
"""
logger_csvs.info("enter write_csv_to_file")
try:
for filename, data in d.items():
... | [
"def",
"write_csv_to_file",
"(",
"d",
")",
":",
"logger_csvs",
".",
"info",
"(",
"\"enter write_csv_to_file\"",
")",
"try",
":",
"for",
"filename",
",",
"data",
"in",
"d",
".",
"items",
"(",
")",
":",
"try",
":",
"l_columns",
"=",
"_reorder_csv",
"(",
"d... | Writes columns of data to a target CSV file.
:param dict d: A dictionary containing one list for every data column. Keys: int, Values: list
:return None: | [
"Writes",
"columns",
"of",
"data",
"to",
"a",
"target",
"CSV",
"file",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/csvs.py#L247-L277 |
nickmckay/LiPD-utilities | Python/lipd/csvs.py | get_csv_from_metadata | def get_csv_from_metadata(dsn, d):
"""
Two goals. Get all csv from metadata, and return new metadata with generated filenames to match files.
:param str dsn: Dataset name
:param dict d: Metadata
:return dict _csvs: Csv
"""
logger_csvs.info("enter get_csv_from_metadata")
_csvs = OrderedD... | python | def get_csv_from_metadata(dsn, d):
"""
Two goals. Get all csv from metadata, and return new metadata with generated filenames to match files.
:param str dsn: Dataset name
:param dict d: Metadata
:return dict _csvs: Csv
"""
logger_csvs.info("enter get_csv_from_metadata")
_csvs = OrderedD... | [
"def",
"get_csv_from_metadata",
"(",
"dsn",
",",
"d",
")",
":",
"logger_csvs",
".",
"info",
"(",
"\"enter get_csv_from_metadata\"",
")",
"_csvs",
"=",
"OrderedDict",
"(",
")",
"_d",
"=",
"copy",
".",
"deepcopy",
"(",
"d",
")",
"try",
":",
"if",
"\"paleoDat... | Two goals. Get all csv from metadata, and return new metadata with generated filenames to match files.
:param str dsn: Dataset name
:param dict d: Metadata
:return dict _csvs: Csv | [
"Two",
"goals",
".",
"Get",
"all",
"csv",
"from",
"metadata",
"and",
"return",
"new",
"metadata",
"with",
"generated",
"filenames",
"to",
"match",
"files",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/csvs.py#L283-L308 |
nickmckay/LiPD-utilities | Python/lipd/csvs.py | _get_csv_from_section | def _get_csv_from_section(sections, crumbs, csvs):
"""
Get table name, variable name, and column values from paleo metadata
:param dict sections: Metadata
:param str crumbs: Crumbs
:param dict csvs: Csv
:return dict sections: Metadata
:return dict csvs: Csv
"""
logger_csvs.info("ent... | python | def _get_csv_from_section(sections, crumbs, csvs):
"""
Get table name, variable name, and column values from paleo metadata
:param dict sections: Metadata
:param str crumbs: Crumbs
:param dict csvs: Csv
:return dict sections: Metadata
:return dict csvs: Csv
"""
logger_csvs.info("ent... | [
"def",
"_get_csv_from_section",
"(",
"sections",
",",
"crumbs",
",",
"csvs",
")",
":",
"logger_csvs",
".",
"info",
"(",
"\"enter get_csv_from_section: {}\"",
".",
"format",
"(",
"crumbs",
")",
")",
"_idx",
"=",
"0",
"try",
":",
"# Process the tables in section",
... | Get table name, variable name, and column values from paleo metadata
:param dict sections: Metadata
:param str crumbs: Crumbs
:param dict csvs: Csv
:return dict sections: Metadata
:return dict csvs: Csv | [
"Get",
"table",
"name",
"variable",
"name",
"and",
"column",
"values",
"from",
"paleo",
"metadata"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/csvs.py#L311-L339 |
nickmckay/LiPD-utilities | Python/lipd/csvs.py | _get_csv_from_model | def _get_csv_from_model(models, crumbs, csvs):
"""
Get csv from model data
:param dict models: Metadata
:param str crumbs: Crumbs
:param dict csvs: Csv
:return dict models: Metadata
:return dict csvs: Csv
"""
logger_csvs.info("enter get_csv_from_model: {}".format(crumbs))
_idx =... | python | def _get_csv_from_model(models, crumbs, csvs):
"""
Get csv from model data
:param dict models: Metadata
:param str crumbs: Crumbs
:param dict csvs: Csv
:return dict models: Metadata
:return dict csvs: Csv
"""
logger_csvs.info("enter get_csv_from_model: {}".format(crumbs))
_idx =... | [
"def",
"_get_csv_from_model",
"(",
"models",
",",
"crumbs",
",",
"csvs",
")",
":",
"logger_csvs",
".",
"info",
"(",
"\"enter get_csv_from_model: {}\"",
".",
"format",
"(",
"crumbs",
")",
")",
"_idx",
"=",
"0",
"try",
":",
"for",
"_name",
",",
"_model",
"in... | Get csv from model data
:param dict models: Metadata
:param str crumbs: Crumbs
:param dict csvs: Csv
:return dict models: Metadata
:return dict csvs: Csv | [
"Get",
"csv",
"from",
"model",
"data"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/csvs.py#L342-L368 |
nickmckay/LiPD-utilities | Python/lipd/csvs.py | _get_csv_from_columns | def _get_csv_from_columns(table, filename, csvs):
"""
Search a data tables for column values. Return a dict of column values
:param dict d: Table data
:return dict: Column values. ref by var name
"""
csvs[filename] = OrderedDict()
try:
if "columns" in table:
try:
... | python | def _get_csv_from_columns(table, filename, csvs):
"""
Search a data tables for column values. Return a dict of column values
:param dict d: Table data
:return dict: Column values. ref by var name
"""
csvs[filename] = OrderedDict()
try:
if "columns" in table:
try:
... | [
"def",
"_get_csv_from_columns",
"(",
"table",
",",
"filename",
",",
"csvs",
")",
":",
"csvs",
"[",
"filename",
"]",
"=",
"OrderedDict",
"(",
")",
"try",
":",
"if",
"\"columns\"",
"in",
"table",
":",
"try",
":",
"for",
"_name",
",",
"_column",
"in",
"ta... | Search a data tables for column values. Return a dict of column values
:param dict d: Table data
:return dict: Column values. ref by var name | [
"Search",
"a",
"data",
"tables",
"for",
"column",
"values",
".",
"Return",
"a",
"dict",
"of",
"column",
"values",
":",
"param",
"dict",
"d",
":",
"Table",
"data",
":",
"return",
"dict",
":",
"Column",
"values",
".",
"ref",
"by",
"var",
"name"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/csvs.py#L389-L410 |
nickmckay/LiPD-utilities | Python/lipd/csvs.py | _get_filename | def _get_filename(table):
"""
Get the filename from a data table. If it doesn't exist, create a new one based on table hierarchy in metadata file.
format: <dataSetName>.<section><idx><table><idx>.csv
example: ODP1098B.Chron1.ChronMeasurementTable.csv
:param dict table: Table data
:param str cru... | python | def _get_filename(table):
"""
Get the filename from a data table. If it doesn't exist, create a new one based on table hierarchy in metadata file.
format: <dataSetName>.<section><idx><table><idx>.csv
example: ODP1098B.Chron1.ChronMeasurementTable.csv
:param dict table: Table data
:param str cru... | [
"def",
"_get_filename",
"(",
"table",
")",
":",
"try",
":",
"filename",
"=",
"table",
"[",
"\"filename\"",
"]",
"except",
"KeyError",
":",
"logger_csvs",
".",
"info",
"(",
"\"get_filename: KeyError: missing filename for a table\"",
")",
"print",
"(",
"\"Error: Missi... | Get the filename from a data table. If it doesn't exist, create a new one based on table hierarchy in metadata file.
format: <dataSetName>.<section><idx><table><idx>.csv
example: ODP1098B.Chron1.ChronMeasurementTable.csv
:param dict table: Table data
:param str crumbs: Crumbs
:return str filename: ... | [
"Get",
"the",
"filename",
"from",
"a",
"data",
"table",
".",
"If",
"it",
"doesn",
"t",
"exist",
"create",
"a",
"new",
"one",
"based",
"on",
"table",
"hierarchy",
"in",
"metadata",
"file",
".",
"format",
":",
"<dataSetName",
">",
".",
"<section",
">",
"... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/csvs.py#L413-L432 |
nickmckay/LiPD-utilities | Python/lipd/csvs.py | _reorder_csv | def _reorder_csv(d, filename=""):
"""
Preserve the csv column ordering before writing back out to CSV file. Keep column data consistent with JSONLD
column number alignment.
{ "var1" : {"number": 1, "values": [] }, "var2": {"number": 1, "values": [] } }
:param dict d: csv data
:param str filenam... | python | def _reorder_csv(d, filename=""):
"""
Preserve the csv column ordering before writing back out to CSV file. Keep column data consistent with JSONLD
column number alignment.
{ "var1" : {"number": 1, "values": [] }, "var2": {"number": 1, "values": [] } }
:param dict d: csv data
:param str filenam... | [
"def",
"_reorder_csv",
"(",
"d",
",",
"filename",
"=",
"\"\"",
")",
":",
"_ensemble",
"=",
"is_ensemble",
"(",
"d",
")",
"_d2",
"=",
"[",
"]",
"try",
":",
"if",
"_ensemble",
":",
"# 1 column ensemble: realizations",
"if",
"len",
"(",
"d",
")",
"==",
"1... | Preserve the csv column ordering before writing back out to CSV file. Keep column data consistent with JSONLD
column number alignment.
{ "var1" : {"number": 1, "values": [] }, "var2": {"number": 1, "values": [] } }
:param dict d: csv data
:param str filename: Filename
:return dict: csv data | [
"Preserve",
"the",
"csv",
"column",
"ordering",
"before",
"writing",
"back",
"out",
"to",
"CSV",
"file",
".",
"Keep",
"column",
"data",
"consistent",
"with",
"JSONLD",
"column",
"number",
"alignment",
".",
"{",
"var1",
":",
"{",
"number",
":",
"1",
"values... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/csvs.py#L470-L528 |
nickmckay/LiPD-utilities | Python/lipd/csvs.py | _is_numeric_data | def _is_numeric_data(ll):
"""
List of lists of csv values data
:param list ll:
:return bool: True, all lists are numeric lists, False, data contains at least one numeric list.
"""
for l in ll:
try:
if any(math.isnan(float(i)) or isinstance(i, str) for i in l):
... | python | def _is_numeric_data(ll):
"""
List of lists of csv values data
:param list ll:
:return bool: True, all lists are numeric lists, False, data contains at least one numeric list.
"""
for l in ll:
try:
if any(math.isnan(float(i)) or isinstance(i, str) for i in l):
... | [
"def",
"_is_numeric_data",
"(",
"ll",
")",
":",
"for",
"l",
"in",
"ll",
":",
"try",
":",
"if",
"any",
"(",
"math",
".",
"isnan",
"(",
"float",
"(",
"i",
")",
")",
"or",
"isinstance",
"(",
"i",
",",
"str",
")",
"for",
"i",
"in",
"l",
")",
":",... | List of lists of csv values data
:param list ll:
:return bool: True, all lists are numeric lists, False, data contains at least one numeric list. | [
"List",
"of",
"lists",
"of",
"csv",
"values",
"data",
":",
"param",
"list",
"ll",
":",
":",
"return",
"bool",
":",
"True",
"all",
"lists",
"are",
"numeric",
"lists",
"False",
"data",
"contains",
"at",
"least",
"one",
"numeric",
"list",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/csvs.py#L531-L548 |
nickmckay/LiPD-utilities | Python/lipd/csvs.py | _merge_ensemble | def _merge_ensemble(ensemble, col_nums, col_vals):
"""
The second column is not typical.
"number" is a list of column numbers and "values" is an array of column values.
Before we can write this to csv, it has to match the format the writer expects.
:param dict ensemble: First column data
:param ... | python | def _merge_ensemble(ensemble, col_nums, col_vals):
"""
The second column is not typical.
"number" is a list of column numbers and "values" is an array of column values.
Before we can write this to csv, it has to match the format the writer expects.
:param dict ensemble: First column data
:param ... | [
"def",
"_merge_ensemble",
"(",
"ensemble",
",",
"col_nums",
",",
"col_vals",
")",
":",
"try",
":",
"# Loop for each column available",
"for",
"num",
"in",
"col_nums",
":",
"# first column number in col_nums is usually \"2\", so backtrack once since ensemble already has one entry"... | The second column is not typical.
"number" is a list of column numbers and "values" is an array of column values.
Before we can write this to csv, it has to match the format the writer expects.
:param dict ensemble: First column data
:param list col_nums: Second column numbers. list of ints
:param l... | [
"The",
"second",
"column",
"is",
"not",
"typical",
".",
"number",
"is",
"a",
"list",
"of",
"column",
"numbers",
"and",
"values",
"is",
"an",
"array",
"of",
"column",
"values",
".",
"Before",
"we",
"can",
"write",
"this",
"to",
"csv",
"it",
"has",
"to",... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/csvs.py#L551-L571 |
nickmckay/LiPD-utilities | Python/lipd/validator_api.py | get_validator_format | def get_validator_format(L):
"""
Format the LIPD data in the layout that the Lipd.net validator accepts.
'_format' example:
[
{"type": "csv", "filenameFull": /path/to/filename.csv, "data": "", ...},
{"type": "json", "filenameFull": /path/to/metadata.jsonld, "data": "", ...},
..... | python | def get_validator_format(L):
"""
Format the LIPD data in the layout that the Lipd.net validator accepts.
'_format' example:
[
{"type": "csv", "filenameFull": /path/to/filename.csv, "data": "", ...},
{"type": "json", "filenameFull": /path/to/metadata.jsonld, "data": "", ...},
..... | [
"def",
"get_validator_format",
"(",
"L",
")",
":",
"_api_data",
"=",
"[",
"]",
"_j",
",",
"_csvs",
"=",
"get_csv_from_metadata",
"(",
"L",
"[",
"\"dataSetName\"",
"]",
",",
"L",
")",
"_j",
"=",
"rm_values_fields",
"(",
"copy",
".",
"deepcopy",
"(",
"L",
... | Format the LIPD data in the layout that the Lipd.net validator accepts.
'_format' example:
[
{"type": "csv", "filenameFull": /path/to/filename.csv, "data": "", ...},
{"type": "json", "filenameFull": /path/to/metadata.jsonld, "data": "", ...},
...
]
:param dict L: Metadata
... | [
"Format",
"the",
"LIPD",
"data",
"in",
"the",
"layout",
"that",
"the",
"Lipd",
".",
"net",
"validator",
"accepts",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/validator_api.py#L14-L73 |
nickmckay/LiPD-utilities | Python/lipd/validator_api.py | create_detailed_results | def create_detailed_results(result):
"""
Use the result from the API call to create an organized single string output for printing to the console.
:param dict result: Results from API call for one file
:return str string: Organized results for printing
"""
string = ""
# Validation Response ... | python | def create_detailed_results(result):
"""
Use the result from the API call to create an organized single string output for printing to the console.
:param dict result: Results from API call for one file
:return str string: Organized results for printing
"""
string = ""
# Validation Response ... | [
"def",
"create_detailed_results",
"(",
"result",
")",
":",
"string",
"=",
"\"\"",
"# Validation Response output",
"# string += \"VALIDATION RESPONSE\\n\"",
"string",
"+=",
"\"STATUS: {}\\n\"",
".",
"format",
"(",
"result",
"[",
"\"status\"",
"]",
")",
"if",
"result",
... | Use the result from the API call to create an organized single string output for printing to the console.
:param dict result: Results from API call for one file
:return str string: Organized results for printing | [
"Use",
"the",
"result",
"from",
"the",
"API",
"call",
"to",
"create",
"an",
"organized",
"single",
"string",
"output",
"for",
"printing",
"to",
"the",
"console",
"."
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/validator_api.py#L76-L96 |
nickmckay/LiPD-utilities | Python/lipd/validator_api.py | display_results | def display_results(results, detailed=False):
"""
Display the results from the validator in a brief or detailed output
:param list results: API results, sorted by dataset name (multiple)
:param bool detailed: Detailed results on or off
:return none:
"""
# print("\nVALIDATOR RESULTS")
# ... | python | def display_results(results, detailed=False):
"""
Display the results from the validator in a brief or detailed output
:param list results: API results, sorted by dataset name (multiple)
:param bool detailed: Detailed results on or off
:return none:
"""
# print("\nVALIDATOR RESULTS")
# ... | [
"def",
"display_results",
"(",
"results",
",",
"detailed",
"=",
"False",
")",
":",
"# print(\"\\nVALIDATOR RESULTS\")",
"# print(\"======================\\n\")",
"if",
"not",
"detailed",
":",
"print",
"(",
"'FILENAME......................................... STATUS..........'",
... | Display the results from the validator in a brief or detailed output
:param list results: API results, sorted by dataset name (multiple)
:param bool detailed: Detailed results on or off
:return none: | [
"Display",
"the",
"results",
"from",
"the",
"validator",
"in",
"a",
"brief",
"or",
"detailed",
"output"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/validator_api.py#L99-L124 |
nickmckay/LiPD-utilities | Python/lipd/validator_api.py | call_validator_api | def call_validator_api(dsn, api_data):
"""
Single call to the lipd.net validator API
'api_data' format:
[
{"type": "csv", "filenameFull": /path/to/filename.csv, "data": "", ...},
{"type": "json", "filenameFull": /path/to/metadata.jsonld, "data": "", ...},
...
]
Result f... | python | def call_validator_api(dsn, api_data):
"""
Single call to the lipd.net validator API
'api_data' format:
[
{"type": "csv", "filenameFull": /path/to/filename.csv, "data": "", ...},
{"type": "json", "filenameFull": /path/to/metadata.jsonld, "data": "", ...},
...
]
Result f... | [
"def",
"call_validator_api",
"(",
"dsn",
",",
"api_data",
")",
":",
"_filename",
"=",
"dsn",
"+",
"\".lpd\"",
"try",
":",
"# Contact server and send LiPD metadata as the payload",
"# print(\"Sending request to LiPD.net validator...\\n\")",
"api_data",
"=",
"json",
".",
"dum... | Single call to the lipd.net validator API
'api_data' format:
[
{"type": "csv", "filenameFull": /path/to/filename.csv, "data": "", ...},
{"type": "json", "filenameFull": /path/to/metadata.jsonld, "data": "", ...},
...
]
Result format:
{"dat": <dict>, "feedback": <dict>, ... | [
"Single",
"call",
"to",
"the",
"lipd",
".",
"net",
"validator",
"API"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/validator_api.py#L127-L190 |
useblocks/sphinxcontrib-needs | sphinxcontrib/needs/filter_common.py | procces_filters | def procces_filters(all_needs, current_needlist):
"""
Filters all needs with given configuration
:param current_needlist: needlist object, which stores all filters
:param all_needs: List of all needs inside document
:return: list of needs, which passed the filters
"""
if current_needlist[... | python | def procces_filters(all_needs, current_needlist):
"""
Filters all needs with given configuration
:param current_needlist: needlist object, which stores all filters
:param all_needs: List of all needs inside document
:return: list of needs, which passed the filters
"""
if current_needlist[... | [
"def",
"procces_filters",
"(",
"all_needs",
",",
"current_needlist",
")",
":",
"if",
"current_needlist",
"[",
"\"sort_by\"",
"]",
"is",
"not",
"None",
":",
"if",
"current_needlist",
"[",
"\"sort_by\"",
"]",
"==",
"\"id\"",
":",
"all_needs",
"=",
"sorted",
"(",... | Filters all needs with given configuration
:param current_needlist: needlist object, which stores all filters
:param all_needs: List of all needs inside document
:return: list of needs, which passed the filters | [
"Filters",
"all",
"needs",
"with",
"given",
"configuration"
] | train | https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/filter_common.py#L68-L117 |
useblocks/sphinxcontrib-needs | sphinxcontrib/needs/filter_common.py | filter_needs | def filter_needs(needs, filter_string="", filter_parts=True, merge_part_with_parent=True):
"""
Filters given needs based on a given filter string.
Returns all needs, which pass the given filter.
:param merge_part_with_parent: If True, need_parts inherit options from their parent need
:param filter_... | python | def filter_needs(needs, filter_string="", filter_parts=True, merge_part_with_parent=True):
"""
Filters given needs based on a given filter string.
Returns all needs, which pass the given filter.
:param merge_part_with_parent: If True, need_parts inherit options from their parent need
:param filter_... | [
"def",
"filter_needs",
"(",
"needs",
",",
"filter_string",
"=",
"\"\"",
",",
"filter_parts",
"=",
"True",
",",
"merge_part_with_parent",
"=",
"True",
")",
":",
"if",
"filter_string",
"is",
"None",
"or",
"filter_string",
"==",
"\"\"",
":",
"return",
"needs",
... | Filters given needs based on a given filter string.
Returns all needs, which pass the given filter.
:param merge_part_with_parent: If True, need_parts inherit options from their parent need
:param filter_parts: If True, need_parts get also filtered
:param filter_string: strings, which gets evaluated ag... | [
"Filters",
"given",
"needs",
"based",
"on",
"a",
"given",
"filter",
"string",
".",
"Returns",
"all",
"needs",
"which",
"pass",
"the",
"given",
"filter",
"."
] | train | https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/filter_common.py#L160-L184 |
useblocks/sphinxcontrib-needs | sphinxcontrib/needs/filter_common.py | filter_single_need | def filter_single_need(need, filter_string=""):
"""
Checks if a single need/need_part passes a filter_string
:param need: need or need_part
:param filter_string: string, which is used as input for eval()
:return: True, if need as passed the filter_string, else False
"""
filter_context = nee... | python | def filter_single_need(need, filter_string=""):
"""
Checks if a single need/need_part passes a filter_string
:param need: need or need_part
:param filter_string: string, which is used as input for eval()
:return: True, if need as passed the filter_string, else False
"""
filter_context = nee... | [
"def",
"filter_single_need",
"(",
"need",
",",
"filter_string",
"=",
"\"\"",
")",
":",
"filter_context",
"=",
"need",
".",
"copy",
"(",
")",
"filter_context",
"[",
"\"search\"",
"]",
"=",
"re",
".",
"search",
"result",
"=",
"False",
"try",
":",
"result",
... | Checks if a single need/need_part passes a filter_string
:param need: need or need_part
:param filter_string: string, which is used as input for eval()
:return: True, if need as passed the filter_string, else False | [
"Checks",
"if",
"a",
"single",
"need",
"/",
"need_part",
"passes",
"a",
"filter_string"
] | train | https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/filter_common.py#L187-L202 |
sijis/sumologic-python | src/sumologic/utils.py | get_logging_level | def get_logging_level(debug):
"""Returns logging level based on boolean"""
level = logging.INFO
if debug:
level = logging.DEBUG
return level | python | def get_logging_level(debug):
"""Returns logging level based on boolean"""
level = logging.INFO
if debug:
level = logging.DEBUG
return level | [
"def",
"get_logging_level",
"(",
"debug",
")",
":",
"level",
"=",
"logging",
".",
"INFO",
"if",
"debug",
":",
"level",
"=",
"logging",
".",
"DEBUG",
"return",
"level"
] | Returns logging level based on boolean | [
"Returns",
"logging",
"level",
"based",
"on",
"boolean"
] | train | https://github.com/sijis/sumologic-python/blob/b50200907837f0d452d14ead5e647b8e24e2e9e5/src/sumologic/utils.py#L4-L9 |
mfussenegger/cr8 | cr8/run_spec.py | run_spec | def run_spec(spec,
benchmark_hosts,
result_hosts=None,
output_fmt=None,
logfile_info=None,
logfile_result=None,
action=None,
fail_if=None,
sample_mode='reservoir'):
"""Run a spec file, executing the statements on... | python | def run_spec(spec,
benchmark_hosts,
result_hosts=None,
output_fmt=None,
logfile_info=None,
logfile_result=None,
action=None,
fail_if=None,
sample_mode='reservoir'):
"""Run a spec file, executing the statements on... | [
"def",
"run_spec",
"(",
"spec",
",",
"benchmark_hosts",
",",
"result_hosts",
"=",
"None",
",",
"output_fmt",
"=",
"None",
",",
"logfile_info",
"=",
"None",
",",
"logfile_result",
"=",
"None",
",",
"action",
"=",
"None",
",",
"fail_if",
"=",
"None",
",",
... | Run a spec file, executing the statements on the benchmark_hosts.
Short example of a spec file:
[setup]
statement_files = ["sql/create_table.sql"]
[[setup.data_files]]
target = "t"
source = "data/t.json"
[[queries]]
statement = "select count(*)... | [
"Run",
"a",
"spec",
"file",
"executing",
"the",
"statements",
"on",
"the",
"benchmark_hosts",
"."
] | train | https://github.com/mfussenegger/cr8/blob/a37d6049f1f9fee2d0556efae2b7b7f8761bffe8/cr8/run_spec.py#L240-L304 |
nickmckay/LiPD-utilities | Python/lipd/download_lipd.py | download_from_url | def download_from_url(src_url, dst_dir):
"""
Use the given URL and destination to download and save a file
:param str src_url: Direct URL to lipd file download
:param str dst_path: Local path to download file to, including filename and ext. ex. /path/to/filename.lpd
:return none:
"""
dst_pat... | python | def download_from_url(src_url, dst_dir):
"""
Use the given URL and destination to download and save a file
:param str src_url: Direct URL to lipd file download
:param str dst_path: Local path to download file to, including filename and ext. ex. /path/to/filename.lpd
:return none:
"""
dst_pat... | [
"def",
"download_from_url",
"(",
"src_url",
",",
"dst_dir",
")",
":",
"dst_path",
"=",
"\"\"",
"if",
"\"MD982181\"",
"not",
"in",
"src_url",
":",
"dsn",
"=",
"input",
"(",
"\"Please enter the dataset name for this file (Name.Location.Year) : \"",
")",
"dst_path",
"=",... | Use the given URL and destination to download and save a file
:param str src_url: Direct URL to lipd file download
:param str dst_path: Local path to download file to, including filename and ext. ex. /path/to/filename.lpd
:return none: | [
"Use",
"the",
"given",
"URL",
"and",
"destination",
"to",
"download",
"and",
"save",
"a",
"file",
":",
"param",
"str",
"src_url",
":",
"Direct",
"URL",
"to",
"lipd",
"file",
"download",
":",
"param",
"str",
"dst_path",
":",
"Local",
"path",
"to",
"downlo... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/download_lipd.py#L20-L38 |
nickmckay/LiPD-utilities | Python/lipd/doi_main.py | doi_main | def doi_main(files):
"""
Main function that controls the script. Take in directory containing the .lpd file(s). Loop for each file.
:return None:
"""
logger_doi_main.info("enter doi_main")
print("Found {0} {1} file(s)".format(str(len(files[".lpd"])), 'LiPD'))
force = prompt_force()
for ... | python | def doi_main(files):
"""
Main function that controls the script. Take in directory containing the .lpd file(s). Loop for each file.
:return None:
"""
logger_doi_main.info("enter doi_main")
print("Found {0} {1} file(s)".format(str(len(files[".lpd"])), 'LiPD'))
force = prompt_force()
for ... | [
"def",
"doi_main",
"(",
"files",
")",
":",
"logger_doi_main",
".",
"info",
"(",
"\"enter doi_main\"",
")",
"print",
"(",
"\"Found {0} {1} file(s)\"",
".",
"format",
"(",
"str",
"(",
"len",
"(",
"files",
"[",
"\".lpd\"",
"]",
")",
")",
",",
"'LiPD'",
")",
... | Main function that controls the script. Take in directory containing the .lpd file(s). Loop for each file.
:return None: | [
"Main",
"function",
"that",
"controls",
"the",
"script",
".",
"Take",
"in",
"directory",
"containing",
"the",
".",
"lpd",
"file",
"(",
"s",
")",
".",
"Loop",
"for",
"each",
"file",
".",
":",
"return",
"None",
":"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/doi_main.py#L11-L61 |
nickmckay/LiPD-utilities | Python/lipd/doi_main.py | process_lpd | def process_lpd(name, dir_tmp):
"""
Opens up json file, invokes doi_resolver, closes file, updates changelog, cleans directory, and makes new bag.
:param str name: Name of current .lpd file
:param str dir_tmp: Path to tmp directory
:return none:
"""
logger_doi_main.info("enter process_lpd")
... | python | def process_lpd(name, dir_tmp):
"""
Opens up json file, invokes doi_resolver, closes file, updates changelog, cleans directory, and makes new bag.
:param str name: Name of current .lpd file
:param str dir_tmp: Path to tmp directory
:return none:
"""
logger_doi_main.info("enter process_lpd")
... | [
"def",
"process_lpd",
"(",
"name",
",",
"dir_tmp",
")",
":",
"logger_doi_main",
".",
"info",
"(",
"\"enter process_lpd\"",
")",
"dir_root",
"=",
"os",
".",
"getcwd",
"(",
")",
"dir_bag",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dir_tmp",
",",
"name",
... | Opens up json file, invokes doi_resolver, closes file, updates changelog, cleans directory, and makes new bag.
:param str name: Name of current .lpd file
:param str dir_tmp: Path to tmp directory
:return none: | [
"Opens",
"up",
"json",
"file",
"invokes",
"doi_resolver",
"closes",
"file",
"updates",
"changelog",
"cleans",
"directory",
"and",
"makes",
"new",
"bag",
".",
":",
"param",
"str",
"name",
":",
"Name",
"of",
"current",
".",
"lpd",
"file",
":",
"param",
"str"... | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/doi_main.py#L64-L97 |
nickmckay/LiPD-utilities | Python/lipd/doi_main.py | prompt_force | def prompt_force():
"""
Ask the user if they want to force update files that were previously resolved
:return bool: response
"""
logger_doi_main.info("enter prompt_force")
count = 0
print("Do you want to force updates for previously resolved files? (y/n)")
while True:
force = inp... | python | def prompt_force():
"""
Ask the user if they want to force update files that were previously resolved
:return bool: response
"""
logger_doi_main.info("enter prompt_force")
count = 0
print("Do you want to force updates for previously resolved files? (y/n)")
while True:
force = inp... | [
"def",
"prompt_force",
"(",
")",
":",
"logger_doi_main",
".",
"info",
"(",
"\"enter prompt_force\"",
")",
"count",
"=",
"0",
"print",
"(",
"\"Do you want to force updates for previously resolved files? (y/n)\"",
")",
"while",
"True",
":",
"force",
"=",
"input",
"(",
... | Ask the user if they want to force update files that were previously resolved
:return bool: response | [
"Ask",
"the",
"user",
"if",
"they",
"want",
"to",
"force",
"update",
"files",
"that",
"were",
"previously",
"resolved",
":",
"return",
"bool",
":",
"response"
] | train | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/doi_main.py#L100-L125 |
useblocks/sphinxcontrib-needs | sphinxcontrib/needs/directives/needtable.py | process_needtables | def process_needtables(app, doctree, fromdocname):
"""
Replace all needtables nodes with a tale of filtered noded.
:param app:
:param doctree:
:param fromdocname:
:return:
"""
env = app.builder.env
for node in doctree.traverse(Needtable):
if not app.config.needs_include_nee... | python | def process_needtables(app, doctree, fromdocname):
"""
Replace all needtables nodes with a tale of filtered noded.
:param app:
:param doctree:
:param fromdocname:
:return:
"""
env = app.builder.env
for node in doctree.traverse(Needtable):
if not app.config.needs_include_nee... | [
"def",
"process_needtables",
"(",
"app",
",",
"doctree",
",",
"fromdocname",
")",
":",
"env",
"=",
"app",
".",
"builder",
".",
"env",
"for",
"node",
"in",
"doctree",
".",
"traverse",
"(",
"Needtable",
")",
":",
"if",
"not",
"app",
".",
"config",
".",
... | Replace all needtables nodes with a tale of filtered noded.
:param app:
:param doctree:
:param fromdocname:
:return: | [
"Replace",
"all",
"needtables",
"nodes",
"with",
"a",
"tale",
"of",
"filtered",
"noded",
"."
] | train | https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/directives/needtable.py#L76-L208 |
useblocks/sphinxcontrib-needs | sphinxcontrib/needs/directives/need.py | get_sections | def get_sections(need_info):
"""Gets the hierarchy of the section nodes as a list starting at the
section of the current need and then its parent sections"""
sections = []
current_node = need_info['target_node']
while current_node:
if isinstance(current_node, nodes.section):
titl... | python | def get_sections(need_info):
"""Gets the hierarchy of the section nodes as a list starting at the
section of the current need and then its parent sections"""
sections = []
current_node = need_info['target_node']
while current_node:
if isinstance(current_node, nodes.section):
titl... | [
"def",
"get_sections",
"(",
"need_info",
")",
":",
"sections",
"=",
"[",
"]",
"current_node",
"=",
"need_info",
"[",
"'target_node'",
"]",
"while",
"current_node",
":",
"if",
"isinstance",
"(",
"current_node",
",",
"nodes",
".",
"section",
")",
":",
"title",... | Gets the hierarchy of the section nodes as a list starting at the
section of the current need and then its parent sections | [
"Gets",
"the",
"hierarchy",
"of",
"the",
"section",
"nodes",
"as",
"a",
"list",
"starting",
"at",
"the",
"section",
"of",
"the",
"current",
"need",
"and",
"then",
"its",
"parent",
"sections"
] | train | https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/directives/need.py#L350-L365 |
useblocks/sphinxcontrib-needs | sphinxcontrib/needs/directives/need.py | purge_needs | def purge_needs(app, env, docname):
"""
Gets executed, if a doc file needs to be purged/ read in again.
So this code delete all found needs for the given docname.
"""
if not hasattr(env, 'needs_all_needs'):
return
env.needs_all_needs = {key: need for key, need in env.needs_all_needs.item... | python | def purge_needs(app, env, docname):
"""
Gets executed, if a doc file needs to be purged/ read in again.
So this code delete all found needs for the given docname.
"""
if not hasattr(env, 'needs_all_needs'):
return
env.needs_all_needs = {key: need for key, need in env.needs_all_needs.item... | [
"def",
"purge_needs",
"(",
"app",
",",
"env",
",",
"docname",
")",
":",
"if",
"not",
"hasattr",
"(",
"env",
",",
"'needs_all_needs'",
")",
":",
"return",
"env",
".",
"needs_all_needs",
"=",
"{",
"key",
":",
"need",
"for",
"key",
",",
"need",
"in",
"e... | Gets executed, if a doc file needs to be purged/ read in again.
So this code delete all found needs for the given docname. | [
"Gets",
"executed",
"if",
"a",
"doc",
"file",
"needs",
"to",
"be",
"purged",
"/",
"read",
"in",
"again",
".",
"So",
"this",
"code",
"delete",
"all",
"found",
"needs",
"for",
"the",
"given",
"docname",
"."
] | train | https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/directives/need.py#L368-L375 |
useblocks/sphinxcontrib-needs | sphinxcontrib/needs/directives/need.py | add_sections | def add_sections(app, doctree, fromdocname):
"""Add section titles to the needs as additional attributes that can
be used in tables and filters"""
needs = getattr(app.builder.env, 'needs_all_needs', {})
for key, need_info in needs.items():
sections = get_sections(need_info)
need_info['se... | python | def add_sections(app, doctree, fromdocname):
"""Add section titles to the needs as additional attributes that can
be used in tables and filters"""
needs = getattr(app.builder.env, 'needs_all_needs', {})
for key, need_info in needs.items():
sections = get_sections(need_info)
need_info['se... | [
"def",
"add_sections",
"(",
"app",
",",
"doctree",
",",
"fromdocname",
")",
":",
"needs",
"=",
"getattr",
"(",
"app",
".",
"builder",
".",
"env",
",",
"'needs_all_needs'",
",",
"{",
"}",
")",
"for",
"key",
",",
"need_info",
"in",
"needs",
".",
"items",... | Add section titles to the needs as additional attributes that can
be used in tables and filters | [
"Add",
"section",
"titles",
"to",
"the",
"needs",
"as",
"additional",
"attributes",
"that",
"can",
"be",
"used",
"in",
"tables",
"and",
"filters"
] | train | https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/directives/need.py#L378-L385 |
useblocks/sphinxcontrib-needs | sphinxcontrib/needs/directives/need.py | process_need_nodes | def process_need_nodes(app, doctree, fromdocname):
"""
Event handler to add title meta data (status, tags, links, ...) information to the Need node.
:param app:
:param doctree:
:param fromdocname:
:return:
"""
if not app.config.needs_include_needs:
for node in doctree.traverse(N... | python | def process_need_nodes(app, doctree, fromdocname):
"""
Event handler to add title meta data (status, tags, links, ...) information to the Need node.
:param app:
:param doctree:
:param fromdocname:
:return:
"""
if not app.config.needs_include_needs:
for node in doctree.traverse(N... | [
"def",
"process_need_nodes",
"(",
"app",
",",
"doctree",
",",
"fromdocname",
")",
":",
"if",
"not",
"app",
".",
"config",
".",
"needs_include_needs",
":",
"for",
"node",
"in",
"doctree",
".",
"traverse",
"(",
"Need",
")",
":",
"node",
".",
"parent",
".",... | Event handler to add title meta data (status, tags, links, ...) information to the Need node.
:param app:
:param doctree:
:param fromdocname:
:return: | [
"Event",
"handler",
"to",
"add",
"title",
"meta",
"data",
"(",
"status",
"tags",
"links",
"...",
")",
"information",
"to",
"the",
"Need",
"node",
"."
] | train | https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/directives/need.py#L388-L441 |
useblocks/sphinxcontrib-needs | sphinxcontrib/needs/directives/need.py | create_back_links | def create_back_links(env):
"""
Create back-links in all found needs.
But do this only once, as all needs are already collected and this sorting is for all
needs and not only for the ones of the current document.
:param env: sphinx enviroment
:return: None
"""
if env.needs_workflow['bac... | python | def create_back_links(env):
"""
Create back-links in all found needs.
But do this only once, as all needs are already collected and this sorting is for all
needs and not only for the ones of the current document.
:param env: sphinx enviroment
:return: None
"""
if env.needs_workflow['bac... | [
"def",
"create_back_links",
"(",
"env",
")",
":",
"if",
"env",
".",
"needs_workflow",
"[",
"'backlink_creation'",
"]",
":",
"return",
"needs",
"=",
"env",
".",
"needs_all_needs",
"for",
"key",
",",
"need",
"in",
"needs",
".",
"items",
"(",
")",
":",
"for... | Create back-links in all found needs.
But do this only once, as all needs are already collected and this sorting is for all
needs and not only for the ones of the current document.
:param env: sphinx enviroment
:return: None | [
"Create",
"back",
"-",
"links",
"in",
"all",
"found",
"needs",
".",
"But",
"do",
"this",
"only",
"once",
"as",
"all",
"needs",
"are",
"already",
"collected",
"and",
"this",
"sorting",
"is",
"for",
"all",
"needs",
"and",
"not",
"only",
"for",
"the",
"on... | train | https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/directives/need.py#L444-L476 |
useblocks/sphinxcontrib-needs | sphinxcontrib/needs/directives/need.py | construct_headline | def construct_headline(need_data, app):
"""
Constructs the node-structure for the headline/title container
:param need_data: need_info container
:return: node
"""
# need title calculation
title_type = '{}: '.format(need_data["type_name"])
title_headline = need_data["title"]
title_id ... | python | def construct_headline(need_data, app):
"""
Constructs the node-structure for the headline/title container
:param need_data: need_info container
:return: node
"""
# need title calculation
title_type = '{}: '.format(need_data["type_name"])
title_headline = need_data["title"]
title_id ... | [
"def",
"construct_headline",
"(",
"need_data",
",",
"app",
")",
":",
"# need title calculation",
"title_type",
"=",
"'{}: '",
".",
"format",
"(",
"need_data",
"[",
"\"type_name\"",
"]",
")",
"title_headline",
"=",
"need_data",
"[",
"\"title\"",
"]",
"title_id",
... | Constructs the node-structure for the headline/title container
:param need_data: need_info container
:return: node | [
"Constructs",
"the",
"node",
"-",
"structure",
"for",
"the",
"headline",
"/",
"title",
"container",
":",
"param",
"need_data",
":",
"need_info",
"container",
":",
"return",
":",
"node"
] | train | https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/directives/need.py#L479-L515 |
useblocks/sphinxcontrib-needs | sphinxcontrib/needs/directives/need.py | construct_meta | def construct_meta(need_data, env):
"""
Constructs the node-structure for the status container
:param need_data: need_info container
:return: node
"""
hide_options = env.config.needs_hide_options
if not isinstance(hide_options, list):
raise SphinxError('Config parameter needs_hide_o... | python | def construct_meta(need_data, env):
"""
Constructs the node-structure for the status container
:param need_data: need_info container
:return: node
"""
hide_options = env.config.needs_hide_options
if not isinstance(hide_options, list):
raise SphinxError('Config parameter needs_hide_o... | [
"def",
"construct_meta",
"(",
"need_data",
",",
"env",
")",
":",
"hide_options",
"=",
"env",
".",
"config",
".",
"needs_hide_options",
"if",
"not",
"isinstance",
"(",
"hide_options",
",",
"list",
")",
":",
"raise",
"SphinxError",
"(",
"'Config parameter needs_hi... | Constructs the node-structure for the status container
:param need_data: need_info container
:return: node | [
"Constructs",
"the",
"node",
"-",
"structure",
"for",
"the",
"status",
"container",
":",
"param",
"need_data",
":",
"need_info",
"container",
":",
"return",
":",
"node"
] | train | https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/directives/need.py#L518-L614 |
useblocks/sphinxcontrib-needs | sphinxcontrib/needs/directives/need.py | _fix_list_dyn_func | def _fix_list_dyn_func(list):
"""
This searches a list for dynamic function fragments, which may have been cut by generic searches for ",|;".
Example:
`link_a, [[copy('links', need_id)]]` this will be splitted in list of 3 parts:
#. link_a
#. [[copy('links'
#. need_id)]]
This function... | python | def _fix_list_dyn_func(list):
"""
This searches a list for dynamic function fragments, which may have been cut by generic searches for ",|;".
Example:
`link_a, [[copy('links', need_id)]]` this will be splitted in list of 3 parts:
#. link_a
#. [[copy('links'
#. need_id)]]
This function... | [
"def",
"_fix_list_dyn_func",
"(",
"list",
")",
":",
"open_func_string",
"=",
"False",
"new_list",
"=",
"[",
"]",
"for",
"element",
"in",
"list",
":",
"if",
"'[['",
"in",
"element",
":",
"open_func_string",
"=",
"True",
"new_link",
"=",
"[",
"element",
"]",... | This searches a list for dynamic function fragments, which may have been cut by generic searches for ",|;".
Example:
`link_a, [[copy('links', need_id)]]` this will be splitted in list of 3 parts:
#. link_a
#. [[copy('links'
#. need_id)]]
This function fixes the above list to the following:
... | [
"This",
"searches",
"a",
"list",
"for",
"dynamic",
"function",
"fragments",
"which",
"may",
"have",
"been",
"cut",
"by",
"generic",
"searches",
"for",
"|",
";",
"."
] | train | https://github.com/useblocks/sphinxcontrib-needs/blob/f49af4859a74e9fe76de5b9133c01335ac6ae191/sphinxcontrib/needs/directives/need.py#L617-L651 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.