repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
paydunya/paydunya-python | paydunya/invoice.py | Invoice.calculate_total_amt | def calculate_total_amt(self, items={}):
"""Returns the total amount/cost of items in the current invoice"""
_items = items.items() or self.items.items()
return sum(float(x[1].total_price) for x in _items) | python | def calculate_total_amt(self, items={}):
"""Returns the total amount/cost of items in the current invoice"""
_items = items.items() or self.items.items()
return sum(float(x[1].total_price) for x in _items) | [
"def",
"calculate_total_amt",
"(",
"self",
",",
"items",
"=",
"{",
"}",
")",
":",
"_items",
"=",
"items",
".",
"items",
"(",
")",
"or",
"self",
".",
"items",
".",
"items",
"(",
")",
"return",
"sum",
"(",
"float",
"(",
"x",
"[",
"1",
"]",
".",
"... | Returns the total amount/cost of items in the current invoice | [
"Returns",
"the",
"total",
"amount",
"/",
"cost",
"of",
"items",
"in",
"the",
"current",
"invoice"
] | train | https://github.com/paydunya/paydunya-python/blob/bb55791e2814788aec74162d9d78970815f37c30/paydunya/invoice.py#L118-L121 |
paydunya/paydunya-python | paydunya/invoice.py | Invoice.__encode_items | def __encode_items(self, items):
"""Encodes the InvoiceItems into a JSON serializable format
items = [('item_1',InvoiceItem(name='VIP Ticket', quantity=2,
unit_price='3500', total_price='7000',
description='VIP Tickets for party')),...]
... | python | def __encode_items(self, items):
"""Encodes the InvoiceItems into a JSON serializable format
items = [('item_1',InvoiceItem(name='VIP Ticket', quantity=2,
unit_price='3500', total_price='7000',
description='VIP Tickets for party')),...]
... | [
"def",
"__encode_items",
"(",
"self",
",",
"items",
")",
":",
"xs",
"=",
"[",
"item",
".",
"_asdict",
"(",
")",
"for",
"(",
"_key",
",",
"item",
")",
"in",
"items",
".",
"items",
"(",
")",
"]",
"return",
"list",
"(",
"map",
"(",
"lambda",
"x",
... | Encodes the InvoiceItems into a JSON serializable format
items = [('item_1',InvoiceItem(name='VIP Ticket', quantity=2,
unit_price='3500', total_price='7000',
description='VIP Tickets for party')),...] | [
"Encodes",
"the",
"InvoiceItems",
"into",
"a",
"JSON",
"serializable",
"format"
] | train | https://github.com/paydunya/paydunya-python/blob/bb55791e2814788aec74162d9d78970815f37c30/paydunya/invoice.py#L123-L131 |
cons3rt/pycons3rt | pycons3rt/deployment.py | main | def main():
"""Sample usage for this python module
This main method simply illustrates sample usage for this python
module.
:return: None
"""
log = logging.getLogger(mod_logger + '.main')
parser = argparse.ArgumentParser(description='cons3rt deployment CLI')
parser.add_argument('comman... | python | def main():
"""Sample usage for this python module
This main method simply illustrates sample usage for this python
module.
:return: None
"""
log = logging.getLogger(mod_logger + '.main')
parser = argparse.ArgumentParser(description='cons3rt deployment CLI')
parser.add_argument('comman... | [
"def",
"main",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.main'",
")",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'cons3rt deployment CLI'",
")",
"parser",
".",
"add_argument",
"(",
"'c... | Sample usage for this python module
This main method simply illustrates sample usage for this python
module.
:return: None | [
"Sample",
"usage",
"for",
"this",
"python",
"module"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L704-L744 |
cons3rt/pycons3rt | pycons3rt/deployment.py | Deployment.set_deployment_home | def set_deployment_home(self):
"""Sets self.deployment_home
This method finds and sets deployment home, primarily based on
the DEPLOYMENT_HOME environment variable. If not set, this
method will attempt to determine deployment home.
:return: None
"""
log = loggin... | python | def set_deployment_home(self):
"""Sets self.deployment_home
This method finds and sets deployment home, primarily based on
the DEPLOYMENT_HOME environment variable. If not set, this
method will attempt to determine deployment home.
:return: None
"""
log = loggin... | [
"def",
"set_deployment_home",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.set_deployment_home'",
")",
"try",
":",
"self",
".",
"deployment_home",
"=",
"os",
".",
"environ",
"[",
"'DEPLOYMENT_HOME'",
... | Sets self.deployment_home
This method finds and sets deployment home, primarily based on
the DEPLOYMENT_HOME environment variable. If not set, this
method will attempt to determine deployment home.
:return: None | [
"Sets",
"self",
".",
"deployment_home"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L115-L164 |
cons3rt/pycons3rt | pycons3rt/deployment.py | Deployment.read_deployment_properties | def read_deployment_properties(self):
"""Reads the deployment properties file
This method reads the deployment properties file into the
"properties" dictionary object.
:return: None
:raises: DeploymentError
"""
log = logging.getLogger(self.cls_logger + '.read_de... | python | def read_deployment_properties(self):
"""Reads the deployment properties file
This method reads the deployment properties file into the
"properties" dictionary object.
:return: None
:raises: DeploymentError
"""
log = logging.getLogger(self.cls_logger + '.read_de... | [
"def",
"read_deployment_properties",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.read_deployment_properties'",
")",
"# Ensure deployment properties file exists",
"self",
".",
"properties_file",
"=",
"os",
"."... | Reads the deployment properties file
This method reads the deployment properties file into the
"properties" dictionary object.
:return: None
:raises: DeploymentError | [
"Reads",
"the",
"deployment",
"properties",
"file"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L166-L217 |
cons3rt/pycons3rt | pycons3rt/deployment.py | Deployment.get_property | def get_property(self, regex):
"""Gets the name of a specific property
This public method is passed a regular expression and
returns the matching property name. If either the property
is not found or if the passed string matches more than one
property, this function will return ... | python | def get_property(self, regex):
"""Gets the name of a specific property
This public method is passed a regular expression and
returns the matching property name. If either the property
is not found or if the passed string matches more than one
property, this function will return ... | [
"def",
"get_property",
"(",
"self",
",",
"regex",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.get_property'",
")",
"if",
"not",
"isinstance",
"(",
"regex",
",",
"basestring",
")",
":",
"log",
".",
"error",
... | Gets the name of a specific property
This public method is passed a regular expression and
returns the matching property name. If either the property
is not found or if the passed string matches more than one
property, this function will return None.
:param regex: Regular expre... | [
"Gets",
"the",
"name",
"of",
"a",
"specific",
"property"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L219-L255 |
cons3rt/pycons3rt | pycons3rt/deployment.py | Deployment.get_matching_property_names | def get_matching_property_names(self, regex):
"""Returns a list of property names matching the provided
regular expression
:param regex: Regular expression to search on
:return: (list) of property names matching the regex
"""
log = logging.getLogger(self.cls_logger + '.g... | python | def get_matching_property_names(self, regex):
"""Returns a list of property names matching the provided
regular expression
:param regex: Regular expression to search on
:return: (list) of property names matching the regex
"""
log = logging.getLogger(self.cls_logger + '.g... | [
"def",
"get_matching_property_names",
"(",
"self",
",",
"regex",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.get_matching_property_names'",
")",
"prop_list_matched",
"=",
"[",
"]",
"if",
"not",
"isinstance",
"(",
... | Returns a list of property names matching the provided
regular expression
:param regex: Regular expression to search on
:return: (list) of property names matching the regex | [
"Returns",
"a",
"list",
"of",
"property",
"names",
"matching",
"the",
"provided",
"regular",
"expression"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L257-L274 |
cons3rt/pycons3rt | pycons3rt/deployment.py | Deployment.get_value | def get_value(self, property_name):
"""Returns the value associated to the passed property
This public method is passed a specific property as a string
and returns the value of that property. If the property is not
found, None will be returned.
:param property_name (str) The na... | python | def get_value(self, property_name):
"""Returns the value associated to the passed property
This public method is passed a specific property as a string
and returns the value of that property. If the property is not
found, None will be returned.
:param property_name (str) The na... | [
"def",
"get_value",
"(",
"self",
",",
"property_name",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.get_value'",
")",
"if",
"not",
"isinstance",
"(",
"property_name",
",",
"basestring",
")",
":",
"log",
".",
... | Returns the value associated to the passed property
This public method is passed a specific property as a string
and returns the value of that property. If the property is not
found, None will be returned.
:param property_name (str) The name of the property
:return: (str) value... | [
"Returns",
"the",
"value",
"associated",
"to",
"the",
"passed",
"property"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L276-L297 |
cons3rt/pycons3rt | pycons3rt/deployment.py | Deployment.set_cons3rt_role_name | def set_cons3rt_role_name(self):
"""Set the cons3rt_role_name member for this system
:return: None
:raises: DeploymentError
"""
log = logging.getLogger(self.cls_logger + '.set_cons3rt_role_name')
try:
self.cons3rt_role_name = os.environ['CONS3RT_ROLE_NAME']
... | python | def set_cons3rt_role_name(self):
"""Set the cons3rt_role_name member for this system
:return: None
:raises: DeploymentError
"""
log = logging.getLogger(self.cls_logger + '.set_cons3rt_role_name')
try:
self.cons3rt_role_name = os.environ['CONS3RT_ROLE_NAME']
... | [
"def",
"set_cons3rt_role_name",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.set_cons3rt_role_name'",
")",
"try",
":",
"self",
".",
"cons3rt_role_name",
"=",
"os",
".",
"environ",
"[",
"'CONS3RT_ROLE_N... | Set the cons3rt_role_name member for this system
:return: None
:raises: DeploymentError | [
"Set",
"the",
"cons3rt_role_name",
"member",
"for",
"this",
"system"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L299-L322 |
cons3rt/pycons3rt | pycons3rt/deployment.py | Deployment.determine_cons3rt_role_name_linux | def determine_cons3rt_role_name_linux(self):
"""Determines the CONS3RT_ROLE_NAME for this Linux system, and
Set the cons3rt_role_name member for this system
This method determines the CONS3RT_ROLE_NAME for this system
in the deployment by first checking for the environment
varia... | python | def determine_cons3rt_role_name_linux(self):
"""Determines the CONS3RT_ROLE_NAME for this Linux system, and
Set the cons3rt_role_name member for this system
This method determines the CONS3RT_ROLE_NAME for this system
in the deployment by first checking for the environment
varia... | [
"def",
"determine_cons3rt_role_name_linux",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.determine_cons3rt_role_name_linux'",
")",
"# Determine IP addresses for this system",
"log",
".",
"info",
"(",
"'Determini... | Determines the CONS3RT_ROLE_NAME for this Linux system, and
Set the cons3rt_role_name member for this system
This method determines the CONS3RT_ROLE_NAME for this system
in the deployment by first checking for the environment
variable, if not set, determining the value from the
... | [
"Determines",
"the",
"CONS3RT_ROLE_NAME",
"for",
"this",
"Linux",
"system",
"and",
"Set",
"the",
"cons3rt_role_name",
"member",
"for",
"this",
"system"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L324-L399 |
cons3rt/pycons3rt | pycons3rt/deployment.py | Deployment.set_asset_dir | def set_asset_dir(self):
"""Returns the ASSET_DIR environment variable
This method gets the ASSET_DIR environment variable for the
current asset install. It returns either the string value if
set or None if it is not set.
:return: None
"""
log = logging.getLogge... | python | def set_asset_dir(self):
"""Returns the ASSET_DIR environment variable
This method gets the ASSET_DIR environment variable for the
current asset install. It returns either the string value if
set or None if it is not set.
:return: None
"""
log = logging.getLogge... | [
"def",
"set_asset_dir",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.get_asset_dir'",
")",
"try",
":",
"self",
".",
"asset_dir",
"=",
"os",
".",
"environ",
"[",
"'ASSET_DIR'",
"]",
"except",
"Key... | Returns the ASSET_DIR environment variable
This method gets the ASSET_DIR environment variable for the
current asset install. It returns either the string value if
set or None if it is not set.
:return: None | [
"Returns",
"the",
"ASSET_DIR",
"environment",
"variable"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L401-L416 |
cons3rt/pycons3rt | pycons3rt/deployment.py | Deployment.set_scenario_role_names | def set_scenario_role_names(self):
"""Populates the list of scenario role names in this deployment and
populates the scenario_master with the master role
Gets a list of deployment properties containing "isMaster" because
there is exactly one per scenario host, containing the role name
... | python | def set_scenario_role_names(self):
"""Populates the list of scenario role names in this deployment and
populates the scenario_master with the master role
Gets a list of deployment properties containing "isMaster" because
there is exactly one per scenario host, containing the role name
... | [
"def",
"set_scenario_role_names",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.set_scenario_role_names'",
")",
"is_master_props",
"=",
"self",
".",
"get_matching_property_names",
"(",
"'isMaster'",
")",
"f... | Populates the list of scenario role names in this deployment and
populates the scenario_master with the master role
Gets a list of deployment properties containing "isMaster" because
there is exactly one per scenario host, containing the role name
:return: | [
"Populates",
"the",
"list",
"of",
"scenario",
"role",
"names",
"in",
"this",
"deployment",
"and",
"populates",
"the",
"scenario_master",
"with",
"the",
"master",
"role"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L418-L438 |
cons3rt/pycons3rt | pycons3rt/deployment.py | Deployment.set_scenario_network_info | def set_scenario_network_info(self):
"""Populates a list of network info for each scenario host from
deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_scenario_network_info')
for scenario_host in self.scenario_role_names:
... | python | def set_scenario_network_info(self):
"""Populates a list of network info for each scenario host from
deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_scenario_network_info')
for scenario_host in self.scenario_role_names:
... | [
"def",
"set_scenario_network_info",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.set_scenario_network_info'",
")",
"for",
"scenario_host",
"in",
"self",
".",
"scenario_role_names",
":",
"scenario_host_networ... | Populates a list of network info for each scenario host from
deployment properties
:return: None | [
"Populates",
"a",
"list",
"of",
"network",
"info",
"for",
"each",
"scenario",
"host",
"from",
"deployment",
"properties"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L440-L498 |
cons3rt/pycons3rt | pycons3rt/deployment.py | Deployment.set_deployment_name | def set_deployment_name(self):
"""Sets the deployment name from deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_deployment_name')
self.deployment_name = self.get_value('cons3rt.deployment.name')
log.info('Found deployment name: {n}... | python | def set_deployment_name(self):
"""Sets the deployment name from deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_deployment_name')
self.deployment_name = self.get_value('cons3rt.deployment.name')
log.info('Found deployment name: {n}... | [
"def",
"set_deployment_name",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.set_deployment_name'",
")",
"self",
".",
"deployment_name",
"=",
"self",
".",
"get_value",
"(",
"'cons3rt.deployment.name'",
")"... | Sets the deployment name from deployment properties
:return: None | [
"Sets",
"the",
"deployment",
"name",
"from",
"deployment",
"properties"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L500-L507 |
cons3rt/pycons3rt | pycons3rt/deployment.py | Deployment.set_deployment_id | def set_deployment_id(self):
"""Sets the deployment ID from deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_deployment_id')
deployment_id_val = self.get_value('cons3rt.deployment.id')
if not deployment_id_val:
log.debug... | python | def set_deployment_id(self):
"""Sets the deployment ID from deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_deployment_id')
deployment_id_val = self.get_value('cons3rt.deployment.id')
if not deployment_id_val:
log.debug... | [
"def",
"set_deployment_id",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.set_deployment_id'",
")",
"deployment_id_val",
"=",
"self",
".",
"get_value",
"(",
"'cons3rt.deployment.id'",
")",
"if",
"not",
... | Sets the deployment ID from deployment properties
:return: None | [
"Sets",
"the",
"deployment",
"ID",
"from",
"deployment",
"properties"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L509-L525 |
cons3rt/pycons3rt | pycons3rt/deployment.py | Deployment.set_deployment_run_name | def set_deployment_run_name(self):
"""Sets the deployment run name from deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_deployment_run_name')
self.deployment_run_name = self.get_value('cons3rt.deploymentRun.name')
log.info('Found d... | python | def set_deployment_run_name(self):
"""Sets the deployment run name from deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_deployment_run_name')
self.deployment_run_name = self.get_value('cons3rt.deploymentRun.name')
log.info('Found d... | [
"def",
"set_deployment_run_name",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.set_deployment_run_name'",
")",
"self",
".",
"deployment_run_name",
"=",
"self",
".",
"get_value",
"(",
"'cons3rt.deploymentRu... | Sets the deployment run name from deployment properties
:return: None | [
"Sets",
"the",
"deployment",
"run",
"name",
"from",
"deployment",
"properties"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L527-L534 |
cons3rt/pycons3rt | pycons3rt/deployment.py | Deployment.set_deployment_run_id | def set_deployment_run_id(self):
"""Sets the deployment run ID from deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_deployment_run_id')
deployment_run_id_val = self.get_value('cons3rt.deploymentRun.id')
if not deployment_run_id_val... | python | def set_deployment_run_id(self):
"""Sets the deployment run ID from deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_deployment_run_id')
deployment_run_id_val = self.get_value('cons3rt.deploymentRun.id')
if not deployment_run_id_val... | [
"def",
"set_deployment_run_id",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.set_deployment_run_id'",
")",
"deployment_run_id_val",
"=",
"self",
".",
"get_value",
"(",
"'cons3rt.deploymentRun.id'",
")",
"i... | Sets the deployment run ID from deployment properties
:return: None | [
"Sets",
"the",
"deployment",
"run",
"ID",
"from",
"deployment",
"properties"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L536-L552 |
cons3rt/pycons3rt | pycons3rt/deployment.py | Deployment.set_virtualization_realm_type | def set_virtualization_realm_type(self):
"""Sets the virtualization realm type from deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_virtualization_realm_type')
self.virtualization_realm_type = self.get_value('cons3rt.deploymentRun.virtReal... | python | def set_virtualization_realm_type(self):
"""Sets the virtualization realm type from deployment properties
:return: None
"""
log = logging.getLogger(self.cls_logger + '.set_virtualization_realm_type')
self.virtualization_realm_type = self.get_value('cons3rt.deploymentRun.virtReal... | [
"def",
"set_virtualization_realm_type",
"(",
"self",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.set_virtualization_realm_type'",
")",
"self",
".",
"virtualization_realm_type",
"=",
"self",
".",
"get_value",
"(",
"'co... | Sets the virtualization realm type from deployment properties
:return: None | [
"Sets",
"the",
"virtualization",
"realm",
"type",
"from",
"deployment",
"properties"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L554-L561 |
cons3rt/pycons3rt | pycons3rt/deployment.py | Deployment.update_hosts_file | def update_hosts_file(self, ip, entry):
"""Updated the hosts file depending on the OS
:param ip: (str) IP address to update
:param entry: (str) entry to associate to the IP address
:return: None
"""
log = logging.getLogger(self.cls_logger + '.update_hosts_file')
... | python | def update_hosts_file(self, ip, entry):
"""Updated the hosts file depending on the OS
:param ip: (str) IP address to update
:param entry: (str) entry to associate to the IP address
:return: None
"""
log = logging.getLogger(self.cls_logger + '.update_hosts_file')
... | [
"def",
"update_hosts_file",
"(",
"self",
",",
"ip",
",",
"entry",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.update_hosts_file'",
")",
"if",
"get_os",
"(",
")",
"in",
"[",
"'Linux'",
",",
"'Darwin'",
"]",
... | Updated the hosts file depending on the OS
:param ip: (str) IP address to update
:param entry: (str) entry to associate to the IP address
:return: None | [
"Updated",
"the",
"hosts",
"file",
"depending",
"on",
"the",
"OS"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L563-L577 |
cons3rt/pycons3rt | pycons3rt/deployment.py | Deployment.set_scenario_hosts_file | def set_scenario_hosts_file(self, network_name='user-net', domain_name=None):
"""Adds hosts file entries for each system in the scenario
for the specified network_name provided
:param network_name: (str) Name of the network to add to the hosts file
:param domain_name: (str) Domain name ... | python | def set_scenario_hosts_file(self, network_name='user-net', domain_name=None):
"""Adds hosts file entries for each system in the scenario
for the specified network_name provided
:param network_name: (str) Name of the network to add to the hosts file
:param domain_name: (str) Domain name ... | [
"def",
"set_scenario_hosts_file",
"(",
"self",
",",
"network_name",
"=",
"'user-net'",
",",
"domain_name",
"=",
"None",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.set_scenario_hosts_file'",
")",
"log",
".",
"info... | Adds hosts file entries for each system in the scenario
for the specified network_name provided
:param network_name: (str) Name of the network to add to the hosts file
:param domain_name: (str) Domain name to include in the hosts file entries if provided
:return: None | [
"Adds",
"hosts",
"file",
"entries",
"for",
"each",
"system",
"in",
"the",
"scenario",
"for",
"the",
"specified",
"network_name",
"provided"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L579-L597 |
cons3rt/pycons3rt | pycons3rt/deployment.py | Deployment.set_hosts_file_entry_for_role | def set_hosts_file_entry_for_role(self, role_name, network_name='user-net', fqdn=None, domain_name=None):
"""Adds an entry to the hosts file for a scenario host given
the role name and network name
:param role_name: (str) role name of the host to add
:param network_name: (str) Name of t... | python | def set_hosts_file_entry_for_role(self, role_name, network_name='user-net', fqdn=None, domain_name=None):
"""Adds an entry to the hosts file for a scenario host given
the role name and network name
:param role_name: (str) role name of the host to add
:param network_name: (str) Name of t... | [
"def",
"set_hosts_file_entry_for_role",
"(",
"self",
",",
"role_name",
",",
"network_name",
"=",
"'user-net'",
",",
"fqdn",
"=",
"None",
",",
"domain_name",
"=",
"None",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
... | Adds an entry to the hosts file for a scenario host given
the role name and network name
:param role_name: (str) role name of the host to add
:param network_name: (str) Name of the network to add to the hosts file
:param fqdn: (str) Fully qualified domain name to use in the hosts file e... | [
"Adds",
"an",
"entry",
"to",
"the",
"hosts",
"file",
"for",
"a",
"scenario",
"host",
"given",
"the",
"role",
"name",
"and",
"network",
"name"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L599-L625 |
cons3rt/pycons3rt | pycons3rt/deployment.py | Deployment.get_ip_on_network | def get_ip_on_network(self, network_name):
"""Given a network name, returns the IP address
:param network_name: (str) Name of the network to search for
:return: (str) IP address on the specified network or None
"""
return self.get_scenario_host_ip_on_network(
scenari... | python | def get_ip_on_network(self, network_name):
"""Given a network name, returns the IP address
:param network_name: (str) Name of the network to search for
:return: (str) IP address on the specified network or None
"""
return self.get_scenario_host_ip_on_network(
scenari... | [
"def",
"get_ip_on_network",
"(",
"self",
",",
"network_name",
")",
":",
"return",
"self",
".",
"get_scenario_host_ip_on_network",
"(",
"scenario_role_name",
"=",
"self",
".",
"cons3rt_role_name",
",",
"network_name",
"=",
"network_name",
")"
] | Given a network name, returns the IP address
:param network_name: (str) Name of the network to search for
:return: (str) IP address on the specified network or None | [
"Given",
"a",
"network",
"name",
"returns",
"the",
"IP",
"address"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L627-L636 |
cons3rt/pycons3rt | pycons3rt/deployment.py | Deployment.get_scenario_host_ip_on_network | def get_scenario_host_ip_on_network(self, scenario_role_name, network_name):
"""Given a network name, returns the IP address
:param network_name: (str) Name of the network to search for
:param scenario_role_name: (str) role name to return the IP address for
:return: (str) IP address on ... | python | def get_scenario_host_ip_on_network(self, scenario_role_name, network_name):
"""Given a network name, returns the IP address
:param network_name: (str) Name of the network to search for
:param scenario_role_name: (str) role name to return the IP address for
:return: (str) IP address on ... | [
"def",
"get_scenario_host_ip_on_network",
"(",
"self",
",",
"scenario_role_name",
",",
"network_name",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.get_scenario_host_ip_on_network'",
")",
"# Determine the network info for this... | Given a network name, returns the IP address
:param network_name: (str) Name of the network to search for
:param scenario_role_name: (str) role name to return the IP address for
:return: (str) IP address on the specified network or None | [
"Given",
"a",
"network",
"name",
"returns",
"the",
"IP",
"address"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L638-L665 |
cons3rt/pycons3rt | pycons3rt/deployment.py | Deployment.get_device_for_network_linux | def get_device_for_network_linux(self, network_name):
"""Given a cons3rt network name, return the network interface name
on this Linux system
:param network_name: (str) Name of the network to search for
:return: (str) name of the network interface device or None
"""
log ... | python | def get_device_for_network_linux(self, network_name):
"""Given a cons3rt network name, return the network interface name
on this Linux system
:param network_name: (str) Name of the network to search for
:return: (str) name of the network interface device or None
"""
log ... | [
"def",
"get_device_for_network_linux",
"(",
"self",
",",
"network_name",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"cls_logger",
"+",
"'.get_device_for_network_linux'",
")",
"if",
"get_os",
"(",
")",
"not",
"in",
"[",
"'Linux'",
"]",... | Given a cons3rt network name, return the network interface name
on this Linux system
:param network_name: (str) Name of the network to search for
:return: (str) name of the network interface device or None | [
"Given",
"a",
"cons3rt",
"network",
"name",
"return",
"the",
"network",
"interface",
"name",
"on",
"this",
"Linux",
"system"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L667-L701 |
kajala/django-jutil | jutil/auth.py | require_auth | def require_auth(request: Request, exceptions: bool=True) -> User:
"""
Returns authenticated User.
:param request: HttpRequest
:param exceptions: Raise (NotAuthenticated) exception. Default is True.
:return: User
"""
if not request.user or not request.user.is_authenticated:
if except... | python | def require_auth(request: Request, exceptions: bool=True) -> User:
"""
Returns authenticated User.
:param request: HttpRequest
:param exceptions: Raise (NotAuthenticated) exception. Default is True.
:return: User
"""
if not request.user or not request.user.is_authenticated:
if except... | [
"def",
"require_auth",
"(",
"request",
":",
"Request",
",",
"exceptions",
":",
"bool",
"=",
"True",
")",
"->",
"User",
":",
"if",
"not",
"request",
".",
"user",
"or",
"not",
"request",
".",
"user",
".",
"is_authenticated",
":",
"if",
"exceptions",
":",
... | Returns authenticated User.
:param request: HttpRequest
:param exceptions: Raise (NotAuthenticated) exception. Default is True.
:return: User | [
"Returns",
"authenticated",
"User",
".",
":",
"param",
"request",
":",
"HttpRequest",
":",
"param",
"exceptions",
":",
"Raise",
"(",
"NotAuthenticated",
")",
"exception",
".",
"Default",
"is",
"True",
".",
":",
"return",
":",
"User"
] | train | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/auth.py#L7-L18 |
mozilla/libnfldap | libnfldap.py | IPTables.insertSaneDefaults | def insertSaneDefaults(self):
""" Add sane defaults rules to the raw and filter tables """
self.raw.insert(0, '-A OUTPUT -o lo -j NOTRACK')
self.raw.insert(1, '-A PREROUTING -i lo -j NOTRACK')
self.filters.insert(0, '-A INPUT -i lo -j ACCEPT')
self.filters.insert(1, '-A OUTPUT -o lo -j ACCEPT')
self.filters... | python | def insertSaneDefaults(self):
""" Add sane defaults rules to the raw and filter tables """
self.raw.insert(0, '-A OUTPUT -o lo -j NOTRACK')
self.raw.insert(1, '-A PREROUTING -i lo -j NOTRACK')
self.filters.insert(0, '-A INPUT -i lo -j ACCEPT')
self.filters.insert(1, '-A OUTPUT -o lo -j ACCEPT')
self.filters... | [
"def",
"insertSaneDefaults",
"(",
"self",
")",
":",
"self",
".",
"raw",
".",
"insert",
"(",
"0",
",",
"'-A OUTPUT -o lo -j NOTRACK'",
")",
"self",
".",
"raw",
".",
"insert",
"(",
"1",
",",
"'-A PREROUTING -i lo -j NOTRACK'",
")",
"self",
".",
"filters",
".",... | Add sane defaults rules to the raw and filter tables | [
"Add",
"sane",
"defaults",
"rules",
"to",
"the",
"raw",
"and",
"filter",
"tables"
] | train | https://github.com/mozilla/libnfldap/blob/27407a6ed6bfd07d1eba2824398c77e2fe98f968/libnfldap.py#L92-L100 |
mozilla/libnfldap | libnfldap.py | IPTables.appendDefaultDrop | def appendDefaultDrop(self):
""" Add a DROP policy at the end of the rules """
self.filters.append('-A INPUT -j DROP')
self.filters.append('-A OUTPUT -j DROP')
self.filters.append('-A FORWARD -j DROP')
return self | python | def appendDefaultDrop(self):
""" Add a DROP policy at the end of the rules """
self.filters.append('-A INPUT -j DROP')
self.filters.append('-A OUTPUT -j DROP')
self.filters.append('-A FORWARD -j DROP')
return self | [
"def",
"appendDefaultDrop",
"(",
"self",
")",
":",
"self",
".",
"filters",
".",
"append",
"(",
"'-A INPUT -j DROP'",
")",
"self",
".",
"filters",
".",
"append",
"(",
"'-A OUTPUT -j DROP'",
")",
"self",
".",
"filters",
".",
"append",
"(",
"'-A FORWARD -j DROP'"... | Add a DROP policy at the end of the rules | [
"Add",
"a",
"DROP",
"policy",
"at",
"the",
"end",
"of",
"the",
"rules"
] | train | https://github.com/mozilla/libnfldap/blob/27407a6ed6bfd07d1eba2824398c77e2fe98f968/libnfldap.py#L102-L107 |
mozilla/libnfldap | libnfldap.py | IPTables.template | def template(self):
""" Create a rules file in iptables-restore format """
s = Template(self._IPTABLES_TEMPLATE)
return s.substitute(filtertable='\n'.join(self.filters),
rawtable='\n'.join(self.raw),
mangletable='\n'.join(self.mangle),
nattable='\n'.join(self.nat),
date=datetime.today(... | python | def template(self):
""" Create a rules file in iptables-restore format """
s = Template(self._IPTABLES_TEMPLATE)
return s.substitute(filtertable='\n'.join(self.filters),
rawtable='\n'.join(self.raw),
mangletable='\n'.join(self.mangle),
nattable='\n'.join(self.nat),
date=datetime.today(... | [
"def",
"template",
"(",
"self",
")",
":",
"s",
"=",
"Template",
"(",
"self",
".",
"_IPTABLES_TEMPLATE",
")",
"return",
"s",
".",
"substitute",
"(",
"filtertable",
"=",
"'\\n'",
".",
"join",
"(",
"self",
".",
"filters",
")",
",",
"rawtable",
"=",
"'\\n'... | Create a rules file in iptables-restore format | [
"Create",
"a",
"rules",
"file",
"in",
"iptables",
"-",
"restore",
"format"
] | train | https://github.com/mozilla/libnfldap/blob/27407a6ed6bfd07d1eba2824398c77e2fe98f968/libnfldap.py#L155-L162 |
mozilla/libnfldap | libnfldap.py | IPset.template | def template(self):
""" Create a rules file in ipset --restore format """
s = Template(self._IPSET_TEMPLATE)
return s.substitute(sets='\n'.join(self.sets),
date=datetime.today()) | python | def template(self):
""" Create a rules file in ipset --restore format """
s = Template(self._IPSET_TEMPLATE)
return s.substitute(sets='\n'.join(self.sets),
date=datetime.today()) | [
"def",
"template",
"(",
"self",
")",
":",
"s",
"=",
"Template",
"(",
"self",
".",
"_IPSET_TEMPLATE",
")",
"return",
"s",
".",
"substitute",
"(",
"sets",
"=",
"'\\n'",
".",
"join",
"(",
"self",
".",
"sets",
")",
",",
"date",
"=",
"datetime",
".",
"t... | Create a rules file in ipset --restore format | [
"Create",
"a",
"rules",
"file",
"in",
"ipset",
"--",
"restore",
"format"
] | train | https://github.com/mozilla/libnfldap/blob/27407a6ed6bfd07d1eba2824398c77e2fe98f968/libnfldap.py#L210-L214 |
mozilla/libnfldap | libnfldap.py | LDAP.query | def query(self, base, filterstr, attrlist=None):
""" wrapper to search_s """
return self.conn.search_s(base, ldap.SCOPE_SUBTREE, filterstr, attrlist) | python | def query(self, base, filterstr, attrlist=None):
""" wrapper to search_s """
return self.conn.search_s(base, ldap.SCOPE_SUBTREE, filterstr, attrlist) | [
"def",
"query",
"(",
"self",
",",
"base",
",",
"filterstr",
",",
"attrlist",
"=",
"None",
")",
":",
"return",
"self",
".",
"conn",
".",
"search_s",
"(",
"base",
",",
"ldap",
".",
"SCOPE_SUBTREE",
",",
"filterstr",
",",
"attrlist",
")"
] | wrapper to search_s | [
"wrapper",
"to",
"search_s"
] | train | https://github.com/mozilla/libnfldap/blob/27407a6ed6bfd07d1eba2824398c77e2fe98f968/libnfldap.py#L228-L230 |
mozilla/libnfldap | libnfldap.py | LDAP.getUserByNumber | def getUserByNumber(self, base, uidNumber):
""" search for a user in LDAP and return its DN and uid """
res = self.query(base, "uidNumber="+str(uidNumber), ['uid'])
if len(res) > 1:
raise InputError(uidNumber, "Multiple users found. Expecting one.")
return res[0][0], res[0][1]['uid'][0] | python | def getUserByNumber(self, base, uidNumber):
""" search for a user in LDAP and return its DN and uid """
res = self.query(base, "uidNumber="+str(uidNumber), ['uid'])
if len(res) > 1:
raise InputError(uidNumber, "Multiple users found. Expecting one.")
return res[0][0], res[0][1]['uid'][0] | [
"def",
"getUserByNumber",
"(",
"self",
",",
"base",
",",
"uidNumber",
")",
":",
"res",
"=",
"self",
".",
"query",
"(",
"base",
",",
"\"uidNumber=\"",
"+",
"str",
"(",
"uidNumber",
")",
",",
"[",
"'uid'",
"]",
")",
"if",
"len",
"(",
"res",
")",
">",... | search for a user in LDAP and return its DN and uid | [
"search",
"for",
"a",
"user",
"in",
"LDAP",
"and",
"return",
"its",
"DN",
"and",
"uid"
] | train | https://github.com/mozilla/libnfldap/blob/27407a6ed6bfd07d1eba2824398c77e2fe98f968/libnfldap.py#L232-L237 |
mozilla/libnfldap | libnfldap.py | LDAP.getACLs | def getACLs(self, base, searchstr):
"""
Query LDAP to obtain the network ACLs of a given user,
parse the ACLs, and return the results in a dict of the form
acls[group][cidr] = description
"""
acls = dict()
res = self.query(base, searchstr, ['cn', 'ipHostNumber'])
for dn,attr in res:
cn = attr['cn'... | python | def getACLs(self, base, searchstr):
"""
Query LDAP to obtain the network ACLs of a given user,
parse the ACLs, and return the results in a dict of the form
acls[group][cidr] = description
"""
acls = dict()
res = self.query(base, searchstr, ['cn', 'ipHostNumber'])
for dn,attr in res:
cn = attr['cn'... | [
"def",
"getACLs",
"(",
"self",
",",
"base",
",",
"searchstr",
")",
":",
"acls",
"=",
"dict",
"(",
")",
"res",
"=",
"self",
".",
"query",
"(",
"base",
",",
"searchstr",
",",
"[",
"'cn'",
",",
"'ipHostNumber'",
"]",
")",
"for",
"dn",
",",
"attr",
"... | Query LDAP to obtain the network ACLs of a given user,
parse the ACLs, and return the results in a dict of the form
acls[group][cidr] = description | [
"Query",
"LDAP",
"to",
"obtain",
"the",
"network",
"ACLs",
"of",
"a",
"given",
"user",
"parse",
"the",
"ACLs",
"and",
"return",
"the",
"results",
"in",
"a",
"dict",
"of",
"the",
"form",
"acls",
"[",
"group",
"]",
"[",
"cidr",
"]",
"=",
"description"
] | train | https://github.com/mozilla/libnfldap/blob/27407a6ed6bfd07d1eba2824398c77e2fe98f968/libnfldap.py#L239-L262 |
InformaticsMatters/pipelines-utils | src/python/pipelines_utils/parameter_utils.py | splitValues | def splitValues(textStr):
"""Splits a comma-separated number sequence into a list (of floats).
"""
vals = textStr.split(",")
nums = []
for v in vals:
nums.append(float(v))
return nums | python | def splitValues(textStr):
"""Splits a comma-separated number sequence into a list (of floats).
"""
vals = textStr.split(",")
nums = []
for v in vals:
nums.append(float(v))
return nums | [
"def",
"splitValues",
"(",
"textStr",
")",
":",
"vals",
"=",
"textStr",
".",
"split",
"(",
"\",\"",
")",
"nums",
"=",
"[",
"]",
"for",
"v",
"in",
"vals",
":",
"nums",
".",
"append",
"(",
"float",
"(",
"v",
")",
")",
"return",
"nums"
] | Splits a comma-separated number sequence into a list (of floats). | [
"Splits",
"a",
"comma",
"-",
"separated",
"number",
"sequence",
"into",
"a",
"list",
"(",
"of",
"floats",
")",
"."
] | train | https://github.com/InformaticsMatters/pipelines-utils/blob/058aa6eceeff28c4ae402f6f58c58720bff0298e/src/python/pipelines_utils/parameter_utils.py#L49-L56 |
InformaticsMatters/pipelines-utils | src/python/pipelines_utils/parameter_utils.py | expandParameters | def expandParameters(*args):
"""Expands parameters (presented as tuples of lists and symbolic names)
so that each is returned in a new list where each contains the same number
of values.
Each `arg` is a tuple containing two items: a list of values and a
symbolic name.
"""
count = 1
for ... | python | def expandParameters(*args):
"""Expands parameters (presented as tuples of lists and symbolic names)
so that each is returned in a new list where each contains the same number
of values.
Each `arg` is a tuple containing two items: a list of values and a
symbolic name.
"""
count = 1
for ... | [
"def",
"expandParameters",
"(",
"*",
"args",
")",
":",
"count",
"=",
"1",
"for",
"arg",
"in",
"args",
":",
"count",
"=",
"max",
"(",
"len",
"(",
"arg",
"[",
"0",
"]",
")",
",",
"count",
")",
"results",
"=",
"[",
"]",
"for",
"arg",
"in",
"args",... | Expands parameters (presented as tuples of lists and symbolic names)
so that each is returned in a new list where each contains the same number
of values.
Each `arg` is a tuple containing two items: a list of values and a
symbolic name. | [
"Expands",
"parameters",
"(",
"presented",
"as",
"tuples",
"of",
"lists",
"and",
"symbolic",
"names",
")",
"so",
"that",
"each",
"is",
"returned",
"in",
"a",
"new",
"list",
"where",
"each",
"contains",
"the",
"same",
"number",
"of",
"values",
"."
] | train | https://github.com/InformaticsMatters/pipelines-utils/blob/058aa6eceeff28c4ae402f6f58c58720bff0298e/src/python/pipelines_utils/parameter_utils.py#L59-L73 |
InformaticsMatters/pipelines-utils | src/python/pipelines_utils/parameter_utils.py | expandValues | def expandValues(inputs, count, name):
"""Returns the input list with the length of `count`. If the
list is [1] and the count is 3. [1,1,1] is returned. The list
must be the count length or 1. Normally called from `expandParameters()`
where `name` is the symbolic name of the input.
"""
if len(in... | python | def expandValues(inputs, count, name):
"""Returns the input list with the length of `count`. If the
list is [1] and the count is 3. [1,1,1] is returned. The list
must be the count length or 1. Normally called from `expandParameters()`
where `name` is the symbolic name of the input.
"""
if len(in... | [
"def",
"expandValues",
"(",
"inputs",
",",
"count",
",",
"name",
")",
":",
"if",
"len",
"(",
"inputs",
")",
"==",
"count",
":",
"expanded",
"=",
"inputs",
"elif",
"len",
"(",
"inputs",
")",
"==",
"1",
":",
"expanded",
"=",
"inputs",
"*",
"count",
"... | Returns the input list with the length of `count`. If the
list is [1] and the count is 3. [1,1,1] is returned. The list
must be the count length or 1. Normally called from `expandParameters()`
where `name` is the symbolic name of the input. | [
"Returns",
"the",
"input",
"list",
"with",
"the",
"length",
"of",
"count",
".",
"If",
"the",
"list",
"is",
"[",
"1",
"]",
"and",
"the",
"count",
"is",
"3",
".",
"[",
"1",
"1",
"1",
"]",
"is",
"returned",
".",
"The",
"list",
"must",
"be",
"the",
... | train | https://github.com/InformaticsMatters/pipelines-utils/blob/058aa6eceeff28c4ae402f6f58c58720bff0298e/src/python/pipelines_utils/parameter_utils.py#L76-L88 |
kajala/django-jutil | jutil/request.py | get_geo_ip | def get_geo_ip(ip: str, exceptions: bool=False, timeout: int=10) -> dict:
"""
Returns geo IP info or empty dict if geoip query fails at http://ipstack.com.
requires settings.IPSTACK_TOKEN set as valid access token to the API.
Example replies:
{'country_name': 'United States', 'country_code': 'US', ... | python | def get_geo_ip(ip: str, exceptions: bool=False, timeout: int=10) -> dict:
"""
Returns geo IP info or empty dict if geoip query fails at http://ipstack.com.
requires settings.IPSTACK_TOKEN set as valid access token to the API.
Example replies:
{'country_name': 'United States', 'country_code': 'US', ... | [
"def",
"get_geo_ip",
"(",
"ip",
":",
"str",
",",
"exceptions",
":",
"bool",
"=",
"False",
",",
"timeout",
":",
"int",
"=",
"10",
")",
"->",
"dict",
":",
"import",
"requests",
"import",
"traceback",
"try",
":",
"res",
"=",
"requests",
".",
"get",
"(",... | Returns geo IP info or empty dict if geoip query fails at http://ipstack.com.
requires settings.IPSTACK_TOKEN set as valid access token to the API.
Example replies:
{'country_name': 'United States', 'country_code': 'US', 'region_code': 'TX', 'region_name': 'Texas', 'ip': '76.184.236.184', 'latitude': 33.15... | [
"Returns",
"geo",
"IP",
"info",
"or",
"empty",
"dict",
"if",
"geoip",
"query",
"fails",
"at",
"http",
":",
"//",
"ipstack",
".",
"com",
".",
"requires",
"settings",
".",
"IPSTACK_TOKEN",
"set",
"as",
"valid",
"access",
"token",
"to",
"the",
"API",
"."
] | train | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/request.py#L8-L36 |
kajala/django-jutil | jutil/request.py | get_ip_info | def get_ip_info(ip: str, exceptions: bool=False, timeout: int=10) -> tuple:
"""
Returns (ip, country_code, host) tuple of the IP address.
:param ip: IP address
:param exceptions: Raise Exception or not
:param timeout: Timeout in seconds. Note that timeout only affects geo IP part, not getting host n... | python | def get_ip_info(ip: str, exceptions: bool=False, timeout: int=10) -> tuple:
"""
Returns (ip, country_code, host) tuple of the IP address.
:param ip: IP address
:param exceptions: Raise Exception or not
:param timeout: Timeout in seconds. Note that timeout only affects geo IP part, not getting host n... | [
"def",
"get_ip_info",
"(",
"ip",
":",
"str",
",",
"exceptions",
":",
"bool",
"=",
"False",
",",
"timeout",
":",
"int",
"=",
"10",
")",
"->",
"tuple",
":",
"import",
"traceback",
"import",
"socket",
"if",
"not",
"ip",
":",
"# localhost",
"return",
"None... | Returns (ip, country_code, host) tuple of the IP address.
:param ip: IP address
:param exceptions: Raise Exception or not
:param timeout: Timeout in seconds. Note that timeout only affects geo IP part, not getting host name.
:return: (ip, country_code, host) | [
"Returns",
"(",
"ip",
"country_code",
"host",
")",
"tuple",
"of",
"the",
"IP",
"address",
".",
":",
"param",
"ip",
":",
"IP",
"address",
":",
"param",
"exceptions",
":",
"Raise",
"Exception",
"or",
"not",
":",
"param",
"timeout",
":",
"Timeout",
"in",
... | train | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/request.py#L39-L61 |
cons3rt/pycons3rt | pycons3rt/awsapi/metadata.py | is_aws | def is_aws():
"""Determines if this system is on AWS
:return: bool True if this system is running on AWS
"""
log = logging.getLogger(mod_logger + '.is_aws')
log.info('Querying AWS meta data URL: {u}'.format(u=metadata_url))
# Re-try logic for checking the AWS meta data URL
retry_time_sec =... | python | def is_aws():
"""Determines if this system is on AWS
:return: bool True if this system is running on AWS
"""
log = logging.getLogger(mod_logger + '.is_aws')
log.info('Querying AWS meta data URL: {u}'.format(u=metadata_url))
# Re-try logic for checking the AWS meta data URL
retry_time_sec =... | [
"def",
"is_aws",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.is_aws'",
")",
"log",
".",
"info",
"(",
"'Querying AWS meta data URL: {u}'",
".",
"format",
"(",
"u",
"=",
"metadata_url",
")",
")",
"# Re-try logic for checkin... | Determines if this system is on AWS
:return: bool True if this system is running on AWS | [
"Determines",
"if",
"this",
"system",
"is",
"on",
"AWS"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/metadata.py#L44-L79 |
cons3rt/pycons3rt | pycons3rt/awsapi/metadata.py | get_instance_id | def get_instance_id():
"""Gets the instance ID of this EC2 instance
:return: String instance ID or None
"""
log = logging.getLogger(mod_logger + '.get_instance_id')
# Exit if not running on AWS
if not is_aws():
log.info('This machine is not running in AWS, exiting...')
return
... | python | def get_instance_id():
"""Gets the instance ID of this EC2 instance
:return: String instance ID or None
"""
log = logging.getLogger(mod_logger + '.get_instance_id')
# Exit if not running on AWS
if not is_aws():
log.info('This machine is not running in AWS, exiting...')
return
... | [
"def",
"get_instance_id",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.get_instance_id'",
")",
"# Exit if not running on AWS",
"if",
"not",
"is_aws",
"(",
")",
":",
"log",
".",
"info",
"(",
"'This machine is not running in AWS... | Gets the instance ID of this EC2 instance
:return: String instance ID or None | [
"Gets",
"the",
"instance",
"ID",
"of",
"this",
"EC2",
"instance"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/metadata.py#L82-L110 |
cons3rt/pycons3rt | pycons3rt/awsapi/metadata.py | get_vpc_id_from_mac_address | def get_vpc_id_from_mac_address():
"""Gets the VPC ID for this EC2 instance
:return: String instance ID or None
"""
log = logging.getLogger(mod_logger + '.get_vpc_id')
# Exit if not running on AWS
if not is_aws():
log.info('This machine is not running in AWS, exiting...')
retur... | python | def get_vpc_id_from_mac_address():
"""Gets the VPC ID for this EC2 instance
:return: String instance ID or None
"""
log = logging.getLogger(mod_logger + '.get_vpc_id')
# Exit if not running on AWS
if not is_aws():
log.info('This machine is not running in AWS, exiting...')
retur... | [
"def",
"get_vpc_id_from_mac_address",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.get_vpc_id'",
")",
"# Exit if not running on AWS",
"if",
"not",
"is_aws",
"(",
")",
":",
"log",
".",
"info",
"(",
"'This machine is not running... | Gets the VPC ID for this EC2 instance
:return: String instance ID or None | [
"Gets",
"the",
"VPC",
"ID",
"for",
"this",
"EC2",
"instance"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/metadata.py#L113-L151 |
cons3rt/pycons3rt | pycons3rt/awsapi/metadata.py | get_availability_zone | def get_availability_zone():
"""Gets the AWS Availability Zone ID for this system
:return: (str) Availability Zone ID where this system lives
"""
log = logging.getLogger(mod_logger + '.get_availability_zone')
# Exit if not running on AWS
if not is_aws():
log.info('This machine is not r... | python | def get_availability_zone():
"""Gets the AWS Availability Zone ID for this system
:return: (str) Availability Zone ID where this system lives
"""
log = logging.getLogger(mod_logger + '.get_availability_zone')
# Exit if not running on AWS
if not is_aws():
log.info('This machine is not r... | [
"def",
"get_availability_zone",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.get_availability_zone'",
")",
"# Exit if not running on AWS",
"if",
"not",
"is_aws",
"(",
")",
":",
"log",
".",
"info",
"(",
"'This machine is not ru... | Gets the AWS Availability Zone ID for this system
:return: (str) Availability Zone ID where this system lives | [
"Gets",
"the",
"AWS",
"Availability",
"Zone",
"ID",
"for",
"this",
"system"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/metadata.py#L195-L222 |
cons3rt/pycons3rt | pycons3rt/awsapi/metadata.py | get_region | def get_region():
"""Gets the AWS Region ID for this system
:return: (str) AWS Region ID where this system lives
"""
log = logging.getLogger(mod_logger + '.get_region')
# First get the availability zone
availability_zone = get_availability_zone()
if availability_zone is None:
msg ... | python | def get_region():
"""Gets the AWS Region ID for this system
:return: (str) AWS Region ID where this system lives
"""
log = logging.getLogger(mod_logger + '.get_region')
# First get the availability zone
availability_zone = get_availability_zone()
if availability_zone is None:
msg ... | [
"def",
"get_region",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.get_region'",
")",
"# First get the availability zone",
"availability_zone",
"=",
"get_availability_zone",
"(",
")",
"if",
"availability_zone",
"is",
"None",
":",... | Gets the AWS Region ID for this system
:return: (str) AWS Region ID where this system lives | [
"Gets",
"the",
"AWS",
"Region",
"ID",
"for",
"this",
"system"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/metadata.py#L225-L242 |
cons3rt/pycons3rt | pycons3rt/awsapi/metadata.py | get_primary_mac_address | def get_primary_mac_address():
"""Determines the MAC address to use for querying the AWS
meta data service for network related queries
:return: (str) MAC address for the eth0 interface
:raises: AWSMetaDataError
"""
log = logging.getLogger(mod_logger + '.get_primary_mac_address')
log.debug('... | python | def get_primary_mac_address():
"""Determines the MAC address to use for querying the AWS
meta data service for network related queries
:return: (str) MAC address for the eth0 interface
:raises: AWSMetaDataError
"""
log = logging.getLogger(mod_logger + '.get_primary_mac_address')
log.debug('... | [
"def",
"get_primary_mac_address",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.get_primary_mac_address'",
")",
"log",
".",
"debug",
"(",
"'Attempting to determine the MAC address for eth0...'",
")",
"try",
":",
"mac_address",
"=",... | Determines the MAC address to use for querying the AWS
meta data service for network related queries
:return: (str) MAC address for the eth0 interface
:raises: AWSMetaDataError | [
"Determines",
"the",
"MAC",
"address",
"to",
"use",
"for",
"querying",
"the",
"AWS",
"meta",
"data",
"service",
"for",
"network",
"related",
"queries"
] | train | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/metadata.py#L245-L261 |
MarcAureleCoste/sqla-filters | src/sqla_filters/parser/base/base_sqla_parser.py | BaseSqlaParser.attr_sep | def attr_sep(self, new_sep: str) -> None:
"""Set the new value for the attribute separator.
When the new value is assigned a new tree is generated.
"""
self._attr_sep = new_sep
self._filters_tree = self._generate_filters_tree() | python | def attr_sep(self, new_sep: str) -> None:
"""Set the new value for the attribute separator.
When the new value is assigned a new tree is generated.
"""
self._attr_sep = new_sep
self._filters_tree = self._generate_filters_tree() | [
"def",
"attr_sep",
"(",
"self",
",",
"new_sep",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"_attr_sep",
"=",
"new_sep",
"self",
".",
"_filters_tree",
"=",
"self",
".",
"_generate_filters_tree",
"(",
")"
] | Set the new value for the attribute separator.
When the new value is assigned a new tree is generated. | [
"Set",
"the",
"new",
"value",
"for",
"the",
"attribute",
"separator",
".",
"When",
"the",
"new",
"value",
"is",
"assigned",
"a",
"new",
"tree",
"is",
"generated",
"."
] | train | https://github.com/MarcAureleCoste/sqla-filters/blob/a9596f660a11d275bf0e831ecd9e502b0af2a087/src/sqla_filters/parser/base/base_sqla_parser.py#L23-L29 |
kajala/django-jutil | jutil/urls.py | url_equals | def url_equals(a: str, b: str) -> bool:
"""
Compares two URLs/paths and returns True if they point to same URI.
For example, querystring parameters can be different order but URLs are still equal.
:param a: URL/path
:param b: URL/path
:return: True if URLs/paths are equal
"""
from urllib... | python | def url_equals(a: str, b: str) -> bool:
"""
Compares two URLs/paths and returns True if they point to same URI.
For example, querystring parameters can be different order but URLs are still equal.
:param a: URL/path
:param b: URL/path
:return: True if URLs/paths are equal
"""
from urllib... | [
"def",
"url_equals",
"(",
"a",
":",
"str",
",",
"b",
":",
"str",
")",
"->",
"bool",
":",
"from",
"urllib",
".",
"parse",
"import",
"urlparse",
",",
"parse_qsl",
"a2",
"=",
"list",
"(",
"urlparse",
"(",
"a",
")",
")",
"b2",
"=",
"list",
"(",
"urlp... | Compares two URLs/paths and returns True if they point to same URI.
For example, querystring parameters can be different order but URLs are still equal.
:param a: URL/path
:param b: URL/path
:return: True if URLs/paths are equal | [
"Compares",
"two",
"URLs",
"/",
"paths",
"and",
"returns",
"True",
"if",
"they",
"point",
"to",
"same",
"URI",
".",
"For",
"example",
"querystring",
"parameters",
"can",
"be",
"different",
"order",
"but",
"URLs",
"are",
"still",
"equal",
".",
":",
"param",... | train | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/urls.py#L1-L14 |
kajala/django-jutil | jutil/urls.py | url_mod | def url_mod(url: str, new_params: dict) -> str:
"""
Modifies existing URL by setting/overriding specified query string parameters.
Note: Does not support multiple querystring parameters with identical name.
:param url: Base URL/path to modify
:param new_params: Querystring parameters to set/override... | python | def url_mod(url: str, new_params: dict) -> str:
"""
Modifies existing URL by setting/overriding specified query string parameters.
Note: Does not support multiple querystring parameters with identical name.
:param url: Base URL/path to modify
:param new_params: Querystring parameters to set/override... | [
"def",
"url_mod",
"(",
"url",
":",
"str",
",",
"new_params",
":",
"dict",
")",
"->",
"str",
":",
"from",
"urllib",
".",
"parse",
"import",
"urlparse",
",",
"parse_qsl",
",",
"urlunparse",
",",
"urlencode",
"res",
"=",
"urlparse",
"(",
"url",
")",
"quer... | Modifies existing URL by setting/overriding specified query string parameters.
Note: Does not support multiple querystring parameters with identical name.
:param url: Base URL/path to modify
:param new_params: Querystring parameters to set/override (dict)
:return: New URL/path | [
"Modifies",
"existing",
"URL",
"by",
"setting",
"/",
"overriding",
"specified",
"query",
"string",
"parameters",
".",
"Note",
":",
"Does",
"not",
"support",
"multiple",
"querystring",
"parameters",
"with",
"identical",
"name",
".",
":",
"param",
"url",
":",
"B... | train | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/urls.py#L17-L35 |
kajala/django-jutil | jutil/urls.py | url_host | def url_host(url: str) -> str:
"""
Parses hostname from URL.
:param url: URL
:return: hostname
"""
from urllib.parse import urlparse
res = urlparse(url)
return res.netloc.split(':')[0] if res.netloc else '' | python | def url_host(url: str) -> str:
"""
Parses hostname from URL.
:param url: URL
:return: hostname
"""
from urllib.parse import urlparse
res = urlparse(url)
return res.netloc.split(':')[0] if res.netloc else '' | [
"def",
"url_host",
"(",
"url",
":",
"str",
")",
"->",
"str",
":",
"from",
"urllib",
".",
"parse",
"import",
"urlparse",
"res",
"=",
"urlparse",
"(",
"url",
")",
"return",
"res",
".",
"netloc",
".",
"split",
"(",
"':'",
")",
"[",
"0",
"]",
"if",
"... | Parses hostname from URL.
:param url: URL
:return: hostname | [
"Parses",
"hostname",
"from",
"URL",
".",
":",
"param",
"url",
":",
"URL",
":",
"return",
":",
"hostname"
] | train | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/urls.py#L38-L46 |
Vital-Fernandez/dazer | bin/lib/CodeTools/various.py | vitools.ufloatDict_nominal | def ufloatDict_nominal(self, ufloat_dict):
'This gives us a dictionary of nominal values from a dictionary of uncertainties'
return OrderedDict(izip(ufloat_dict.keys(), map(lambda x: x.nominal_value, ufloat_dict.values()))) | python | def ufloatDict_nominal(self, ufloat_dict):
'This gives us a dictionary of nominal values from a dictionary of uncertainties'
return OrderedDict(izip(ufloat_dict.keys(), map(lambda x: x.nominal_value, ufloat_dict.values()))) | [
"def",
"ufloatDict_nominal",
"(",
"self",
",",
"ufloat_dict",
")",
":",
"return",
"OrderedDict",
"(",
"izip",
"(",
"ufloat_dict",
".",
"keys",
"(",
")",
",",
"map",
"(",
"lambda",
"x",
":",
"x",
".",
"nominal_value",
",",
"ufloat_dict",
".",
"values",
"(... | This gives us a dictionary of nominal values from a dictionary of uncertainties | [
"This",
"gives",
"us",
"a",
"dictionary",
"of",
"nominal",
"values",
"from",
"a",
"dictionary",
"of",
"uncertainties"
] | train | https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/CodeTools/various.py#L75-L77 |
Vital-Fernandez/dazer | bin/lib/CodeTools/various.py | vitools.ufloatDict_stdev | def ufloatDict_stdev(self, ufloat_dict):
'This gives us a dictionary of nominal values from a dictionary of uncertainties'
return OrderedDict(izip(ufloat_dict.keys(), map(lambda x: x.std_dev, ufloat_dict.values()))) | python | def ufloatDict_stdev(self, ufloat_dict):
'This gives us a dictionary of nominal values from a dictionary of uncertainties'
return OrderedDict(izip(ufloat_dict.keys(), map(lambda x: x.std_dev, ufloat_dict.values()))) | [
"def",
"ufloatDict_stdev",
"(",
"self",
",",
"ufloat_dict",
")",
":",
"return",
"OrderedDict",
"(",
"izip",
"(",
"ufloat_dict",
".",
"keys",
"(",
")",
",",
"map",
"(",
"lambda",
"x",
":",
"x",
".",
"std_dev",
",",
"ufloat_dict",
".",
"values",
"(",
")"... | This gives us a dictionary of nominal values from a dictionary of uncertainties | [
"This",
"gives",
"us",
"a",
"dictionary",
"of",
"nominal",
"values",
"from",
"a",
"dictionary",
"of",
"uncertainties"
] | train | https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/CodeTools/various.py#L80-L82 |
novopl/peltak | src/peltak/logic/docs.py | docs | def docs(recreate, gen_index, run_doctests):
# type: (bool, bool, bool) -> None
""" Build the documentation for the project.
Args:
recreate (bool):
If set to **True**, the build and output directories will be cleared
prior to generating the docs.
gen_index (bool):
... | python | def docs(recreate, gen_index, run_doctests):
# type: (bool, bool, bool) -> None
""" Build the documentation for the project.
Args:
recreate (bool):
If set to **True**, the build and output directories will be cleared
prior to generating the docs.
gen_index (bool):
... | [
"def",
"docs",
"(",
"recreate",
",",
"gen_index",
",",
"run_doctests",
")",
":",
"# type: (bool, bool, bool) -> None",
"build_dir",
"=",
"conf",
".",
"get_path",
"(",
"'build_dir'",
",",
"'.build'",
")",
"docs_dir",
"=",
"conf",
".",
"get_path",
"(",
"'docs.path... | Build the documentation for the project.
Args:
recreate (bool):
If set to **True**, the build and output directories will be cleared
prior to generating the docs.
gen_index (bool):
If set to **True**, it will generate top-level index file for the
refe... | [
"Build",
"the",
"documentation",
"for",
"the",
"project",
"."
] | train | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/logic/docs.py#L32-L89 |
novopl/peltak | src/peltak/logic/docs.py | gen_ref_docs | def gen_ref_docs(gen_index=False):
# type: (int, bool) -> None
""" Generate reference documentation for the project.
This will use **sphinx-refdoc** to generate the source .rst files for the
reference documentation.
Args:
gen_index (bool):
Set it to **True** if you want to gene... | python | def gen_ref_docs(gen_index=False):
# type: (int, bool) -> None
""" Generate reference documentation for the project.
This will use **sphinx-refdoc** to generate the source .rst files for the
reference documentation.
Args:
gen_index (bool):
Set it to **True** if you want to gene... | [
"def",
"gen_ref_docs",
"(",
"gen_index",
"=",
"False",
")",
":",
"# type: (int, bool) -> None",
"try",
":",
"from",
"refdoc",
"import",
"generate_docs",
"except",
"ImportError",
"as",
"ex",
":",
"msg",
"=",
"(",
"\"You need to install sphinx-refdoc if you want to genera... | Generate reference documentation for the project.
This will use **sphinx-refdoc** to generate the source .rst files for the
reference documentation.
Args:
gen_index (bool):
Set it to **True** if you want to generate the index file with the
list of top-level packages. This i... | [
"Generate",
"reference",
"documentation",
"for",
"the",
"project",
"."
] | train | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/logic/docs.py#L92-L146 |
ebob9/cloudgenix-idname | cloudgenix_idname/__init__.py | generate_id_name_map | def generate_id_name_map(sdk, reverse=False):
"""
Generate the ID-NAME map dict
:param sdk: CloudGenix API constructor
:param reverse: Generate reverse name-> ID map as well, return tuple with both.
:return: ID Name dictionary
"""
global_id_name_dict = {}
global_name_id_dict = {}
#... | python | def generate_id_name_map(sdk, reverse=False):
"""
Generate the ID-NAME map dict
:param sdk: CloudGenix API constructor
:param reverse: Generate reverse name-> ID map as well, return tuple with both.
:return: ID Name dictionary
"""
global_id_name_dict = {}
global_name_id_dict = {}
#... | [
"def",
"generate_id_name_map",
"(",
"sdk",
",",
"reverse",
"=",
"False",
")",
":",
"global_id_name_dict",
"=",
"{",
"}",
"global_name_id_dict",
"=",
"{",
"}",
"# system struct",
"system_list",
"=",
"[",
"]",
"# Global lookup dictionary for sub items",
"if_id_to_name",... | Generate the ID-NAME map dict
:param sdk: CloudGenix API constructor
:param reverse: Generate reverse name-> ID map as well, return tuple with both.
:return: ID Name dictionary | [
"Generate",
"the",
"ID",
"-",
"NAME",
"map",
"dict",
":",
"param",
"sdk",
":",
"CloudGenix",
"API",
"constructor",
":",
"param",
"reverse",
":",
"Generate",
"reverse",
"name",
"-",
">",
"ID",
"map",
"as",
"well",
"return",
"tuple",
"with",
"both",
".",
... | train | https://github.com/ebob9/cloudgenix-idname/blob/f372eaa768dad0610a0f225015f34067416c2b4a/cloudgenix_idname/__init__.py#L386-L719 |
jaredLunde/vital-tools | vital/tools/dicts.py | revrank_dict | def revrank_dict(dict, key=lambda t: t[1], as_tuple=False):
""" Reverse sorts a #dict by a given key, optionally returning it as a
#tuple. By default, the @dict is sorted by it's value.
@dict: the #dict you wish to sorts
@key: the #sorted key to use
@as_tuple: returns result as a #t... | python | def revrank_dict(dict, key=lambda t: t[1], as_tuple=False):
""" Reverse sorts a #dict by a given key, optionally returning it as a
#tuple. By default, the @dict is sorted by it's value.
@dict: the #dict you wish to sorts
@key: the #sorted key to use
@as_tuple: returns result as a #t... | [
"def",
"revrank_dict",
"(",
"dict",
",",
"key",
"=",
"lambda",
"t",
":",
"t",
"[",
"1",
"]",
",",
"as_tuple",
"=",
"False",
")",
":",
"sorted_list",
"=",
"sorted",
"(",
"dict",
".",
"items",
"(",
")",
",",
"key",
"=",
"key",
",",
"reverse",
"=",
... | Reverse sorts a #dict by a given key, optionally returning it as a
#tuple. By default, the @dict is sorted by it's value.
@dict: the #dict you wish to sorts
@key: the #sorted key to use
@as_tuple: returns result as a #tuple ((k, v),...)
-> :class:OrderedDict or #tuple | [
"Reverse",
"sorts",
"a",
"#dict",
"by",
"a",
"given",
"key",
"optionally",
"returning",
"it",
"as",
"a",
"#tuple",
".",
"By",
"default",
"the",
"@dict",
"is",
"sorted",
"by",
"it",
"s",
"value",
"."
] | train | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/dicts.py#L31-L42 |
jaredLunde/vital-tools | vital/tools/dicts.py | rank_dict | def rank_dict(dict, key=lambda t: t[1], as_tuple=False):
""" Sorts a #dict by a given key, optionally returning it as a
#tuple. By default, the @dict is sorted by it's value.
@dict: the #dict you wish to sorts
@key: the #sorted key to use
@as_tuple: returns result as a #tuple ((k, v... | python | def rank_dict(dict, key=lambda t: t[1], as_tuple=False):
""" Sorts a #dict by a given key, optionally returning it as a
#tuple. By default, the @dict is sorted by it's value.
@dict: the #dict you wish to sorts
@key: the #sorted key to use
@as_tuple: returns result as a #tuple ((k, v... | [
"def",
"rank_dict",
"(",
"dict",
",",
"key",
"=",
"lambda",
"t",
":",
"t",
"[",
"1",
"]",
",",
"as_tuple",
"=",
"False",
")",
":",
"sorted_list",
"=",
"sorted",
"(",
"dict",
".",
"items",
"(",
")",
",",
"key",
"=",
"key",
")",
"return",
"OrderedD... | Sorts a #dict by a given key, optionally returning it as a
#tuple. By default, the @dict is sorted by it's value.
@dict: the #dict you wish to sorts
@key: the #sorted key to use
@as_tuple: returns result as a #tuple ((k, v),...)
-> :class:OrderedDict or #tuple | [
"Sorts",
"a",
"#dict",
"by",
"a",
"given",
"key",
"optionally",
"returning",
"it",
"as",
"a",
"#tuple",
".",
"By",
"default",
"the",
"@dict",
"is",
"sorted",
"by",
"it",
"s",
"value",
"."
] | train | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/dicts.py#L45-L56 |
jaredLunde/vital-tools | vital/tools/dicts.py | getitem_in | def getitem_in(obj, name):
""" Finds a key in @obj via a period-delimited string @name.
@obj: (#dict)
@name: (#str) |.|-separated keys to search @obj in
..
obj = {'foo': {'bar': {'baz': True}}}
getitem_in(obj, 'foo.bar.baz')
..
|True|
"""
for p... | python | def getitem_in(obj, name):
""" Finds a key in @obj via a period-delimited string @name.
@obj: (#dict)
@name: (#str) |.|-separated keys to search @obj in
..
obj = {'foo': {'bar': {'baz': True}}}
getitem_in(obj, 'foo.bar.baz')
..
|True|
"""
for p... | [
"def",
"getitem_in",
"(",
"obj",
",",
"name",
")",
":",
"for",
"part",
"in",
"name",
".",
"split",
"(",
"'.'",
")",
":",
"obj",
"=",
"obj",
"[",
"part",
"]",
"return",
"obj"
] | Finds a key in @obj via a period-delimited string @name.
@obj: (#dict)
@name: (#str) |.|-separated keys to search @obj in
..
obj = {'foo': {'bar': {'baz': True}}}
getitem_in(obj, 'foo.bar.baz')
..
|True| | [
"Finds",
"a",
"key",
"in"
] | train | https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/dicts.py#L59-L71 |
novopl/peltak | src/peltak/extra/gitflow/commands/release.py | start | def start(component, exact):
# type: (str) -> None
""" Create a new release.
It will bump the current version number and create a release branch called
`release/<version>` with one new commit (the version bump).
**Example Config**::
\b
version_file: 'src/mypkg/__init__.py'
**... | python | def start(component, exact):
# type: (str) -> None
""" Create a new release.
It will bump the current version number and create a release branch called
`release/<version>` with one new commit (the version bump).
**Example Config**::
\b
version_file: 'src/mypkg/__init__.py'
**... | [
"def",
"start",
"(",
"component",
",",
"exact",
")",
":",
"# type: (str) -> None",
"from",
"peltak",
".",
"extra",
".",
"gitflow",
"import",
"logic",
"logic",
".",
"release",
".",
"start",
"(",
"component",
",",
"exact",
")"
] | Create a new release.
It will bump the current version number and create a release branch called
`release/<version>` with one new commit (the version bump).
**Example Config**::
\b
version_file: 'src/mypkg/__init__.py'
**Examples**::
\b
$ peltak release start patch ... | [
"Create",
"a",
"new",
"release",
"."
] | train | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/commands/release.py#L59-L81 |
novopl/peltak | src/peltak/extra/gitflow/commands/release.py | tag_release | def tag_release(message):
# type: (str, bool) -> None
""" Tag the current commit with as the current version release.
This should be the same commit as the one that's uploaded as the release
(to pypi for example).
**Example Config**::
\b
version_file: 'src/mypkg/__init__.py'
... | python | def tag_release(message):
# type: (str, bool) -> None
""" Tag the current commit with as the current version release.
This should be the same commit as the one that's uploaded as the release
(to pypi for example).
**Example Config**::
\b
version_file: 'src/mypkg/__init__.py'
... | [
"def",
"tag_release",
"(",
"message",
")",
":",
"# type: (str, bool) -> None",
"from",
"peltak",
".",
"extra",
".",
"gitflow",
"import",
"logic",
"logic",
".",
"release",
".",
"tag",
"(",
"message",
")"
] | Tag the current commit with as the current version release.
This should be the same commit as the one that's uploaded as the release
(to pypi for example).
**Example Config**::
\b
version_file: 'src/mypkg/__init__.py'
Examples::
$ peltak release tag # Tag the curren... | [
"Tag",
"the",
"current",
"commit",
"with",
"as",
"the",
"current",
"version",
"release",
"."
] | train | https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/commands/release.py#L91-L109 |
Vital-Fernandez/dazer | working_examples/pyCloudy_heliumEmissivities.py | query_file_location | def query_file_location(question, default_address):
"""
This function asks for a location file address from the command terminal
it checks if the file exists before proceeding with the code
"question" is a string that is presented to the user.
"default_address" is the presumed file location.
""... | python | def query_file_location(question, default_address):
"""
This function asks for a location file address from the command terminal
it checks if the file exists before proceeding with the code
"question" is a string that is presented to the user.
"default_address" is the presumed file location.
""... | [
"def",
"query_file_location",
"(",
"question",
",",
"default_address",
")",
":",
"while",
"True",
":",
"if",
"default_address",
"==",
"None",
":",
"prompt",
"=",
"'{}:'",
".",
"format",
"(",
"question",
",",
"default_address",
")",
"else",
":",
"prompt",
"="... | This function asks for a location file address from the command terminal
it checks if the file exists before proceeding with the code
"question" is a string that is presented to the user.
"default_address" is the presumed file location. | [
"This",
"function",
"asks",
"for",
"a",
"location",
"file",
"address",
"from",
"the",
"command",
"terminal",
"it",
"checks",
"if",
"the",
"file",
"exists",
"before",
"proceeding",
"with",
"the",
"code",
"question",
"is",
"a",
"string",
"that",
"is",
"present... | train | https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/working_examples/pyCloudy_heliumEmissivities.py#L8-L30 |
Vital-Fernandez/dazer | working_examples/pyCloudy_heliumEmissivities.py | declare_output_files | def declare_output_files():
"""
This method establishes the output files from pycloudy grids
For these simulations in which we are only want to calculate the emissivities from the hydrogen and helium lines
most of the default files from pycloudy outputs are not required
:return:
"""
#Exclu... | python | def declare_output_files():
"""
This method establishes the output files from pycloudy grids
For these simulations in which we are only want to calculate the emissivities from the hydrogen and helium lines
most of the default files from pycloudy outputs are not required
:return:
"""
#Exclu... | [
"def",
"declare_output_files",
"(",
")",
":",
"#Exclude these files from being generated by the simulations",
"components_remove",
"=",
"[",
"#['radius', '.rad'],",
"#['continuum', '.cont'],",
"#['physical conditions', '.phy'],",
"[",
"'overview'",
",",
"'.ovr'",
"]",
",",
"[",
... | This method establishes the output files from pycloudy grids
For these simulations in which we are only want to calculate the emissivities from the hydrogen and helium lines
most of the default files from pycloudy outputs are not required
:return: | [
"This",
"method",
"establishes",
"the",
"output",
"files",
"from",
"pycloudy",
"grids",
"For",
"these",
"simulations",
"in",
"which",
"we",
"are",
"only",
"want",
"to",
"calculate",
"the",
"emissivities",
"from",
"the",
"hydrogen",
"and",
"helium",
"lines",
"m... | train | https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/working_examples/pyCloudy_heliumEmissivities.py#L85-L120 |
kajala/django-jutil | jutil/format.py | format_full_name | def format_full_name(first_name: str, last_name: str, max_length: int = 20):
"""
Limits name length to specified length. Tries to keep name as human-readable an natural as possible.
:param first_name: First name
:param last_name: Last name
:param max_length: Maximum length
:return: Full name of ... | python | def format_full_name(first_name: str, last_name: str, max_length: int = 20):
"""
Limits name length to specified length. Tries to keep name as human-readable an natural as possible.
:param first_name: First name
:param last_name: Last name
:param max_length: Maximum length
:return: Full name of ... | [
"def",
"format_full_name",
"(",
"first_name",
":",
"str",
",",
"last_name",
":",
"str",
",",
"max_length",
":",
"int",
"=",
"20",
")",
":",
"# dont allow commas in limited names",
"first_name",
"=",
"first_name",
".",
"replace",
"(",
"','",
",",
"' '",
")",
... | Limits name length to specified length. Tries to keep name as human-readable an natural as possible.
:param first_name: First name
:param last_name: Last name
:param max_length: Maximum length
:return: Full name of shortened version depending on length | [
"Limits",
"name",
"length",
"to",
"specified",
"length",
".",
"Tries",
"to",
"keep",
"name",
"as",
"human",
"-",
"readable",
"an",
"natural",
"as",
"possible",
".",
":",
"param",
"first_name",
":",
"First",
"name",
":",
"param",
"last_name",
":",
"Last",
... | train | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/format.py#L6-L47 |
kajala/django-jutil | jutil/format.py | format_timedelta | def format_timedelta(dt: timedelta) -> str:
"""
Formats timedelta to readable format, e.g. 1h30min.
:param dt: timedelta
:return: str
"""
seconds = int(dt.total_seconds())
days, remainder = divmod(seconds, 86400)
hours, remainder = divmod(remainder, 3600)
minutes, seconds = divmod(re... | python | def format_timedelta(dt: timedelta) -> str:
"""
Formats timedelta to readable format, e.g. 1h30min.
:param dt: timedelta
:return: str
"""
seconds = int(dt.total_seconds())
days, remainder = divmod(seconds, 86400)
hours, remainder = divmod(remainder, 3600)
minutes, seconds = divmod(re... | [
"def",
"format_timedelta",
"(",
"dt",
":",
"timedelta",
")",
"->",
"str",
":",
"seconds",
"=",
"int",
"(",
"dt",
".",
"total_seconds",
"(",
")",
")",
"days",
",",
"remainder",
"=",
"divmod",
"(",
"seconds",
",",
"86400",
")",
"hours",
",",
"remainder",... | Formats timedelta to readable format, e.g. 1h30min.
:param dt: timedelta
:return: str | [
"Formats",
"timedelta",
"to",
"readable",
"format",
"e",
".",
"g",
".",
"1h30min",
".",
":",
"param",
"dt",
":",
"timedelta",
":",
"return",
":",
"str"
] | train | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/format.py#L50-L69 |
kajala/django-jutil | jutil/format.py | format_xml | def format_xml(xml_str: str, exceptions: bool=False):
"""
Formats XML document as human-readable plain text.
:param xml_str: str (Input XML str)
:param exceptions: Raise exceptions on error
:return: str (Formatted XML str)
"""
try:
import xml.dom.minidom
return xml.dom.minido... | python | def format_xml(xml_str: str, exceptions: bool=False):
"""
Formats XML document as human-readable plain text.
:param xml_str: str (Input XML str)
:param exceptions: Raise exceptions on error
:return: str (Formatted XML str)
"""
try:
import xml.dom.minidom
return xml.dom.minido... | [
"def",
"format_xml",
"(",
"xml_str",
":",
"str",
",",
"exceptions",
":",
"bool",
"=",
"False",
")",
":",
"try",
":",
"import",
"xml",
".",
"dom",
".",
"minidom",
"return",
"xml",
".",
"dom",
".",
"minidom",
".",
"parseString",
"(",
"xml_str",
")",
".... | Formats XML document as human-readable plain text.
:param xml_str: str (Input XML str)
:param exceptions: Raise exceptions on error
:return: str (Formatted XML str) | [
"Formats",
"XML",
"document",
"as",
"human",
"-",
"readable",
"plain",
"text",
".",
":",
"param",
"xml_str",
":",
"str",
"(",
"Input",
"XML",
"str",
")",
":",
"param",
"exceptions",
":",
"Raise",
"exceptions",
"on",
"error",
":",
"return",
":",
"str",
... | train | https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/format.py#L72-L85 |
isogeo/isogeo-api-py-minsdk | isogeo_pysdk/samples/desktop_ttk_search_form/isogeo_tk_search_form_py3_async.py | IsogeoSearchForm.worker_allocator | def worker_allocator(self, async_loop, to_do, **kwargs):
""" Handler starting the asyncio part. """
d = kwargs
threading.Thread(
target=self._asyncio_thread, args=(async_loop, to_do, d)
).start() | python | def worker_allocator(self, async_loop, to_do, **kwargs):
""" Handler starting the asyncio part. """
d = kwargs
threading.Thread(
target=self._asyncio_thread, args=(async_loop, to_do, d)
).start() | [
"def",
"worker_allocator",
"(",
"self",
",",
"async_loop",
",",
"to_do",
",",
"*",
"*",
"kwargs",
")",
":",
"d",
"=",
"kwargs",
"threading",
".",
"Thread",
"(",
"target",
"=",
"self",
".",
"_asyncio_thread",
",",
"args",
"=",
"(",
"async_loop",
",",
"t... | Handler starting the asyncio part. | [
"Handler",
"starting",
"the",
"asyncio",
"part",
"."
] | train | https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/samples/desktop_ttk_search_form/isogeo_tk_search_form_py3_async.py#L266-L271 |
nathankw/pulsarpy | pulsarpy/utils.py | send_mail | def send_mail(form, from_name):
"""
Sends a mail using the configured mail server for Pulsar. See mailgun documentation at
https://documentation.mailgun.com/en/latest/user_manual.html#sending-via-api for specifics.
Args:
form: `dict`. The mail form fields, i.e. 'to', 'from', ...
Returns:... | python | def send_mail(form, from_name):
"""
Sends a mail using the configured mail server for Pulsar. See mailgun documentation at
https://documentation.mailgun.com/en/latest/user_manual.html#sending-via-api for specifics.
Args:
form: `dict`. The mail form fields, i.e. 'to', 'from', ...
Returns:... | [
"def",
"send_mail",
"(",
"form",
",",
"from_name",
")",
":",
"form",
"[",
"\"from\"",
"]",
"=",
"\"{} <mailgun@{}>\"",
".",
"format",
"(",
"from_name",
",",
"pulsarpy",
".",
"MAIL_DOMAIN",
")",
",",
"if",
"not",
"pulsarpy",
".",
"MAIL_SERVER_URL",
":",
"ra... | Sends a mail using the configured mail server for Pulsar. See mailgun documentation at
https://documentation.mailgun.com/en/latest/user_manual.html#sending-via-api for specifics.
Args:
form: `dict`. The mail form fields, i.e. 'to', 'from', ...
Returns:
`requests.models.Response` instanc... | [
"Sends",
"a",
"mail",
"using",
"the",
"configured",
"mail",
"server",
"for",
"Pulsar",
".",
"See",
"mailgun",
"documentation",
"at",
"https",
":",
"//",
"documentation",
".",
"mailgun",
".",
"com",
"/",
"en",
"/",
"latest",
"/",
"user_manual",
".",
"html#s... | train | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/utils.py#L15-L48 |
nathankw/pulsarpy | pulsarpy/utils.py | get_exp_of_biosample | def get_exp_of_biosample(biosample_rec):
"""
Determines whether the biosample is part of a ChipseqExperiment or SingleCellSorting
Experiment, and if so, returns the associated experiment as a models.Model instance that
is one of those two classes. The biosample is determined to be part of a ChipseqExper... | python | def get_exp_of_biosample(biosample_rec):
"""
Determines whether the biosample is part of a ChipseqExperiment or SingleCellSorting
Experiment, and if so, returns the associated experiment as a models.Model instance that
is one of those two classes. The biosample is determined to be part of a ChipseqExper... | [
"def",
"get_exp_of_biosample",
"(",
"biosample_rec",
")",
":",
"chip_exp_id",
"=",
"biosample_rec",
".",
"chipseq_experiment_id",
"ssc_id",
"=",
"biosample_rec",
".",
"sorting_biosample_single_cell_sorting_id",
"if",
"chip_exp_id",
":",
"return",
"{",
"\"type\"",
":",
"... | Determines whether the biosample is part of a ChipseqExperiment or SingleCellSorting
Experiment, and if so, returns the associated experiment as a models.Model instance that
is one of those two classes. The biosample is determined to be part of a ChipseqExperiment if the Biosample.chipseq_experiment_id
attr... | [
"Determines",
"whether",
"the",
"biosample",
"is",
"part",
"of",
"a",
"ChipseqExperiment",
"or",
"SingleCellSorting",
"Experiment",
"and",
"if",
"so",
"returns",
"the",
"associated",
"experiment",
"as",
"a",
"models",
".",
"Model",
"instance",
"that",
"is",
"one... | train | https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/utils.py#L57-L84 |
klmitch/cli_tools | cli_tools.py | _clean_text | def _clean_text(text):
"""
Clean up a multiple-line, potentially multiple-paragraph text
string. This is used to extract the first paragraph of a string
and eliminate line breaks and indentation. Lines will be joined
together by a single space.
:param text: The text string to clean up. It is... | python | def _clean_text(text):
"""
Clean up a multiple-line, potentially multiple-paragraph text
string. This is used to extract the first paragraph of a string
and eliminate line breaks and indentation. Lines will be joined
together by a single space.
:param text: The text string to clean up. It is... | [
"def",
"_clean_text",
"(",
"text",
")",
":",
"desc",
"=",
"[",
"]",
"for",
"line",
"in",
"(",
"text",
"or",
"''",
")",
".",
"strip",
"(",
")",
".",
"split",
"(",
"'\\n'",
")",
":",
"# Clean up the line...",
"line",
"=",
"line",
".",
"strip",
"(",
... | Clean up a multiple-line, potentially multiple-paragraph text
string. This is used to extract the first paragraph of a string
and eliminate line breaks and indentation. Lines will be joined
together by a single space.
:param text: The text string to clean up. It is safe to pass
``No... | [
"Clean",
"up",
"a",
"multiple",
"-",
"line",
"potentially",
"multiple",
"-",
"paragraph",
"text",
"string",
".",
"This",
"is",
"used",
"to",
"extract",
"the",
"first",
"paragraph",
"of",
"a",
"string",
"and",
"eliminate",
"line",
"breaks",
"and",
"indentatio... | train | https://github.com/klmitch/cli_tools/blob/3f9b5fd8d7458a402b3999618644ffa419d8a946/cli_tools.py#L28-L52 |
klmitch/cli_tools | cli_tools.py | prog | def prog(text):
"""
Decorator used to specify the program name for the console script
help message.
:param text: The text to use for the program name.
"""
def decorator(func):
adaptor = ScriptAdaptor._get_adaptor(func)
adaptor.prog = text
return func
return decorato... | python | def prog(text):
"""
Decorator used to specify the program name for the console script
help message.
:param text: The text to use for the program name.
"""
def decorator(func):
adaptor = ScriptAdaptor._get_adaptor(func)
adaptor.prog = text
return func
return decorato... | [
"def",
"prog",
"(",
"text",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"adaptor",
"=",
"ScriptAdaptor",
".",
"_get_adaptor",
"(",
"func",
")",
"adaptor",
".",
"prog",
"=",
"text",
"return",
"func",
"return",
"decorator"
] | Decorator used to specify the program name for the console script
help message.
:param text: The text to use for the program name. | [
"Decorator",
"used",
"to",
"specify",
"the",
"program",
"name",
"for",
"the",
"console",
"script",
"help",
"message",
"."
] | train | https://github.com/klmitch/cli_tools/blob/3f9b5fd8d7458a402b3999618644ffa419d8a946/cli_tools.py#L693-L705 |
klmitch/cli_tools | cli_tools.py | usage | def usage(text):
"""
Decorator used to specify a usage string for the console script
help message.
:param text: The text to use for the usage.
"""
def decorator(func):
adaptor = ScriptAdaptor._get_adaptor(func)
adaptor.usage = text
return func
return decorator | python | def usage(text):
"""
Decorator used to specify a usage string for the console script
help message.
:param text: The text to use for the usage.
"""
def decorator(func):
adaptor = ScriptAdaptor._get_adaptor(func)
adaptor.usage = text
return func
return decorator | [
"def",
"usage",
"(",
"text",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"adaptor",
"=",
"ScriptAdaptor",
".",
"_get_adaptor",
"(",
"func",
")",
"adaptor",
".",
"usage",
"=",
"text",
"return",
"func",
"return",
"decorator"
] | Decorator used to specify a usage string for the console script
help message.
:param text: The text to use for the usage. | [
"Decorator",
"used",
"to",
"specify",
"a",
"usage",
"string",
"for",
"the",
"console",
"script",
"help",
"message",
"."
] | train | https://github.com/klmitch/cli_tools/blob/3f9b5fd8d7458a402b3999618644ffa419d8a946/cli_tools.py#L708-L720 |
klmitch/cli_tools | cli_tools.py | description | def description(text):
"""
Decorator used to specify a short description of the console
script. This can be used to override the default, which is
derived from the docstring of the function.
:param text: The text to use for the description.
"""
def decorator(func):
adaptor = Scrip... | python | def description(text):
"""
Decorator used to specify a short description of the console
script. This can be used to override the default, which is
derived from the docstring of the function.
:param text: The text to use for the description.
"""
def decorator(func):
adaptor = Scrip... | [
"def",
"description",
"(",
"text",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"adaptor",
"=",
"ScriptAdaptor",
".",
"_get_adaptor",
"(",
"func",
")",
"adaptor",
".",
"description",
"=",
"text",
"return",
"func",
"return",
"decorator"
] | Decorator used to specify a short description of the console
script. This can be used to override the default, which is
derived from the docstring of the function.
:param text: The text to use for the description. | [
"Decorator",
"used",
"to",
"specify",
"a",
"short",
"description",
"of",
"the",
"console",
"script",
".",
"This",
"can",
"be",
"used",
"to",
"override",
"the",
"default",
"which",
"is",
"derived",
"from",
"the",
"docstring",
"of",
"the",
"function",
"."
] | train | https://github.com/klmitch/cli_tools/blob/3f9b5fd8d7458a402b3999618644ffa419d8a946/cli_tools.py#L723-L736 |
klmitch/cli_tools | cli_tools.py | epilog | def epilog(text):
"""
Decorator used to specify an epilog for the console script help
message.
:param text: The text to use for the epilog.
"""
def decorator(func):
adaptor = ScriptAdaptor._get_adaptor(func)
adaptor.epilog = text
return func
return decorator | python | def epilog(text):
"""
Decorator used to specify an epilog for the console script help
message.
:param text: The text to use for the epilog.
"""
def decorator(func):
adaptor = ScriptAdaptor._get_adaptor(func)
adaptor.epilog = text
return func
return decorator | [
"def",
"epilog",
"(",
"text",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"adaptor",
"=",
"ScriptAdaptor",
".",
"_get_adaptor",
"(",
"func",
")",
"adaptor",
".",
"epilog",
"=",
"text",
"return",
"func",
"return",
"decorator"
] | Decorator used to specify an epilog for the console script help
message.
:param text: The text to use for the epilog. | [
"Decorator",
"used",
"to",
"specify",
"an",
"epilog",
"for",
"the",
"console",
"script",
"help",
"message",
"."
] | train | https://github.com/klmitch/cli_tools/blob/3f9b5fd8d7458a402b3999618644ffa419d8a946/cli_tools.py#L739-L751 |
klmitch/cli_tools | cli_tools.py | formatter_class | def formatter_class(klass):
"""
Decorator used to specify the formatter class for the console
script.
:param klass: The formatter class to use.
"""
def decorator(func):
adaptor = ScriptAdaptor._get_adaptor(func)
adaptor.formatter_class = klass
return func
return dec... | python | def formatter_class(klass):
"""
Decorator used to specify the formatter class for the console
script.
:param klass: The formatter class to use.
"""
def decorator(func):
adaptor = ScriptAdaptor._get_adaptor(func)
adaptor.formatter_class = klass
return func
return dec... | [
"def",
"formatter_class",
"(",
"klass",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"adaptor",
"=",
"ScriptAdaptor",
".",
"_get_adaptor",
"(",
"func",
")",
"adaptor",
".",
"formatter_class",
"=",
"klass",
"return",
"func",
"return",
"decorator"
] | Decorator used to specify the formatter class for the console
script.
:param klass: The formatter class to use. | [
"Decorator",
"used",
"to",
"specify",
"the",
"formatter",
"class",
"for",
"the",
"console",
"script",
"."
] | train | https://github.com/klmitch/cli_tools/blob/3f9b5fd8d7458a402b3999618644ffa419d8a946/cli_tools.py#L754-L766 |
klmitch/cli_tools | cli_tools.py | argument | def argument(*args, **kwargs):
"""
Decorator used to specify an argument taken by the console script.
Positional and keyword arguments have the same meaning as those
given to ``argparse.ArgumentParser.add_argument()``.
"""
def decorator(func):
adaptor = ScriptAdaptor._get_adaptor(func)
... | python | def argument(*args, **kwargs):
"""
Decorator used to specify an argument taken by the console script.
Positional and keyword arguments have the same meaning as those
given to ``argparse.ArgumentParser.add_argument()``.
"""
def decorator(func):
adaptor = ScriptAdaptor._get_adaptor(func)
... | [
"def",
"argument",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"adaptor",
"=",
"ScriptAdaptor",
".",
"_get_adaptor",
"(",
"func",
")",
"group",
"=",
"kwargs",
".",
"pop",
"(",
"'group'",
",",
"None"... | Decorator used to specify an argument taken by the console script.
Positional and keyword arguments have the same meaning as those
given to ``argparse.ArgumentParser.add_argument()``. | [
"Decorator",
"used",
"to",
"specify",
"an",
"argument",
"taken",
"by",
"the",
"console",
"script",
".",
"Positional",
"and",
"keyword",
"arguments",
"have",
"the",
"same",
"meaning",
"as",
"those",
"given",
"to",
"argparse",
".",
"ArgumentParser",
".",
"add_ar... | train | https://github.com/klmitch/cli_tools/blob/3f9b5fd8d7458a402b3999618644ffa419d8a946/cli_tools.py#L769-L781 |
klmitch/cli_tools | cli_tools.py | argument_group | def argument_group(group, **kwargs):
"""
Decorator used to specify an argument group. Keyword arguments
have the same meaning as those given to
``argparse.ArgumentParser.add_argument_group()``.
Arguments may be placed in a given argument group by passing the
``group`` keyword argument to @argu... | python | def argument_group(group, **kwargs):
"""
Decorator used to specify an argument group. Keyword arguments
have the same meaning as those given to
``argparse.ArgumentParser.add_argument_group()``.
Arguments may be placed in a given argument group by passing the
``group`` keyword argument to @argu... | [
"def",
"argument_group",
"(",
"group",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"adaptor",
"=",
"ScriptAdaptor",
".",
"_get_adaptor",
"(",
"func",
")",
"adaptor",
".",
"_add_group",
"(",
"group",
",",
"'group'",
",",
... | Decorator used to specify an argument group. Keyword arguments
have the same meaning as those given to
``argparse.ArgumentParser.add_argument_group()``.
Arguments may be placed in a given argument group by passing the
``group`` keyword argument to @argument().
:param group: The name of the argume... | [
"Decorator",
"used",
"to",
"specify",
"an",
"argument",
"group",
".",
"Keyword",
"arguments",
"have",
"the",
"same",
"meaning",
"as",
"those",
"given",
"to",
"argparse",
".",
"ArgumentParser",
".",
"add_argument_group",
"()",
"."
] | train | https://github.com/klmitch/cli_tools/blob/3f9b5fd8d7458a402b3999618644ffa419d8a946/cli_tools.py#L784-L800 |
klmitch/cli_tools | cli_tools.py | subparsers | def subparsers(**kwargs):
"""
Decorator used to specify alternate keyword arguments to pass to
the ``argparse.ArgumentParser.add_subparsers()`` call.
"""
def decorator(func):
adaptor = ScriptAdaptor._get_adaptor(func)
adaptor.subkwargs = kwargs
adaptor.do_subs = True
... | python | def subparsers(**kwargs):
"""
Decorator used to specify alternate keyword arguments to pass to
the ``argparse.ArgumentParser.add_subparsers()`` call.
"""
def decorator(func):
adaptor = ScriptAdaptor._get_adaptor(func)
adaptor.subkwargs = kwargs
adaptor.do_subs = True
... | [
"def",
"subparsers",
"(",
"*",
"*",
"kwargs",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"adaptor",
"=",
"ScriptAdaptor",
".",
"_get_adaptor",
"(",
"func",
")",
"adaptor",
".",
"subkwargs",
"=",
"kwargs",
"adaptor",
".",
"do_subs",
"=",
"True",... | Decorator used to specify alternate keyword arguments to pass to
the ``argparse.ArgumentParser.add_subparsers()`` call. | [
"Decorator",
"used",
"to",
"specify",
"alternate",
"keyword",
"arguments",
"to",
"pass",
"to",
"the",
"argparse",
".",
"ArgumentParser",
".",
"add_subparsers",
"()",
"call",
"."
] | train | https://github.com/klmitch/cli_tools/blob/3f9b5fd8d7458a402b3999618644ffa419d8a946/cli_tools.py#L822-L833 |
klmitch/cli_tools | cli_tools.py | load_subcommands | def load_subcommands(group):
"""
Decorator used to load subcommands from a given ``pkg_resources``
entrypoint group. Each function must be appropriately decorated
with the ``cli_tools`` decorators to be considered an extension.
:param group: The name of the ``pkg_resources`` entrypoint group.
... | python | def load_subcommands(group):
"""
Decorator used to load subcommands from a given ``pkg_resources``
entrypoint group. Each function must be appropriately decorated
with the ``cli_tools`` decorators to be considered an extension.
:param group: The name of the ``pkg_resources`` entrypoint group.
... | [
"def",
"load_subcommands",
"(",
"group",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"adaptor",
"=",
"ScriptAdaptor",
".",
"_get_adaptor",
"(",
"func",
")",
"adaptor",
".",
"_add_extensions",
"(",
"group",
")",
"return",
"func",
"return",
"decorator... | Decorator used to load subcommands from a given ``pkg_resources``
entrypoint group. Each function must be appropriately decorated
with the ``cli_tools`` decorators to be considered an extension.
:param group: The name of the ``pkg_resources`` entrypoint group. | [
"Decorator",
"used",
"to",
"load",
"subcommands",
"from",
"a",
"given",
"pkg_resources",
"entrypoint",
"group",
".",
"Each",
"function",
"must",
"be",
"appropriately",
"decorated",
"with",
"the",
"cli_tools",
"decorators",
"to",
"be",
"considered",
"an",
"extensio... | train | https://github.com/klmitch/cli_tools/blob/3f9b5fd8d7458a402b3999618644ffa419d8a946/cli_tools.py#L836-L849 |
pmacosta/ptrie | ptrie/ptrie.py | Trie._collapse_subtree | def _collapse_subtree(self, name, recursive=True):
"""Collapse a sub-tree."""
oname = name
children = self._db[name]["children"]
data = self._db[name]["data"]
del_list = []
while (len(children) == 1) and (not data):
del_list.append(name)
name = chi... | python | def _collapse_subtree(self, name, recursive=True):
"""Collapse a sub-tree."""
oname = name
children = self._db[name]["children"]
data = self._db[name]["data"]
del_list = []
while (len(children) == 1) and (not data):
del_list.append(name)
name = chi... | [
"def",
"_collapse_subtree",
"(",
"self",
",",
"name",
",",
"recursive",
"=",
"True",
")",
":",
"oname",
"=",
"name",
"children",
"=",
"self",
".",
"_db",
"[",
"name",
"]",
"[",
"\"children\"",
"]",
"data",
"=",
"self",
".",
"_db",
"[",
"name",
"]",
... | Collapse a sub-tree. | [
"Collapse",
"a",
"sub",
"-",
"tree",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L127-L152 |
pmacosta/ptrie | ptrie/ptrie.py | Trie._create_intermediate_nodes | def _create_intermediate_nodes(self, name):
"""Create intermediate nodes if hierarchy does not exist."""
hierarchy = self._split_node_name(name, self.root_name)
node_tree = [
self.root_name
+ self._node_separator
+ self._node_separator.join(hierarchy[: num + 1... | python | def _create_intermediate_nodes(self, name):
"""Create intermediate nodes if hierarchy does not exist."""
hierarchy = self._split_node_name(name, self.root_name)
node_tree = [
self.root_name
+ self._node_separator
+ self._node_separator.join(hierarchy[: num + 1... | [
"def",
"_create_intermediate_nodes",
"(",
"self",
",",
"name",
")",
":",
"hierarchy",
"=",
"self",
".",
"_split_node_name",
"(",
"name",
",",
"self",
".",
"root_name",
")",
"node_tree",
"=",
"[",
"self",
".",
"root_name",
"+",
"self",
".",
"_node_separator",... | Create intermediate nodes if hierarchy does not exist. | [
"Create",
"intermediate",
"nodes",
"if",
"hierarchy",
"does",
"not",
"exist",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L154-L172 |
pmacosta/ptrie | ptrie/ptrie.py | Trie._create_node | def _create_node(self, name, parent, children, data):
"""Create new tree node."""
self._db[name] = {"parent": parent, "children": children, "data": data} | python | def _create_node(self, name, parent, children, data):
"""Create new tree node."""
self._db[name] = {"parent": parent, "children": children, "data": data} | [
"def",
"_create_node",
"(",
"self",
",",
"name",
",",
"parent",
",",
"children",
",",
"data",
")",
":",
"self",
".",
"_db",
"[",
"name",
"]",
"=",
"{",
"\"parent\"",
":",
"parent",
",",
"\"children\"",
":",
"children",
",",
"\"data\"",
":",
"data",
"... | Create new tree node. | [
"Create",
"new",
"tree",
"node",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L174-L176 |
pmacosta/ptrie | ptrie/ptrie.py | Trie._delete_subtree | def _delete_subtree(self, nodes):
"""
Delete subtree private method.
No argument validation and usage of getter/setter private methods is
used for speed
"""
nodes = nodes if isinstance(nodes, list) else [nodes]
iobj = [
(self._db[node]["parent"], node... | python | def _delete_subtree(self, nodes):
"""
Delete subtree private method.
No argument validation and usage of getter/setter private methods is
used for speed
"""
nodes = nodes if isinstance(nodes, list) else [nodes]
iobj = [
(self._db[node]["parent"], node... | [
"def",
"_delete_subtree",
"(",
"self",
",",
"nodes",
")",
":",
"nodes",
"=",
"nodes",
"if",
"isinstance",
"(",
"nodes",
",",
"list",
")",
"else",
"[",
"nodes",
"]",
"iobj",
"=",
"[",
"(",
"self",
".",
"_db",
"[",
"node",
"]",
"[",
"\"parent\"",
"]"... | Delete subtree private method.
No argument validation and usage of getter/setter private methods is
used for speed | [
"Delete",
"subtree",
"private",
"method",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L190-L213 |
pmacosta/ptrie | ptrie/ptrie.py | Trie._find_common_prefix | def _find_common_prefix(self, node1, node2):
"""Find common prefix between two nodes."""
tokens1 = [item.strip() for item in node1.split(self.node_separator)]
tokens2 = [item.strip() for item in node2.split(self.node_separator)]
ret = []
for token1, token2 in zip(tokens1, tokens2... | python | def _find_common_prefix(self, node1, node2):
"""Find common prefix between two nodes."""
tokens1 = [item.strip() for item in node1.split(self.node_separator)]
tokens2 = [item.strip() for item in node2.split(self.node_separator)]
ret = []
for token1, token2 in zip(tokens1, tokens2... | [
"def",
"_find_common_prefix",
"(",
"self",
",",
"node1",
",",
"node2",
")",
":",
"tokens1",
"=",
"[",
"item",
".",
"strip",
"(",
")",
"for",
"item",
"in",
"node1",
".",
"split",
"(",
"self",
".",
"node_separator",
")",
"]",
"tokens2",
"=",
"[",
"item... | Find common prefix between two nodes. | [
"Find",
"common",
"prefix",
"between",
"two",
"nodes",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L223-L233 |
pmacosta/ptrie | ptrie/ptrie.py | Trie._prt | def _prt(self, name, lparent, sep, pre1, pre2):
"""
Print a row (leaf) of tree.
:param name: Full node name
:type name: string
:param lparent: Position in full node name of last separator before
node to be printed
:type lparent: integer
... | python | def _prt(self, name, lparent, sep, pre1, pre2):
"""
Print a row (leaf) of tree.
:param name: Full node name
:type name: string
:param lparent: Position in full node name of last separator before
node to be printed
:type lparent: integer
... | [
"def",
"_prt",
"(",
"self",
",",
"name",
",",
"lparent",
",",
"sep",
",",
"pre1",
",",
"pre2",
")",
":",
"# pylint: disable=R0914",
"nname",
"=",
"name",
"[",
"lparent",
"+",
"1",
":",
"]",
"children",
"=",
"self",
".",
"_db",
"[",
"name",
"]",
"["... | Print a row (leaf) of tree.
:param name: Full node name
:type name: string
:param lparent: Position in full node name of last separator before
node to be printed
:type lparent: integer
:param pre1: Connector next to node name, either a null character ... | [
"Print",
"a",
"row",
"(",
"leaf",
")",
"of",
"tree",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L273-L308 |
pmacosta/ptrie | ptrie/ptrie.py | Trie._rename_node | def _rename_node(self, name, new_name):
"""
Rename node private method.
No argument validation and usage of getter/setter private methods is
used for speed
"""
# Update parent
if not self.is_root(name):
parent = self._db[name]["parent"]
se... | python | def _rename_node(self, name, new_name):
"""
Rename node private method.
No argument validation and usage of getter/setter private methods is
used for speed
"""
# Update parent
if not self.is_root(name):
parent = self._db[name]["parent"]
se... | [
"def",
"_rename_node",
"(",
"self",
",",
"name",
",",
"new_name",
")",
":",
"# Update parent",
"if",
"not",
"self",
".",
"is_root",
"(",
"name",
")",
":",
"parent",
"=",
"self",
".",
"_db",
"[",
"name",
"]",
"[",
"\"parent\"",
"]",
"self",
".",
"_db"... | Rename node private method.
No argument validation and usage of getter/setter private methods is
used for speed | [
"Rename",
"node",
"private",
"method",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L310-L346 |
pmacosta/ptrie | ptrie/ptrie.py | Trie._search_tree | def _search_tree(self, name):
"""Search_tree for nodes that contain a specific hierarchy name."""
tpl1 = "{sep}{name}{sep}".format(sep=self._node_separator, name=name)
tpl2 = "{sep}{name}".format(sep=self._node_separator, name=name)
tpl3 = "{name}{sep}".format(sep=self._node_separator, n... | python | def _search_tree(self, name):
"""Search_tree for nodes that contain a specific hierarchy name."""
tpl1 = "{sep}{name}{sep}".format(sep=self._node_separator, name=name)
tpl2 = "{sep}{name}".format(sep=self._node_separator, name=name)
tpl3 = "{name}{sep}".format(sep=self._node_separator, n... | [
"def",
"_search_tree",
"(",
"self",
",",
"name",
")",
":",
"tpl1",
"=",
"\"{sep}{name}{sep}\"",
".",
"format",
"(",
"sep",
"=",
"self",
".",
"_node_separator",
",",
"name",
"=",
"name",
")",
"tpl2",
"=",
"\"{sep}{name}\"",
".",
"format",
"(",
"sep",
"=",... | Search_tree for nodes that contain a specific hierarchy name. | [
"Search_tree",
"for",
"nodes",
"that",
"contain",
"a",
"specific",
"hierarchy",
"name",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L348-L362 |
pmacosta/ptrie | ptrie/ptrie.py | Trie._validate_node_name | def _validate_node_name(self, var_value):
"""Validate NodeName pseudo-type."""
# pylint: disable=R0201
var_values = var_value if isinstance(var_value, list) else [var_value]
for item in var_values:
if (not isinstance(item, str)) or (
isinstance(item, str)
... | python | def _validate_node_name(self, var_value):
"""Validate NodeName pseudo-type."""
# pylint: disable=R0201
var_values = var_value if isinstance(var_value, list) else [var_value]
for item in var_values:
if (not isinstance(item, str)) or (
isinstance(item, str)
... | [
"def",
"_validate_node_name",
"(",
"self",
",",
"var_value",
")",
":",
"# pylint: disable=R0201",
"var_values",
"=",
"var_value",
"if",
"isinstance",
"(",
"var_value",
",",
"list",
")",
"else",
"[",
"var_value",
"]",
"for",
"item",
"in",
"var_values",
":",
"if... | Validate NodeName pseudo-type. | [
"Validate",
"NodeName",
"pseudo",
"-",
"type",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L381-L399 |
pmacosta/ptrie | ptrie/ptrie.py | Trie._validate_nodes_with_data | def _validate_nodes_with_data(self, names):
"""Validate NodeWithData pseudo-type."""
names = names if isinstance(names, list) else [names]
if not names:
raise RuntimeError("Argument `nodes` is not valid")
for ndict in names:
if (not isinstance(ndict, dict)) or (
... | python | def _validate_nodes_with_data(self, names):
"""Validate NodeWithData pseudo-type."""
names = names if isinstance(names, list) else [names]
if not names:
raise RuntimeError("Argument `nodes` is not valid")
for ndict in names:
if (not isinstance(ndict, dict)) or (
... | [
"def",
"_validate_nodes_with_data",
"(",
"self",
",",
"names",
")",
":",
"names",
"=",
"names",
"if",
"isinstance",
"(",
"names",
",",
"list",
")",
"else",
"[",
"names",
"]",
"if",
"not",
"names",
":",
"raise",
"RuntimeError",
"(",
"\"Argument `nodes` is not... | Validate NodeWithData pseudo-type. | [
"Validate",
"NodeWithData",
"pseudo",
"-",
"type",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L401-L424 |
pmacosta/ptrie | ptrie/ptrie.py | Trie.add_nodes | def add_nodes(self, nodes): # noqa: D302
r"""
Add nodes to tree.
:param nodes: Node(s) to add with associated data. If there are
several list items in the argument with the same node
name the resulting node data is a list with items
... | python | def add_nodes(self, nodes): # noqa: D302
r"""
Add nodes to tree.
:param nodes: Node(s) to add with associated data. If there are
several list items in the argument with the same node
name the resulting node data is a list with items
... | [
"def",
"add_nodes",
"(",
"self",
",",
"nodes",
")",
":",
"# noqa: D302",
"self",
".",
"_validate_nodes_with_data",
"(",
"nodes",
")",
"nodes",
"=",
"nodes",
"if",
"isinstance",
"(",
"nodes",
",",
"list",
")",
"else",
"[",
"nodes",
"]",
"# Create root node (i... | r"""
Add nodes to tree.
:param nodes: Node(s) to add with associated data. If there are
several list items in the argument with the same node
name the resulting node data is a list with items
corresponding to the data of each entry in th... | [
"r",
"Add",
"nodes",
"to",
"tree",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L426-L508 |
pmacosta/ptrie | ptrie/ptrie.py | Trie.collapse_subtree | def collapse_subtree(self, name, recursive=True): # noqa: D302
r"""
Collapse a sub-tree.
Nodes that have a single child and no data are combined with their
child as a single tree node
:param name: Root of the sub-tree to collapse
:type name: :ref:`NodeName`
:... | python | def collapse_subtree(self, name, recursive=True): # noqa: D302
r"""
Collapse a sub-tree.
Nodes that have a single child and no data are combined with their
child as a single tree node
:param name: Root of the sub-tree to collapse
:type name: :ref:`NodeName`
:... | [
"def",
"collapse_subtree",
"(",
"self",
",",
"name",
",",
"recursive",
"=",
"True",
")",
":",
"# noqa: D302",
"if",
"self",
".",
"_validate_node_name",
"(",
"name",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Argument `name` is not valid\"",
")",
"if",
"not",
"... | r"""
Collapse a sub-tree.
Nodes that have a single child and no data are combined with their
child as a single tree node
:param name: Root of the sub-tree to collapse
:type name: :ref:`NodeName`
:param recursive: Flag that indicates whether the collapse operation
... | [
"r",
"Collapse",
"a",
"sub",
"-",
"tree",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L510-L567 |
pmacosta/ptrie | ptrie/ptrie.py | Trie.copy_subtree | def copy_subtree(self, source_node, dest_node): # noqa: D302
r"""
Copy a sub-tree from one sub-node to another.
Data is added if some nodes of the source sub-tree exist in the
destination sub-tree
:param source_name: Root node of the sub-tree to copy from
:type source... | python | def copy_subtree(self, source_node, dest_node): # noqa: D302
r"""
Copy a sub-tree from one sub-node to another.
Data is added if some nodes of the source sub-tree exist in the
destination sub-tree
:param source_name: Root node of the sub-tree to copy from
:type source... | [
"def",
"copy_subtree",
"(",
"self",
",",
"source_node",
",",
"dest_node",
")",
":",
"# noqa: D302",
"if",
"self",
".",
"_validate_node_name",
"(",
"source_node",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Argument `source_node` is not valid\"",
")",
"if",
"self",
... | r"""
Copy a sub-tree from one sub-node to another.
Data is added if some nodes of the source sub-tree exist in the
destination sub-tree
:param source_name: Root node of the sub-tree to copy from
:type source_name: :ref:`NodeName`
:param dest_name: Root node of the sub... | [
"r",
"Copy",
"a",
"sub",
"-",
"tree",
"from",
"one",
"sub",
"-",
"node",
"to",
"another",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L569-L642 |
pmacosta/ptrie | ptrie/ptrie.py | Trie.delete_prefix | def delete_prefix(self, name): # noqa: D302
r"""
Delete hierarchy levels from all nodes in the tree.
:param nodes: Prefix to delete
:type nodes: :ref:`NodeName`
:raises:
* RuntimeError (Argument \`name\` is not a valid prefix)
* RuntimeError (Argument \`nam... | python | def delete_prefix(self, name): # noqa: D302
r"""
Delete hierarchy levels from all nodes in the tree.
:param nodes: Prefix to delete
:type nodes: :ref:`NodeName`
:raises:
* RuntimeError (Argument \`name\` is not a valid prefix)
* RuntimeError (Argument \`nam... | [
"def",
"delete_prefix",
"(",
"self",
",",
"name",
")",
":",
"# noqa: D302",
"if",
"self",
".",
"_validate_node_name",
"(",
"name",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Argument `name` is not valid\"",
")",
"if",
"(",
"not",
"self",
".",
"root_name",
".",... | r"""
Delete hierarchy levels from all nodes in the tree.
:param nodes: Prefix to delete
:type nodes: :ref:`NodeName`
:raises:
* RuntimeError (Argument \`name\` is not a valid prefix)
* RuntimeError (Argument \`name\` is not valid)
For example:
... | [
"r",
"Delete",
"hierarchy",
"levels",
"from",
"all",
"nodes",
"in",
"the",
"tree",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L644-L692 |
pmacosta/ptrie | ptrie/ptrie.py | Trie.delete_subtree | def delete_subtree(self, nodes): # noqa: D302
r"""
Delete nodes (and their sub-trees) from the tree.
:param nodes: Node(s) to delete
:type nodes: :ref:`NodeName` or list of :ref:`NodeName`
:raises:
* RuntimeError (Argument \`nodes\` is not valid)
* RuntimeE... | python | def delete_subtree(self, nodes): # noqa: D302
r"""
Delete nodes (and their sub-trees) from the tree.
:param nodes: Node(s) to delete
:type nodes: :ref:`NodeName` or list of :ref:`NodeName`
:raises:
* RuntimeError (Argument \`nodes\` is not valid)
* RuntimeE... | [
"def",
"delete_subtree",
"(",
"self",
",",
"nodes",
")",
":",
"# noqa: D302",
"if",
"self",
".",
"_validate_node_name",
"(",
"nodes",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Argument `nodes` is not valid\"",
")",
"self",
".",
"_delete_subtree",
"(",
"nodes",
... | r"""
Delete nodes (and their sub-trees) from the tree.
:param nodes: Node(s) to delete
:type nodes: :ref:`NodeName` or list of :ref:`NodeName`
:raises:
* RuntimeError (Argument \`nodes\` is not valid)
* RuntimeError (Node *[node_name]* not in tree)
Using th... | [
"r",
"Delete",
"nodes",
"(",
"and",
"their",
"sub",
"-",
"trees",
")",
"from",
"the",
"tree",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L694-L729 |
pmacosta/ptrie | ptrie/ptrie.py | Trie.flatten_subtree | def flatten_subtree(self, name): # noqa: D302
r"""
Flatten sub-tree.
Nodes that have children and no data are merged with each child
:param name: Ending hierarchy node whose sub-trees are to be
flattened
:type name: :ref:`NodeName`
:raises:
... | python | def flatten_subtree(self, name): # noqa: D302
r"""
Flatten sub-tree.
Nodes that have children and no data are merged with each child
:param name: Ending hierarchy node whose sub-trees are to be
flattened
:type name: :ref:`NodeName`
:raises:
... | [
"def",
"flatten_subtree",
"(",
"self",
",",
"name",
")",
":",
"# noqa: D302",
"if",
"self",
".",
"_validate_node_name",
"(",
"name",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Argument `name` is not valid\"",
")",
"self",
".",
"_node_in_tree",
"(",
"name",
")",
... | r"""
Flatten sub-tree.
Nodes that have children and no data are merged with each child
:param name: Ending hierarchy node whose sub-trees are to be
flattened
:type name: :ref:`NodeName`
:raises:
* RuntimeError (Argument \`name\` is not valid)
... | [
"r",
"Flatten",
"sub",
"-",
"tree",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L731-L807 |
pmacosta/ptrie | ptrie/ptrie.py | Trie.get_children | def get_children(self, name):
r"""
Get the children node names of a node.
:param name: Parent node name
:type name: :ref:`NodeName`
:rtype: list of :ref:`NodeName`
:raises:
* RuntimeError (Argument \`name\` is not valid)
* RuntimeError (Node *[name]... | python | def get_children(self, name):
r"""
Get the children node names of a node.
:param name: Parent node name
:type name: :ref:`NodeName`
:rtype: list of :ref:`NodeName`
:raises:
* RuntimeError (Argument \`name\` is not valid)
* RuntimeError (Node *[name]... | [
"def",
"get_children",
"(",
"self",
",",
"name",
")",
":",
"if",
"self",
".",
"_validate_node_name",
"(",
"name",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Argument `name` is not valid\"",
")",
"self",
".",
"_node_in_tree",
"(",
"name",
")",
"return",
"sorted... | r"""
Get the children node names of a node.
:param name: Parent node name
:type name: :ref:`NodeName`
:rtype: list of :ref:`NodeName`
:raises:
* RuntimeError (Argument \`name\` is not valid)
* RuntimeError (Node *[name]* not in tree) | [
"r",
"Get",
"the",
"children",
"node",
"names",
"of",
"a",
"node",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L809-L826 |
pmacosta/ptrie | ptrie/ptrie.py | Trie.get_data | def get_data(self, name):
r"""
Get the data associated with a node.
:param name: Node name
:type name: :ref:`NodeName`
:rtype: any type or list of objects of any type
:raises:
* RuntimeError (Argument \`name\` is not valid)
* RuntimeError (Node *[na... | python | def get_data(self, name):
r"""
Get the data associated with a node.
:param name: Node name
:type name: :ref:`NodeName`
:rtype: any type or list of objects of any type
:raises:
* RuntimeError (Argument \`name\` is not valid)
* RuntimeError (Node *[na... | [
"def",
"get_data",
"(",
"self",
",",
"name",
")",
":",
"if",
"self",
".",
"_validate_node_name",
"(",
"name",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Argument `name` is not valid\"",
")",
"self",
".",
"_node_in_tree",
"(",
"name",
")",
"return",
"self",
"... | r"""
Get the data associated with a node.
:param name: Node name
:type name: :ref:`NodeName`
:rtype: any type or list of objects of any type
:raises:
* RuntimeError (Argument \`name\` is not valid)
* RuntimeError (Node *[name]* not in tree) | [
"r",
"Get",
"the",
"data",
"associated",
"with",
"a",
"node",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L828-L845 |
pmacosta/ptrie | ptrie/ptrie.py | Trie.get_leafs | def get_leafs(self, name):
r"""
Get the sub-tree leaf node(s).
:param name: Sub-tree root node name
:type name: :ref:`NodeName`
:rtype: list of :ref:`NodeName`
:raises:
* RuntimeError (Argument \`name\` is not valid)
* RuntimeError (Node *[name]* no... | python | def get_leafs(self, name):
r"""
Get the sub-tree leaf node(s).
:param name: Sub-tree root node name
:type name: :ref:`NodeName`
:rtype: list of :ref:`NodeName`
:raises:
* RuntimeError (Argument \`name\` is not valid)
* RuntimeError (Node *[name]* no... | [
"def",
"get_leafs",
"(",
"self",
",",
"name",
")",
":",
"if",
"self",
".",
"_validate_node_name",
"(",
"name",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Argument `name` is not valid\"",
")",
"self",
".",
"_node_in_tree",
"(",
"name",
")",
"return",
"[",
"no... | r"""
Get the sub-tree leaf node(s).
:param name: Sub-tree root node name
:type name: :ref:`NodeName`
:rtype: list of :ref:`NodeName`
:raises:
* RuntimeError (Argument \`name\` is not valid)
* RuntimeError (Node *[name]* not in tree) | [
"r",
"Get",
"the",
"sub",
"-",
"tree",
"leaf",
"node",
"(",
"s",
")",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L847-L864 |
pmacosta/ptrie | ptrie/ptrie.py | Trie.get_node | def get_node(self, name):
r"""
Get a tree node structure.
The structure is a dictionary with the following keys:
* **parent** (*NodeName*) Parent node name, :code:`''` if the
node is the root node
* **children** (*list of NodeName*) Children node names, an
... | python | def get_node(self, name):
r"""
Get a tree node structure.
The structure is a dictionary with the following keys:
* **parent** (*NodeName*) Parent node name, :code:`''` if the
node is the root node
* **children** (*list of NodeName*) Children node names, an
... | [
"def",
"get_node",
"(",
"self",
",",
"name",
")",
":",
"if",
"self",
".",
"_validate_node_name",
"(",
"name",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Argument `name` is not valid\"",
")",
"self",
".",
"_node_in_tree",
"(",
"name",
")",
"return",
"self",
"... | r"""
Get a tree node structure.
The structure is a dictionary with the following keys:
* **parent** (*NodeName*) Parent node name, :code:`''` if the
node is the root node
* **children** (*list of NodeName*) Children node names, an
empty list if node is a leaf
... | [
"r",
"Get",
"a",
"tree",
"node",
"structure",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L866-L893 |
pmacosta/ptrie | ptrie/ptrie.py | Trie.get_node_children | def get_node_children(self, name):
r"""
Get the list of children structures of a node.
See :py:meth:`ptrie.Trie.get_node` for details about the structure
:param name: Parent node name
:type name: :ref:`NodeName`
:rtype: list
:raises:
* RuntimeError (... | python | def get_node_children(self, name):
r"""
Get the list of children structures of a node.
See :py:meth:`ptrie.Trie.get_node` for details about the structure
:param name: Parent node name
:type name: :ref:`NodeName`
:rtype: list
:raises:
* RuntimeError (... | [
"def",
"get_node_children",
"(",
"self",
",",
"name",
")",
":",
"if",
"self",
".",
"_validate_node_name",
"(",
"name",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Argument `name` is not valid\"",
")",
"self",
".",
"_node_in_tree",
"(",
"name",
")",
"return",
"[... | r"""
Get the list of children structures of a node.
See :py:meth:`ptrie.Trie.get_node` for details about the structure
:param name: Parent node name
:type name: :ref:`NodeName`
:rtype: list
:raises:
* RuntimeError (Argument \`name\` is not valid)
*... | [
"r",
"Get",
"the",
"list",
"of",
"children",
"structures",
"of",
"a",
"node",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L895-L914 |
pmacosta/ptrie | ptrie/ptrie.py | Trie.get_node_parent | def get_node_parent(self, name):
r"""
Get the parent structure of a node.
See :py:meth:`ptrie.Trie.get_node` for details about the structure
:param name: Child node name
:type name: :ref:`NodeName`
:rtype: dictionary
:raises:
* RuntimeError (Argument... | python | def get_node_parent(self, name):
r"""
Get the parent structure of a node.
See :py:meth:`ptrie.Trie.get_node` for details about the structure
:param name: Child node name
:type name: :ref:`NodeName`
:rtype: dictionary
:raises:
* RuntimeError (Argument... | [
"def",
"get_node_parent",
"(",
"self",
",",
"name",
")",
":",
"if",
"self",
".",
"_validate_node_name",
"(",
"name",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Argument `name` is not valid\"",
")",
"self",
".",
"_node_in_tree",
"(",
"name",
")",
"return",
"sel... | r"""
Get the parent structure of a node.
See :py:meth:`ptrie.Trie.get_node` for details about the structure
:param name: Child node name
:type name: :ref:`NodeName`
:rtype: dictionary
:raises:
* RuntimeError (Argument \`name\` is not valid)
* Runti... | [
"r",
"Get",
"the",
"parent",
"structure",
"of",
"a",
"node",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L916-L935 |
pmacosta/ptrie | ptrie/ptrie.py | Trie.get_subtree | def get_subtree(self, name): # noqa: D302
r"""
Get all node names in a sub-tree.
:param name: Sub-tree root node name
:type name: :ref:`NodeName`
:rtype: list of :ref:`NodeName`
:raises:
* RuntimeError (Argument \`name\` is not valid)
* RuntimeErro... | python | def get_subtree(self, name): # noqa: D302
r"""
Get all node names in a sub-tree.
:param name: Sub-tree root node name
:type name: :ref:`NodeName`
:rtype: list of :ref:`NodeName`
:raises:
* RuntimeError (Argument \`name\` is not valid)
* RuntimeErro... | [
"def",
"get_subtree",
"(",
"self",
",",
"name",
")",
":",
"# noqa: D302",
"if",
"self",
".",
"_validate_node_name",
"(",
"name",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Argument `name` is not valid\"",
")",
"self",
".",
"_node_in_tree",
"(",
"name",
")",
"r... | r"""
Get all node names in a sub-tree.
:param name: Sub-tree root node name
:type name: :ref:`NodeName`
:rtype: list of :ref:`NodeName`
:raises:
* RuntimeError (Argument \`name\` is not valid)
* RuntimeError (Node *[name]* not in tree)
Using the sa... | [
"r",
"Get",
"all",
"node",
"names",
"in",
"a",
"sub",
"-",
"tree",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L937-L975 |
pmacosta/ptrie | ptrie/ptrie.py | Trie.in_tree | def in_tree(self, name):
r"""
Test if a node is in the tree.
:param name: Node name to search for
:type name: :ref:`NodeName`
:rtype: boolean
:raises: RuntimeError (Argument \`name\` is not valid)
"""
if self._validate_node_name(name):
rais... | python | def in_tree(self, name):
r"""
Test if a node is in the tree.
:param name: Node name to search for
:type name: :ref:`NodeName`
:rtype: boolean
:raises: RuntimeError (Argument \`name\` is not valid)
"""
if self._validate_node_name(name):
rais... | [
"def",
"in_tree",
"(",
"self",
",",
"name",
")",
":",
"if",
"self",
".",
"_validate_node_name",
"(",
"name",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Argument `name` is not valid\"",
")",
"return",
"name",
"in",
"self",
".",
"_db"
] | r"""
Test if a node is in the tree.
:param name: Node name to search for
:type name: :ref:`NodeName`
:rtype: boolean
:raises: RuntimeError (Argument \`name\` is not valid) | [
"r",
"Test",
"if",
"a",
"node",
"is",
"in",
"the",
"tree",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L996-L1009 |
pmacosta/ptrie | ptrie/ptrie.py | Trie.is_leaf | def is_leaf(self, name):
r"""
Test if a node is a leaf node (node with no children).
:param name: Node name
:type name: :ref:`NodeName`
:rtype: boolean
:raises:
* RuntimeError (Argument \`name\` is not valid)
* RuntimeError (Node *[name]* not in tre... | python | def is_leaf(self, name):
r"""
Test if a node is a leaf node (node with no children).
:param name: Node name
:type name: :ref:`NodeName`
:rtype: boolean
:raises:
* RuntimeError (Argument \`name\` is not valid)
* RuntimeError (Node *[name]* not in tre... | [
"def",
"is_leaf",
"(",
"self",
",",
"name",
")",
":",
"if",
"self",
".",
"_validate_node_name",
"(",
"name",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Argument `name` is not valid\"",
")",
"self",
".",
"_node_in_tree",
"(",
"name",
")",
"return",
"not",
"se... | r"""
Test if a node is a leaf node (node with no children).
:param name: Node name
:type name: :ref:`NodeName`
:rtype: boolean
:raises:
* RuntimeError (Argument \`name\` is not valid)
* RuntimeError (Node *[name]* not in tree) | [
"r",
"Test",
"if",
"a",
"node",
"is",
"a",
"leaf",
"node",
"(",
"node",
"with",
"no",
"children",
")",
"."
] | train | https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L1011-L1028 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.