repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
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" ]
f004ab3a35c5bff2f698131fef3b2a8ed5a7596d
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L638-L665
train
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" ]
f004ab3a35c5bff2f698131fef3b2a8ed5a7596d
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/deployment.py#L667-L701
train
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" ]
2abd93ebad51042744eaeb1ee1074ed0eb55ad0c
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/auth.py#L7-L18
train
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" ]
27407a6ed6bfd07d1eba2824398c77e2fe98f968
https://github.com/mozilla/libnfldap/blob/27407a6ed6bfd07d1eba2824398c77e2fe98f968/libnfldap.py#L92-L100
train
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" ]
27407a6ed6bfd07d1eba2824398c77e2fe98f968
https://github.com/mozilla/libnfldap/blob/27407a6ed6bfd07d1eba2824398c77e2fe98f968/libnfldap.py#L102-L107
train
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" ]
27407a6ed6bfd07d1eba2824398c77e2fe98f968
https://github.com/mozilla/libnfldap/blob/27407a6ed6bfd07d1eba2824398c77e2fe98f968/libnfldap.py#L155-L162
train
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" ]
27407a6ed6bfd07d1eba2824398c77e2fe98f968
https://github.com/mozilla/libnfldap/blob/27407a6ed6bfd07d1eba2824398c77e2fe98f968/libnfldap.py#L210-L214
train
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" ]
27407a6ed6bfd07d1eba2824398c77e2fe98f968
https://github.com/mozilla/libnfldap/blob/27407a6ed6bfd07d1eba2824398c77e2fe98f968/libnfldap.py#L228-L230
train
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" ]
27407a6ed6bfd07d1eba2824398c77e2fe98f968
https://github.com/mozilla/libnfldap/blob/27407a6ed6bfd07d1eba2824398c77e2fe98f968/libnfldap.py#L232-L237
train
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" ]
27407a6ed6bfd07d1eba2824398c77e2fe98f968
https://github.com/mozilla/libnfldap/blob/27407a6ed6bfd07d1eba2824398c77e2fe98f968/libnfldap.py#L239-L262
train
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", ")", "." ]
058aa6eceeff28c4ae402f6f58c58720bff0298e
https://github.com/InformaticsMatters/pipelines-utils/blob/058aa6eceeff28c4ae402f6f58c58720bff0298e/src/python/pipelines_utils/parameter_utils.py#L49-L56
train
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", "." ]
058aa6eceeff28c4ae402f6f58c58720bff0298e
https://github.com/InformaticsMatters/pipelines-utils/blob/058aa6eceeff28c4ae402f6f58c58720bff0298e/src/python/pipelines_utils/parameter_utils.py#L59-L73
train
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", ...
058aa6eceeff28c4ae402f6f58c58720bff0298e
https://github.com/InformaticsMatters/pipelines-utils/blob/058aa6eceeff28c4ae402f6f58c58720bff0298e/src/python/pipelines_utils/parameter_utils.py#L76-L88
train
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", "." ]
2abd93ebad51042744eaeb1ee1074ed0eb55ad0c
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/request.py#L8-L36
train
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", ...
2abd93ebad51042744eaeb1ee1074ed0eb55ad0c
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/request.py#L39-L61
train
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" ]
f004ab3a35c5bff2f698131fef3b2a8ed5a7596d
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/metadata.py#L44-L79
train
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" ]
f004ab3a35c5bff2f698131fef3b2a8ed5a7596d
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/metadata.py#L82-L110
train
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" ]
f004ab3a35c5bff2f698131fef3b2a8ed5a7596d
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/metadata.py#L113-L151
train
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" ]
f004ab3a35c5bff2f698131fef3b2a8ed5a7596d
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/metadata.py#L195-L222
train
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" ]
f004ab3a35c5bff2f698131fef3b2a8ed5a7596d
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/metadata.py#L225-L242
train
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" ]
f004ab3a35c5bff2f698131fef3b2a8ed5a7596d
https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/metadata.py#L245-L261
train
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", "." ]
a9596f660a11d275bf0e831ecd9e502b0af2a087
https://github.com/MarcAureleCoste/sqla-filters/blob/a9596f660a11d275bf0e831ecd9e502b0af2a087/src/sqla_filters/parser/base/base_sqla_parser.py#L23-L29
train
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",...
2abd93ebad51042744eaeb1ee1074ed0eb55ad0c
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/urls.py#L1-L14
train
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...
2abd93ebad51042744eaeb1ee1074ed0eb55ad0c
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/urls.py#L17-L35
train
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" ]
2abd93ebad51042744eaeb1ee1074ed0eb55ad0c
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/urls.py#L38-L46
train
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" ]
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/CodeTools/various.py#L75-L77
train
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" ]
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/CodeTools/various.py#L80-L82
train
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", "." ]
b627acc019e3665875fe76cdca0a14773b69beaa
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/logic/docs.py#L32-L89
train
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", "." ]
b627acc019e3665875fe76cdca0a14773b69beaa
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/logic/docs.py#L92-L146
train
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", ".", ...
f372eaa768dad0610a0f225015f34067416c2b4a
https://github.com/ebob9/cloudgenix-idname/blob/f372eaa768dad0610a0f225015f34067416c2b4a/cloudgenix_idname/__init__.py#L386-L719
train
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", "." ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/dicts.py#L31-L42
train
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", "." ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/dicts.py#L45-L56
train
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" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/dicts.py#L59-L71
train
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", "." ]
b627acc019e3665875fe76cdca0a14773b69beaa
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/commands/release.py#L59-L81
train
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", "." ]
b627acc019e3665875fe76cdca0a14773b69beaa
https://github.com/novopl/peltak/blob/b627acc019e3665875fe76cdca0a14773b69beaa/src/peltak/extra/gitflow/commands/release.py#L91-L109
train
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...
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/working_examples/pyCloudy_heliumEmissivities.py#L8-L30
train
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...
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/working_examples/pyCloudy_heliumEmissivities.py#L85-L120
train
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", ...
2abd93ebad51042744eaeb1ee1074ed0eb55ad0c
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/format.py#L6-L47
train
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" ]
2abd93ebad51042744eaeb1ee1074ed0eb55ad0c
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/format.py#L50-L69
train
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", ...
2abd93ebad51042744eaeb1ee1074ed0eb55ad0c
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/format.py#L72-L85
train
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", "." ]
57a604be92c7767b26abd247012cc1a584b386a0
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
train
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...
359b040c0f2383b88c0b5548715fefd35f5f634c
https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/utils.py#L15-L48
train
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...
359b040c0f2383b88c0b5548715fefd35f5f634c
https://github.com/nathankw/pulsarpy/blob/359b040c0f2383b88c0b5548715fefd35f5f634c/pulsarpy/utils.py#L57-L84
train
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...
3f9b5fd8d7458a402b3999618644ffa419d8a946
https://github.com/klmitch/cli_tools/blob/3f9b5fd8d7458a402b3999618644ffa419d8a946/cli_tools.py#L28-L52
train
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", "." ]
3f9b5fd8d7458a402b3999618644ffa419d8a946
https://github.com/klmitch/cli_tools/blob/3f9b5fd8d7458a402b3999618644ffa419d8a946/cli_tools.py#L693-L705
train
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", "." ]
3f9b5fd8d7458a402b3999618644ffa419d8a946
https://github.com/klmitch/cli_tools/blob/3f9b5fd8d7458a402b3999618644ffa419d8a946/cli_tools.py#L708-L720
train
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", "." ]
3f9b5fd8d7458a402b3999618644ffa419d8a946
https://github.com/klmitch/cli_tools/blob/3f9b5fd8d7458a402b3999618644ffa419d8a946/cli_tools.py#L723-L736
train
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", "." ]
3f9b5fd8d7458a402b3999618644ffa419d8a946
https://github.com/klmitch/cli_tools/blob/3f9b5fd8d7458a402b3999618644ffa419d8a946/cli_tools.py#L739-L751
train
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", "." ]
3f9b5fd8d7458a402b3999618644ffa419d8a946
https://github.com/klmitch/cli_tools/blob/3f9b5fd8d7458a402b3999618644ffa419d8a946/cli_tools.py#L754-L766
train
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...
3f9b5fd8d7458a402b3999618644ffa419d8a946
https://github.com/klmitch/cli_tools/blob/3f9b5fd8d7458a402b3999618644ffa419d8a946/cli_tools.py#L769-L781
train
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", "()", "." ]
3f9b5fd8d7458a402b3999618644ffa419d8a946
https://github.com/klmitch/cli_tools/blob/3f9b5fd8d7458a402b3999618644ffa419d8a946/cli_tools.py#L784-L800
train
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", "." ]
3f9b5fd8d7458a402b3999618644ffa419d8a946
https://github.com/klmitch/cli_tools/blob/3f9b5fd8d7458a402b3999618644ffa419d8a946/cli_tools.py#L822-L833
train
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...
3f9b5fd8d7458a402b3999618644ffa419d8a946
https://github.com/klmitch/cli_tools/blob/3f9b5fd8d7458a402b3999618644ffa419d8a946/cli_tools.py#L836-L849
train
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", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L127-L152
train
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", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L154-L172
train
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", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L174-L176
train
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", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L190-L213
train
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", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L223-L233
train
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", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L273-L308
train
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", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L310-L346
train
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", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L348-L362
train
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", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L381-L399
train
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", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L401-L424
train
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", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L426-L508
train
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", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L510-L567
train
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", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L569-L642
train
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", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L644-L692
train
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", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L694-L729
train
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", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L731-L807
train
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", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L809-L826
train
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", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L828-L845
train
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", ")", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L847-L864
train
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", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L866-L893
train
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", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L895-L914
train
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", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L916-L935
train
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", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L937-L975
train
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", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L996-L1009
train
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", ")", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L1011-L1028
train
pmacosta/ptrie
ptrie/ptrie.py
Trie.make_root
def make_root(self, name): # noqa: D302 r""" Make a sub-node the root node of the tree. All nodes not belonging to the sub-tree are deleted :param name: New root node name :type name: :ref:`NodeName` :raises: * RuntimeError (Argument \`name\` is not valid) ...
python
def make_root(self, name): # noqa: D302 r""" Make a sub-node the root node of the tree. All nodes not belonging to the sub-tree are deleted :param name: New root node name :type name: :ref:`NodeName` :raises: * RuntimeError (Argument \`name\` is not valid) ...
[ "def", "make_root", "(", "self", ",", "name", ")", ":", "# noqa: D302", "if", "self", ".", "_validate_node_name", "(", "name", ")", ":", "raise", "RuntimeError", "(", "\"Argument `name` is not valid\"", ")", "if", "(", "name", "!=", "self", ".", "root_name", ...
r""" Make a sub-node the root node of the tree. All nodes not belonging to the sub-tree are deleted :param name: New root node name :type name: :ref:`NodeName` :raises: * RuntimeError (Argument \`name\` is not valid) * RuntimeError (Node *[name]* not in tre...
[ "r", "Make", "a", "sub", "-", "node", "the", "root", "node", "of", "the", "tree", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L1030-L1075
train
pmacosta/ptrie
ptrie/ptrie.py
Trie.print_node
def print_node(self, name): # noqa: D302 r""" Print node information (parent, children and data). :param name: Node name :type name: :ref:`NodeName` :raises: * RuntimeError (Argument \`name\` is not valid) * RuntimeError (Node *[name]* not in tree) ...
python
def print_node(self, name): # noqa: D302 r""" Print node information (parent, children and data). :param name: Node name :type name: :ref:`NodeName` :raises: * RuntimeError (Argument \`name\` is not valid) * RuntimeError (Node *[name]* not in tree) ...
[ "def", "print_node", "(", "self", ",", "name", ")", ":", "# noqa: D302", "if", "self", ".", "_validate_node_name", "(", "name", ")", ":", "raise", "RuntimeError", "(", "\"Argument `name` is not valid\"", ")", "self", ".", "_node_in_tree", "(", "name", ")", "no...
r""" Print node information (parent, children and data). :param name: Node name :type name: :ref:`NodeName` :raises: * RuntimeError (Argument \`name\` is not valid) * RuntimeError (Node *[name]* not in tree) Using the same example tree created in :p...
[ "r", "Print", "node", "information", "(", "parent", "children", "and", "data", ")", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L1077-L1133
train
pmacosta/ptrie
ptrie/ptrie.py
Trie.rename_node
def rename_node(self, name, new_name): # noqa: D302 r""" Rename a tree node. It is typical to have a root node name with more than one hierarchy level after using :py:meth:`ptrie.Trie.make_root`. In this instance the root node *can* be renamed as long as the new root name has t...
python
def rename_node(self, name, new_name): # noqa: D302 r""" Rename a tree node. It is typical to have a root node name with more than one hierarchy level after using :py:meth:`ptrie.Trie.make_root`. In this instance the root node *can* be renamed as long as the new root name has t...
[ "def", "rename_node", "(", "self", ",", "name", ",", "new_name", ")", ":", "# noqa: D302", "if", "self", ".", "_validate_node_name", "(", "name", ")", ":", "raise", "RuntimeError", "(", "\"Argument `name` is not valid\"", ")", "if", "self", ".", "_validate_node_...
r""" Rename a tree node. It is typical to have a root node name with more than one hierarchy level after using :py:meth:`ptrie.Trie.make_root`. In this instance the root node *can* be renamed as long as the new root name has the same or less hierarchy levels as the existing root...
[ "r", "Rename", "a", "tree", "node", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L1135-L1203
train
pmacosta/ptrie
ptrie/ptrie.py
Trie.search_tree
def search_tree(self, name): # noqa: D302 r""" Search tree for all nodes with a specific name. :param name: Node name to search for :type name: :ref:`NodeName` :raises: RuntimeError (Argument \`name\` is not valid) For example: >>> from __future__ import...
python
def search_tree(self, name): # noqa: D302 r""" Search tree for all nodes with a specific name. :param name: Node name to search for :type name: :ref:`NodeName` :raises: RuntimeError (Argument \`name\` is not valid) For example: >>> from __future__ import...
[ "def", "search_tree", "(", "self", ",", "name", ")", ":", "# noqa: D302", "if", "self", ".", "_validate_node_name", "(", "name", ")", ":", "raise", "RuntimeError", "(", "\"Argument `name` is not valid\"", ")", "return", "self", ".", "_search_tree", "(", "name", ...
r""" Search tree for all nodes with a specific name. :param name: Node name to search for :type name: :ref:`NodeName` :raises: RuntimeError (Argument \`name\` is not valid) For example: >>> from __future__ import print_function >>> import pprint, ptri...
[ "r", "Search", "tree", "for", "all", "nodes", "with", "a", "specific", "name", "." ]
c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L1205-L1243
train
gpiantoni/bidso
bidso/find.py
find_root
def find_root(filename, target='bids'): """Find base directory (root) for a filename. Parameters ---------- filename : instance of Path search the root for this file target: str 'bids' (the directory containing 'participants.tsv'), 'subject' (the directory starting with 'sub...
python
def find_root(filename, target='bids'): """Find base directory (root) for a filename. Parameters ---------- filename : instance of Path search the root for this file target: str 'bids' (the directory containing 'participants.tsv'), 'subject' (the directory starting with 'sub...
[ "def", "find_root", "(", "filename", ",", "target", "=", "'bids'", ")", ":", "lg", ".", "debug", "(", "f'Searching root in {filename}'", ")", "if", "target", "==", "'bids'", "and", "(", "filename", "/", "'dataset_description.json'", ")", ".", "exists", "(", ...
Find base directory (root) for a filename. Parameters ---------- filename : instance of Path search the root for this file target: str 'bids' (the directory containing 'participants.tsv'), 'subject' (the directory starting with 'sub-'), 'session' (the directory starting with ...
[ "Find", "base", "directory", "(", "root", ")", "for", "a", "filename", "." ]
af163b921ec4e3d70802de07f174de184491cfce
https://github.com/gpiantoni/bidso/blob/af163b921ec4e3d70802de07f174de184491cfce/bidso/find.py#L8-L33
train
gpiantoni/bidso
bidso/find.py
find_in_bids
def find_in_bids(filename, pattern=None, generator=False, upwards=False, wildcard=True, **kwargs): """Find nearest file matching some criteria. Parameters ---------- filename : instance of Path search the root for this file pattern : str glob string for search crite...
python
def find_in_bids(filename, pattern=None, generator=False, upwards=False, wildcard=True, **kwargs): """Find nearest file matching some criteria. Parameters ---------- filename : instance of Path search the root for this file pattern : str glob string for search crite...
[ "def", "find_in_bids", "(", "filename", ",", "pattern", "=", "None", ",", "generator", "=", "False", ",", "upwards", "=", "False", ",", "wildcard", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "upwards", "and", "generator", ":", "raise", "Valu...
Find nearest file matching some criteria. Parameters ---------- filename : instance of Path search the root for this file pattern : str glob string for search criteria of the filename of interest (remember to include '*'). The pattern is passed directly to rglob. wildcard : ...
[ "Find", "nearest", "file", "matching", "some", "criteria", "." ]
af163b921ec4e3d70802de07f174de184491cfce
https://github.com/gpiantoni/bidso/blob/af163b921ec4e3d70802de07f174de184491cfce/bidso/find.py#L36-L86
train
Vital-Fernandez/dazer
bin/lib/Plotting_Libraries/dazer_plotter.py
Fig_Conf.define_format
def define_format(self, plotStyle, plotSize): #Default sizes for computer sizing_dict = {} sizing_dict['figure.figsize'] = (14, 8) sizing_dict['legend.fontsize'] = 15 sizing_dict['axes.labelsize'] = 20 sizing_dict['axes.titlesize'] = 24 sizing_dict['xtick.labelsi...
python
def define_format(self, plotStyle, plotSize): #Default sizes for computer sizing_dict = {} sizing_dict['figure.figsize'] = (14, 8) sizing_dict['legend.fontsize'] = 15 sizing_dict['axes.labelsize'] = 20 sizing_dict['axes.titlesize'] = 24 sizing_dict['xtick.labelsi...
[ "def", "define_format", "(", "self", ",", "plotStyle", ",", "plotSize", ")", ":", "#Default sizes for computer", "sizing_dict", "=", "{", "}", "sizing_dict", "[", "'figure.figsize'", "]", "=", "(", "14", ",", "8", ")", "sizing_dict", "[", "'legend.fontsize'", ...
Seaborn color blind #0072B2 dark blue #009E73 green #D55E00 orangish #CC79A7 pink #F0E442 yellow #56B4E9 cyan #bcbd22 olive #adicional #7f7f7f grey #FFB5B8 skin
[ "Seaborn", "color", "blind", "#0072B2", "dark", "blue", "#009E73", "green", "#D55E00", "orangish", "#CC79A7", "pink", "#F0E442", "yellow", "#56B4E9", "cyan", "#bcbd22", "olive", "#adicional", "#7f7f7f", "grey", "#FFB5B8", "skin" ]
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Plotting_Libraries/dazer_plotter.py#L42-L163
train
gpiantoni/bidso
bidso/objects.py
Electrodes.get_xyz
def get_xyz(self, list_of_names=None): """Get xyz coordinates for these electrodes Parameters ---------- list_of_names : list of str list of electrode names to use Returns ------- list of tuples of 3 floats (x, y, z) list of xyz coordinat...
python
def get_xyz(self, list_of_names=None): """Get xyz coordinates for these electrodes Parameters ---------- list_of_names : list of str list of electrode names to use Returns ------- list of tuples of 3 floats (x, y, z) list of xyz coordinat...
[ "def", "get_xyz", "(", "self", ",", "list_of_names", "=", "None", ")", ":", "if", "list_of_names", "is", "not", "None", ":", "filter_lambda", "=", "lambda", "x", ":", "x", "[", "'name'", "]", "in", "list_of_names", "else", ":", "filter_lambda", "=", "Non...
Get xyz coordinates for these electrodes Parameters ---------- list_of_names : list of str list of electrode names to use Returns ------- list of tuples of 3 floats (x, y, z) list of xyz coordinates for all the electrodes TODO --...
[ "Get", "xyz", "coordinates", "for", "these", "electrodes" ]
af163b921ec4e3d70802de07f174de184491cfce
https://github.com/gpiantoni/bidso/blob/af163b921ec4e3d70802de07f174de184491cfce/bidso/objects.py#L12-L37
train
Vital-Fernandez/dazer
bin/lib/Math_Libraries/bces_script.py
bces
def bces(y1,y1err,y2,y2err,cerr): """ Does the entire regression calculation for 4 slopes: OLS(Y|X), OLS(X|Y), bisector, orthogonal. Fitting form: Y=AX+B. Usage: >>> a,b,aerr,berr,covab=bces(x,xerr,y,yerr,cov) Output: - a,b : best-fit parameters a,b of the linear regression - aerr,berr : the standard deviations i...
python
def bces(y1,y1err,y2,y2err,cerr): """ Does the entire regression calculation for 4 slopes: OLS(Y|X), OLS(X|Y), bisector, orthogonal. Fitting form: Y=AX+B. Usage: >>> a,b,aerr,berr,covab=bces(x,xerr,y,yerr,cov) Output: - a,b : best-fit parameters a,b of the linear regression - aerr,berr : the standard deviations i...
[ "def", "bces", "(", "y1", ",", "y1err", ",", "y2", ",", "y2err", ",", "cerr", ")", ":", "# Arrays holding the code main results for each method:", "# Elements: 0-Y|X, 1-X|Y, 2-bisector, 3-orthogonal", "a", ",", "b", ",", "avar", ",", "bvar", ",", "covarxiz", ",", ...
Does the entire regression calculation for 4 slopes: OLS(Y|X), OLS(X|Y), bisector, orthogonal. Fitting form: Y=AX+B. Usage: >>> a,b,aerr,berr,covab=bces(x,xerr,y,yerr,cov) Output: - a,b : best-fit parameters a,b of the linear regression - aerr,berr : the standard deviations in a,b - covab : the covariance between ...
[ "Does", "the", "entire", "regression", "calculation", "for", "4", "slopes", ":", "OLS", "(", "Y|X", ")", "OLS", "(", "X|Y", ")", "bisector", "orthogonal", ".", "Fitting", "form", ":", "Y", "=", "AX", "+", "B", "." ]
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Math_Libraries/bces_script.py#L6-L79
train
Vital-Fernandez/dazer
bin/lib/Math_Libraries/bces_script.py
bootstrap
def bootstrap(v): """ Constructs Monte Carlo simulated data set using the Bootstrap algorithm. Usage: >>> bootstrap(x) where x is either an array or a list of arrays. If it is a list, the code returns the corresponding list of bootst...
python
def bootstrap(v): """ Constructs Monte Carlo simulated data set using the Bootstrap algorithm. Usage: >>> bootstrap(x) where x is either an array or a list of arrays. If it is a list, the code returns the corresponding list of bootst...
[ "def", "bootstrap", "(", "v", ")", ":", "if", "type", "(", "v", ")", "==", "list", ":", "vboot", "=", "[", "]", "# list of boostrapped arrays", "n", "=", "v", "[", "0", "]", ".", "size", "iran", "=", "scipy", ".", "random", ".", "randint", "(", "...
Constructs Monte Carlo simulated data set using the Bootstrap algorithm. Usage: >>> bootstrap(x) where x is either an array or a list of arrays. If it is a list, the code returns the corresponding list of bootstrapped arrays assuming...
[ "Constructs", "Monte", "Carlo", "simulated", "data", "set", "using", "the", "Bootstrap", "algorithm", "." ]
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Math_Libraries/bces_script.py#L81-L107
train
Vital-Fernandez/dazer
bin/lib/Math_Libraries/bces_script.py
bcesboot
def bcesboot(y1,y1err,y2,y2err,cerr,nsim=10000): """ Does the BCES with bootstrapping. Usage: >>> a,b,aerr,berr,covab=bcesboot(x,xerr,y,yerr,cov,nsim) :param x,y: data :param xerr,yerr: measurement errors affecting x and y :param cov: covariance between the measurement errors (all are arrays) :param ns...
python
def bcesboot(y1,y1err,y2,y2err,cerr,nsim=10000): """ Does the BCES with bootstrapping. Usage: >>> a,b,aerr,berr,covab=bcesboot(x,xerr,y,yerr,cov,nsim) :param x,y: data :param xerr,yerr: measurement errors affecting x and y :param cov: covariance between the measurement errors (all are arrays) :param ns...
[ "def", "bcesboot", "(", "y1", ",", "y1err", ",", "y2", ",", "y2err", ",", "cerr", ",", "nsim", "=", "10000", ")", ":", "# Progress bar initialization", "\"\"\"\n\tMy convention for storing the results of the bces code below as \n\tmatrixes for processing later are as follow:\n\...
Does the BCES with bootstrapping. Usage: >>> a,b,aerr,berr,covab=bcesboot(x,xerr,y,yerr,cov,nsim) :param x,y: data :param xerr,yerr: measurement errors affecting x and y :param cov: covariance between the measurement errors (all are arrays) :param nsim: number of Monte Carlo simulations (bootstraps) :re...
[ "Does", "the", "BCES", "with", "bootstrapping", ".", "Usage", ":", ">>>", "a", "b", "aerr", "berr", "covab", "=", "bcesboot", "(", "x", "xerr", "y", "yerr", "cov", "nsim", ")", ":", "param", "x", "y", ":", "data", ":", "param", "xerr", "yerr", ":",...
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Math_Libraries/bces_script.py#L109-L171
train
Vital-Fernandez/dazer
bin/lib/Math_Libraries/bces_script.py
bcesboot_backup
def bcesboot_backup(y1,y1err,y2,y2err,cerr,nsim=10000): """ Does the BCES with bootstrapping. Usage: >>> a,b,aerr,berr,covab=bcesboot(x,xerr,y,yerr,cov,nsim) :param x,y: data :param xerr,yerr: measurement errors affecting x and y :param cov: covariance between the measurement errors (all are arrays) :param nsim: n...
python
def bcesboot_backup(y1,y1err,y2,y2err,cerr,nsim=10000): """ Does the BCES with bootstrapping. Usage: >>> a,b,aerr,berr,covab=bcesboot(x,xerr,y,yerr,cov,nsim) :param x,y: data :param xerr,yerr: measurement errors affecting x and y :param cov: covariance between the measurement errors (all are arrays) :param nsim: n...
[ "def", "bcesboot_backup", "(", "y1", ",", "y1err", ",", "y2", ",", "y2err", ",", "cerr", ",", "nsim", "=", "10000", ")", ":", "import", "fish", "# Progress bar initialization", "peixe", "=", "fish", ".", "ProgressFish", "(", "total", "=", "nsim", ")", "p...
Does the BCES with bootstrapping. Usage: >>> a,b,aerr,berr,covab=bcesboot(x,xerr,y,yerr,cov,nsim) :param x,y: data :param xerr,yerr: measurement errors affecting x and y :param cov: covariance between the measurement errors (all are arrays) :param nsim: number of Monte Carlo simulations (bootstraps) :returns: a,b ...
[ "Does", "the", "BCES", "with", "bootstrapping", "." ]
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Math_Libraries/bces_script.py#L173-L237
train
Vital-Fernandez/dazer
bin/lib/Math_Libraries/bces_script.py
ab
def ab(x): """ This method is the big bottleneck of the parallel BCES code. That's the reason why I put these calculations in a separate method, in order to distribute this among the cores. In the original BCES method, this is inside the main routine. Argument: [y1,y1err,y2,y2err,cerr,nsim] where nsim is the numb...
python
def ab(x): """ This method is the big bottleneck of the parallel BCES code. That's the reason why I put these calculations in a separate method, in order to distribute this among the cores. In the original BCES method, this is inside the main routine. Argument: [y1,y1err,y2,y2err,cerr,nsim] where nsim is the numb...
[ "def", "ab", "(", "x", ")", ":", "y1", ",", "y1err", ",", "y2", ",", "y2err", ",", "cerr", ",", "nsim", "=", "x", "[", "0", "]", ",", "x", "[", "1", "]", ",", "x", "[", "2", "]", ",", "x", "[", "3", "]", ",", "x", "[", "4", "]", ","...
This method is the big bottleneck of the parallel BCES code. That's the reason why I put these calculations in a separate method, in order to distribute this among the cores. In the original BCES method, this is inside the main routine. Argument: [y1,y1err,y2,y2err,cerr,nsim] where nsim is the number of bootstrapp...
[ "This", "method", "is", "the", "big", "bottleneck", "of", "the", "parallel", "BCES", "code", ".", "That", "s", "the", "reason", "why", "I", "put", "these", "calculations", "in", "a", "separate", "method", "in", "order", "to", "distribute", "this", "among",...
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Math_Libraries/bces_script.py#L242-L274
train
Vital-Fernandez/dazer
bin/lib/Math_Libraries/bces_script.py
bcesp
def bcesp(y1,y1err,y2,y2err,cerr,nsim=10000): """ Parallel implementation of the BCES with bootstrapping. Divide the bootstraps equally among the threads (cores) of the machine. It will automatically detect the number of cores available. Usage: >>> a,b,aerr,berr,covab=bcesp(x,xerr,y,yerr,cov,nsim) :param x,y: data ...
python
def bcesp(y1,y1err,y2,y2err,cerr,nsim=10000): """ Parallel implementation of the BCES with bootstrapping. Divide the bootstraps equally among the threads (cores) of the machine. It will automatically detect the number of cores available. Usage: >>> a,b,aerr,berr,covab=bcesp(x,xerr,y,yerr,cov,nsim) :param x,y: data ...
[ "def", "bcesp", "(", "y1", ",", "y1err", ",", "y2", ",", "y2err", ",", "cerr", ",", "nsim", "=", "10000", ")", ":", "import", "time", "# for benchmarking", "import", "multiprocessing", "print", "\"BCES,\"", ",", "nsim", ",", "\"trials... \"", ",", "tic", ...
Parallel implementation of the BCES with bootstrapping. Divide the bootstraps equally among the threads (cores) of the machine. It will automatically detect the number of cores available. Usage: >>> a,b,aerr,berr,covab=bcesp(x,xerr,y,yerr,cov,nsim) :param x,y: data :param xerr,yerr: measurement errors affecting x an...
[ "Parallel", "implementation", "of", "the", "BCES", "with", "bootstrapping", ".", "Divide", "the", "bootstraps", "equally", "among", "the", "threads", "(", "cores", ")", "of", "the", "machine", ".", "It", "will", "automatically", "detect", "the", "number", "of"...
3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244
https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/Math_Libraries/bces_script.py#L276-L361
train
jaredLunde/vital-tools
vital/debug/stats.py
mean
def mean(data): """Return the sample arithmetic mean of data.""" #: http://stackoverflow.com/a/27758326 n = len(data) if n < 1: raise ValueError('mean requires at least one data point') return sum(data)/n
python
def mean(data): """Return the sample arithmetic mean of data.""" #: http://stackoverflow.com/a/27758326 n = len(data) if n < 1: raise ValueError('mean requires at least one data point') return sum(data)/n
[ "def", "mean", "(", "data", ")", ":", "#: http://stackoverflow.com/a/27758326", "n", "=", "len", "(", "data", ")", "if", "n", "<", "1", ":", "raise", "ValueError", "(", "'mean requires at least one data point'", ")", "return", "sum", "(", "data", ")", "/", "...
Return the sample arithmetic mean of data.
[ "Return", "the", "sample", "arithmetic", "mean", "of", "data", "." ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/stats.py#L19-L25
train
jaredLunde/vital-tools
vital/debug/stats.py
pstdev
def pstdev(data): """Calculates the population standard deviation.""" #: http://stackoverflow.com/a/27758326 n = len(data) if n < 2: raise ValueError('variance requires at least two data points') ss = _ss(data) pvar = ss/n # the population variance return pvar**0.5
python
def pstdev(data): """Calculates the population standard deviation.""" #: http://stackoverflow.com/a/27758326 n = len(data) if n < 2: raise ValueError('variance requires at least two data points') ss = _ss(data) pvar = ss/n # the population variance return pvar**0.5
[ "def", "pstdev", "(", "data", ")", ":", "#: http://stackoverflow.com/a/27758326", "n", "=", "len", "(", "data", ")", "if", "n", "<", "2", ":", "raise", "ValueError", "(", "'variance requires at least two data points'", ")", "ss", "=", "_ss", "(", "data", ")", ...
Calculates the population standard deviation.
[ "Calculates", "the", "population", "standard", "deviation", "." ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/stats.py#L36-L44
train
jaredLunde/vital-tools
vital/debug/stats.py
median
def median(lst): """ Calcuates the median value in a @lst """ #: http://stackoverflow.com/a/24101534 sortedLst = sorted(lst) lstLen = len(lst) index = (lstLen - 1) // 2 if (lstLen % 2): return sortedLst[index] else: return (sortedLst[index] + sortedLst[index + 1])/2.0
python
def median(lst): """ Calcuates the median value in a @lst """ #: http://stackoverflow.com/a/24101534 sortedLst = sorted(lst) lstLen = len(lst) index = (lstLen - 1) // 2 if (lstLen % 2): return sortedLst[index] else: return (sortedLst[index] + sortedLst[index + 1])/2.0
[ "def", "median", "(", "lst", ")", ":", "#: http://stackoverflow.com/a/24101534", "sortedLst", "=", "sorted", "(", "lst", ")", "lstLen", "=", "len", "(", "lst", ")", "index", "=", "(", "lstLen", "-", "1", ")", "//", "2", "if", "(", "lstLen", "%", "2", ...
Calcuates the median value in a @lst
[ "Calcuates", "the", "median", "value", "in", "a" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/debug/stats.py#L47-L56
train
kajala/django-jutil
jutil/email.py
send_email
def send_email(recipients: list, subject: str, text: str, html: str='', sender: str='', files: list=[], exceptions: bool=False): """ :param recipients: List of recipients; or single email (str); or comma-separated email list (str); or list of name-email pairs (e.g. settings.ADMINS) :param subject: Subject o...
python
def send_email(recipients: list, subject: str, text: str, html: str='', sender: str='', files: list=[], exceptions: bool=False): """ :param recipients: List of recipients; or single email (str); or comma-separated email list (str); or list of name-email pairs (e.g. settings.ADMINS) :param subject: Subject o...
[ "def", "send_email", "(", "recipients", ":", "list", ",", "subject", ":", "str", ",", "text", ":", "str", ",", "html", ":", "str", "=", "''", ",", "sender", ":", "str", "=", "''", ",", "files", ":", "list", "=", "[", "]", ",", "exceptions", ":", ...
:param recipients: List of recipients; or single email (str); or comma-separated email list (str); or list of name-email pairs (e.g. settings.ADMINS) :param subject: Subject of the email :param text: Body (text) :param html: Body (html) :param sender: Sender email, or settings.DEFAULT_FROM_EMAIL if miss...
[ ":", "param", "recipients", ":", "List", "of", "recipients", ";", "or", "single", "email", "(", "str", ")", ";", "or", "comma", "-", "separated", "email", "list", "(", "str", ")", ";", "or", "list", "of", "name", "-", "email", "pairs", "(", "e", "....
2abd93ebad51042744eaeb1ee1074ed0eb55ad0c
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/email.py#L7-L90
train
jaredLunde/vital-tools
vital/tools/html.py
remove_whitespace
def remove_whitespace(s): """ Unsafely attempts to remove HTML whitespace. This is not an HTML parser which is why its considered 'unsafe', but it should work for most implementations. Just use on at your own risk. @s: #str -> HTML with whitespace removed, ignoring <pre>, script, t...
python
def remove_whitespace(s): """ Unsafely attempts to remove HTML whitespace. This is not an HTML parser which is why its considered 'unsafe', but it should work for most implementations. Just use on at your own risk. @s: #str -> HTML with whitespace removed, ignoring <pre>, script, t...
[ "def", "remove_whitespace", "(", "s", ")", ":", "ignores", "=", "{", "}", "for", "ignore", "in", "html_ignore_whitespace_re", ".", "finditer", "(", "s", ")", ":", "name", "=", "\"{}{}{}\"", ".", "format", "(", "r\"{}\"", ",", "uuid", ".", "uuid4", "(", ...
Unsafely attempts to remove HTML whitespace. This is not an HTML parser which is why its considered 'unsafe', but it should work for most implementations. Just use on at your own risk. @s: #str -> HTML with whitespace removed, ignoring <pre>, script, textarea and code tags
[ "Unsafely", "attempts", "to", "remove", "HTML", "whitespace", ".", "This", "is", "not", "an", "HTML", "parser", "which", "is", "why", "its", "considered", "unsafe", "but", "it", "should", "work", "for", "most", "implementations", ".", "Just", "use", "on", ...
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/html.py#L38-L56
train
jaredLunde/vital-tools
vital/tools/html.py
hashtag_links
def hashtag_links(uri, s): """ Turns hashtag-like strings into HTML links @uri: /uri/ root for the hashtag-like @s: the #str string you're looking for |#|hashtags in -> #str HTML link |<a href="/uri/hashtag">hashtag</a>| """ for tag, after in hashtag_re.findall(s): _uri = '...
python
def hashtag_links(uri, s): """ Turns hashtag-like strings into HTML links @uri: /uri/ root for the hashtag-like @s: the #str string you're looking for |#|hashtags in -> #str HTML link |<a href="/uri/hashtag">hashtag</a>| """ for tag, after in hashtag_re.findall(s): _uri = '...
[ "def", "hashtag_links", "(", "uri", ",", "s", ")", ":", "for", "tag", ",", "after", "in", "hashtag_re", ".", "findall", "(", "s", ")", ":", "_uri", "=", "'/'", "+", "(", "uri", "or", "\"\"", ")", ".", "lstrip", "(", "\"/\"", ")", "+", "quote", ...
Turns hashtag-like strings into HTML links @uri: /uri/ root for the hashtag-like @s: the #str string you're looking for |#|hashtags in -> #str HTML link |<a href="/uri/hashtag">hashtag</a>|
[ "Turns", "hashtag", "-", "like", "strings", "into", "HTML", "links" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/html.py#L59-L71
train
jaredLunde/vital-tools
vital/tools/html.py
mentions_links
def mentions_links(uri, s): """ Turns mentions-like strings into HTML links, @uri: /uri/ root for the hashtag-like @s: the #str string you're looking for |@|mentions in -> #str HTML link |<a href="/uri/mention">mention</a>| """ for username, after in mentions_re.findall(s): ...
python
def mentions_links(uri, s): """ Turns mentions-like strings into HTML links, @uri: /uri/ root for the hashtag-like @s: the #str string you're looking for |@|mentions in -> #str HTML link |<a href="/uri/mention">mention</a>| """ for username, after in mentions_re.findall(s): ...
[ "def", "mentions_links", "(", "uri", ",", "s", ")", ":", "for", "username", ",", "after", "in", "mentions_re", ".", "findall", "(", "s", ")", ":", "_uri", "=", "'/'", "+", "(", "uri", "or", "\"\"", ")", ".", "lstrip", "(", "\"/\"", ")", "+", "quo...
Turns mentions-like strings into HTML links, @uri: /uri/ root for the hashtag-like @s: the #str string you're looking for |@|mentions in -> #str HTML link |<a href="/uri/mention">mention</a>|
[ "Turns", "mentions", "-", "like", "strings", "into", "HTML", "links", "@uri", ":", "/", "uri", "/", "root", "for", "the", "hashtag", "-", "like", "@s", ":", "the", "#str", "string", "you", "re", "looking", "for", "|@|mentions", "in" ]
ea924c9bbb6ec22aa66f8095f018b1ee0099ac04
https://github.com/jaredLunde/vital-tools/blob/ea924c9bbb6ec22aa66f8095f018b1ee0099ac04/vital/tools/html.py#L74-L85
train
MarcAureleCoste/sqla-filters
src/sqla_filters/tree/tree.py
SqlaFilterTree.filter
def filter(self, query: Query): """Return a new filtered query. Use the tree to filter the query and return a new query "filtered". This query can be filtered again using another tree or even a manual filter. To manually filter query see : - https://docs.sqlalch...
python
def filter(self, query: Query): """Return a new filtered query. Use the tree to filter the query and return a new query "filtered". This query can be filtered again using another tree or even a manual filter. To manually filter query see : - https://docs.sqlalch...
[ "def", "filter", "(", "self", ",", "query", ":", "Query", ")", ":", "entity", "=", "query", ".", "column_descriptions", "[", "0", "]", "[", "'type'", "]", "new_query", ",", "filters", "=", "self", ".", "_root", ".", "filter", "(", "query", ",", "enti...
Return a new filtered query. Use the tree to filter the query and return a new query "filtered". This query can be filtered again using another tree or even a manual filter. To manually filter query see : - https://docs.sqlalchemy.org/en/rel_1_2/orm/query.html?highlight...
[ "Return", "a", "new", "filtered", "query", ".", "Use", "the", "tree", "to", "filter", "the", "query", "and", "return", "a", "new", "query", "filtered", ".", "This", "query", "can", "be", "filtered", "again", "using", "another", "tree", "or", "even", "a",...
a9596f660a11d275bf0e831ecd9e502b0af2a087
https://github.com/MarcAureleCoste/sqla-filters/blob/a9596f660a11d275bf0e831ecd9e502b0af2a087/src/sqla_filters/tree/tree.py#L26-L37
train