repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
AustralianSynchrotron/lightflow | lightflow/workflows.py | events | def events(config):
""" Return a generator that yields workflow events.
For every workflow event that is sent from celery this generator yields an event
object.
Args:
config (Config): Reference to the configuration object from which the
settings are retrieved.
Returns:
... | python | def events(config):
""" Return a generator that yields workflow events.
For every workflow event that is sent from celery this generator yields an event
object.
Args:
config (Config): Reference to the configuration object from which the
settings are retrieved.
Returns:
... | [
"def",
"events",
"(",
"config",
")",
":",
"celery_app",
"=",
"create_app",
"(",
"config",
")",
"for",
"event",
"in",
"event_stream",
"(",
"celery_app",
",",
"filter_by_prefix",
"=",
"'task'",
")",
":",
"try",
":",
"yield",
"create_event_model",
"(",
"event",... | Return a generator that yields workflow events.
For every workflow event that is sent from celery this generator yields an event
object.
Args:
config (Config): Reference to the configuration object from which the
settings are retrieved.
Returns:
generator: A generator that... | [
"Return",
"a",
"generator",
"that",
"yields",
"workflow",
"events",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/workflows.py#L177-L197 | train | Returns a generator that yields workflow events. |
AustralianSynchrotron/lightflow | lightflow/tasks/bash_task.py | BashTaskOutputReader.run | def run(self):
""" Drain the process output streams. """
read_stdout = partial(self._read_output, stream=self._process.stdout,
callback=self._callback_stdout,
output_file=self._stdout_file)
read_stderr = partial(self._read_output, stre... | python | def run(self):
""" Drain the process output streams. """
read_stdout = partial(self._read_output, stream=self._process.stdout,
callback=self._callback_stdout,
output_file=self._stdout_file)
read_stderr = partial(self._read_output, stre... | [
"def",
"run",
"(",
"self",
")",
":",
"read_stdout",
"=",
"partial",
"(",
"self",
".",
"_read_output",
",",
"stream",
"=",
"self",
".",
"_process",
".",
"stdout",
",",
"callback",
"=",
"self",
".",
"_callback_stdout",
",",
"output_file",
"=",
"self",
".",... | Drain the process output streams. | [
"Drain",
"the",
"process",
"output",
"streams",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/tasks/bash_task.py#L64-L91 | train | Runs the process and returns the current state of the application. |
AustralianSynchrotron/lightflow | lightflow/tasks/bash_task.py | BashTaskOutputReader._read_output | def _read_output(self, stream, callback, output_file):
""" Read the output of the process, executed the callback and save the output.
Args:
stream: A file object pointing to the output stream that should be read.
callback(callable, None): A callback function that is called for e... | python | def _read_output(self, stream, callback, output_file):
""" Read the output of the process, executed the callback and save the output.
Args:
stream: A file object pointing to the output stream that should be read.
callback(callable, None): A callback function that is called for e... | [
"def",
"_read_output",
"(",
"self",
",",
"stream",
",",
"callback",
",",
"output_file",
")",
":",
"if",
"(",
"callback",
"is",
"None",
"and",
"output_file",
"is",
"None",
")",
"or",
"stream",
".",
"closed",
":",
"return",
"False",
"line",
"=",
"stream",
... | Read the output of the process, executed the callback and save the output.
Args:
stream: A file object pointing to the output stream that should be read.
callback(callable, None): A callback function that is called for each new
line of output.
output_file: A ... | [
"Read",
"the",
"output",
"of",
"the",
"process",
"executed",
"the",
"callback",
"and",
"save",
"the",
"output",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/tasks/bash_task.py#L93-L119 | train | Read the output of the process and execute the callback and save the output. |
AustralianSynchrotron/lightflow | lightflow/tasks/bash_task.py | BashTask.run | def run(self, data, store, signal, context, **kwargs):
""" The main run method of the Python task.
Args:
data (:class:`.MultiTaskData`): The data object that has been passed from the
predecessor task.
store (:class:`.DataStoreDocument`): The persistent data store... | python | def run(self, data, store, signal, context, **kwargs):
""" The main run method of the Python task.
Args:
data (:class:`.MultiTaskData`): The data object that has been passed from the
predecessor task.
store (:class:`.DataStoreDocument`): The persistent data store... | [
"def",
"run",
"(",
"self",
",",
"data",
",",
"store",
",",
"signal",
",",
"context",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"self",
".",
"params",
".",
"eval",
"(",
"data",
",",
"store",
",",
"exclude",
"=",
"[",
"'command'",
"]",
")",... | The main run method of the Python task.
Args:
data (:class:`.MultiTaskData`): The data object that has been passed from the
predecessor task.
store (:class:`.DataStoreDocument`): The persistent data store object that allows the
task to store data for acce... | [
"The",
"main",
"run",
"method",
"of",
"the",
"Python",
"task",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/tasks/bash_task.py#L293-L389 | train | This method is called by the main run method of the Python task. It runs the command and sends the output to the process. |
AustralianSynchrotron/lightflow | lightflow/tasks/bash_task.py | BashTask._run_as | def _run_as(user, group):
""" Function wrapper that sets the user and group for the process """
def wrapper():
if user is not None:
os.setuid(user)
if group is not None:
os.setgid(group)
return wrapper | python | def _run_as(user, group):
""" Function wrapper that sets the user and group for the process """
def wrapper():
if user is not None:
os.setuid(user)
if group is not None:
os.setgid(group)
return wrapper | [
"def",
"_run_as",
"(",
"user",
",",
"group",
")",
":",
"def",
"wrapper",
"(",
")",
":",
"if",
"user",
"is",
"not",
"None",
":",
"os",
".",
"setuid",
"(",
"user",
")",
"if",
"group",
"is",
"not",
"None",
":",
"os",
".",
"setgid",
"(",
"group",
"... | Function wrapper that sets the user and group for the process | [
"Function",
"wrapper",
"that",
"sets",
"the",
"user",
"and",
"group",
"for",
"the",
"process"
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/tasks/bash_task.py#L392-L399 | train | Function wrapper that sets the user and group for the process |
AustralianSynchrotron/lightflow | lightflow/models/parameters.py | Option.convert | def convert(self, value):
""" Convert the specified value to the type of the option.
Args:
value: The value that should be converted.
Returns:
The value with the type given by the option.
"""
if self._type is str:
return str(value)
el... | python | def convert(self, value):
""" Convert the specified value to the type of the option.
Args:
value: The value that should be converted.
Returns:
The value with the type given by the option.
"""
if self._type is str:
return str(value)
el... | [
"def",
"convert",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"_type",
"is",
"str",
":",
"return",
"str",
"(",
"value",
")",
"elif",
"self",
".",
"_type",
"is",
"int",
":",
"try",
":",
"return",
"int",
"(",
"value",
")",
"except",
"("... | Convert the specified value to the type of the option.
Args:
value: The value that should be converted.
Returns:
The value with the type given by the option. | [
"Convert",
"the",
"specified",
"value",
"to",
"the",
"type",
"of",
"the",
"option",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/parameters.py#L62-L93 | train | Converts the specified value to the type given by the option. |
AustralianSynchrotron/lightflow | lightflow/models/parameters.py | Parameters.check_missing | def check_missing(self, args):
""" Returns the names of all options that are required but were not specified.
All options that don't have a default value are required in order to run the
workflow.
Args:
args (dict): A dictionary of the provided arguments that is checked for... | python | def check_missing(self, args):
""" Returns the names of all options that are required but were not specified.
All options that don't have a default value are required in order to run the
workflow.
Args:
args (dict): A dictionary of the provided arguments that is checked for... | [
"def",
"check_missing",
"(",
"self",
",",
"args",
")",
":",
"return",
"[",
"opt",
".",
"name",
"for",
"opt",
"in",
"self",
"if",
"(",
"opt",
".",
"name",
"not",
"in",
"args",
")",
"and",
"(",
"opt",
".",
"default",
"is",
"None",
")",
"]"
] | Returns the names of all options that are required but were not specified.
All options that don't have a default value are required in order to run the
workflow.
Args:
args (dict): A dictionary of the provided arguments that is checked for
missing options.
... | [
"Returns",
"the",
"names",
"of",
"all",
"options",
"that",
"are",
"required",
"but",
"were",
"not",
"specified",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/parameters.py#L99-L114 | train | Checks that all options that are not specified in the passed arguments are present in the current configuration. |
AustralianSynchrotron/lightflow | lightflow/models/parameters.py | Parameters.consolidate | def consolidate(self, args):
""" Consolidate the provided arguments.
If the provided arguments have matching options, this performs a type conversion.
For any option that has a default value and is not present in the provided
arguments, the default value is added.
Args:
... | python | def consolidate(self, args):
""" Consolidate the provided arguments.
If the provided arguments have matching options, this performs a type conversion.
For any option that has a default value and is not present in the provided
arguments, the default value is added.
Args:
... | [
"def",
"consolidate",
"(",
"self",
",",
"args",
")",
":",
"result",
"=",
"dict",
"(",
"args",
")",
"for",
"opt",
"in",
"self",
":",
"if",
"opt",
".",
"name",
"in",
"result",
":",
"result",
"[",
"opt",
".",
"name",
"]",
"=",
"opt",
".",
"convert",... | Consolidate the provided arguments.
If the provided arguments have matching options, this performs a type conversion.
For any option that has a default value and is not present in the provided
arguments, the default value is added.
Args:
args (dict): A dictionary of the pro... | [
"Consolidate",
"the",
"provided",
"arguments",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/parameters.py#L116-L139 | train | Consolidate the provided arguments. |
AustralianSynchrotron/lightflow | lightflow/models/dag.py | Dag.define | def define(self, schema, *, validate=True):
""" Store the task graph definition (schema).
The schema has to adhere to the following rules:
A key in the schema dict represents a parent task and the value one or more
children:
{parent: [child]} or {parent: [child1, child2]}
... | python | def define(self, schema, *, validate=True):
""" Store the task graph definition (schema).
The schema has to adhere to the following rules:
A key in the schema dict represents a parent task and the value one or more
children:
{parent: [child]} or {parent: [child1, child2]}
... | [
"def",
"define",
"(",
"self",
",",
"schema",
",",
"*",
",",
"validate",
"=",
"True",
")",
":",
"self",
".",
"_schema",
"=",
"schema",
"if",
"validate",
":",
"self",
".",
"validate",
"(",
"self",
".",
"make_graph",
"(",
"self",
".",
"_schema",
")",
... | Store the task graph definition (schema).
The schema has to adhere to the following rules:
A key in the schema dict represents a parent task and the value one or more
children:
{parent: [child]} or {parent: [child1, child2]}
The data output of one task can be routed to a l... | [
"Store",
"the",
"task",
"graph",
"definition",
"(",
"schema",
")",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/dag.py#L77-L100 | train | Define the task graph definition. |
AustralianSynchrotron/lightflow | lightflow/models/dag.py | Dag.run | def run(self, config, workflow_id, signal, *, data=None):
""" Run the dag by calling the tasks in the correct order.
Args:
config (Config): Reference to the configuration object from which the
settings for the dag are retrieved.
workflow_id (str): Th... | python | def run(self, config, workflow_id, signal, *, data=None):
""" Run the dag by calling the tasks in the correct order.
Args:
config (Config): Reference to the configuration object from which the
settings for the dag are retrieved.
workflow_id (str): Th... | [
"def",
"run",
"(",
"self",
",",
"config",
",",
"workflow_id",
",",
"signal",
",",
"*",
",",
"data",
"=",
"None",
")",
":",
"graph",
"=",
"self",
".",
"make_graph",
"(",
"self",
".",
"_schema",
")",
"# pre-checks",
"self",
".",
"validate",
"(",
"graph... | Run the dag by calling the tasks in the correct order.
Args:
config (Config): Reference to the configuration object from which the
settings for the dag are retrieved.
workflow_id (str): The unique ID of the workflow that runs this dag.
signal (Da... | [
"Run",
"the",
"dag",
"by",
"calling",
"the",
"tasks",
"in",
"the",
"correct",
"order",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/dag.py#L102-L241 | train | Runs the dag by calling the tasks in the correct order. |
AustralianSynchrotron/lightflow | lightflow/models/dag.py | Dag.validate | def validate(self, graph):
""" Validate the graph by checking whether it is a directed acyclic graph.
Args:
graph (DiGraph): Reference to a DiGraph object from NetworkX.
Raises:
DirectedAcyclicGraphInvalid: If the graph is not a valid dag.
"""
if not nx.... | python | def validate(self, graph):
""" Validate the graph by checking whether it is a directed acyclic graph.
Args:
graph (DiGraph): Reference to a DiGraph object from NetworkX.
Raises:
DirectedAcyclicGraphInvalid: If the graph is not a valid dag.
"""
if not nx.... | [
"def",
"validate",
"(",
"self",
",",
"graph",
")",
":",
"if",
"not",
"nx",
".",
"is_directed_acyclic_graph",
"(",
"graph",
")",
":",
"raise",
"DirectedAcyclicGraphInvalid",
"(",
"graph_name",
"=",
"self",
".",
"_name",
")"
] | Validate the graph by checking whether it is a directed acyclic graph.
Args:
graph (DiGraph): Reference to a DiGraph object from NetworkX.
Raises:
DirectedAcyclicGraphInvalid: If the graph is not a valid dag. | [
"Validate",
"the",
"graph",
"by",
"checking",
"whether",
"it",
"is",
"a",
"directed",
"acyclic",
"graph",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/dag.py#L243-L253 | train | Validate the graph by checking whether it is a directed acyclic graph. |
AustralianSynchrotron/lightflow | lightflow/models/dag.py | Dag.make_graph | def make_graph(schema):
""" Construct the task graph (dag) from a given schema.
Parses the graph schema definition and creates the task graph. Tasks are the
vertices of the graph and the connections defined in the schema become the edges.
A key in the schema dict represents a parent ta... | python | def make_graph(schema):
""" Construct the task graph (dag) from a given schema.
Parses the graph schema definition and creates the task graph. Tasks are the
vertices of the graph and the connections defined in the schema become the edges.
A key in the schema dict represents a parent ta... | [
"def",
"make_graph",
"(",
"schema",
")",
":",
"if",
"schema",
"is",
"None",
":",
"raise",
"DirectedAcyclicGraphUndefined",
"(",
")",
"# sanitize the input schema such that it follows the structure:",
"# {parent: {child_1: slot_1, child_2: slot_2, ...}, ...}",
"sanitized_schema",... | Construct the task graph (dag) from a given schema.
Parses the graph schema definition and creates the task graph. Tasks are the
vertices of the graph and the connections defined in the schema become the edges.
A key in the schema dict represents a parent task and the value one or more
... | [
"Construct",
"the",
"task",
"graph",
"(",
"dag",
")",
"from",
"a",
"given",
"schema",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/dag.py#L256-L318 | train | Constructs a graph object from a given schema. |
AustralianSynchrotron/lightflow | lightflow/models/task_data.py | TaskData.merge | def merge(self, dataset):
""" Merge the specified dataset on top of the existing data.
This replaces all values in the existing dataset with the values from the
given dataset.
Args:
dataset (TaskData): A reference to the TaskData object that should be merged
... | python | def merge(self, dataset):
""" Merge the specified dataset on top of the existing data.
This replaces all values in the existing dataset with the values from the
given dataset.
Args:
dataset (TaskData): A reference to the TaskData object that should be merged
... | [
"def",
"merge",
"(",
"self",
",",
"dataset",
")",
":",
"def",
"merge_data",
"(",
"source",
",",
"dest",
")",
":",
"for",
"key",
",",
"value",
"in",
"source",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"m... | Merge the specified dataset on top of the existing data.
This replaces all values in the existing dataset with the values from the
given dataset.
Args:
dataset (TaskData): A reference to the TaskData object that should be merged
on top of the existing object. | [
"Merge",
"the",
"specified",
"dataset",
"on",
"top",
"of",
"the",
"existing",
"data",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_data.py#L59-L81 | train | Merges the specified dataset on top of the existing data. |
AustralianSynchrotron/lightflow | lightflow/models/task_data.py | MultiTaskData.add_dataset | def add_dataset(self, task_name, dataset=None, *, aliases=None):
""" Add a new dataset to the MultiTaskData.
Args:
task_name (str): The name of the task from which the dataset was received.
dataset (TaskData): The dataset that should be added.
aliases (list): A list ... | python | def add_dataset(self, task_name, dataset=None, *, aliases=None):
""" Add a new dataset to the MultiTaskData.
Args:
task_name (str): The name of the task from which the dataset was received.
dataset (TaskData): The dataset that should be added.
aliases (list): A list ... | [
"def",
"add_dataset",
"(",
"self",
",",
"task_name",
",",
"dataset",
"=",
"None",
",",
"*",
",",
"aliases",
"=",
"None",
")",
":",
"self",
".",
"_datasets",
".",
"append",
"(",
"dataset",
"if",
"dataset",
"is",
"not",
"None",
"else",
"TaskData",
"(",
... | Add a new dataset to the MultiTaskData.
Args:
task_name (str): The name of the task from which the dataset was received.
dataset (TaskData): The dataset that should be added.
aliases (list): A list of aliases that should be registered with the dataset. | [
"Add",
"a",
"new",
"dataset",
"to",
"the",
"MultiTaskData",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_data.py#L146-L163 | train | Adds a new dataset to the MultiTaskData. |
AustralianSynchrotron/lightflow | lightflow/models/task_data.py | MultiTaskData.add_alias | def add_alias(self, alias, index):
""" Add an alias pointing to the specified index.
Args:
alias (str): The alias that should point to the given index.
index (int): The index of the dataset for which an alias should be added.
Raises:
DataInvalidIndex: If the... | python | def add_alias(self, alias, index):
""" Add an alias pointing to the specified index.
Args:
alias (str): The alias that should point to the given index.
index (int): The index of the dataset for which an alias should be added.
Raises:
DataInvalidIndex: If the... | [
"def",
"add_alias",
"(",
"self",
",",
"alias",
",",
"index",
")",
":",
"if",
"index",
">=",
"len",
"(",
"self",
".",
"_datasets",
")",
":",
"raise",
"DataInvalidIndex",
"(",
"'A dataset with index {} does not exist'",
".",
"format",
"(",
"index",
")",
")",
... | Add an alias pointing to the specified index.
Args:
alias (str): The alias that should point to the given index.
index (int): The index of the dataset for which an alias should be added.
Raises:
DataInvalidIndex: If the index does not represent a valid dataset. | [
"Add",
"an",
"alias",
"pointing",
"to",
"the",
"specified",
"index",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_data.py#L165-L177 | train | Adds an alias pointing to the given index. |
AustralianSynchrotron/lightflow | lightflow/models/task_data.py | MultiTaskData.flatten | def flatten(self, in_place=True):
""" Merge all datasets into a single dataset.
The default dataset is the last dataset to be merged, as it is considered to be
the primary source of information and should overwrite all existing fields with
the same key.
Args:
in_pla... | python | def flatten(self, in_place=True):
""" Merge all datasets into a single dataset.
The default dataset is the last dataset to be merged, as it is considered to be
the primary source of information and should overwrite all existing fields with
the same key.
Args:
in_pla... | [
"def",
"flatten",
"(",
"self",
",",
"in_place",
"=",
"True",
")",
":",
"new_dataset",
"=",
"TaskData",
"(",
")",
"for",
"i",
",",
"dataset",
"in",
"enumerate",
"(",
"self",
".",
"_datasets",
")",
":",
"if",
"i",
"!=",
"self",
".",
"_default_index",
"... | Merge all datasets into a single dataset.
The default dataset is the last dataset to be merged, as it is considered to be
the primary source of information and should overwrite all existing fields with
the same key.
Args:
in_place (bool): Set to ``True`` to replace the exis... | [
"Merge",
"all",
"datasets",
"into",
"a",
"single",
"dataset",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_data.py#L179-L211 | train | Returns a new MultiTaskData object containing all datasets and all aliases. |
AustralianSynchrotron/lightflow | lightflow/models/task_data.py | MultiTaskData.set_default_by_alias | def set_default_by_alias(self, alias):
""" Set the default dataset by its alias.
After changing the default dataset, all calls without explicitly specifying the
dataset by index or alias will be redirected to this dataset.
Args:
alias (str): The alias of the dataset that sh... | python | def set_default_by_alias(self, alias):
""" Set the default dataset by its alias.
After changing the default dataset, all calls without explicitly specifying the
dataset by index or alias will be redirected to this dataset.
Args:
alias (str): The alias of the dataset that sh... | [
"def",
"set_default_by_alias",
"(",
"self",
",",
"alias",
")",
":",
"if",
"alias",
"not",
"in",
"self",
".",
"_aliases",
":",
"raise",
"DataInvalidAlias",
"(",
"'A dataset with alias {} does not exist'",
".",
"format",
"(",
"alias",
")",
")",
"self",
".",
"_de... | Set the default dataset by its alias.
After changing the default dataset, all calls without explicitly specifying the
dataset by index or alias will be redirected to this dataset.
Args:
alias (str): The alias of the dataset that should be made the default.
Raises:
... | [
"Set",
"the",
"default",
"dataset",
"by",
"its",
"alias",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_data.py#L213-L228 | train | Set the default dataset by its alias. |
AustralianSynchrotron/lightflow | lightflow/models/task_data.py | MultiTaskData.set_default_by_index | def set_default_by_index(self, index):
""" Set the default dataset by its index.
After changing the default dataset, all calls without explicitly specifying the
dataset by index or alias will be redirected to this dataset.
Args:
index (int): The index of the dataset that sh... | python | def set_default_by_index(self, index):
""" Set the default dataset by its index.
After changing the default dataset, all calls without explicitly specifying the
dataset by index or alias will be redirected to this dataset.
Args:
index (int): The index of the dataset that sh... | [
"def",
"set_default_by_index",
"(",
"self",
",",
"index",
")",
":",
"if",
"index",
">=",
"len",
"(",
"self",
".",
"_datasets",
")",
":",
"raise",
"DataInvalidIndex",
"(",
"'A dataset with index {} does not exist'",
".",
"format",
"(",
"index",
")",
")",
"self"... | Set the default dataset by its index.
After changing the default dataset, all calls without explicitly specifying the
dataset by index or alias will be redirected to this dataset.
Args:
index (int): The index of the dataset that should be made the default.
Raises:
... | [
"Set",
"the",
"default",
"dataset",
"by",
"its",
"index",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_data.py#L230-L245 | train | Set the default dataset by its index. |
AustralianSynchrotron/lightflow | lightflow/models/task_data.py | MultiTaskData.get_by_alias | def get_by_alias(self, alias):
""" Return a dataset by its alias.
Args:
alias (str): The alias of the dataset that should be returned.
Raises:
DataInvalidAlias: If the alias does not represent a valid dataset.
"""
if alias not in self._aliases:
... | python | def get_by_alias(self, alias):
""" Return a dataset by its alias.
Args:
alias (str): The alias of the dataset that should be returned.
Raises:
DataInvalidAlias: If the alias does not represent a valid dataset.
"""
if alias not in self._aliases:
... | [
"def",
"get_by_alias",
"(",
"self",
",",
"alias",
")",
":",
"if",
"alias",
"not",
"in",
"self",
".",
"_aliases",
":",
"raise",
"DataInvalidAlias",
"(",
"'A dataset with alias {} does not exist'",
".",
"format",
"(",
"alias",
")",
")",
"return",
"self",
".",
... | Return a dataset by its alias.
Args:
alias (str): The alias of the dataset that should be returned.
Raises:
DataInvalidAlias: If the alias does not represent a valid dataset. | [
"Return",
"a",
"dataset",
"by",
"its",
"alias",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_data.py#L247-L259 | train | Return a dataset by its alias. |
AustralianSynchrotron/lightflow | lightflow/models/task_data.py | MultiTaskData.get_by_index | def get_by_index(self, index):
""" Return a dataset by its index.
Args:
index (int): The index of the dataset that should be returned.
Raises:
DataInvalidIndex: If the index does not represent a valid dataset.
"""
if index >= len(self._datasets):
... | python | def get_by_index(self, index):
""" Return a dataset by its index.
Args:
index (int): The index of the dataset that should be returned.
Raises:
DataInvalidIndex: If the index does not represent a valid dataset.
"""
if index >= len(self._datasets):
... | [
"def",
"get_by_index",
"(",
"self",
",",
"index",
")",
":",
"if",
"index",
">=",
"len",
"(",
"self",
".",
"_datasets",
")",
":",
"raise",
"DataInvalidIndex",
"(",
"'A dataset with index {} does not exist'",
".",
"format",
"(",
"index",
")",
")",
"return",
"s... | Return a dataset by its index.
Args:
index (int): The index of the dataset that should be returned.
Raises:
DataInvalidIndex: If the index does not represent a valid dataset. | [
"Return",
"a",
"dataset",
"by",
"its",
"index",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_data.py#L261-L273 | train | Return a dataset by its index. |
AustralianSynchrotron/lightflow | lightflow/tasks/python_task.py | PythonTask.run | def run(self, data, store, signal, context, **kwargs):
""" The main run method of the Python task.
Args:
data (:class:`.MultiTaskData`): The data object that has been passed from the
predecessor task.
store (:class:`.DataStoreDocument`): The persistent data store... | python | def run(self, data, store, signal, context, **kwargs):
""" The main run method of the Python task.
Args:
data (:class:`.MultiTaskData`): The data object that has been passed from the
predecessor task.
store (:class:`.DataStoreDocument`): The persistent data store... | [
"def",
"run",
"(",
"self",
",",
"data",
",",
"store",
",",
"signal",
",",
"context",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_callback",
"is",
"not",
"None",
":",
"result",
"=",
"self",
".",
"_callback",
"(",
"data",
",",
"store",
... | The main run method of the Python task.
Args:
data (:class:`.MultiTaskData`): The data object that has been passed from the
predecessor task.
store (:class:`.DataStoreDocument`): The persistent data store object that allows the
task to store data for acce... | [
"The",
"main",
"run",
"method",
"of",
"the",
"Python",
"task",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/tasks/python_task.py#L80-L99 | train | This method is called by the main run method of the Python task. It is called by the main run method of the Python task. |
AustralianSynchrotron/lightflow | lightflow/models/task_context.py | TaskContext.to_dict | def to_dict(self):
""" Return the task context content as a dictionary. """
return {
'task_name': self.task_name,
'dag_name': self.dag_name,
'workflow_name': self.workflow_name,
'workflow_id': self.workflow_id,
'worker_hostname': self.worker_ho... | python | def to_dict(self):
""" Return the task context content as a dictionary. """
return {
'task_name': self.task_name,
'dag_name': self.dag_name,
'workflow_name': self.workflow_name,
'workflow_id': self.workflow_id,
'worker_hostname': self.worker_ho... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"return",
"{",
"'task_name'",
":",
"self",
".",
"task_name",
",",
"'dag_name'",
":",
"self",
".",
"dag_name",
",",
"'workflow_name'",
":",
"self",
".",
"workflow_name",
",",
"'workflow_id'",
":",
"self",
".",
"workf... | Return the task context content as a dictionary. | [
"Return",
"the",
"task",
"context",
"content",
"as",
"a",
"dictionary",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_context.py#L21-L29 | train | Return the task context content as a dictionary. |
AustralianSynchrotron/lightflow | lightflow/workers.py | start_worker | def start_worker(queues, config, *, name=None, celery_args=None, check_datastore=True):
""" Start a worker process.
Args:
queues (list): List of queue names this worker accepts jobs from.
config (Config): Reference to the configuration object from which the
settings for the worker a... | python | def start_worker(queues, config, *, name=None, celery_args=None, check_datastore=True):
""" Start a worker process.
Args:
queues (list): List of queue names this worker accepts jobs from.
config (Config): Reference to the configuration object from which the
settings for the worker a... | [
"def",
"start_worker",
"(",
"queues",
",",
"config",
",",
"*",
",",
"name",
"=",
"None",
",",
"celery_args",
"=",
"None",
",",
"check_datastore",
"=",
"True",
")",
":",
"celery_app",
"=",
"create_app",
"(",
"config",
")",
"if",
"check_datastore",
":",
"w... | Start a worker process.
Args:
queues (list): List of queue names this worker accepts jobs from.
config (Config): Reference to the configuration object from which the
settings for the worker are retrieved.
name (string): Unique name for the worker. The hostname template variables... | [
"Start",
"a",
"worker",
"process",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/workers.py#L10-L42 | train | Start a worker process. |
AustralianSynchrotron/lightflow | lightflow/workers.py | stop_worker | def stop_worker(config, *, worker_ids=None):
""" Stop a worker process.
Args:
config (Config): Reference to the configuration object from which the
settings for the worker are retrieved.
worker_ids (list): An optional list of ids for the worker that should be stopped.
"""
if... | python | def stop_worker(config, *, worker_ids=None):
""" Stop a worker process.
Args:
config (Config): Reference to the configuration object from which the
settings for the worker are retrieved.
worker_ids (list): An optional list of ids for the worker that should be stopped.
"""
if... | [
"def",
"stop_worker",
"(",
"config",
",",
"*",
",",
"worker_ids",
"=",
"None",
")",
":",
"if",
"worker_ids",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"worker_ids",
",",
"list",
")",
":",
"worker_ids",
"=",
"[",
"worker_ids",
"]",
"celery_app... | Stop a worker process.
Args:
config (Config): Reference to the configuration object from which the
settings for the worker are retrieved.
worker_ids (list): An optional list of ids for the worker that should be stopped. | [
"Stop",
"a",
"worker",
"process",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/workers.py#L45-L57 | train | Stop a worker process. |
AustralianSynchrotron/lightflow | lightflow/workers.py | list_workers | def list_workers(config, *, filter_by_queues=None):
""" Return a list of all available workers.
Args:
config (Config): Reference to the configuration object from which the
settings are retrieved.
filter_by_queues (list): Restrict the returned workers to workers that listen to
... | python | def list_workers(config, *, filter_by_queues=None):
""" Return a list of all available workers.
Args:
config (Config): Reference to the configuration object from which the
settings are retrieved.
filter_by_queues (list): Restrict the returned workers to workers that listen to
... | [
"def",
"list_workers",
"(",
"config",
",",
"*",
",",
"filter_by_queues",
"=",
"None",
")",
":",
"celery_app",
"=",
"create_app",
"(",
"config",
")",
"worker_stats",
"=",
"celery_app",
".",
"control",
".",
"inspect",
"(",
")",
".",
"stats",
"(",
")",
"que... | Return a list of all available workers.
Args:
config (Config): Reference to the configuration object from which the
settings are retrieved.
filter_by_queues (list): Restrict the returned workers to workers that listen to
at least one of the queue names in this list.
Ret... | [
"Return",
"a",
"list",
"of",
"all",
"available",
"workers",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/workers.py#L60-L93 | train | Return a list of all available workers. |
AustralianSynchrotron/lightflow | lightflow/models/task_parameters.py | TaskParameters.eval | def eval(self, data, data_store, *, exclude=None):
""" Return a new object in which callable parameters have been evaluated.
Native types are not touched and simply returned, while callable methods are
executed and their return value is returned.
Args:
data (MultiTaskData):... | python | def eval(self, data, data_store, *, exclude=None):
""" Return a new object in which callable parameters have been evaluated.
Native types are not touched and simply returned, while callable methods are
executed and their return value is returned.
Args:
data (MultiTaskData):... | [
"def",
"eval",
"(",
"self",
",",
"data",
",",
"data_store",
",",
"*",
",",
"exclude",
"=",
"None",
")",
":",
"exclude",
"=",
"[",
"]",
"if",
"exclude",
"is",
"None",
"else",
"exclude",
"result",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"s... | Return a new object in which callable parameters have been evaluated.
Native types are not touched and simply returned, while callable methods are
executed and their return value is returned.
Args:
data (MultiTaskData): The data object that has been passed from the
... | [
"Return",
"a",
"new",
"object",
"in",
"which",
"callable",
"parameters",
"have",
"been",
"evaluated",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_parameters.py#L60-L90 | train | Evaluate the callable parameters of the current object. |
AustralianSynchrotron/lightflow | lightflow/models/task_parameters.py | TaskParameters.eval_single | def eval_single(self, key, data, data_store):
""" Evaluate the value of a single parameter taking into account callables .
Native types are not touched and simply returned, while callable methods are
executed and their return value is returned.
Args:
key (str): The name of ... | python | def eval_single(self, key, data, data_store):
""" Evaluate the value of a single parameter taking into account callables .
Native types are not touched and simply returned, while callable methods are
executed and their return value is returned.
Args:
key (str): The name of ... | [
"def",
"eval_single",
"(",
"self",
",",
"key",
",",
"data",
",",
"data_store",
")",
":",
"if",
"key",
"in",
"self",
":",
"value",
"=",
"self",
"[",
"key",
"]",
"if",
"value",
"is",
"not",
"None",
"and",
"callable",
"(",
"value",
")",
":",
"return",... | Evaluate the value of a single parameter taking into account callables .
Native types are not touched and simply returned, while callable methods are
executed and their return value is returned.
Args:
key (str): The name of the parameter that should be evaluated.
data (... | [
"Evaluate",
"the",
"value",
"of",
"a",
"single",
"parameter",
"taking",
"into",
"account",
"callables",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task_parameters.py#L92-L114 | train | Evaluate the value of a single parameter taking into account callables. |
dh1tw/pyhamtools | pyhamtools/qsl.py | get_lotw_users | def get_lotw_users(**kwargs):
"""Download the latest offical list of `ARRL Logbook of the World (LOTW)`__ users.
Args:
url (str, optional): Download URL
Returns:
dict: Dictionary containing the callsign (unicode) date of the last LOTW upload (datetime)
Raises:
... | python | def get_lotw_users(**kwargs):
"""Download the latest offical list of `ARRL Logbook of the World (LOTW)`__ users.
Args:
url (str, optional): Download URL
Returns:
dict: Dictionary containing the callsign (unicode) date of the last LOTW upload (datetime)
Raises:
... | [
"def",
"get_lotw_users",
"(",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"\"\"",
"lotw",
"=",
"{",
"}",
"try",
":",
"url",
"=",
"kwargs",
"[",
"'url'",
"]",
"except",
"KeyError",
":",
"# url = \"http://wd5eae.org/LoTW_Data.txt\"",
"url",
"=",
"\"https://lotw.... | Download the latest offical list of `ARRL Logbook of the World (LOTW)`__ users.
Args:
url (str, optional): Download URL
Returns:
dict: Dictionary containing the callsign (unicode) date of the last LOTW upload (datetime)
Raises:
IOError: When network is unav... | [
"Download",
"the",
"latest",
"offical",
"list",
"of",
"ARRL",
"Logbook",
"of",
"the",
"World",
"(",
"LOTW",
")",
"__",
"users",
"."
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/qsl.py#L12-L69 | train | Download the latest offical list of the LOTW User Activity of the World and return a dictionary containing the callsign date of the last LOTW upload |
dh1tw/pyhamtools | pyhamtools/qsl.py | get_clublog_users | def get_clublog_users(**kwargs):
"""Download the latest offical list of `Clublog`__ users.
Args:
url (str, optional): Download URL
Returns:
dict: Dictionary containing (if data available) the fields:
firstqso, lastqso, last-lotw, lastupload (datetime),
... | python | def get_clublog_users(**kwargs):
"""Download the latest offical list of `Clublog`__ users.
Args:
url (str, optional): Download URL
Returns:
dict: Dictionary containing (if data available) the fields:
firstqso, lastqso, last-lotw, lastupload (datetime),
... | [
"def",
"get_clublog_users",
"(",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"\"\"",
"clublog",
"=",
"{",
"}",
"try",
":",
"url",
"=",
"kwargs",
"[",
"'url'",
"]",
"except",
"KeyError",
":",
"url",
"=",
"\"https://secure.clublog.org/clublog-users.json.zip\"",
... | Download the latest offical list of `Clublog`__ users.
Args:
url (str, optional): Download URL
Returns:
dict: Dictionary containing (if data available) the fields:
firstqso, lastqso, last-lotw, lastupload (datetime),
locator (string) and oqrs (bo... | [
"Download",
"the",
"latest",
"offical",
"list",
"of",
"Clublog",
"__",
"users",
"."
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/qsl.py#L71-L157 | train | Download the latest offical list of Clublog __ users. |
dh1tw/pyhamtools | pyhamtools/qsl.py | get_eqsl_users | def get_eqsl_users(**kwargs):
"""Download the latest official list of `EQSL.cc`__ users. The list of users can be found here_.
Args:
url (str, optional): Download URL
Returns:
list: List containing the callsigns of EQSL users (unicode)
Raises:
IOError: ... | python | def get_eqsl_users(**kwargs):
"""Download the latest official list of `EQSL.cc`__ users. The list of users can be found here_.
Args:
url (str, optional): Download URL
Returns:
list: List containing the callsigns of EQSL users (unicode)
Raises:
IOError: ... | [
"def",
"get_eqsl_users",
"(",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"\"\"",
"eqsl",
"=",
"[",
"]",
"try",
":",
"url",
"=",
"kwargs",
"[",
"'url'",
"]",
"except",
"KeyError",
":",
"url",
"=",
"\"http://www.eqsl.cc/QSLCard/DownloadedFiles/AGMemberlist.txt\""... | Download the latest official list of `EQSL.cc`__ users. The list of users can be found here_.
Args:
url (str, optional): Download URL
Returns:
list: List containing the callsigns of EQSL users (unicode)
Raises:
IOError: When network is unavailable, file can... | [
"Download",
"the",
"latest",
"official",
"list",
"of",
"EQSL",
".",
"cc",
"__",
"users",
".",
"The",
"list",
"of",
"users",
"can",
"be",
"found",
"here_",
"."
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/qsl.py#L159-L206 | train | Download the latest official list of EQSL. cc __ users. The list of users can be found here_. |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib.copy_data_in_redis | def copy_data_in_redis(self, redis_prefix, redis_instance):
"""
Copy the complete lookup data into redis. Old data will be overwritten.
Args:
redis_prefix (str): Prefix to distinguish the data in redis for the different looktypes
redis_instance (str): an Instance of Redi... | python | def copy_data_in_redis(self, redis_prefix, redis_instance):
"""
Copy the complete lookup data into redis. Old data will be overwritten.
Args:
redis_prefix (str): Prefix to distinguish the data in redis for the different looktypes
redis_instance (str): an Instance of Redi... | [
"def",
"copy_data_in_redis",
"(",
"self",
",",
"redis_prefix",
",",
"redis_instance",
")",
":",
"if",
"redis_instance",
"is",
"not",
"None",
":",
"self",
".",
"_redis",
"=",
"redis_instance",
"if",
"self",
".",
"_redis",
"is",
"None",
":",
"raise",
"Attribut... | Copy the complete lookup data into redis. Old data will be overwritten.
Args:
redis_prefix (str): Prefix to distinguish the data in redis for the different looktypes
redis_instance (str): an Instance of Redis
Returns:
bool: returns True when the data has been copied... | [
"Copy",
"the",
"complete",
"lookup",
"data",
"into",
"redis",
".",
"Old",
"data",
"will",
"be",
"overwritten",
"."
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L151-L223 | train | Copy the complete lookup data into Redis. |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib.lookup_entity | def lookup_entity(self, entity=None):
"""Returns lookup data of an ADIF Entity
Args:
entity (int): ADIF identifier of country
Returns:
dict: Dictionary containing the country specific data
Raises:
KeyError: No matching entity found
Example:... | python | def lookup_entity(self, entity=None):
"""Returns lookup data of an ADIF Entity
Args:
entity (int): ADIF identifier of country
Returns:
dict: Dictionary containing the country specific data
Raises:
KeyError: No matching entity found
Example:... | [
"def",
"lookup_entity",
"(",
"self",
",",
"entity",
"=",
"None",
")",
":",
"if",
"self",
".",
"_lookuptype",
"==",
"\"clublogxml\"",
":",
"entity",
"=",
"int",
"(",
"entity",
")",
"if",
"entity",
"in",
"self",
".",
"_entities",
":",
"return",
"self",
"... | Returns lookup data of an ADIF Entity
Args:
entity (int): ADIF identifier of country
Returns:
dict: Dictionary containing the country specific data
Raises:
KeyError: No matching entity found
Example:
The following code queries the the Cl... | [
"Returns",
"lookup",
"data",
"of",
"an",
"ADIF",
"Entity"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L243-L302 | train | Returns the lookup data of an ADIF Entity with the specified ID. |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._strip_metadata | def _strip_metadata(self, my_dict):
"""
Create a copy of dict and remove not needed data
"""
new_dict = copy.deepcopy(my_dict)
if const.START in new_dict:
del new_dict[const.START]
if const.END in new_dict:
del new_dict[const.END]
if const.... | python | def _strip_metadata(self, my_dict):
"""
Create a copy of dict and remove not needed data
"""
new_dict = copy.deepcopy(my_dict)
if const.START in new_dict:
del new_dict[const.START]
if const.END in new_dict:
del new_dict[const.END]
if const.... | [
"def",
"_strip_metadata",
"(",
"self",
",",
"my_dict",
")",
":",
"new_dict",
"=",
"copy",
".",
"deepcopy",
"(",
"my_dict",
")",
"if",
"const",
".",
"START",
"in",
"new_dict",
":",
"del",
"new_dict",
"[",
"const",
".",
"START",
"]",
"if",
"const",
".",
... | Create a copy of dict and remove not needed data | [
"Create",
"a",
"copy",
"of",
"dict",
"and",
"remove",
"not",
"needed",
"data"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L304-L319 | train | Remove not needed metadata from a dictionary. |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib.lookup_callsign | def lookup_callsign(self, callsign=None, timestamp=timestamp_now):
"""
Returns lookup data if an exception exists for a callsign
Args:
callsign (string): Amateur radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
... | python | def lookup_callsign(self, callsign=None, timestamp=timestamp_now):
"""
Returns lookup data if an exception exists for a callsign
Args:
callsign (string): Amateur radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
... | [
"def",
"lookup_callsign",
"(",
"self",
",",
"callsign",
"=",
"None",
",",
"timestamp",
"=",
"timestamp_now",
")",
":",
"callsign",
"=",
"callsign",
".",
"strip",
"(",
")",
".",
"upper",
"(",
")",
"if",
"self",
".",
"_lookuptype",
"==",
"\"clublogapi\"",
... | Returns lookup data if an exception exists for a callsign
Args:
callsign (string): Amateur radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
dict: Dictionary containing the country specific data of the callsign
Raises... | [
"Returns",
"lookup",
"data",
"if",
"an",
"exception",
"exists",
"for",
"a",
"callsign"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L322-L388 | train | Returns the data for a specific callsign. |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._get_dicts_from_redis | def _get_dicts_from_redis(self, name, index_name, redis_prefix, item):
"""
Retrieve the data of an item from redis and put it in an index and data dictionary to match the
common query interface.
"""
r = self._redis
data_dict = {}
data_index_dict = {}
if r... | python | def _get_dicts_from_redis(self, name, index_name, redis_prefix, item):
"""
Retrieve the data of an item from redis and put it in an index and data dictionary to match the
common query interface.
"""
r = self._redis
data_dict = {}
data_index_dict = {}
if r... | [
"def",
"_get_dicts_from_redis",
"(",
"self",
",",
"name",
",",
"index_name",
",",
"redis_prefix",
",",
"item",
")",
":",
"r",
"=",
"self",
".",
"_redis",
"data_dict",
"=",
"{",
"}",
"data_index_dict",
"=",
"{",
"}",
"if",
"redis_prefix",
"is",
"None",
":... | Retrieve the data of an item from redis and put it in an index and data dictionary to match the
common query interface. | [
"Retrieve",
"the",
"data",
"of",
"an",
"item",
"from",
"redis",
"and",
"put",
"it",
"in",
"an",
"index",
"and",
"data",
"dictionary",
"to",
"match",
"the",
"common",
"query",
"interface",
"."
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L390-L411 | train | Retrieve the data of an item from redis and put it in an index and data dictionary to match the common query interface. |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._check_data_for_date | def _check_data_for_date(self, item, timestamp, data_dict, data_index_dict):
"""
Checks if the item is found in the index. An entry in the index points to the data
in the data_dict. This is mainly used retrieve callsigns and prefixes.
In case data is found for item, a dict containing the... | python | def _check_data_for_date(self, item, timestamp, data_dict, data_index_dict):
"""
Checks if the item is found in the index. An entry in the index points to the data
in the data_dict. This is mainly used retrieve callsigns and prefixes.
In case data is found for item, a dict containing the... | [
"def",
"_check_data_for_date",
"(",
"self",
",",
"item",
",",
"timestamp",
",",
"data_dict",
",",
"data_index_dict",
")",
":",
"if",
"item",
"in",
"data_index_dict",
":",
"for",
"item",
"in",
"data_index_dict",
"[",
"item",
"]",
":",
"# startdate < timestamp",
... | Checks if the item is found in the index. An entry in the index points to the data
in the data_dict. This is mainly used retrieve callsigns and prefixes.
In case data is found for item, a dict containing the data is returned. Otherwise a KeyError is raised. | [
"Checks",
"if",
"the",
"item",
"is",
"found",
"in",
"the",
"index",
".",
"An",
"entry",
"in",
"the",
"index",
"points",
"to",
"the",
"data",
"in",
"the",
"data_dict",
".",
"This",
"is",
"mainly",
"used",
"retrieve",
"callsigns",
"and",
"prefixes",
".",
... | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L413-L450 | train | Checks if the data for the given item is found in the index and returns the data that is stored in the index. |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._check_inv_operation_for_date | def _check_inv_operation_for_date(self, item, timestamp, data_dict, data_index_dict):
"""
Checks if the callsign is marked as an invalid operation for a given timestamp.
In case the operation is invalid, True is returned. Otherwise a KeyError is raised.
"""
if item in data_index... | python | def _check_inv_operation_for_date(self, item, timestamp, data_dict, data_index_dict):
"""
Checks if the callsign is marked as an invalid operation for a given timestamp.
In case the operation is invalid, True is returned. Otherwise a KeyError is raised.
"""
if item in data_index... | [
"def",
"_check_inv_operation_for_date",
"(",
"self",
",",
"item",
",",
"timestamp",
",",
"data_dict",
",",
"data_index_dict",
")",
":",
"if",
"item",
"in",
"data_index_dict",
":",
"for",
"item",
"in",
"data_index_dict",
"[",
"item",
"]",
":",
"# startdate < time... | Checks if the callsign is marked as an invalid operation for a given timestamp.
In case the operation is invalid, True is returned. Otherwise a KeyError is raised. | [
"Checks",
"if",
"the",
"callsign",
"is",
"marked",
"as",
"an",
"invalid",
"operation",
"for",
"a",
"given",
"timestamp",
".",
"In",
"case",
"the",
"operation",
"is",
"invalid",
"True",
"is",
"returned",
".",
"Otherwise",
"a",
"KeyError",
"is",
"raised",
".... | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L453-L482 | train | Checks if the callsign is invalid for a given timestamp. |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib.lookup_prefix | def lookup_prefix(self, prefix, timestamp=timestamp_now):
"""
Returns lookup data of a Prefix
Args:
prefix (string): Prefix of a Amateur Radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
dict: Dictionary contai... | python | def lookup_prefix(self, prefix, timestamp=timestamp_now):
"""
Returns lookup data of a Prefix
Args:
prefix (string): Prefix of a Amateur Radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
dict: Dictionary contai... | [
"def",
"lookup_prefix",
"(",
"self",
",",
"prefix",
",",
"timestamp",
"=",
"timestamp_now",
")",
":",
"prefix",
"=",
"prefix",
".",
"strip",
"(",
")",
".",
"upper",
"(",
")",
"if",
"self",
".",
"_lookuptype",
"==",
"\"clublogxml\"",
"or",
"self",
".",
... | Returns lookup data of a Prefix
Args:
prefix (string): Prefix of a Amateur Radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
dict: Dictionary containing the country specific data of the Prefix
Raises:
KeyE... | [
"Returns",
"lookup",
"data",
"of",
"a",
"Prefix"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L485-L538 | train | Returns the lookup data for a specific prefix |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib.is_invalid_operation | def is_invalid_operation(self, callsign, timestamp=datetime.utcnow().replace(tzinfo=UTC)):
"""
Returns True if an operations is known as invalid
Args:
callsign (string): Amateur Radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Ret... | python | def is_invalid_operation(self, callsign, timestamp=datetime.utcnow().replace(tzinfo=UTC)):
"""
Returns True if an operations is known as invalid
Args:
callsign (string): Amateur Radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Ret... | [
"def",
"is_invalid_operation",
"(",
"self",
",",
"callsign",
",",
"timestamp",
"=",
"datetime",
".",
"utcnow",
"(",
")",
".",
"replace",
"(",
"tzinfo",
"=",
"UTC",
")",
")",
":",
"callsign",
"=",
"callsign",
".",
"strip",
"(",
")",
".",
"upper",
"(",
... | Returns True if an operations is known as invalid
Args:
callsign (string): Amateur Radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
bool: True if a record exists for this callsign (at the given time)
Raises:
... | [
"Returns",
"True",
"if",
"an",
"operations",
"is",
"known",
"as",
"invalid"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L540-L591 | train | Checks if an operation is known as invalid for a given callsign. |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._check_zone_exception_for_date | def _check_zone_exception_for_date(self, item, timestamp, data_dict, data_index_dict):
"""
Checks the index and data if a cq-zone exception exists for the callsign
When a zone exception is found, the zone is returned. If no exception is found
a KeyError is raised
"""
if ... | python | def _check_zone_exception_for_date(self, item, timestamp, data_dict, data_index_dict):
"""
Checks the index and data if a cq-zone exception exists for the callsign
When a zone exception is found, the zone is returned. If no exception is found
a KeyError is raised
"""
if ... | [
"def",
"_check_zone_exception_for_date",
"(",
"self",
",",
"item",
",",
"timestamp",
",",
"data_dict",
",",
"data_index_dict",
")",
":",
"if",
"item",
"in",
"data_index_dict",
":",
"for",
"item",
"in",
"data_index_dict",
"[",
"item",
"]",
":",
"# startdate < tim... | Checks the index and data if a cq-zone exception exists for the callsign
When a zone exception is found, the zone is returned. If no exception is found
a KeyError is raised | [
"Checks",
"the",
"index",
"and",
"data",
"if",
"a",
"cq",
"-",
"zone",
"exception",
"exists",
"for",
"the",
"callsign",
"When",
"a",
"zone",
"exception",
"is",
"found",
"the",
"zone",
"is",
"returned",
".",
"If",
"no",
"exception",
"is",
"found",
"a",
... | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L594-L624 | train | Checks the index and data for a cq - zone exception for the specified date. |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib.lookup_zone_exception | def lookup_zone_exception(self, callsign, timestamp=datetime.utcnow().replace(tzinfo=UTC)):
"""
Returns a CQ Zone if an exception exists for the given callsign
Args:
callsign (string): Amateur radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
... | python | def lookup_zone_exception(self, callsign, timestamp=datetime.utcnow().replace(tzinfo=UTC)):
"""
Returns a CQ Zone if an exception exists for the given callsign
Args:
callsign (string): Amateur radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
... | [
"def",
"lookup_zone_exception",
"(",
"self",
",",
"callsign",
",",
"timestamp",
"=",
"datetime",
".",
"utcnow",
"(",
")",
".",
"replace",
"(",
"tzinfo",
"=",
"UTC",
")",
")",
":",
"callsign",
"=",
"callsign",
".",
"strip",
"(",
")",
".",
"upper",
"(",
... | Returns a CQ Zone if an exception exists for the given callsign
Args:
callsign (string): Amateur radio callsign
timestamp (datetime, optional): datetime in UTC (tzinfo=pytz.UTC)
Returns:
int: Value of the the CQ Zone exception which exists for this callsign (at the given ti... | [
"Returns",
"a",
"CQ",
"Zone",
"if",
"an",
"exception",
"exists",
"for",
"the",
"given",
"callsign"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L627-L673 | train | Returns a CQ Zone exception for the given callsign at the given time. |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._lookup_clublogAPI | def _lookup_clublogAPI(self, callsign=None, timestamp=timestamp_now, url="https://secure.clublog.org/dxcc", apikey=None):
""" Set up the Lookup object for Clublog Online API
"""
params = {"year" : timestamp.strftime("%Y"),
"month" : timestamp.strftime("%m"),
"day" : time... | python | def _lookup_clublogAPI(self, callsign=None, timestamp=timestamp_now, url="https://secure.clublog.org/dxcc", apikey=None):
""" Set up the Lookup object for Clublog Online API
"""
params = {"year" : timestamp.strftime("%Y"),
"month" : timestamp.strftime("%m"),
"day" : time... | [
"def",
"_lookup_clublogAPI",
"(",
"self",
",",
"callsign",
"=",
"None",
",",
"timestamp",
"=",
"timestamp_now",
",",
"url",
"=",
"\"https://secure.clublog.org/dxcc\"",
",",
"apikey",
"=",
"None",
")",
":",
"params",
"=",
"{",
"\"year\"",
":",
"timestamp",
".",... | Set up the Lookup object for Clublog Online API | [
"Set",
"up",
"the",
"Lookup",
"object",
"for",
"Clublog",
"Online",
"API"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L675-L712 | train | Get the lookup object for Clublog Online API |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._lookup_qrz_callsign | def _lookup_qrz_callsign(self, callsign=None, apikey=None, apiv="1.3.3"):
""" Performs the callsign lookup against the QRZ.com XML API:
"""
if apikey is None:
raise AttributeError("Session Key Missing")
callsign = callsign.upper()
response = self._request_callsign_... | python | def _lookup_qrz_callsign(self, callsign=None, apikey=None, apiv="1.3.3"):
""" Performs the callsign lookup against the QRZ.com XML API:
"""
if apikey is None:
raise AttributeError("Session Key Missing")
callsign = callsign.upper()
response = self._request_callsign_... | [
"def",
"_lookup_qrz_callsign",
"(",
"self",
",",
"callsign",
"=",
"None",
",",
"apikey",
"=",
"None",
",",
"apiv",
"=",
"\"1.3.3\"",
")",
":",
"if",
"apikey",
"is",
"None",
":",
"raise",
"AttributeError",
"(",
"\"Session Key Missing\"",
")",
"callsign",
"=",... | Performs the callsign lookup against the QRZ.com XML API: | [
"Performs",
"the",
"callsign",
"lookup",
"against",
"the",
"QRZ",
".",
"com",
"XML",
"API",
":"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L793-L958 | train | Perform a QRZ callsign lookup against the QRZ. com XML API. |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._load_clublogXML | def _load_clublogXML(self,
url="https://secure.clublog.org/cty.php",
apikey=None,
cty_file=None):
""" Load and process the ClublogXML file either as a download or from file
"""
if self._download:
cty_file = self... | python | def _load_clublogXML(self,
url="https://secure.clublog.org/cty.php",
apikey=None,
cty_file=None):
""" Load and process the ClublogXML file either as a download or from file
"""
if self._download:
cty_file = self... | [
"def",
"_load_clublogXML",
"(",
"self",
",",
"url",
"=",
"\"https://secure.clublog.org/cty.php\"",
",",
"apikey",
"=",
"None",
",",
"cty_file",
"=",
"None",
")",
":",
"if",
"self",
".",
"_download",
":",
"cty_file",
"=",
"self",
".",
"_download_file",
"(",
"... | Load and process the ClublogXML file either as a download or from file | [
"Load",
"and",
"process",
"the",
"ClublogXML",
"file",
"either",
"as",
"a",
"download",
"or",
"from",
"file"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L960-L989 | train | Load and process the ClublogXML file. |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._load_countryfile | def _load_countryfile(self,
url="https://www.country-files.com/cty/cty.plist",
country_mapping_filename="countryfilemapping.json",
cty_file=None):
""" Load and process the ClublogXML file either as a download or from file
"""
... | python | def _load_countryfile(self,
url="https://www.country-files.com/cty/cty.plist",
country_mapping_filename="countryfilemapping.json",
cty_file=None):
""" Load and process the ClublogXML file either as a download or from file
"""
... | [
"def",
"_load_countryfile",
"(",
"self",
",",
"url",
"=",
"\"https://www.country-files.com/cty/cty.plist\"",
",",
"country_mapping_filename",
"=",
"\"countryfilemapping.json\"",
",",
"cty_file",
"=",
"None",
")",
":",
"cwdFile",
"=",
"os",
".",
"path",
".",
"abspath",... | Load and process the ClublogXML file either as a download or from file | [
"Load",
"and",
"process",
"the",
"ClublogXML",
"file",
"either",
"as",
"a",
"download",
"or",
"from",
"file"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L991-L1023 | train | Loads and processes the ClublogXML file for the current locale. |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._download_file | def _download_file(self, url, apikey=None):
""" Download lookup files either from Clublog or Country-files.com
"""
import gzip
import tempfile
cty = {}
cty_date = ""
cty_file_path = None
filename = None
# download file
if apikey: # clubl... | python | def _download_file(self, url, apikey=None):
""" Download lookup files either from Clublog or Country-files.com
"""
import gzip
import tempfile
cty = {}
cty_date = ""
cty_file_path = None
filename = None
# download file
if apikey: # clubl... | [
"def",
"_download_file",
"(",
"self",
",",
"url",
",",
"apikey",
"=",
"None",
")",
":",
"import",
"gzip",
"import",
"tempfile",
"cty",
"=",
"{",
"}",
"cty_date",
"=",
"\"\"",
"cty_file_path",
"=",
"None",
"filename",
"=",
"None",
"# download file",
"if",
... | Download lookup files either from Clublog or Country-files.com | [
"Download",
"lookup",
"files",
"either",
"from",
"Clublog",
"or",
"Country",
"-",
"files",
".",
"com"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1025-L1082 | train | Download lookup files either from Clublog or Country - files. com and return the filename of the downloaded file. |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._extract_clublog_header | def _extract_clublog_header(self, cty_xml_filename):
"""
Extract the header of the Clublog XML File
"""
cty_header = {}
try:
with open(cty_xml_filename, "r") as cty:
raw_header = cty.readline()
cty_date = re.search("date='.+'", raw_heade... | python | def _extract_clublog_header(self, cty_xml_filename):
"""
Extract the header of the Clublog XML File
"""
cty_header = {}
try:
with open(cty_xml_filename, "r") as cty:
raw_header = cty.readline()
cty_date = re.search("date='.+'", raw_heade... | [
"def",
"_extract_clublog_header",
"(",
"self",
",",
"cty_xml_filename",
")",
":",
"cty_header",
"=",
"{",
"}",
"try",
":",
"with",
"open",
"(",
"cty_xml_filename",
",",
"\"r\"",
")",
"as",
"cty",
":",
"raw_header",
"=",
"cty",
".",
"readline",
"(",
")",
... | Extract the header of the Clublog XML File | [
"Extract",
"the",
"header",
"of",
"the",
"Clublog",
"XML",
"File"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1084-L1119 | train | Extract the header of the Clublog XML File |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._remove_clublog_xml_header | def _remove_clublog_xml_header(self, cty_xml_filename):
"""
remove the header of the Clublog XML File to make it
properly parseable for the python ElementTree XML parser
"""
import tempfile
try:
with open(cty_xml_filename, "r") as f:
c... | python | def _remove_clublog_xml_header(self, cty_xml_filename):
"""
remove the header of the Clublog XML File to make it
properly parseable for the python ElementTree XML parser
"""
import tempfile
try:
with open(cty_xml_filename, "r") as f:
c... | [
"def",
"_remove_clublog_xml_header",
"(",
"self",
",",
"cty_xml_filename",
")",
":",
"import",
"tempfile",
"try",
":",
"with",
"open",
"(",
"cty_xml_filename",
",",
"\"r\"",
")",
"as",
"f",
":",
"content",
"=",
"f",
".",
"readlines",
"(",
")",
"cty_dir",
"... | remove the header of the Clublog XML File to make it
properly parseable for the python ElementTree XML parser | [
"remove",
"the",
"header",
"of",
"the",
"Clublog",
"XML",
"File",
"to",
"make",
"it",
"properly",
"parseable",
"for",
"the",
"python",
"ElementTree",
"XML",
"parser"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1122-L1147 | train | Remove the header of the Clublog XML File to make it properly parseable for the python ElementTree XML parser |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._parse_clublog_xml | def _parse_clublog_xml(self, cty_xml_filename):
"""
parse the content of a clublog XML file and return the
parsed values in dictionaries
"""
entities = {}
call_exceptions = {}
prefixes = {}
invalid_operations = {}
zone_exceptions = {}
ca... | python | def _parse_clublog_xml(self, cty_xml_filename):
"""
parse the content of a clublog XML file and return the
parsed values in dictionaries
"""
entities = {}
call_exceptions = {}
prefixes = {}
invalid_operations = {}
zone_exceptions = {}
ca... | [
"def",
"_parse_clublog_xml",
"(",
"self",
",",
"cty_xml_filename",
")",
":",
"entities",
"=",
"{",
"}",
"call_exceptions",
"=",
"{",
"}",
"prefixes",
"=",
"{",
"}",
"invalid_operations",
"=",
"{",
"}",
"zone_exceptions",
"=",
"{",
"}",
"call_exceptions_index",... | parse the content of a clublog XML file and return the
parsed values in dictionaries | [
"parse",
"the",
"content",
"of",
"a",
"clublog",
"XML",
"file",
"and",
"return",
"the",
"parsed",
"values",
"in",
"dictionaries"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1149-L1364 | train | Parse the content of a clublog XML file and return the dictionary of the ADIF Country Entity IDs and their values. |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._parse_country_file | def _parse_country_file(self, cty_file, country_mapping_filename=None):
"""
Parse the content of a PLIST file from country-files.com return the
parsed values in dictionaries.
Country-files.com provides Prefixes and Exceptions
"""
import plistlib
cty_list = None... | python | def _parse_country_file(self, cty_file, country_mapping_filename=None):
"""
Parse the content of a PLIST file from country-files.com return the
parsed values in dictionaries.
Country-files.com provides Prefixes and Exceptions
"""
import plistlib
cty_list = None... | [
"def",
"_parse_country_file",
"(",
"self",
",",
"cty_file",
",",
"country_mapping_filename",
"=",
"None",
")",
":",
"import",
"plistlib",
"cty_list",
"=",
"None",
"entities",
"=",
"{",
"}",
"exceptions",
"=",
"{",
"}",
"prefixes",
"=",
"{",
"}",
"exceptions_... | Parse the content of a PLIST file from country-files.com return the
parsed values in dictionaries.
Country-files.com provides Prefixes and Exceptions | [
"Parse",
"the",
"content",
"of",
"a",
"PLIST",
"file",
"from",
"country",
"-",
"files",
".",
"com",
"return",
"the",
"parsed",
"values",
"in",
"dictionaries",
".",
"Country",
"-",
"files",
".",
"com",
"provides",
"Prefixes",
"and",
"Exceptions"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1366-L1433 | train | Parse the content of a PLIST file from country - files. com and return the parsed values in dictionaries. |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._generate_random_word | def _generate_random_word(self, length):
"""
Generates a random word
"""
return ''.join(random.choice(string.ascii_lowercase) for _ in range(length)) | python | def _generate_random_word(self, length):
"""
Generates a random word
"""
return ''.join(random.choice(string.ascii_lowercase) for _ in range(length)) | [
"def",
"_generate_random_word",
"(",
"self",
",",
"length",
")",
":",
"return",
"''",
".",
"join",
"(",
"random",
".",
"choice",
"(",
"string",
".",
"ascii_lowercase",
")",
"for",
"_",
"in",
"range",
"(",
"length",
")",
")"
] | Generates a random word | [
"Generates",
"a",
"random",
"word"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1435-L1439 | train | Generates a random word of the given length. |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._check_html_response | def _check_html_response(self, response):
"""
Checks if the API Key is valid and if the request returned a 200 status (ok)
"""
error1 = "Access to this form requires a valid API key. For more info see: http://www.clublog.org/need_api.php"
error2 = "Invalid or missing API Key... | python | def _check_html_response(self, response):
"""
Checks if the API Key is valid and if the request returned a 200 status (ok)
"""
error1 = "Access to this form requires a valid API key. For more info see: http://www.clublog.org/need_api.php"
error2 = "Invalid or missing API Key... | [
"def",
"_check_html_response",
"(",
"self",
",",
"response",
")",
":",
"error1",
"=",
"\"Access to this form requires a valid API key. For more info see: http://www.clublog.org/need_api.php\"",
"error2",
"=",
"\"Invalid or missing API Key\"",
"if",
"response",
".",
"status_code",
... | Checks if the API Key is valid and if the request returned a 200 status (ok) | [
"Checks",
"if",
"the",
"API",
"Key",
"is",
"valid",
"and",
"if",
"the",
"request",
"returned",
"a",
"200",
"status",
"(",
"ok",
")"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1441-L1457 | train | Checks if the response from the API Key is OK and if it is not raise LookupError |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._serialize_data | def _serialize_data(self, my_dict):
"""
Serialize a Dictionary into JSON
"""
new_dict = {}
for item in my_dict:
if isinstance(my_dict[item], datetime):
new_dict[item] = my_dict[item].strftime('%Y-%m-%d%H:%M:%S')
else:
new_di... | python | def _serialize_data(self, my_dict):
"""
Serialize a Dictionary into JSON
"""
new_dict = {}
for item in my_dict:
if isinstance(my_dict[item], datetime):
new_dict[item] = my_dict[item].strftime('%Y-%m-%d%H:%M:%S')
else:
new_di... | [
"def",
"_serialize_data",
"(",
"self",
",",
"my_dict",
")",
":",
"new_dict",
"=",
"{",
"}",
"for",
"item",
"in",
"my_dict",
":",
"if",
"isinstance",
"(",
"my_dict",
"[",
"item",
"]",
",",
"datetime",
")",
":",
"new_dict",
"[",
"item",
"]",
"=",
"my_d... | Serialize a Dictionary into JSON | [
"Serialize",
"a",
"Dictionary",
"into",
"JSON"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1460-L1471 | train | Serialize a Dictionary into JSON |
dh1tw/pyhamtools | pyhamtools/lookuplib.py | LookupLib._deserialize_data | def _deserialize_data(self, json_data):
"""
Deserialize a JSON into a dictionary
"""
my_dict = json.loads(json_data.decode('utf8').replace("'", '"'),
encoding='UTF-8')
for item in my_dict:
if item == const.ADIF:
my_dict[item] = int(my_dic... | python | def _deserialize_data(self, json_data):
"""
Deserialize a JSON into a dictionary
"""
my_dict = json.loads(json_data.decode('utf8').replace("'", '"'),
encoding='UTF-8')
for item in my_dict:
if item == const.ADIF:
my_dict[item] = int(my_dic... | [
"def",
"_deserialize_data",
"(",
"self",
",",
"json_data",
")",
":",
"my_dict",
"=",
"json",
".",
"loads",
"(",
"json_data",
".",
"decode",
"(",
"'utf8'",
")",
".",
"replace",
"(",
"\"'\"",
",",
"'\"'",
")",
",",
"encoding",
"=",
"'UTF-8'",
")",
"for",... | Deserialize a JSON into a dictionary | [
"Deserialize",
"a",
"JSON",
"into",
"a",
"dictionary"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/lookuplib.py#L1473-L1507 | train | Deserializes a JSON into a dictionary. |
AustralianSynchrotron/lightflow | lightflow/models/mongo_proxy.py | get_methods | def get_methods(*objs):
""" Return the names of all callable attributes of an object"""
return set(
attr
for obj in objs
for attr in dir(obj)
if not attr.startswith('_') and callable(getattr(obj, attr))
) | python | def get_methods(*objs):
""" Return the names of all callable attributes of an object"""
return set(
attr
for obj in objs
for attr in dir(obj)
if not attr.startswith('_') and callable(getattr(obj, attr))
) | [
"def",
"get_methods",
"(",
"*",
"objs",
")",
":",
"return",
"set",
"(",
"attr",
"for",
"obj",
"in",
"objs",
"for",
"attr",
"in",
"dir",
"(",
"obj",
")",
"if",
"not",
"attr",
".",
"startswith",
"(",
"'_'",
")",
"and",
"callable",
"(",
"getattr",
"("... | Return the names of all callable attributes of an object | [
"Return",
"the",
"names",
"of",
"all",
"callable",
"attributes",
"of",
"an",
"object"
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/mongo_proxy.py#L18-L25 | train | Return the names of all callable attributes of an object |
AustralianSynchrotron/lightflow | lightflow/config.py | Config.from_file | def from_file(cls, filename, *, strict=True):
""" Create a new Config object from a configuration file.
Args:
filename (str): The location and name of the configuration file.
strict (bool): If true raises a ConfigLoadError when the configuration
cannot be found.
... | python | def from_file(cls, filename, *, strict=True):
""" Create a new Config object from a configuration file.
Args:
filename (str): The location and name of the configuration file.
strict (bool): If true raises a ConfigLoadError when the configuration
cannot be found.
... | [
"def",
"from_file",
"(",
"cls",
",",
"filename",
",",
"*",
",",
"strict",
"=",
"True",
")",
":",
"config",
"=",
"cls",
"(",
")",
"config",
".",
"load_from_file",
"(",
"filename",
",",
"strict",
"=",
"strict",
")",
"return",
"config"
] | Create a new Config object from a configuration file.
Args:
filename (str): The location and name of the configuration file.
strict (bool): If true raises a ConfigLoadError when the configuration
cannot be found.
Returns:
An instance of the Config cl... | [
"Create",
"a",
"new",
"Config",
"object",
"from",
"a",
"configuration",
"file",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/config.py#L43-L59 | train | Create a new Config object from a configuration file. |
AustralianSynchrotron/lightflow | lightflow/config.py | Config.load_from_file | def load_from_file(self, filename=None, *, strict=True):
""" Load the configuration from a file.
The location of the configuration file can either be specified directly in the
parameter filename or is searched for in the following order:
1. In the environment variable given by LIGH... | python | def load_from_file(self, filename=None, *, strict=True):
""" Load the configuration from a file.
The location of the configuration file can either be specified directly in the
parameter filename or is searched for in the following order:
1. In the environment variable given by LIGH... | [
"def",
"load_from_file",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"*",
",",
"strict",
"=",
"True",
")",
":",
"self",
".",
"set_to_default",
"(",
")",
"if",
"filename",
":",
"self",
".",
"_update_from_file",
"(",
"filename",
")",
"else",
":",
"if... | Load the configuration from a file.
The location of the configuration file can either be specified directly in the
parameter filename or is searched for in the following order:
1. In the environment variable given by LIGHTFLOW_CONFIG_ENV
2. In the current execution directory
... | [
"Load",
"the",
"configuration",
"from",
"a",
"file",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/config.py#L61-L97 | train | Loads the configuration from a file. |
AustralianSynchrotron/lightflow | lightflow/config.py | Config.load_from_dict | def load_from_dict(self, conf_dict=None):
""" Load the configuration from a dictionary.
Args:
conf_dict (dict): Dictionary with the configuration.
"""
self.set_to_default()
self._update_dict(self._config, conf_dict)
self._update_python_paths() | python | def load_from_dict(self, conf_dict=None):
""" Load the configuration from a dictionary.
Args:
conf_dict (dict): Dictionary with the configuration.
"""
self.set_to_default()
self._update_dict(self._config, conf_dict)
self._update_python_paths() | [
"def",
"load_from_dict",
"(",
"self",
",",
"conf_dict",
"=",
"None",
")",
":",
"self",
".",
"set_to_default",
"(",
")",
"self",
".",
"_update_dict",
"(",
"self",
".",
"_config",
",",
"conf_dict",
")",
"self",
".",
"_update_python_paths",
"(",
")"
] | Load the configuration from a dictionary.
Args:
conf_dict (dict): Dictionary with the configuration. | [
"Load",
"the",
"configuration",
"from",
"a",
"dictionary",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/config.py#L99-L107 | train | Load the configuration from a dictionary. |
AustralianSynchrotron/lightflow | lightflow/config.py | Config._update_from_file | def _update_from_file(self, filename):
""" Helper method to update an existing configuration with the values from a file.
Loads a configuration file and replaces all values in the existing configuration
dictionary with the values from the file.
Args:
filename (str): The pat... | python | def _update_from_file(self, filename):
""" Helper method to update an existing configuration with the values from a file.
Loads a configuration file and replaces all values in the existing configuration
dictionary with the values from the file.
Args:
filename (str): The pat... | [
"def",
"_update_from_file",
"(",
"self",
",",
"filename",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"try",
":",
"with",
"open",
"(",
"filename",
",",
"'r'",
")",
"as",
"config_file",
":",
"yaml_dict",
"=",
"yaml",
"... | Helper method to update an existing configuration with the values from a file.
Loads a configuration file and replaces all values in the existing configuration
dictionary with the values from the file.
Args:
filename (str): The path and name to the configuration file. | [
"Helper",
"method",
"to",
"update",
"an",
"existing",
"configuration",
"with",
"the",
"values",
"from",
"a",
"file",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/config.py#L169-L188 | train | Updates the dictionary with the values from a file. |
AustralianSynchrotron/lightflow | lightflow/config.py | Config._update_dict | def _update_dict(self, to_dict, from_dict):
""" Recursively merges the fields for two dictionaries.
Args:
to_dict (dict): The dictionary onto which the merge is executed.
from_dict (dict): The dictionary merged into to_dict
"""
for key, value in from_dict.items()... | python | def _update_dict(self, to_dict, from_dict):
""" Recursively merges the fields for two dictionaries.
Args:
to_dict (dict): The dictionary onto which the merge is executed.
from_dict (dict): The dictionary merged into to_dict
"""
for key, value in from_dict.items()... | [
"def",
"_update_dict",
"(",
"self",
",",
"to_dict",
",",
"from_dict",
")",
":",
"for",
"key",
",",
"value",
"in",
"from_dict",
".",
"items",
"(",
")",
":",
"if",
"key",
"in",
"to_dict",
"and",
"isinstance",
"(",
"to_dict",
"[",
"key",
"]",
",",
"dict... | Recursively merges the fields for two dictionaries.
Args:
to_dict (dict): The dictionary onto which the merge is executed.
from_dict (dict): The dictionary merged into to_dict | [
"Recursively",
"merges",
"the",
"fields",
"for",
"two",
"dictionaries",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/config.py#L190-L202 | train | Recursively merges the fields for two dictionaries. |
AustralianSynchrotron/lightflow | lightflow/config.py | Config._update_python_paths | def _update_python_paths(self):
""" Append the workflow and libraries paths to the PYTHONPATH. """
for path in self._config['workflows'] + self._config['libraries']:
if os.path.isdir(os.path.abspath(path)):
if path not in sys.path:
sys.path.append(path)
... | python | def _update_python_paths(self):
""" Append the workflow and libraries paths to the PYTHONPATH. """
for path in self._config['workflows'] + self._config['libraries']:
if os.path.isdir(os.path.abspath(path)):
if path not in sys.path:
sys.path.append(path)
... | [
"def",
"_update_python_paths",
"(",
"self",
")",
":",
"for",
"path",
"in",
"self",
".",
"_config",
"[",
"'workflows'",
"]",
"+",
"self",
".",
"_config",
"[",
"'libraries'",
"]",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"os",
".",
"path",
".",... | Append the workflow and libraries paths to the PYTHONPATH. | [
"Append",
"the",
"workflow",
"and",
"libraries",
"paths",
"to",
"the",
"PYTHONPATH",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/config.py#L204-L212 | train | Append the workflow and libraries paths to the PYTHONPATH. |
dh1tw/pyhamtools | pyhamtools/dxcluster.py | decode_char_spot | def decode_char_spot(raw_string):
"""Chop Line from DX-Cluster into pieces and return a dict with the spot data"""
data = {}
# Spotter callsign
if re.match('[A-Za-z0-9\/]+[:$]', raw_string[6:15]):
data[const.SPOTTER] = re.sub(':', '', re.match('[A-Za-z0-9\/]+[:$]', raw_string[6:15]).group(0))
... | python | def decode_char_spot(raw_string):
"""Chop Line from DX-Cluster into pieces and return a dict with the spot data"""
data = {}
# Spotter callsign
if re.match('[A-Za-z0-9\/]+[:$]', raw_string[6:15]):
data[const.SPOTTER] = re.sub(':', '', re.match('[A-Za-z0-9\/]+[:$]', raw_string[6:15]).group(0))
... | [
"def",
"decode_char_spot",
"(",
"raw_string",
")",
":",
"data",
"=",
"{",
"}",
"# Spotter callsign",
"if",
"re",
".",
"match",
"(",
"'[A-Za-z0-9\\/]+[:$]'",
",",
"raw_string",
"[",
"6",
":",
"15",
"]",
")",
":",
"data",
"[",
"const",
".",
"SPOTTER",
"]",... | Chop Line from DX-Cluster into pieces and return a dict with the spot data | [
"Chop",
"Line",
"from",
"DX",
"-",
"Cluster",
"into",
"pieces",
"and",
"return",
"a",
"dict",
"with",
"the",
"spot",
"data"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/dxcluster.py#L16-L36 | train | Decode a single character spot into pieces and return a dict with the spot data |
dh1tw/pyhamtools | pyhamtools/dxcluster.py | decode_pc11_message | def decode_pc11_message(raw_string):
"""Decode PC11 message, which usually contains DX Spots"""
data = {}
spot = raw_string.split("^")
data[const.FREQUENCY] = float(spot[1])
data[const.DX] = spot[2]
data[const.TIME] = datetime.fromtimestamp(mktime(strptime(spot[3]+" "+spot[4][:-1], "%d-%b-%Y %H... | python | def decode_pc11_message(raw_string):
"""Decode PC11 message, which usually contains DX Spots"""
data = {}
spot = raw_string.split("^")
data[const.FREQUENCY] = float(spot[1])
data[const.DX] = spot[2]
data[const.TIME] = datetime.fromtimestamp(mktime(strptime(spot[3]+" "+spot[4][:-1], "%d-%b-%Y %H... | [
"def",
"decode_pc11_message",
"(",
"raw_string",
")",
":",
"data",
"=",
"{",
"}",
"spot",
"=",
"raw_string",
".",
"split",
"(",
"\"^\"",
")",
"data",
"[",
"const",
".",
"FREQUENCY",
"]",
"=",
"float",
"(",
"spot",
"[",
"1",
"]",
")",
"data",
"[",
"... | Decode PC11 message, which usually contains DX Spots | [
"Decode",
"PC11",
"message",
"which",
"usually",
"contains",
"DX",
"Spots"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/dxcluster.py#L38-L50 | train | Decode PC11 message which usually contains DX Spots |
dh1tw/pyhamtools | pyhamtools/dxcluster.py | decode_pc23_message | def decode_pc23_message(raw_string):
""" Decode PC23 Message which usually contains WCY """
data = {}
wcy = raw_string.split("^")
data[const.R] = int(wcy[1])
data[const.expk] = int(wcy[2])
data[const.CALLSIGN] = wcy[3]
data[const.A] = wcy[4]
data[const.SFI] = wcy[5]
data[const.K] = ... | python | def decode_pc23_message(raw_string):
""" Decode PC23 Message which usually contains WCY """
data = {}
wcy = raw_string.split("^")
data[const.R] = int(wcy[1])
data[const.expk] = int(wcy[2])
data[const.CALLSIGN] = wcy[3]
data[const.A] = wcy[4]
data[const.SFI] = wcy[5]
data[const.K] = ... | [
"def",
"decode_pc23_message",
"(",
"raw_string",
")",
":",
"data",
"=",
"{",
"}",
"wcy",
"=",
"raw_string",
".",
"split",
"(",
"\"^\"",
")",
"data",
"[",
"const",
".",
"R",
"]",
"=",
"int",
"(",
"wcy",
"[",
"1",
"]",
")",
"data",
"[",
"const",
".... | Decode PC23 Message which usually contains WCY | [
"Decode",
"PC23",
"Message",
"which",
"usually",
"contains",
"WCY"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/dxcluster.py#L68-L83 | train | Decode PC23 Message which usually contains WCY |
AustralianSynchrotron/lightflow | lightflow/models/task.py | BaseTask._run | def _run(self, data, store, signal, context, *,
success_callback=None, stop_callback=None, abort_callback=None):
""" The internal run method that decorates the public run method.
This method makes sure data is being passed to and from the task.
Args:
data (MultiTaskDat... | python | def _run(self, data, store, signal, context, *,
success_callback=None, stop_callback=None, abort_callback=None):
""" The internal run method that decorates the public run method.
This method makes sure data is being passed to and from the task.
Args:
data (MultiTaskDat... | [
"def",
"_run",
"(",
"self",
",",
"data",
",",
"store",
",",
"signal",
",",
"context",
",",
"*",
",",
"success_callback",
"=",
"None",
",",
"stop_callback",
"=",
"None",
",",
"abort_callback",
"=",
"None",
")",
":",
"if",
"data",
"is",
"None",
":",
"d... | The internal run method that decorates the public run method.
This method makes sure data is being passed to and from the task.
Args:
data (MultiTaskData): The data object that has been passed from the
predecessor task.
store (DataStoreDocument... | [
"The",
"internal",
"run",
"method",
"that",
"decorates",
"the",
"public",
"run",
"method",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/task.py#L208-L295 | train | This method is called by the internal run method of the internal run method. It wraps the run method to make sure that the data object passed to the internal run method is passed to the internal run method. |
dh1tw/pyhamtools | pyhamtools/locator.py | latlong_to_locator | def latlong_to_locator (latitude, longitude):
"""converts WGS84 coordinates into the corresponding Maidenhead Locator
Args:
latitude (float): Latitude
longitude (float): Longitude
Returns:
string: Maidenhead locator
Raises:
ValueError: When ... | python | def latlong_to_locator (latitude, longitude):
"""converts WGS84 coordinates into the corresponding Maidenhead Locator
Args:
latitude (float): Latitude
longitude (float): Longitude
Returns:
string: Maidenhead locator
Raises:
ValueError: When ... | [
"def",
"latlong_to_locator",
"(",
"latitude",
",",
"longitude",
")",
":",
"if",
"longitude",
">=",
"180",
"or",
"longitude",
"<=",
"-",
"180",
":",
"raise",
"ValueError",
"if",
"latitude",
">=",
"90",
"or",
"latitude",
"<=",
"-",
"90",
":",
"raise",
"Val... | converts WGS84 coordinates into the corresponding Maidenhead Locator
Args:
latitude (float): Latitude
longitude (float): Longitude
Returns:
string: Maidenhead locator
Raises:
ValueError: When called with wrong or invalid input args
T... | [
"converts",
"WGS84",
"coordinates",
"into",
"the",
"corresponding",
"Maidenhead",
"Locator"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/locator.py#L10-L55 | train | Converts WGS84 coordinates into Maidenhead Locator |
dh1tw/pyhamtools | pyhamtools/locator.py | locator_to_latlong | def locator_to_latlong (locator):
"""converts Maidenhead locator in the corresponding WGS84 coordinates
Args:
locator (string): Locator, either 4 or 6 characters
Returns:
tuple (float, float): Latitude, Longitude
Raises:
ValueError: When called with wro... | python | def locator_to_latlong (locator):
"""converts Maidenhead locator in the corresponding WGS84 coordinates
Args:
locator (string): Locator, either 4 or 6 characters
Returns:
tuple (float, float): Latitude, Longitude
Raises:
ValueError: When called with wro... | [
"def",
"locator_to_latlong",
"(",
"locator",
")",
":",
"locator",
"=",
"locator",
".",
"upper",
"(",
")",
"if",
"len",
"(",
"locator",
")",
"==",
"5",
"or",
"len",
"(",
"locator",
")",
"<",
"4",
":",
"raise",
"ValueError",
"if",
"ord",
"(",
"locator"... | converts Maidenhead locator in the corresponding WGS84 coordinates
Args:
locator (string): Locator, either 4 or 6 characters
Returns:
tuple (float, float): Latitude, Longitude
Raises:
ValueError: When called with wrong or invalid input arg
TypeE... | [
"converts",
"Maidenhead",
"locator",
"in",
"the",
"corresponding",
"WGS84",
"coordinates"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/locator.py#L57-L125 | train | Converts a Maidenhead locator in the corresponding WGS84 coordinates into a Latitude and Longitude tuple. |
dh1tw/pyhamtools | pyhamtools/locator.py | calculate_distance | def calculate_distance(locator1, locator2):
"""calculates the (shortpath) distance between two Maidenhead locators
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Distance in km
... | python | def calculate_distance(locator1, locator2):
"""calculates the (shortpath) distance between two Maidenhead locators
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Distance in km
... | [
"def",
"calculate_distance",
"(",
"locator1",
",",
"locator2",
")",
":",
"R",
"=",
"6371",
"#earh radius",
"lat1",
",",
"long1",
"=",
"locator_to_latlong",
"(",
"locator1",
")",
"lat2",
",",
"long2",
"=",
"locator_to_latlong",
"(",
"locator2",
")",
"d_lat",
... | calculates the (shortpath) distance between two Maidenhead locators
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Distance in km
Raises:
ValueError: When called wi... | [
"calculates",
"the",
"(",
"shortpath",
")",
"distance",
"between",
"two",
"Maidenhead",
"locators"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/locator.py#L128-L167 | train | Calculates the distance between two Maidenhead locators in km
|
dh1tw/pyhamtools | pyhamtools/locator.py | calculate_distance_longpath | def calculate_distance_longpath(locator1, locator2):
"""calculates the (longpath) distance between two Maidenhead locators
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Distance in... | python | def calculate_distance_longpath(locator1, locator2):
"""calculates the (longpath) distance between two Maidenhead locators
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Distance in... | [
"def",
"calculate_distance_longpath",
"(",
"locator1",
",",
"locator2",
")",
":",
"c",
"=",
"40008",
"#[km] earth circumference",
"sp",
"=",
"calculate_distance",
"(",
"locator1",
",",
"locator2",
")",
"return",
"c",
"-",
"sp"
] | calculates the (longpath) distance between two Maidenhead locators
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Distance in km
Raises:
ValueError: When called wit... | [
"calculates",
"the",
"(",
"longpath",
")",
"distance",
"between",
"two",
"Maidenhead",
"locators"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/locator.py#L170-L196 | train | calculates the longpath distance between two Maidenhead locators in km
|
dh1tw/pyhamtools | pyhamtools/locator.py | calculate_heading | def calculate_heading(locator1, locator2):
"""calculates the heading from the first to the second locator
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Heading in deg
Rais... | python | def calculate_heading(locator1, locator2):
"""calculates the heading from the first to the second locator
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Heading in deg
Rais... | [
"def",
"calculate_heading",
"(",
"locator1",
",",
"locator2",
")",
":",
"lat1",
",",
"long1",
"=",
"locator_to_latlong",
"(",
"locator1",
")",
"lat2",
",",
"long2",
"=",
"locator_to_latlong",
"(",
"locator2",
")",
"r_lat1",
"=",
"radians",
"(",
"lat1",
")",
... | calculates the heading from the first to the second locator
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Heading in deg
Raises:
ValueError: When called with wrong... | [
"calculates",
"the",
"heading",
"from",
"the",
"first",
"to",
"the",
"second",
"locator"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/locator.py#L199-L237 | train | Calculates the heading from the first to the second locator
and returns the heading in degree. |
dh1tw/pyhamtools | pyhamtools/locator.py | calculate_heading_longpath | def calculate_heading_longpath(locator1, locator2):
"""calculates the heading from the first to the second locator (long path)
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Long pa... | python | def calculate_heading_longpath(locator1, locator2):
"""calculates the heading from the first to the second locator (long path)
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Long pa... | [
"def",
"calculate_heading_longpath",
"(",
"locator1",
",",
"locator2",
")",
":",
"heading",
"=",
"calculate_heading",
"(",
"locator1",
",",
"locator2",
")",
"lp",
"=",
"(",
"heading",
"+",
"180",
")",
"%",
"360",
"return",
"lp"
] | calculates the heading from the first to the second locator (long path)
Args:
locator1 (string): Locator, either 4 or 6 characters
locator2 (string): Locator, either 4 or 6 characters
Returns:
float: Long path heading in deg
Raises:
ValueError: ... | [
"calculates",
"the",
"heading",
"from",
"the",
"first",
"to",
"the",
"second",
"locator",
"(",
"long",
"path",
")"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/locator.py#L239-L266 | train | calculates the long path heading from the first to the second locator |
dh1tw/pyhamtools | pyhamtools/locator.py | calculate_sunrise_sunset | def calculate_sunrise_sunset(locator, calc_date=datetime.utcnow()):
"""calculates the next sunset and sunrise for a Maidenhead locator at a give date & time
Args:
locator1 (string): Maidenhead Locator, either 4 or 6 characters
calc_date (datetime, optional): Starting datetime for th... | python | def calculate_sunrise_sunset(locator, calc_date=datetime.utcnow()):
"""calculates the next sunset and sunrise for a Maidenhead locator at a give date & time
Args:
locator1 (string): Maidenhead Locator, either 4 or 6 characters
calc_date (datetime, optional): Starting datetime for th... | [
"def",
"calculate_sunrise_sunset",
"(",
"locator",
",",
"calc_date",
"=",
"datetime",
".",
"utcnow",
"(",
")",
")",
":",
"morning_dawn",
"=",
"None",
"sunrise",
"=",
"None",
"evening_dawn",
"=",
"None",
"sunset",
"=",
"None",
"latitude",
",",
"longitude",
"=... | calculates the next sunset and sunrise for a Maidenhead locator at a give date & time
Args:
locator1 (string): Maidenhead Locator, either 4 or 6 characters
calc_date (datetime, optional): Starting datetime for the calculations (UTC)
Returns:
dict: Containing datetim... | [
"calculates",
"the",
"next",
"sunset",
"and",
"sunrise",
"for",
"a",
"Maidenhead",
"locator",
"at",
"a",
"give",
"date",
"&",
"time"
] | ee7e4b8732e23c298da10e07163748156c16d0fa | https://github.com/dh1tw/pyhamtools/blob/ee7e4b8732e23c298da10e07163748156c16d0fa/pyhamtools/locator.py#L268-L358 | train | Calculates the next sunset and sunrise for a Maidenhead locator at a give date & time. |
AustralianSynchrotron/lightflow | lightflow/queue/pickle.py | cloudpickle_dumps | def cloudpickle_dumps(obj, dumper=cloudpickle.dumps):
""" Encode Python objects into a byte stream using cloudpickle. """
return dumper(obj, protocol=serialization.pickle_protocol) | python | def cloudpickle_dumps(obj, dumper=cloudpickle.dumps):
""" Encode Python objects into a byte stream using cloudpickle. """
return dumper(obj, protocol=serialization.pickle_protocol) | [
"def",
"cloudpickle_dumps",
"(",
"obj",
",",
"dumper",
"=",
"cloudpickle",
".",
"dumps",
")",
":",
"return",
"dumper",
"(",
"obj",
",",
"protocol",
"=",
"serialization",
".",
"pickle_protocol",
")"
] | Encode Python objects into a byte stream using cloudpickle. | [
"Encode",
"Python",
"objects",
"into",
"a",
"byte",
"stream",
"using",
"cloudpickle",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/queue/pickle.py#L18-L20 | train | Encode Python objects into a byte stream using cloudpickle. |
AustralianSynchrotron/lightflow | lightflow/queue/pickle.py | patch_celery | def patch_celery():
""" Monkey patch Celery to use cloudpickle instead of pickle. """
registry = serialization.registry
serialization.pickle = cloudpickle
registry.unregister('pickle')
registry.register('pickle', cloudpickle_dumps, cloudpickle_loads,
content_type='application/x... | python | def patch_celery():
""" Monkey patch Celery to use cloudpickle instead of pickle. """
registry = serialization.registry
serialization.pickle = cloudpickle
registry.unregister('pickle')
registry.register('pickle', cloudpickle_dumps, cloudpickle_loads,
content_type='application/x... | [
"def",
"patch_celery",
"(",
")",
":",
"registry",
"=",
"serialization",
".",
"registry",
"serialization",
".",
"pickle",
"=",
"cloudpickle",
"registry",
".",
"unregister",
"(",
"'pickle'",
")",
"registry",
".",
"register",
"(",
"'pickle'",
",",
"cloudpickle_dump... | Monkey patch Celery to use cloudpickle instead of pickle. | [
"Monkey",
"patch",
"Celery",
"to",
"use",
"cloudpickle",
"instead",
"of",
"pickle",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/queue/pickle.py#L23-L40 | train | Monkey patch Celery to use cloudpickle instead of pickle. |
AustralianSynchrotron/lightflow | lightflow/models/signal.py | SignalConnection.connect | def connect(self):
""" Connects to the redis database. """
self._connection = StrictRedis(
host=self._host,
port=self._port,
db=self._database,
password=self._password) | python | def connect(self):
""" Connects to the redis database. """
self._connection = StrictRedis(
host=self._host,
port=self._port,
db=self._database,
password=self._password) | [
"def",
"connect",
"(",
"self",
")",
":",
"self",
".",
"_connection",
"=",
"StrictRedis",
"(",
"host",
"=",
"self",
".",
"_host",
",",
"port",
"=",
"self",
".",
"_port",
",",
"db",
"=",
"self",
".",
"_database",
",",
"password",
"=",
"self",
".",
"_... | Connects to the redis database. | [
"Connects",
"to",
"the",
"redis",
"database",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/signal.py#L47-L53 | train | Connects to the redis database. |
AustralianSynchrotron/lightflow | lightflow/models/signal.py | Server.receive | def receive(self):
""" Returns a single request.
Takes the first request from the list of requests and returns it. If the list
is empty, None is returned.
Returns:
Response: If a new request is available a Request object is returned,
otherwise None is ... | python | def receive(self):
""" Returns a single request.
Takes the first request from the list of requests and returns it. If the list
is empty, None is returned.
Returns:
Response: If a new request is available a Request object is returned,
otherwise None is ... | [
"def",
"receive",
"(",
"self",
")",
":",
"pickled_request",
"=",
"self",
".",
"_connection",
".",
"connection",
".",
"lpop",
"(",
"self",
".",
"_request_key",
")",
"return",
"pickle",
".",
"loads",
"(",
"pickled_request",
")",
"if",
"pickled_request",
"is",
... | Returns a single request.
Takes the first request from the list of requests and returns it. If the list
is empty, None is returned.
Returns:
Response: If a new request is available a Request object is returned,
otherwise None is returned. | [
"Returns",
"a",
"single",
"request",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/signal.py#L118-L129 | train | Returns a single request from the list of requests and returns it. |
AustralianSynchrotron/lightflow | lightflow/models/signal.py | Server.send | def send(self, response):
""" Send a response back to the client that issued a request.
Args:
response (Response): Reference to the response object that should be sent.
"""
self._connection.connection.set('{}:{}'.format(SIGNAL_REDIS_PREFIX, response.uid),
... | python | def send(self, response):
""" Send a response back to the client that issued a request.
Args:
response (Response): Reference to the response object that should be sent.
"""
self._connection.connection.set('{}:{}'.format(SIGNAL_REDIS_PREFIX, response.uid),
... | [
"def",
"send",
"(",
"self",
",",
"response",
")",
":",
"self",
".",
"_connection",
".",
"connection",
".",
"set",
"(",
"'{}:{}'",
".",
"format",
"(",
"SIGNAL_REDIS_PREFIX",
",",
"response",
".",
"uid",
")",
",",
"pickle",
".",
"dumps",
"(",
"response",
... | Send a response back to the client that issued a request.
Args:
response (Response): Reference to the response object that should be sent. | [
"Send",
"a",
"response",
"back",
"to",
"the",
"client",
"that",
"issued",
"a",
"request",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/signal.py#L131-L138 | train | Send a response back to the client that issued a request. |
AustralianSynchrotron/lightflow | lightflow/models/signal.py | Server.restore | def restore(self, request):
""" Push the request back onto the queue.
Args:
request (Request): Reference to a request object that should be pushed back
onto the request queue.
"""
self._connection.connection.rpush(self._request_key, pickle.dump... | python | def restore(self, request):
""" Push the request back onto the queue.
Args:
request (Request): Reference to a request object that should be pushed back
onto the request queue.
"""
self._connection.connection.rpush(self._request_key, pickle.dump... | [
"def",
"restore",
"(",
"self",
",",
"request",
")",
":",
"self",
".",
"_connection",
".",
"connection",
".",
"rpush",
"(",
"self",
".",
"_request_key",
",",
"pickle",
".",
"dumps",
"(",
"request",
")",
")"
] | Push the request back onto the queue.
Args:
request (Request): Reference to a request object that should be pushed back
onto the request queue. | [
"Push",
"the",
"request",
"back",
"onto",
"the",
"queue",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/signal.py#L140-L147 | train | Push the request back onto the queue. |
AustralianSynchrotron/lightflow | lightflow/models/signal.py | Client.send | def send(self, request):
""" Send a request to the server and wait for its response.
Args:
request (Request): Reference to a request object that is sent to the server.
Returns:
Response: The response from the server to the request.
"""
self._connection.c... | python | def send(self, request):
""" Send a request to the server and wait for its response.
Args:
request (Request): Reference to a request object that is sent to the server.
Returns:
Response: The response from the server to the request.
"""
self._connection.c... | [
"def",
"send",
"(",
"self",
",",
"request",
")",
":",
"self",
".",
"_connection",
".",
"connection",
".",
"rpush",
"(",
"self",
".",
"_request_key",
",",
"pickle",
".",
"dumps",
"(",
"request",
")",
")",
"resp_key",
"=",
"'{}:{}'",
".",
"format",
"(",
... | Send a request to the server and wait for its response.
Args:
request (Request): Reference to a request object that is sent to the server.
Returns:
Response: The response from the server to the request. | [
"Send",
"a",
"request",
"to",
"the",
"server",
"and",
"wait",
"for",
"its",
"response",
"."
] | dc53dbc1d961e20fb144273baca258060705c03e | https://github.com/AustralianSynchrotron/lightflow/blob/dc53dbc1d961e20fb144273baca258060705c03e/lightflow/models/signal.py#L171-L192 | train | Send a request to the server and wait for its response. |
krzysiekfonal/grammaregex | grammaregex/grammaregex.py | verify_pattern | def verify_pattern(pattern):
"""Verifies if pattern for matching and finding fulfill expected structure.
:param pattern: string pattern to verify
:return: True if pattern has proper syntax, False otherwise
"""
regex = re.compile("^!?[a-zA-Z]+$|[*]{1,2}$")
def __verify_pattern__(__pa... | python | def verify_pattern(pattern):
"""Verifies if pattern for matching and finding fulfill expected structure.
:param pattern: string pattern to verify
:return: True if pattern has proper syntax, False otherwise
"""
regex = re.compile("^!?[a-zA-Z]+$|[*]{1,2}$")
def __verify_pattern__(__pa... | [
"def",
"verify_pattern",
"(",
"pattern",
")",
":",
"regex",
"=",
"re",
".",
"compile",
"(",
"\"^!?[a-zA-Z]+$|[*]{1,2}$\"",
")",
"def",
"__verify_pattern__",
"(",
"__pattern__",
")",
":",
"if",
"not",
"__pattern__",
":",
"return",
"False",
"elif",
"__pattern__",
... | Verifies if pattern for matching and finding fulfill expected structure.
:param pattern: string pattern to verify
:return: True if pattern has proper syntax, False otherwise | [
"Verifies",
"if",
"pattern",
"for",
"matching",
"and",
"finding",
"fulfill",
"expected",
"structure",
"."
] | 5212075433fc5201da628acf09cdf5bf73aa1ad0 | https://github.com/krzysiekfonal/grammaregex/blob/5212075433fc5201da628acf09cdf5bf73aa1ad0/grammaregex/grammaregex.py#L40-L60 | train | Verifies if pattern for matching and finding fulfill expected structure. |
krzysiekfonal/grammaregex | grammaregex/grammaregex.py | print_tree | def print_tree(sent, token_attr):
"""Prints sentences tree as string using token_attr from token(like pos_, tag_ etc.)
:param sent: sentence to print
:param token_attr: choosen attr to present for tokens(e.g. dep_, pos_, tag_, ...)
"""
def __print_sent__(token, attr):
print("{", en... | python | def print_tree(sent, token_attr):
"""Prints sentences tree as string using token_attr from token(like pos_, tag_ etc.)
:param sent: sentence to print
:param token_attr: choosen attr to present for tokens(e.g. dep_, pos_, tag_, ...)
"""
def __print_sent__(token, attr):
print("{", en... | [
"def",
"print_tree",
"(",
"sent",
",",
"token_attr",
")",
":",
"def",
"__print_sent__",
"(",
"token",
",",
"attr",
")",
":",
"print",
"(",
"\"{\"",
",",
"end",
"=",
"\" \"",
")",
"[",
"__print_sent__",
"(",
"t",
",",
"attr",
")",
"for",
"t",
"in",
... | Prints sentences tree as string using token_attr from token(like pos_, tag_ etc.)
:param sent: sentence to print
:param token_attr: choosen attr to present for tokens(e.g. dep_, pos_, tag_, ...) | [
"Prints",
"sentences",
"tree",
"as",
"string",
"using",
"token_attr",
"from",
"token",
"(",
"like",
"pos_",
"tag_",
"etc",
".",
")"
] | 5212075433fc5201da628acf09cdf5bf73aa1ad0 | https://github.com/krzysiekfonal/grammaregex/blob/5212075433fc5201da628acf09cdf5bf73aa1ad0/grammaregex/grammaregex.py#L63-L76 | train | Prints a tree of sentences using token_attr from token |
krzysiekfonal/grammaregex | grammaregex/grammaregex.py | match_tree | def match_tree(sentence, pattern):
"""Matches given sentence with provided pattern.
:param sentence: sentence from Spacy(see: http://spacy.io/docs/#doc-spans-sents) representing complete statement
:param pattern: pattern to which sentence will be compared
:return: True if sentence match to... | python | def match_tree(sentence, pattern):
"""Matches given sentence with provided pattern.
:param sentence: sentence from Spacy(see: http://spacy.io/docs/#doc-spans-sents) representing complete statement
:param pattern: pattern to which sentence will be compared
:return: True if sentence match to... | [
"def",
"match_tree",
"(",
"sentence",
",",
"pattern",
")",
":",
"if",
"not",
"verify_pattern",
"(",
"pattern",
")",
":",
"raise",
"PatternSyntaxException",
"(",
"pattern",
")",
"def",
"_match_node",
"(",
"t",
",",
"p",
")",
":",
"pat_node",
"=",
"p",
"."... | Matches given sentence with provided pattern.
:param sentence: sentence from Spacy(see: http://spacy.io/docs/#doc-spans-sents) representing complete statement
:param pattern: pattern to which sentence will be compared
:return: True if sentence match to pattern, False otherwise
:raises... | [
"Matches",
"given",
"sentence",
"with",
"provided",
"pattern",
"."
] | 5212075433fc5201da628acf09cdf5bf73aa1ad0 | https://github.com/krzysiekfonal/grammaregex/blob/5212075433fc5201da628acf09cdf5bf73aa1ad0/grammaregex/grammaregex.py#L79-L111 | train | Matches given sentence with given pattern. |
krzysiekfonal/grammaregex | grammaregex/grammaregex.py | find_tokens | def find_tokens(sentence, pattern):
"""Find all tokens from parts of sentence fitted to pattern, being on the end of matched sub-tree(of sentence)
:param sentence: sentence from Spacy(see: http://spacy.io/docs/#doc-spans-sents) representing complete statement
:param pattern: pattern to which senten... | python | def find_tokens(sentence, pattern):
"""Find all tokens from parts of sentence fitted to pattern, being on the end of matched sub-tree(of sentence)
:param sentence: sentence from Spacy(see: http://spacy.io/docs/#doc-spans-sents) representing complete statement
:param pattern: pattern to which senten... | [
"def",
"find_tokens",
"(",
"sentence",
",",
"pattern",
")",
":",
"if",
"not",
"verify_pattern",
"(",
"pattern",
")",
":",
"raise",
"PatternSyntaxException",
"(",
"pattern",
")",
"def",
"_match_node",
"(",
"t",
",",
"p",
",",
"tokens",
")",
":",
"pat_node",... | Find all tokens from parts of sentence fitted to pattern, being on the end of matched sub-tree(of sentence)
:param sentence: sentence from Spacy(see: http://spacy.io/docs/#doc-spans-sents) representing complete statement
:param pattern: pattern to which sentence will be compared
:return: Spacy... | [
"Find",
"all",
"tokens",
"from",
"parts",
"of",
"sentence",
"fitted",
"to",
"pattern",
"being",
"on",
"the",
"end",
"of",
"matched",
"sub",
"-",
"tree",
"(",
"of",
"sentence",
")"
] | 5212075433fc5201da628acf09cdf5bf73aa1ad0 | https://github.com/krzysiekfonal/grammaregex/blob/5212075433fc5201da628acf09cdf5bf73aa1ad0/grammaregex/grammaregex.py#L114-L146 | train | Find all tokens from parts of sentence fitted to pattern. |
pwwang/liquidpy | liquid/__init__.py | Liquid.split | def split (s, delimter, trim = True, limit = 0): # pragma: no cover
"""
Split a string using a single-character delimter
@params:
`s`: the string
`delimter`: the single-character delimter
`trim`: whether to trim each part. Default: True
@examples:
```python
ret = split("'a,b',c", ",")
# ret ==... | python | def split (s, delimter, trim = True, limit = 0): # pragma: no cover
"""
Split a string using a single-character delimter
@params:
`s`: the string
`delimter`: the single-character delimter
`trim`: whether to trim each part. Default: True
@examples:
```python
ret = split("'a,b',c", ",")
# ret ==... | [
"def",
"split",
"(",
"s",
",",
"delimter",
",",
"trim",
"=",
"True",
",",
"limit",
"=",
"0",
")",
":",
"# pragma: no cover",
"ret",
"=",
"[",
"]",
"special1",
"=",
"[",
"'('",
",",
"')'",
",",
"'['",
",",
"']'",
",",
"'{'",
",",
"'}'",
"]",
"sp... | Split a string using a single-character delimter
@params:
`s`: the string
`delimter`: the single-character delimter
`trim`: whether to trim each part. Default: True
@examples:
```python
ret = split("'a,b',c", ",")
# ret == ["'a,b'", "c"]
# ',' inside quotes will be recognized.
```
@returns... | [
"Split",
"a",
"string",
"using",
"a",
"single",
"-",
"character",
"delimter"
] | f422af836740b7facfbc6b89e5162a17d619dd07 | https://github.com/pwwang/liquidpy/blob/f422af836740b7facfbc6b89e5162a17d619dd07/liquid/__init__.py#L367-L421 | train | Split a string using a single - character delimter. |
pwwang/liquidpy | liquid/__init__.py | Liquid.render | def render(self, **context):
"""
Render this template by applying it to `context`.
@params:
`context`: a dictionary of values to use in this rendering.
@returns:
The rendered string
"""
# Make the complete context we'll use.
localns = self.envs.copy()
localns.update(context)
try:
exec(str(se... | python | def render(self, **context):
"""
Render this template by applying it to `context`.
@params:
`context`: a dictionary of values to use in this rendering.
@returns:
The rendered string
"""
# Make the complete context we'll use.
localns = self.envs.copy()
localns.update(context)
try:
exec(str(se... | [
"def",
"render",
"(",
"self",
",",
"*",
"*",
"context",
")",
":",
"# Make the complete context we'll use.",
"localns",
"=",
"self",
".",
"envs",
".",
"copy",
"(",
")",
"localns",
".",
"update",
"(",
"context",
")",
"try",
":",
"exec",
"(",
"str",
"(",
... | Render this template by applying it to `context`.
@params:
`context`: a dictionary of values to use in this rendering.
@returns:
The rendered string | [
"Render",
"this",
"template",
"by",
"applying",
"it",
"to",
"context",
"."
] | f422af836740b7facfbc6b89e5162a17d619dd07 | https://github.com/pwwang/liquidpy/blob/f422af836740b7facfbc6b89e5162a17d619dd07/liquid/__init__.py#L575-L624 | train | Render this template by applying it to context. |
pwwang/liquidpy | liquid/builder.py | LiquidCode.addLine | def addLine(self, line):
"""
Add a line of source to the code.
Indentation and newline will be added for you, don't provide them.
@params:
`line`: The line to add
"""
if not isinstance(line, LiquidLine):
line = LiquidLine(line)
line.ndent = self.ndent
self.codes.append(line) | python | def addLine(self, line):
"""
Add a line of source to the code.
Indentation and newline will be added for you, don't provide them.
@params:
`line`: The line to add
"""
if not isinstance(line, LiquidLine):
line = LiquidLine(line)
line.ndent = self.ndent
self.codes.append(line) | [
"def",
"addLine",
"(",
"self",
",",
"line",
")",
":",
"if",
"not",
"isinstance",
"(",
"line",
",",
"LiquidLine",
")",
":",
"line",
"=",
"LiquidLine",
"(",
"line",
")",
"line",
".",
"ndent",
"=",
"self",
".",
"ndent",
"self",
".",
"codes",
".",
"app... | Add a line of source to the code.
Indentation and newline will be added for you, don't provide them.
@params:
`line`: The line to add | [
"Add",
"a",
"line",
"of",
"source",
"to",
"the",
"code",
".",
"Indentation",
"and",
"newline",
"will",
"be",
"added",
"for",
"you",
"don",
"t",
"provide",
"them",
"."
] | f422af836740b7facfbc6b89e5162a17d619dd07 | https://github.com/pwwang/liquidpy/blob/f422af836740b7facfbc6b89e5162a17d619dd07/liquid/builder.py#L57-L67 | train | Adds a line of source to the code. |
ManufacturaInd/python-zenlog | zenlog/__init__.py | Log.level | def level(self, lvl=None):
'''Get or set the logging level.'''
if not lvl:
return self._lvl
self._lvl = self._parse_level(lvl)
self.stream.setLevel(self._lvl)
logging.root.setLevel(self._lvl) | python | def level(self, lvl=None):
'''Get or set the logging level.'''
if not lvl:
return self._lvl
self._lvl = self._parse_level(lvl)
self.stream.setLevel(self._lvl)
logging.root.setLevel(self._lvl) | [
"def",
"level",
"(",
"self",
",",
"lvl",
"=",
"None",
")",
":",
"if",
"not",
"lvl",
":",
"return",
"self",
".",
"_lvl",
"self",
".",
"_lvl",
"=",
"self",
".",
"_parse_level",
"(",
"lvl",
")",
"self",
".",
"stream",
".",
"setLevel",
"(",
"self",
"... | Get or set the logging level. | [
"Get",
"or",
"set",
"the",
"logging",
"level",
"."
] | 8f4ddf281287c99e286b78ef2d0d949a7172ba4c | https://github.com/ManufacturaInd/python-zenlog/blob/8f4ddf281287c99e286b78ef2d0d949a7172ba4c/zenlog/__init__.py#L90-L96 | train | Get or set the logging level. |
mirumee/django-prices-openexchangerates | django_prices_openexchangerates/__init__.py | get_rate_from_db | def get_rate_from_db(currency: str) -> Decimal:
"""
Fetch currency conversion rate from the database
"""
from .models import ConversionRate
try:
rate = ConversionRate.objects.get_rate(currency)
except ConversionRate.DoesNotExist: # noqa
raise ValueError('No conversion rate for %... | python | def get_rate_from_db(currency: str) -> Decimal:
"""
Fetch currency conversion rate from the database
"""
from .models import ConversionRate
try:
rate = ConversionRate.objects.get_rate(currency)
except ConversionRate.DoesNotExist: # noqa
raise ValueError('No conversion rate for %... | [
"def",
"get_rate_from_db",
"(",
"currency",
":",
"str",
")",
"->",
"Decimal",
":",
"from",
".",
"models",
"import",
"ConversionRate",
"try",
":",
"rate",
"=",
"ConversionRate",
".",
"objects",
".",
"get_rate",
"(",
"currency",
")",
"except",
"ConversionRate",
... | Fetch currency conversion rate from the database | [
"Fetch",
"currency",
"conversion",
"rate",
"from",
"the",
"database"
] | 3f633ad20f62dce03c526e9af93335f2b6b1a950 | https://github.com/mirumee/django-prices-openexchangerates/blob/3f633ad20f62dce03c526e9af93335f2b6b1a950/django_prices_openexchangerates/__init__.py#L15-L24 | train | Fetch currency conversion rate from the database |
mirumee/django-prices-openexchangerates | django_prices_openexchangerates/__init__.py | get_conversion_rate | def get_conversion_rate(from_currency: str, to_currency: str) -> Decimal:
"""
Get conversion rate to use in exchange
"""
reverse_rate = False
if to_currency == BASE_CURRENCY:
# Fetch exchange rate for base currency and use 1 / rate for conversion
rate_currency = from_currency
... | python | def get_conversion_rate(from_currency: str, to_currency: str) -> Decimal:
"""
Get conversion rate to use in exchange
"""
reverse_rate = False
if to_currency == BASE_CURRENCY:
# Fetch exchange rate for base currency and use 1 / rate for conversion
rate_currency = from_currency
... | [
"def",
"get_conversion_rate",
"(",
"from_currency",
":",
"str",
",",
"to_currency",
":",
"str",
")",
"->",
"Decimal",
":",
"reverse_rate",
"=",
"False",
"if",
"to_currency",
"==",
"BASE_CURRENCY",
":",
"# Fetch exchange rate for base currency and use 1 / rate for conversi... | Get conversion rate to use in exchange | [
"Get",
"conversion",
"rate",
"to",
"use",
"in",
"exchange"
] | 3f633ad20f62dce03c526e9af93335f2b6b1a950 | https://github.com/mirumee/django-prices-openexchangerates/blob/3f633ad20f62dce03c526e9af93335f2b6b1a950/django_prices_openexchangerates/__init__.py#L27-L44 | train | Get conversion rate for a given currency |
mirumee/django-prices-openexchangerates | django_prices_openexchangerates/__init__.py | exchange_currency | def exchange_currency(
base: T, to_currency: str, *, conversion_rate: Decimal=None) -> T:
"""
Exchanges Money, TaxedMoney and their ranges to the specified currency.
get_rate parameter is a callable taking single argument (target currency)
that returns proper conversion rate
"""
if base.... | python | def exchange_currency(
base: T, to_currency: str, *, conversion_rate: Decimal=None) -> T:
"""
Exchanges Money, TaxedMoney and their ranges to the specified currency.
get_rate parameter is a callable taking single argument (target currency)
that returns proper conversion rate
"""
if base.... | [
"def",
"exchange_currency",
"(",
"base",
":",
"T",
",",
"to_currency",
":",
"str",
",",
"*",
",",
"conversion_rate",
":",
"Decimal",
"=",
"None",
")",
"->",
"T",
":",
"if",
"base",
".",
"currency",
"==",
"to_currency",
":",
"return",
"base",
"if",
"bas... | Exchanges Money, TaxedMoney and their ranges to the specified currency.
get_rate parameter is a callable taking single argument (target currency)
that returns proper conversion rate | [
"Exchanges",
"Money",
"TaxedMoney",
"and",
"their",
"ranges",
"to",
"the",
"specified",
"currency",
".",
"get_rate",
"parameter",
"is",
"a",
"callable",
"taking",
"single",
"argument",
"(",
"target",
"currency",
")",
"that",
"returns",
"proper",
"conversion",
"r... | 3f633ad20f62dce03c526e9af93335f2b6b1a950 | https://github.com/mirumee/django-prices-openexchangerates/blob/3f633ad20f62dce03c526e9af93335f2b6b1a950/django_prices_openexchangerates/__init__.py#L47-L85 | train | Exchange currency from base to another currency. |
mdredze/carmen-python | carmen/resolvers/profile.py | normalize | def normalize(location_name, preserve_commas=False):
"""Normalize *location_name* by stripping punctuation and collapsing
runs of whitespace, and return the normalized name."""
def replace(match):
if preserve_commas and ',' in match.group(0):
return ','
return ' '
return NORM... | python | def normalize(location_name, preserve_commas=False):
"""Normalize *location_name* by stripping punctuation and collapsing
runs of whitespace, and return the normalized name."""
def replace(match):
if preserve_commas and ',' in match.group(0):
return ','
return ' '
return NORM... | [
"def",
"normalize",
"(",
"location_name",
",",
"preserve_commas",
"=",
"False",
")",
":",
"def",
"replace",
"(",
"match",
")",
":",
"if",
"preserve_commas",
"and",
"','",
"in",
"match",
".",
"group",
"(",
"0",
")",
":",
"return",
"','",
"return",
"' '",
... | Normalize *location_name* by stripping punctuation and collapsing
runs of whitespace, and return the normalized name. | [
"Normalize",
"*",
"location_name",
"*",
"by",
"stripping",
"punctuation",
"and",
"collapsing",
"runs",
"of",
"whitespace",
"and",
"return",
"the",
"normalized",
"name",
"."
] | 070b974222b5407f7aae2518ffbdf9df198b8e96 | https://github.com/mdredze/carmen-python/blob/070b974222b5407f7aae2518ffbdf9df198b8e96/carmen/resolvers/profile.py#L15-L22 | train | Normalize a location name by stripping punctuation and collapsing
runs of whitespace and returning the normalized name. |
kristianfoerster/melodist | melodist/stationstatistics.py | StationStatistics.calc_precipitation_stats | def calc_precipitation_stats(self, months=None, avg_stats=True, percentile=50):
"""
Calculates precipitation statistics for the cascade model while aggregating hourly observations
Parameters
----------
months : Months for each seasons to be used for statistics (array of n... | python | def calc_precipitation_stats(self, months=None, avg_stats=True, percentile=50):
"""
Calculates precipitation statistics for the cascade model while aggregating hourly observations
Parameters
----------
months : Months for each seasons to be used for statistics (array of n... | [
"def",
"calc_precipitation_stats",
"(",
"self",
",",
"months",
"=",
"None",
",",
"avg_stats",
"=",
"True",
",",
"percentile",
"=",
"50",
")",
":",
"if",
"months",
"is",
"None",
":",
"months",
"=",
"[",
"np",
".",
"arange",
"(",
"12",
")",
"+",
"1",
... | Calculates precipitation statistics for the cascade model while aggregating hourly observations
Parameters
----------
months : Months for each seasons to be used for statistics (array of numpy array, default=1-12, e.g., [np.arange(12) + 1])
avg_stats : average statistics for ... | [
"Calculates",
"precipitation",
"statistics",
"for",
"the",
"cascade",
"model",
"while",
"aggregating",
"hourly",
"observations"
] | ddc155c77b65f791be0021dbbaf68c6bac42ecbd | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/stationstatistics.py#L77-L92 | train | Calculates precipitation statistics for the cascade model while aggregating hourly observations |
kristianfoerster/melodist | melodist/stationstatistics.py | StationStatistics.calc_wind_stats | def calc_wind_stats(self):
"""
Calculates statistics in order to derive diurnal patterns of wind speed
"""
a, b, t_shift = melodist.fit_cosine_function(self.data.wind)
self.wind.update(a=a, b=b, t_shift=t_shift) | python | def calc_wind_stats(self):
"""
Calculates statistics in order to derive diurnal patterns of wind speed
"""
a, b, t_shift = melodist.fit_cosine_function(self.data.wind)
self.wind.update(a=a, b=b, t_shift=t_shift) | [
"def",
"calc_wind_stats",
"(",
"self",
")",
":",
"a",
",",
"b",
",",
"t_shift",
"=",
"melodist",
".",
"fit_cosine_function",
"(",
"self",
".",
"data",
".",
"wind",
")",
"self",
".",
"wind",
".",
"update",
"(",
"a",
"=",
"a",
",",
"b",
"=",
"b",
"... | Calculates statistics in order to derive diurnal patterns of wind speed | [
"Calculates",
"statistics",
"in",
"order",
"to",
"derive",
"diurnal",
"patterns",
"of",
"wind",
"speed"
] | ddc155c77b65f791be0021dbbaf68c6bac42ecbd | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/stationstatistics.py#L94-L99 | train | Calculates statistics in order to derive diurnal patterns of wind speed |
kristianfoerster/melodist | melodist/stationstatistics.py | StationStatistics.calc_humidity_stats | def calc_humidity_stats(self):
"""
Calculates statistics in order to derive diurnal patterns of relative humidity.
"""
a1, a0 = melodist.calculate_dewpoint_regression(self.data, return_stats=False)
self.hum.update(a0=a0, a1=a1)
self.hum.kr = 12
self.hum.month_hou... | python | def calc_humidity_stats(self):
"""
Calculates statistics in order to derive diurnal patterns of relative humidity.
"""
a1, a0 = melodist.calculate_dewpoint_regression(self.data, return_stats=False)
self.hum.update(a0=a0, a1=a1)
self.hum.kr = 12
self.hum.month_hou... | [
"def",
"calc_humidity_stats",
"(",
"self",
")",
":",
"a1",
",",
"a0",
"=",
"melodist",
".",
"calculate_dewpoint_regression",
"(",
"self",
".",
"data",
",",
"return_stats",
"=",
"False",
")",
"self",
".",
"hum",
".",
"update",
"(",
"a0",
"=",
"a0",
",",
... | Calculates statistics in order to derive diurnal patterns of relative humidity. | [
"Calculates",
"statistics",
"in",
"order",
"to",
"derive",
"diurnal",
"patterns",
"of",
"relative",
"humidity",
"."
] | ddc155c77b65f791be0021dbbaf68c6bac42ecbd | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/stationstatistics.py#L101-L109 | train | Calculates statistics in order to derive diurnal patterns of relative humidity. |
kristianfoerster/melodist | melodist/stationstatistics.py | StationStatistics.calc_temperature_stats | def calc_temperature_stats(self):
"""
Calculates statistics in order to derive diurnal patterns of temperature
"""
self.temp.max_delta = melodist.get_shift_by_data(self.data.temp, self._lon, self._lat, self._timezone)
self.temp.mean_course = melodist.util.calculate_mean_daily_cou... | python | def calc_temperature_stats(self):
"""
Calculates statistics in order to derive diurnal patterns of temperature
"""
self.temp.max_delta = melodist.get_shift_by_data(self.data.temp, self._lon, self._lat, self._timezone)
self.temp.mean_course = melodist.util.calculate_mean_daily_cou... | [
"def",
"calc_temperature_stats",
"(",
"self",
")",
":",
"self",
".",
"temp",
".",
"max_delta",
"=",
"melodist",
".",
"get_shift_by_data",
"(",
"self",
".",
"data",
".",
"temp",
",",
"self",
".",
"_lon",
",",
"self",
".",
"_lat",
",",
"self",
".",
"_tim... | Calculates statistics in order to derive diurnal patterns of temperature | [
"Calculates",
"statistics",
"in",
"order",
"to",
"derive",
"diurnal",
"patterns",
"of",
"temperature"
] | ddc155c77b65f791be0021dbbaf68c6bac42ecbd | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/stationstatistics.py#L111-L116 | train | Calculates statistics in order to derive diurnal patterns of temperature |
kristianfoerster/melodist | melodist/stationstatistics.py | StationStatistics.calc_radiation_stats | def calc_radiation_stats(self, data_daily=None, day_length=None, how='all'):
"""
Calculates statistics in order to derive solar radiation from sunshine duration or
minimum/maximum temperature.
Parameters
----------
data_daily : DataFrame, optional
Daily data ... | python | def calc_radiation_stats(self, data_daily=None, day_length=None, how='all'):
"""
Calculates statistics in order to derive solar radiation from sunshine duration or
minimum/maximum temperature.
Parameters
----------
data_daily : DataFrame, optional
Daily data ... | [
"def",
"calc_radiation_stats",
"(",
"self",
",",
"data_daily",
"=",
"None",
",",
"day_length",
"=",
"None",
",",
"how",
"=",
"'all'",
")",
":",
"assert",
"how",
"in",
"(",
"'all'",
",",
"'seasonal'",
",",
"'monthly'",
")",
"self",
".",
"glob",
".",
"me... | Calculates statistics in order to derive solar radiation from sunshine duration or
minimum/maximum temperature.
Parameters
----------
data_daily : DataFrame, optional
Daily data from the associated ``Station`` object.
day_length : Series, optional
Day le... | [
"Calculates",
"statistics",
"in",
"order",
"to",
"derive",
"solar",
"radiation",
"from",
"sunshine",
"duration",
"or",
"minimum",
"/",
"maximum",
"temperature",
"."
] | ddc155c77b65f791be0021dbbaf68c6bac42ecbd | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/stationstatistics.py#L118-L186 | train | Calculates statistics in order to derive solar radiation from sunshine duration or solar temperature. |
kristianfoerster/melodist | melodist/stationstatistics.py | StationStatistics.to_json | def to_json(self, filename=None):
"""
Exports statistical data to a JSON formatted file
Parameters
----------
filename: output file that holds statistics data
"""
def json_encoder(obj):
if isinstance(obj, pd.DataFrame) or isinstance(obj, pd.Series)... | python | def to_json(self, filename=None):
"""
Exports statistical data to a JSON formatted file
Parameters
----------
filename: output file that holds statistics data
"""
def json_encoder(obj):
if isinstance(obj, pd.DataFrame) or isinstance(obj, pd.Series)... | [
"def",
"to_json",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"def",
"json_encoder",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"pd",
".",
"DataFrame",
")",
"or",
"isinstance",
"(",
"obj",
",",
"pd",
".",
"Series",
")",
":"... | Exports statistical data to a JSON formatted file
Parameters
----------
filename: output file that holds statistics data | [
"Exports",
"statistical",
"data",
"to",
"a",
"JSON",
"formatted",
"file"
] | ddc155c77b65f791be0021dbbaf68c6bac42ecbd | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/stationstatistics.py#L188-L223 | train | Exports statistical data to a JSON formatted file |
kristianfoerster/melodist | melodist/stationstatistics.py | StationStatistics.from_json | def from_json(cls, filename):
"""
Imports statistical data from a JSON formatted file
Parameters
----------
filename: input file that holds statistics data
"""
def json_decoder(d):
if 'p01' in d and 'pxx' in d: # we assume this is a CascadeStatist... | python | def from_json(cls, filename):
"""
Imports statistical data from a JSON formatted file
Parameters
----------
filename: input file that holds statistics data
"""
def json_decoder(d):
if 'p01' in d and 'pxx' in d: # we assume this is a CascadeStatist... | [
"def",
"from_json",
"(",
"cls",
",",
"filename",
")",
":",
"def",
"json_decoder",
"(",
"d",
")",
":",
"if",
"'p01'",
"in",
"d",
"and",
"'pxx'",
"in",
"d",
":",
"# we assume this is a CascadeStatistics object",
"return",
"melodist",
".",
"cascade",
".",
"Casc... | Imports statistical data from a JSON formatted file
Parameters
----------
filename: input file that holds statistics data | [
"Imports",
"statistical",
"data",
"from",
"a",
"JSON",
"formatted",
"file"
] | ddc155c77b65f791be0021dbbaf68c6bac42ecbd | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/stationstatistics.py#L226-L272 | train | Imports statistical data from a JSON formatted file containing statistics. |
kristianfoerster/melodist | melodist/radiation.py | disaggregate_radiation | def disaggregate_radiation(data_daily,
sun_times=None,
pot_rad=None,
method='pot_rad',
angstr_a=0.25,
angstr_b=0.5,
bristcamp_a=0.75,
... | python | def disaggregate_radiation(data_daily,
sun_times=None,
pot_rad=None,
method='pot_rad',
angstr_a=0.25,
angstr_b=0.5,
bristcamp_a=0.75,
... | [
"def",
"disaggregate_radiation",
"(",
"data_daily",
",",
"sun_times",
"=",
"None",
",",
"pot_rad",
"=",
"None",
",",
"method",
"=",
"'pot_rad'",
",",
"angstr_a",
"=",
"0.25",
",",
"angstr_b",
"=",
"0.5",
",",
"bristcamp_a",
"=",
"0.75",
",",
"bristcamp_c",
... | general function for radiation disaggregation
Args:
daily_data: daily values
sun_times: daily dataframe including results of the util.sun_times function
pot_rad: hourly dataframe including potential radiation
method: keyword specifying the disaggregation method to be used
... | [
"general",
"function",
"for",
"radiation",
"disaggregation",
"Args",
":",
"daily_data",
":",
"daily",
"values",
"sun_times",
":",
"daily",
"dataframe",
"including",
"results",
"of",
"the",
"util",
".",
"sun_times",
"function",
"pot_rad",
":",
"hourly",
"dataframe"... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/radiation.py#L37-L93 | train | function to disaggregate radiation by day |
kristianfoerster/melodist | melodist/radiation.py | potential_radiation | def potential_radiation(dates, lon, lat, timezone, terrain_slope=0, terrain_slope_azimuth=0,
cloud_fraction=0, split=False):
"""
Calculate potential shortwave radiation for a specific location and time.
This routine calculates global radiation as described in:
Liston, G. E... | python | def potential_radiation(dates, lon, lat, timezone, terrain_slope=0, terrain_slope_azimuth=0,
cloud_fraction=0, split=False):
"""
Calculate potential shortwave radiation for a specific location and time.
This routine calculates global radiation as described in:
Liston, G. E... | [
"def",
"potential_radiation",
"(",
"dates",
",",
"lon",
",",
"lat",
",",
"timezone",
",",
"terrain_slope",
"=",
"0",
",",
"terrain_slope_azimuth",
"=",
"0",
",",
"cloud_fraction",
"=",
"0",
",",
"split",
"=",
"False",
")",
":",
"solar_constant",
"=",
"1367... | Calculate potential shortwave radiation for a specific location and time.
This routine calculates global radiation as described in:
Liston, G. E. and Elder, K. (2006): A Meteorological Distribution System for
High-Resolution Terrestrial Modeling (MicroMet), J. Hydrometeorol., 7, 217–234.
Correct... | [
"Calculate",
"potential",
"shortwave",
"radiation",
"for",
"a",
"specific",
"location",
"and",
"time",
".",
"This",
"routine",
"calculates",
"global",
"radiation",
"as",
"described",
"in",
":",
"Liston",
"G",
".",
"E",
".",
"and",
"Elder",
"K",
".",
"(",
"... | ddc155c77b65f791be0021dbbaf68c6bac42ecbd | https://github.com/kristianfoerster/melodist/blob/ddc155c77b65f791be0021dbbaf68c6bac42ecbd/melodist/radiation.py#L96-L177 | train | Returns a DataFrame containing the total potential radiation for a specific location and time. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.