repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
EdwinvO/pyutillib
pyutillib/string_utils.py
random_string
def random_string(length=8, charset=None): ''' Generates a string with random characters. If no charset is specified, only letters and digits are used. Args: length (int) length of the returned string charset (string) list of characters to choose from Returns: (str) with ran...
python
def random_string(length=8, charset=None): ''' Generates a string with random characters. If no charset is specified, only letters and digits are used. Args: length (int) length of the returned string charset (string) list of characters to choose from Returns: (str) with ran...
[ "def", "random_string", "(", "length", "=", "8", ",", "charset", "=", "None", ")", ":", "if", "length", "<", "1", ":", "raise", "ValueError", "(", "'Length must be > 0'", ")", "if", "not", "charset", ":", "charset", "=", "string", ".", "letters", "+", ...
Generates a string with random characters. If no charset is specified, only letters and digits are used. Args: length (int) length of the returned string charset (string) list of characters to choose from Returns: (str) with random characters from charset Raises: -
[ "Generates", "a", "string", "with", "random", "characters", ".", "If", "no", "charset", "is", "specified", "only", "letters", "and", "digits", "are", "used", "." ]
train
https://github.com/EdwinvO/pyutillib/blob/6d773c31d1f27cc5256d47feb8afb5c3ae5f0db5/pyutillib/string_utils.py#L28-L45
EdwinvO/pyutillib
pyutillib/string_utils.py
str2dict
def str2dict(str_in): ''' Extracts a dict from a string. Args: str_in (string) that contains python dict Returns: (dict) or None if no valid dict was found Raises: - ''' dict_out = safe_eval(str_in) if not isinstance(dict_out, dict): dict_out = None r...
python
def str2dict(str_in): ''' Extracts a dict from a string. Args: str_in (string) that contains python dict Returns: (dict) or None if no valid dict was found Raises: - ''' dict_out = safe_eval(str_in) if not isinstance(dict_out, dict): dict_out = None r...
[ "def", "str2dict", "(", "str_in", ")", ":", "dict_out", "=", "safe_eval", "(", "str_in", ")", "if", "not", "isinstance", "(", "dict_out", ",", "dict", ")", ":", "dict_out", "=", "None", "return", "dict_out" ]
Extracts a dict from a string. Args: str_in (string) that contains python dict Returns: (dict) or None if no valid dict was found Raises: -
[ "Extracts", "a", "dict", "from", "a", "string", "." ]
train
https://github.com/EdwinvO/pyutillib/blob/6d773c31d1f27cc5256d47feb8afb5c3ae5f0db5/pyutillib/string_utils.py#L65-L79
EdwinvO/pyutillib
pyutillib/string_utils.py
str2tuple
def str2tuple(str_in): ''' Extracts a tuple from a string. Args: str_in (string) that contains python tuple Returns: (dict) or None if no valid tuple was found Raises: - ''' tuple_out = safe_eval(str_in) if not isinstance(tuple_out, tuple): tuple_out = No...
python
def str2tuple(str_in): ''' Extracts a tuple from a string. Args: str_in (string) that contains python tuple Returns: (dict) or None if no valid tuple was found Raises: - ''' tuple_out = safe_eval(str_in) if not isinstance(tuple_out, tuple): tuple_out = No...
[ "def", "str2tuple", "(", "str_in", ")", ":", "tuple_out", "=", "safe_eval", "(", "str_in", ")", "if", "not", "isinstance", "(", "tuple_out", ",", "tuple", ")", ":", "tuple_out", "=", "None", "return", "tuple_out" ]
Extracts a tuple from a string. Args: str_in (string) that contains python tuple Returns: (dict) or None if no valid tuple was found Raises: -
[ "Extracts", "a", "tuple", "from", "a", "string", "." ]
train
https://github.com/EdwinvO/pyutillib/blob/6d773c31d1f27cc5256d47feb8afb5c3ae5f0db5/pyutillib/string_utils.py#L82-L96
EdwinvO/pyutillib
pyutillib/string_utils.py
str2dict_keys
def str2dict_keys(str_in): ''' Extracts the keys from a string that represents a dict and returns them sorted by key. Args: str_in (string) that contains python dict Returns: (list) with keys or None if no valid dict was found Raises: - ''' tmp_dict = str2dict(st...
python
def str2dict_keys(str_in): ''' Extracts the keys from a string that represents a dict and returns them sorted by key. Args: str_in (string) that contains python dict Returns: (list) with keys or None if no valid dict was found Raises: - ''' tmp_dict = str2dict(st...
[ "def", "str2dict_keys", "(", "str_in", ")", ":", "tmp_dict", "=", "str2dict", "(", "str_in", ")", "if", "tmp_dict", "is", "None", ":", "return", "None", "return", "sorted", "(", "[", "k", "for", "k", "in", "tmp_dict", "]", ")" ]
Extracts the keys from a string that represents a dict and returns them sorted by key. Args: str_in (string) that contains python dict Returns: (list) with keys or None if no valid dict was found Raises: -
[ "Extracts", "the", "keys", "from", "a", "string", "that", "represents", "a", "dict", "and", "returns", "them", "sorted", "by", "key", "." ]
train
https://github.com/EdwinvO/pyutillib/blob/6d773c31d1f27cc5256d47feb8afb5c3ae5f0db5/pyutillib/string_utils.py#L100-L115
EdwinvO/pyutillib
pyutillib/string_utils.py
str2dict_values
def str2dict_values(str_in): ''' Extracts the values from a string that represents a dict and returns them sorted by key. Args: str_in (string) that contains python dict Returns: (list) with values or None if no valid dict was found Raises: - ''' tmp_dict = str2d...
python
def str2dict_values(str_in): ''' Extracts the values from a string that represents a dict and returns them sorted by key. Args: str_in (string) that contains python dict Returns: (list) with values or None if no valid dict was found Raises: - ''' tmp_dict = str2d...
[ "def", "str2dict_values", "(", "str_in", ")", ":", "tmp_dict", "=", "str2dict", "(", "str_in", ")", "if", "tmp_dict", "is", "None", ":", "return", "None", "return", "[", "tmp_dict", "[", "key", "]", "for", "key", "in", "sorted", "(", "k", "for", "k", ...
Extracts the values from a string that represents a dict and returns them sorted by key. Args: str_in (string) that contains python dict Returns: (list) with values or None if no valid dict was found Raises: -
[ "Extracts", "the", "values", "from", "a", "string", "that", "represents", "a", "dict", "and", "returns", "them", "sorted", "by", "key", "." ]
train
https://github.com/EdwinvO/pyutillib/blob/6d773c31d1f27cc5256d47feb8afb5c3ae5f0db5/pyutillib/string_utils.py#L119-L134
EdwinvO/pyutillib
pyutillib/string_utils.py
decstr2int
def decstr2int(dec_str, decimals): ''' Returns an integer that has the value of the decimal string: dec_str*10^decimals Arguments: dec_str (string) that represents a decimal number decimals (int): number of decimals for creating the integer output Returns: (int) Rais...
python
def decstr2int(dec_str, decimals): ''' Returns an integer that has the value of the decimal string: dec_str*10^decimals Arguments: dec_str (string) that represents a decimal number decimals (int): number of decimals for creating the integer output Returns: (int) Rais...
[ "def", "decstr2int", "(", "dec_str", ",", "decimals", ")", ":", "if", "not", "isinstance", "(", "decimals", ",", "int", ")", ":", "raise", "TypeError", "(", "'decimals must be an integer'", ")", "try", ":", "dollars", ",", "cents", "=", "dec_str", ".", "sp...
Returns an integer that has the value of the decimal string: dec_str*10^decimals Arguments: dec_str (string) that represents a decimal number decimals (int): number of decimals for creating the integer output Returns: (int) Raises: ValueError if dec_string is not a v...
[ "Returns", "an", "integer", "that", "has", "the", "value", "of", "the", "decimal", "string", ":", "dec_str", "*", "10^decimals" ]
train
https://github.com/EdwinvO/pyutillib/blob/6d773c31d1f27cc5256d47feb8afb5c3ae5f0db5/pyutillib/string_utils.py#L137-L176
sirrice/scorpionsql
scorpionsql/sqlparser.py
expr_to_str
def expr_to_str(n, l=None): """ construct SQL string from expression node """ op = n[0] if op.startswith('_') and op.endswith('_'): op = op.strip('_') if op == 'var': return n[1] elif op == 'literal': if isinstance(n[1], basestring): re...
python
def expr_to_str(n, l=None): """ construct SQL string from expression node """ op = n[0] if op.startswith('_') and op.endswith('_'): op = op.strip('_') if op == 'var': return n[1] elif op == 'literal': if isinstance(n[1], basestring): re...
[ "def", "expr_to_str", "(", "n", ",", "l", "=", "None", ")", ":", "op", "=", "n", "[", "0", "]", "if", "op", ".", "startswith", "(", "'_'", ")", "and", "op", ".", "endswith", "(", "'_'", ")", ":", "op", "=", "op", ".", "strip", "(", "'_'", "...
construct SQL string from expression node
[ "construct", "SQL", "string", "from", "expression", "node" ]
train
https://github.com/sirrice/scorpionsql/blob/baa05b745fae5df3171244c3e32160bd36c99e86/scorpionsql/sqlparser.py#L95-L116
sirrice/scorpionsql
scorpionsql/sqlparser.py
get_vars
def get_vars(n): """ extract variables from expression node defined by tuple-pair: (_var_, [variable name]) """ op = n[0] if op.startswith('_') and op.endswith('_'): op = op.strip('_') if op == 'var': return [n[1]] return [] else: ret = [] ...
python
def get_vars(n): """ extract variables from expression node defined by tuple-pair: (_var_, [variable name]) """ op = n[0] if op.startswith('_') and op.endswith('_'): op = op.strip('_') if op == 'var': return [n[1]] return [] else: ret = [] ...
[ "def", "get_vars", "(", "n", ")", ":", "op", "=", "n", "[", "0", "]", "if", "op", ".", "startswith", "(", "'_'", ")", "and", "op", ".", "endswith", "(", "'_'", ")", ":", "op", "=", "op", ".", "strip", "(", "'_'", ")", "if", "op", "==", "'va...
extract variables from expression node defined by tuple-pair: (_var_, [variable name])
[ "extract", "variables", "from", "expression", "node", "defined", "by", "tuple", "-", "pair", ":", "(", "_var_", "[", "variable", "name", "]", ")" ]
train
https://github.com/sirrice/scorpionsql/blob/baa05b745fae5df3171244c3e32160bd36c99e86/scorpionsql/sqlparser.py#L118-L135
sirrice/scorpionsql
scorpionsql/sqlparser.py
construct_func_expr
def construct_func_expr(n): """ construct the function expression """ op = n[0] if op.startswith('_') and op.endswith('_'): op = op.strip('_') if op == 'var': return Var(str(n[1])) elif op == 'literal': if isinstance(n[1], basestring): ...
python
def construct_func_expr(n): """ construct the function expression """ op = n[0] if op.startswith('_') and op.endswith('_'): op = op.strip('_') if op == 'var': return Var(str(n[1])) elif op == 'literal': if isinstance(n[1], basestring): ...
[ "def", "construct_func_expr", "(", "n", ")", ":", "op", "=", "n", "[", "0", "]", "if", "op", ".", "startswith", "(", "'_'", ")", "and", "op", ".", "endswith", "(", "'_'", ")", ":", "op", "=", "op", ".", "strip", "(", "'_'", ")", "if", "op", "...
construct the function expression
[ "construct", "the", "function", "expression" ]
train
https://github.com/sirrice/scorpionsql/blob/baa05b745fae5df3171244c3e32160bd36c99e86/scorpionsql/sqlparser.py#L138-L159
robertdfrench/psychic-disco
psychic_disco/api_gateway_config.py
fetch_api_by_name
def fetch_api_by_name(api_name): """ Fetch an api record by its name """ api_records = console.get_rest_apis()['items'] matches = filter(lambda x: x['name'] == api_name, api_records) if not matches: return None return matches[0]
python
def fetch_api_by_name(api_name): """ Fetch an api record by its name """ api_records = console.get_rest_apis()['items'] matches = filter(lambda x: x['name'] == api_name, api_records) if not matches: return None return matches[0]
[ "def", "fetch_api_by_name", "(", "api_name", ")", ":", "api_records", "=", "console", ".", "get_rest_apis", "(", ")", "[", "'items'", "]", "matches", "=", "filter", "(", "lambda", "x", ":", "x", "[", "'name'", "]", "==", "api_name", ",", "api_records", "...
Fetch an api record by its name
[ "Fetch", "an", "api", "record", "by", "its", "name" ]
train
https://github.com/robertdfrench/psychic-disco/blob/3cf167b44c64d64606691fc186be7d9ef8e8e938/psychic_disco/api_gateway_config.py#L8-L14
robertdfrench/psychic-disco
psychic_disco/api_gateway_config.py
fetch_method
def fetch_method(api_id, resource_id, verb): """ Fetch extra metadata for this particular method """ return console.get_method( restApiId=api_id, resourceId=resource_id, httpMethod=verb)
python
def fetch_method(api_id, resource_id, verb): """ Fetch extra metadata for this particular method """ return console.get_method( restApiId=api_id, resourceId=resource_id, httpMethod=verb)
[ "def", "fetch_method", "(", "api_id", ",", "resource_id", ",", "verb", ")", ":", "return", "console", ".", "get_method", "(", "restApiId", "=", "api_id", ",", "resourceId", "=", "resource_id", ",", "httpMethod", "=", "verb", ")" ]
Fetch extra metadata for this particular method
[ "Fetch", "extra", "metadata", "for", "this", "particular", "method" ]
train
https://github.com/robertdfrench/psychic-disco/blob/3cf167b44c64d64606691fc186be7d9ef8e8e938/psychic_disco/api_gateway_config.py#L27-L32
dnerdy/django-reroute
reroute/verbs.py
request_method
def request_method(request): '''Returns the effective HTTP method of a request. To support the entire range of HTTP methods from HTML forms (which only support GET and POST), an HTTP method may be emulated by setting a POST parameter named "_method" to the name of the HTTP method to be emulated. Ex...
python
def request_method(request): '''Returns the effective HTTP method of a request. To support the entire range of HTTP methods from HTML forms (which only support GET and POST), an HTTP method may be emulated by setting a POST parameter named "_method" to the name of the HTTP method to be emulated. Ex...
[ "def", "request_method", "(", "request", ")", ":", "# For security reasons POST is the only method that supports HTTP method emulation.", "# For example, if POST requires csrf_token, we don't want POST methods to be called via", "# GET (thereby bypassing CSRF protection). POST has the most limited s...
Returns the effective HTTP method of a request. To support the entire range of HTTP methods from HTML forms (which only support GET and POST), an HTTP method may be emulated by setting a POST parameter named "_method" to the name of the HTTP method to be emulated. Example HTML: <!-- Submits a f...
[ "Returns", "the", "effective", "HTTP", "method", "of", "a", "request", ".", "To", "support", "the", "entire", "range", "of", "HTTP", "methods", "from", "HTML", "forms", "(", "which", "only", "support", "GET", "and", "POST", ")", "an", "HTTP", "method", "...
train
https://github.com/dnerdy/django-reroute/blob/fbc9c3a15f12e9522ef3333896ce0564a2888a30/reroute/verbs.py#L30-L62
artizirk/python-axp209
axp209.py
AXP209.battery_voltage
def battery_voltage(self): """ Returns voltage in mV """ msb = self.bus.read_byte_data(AXP209_ADDRESS, BATTERY_VOLTAGE_MSB_REG) lsb = self.bus.read_byte_data(AXP209_ADDRESS, BATTERY_VOLTAGE_LSB_REG) voltage_bin = msb << 4 | lsb & 0x0f return voltage_bin * 1.1
python
def battery_voltage(self): """ Returns voltage in mV """ msb = self.bus.read_byte_data(AXP209_ADDRESS, BATTERY_VOLTAGE_MSB_REG) lsb = self.bus.read_byte_data(AXP209_ADDRESS, BATTERY_VOLTAGE_LSB_REG) voltage_bin = msb << 4 | lsb & 0x0f return voltage_bin * 1.1
[ "def", "battery_voltage", "(", "self", ")", ":", "msb", "=", "self", ".", "bus", ".", "read_byte_data", "(", "AXP209_ADDRESS", ",", "BATTERY_VOLTAGE_MSB_REG", ")", "lsb", "=", "self", ".", "bus", ".", "read_byte_data", "(", "AXP209_ADDRESS", ",", "BATTERY_VOLT...
Returns voltage in mV
[ "Returns", "voltage", "in", "mV" ]
train
https://github.com/artizirk/python-axp209/blob/dc48015b23ea3695bf1ee076355c96ea434b77e4/axp209.py#L189-L194
artizirk/python-axp209
axp209.py
AXP209.battery_charge_current
def battery_charge_current(self): """ Returns current in mA """ msb = self.bus.read_byte_data(AXP209_ADDRESS, BATTERY_CHARGE_CURRENT_MSB_REG) lsb = self.bus.read_byte_data(AXP209_ADDRESS, BATTERY_CHARGE_CURRENT_LSB_REG) # (12 bits) charge_bin = msb << 4 | lsb & 0x0f # 0 m...
python
def battery_charge_current(self): """ Returns current in mA """ msb = self.bus.read_byte_data(AXP209_ADDRESS, BATTERY_CHARGE_CURRENT_MSB_REG) lsb = self.bus.read_byte_data(AXP209_ADDRESS, BATTERY_CHARGE_CURRENT_LSB_REG) # (12 bits) charge_bin = msb << 4 | lsb & 0x0f # 0 m...
[ "def", "battery_charge_current", "(", "self", ")", ":", "msb", "=", "self", ".", "bus", ".", "read_byte_data", "(", "AXP209_ADDRESS", ",", "BATTERY_CHARGE_CURRENT_MSB_REG", ")", "lsb", "=", "self", ".", "bus", ".", "read_byte_data", "(", "AXP209_ADDRESS", ",", ...
Returns current in mA
[ "Returns", "current", "in", "mA" ]
train
https://github.com/artizirk/python-axp209/blob/dc48015b23ea3695bf1ee076355c96ea434b77e4/axp209.py#L197-L204
artizirk/python-axp209
axp209.py
AXP209.battery_discharge_current
def battery_discharge_current(self): """ Returns current in mA """ msb = self.bus.read_byte_data(AXP209_ADDRESS, BATTERY_DISCHARGE_CURRENT_MSB_REG) lsb = self.bus.read_byte_data(AXP209_ADDRESS, BATTERY_DISCHARGE_CURRENT_LSB_REG) # 13bits discharge_bin = msb << 5 | lsb & 0x1f ...
python
def battery_discharge_current(self): """ Returns current in mA """ msb = self.bus.read_byte_data(AXP209_ADDRESS, BATTERY_DISCHARGE_CURRENT_MSB_REG) lsb = self.bus.read_byte_data(AXP209_ADDRESS, BATTERY_DISCHARGE_CURRENT_LSB_REG) # 13bits discharge_bin = msb << 5 | lsb & 0x1f ...
[ "def", "battery_discharge_current", "(", "self", ")", ":", "msb", "=", "self", ".", "bus", ".", "read_byte_data", "(", "AXP209_ADDRESS", ",", "BATTERY_DISCHARGE_CURRENT_MSB_REG", ")", "lsb", "=", "self", ".", "bus", ".", "read_byte_data", "(", "AXP209_ADDRESS", ...
Returns current in mA
[ "Returns", "current", "in", "mA" ]
train
https://github.com/artizirk/python-axp209/blob/dc48015b23ea3695bf1ee076355c96ea434b77e4/axp209.py#L207-L214
artizirk/python-axp209
axp209.py
AXP209.internal_temperature
def internal_temperature(self): """ Returns temperature in celsius C """ temp_msb = self.bus.read_byte_data(AXP209_ADDRESS, INTERNAL_TEMPERATURE_MSB_REG) temp_lsb = self.bus.read_byte_data(AXP209_ADDRESS, INTERNAL_TEMPERATURE_LSB_REG) # MSB is 8 bits, LSB is lower 4 bits temp = t...
python
def internal_temperature(self): """ Returns temperature in celsius C """ temp_msb = self.bus.read_byte_data(AXP209_ADDRESS, INTERNAL_TEMPERATURE_MSB_REG) temp_lsb = self.bus.read_byte_data(AXP209_ADDRESS, INTERNAL_TEMPERATURE_LSB_REG) # MSB is 8 bits, LSB is lower 4 bits temp = t...
[ "def", "internal_temperature", "(", "self", ")", ":", "temp_msb", "=", "self", ".", "bus", ".", "read_byte_data", "(", "AXP209_ADDRESS", ",", "INTERNAL_TEMPERATURE_MSB_REG", ")", "temp_lsb", "=", "self", ".", "bus", ".", "read_byte_data", "(", "AXP209_ADDRESS", ...
Returns temperature in celsius C
[ "Returns", "temperature", "in", "celsius", "C" ]
train
https://github.com/artizirk/python-axp209/blob/dc48015b23ea3695bf1ee076355c96ea434b77e4/axp209.py#L217-L224
TheOneHyer/arandomness
build/lib.linux-x86_64-3.6/arandomness/files/copen.py
copen
def copen(fileobj, mode='rb', **kwargs): """Detects and opens compressed file for reading and writing. Args: fileobj (File): any File-like object supported by an underlying compression algorithm mode (unicode): mode to open fileobj with **kwargs: keyword-argume...
python
def copen(fileobj, mode='rb', **kwargs): """Detects and opens compressed file for reading and writing. Args: fileobj (File): any File-like object supported by an underlying compression algorithm mode (unicode): mode to open fileobj with **kwargs: keyword-argume...
[ "def", "copen", "(", "fileobj", ",", "mode", "=", "'rb'", ",", "*", "*", "kwargs", ")", ":", "algo", "=", "io", ".", "open", "# Only used as io.open in write mode", "mode", "=", "mode", ".", "lower", "(", ")", ".", "strip", "(", ")", "modules", "=", ...
Detects and opens compressed file for reading and writing. Args: fileobj (File): any File-like object supported by an underlying compression algorithm mode (unicode): mode to open fileobj with **kwargs: keyword-arguments to pass to the compression algorithm Re...
[ "Detects", "and", "opens", "compressed", "file", "for", "reading", "and", "writing", "." ]
train
https://github.com/TheOneHyer/arandomness/blob/ae9f630e9a1d67b0eb6d61644a49756de8a5268c/build/lib.linux-x86_64-3.6/arandomness/files/copen.py#L41-L147
rackerlabs/rackspace-python-neutronclient
neutronclient/neutron/v2_0/securitygroup.py
ListSecurityGroupRule._get_sg_name_dict
def _get_sg_name_dict(self, data, page_size, no_nameconv): """Get names of security groups referred in the retrieved rules. :return: a dict from secgroup ID to secgroup name """ if no_nameconv: return {} neutron_client = self.get_client() search_opts = {'fiel...
python
def _get_sg_name_dict(self, data, page_size, no_nameconv): """Get names of security groups referred in the retrieved rules. :return: a dict from secgroup ID to secgroup name """ if no_nameconv: return {} neutron_client = self.get_client() search_opts = {'fiel...
[ "def", "_get_sg_name_dict", "(", "self", ",", "data", ",", "page_size", ",", "no_nameconv", ")", ":", "if", "no_nameconv", ":", "return", "{", "}", "neutron_client", "=", "self", ".", "get_client", "(", ")", "search_opts", "=", "{", "'fields'", ":", "[", ...
Get names of security groups referred in the retrieved rules. :return: a dict from secgroup ID to secgroup name
[ "Get", "names", "of", "security", "groups", "referred", "in", "the", "retrieved", "rules", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/neutron/v2_0/securitygroup.py#L215-L258
jmgilman/Neolib
neolib/user/Bank.py
Bank.load
def load(self): """ Loads the user's account details and Raises parseException """ pg = self.usr.getPage("http://www.neopets.com/bank.phtml") # Verifies account exists if not "great to see you again" in pg.content: logging.getL...
python
def load(self): """ Loads the user's account details and Raises parseException """ pg = self.usr.getPage("http://www.neopets.com/bank.phtml") # Verifies account exists if not "great to see you again" in pg.content: logging.getL...
[ "def", "load", "(", "self", ")", ":", "pg", "=", "self", ".", "usr", ".", "getPage", "(", "\"http://www.neopets.com/bank.phtml\"", ")", "# Verifies account exists", "if", "not", "\"great to see you again\"", "in", "pg", ".", "content", ":", "logging", ".", "getL...
Loads the user's account details and Raises parseException
[ "Loads", "the", "user", "s", "account", "details", "and", "Raises", "parseException" ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/user/Bank.py#L51-L64
jmgilman/Neolib
neolib/user/Bank.py
Bank.deposit
def deposit(self, amount): """ Deposits specified neopoints into the user's account, returns result Parameters: amount (int) -- Amount of neopoints to deposit Returns bool - True if successful, False otherwise Raises no...
python
def deposit(self, amount): """ Deposits specified neopoints into the user's account, returns result Parameters: amount (int) -- Amount of neopoints to deposit Returns bool - True if successful, False otherwise Raises no...
[ "def", "deposit", "(", "self", ",", "amount", ")", ":", "pg", "=", "self", ".", "usr", ".", "getPage", "(", "\"http://www.neopets.com/bank.phtml\"", ")", "if", "self", ".", "usr", ".", "nps", "<", "int", "(", "amount", ")", ":", "raise", "notEnoughNps", ...
Deposits specified neopoints into the user's account, returns result Parameters: amount (int) -- Amount of neopoints to deposit Returns bool - True if successful, False otherwise Raises notEnoughNps
[ "Deposits", "specified", "neopoints", "into", "the", "user", "s", "account", "returns", "result", "Parameters", ":", "amount", "(", "int", ")", "--", "Amount", "of", "neopoints", "to", "deposit", "Returns", "bool", "-", "True", "if", "successful", "False", "...
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/user/Bank.py#L66-L94
jmgilman/Neolib
neolib/user/Bank.py
Bank.withdraw
def withdraw(self, amount): """ Withdraws specified neopoints from the user's account, returns result Parameters: amount (int) -- Amount of neopoints to withdraw Returns bool - True if successful, False otherwise Raises ...
python
def withdraw(self, amount): """ Withdraws specified neopoints from the user's account, returns result Parameters: amount (int) -- Amount of neopoints to withdraw Returns bool - True if successful, False otherwise Raises ...
[ "def", "withdraw", "(", "self", ",", "amount", ")", ":", "pg", "=", "self", ".", "usr", ".", "getPage", "(", "\"http://www.neopets.com/bank.phtml\"", ")", "try", ":", "results", "=", "pg", ".", "find", "(", "text", "=", "\"Account Type:\"", ")", ".", "pa...
Withdraws specified neopoints from the user's account, returns result Parameters: amount (int) -- Amount of neopoints to withdraw Returns bool - True if successful, False otherwise Raises notEnoughBalance
[ "Withdraws", "specified", "neopoints", "from", "the", "user", "s", "account", "returns", "result", "Parameters", ":", "amount", "(", "int", ")", "--", "Amount", "of", "neopoints", "to", "withdraw", "Returns", "bool", "-", "True", "if", "successful", "False", ...
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/user/Bank.py#L96-L130
jmgilman/Neolib
neolib/user/Bank.py
Bank.collectInterest
def collectInterest(self): """ Collects user's daily interest, returns result Returns bool - True if successful, False otherwise """ if self.collectedInterest: return False pg = self.usr.getPage("http://www.neopets.com/bank.phtml") ...
python
def collectInterest(self): """ Collects user's daily interest, returns result Returns bool - True if successful, False otherwise """ if self.collectedInterest: return False pg = self.usr.getPage("http://www.neopets.com/bank.phtml") ...
[ "def", "collectInterest", "(", "self", ")", ":", "if", "self", ".", "collectedInterest", ":", "return", "False", "pg", "=", "self", ".", "usr", ".", "getPage", "(", "\"http://www.neopets.com/bank.phtml\"", ")", "form", "=", "pg", ".", "form", "(", "action", ...
Collects user's daily interest, returns result Returns bool - True if successful, False otherwise
[ "Collects", "user", "s", "daily", "interest", "returns", "result", "Returns", "bool", "-", "True", "if", "successful", "False", "otherwise" ]
train
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/user/Bank.py#L132-L153
svasilev94/GraphLibrary
graphlibrary/prim.py
connected_components
def connected_components(G): """ Check if G is connected and return list of sets. Every set contains all vertices in one connected component. """ result = [] vertices = set(G.vertices) while vertices: n = vertices.pop() group = {n} queue = Queue() q...
python
def connected_components(G): """ Check if G is connected and return list of sets. Every set contains all vertices in one connected component. """ result = [] vertices = set(G.vertices) while vertices: n = vertices.pop() group = {n} queue = Queue() q...
[ "def", "connected_components", "(", "G", ")", ":", "result", "=", "[", "]", "vertices", "=", "set", "(", "G", ".", "vertices", ")", "while", "vertices", ":", "n", "=", "vertices", ".", "pop", "(", ")", "group", "=", "{", "n", "}", "queue", "=", "...
Check if G is connected and return list of sets. Every set contains all vertices in one connected component.
[ "Check", "if", "G", "is", "connected", "and", "return", "list", "of", "sets", ".", "Every", "set", "contains", "all", "vertices", "in", "one", "connected", "component", "." ]
train
https://github.com/svasilev94/GraphLibrary/blob/bf979a80bdea17eeb25955f0c119ca8f711ef62b/graphlibrary/prim.py#L8-L29
svasilev94/GraphLibrary
graphlibrary/prim.py
prim
def prim(G, start, weight='weight'): """ Algorithm for finding a minimum spanning tree for a weighted undirected graph. """ if len(connected_components(G)) != 1: raise GraphInsertError("Prim algorithm work with connected graph only") if start not in G.vertices: raise Grap...
python
def prim(G, start, weight='weight'): """ Algorithm for finding a minimum spanning tree for a weighted undirected graph. """ if len(connected_components(G)) != 1: raise GraphInsertError("Prim algorithm work with connected graph only") if start not in G.vertices: raise Grap...
[ "def", "prim", "(", "G", ",", "start", ",", "weight", "=", "'weight'", ")", ":", "if", "len", "(", "connected_components", "(", "G", ")", ")", "!=", "1", ":", "raise", "GraphInsertError", "(", "\"Prim algorithm work with connected graph only\"", ")", "if", "...
Algorithm for finding a minimum spanning tree for a weighted undirected graph.
[ "Algorithm", "for", "finding", "a", "minimum", "spanning", "tree", "for", "a", "weighted", "undirected", "graph", "." ]
train
https://github.com/svasilev94/GraphLibrary/blob/bf979a80bdea17eeb25955f0c119ca8f711ef62b/graphlibrary/prim.py#L43-L73
rgmining/ria
ria/one.py
BipartiteGraph.update
def update(self): """Update reviewers' anomalous scores and products' summaries. Returns: maximum absolute difference between old summary and new one, and old anomalous score and new one. """ if self.updated: return 0 res = super(BipartiteGraph, ...
python
def update(self): """Update reviewers' anomalous scores and products' summaries. Returns: maximum absolute difference between old summary and new one, and old anomalous score and new one. """ if self.updated: return 0 res = super(BipartiteGraph, ...
[ "def", "update", "(", "self", ")", ":", "if", "self", ".", "updated", ":", "return", "0", "res", "=", "super", "(", "BipartiteGraph", ",", "self", ")", ".", "update", "(", ")", "self", ".", "updated", "=", "True", "return", "res" ]
Update reviewers' anomalous scores and products' summaries. Returns: maximum absolute difference between old summary and new one, and old anomalous score and new one.
[ "Update", "reviewers", "anomalous", "scores", "and", "products", "summaries", "." ]
train
https://github.com/rgmining/ria/blob/39223c67b7e59e10bd8e3a9062fb13f8bf893a5d/ria/one.py#L43-L55
robertdfrench/psychic-disco
psychic_disco/rest_api.py
RestApi.find
def find(cls, api_name): """ Find or create an API model object by name """ if api_name in cls.apis_by_name: return cls.apis_by_name[api_name] api = cls(api_name) api._fetch_from_aws() if api.exists_in_aws: api._fetch_resources() cls.apis_by_name[a...
python
def find(cls, api_name): """ Find or create an API model object by name """ if api_name in cls.apis_by_name: return cls.apis_by_name[api_name] api = cls(api_name) api._fetch_from_aws() if api.exists_in_aws: api._fetch_resources() cls.apis_by_name[a...
[ "def", "find", "(", "cls", ",", "api_name", ")", ":", "if", "api_name", "in", "cls", ".", "apis_by_name", ":", "return", "cls", ".", "apis_by_name", "[", "api_name", "]", "api", "=", "cls", "(", "api_name", ")", "api", ".", "_fetch_from_aws", "(", ")",...
Find or create an API model object by name
[ "Find", "or", "create", "an", "API", "model", "object", "by", "name" ]
train
https://github.com/robertdfrench/psychic-disco/blob/3cf167b44c64d64606691fc186be7d9ef8e8e938/psychic_disco/rest_api.py#L20-L29
hapylestat/apputils
apputils/settings/general.py
get_instance
def get_instance(in_memory=False, config_path=None, config_name=None): """ :arg in_memory Initialize Configuration instance in memory only :type in_memory bool :type config_path str :type config_name str :rtype Configuration :return Configuration """ global __conf if __conf is None: __conf = Co...
python
def get_instance(in_memory=False, config_path=None, config_name=None): """ :arg in_memory Initialize Configuration instance in memory only :type in_memory bool :type config_path str :type config_name str :rtype Configuration :return Configuration """ global __conf if __conf is None: __conf = Co...
[ "def", "get_instance", "(", "in_memory", "=", "False", ",", "config_path", "=", "None", ",", "config_name", "=", "None", ")", ":", "global", "__conf", "if", "__conf", "is", "None", ":", "__conf", "=", "Configuration", "(", "in_memory", "=", "in_memory", ",...
:arg in_memory Initialize Configuration instance in memory only :type in_memory bool :type config_path str :type config_name str :rtype Configuration :return Configuration
[ ":", "arg", "in_memory", "Initialize", "Configuration", "instance", "in", "memory", "only", ":", "type", "in_memory", "bool", ":", "type", "config_path", "str", ":", "type", "config_name", "str", ":", "rtype", "Configuration", ":", "return", "Configuration" ]
train
https://github.com/hapylestat/apputils/blob/5d185616feda27e6e21273307161471ef11a3518/apputils/settings/general.py#L204-L218
hapylestat/apputils
apputils/settings/general.py
Configuration._load_from_configs
def _load_from_configs(self, filename): """ Return content of file which located in configuration directory """ config_filename = os.path.join(self._config_path, filename) if os.path.exists(config_filename): try: f = open(config_filename, 'r') content = ''.join(f.readlines()) ...
python
def _load_from_configs(self, filename): """ Return content of file which located in configuration directory """ config_filename = os.path.join(self._config_path, filename) if os.path.exists(config_filename): try: f = open(config_filename, 'r') content = ''.join(f.readlines()) ...
[ "def", "_load_from_configs", "(", "self", ",", "filename", ")", ":", "config_filename", "=", "os", ".", "path", ".", "join", "(", "self", ".", "_config_path", ",", "filename", ")", "if", "os", ".", "path", ".", "exists", "(", "config_filename", ")", ":",...
Return content of file which located in configuration directory
[ "Return", "content", "of", "file", "which", "located", "in", "configuration", "directory" ]
train
https://github.com/hapylestat/apputils/blob/5d185616feda27e6e21273307161471ef11a3518/apputils/settings/general.py#L70-L84
hapylestat/apputils
apputils/settings/general.py
Configuration.load
def load(self): """ Load application configuration """ try: if not self.__in_memory: self._json = json.loads(self._load_from_configs(self._main_config)) # ToDo: make this via extension for root logger # self._log = aLogger.getLogger(__name__, cfg=self) # reload logger usi...
python
def load(self): """ Load application configuration """ try: if not self.__in_memory: self._json = json.loads(self._load_from_configs(self._main_config)) # ToDo: make this via extension for root logger # self._log = aLogger.getLogger(__name__, cfg=self) # reload logger usi...
[ "def", "load", "(", "self", ")", ":", "try", ":", "if", "not", "self", ".", "__in_memory", ":", "self", ".", "_json", "=", "json", ".", "loads", "(", "self", ".", "_load_from_configs", "(", "self", ".", "_main_config", ")", ")", "# ToDo: make this via ex...
Load application configuration
[ "Load", "application", "configuration" ]
train
https://github.com/hapylestat/apputils/blob/5d185616feda27e6e21273307161471ef11a3518/apputils/settings/general.py#L86-L102
hapylestat/apputils
apputils/settings/general.py
Configuration._load_modules
def _load_modules(self): """ Load modules-related configuration listened in modules section Before loading: "modules": { "mal": "myanimelist.json", "ann": "animenewsnetwork.json" } After loading: "modules": { "mal": { .... }, "ann": { ...
python
def _load_modules(self): """ Load modules-related configuration listened in modules section Before loading: "modules": { "mal": "myanimelist.json", "ann": "animenewsnetwork.json" } After loading: "modules": { "mal": { .... }, "ann": { ...
[ "def", "_load_modules", "(", "self", ")", ":", "if", "self", ".", "exists", "(", "\"modules\"", ")", ":", "for", "item", "in", "self", ".", "_json", "[", "\"modules\"", "]", ":", "try", ":", "json_data", "=", "json", ".", "loads", "(", "self", ".", ...
Load modules-related configuration listened in modules section Before loading: "modules": { "mal": "myanimelist.json", "ann": "animenewsnetwork.json" } After loading: "modules": { "mal": { .... }, "ann": { .... } }
[ "Load", "modules", "-", "related", "configuration", "listened", "in", "modules", "section", "Before", "loading", ":", "modules", ":", "{", "mal", ":", "myanimelist", ".", "json", "ann", ":", "animenewsnetwork", ".", "json", "}", "After", "loading", ":", "mod...
train
https://github.com/hapylestat/apputils/blob/5d185616feda27e6e21273307161471ef11a3518/apputils/settings/general.py#L104-L128
hapylestat/apputils
apputils/settings/general.py
Configuration.exists
def exists(self, path): """ Check for property existence :param path: path to the property with name including :return: """ if self._json is None: return False node = self._json path_arr = path.split('.') while len(path_arr) > 0: path_item = path_arr.pop(0) if path...
python
def exists(self, path): """ Check for property existence :param path: path to the property with name including :return: """ if self._json is None: return False node = self._json path_arr = path.split('.') while len(path_arr) > 0: path_item = path_arr.pop(0) if path...
[ "def", "exists", "(", "self", ",", "path", ")", ":", "if", "self", ".", "_json", "is", "None", ":", "return", "False", "node", "=", "self", ".", "_json", "path_arr", "=", "path", ".", "split", "(", "'.'", ")", "while", "len", "(", "path_arr", ")", ...
Check for property existence :param path: path to the property with name including :return:
[ "Check", "for", "property", "existence", ":", "param", "path", ":", "path", "to", "the", "property", "with", "name", "including", ":", "return", ":" ]
train
https://github.com/hapylestat/apputils/blob/5d185616feda27e6e21273307161471ef11a3518/apputils/settings/general.py#L134-L154
hapylestat/apputils
apputils/settings/general.py
Configuration.get
def get(self, path, default=None, check_type=None, module_name=None): """ Get option property :param path: full path to the property with name :param default: default value if original is not present :param check_type: cast param to passed type, if fail, default will returned :param module_name...
python
def get(self, path, default=None, check_type=None, module_name=None): """ Get option property :param path: full path to the property with name :param default: default value if original is not present :param check_type: cast param to passed type, if fail, default will returned :param module_name...
[ "def", "get", "(", "self", ",", "path", ",", "default", "=", "None", ",", "check_type", "=", "None", ",", "module_name", "=", "None", ")", ":", "if", "self", ".", "_json", "is", "not", "None", ":", "# process whole json or just concrete module", "node", "=...
Get option property :param path: full path to the property with name :param default: default value if original is not present :param check_type: cast param to passed type, if fail, default will returned :param module_name: get property from module name :return:
[ "Get", "option", "property" ]
train
https://github.com/hapylestat/apputils/blob/5d185616feda27e6e21273307161471ef11a3518/apputils/settings/general.py#L156-L189
hapylestat/apputils
apputils/settings/general.py
Configuration.get_module_config
def get_module_config(self, name): """ Return module configuration loaded from separate file or None """ if self.exists("modules"): if name in self._json["modules"] and not isinstance(self._json["modules"][name], str): return self._json["modules"][name] return None
python
def get_module_config(self, name): """ Return module configuration loaded from separate file or None """ if self.exists("modules"): if name in self._json["modules"] and not isinstance(self._json["modules"][name], str): return self._json["modules"][name] return None
[ "def", "get_module_config", "(", "self", ",", "name", ")", ":", "if", "self", ".", "exists", "(", "\"modules\"", ")", ":", "if", "name", "in", "self", ".", "_json", "[", "\"modules\"", "]", "and", "not", "isinstance", "(", "self", ".", "_json", "[", ...
Return module configuration loaded from separate file or None
[ "Return", "module", "configuration", "loaded", "from", "separate", "file", "or", "None" ]
train
https://github.com/hapylestat/apputils/blob/5d185616feda27e6e21273307161471ef11a3518/apputils/settings/general.py#L191-L198
naphatkrit/easyci
easyci/hooks/hooks_manager.py
get_hook
def get_hook(hook_name): """Returns the specified hook. Args: hook_name (str) Returns: str - (the content of) the hook Raises: HookNotFoundError """ if not pkg_resources.resource_exists(__name__, hook_name): raise HookNotFoundError return pkg_resources.reso...
python
def get_hook(hook_name): """Returns the specified hook. Args: hook_name (str) Returns: str - (the content of) the hook Raises: HookNotFoundError """ if not pkg_resources.resource_exists(__name__, hook_name): raise HookNotFoundError return pkg_resources.reso...
[ "def", "get_hook", "(", "hook_name", ")", ":", "if", "not", "pkg_resources", ".", "resource_exists", "(", "__name__", ",", "hook_name", ")", ":", "raise", "HookNotFoundError", "return", "pkg_resources", ".", "resource_string", "(", "__name__", ",", "hook_name", ...
Returns the specified hook. Args: hook_name (str) Returns: str - (the content of) the hook Raises: HookNotFoundError
[ "Returns", "the", "specified", "hook", "." ]
train
https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/hooks/hooks_manager.py#L8-L22
Othernet-Project/conz
conz/progress.py
Progress.end
def end(self, s=None, post=None, noraise=False): """ Prints the end banner and raises ``ProgressOK`` exception When ``noraise`` flag is set to ``True``, then the exception is not raised, and progress is allowed to continue. If ``post`` function is supplied it is invoked with no argumen...
python
def end(self, s=None, post=None, noraise=False): """ Prints the end banner and raises ``ProgressOK`` exception When ``noraise`` flag is set to ``True``, then the exception is not raised, and progress is allowed to continue. If ``post`` function is supplied it is invoked with no argumen...
[ "def", "end", "(", "self", ",", "s", "=", "None", ",", "post", "=", "None", ",", "noraise", "=", "False", ")", ":", "s", "=", "s", "or", "self", ".", "end_msg", "self", ".", "printer", "(", "self", ".", "color", ".", "green", "(", "s", ")", "...
Prints the end banner and raises ``ProgressOK`` exception When ``noraise`` flag is set to ``True``, then the exception is not raised, and progress is allowed to continue. If ``post`` function is supplied it is invoked with no arguments after the close banner is printed, but before exce...
[ "Prints", "the", "end", "banner", "and", "raises", "ProgressOK", "exception" ]
train
https://github.com/Othernet-Project/conz/blob/051214fa95a837c21595b03426a2c54c522d07a0/conz/progress.py#L55-L71
Othernet-Project/conz
conz/progress.py
Progress.abrt
def abrt(self, s=None, post=None, noraise=False): """ Prints the abrt banner and raises ``ProgressAbrt`` exception When ``noraise`` flag is set to ``True``, then the exception is not raised, and progress is allowed to continue. If ``post`` function is supplied it is invoked with no arg...
python
def abrt(self, s=None, post=None, noraise=False): """ Prints the abrt banner and raises ``ProgressAbrt`` exception When ``noraise`` flag is set to ``True``, then the exception is not raised, and progress is allowed to continue. If ``post`` function is supplied it is invoked with no arg...
[ "def", "abrt", "(", "self", ",", "s", "=", "None", ",", "post", "=", "None", ",", "noraise", "=", "False", ")", ":", "s", "=", "s", "or", "self", ".", "abrt_msg", "self", ".", "printer", "(", "self", ".", "color", ".", "red", "(", "s", ")", "...
Prints the abrt banner and raises ``ProgressAbrt`` exception When ``noraise`` flag is set to ``True``, then the exception is not raised, and progress is allowed to continue. If ``post`` function is supplied it is invoked with no arguments after the close banner is printed, but before e...
[ "Prints", "the", "abrt", "banner", "and", "raises", "ProgressAbrt", "exception" ]
train
https://github.com/Othernet-Project/conz/blob/051214fa95a837c21595b03426a2c54c522d07a0/conz/progress.py#L73-L89
Othernet-Project/conz
conz/progress.py
Progress.prog
def prog(self, s=None): """ Prints the progress indicator """ s = s or self.prog_msg self.printer(s, end='')
python
def prog(self, s=None): """ Prints the progress indicator """ s = s or self.prog_msg self.printer(s, end='')
[ "def", "prog", "(", "self", ",", "s", "=", "None", ")", ":", "s", "=", "s", "or", "self", ".", "prog_msg", "self", ".", "printer", "(", "s", ",", "end", "=", "''", ")" ]
Prints the progress indicator
[ "Prints", "the", "progress", "indicator" ]
train
https://github.com/Othernet-Project/conz/blob/051214fa95a837c21595b03426a2c54c522d07a0/conz/progress.py#L91-L94
ECESeniorDesign/lazy_record
lazy_record/repo.py
Repo.where
def where(self, custom_restrictions=[], **restrictions): """ Analog to SQL "WHERE". Does not perform a query until `select` is called. Returns a repo object. Options selected through keyword arguments are assumed to use == unles the value is a list, tuple, or dictionary. List or ...
python
def where(self, custom_restrictions=[], **restrictions): """ Analog to SQL "WHERE". Does not perform a query until `select` is called. Returns a repo object. Options selected through keyword arguments are assumed to use == unles the value is a list, tuple, or dictionary. List or ...
[ "def", "where", "(", "self", ",", "custom_restrictions", "=", "[", "]", ",", "*", "*", "restrictions", ")", ":", "# Generate the SQL pieces and the relevant values", "standard_names", ",", "standard_values", "=", "self", ".", "_standard_items", "(", "restrictions", ...
Analog to SQL "WHERE". Does not perform a query until `select` is called. Returns a repo object. Options selected through keyword arguments are assumed to use == unles the value is a list, tuple, or dictionary. List or tuple values translate to an SQL `IN` over those values, and a dictio...
[ "Analog", "to", "SQL", "WHERE", ".", "Does", "not", "perform", "a", "query", "until", "select", "is", "called", ".", "Returns", "a", "repo", "object", ".", "Options", "selected", "through", "keyword", "arguments", "are", "assumed", "to", "use", "==", "unle...
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/repo.py#L34-L61
ECESeniorDesign/lazy_record
lazy_record/repo.py
Repo._in_items
def _in_items(self, restrictions): """Generate argument pairs for queries like where(id=[1, 2])""" def build_in(table, name, value): return "{}.{} IN ({})".format(table, name, ", ".join(["?"] * len(value))) in_items = self._build_where(restr...
python
def _in_items(self, restrictions): """Generate argument pairs for queries like where(id=[1, 2])""" def build_in(table, name, value): return "{}.{} IN ({})".format(table, name, ", ".join(["?"] * len(value))) in_items = self._build_where(restr...
[ "def", "_in_items", "(", "self", ",", "restrictions", ")", ":", "def", "build_in", "(", "table", ",", "name", ",", "value", ")", ":", "return", "\"{}.{} IN ({})\"", ".", "format", "(", "table", ",", "name", ",", "\", \"", ".", "join", "(", "[", "\"?\""...
Generate argument pairs for queries like where(id=[1, 2])
[ "Generate", "argument", "pairs", "for", "queries", "like", "where", "(", "id", "=", "[", "1", "2", "]", ")" ]
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/repo.py#L63-L72
ECESeniorDesign/lazy_record
lazy_record/repo.py
Repo._custom_items
def _custom_items(self, restrictions): """Generate argument pairs for queries like where("id > ?", 7)""" def scope_name(query, table): # The first entry in the query is the column # If the column already has a ".", that means that the table has # already been chosen ...
python
def _custom_items(self, restrictions): """Generate argument pairs for queries like where("id > ?", 7)""" def scope_name(query, table): # The first entry in the query is the column # If the column already has a ".", that means that the table has # already been chosen ...
[ "def", "_custom_items", "(", "self", ",", "restrictions", ")", ":", "def", "scope_name", "(", "query", ",", "table", ")", ":", "# The first entry in the query is the column", "# If the column already has a \".\", that means that the table has", "# already been chosen", "for", ...
Generate argument pairs for queries like where("id > ?", 7)
[ "Generate", "argument", "pairs", "for", "queries", "like", "where", "(", "id", ">", "?", "7", ")" ]
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/repo.py#L74-L91
ECESeniorDesign/lazy_record
lazy_record/repo.py
Repo._standard_items
def _standard_items(self, restrictions): """Generate argument pairs for queries like where(id=2)""" standard_items = self._build_where(restrictions, for_in=False) names = ["{}.{} == ?".format(pair[0], pair[1]) for pair in standard_items] values = [item[2] for item in sta...
python
def _standard_items(self, restrictions): """Generate argument pairs for queries like where(id=2)""" standard_items = self._build_where(restrictions, for_in=False) names = ["{}.{} == ?".format(pair[0], pair[1]) for pair in standard_items] values = [item[2] for item in sta...
[ "def", "_standard_items", "(", "self", ",", "restrictions", ")", ":", "standard_items", "=", "self", ".", "_build_where", "(", "restrictions", ",", "for_in", "=", "False", ")", "names", "=", "[", "\"{}.{} == ?\"", ".", "format", "(", "pair", "[", "0", "]",...
Generate argument pairs for queries like where(id=2)
[ "Generate", "argument", "pairs", "for", "queries", "like", "where", "(", "id", "=", "2", ")" ]
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/repo.py#L93-L99
ECESeniorDesign/lazy_record
lazy_record/repo.py
Repo.inner_join
def inner_join(self, *joiners): """ Analog to SQL "INNER JOIN". +joiners+ is a list with entries of the form: { 'table': <table_name>, 'on': [<foreign_key>, <local_id>] } Example: >>> Repo('bs').inner_join( {'table': 'cs', on...
python
def inner_join(self, *joiners): """ Analog to SQL "INNER JOIN". +joiners+ is a list with entries of the form: { 'table': <table_name>, 'on': [<foreign_key>, <local_id>] } Example: >>> Repo('bs').inner_join( {'table': 'cs', on...
[ "def", "inner_join", "(", "self", ",", "*", "joiners", ")", ":", "def", "inner_joins", "(", "js", ",", "current_table", ")", ":", "for", "joiner", "in", "js", ":", "yield", "(", "(", "(", "current_table", ",", "joiner", "[", "'on'", "]", "[", "1", ...
Analog to SQL "INNER JOIN". +joiners+ is a list with entries of the form: { 'table': <table_name>, 'on': [<foreign_key>, <local_id>] } Example: >>> Repo('bs').inner_join( {'table': 'cs', on: ['b_id', 'id']}).select("*") SELECT bs.* F...
[ "Analog", "to", "SQL", "INNER", "JOIN", ".", "+", "joiners", "+", "is", "a", "list", "with", "entries", "of", "the", "form", ":" ]
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/repo.py#L115-L138
ECESeniorDesign/lazy_record
lazy_record/repo.py
Repo.order_by
def order_by(self, **kwargs): """ Analog to SQL "ORDER BY". +kwargs+ should only contain one item. examples) NO: repo.order_by() NO: repo.order_by(id="desc", name="asc") YES: repo.order_by(id="asc) """ if kwargs: col, order = kwargs.popite...
python
def order_by(self, **kwargs): """ Analog to SQL "ORDER BY". +kwargs+ should only contain one item. examples) NO: repo.order_by() NO: repo.order_by(id="desc", name="asc") YES: repo.order_by(id="asc) """ if kwargs: col, order = kwargs.popite...
[ "def", "order_by", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ":", "col", ",", "order", "=", "kwargs", ".", "popitem", "(", ")", "self", ".", "order_clause", "=", "\"order by {col} {order} \"", ".", "format", "(", "col", "=", "col"...
Analog to SQL "ORDER BY". +kwargs+ should only contain one item. examples) NO: repo.order_by() NO: repo.order_by(id="desc", name="asc") YES: repo.order_by(id="asc)
[ "Analog", "to", "SQL", "ORDER", "BY", ".", "+", "kwargs", "+", "should", "only", "contain", "one", "item", "." ]
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/repo.py#L140-L155
ECESeniorDesign/lazy_record
lazy_record/repo.py
Repo.select
def select(self, *attributes): """ Select the passed +attributes+ from the table, subject to the restrictions provided by the other methods in this class. ex) >>> Repo("foos").select("name", "id") SELECT foos.name, foos.id FROM foos """ namespaced_attrib...
python
def select(self, *attributes): """ Select the passed +attributes+ from the table, subject to the restrictions provided by the other methods in this class. ex) >>> Repo("foos").select("name", "id") SELECT foos.name, foos.id FROM foos """ namespaced_attrib...
[ "def", "select", "(", "self", ",", "*", "attributes", ")", ":", "namespaced_attributes", "=", "[", "\"{table}.{attr}\"", ".", "format", "(", "table", "=", "self", ".", "table_name", ",", "attr", "=", "attr", ")", "for", "attr", "in", "attributes", "]", "...
Select the passed +attributes+ from the table, subject to the restrictions provided by the other methods in this class. ex) >>> Repo("foos").select("name", "id") SELECT foos.name, foos.id FROM foos
[ "Select", "the", "passed", "+", "attributes", "+", "from", "the", "table", "subject", "to", "the", "restrictions", "provided", "by", "the", "other", "methods", "in", "this", "class", "." ]
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/repo.py#L197-L224
ECESeniorDesign/lazy_record
lazy_record/repo.py
Repo.count
def count(self): """ Count the number of records in the table, subject to the query. """ cmd = ("select COUNT(*) from {table} " "{join_clause}{where_clause}{order_clause}").format( table=self.table_name, where_clause=self.where_claus...
python
def count(self): """ Count the number of records in the table, subject to the query. """ cmd = ("select COUNT(*) from {table} " "{join_clause}{where_clause}{order_clause}").format( table=self.table_name, where_clause=self.where_claus...
[ "def", "count", "(", "self", ")", ":", "cmd", "=", "(", "\"select COUNT(*) from {table} \"", "\"{join_clause}{where_clause}{order_clause}\"", ")", ".", "format", "(", "table", "=", "self", ".", "table_name", ",", "where_clause", "=", "self", ".", "where_clause", "...
Count the number of records in the table, subject to the query.
[ "Count", "the", "number", "of", "records", "in", "the", "table", "subject", "to", "the", "query", "." ]
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/repo.py#L226-L236
ECESeniorDesign/lazy_record
lazy_record/repo.py
Repo.insert
def insert(self, **data): """ Insert the passed +data+ into the table. Raises Invalid if a where clause is present (i.e. no INSERT INTO table WHERE) """ if self.where_clause: raise Invalid("Cannot insert with 'where' clause.") # Ensure that order is preserved ...
python
def insert(self, **data): """ Insert the passed +data+ into the table. Raises Invalid if a where clause is present (i.e. no INSERT INTO table WHERE) """ if self.where_clause: raise Invalid("Cannot insert with 'where' clause.") # Ensure that order is preserved ...
[ "def", "insert", "(", "self", ",", "*", "*", "data", ")", ":", "if", "self", ".", "where_clause", ":", "raise", "Invalid", "(", "\"Cannot insert with 'where' clause.\"", ")", "# Ensure that order is preserved", "data", "=", "data", ".", "items", "(", ")", "cmd...
Insert the passed +data+ into the table. Raises Invalid if a where clause is present (i.e. no INSERT INTO table WHERE)
[ "Insert", "the", "passed", "+", "data", "+", "into", "the", "table", ".", "Raises", "Invalid", "if", "a", "where", "clause", "is", "present", "(", "i", ".", "e", ".", "no", "INSERT", "INTO", "table", "WHERE", ")" ]
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/repo.py#L238-L254
ECESeniorDesign/lazy_record
lazy_record/repo.py
Repo.update
def update(self, **data): """ Update records in the table with +data+. Often combined with `where`, as it acts on all records in the table unless restricted. ex) >>> Repo("foos").update(name="bar") UPDATE foos SET name = "bar" """ data = data.items() ...
python
def update(self, **data): """ Update records in the table with +data+. Often combined with `where`, as it acts on all records in the table unless restricted. ex) >>> Repo("foos").update(name="bar") UPDATE foos SET name = "bar" """ data = data.items() ...
[ "def", "update", "(", "self", ",", "*", "*", "data", ")", ":", "data", "=", "data", ".", "items", "(", ")", "update_command_arg", "=", "\", \"", ".", "join", "(", "\"{} = ?\"", ".", "format", "(", "entry", "[", "0", "]", ")", "for", "entry", "in", ...
Update records in the table with +data+. Often combined with `where`, as it acts on all records in the table unless restricted. ex) >>> Repo("foos").update(name="bar") UPDATE foos SET name = "bar"
[ "Update", "records", "in", "the", "table", "with", "+", "data", "+", ".", "Often", "combined", "with", "where", "as", "it", "acts", "on", "all", "records", "in", "the", "table", "unless", "restricted", "." ]
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/repo.py#L256-L273
ECESeniorDesign/lazy_record
lazy_record/repo.py
Repo.delete
def delete(self): """ Remove entries from the table. Often combined with `where`, as it acts on all records in the table unless restricted. """ cmd = "delete from {table} {where_clause}".format( table=self.table_name, where_clause=self.where_clause ...
python
def delete(self): """ Remove entries from the table. Often combined with `where`, as it acts on all records in the table unless restricted. """ cmd = "delete from {table} {where_clause}".format( table=self.table_name, where_clause=self.where_clause ...
[ "def", "delete", "(", "self", ")", ":", "cmd", "=", "\"delete from {table} {where_clause}\"", ".", "format", "(", "table", "=", "self", ".", "table_name", ",", "where_clause", "=", "self", ".", "where_clause", ")", ".", "rstrip", "(", ")", "Repo", ".", "db...
Remove entries from the table. Often combined with `where`, as it acts on all records in the table unless restricted.
[ "Remove", "entries", "from", "the", "table", ".", "Often", "combined", "with", "where", "as", "it", "acts", "on", "all", "records", "in", "the", "table", "unless", "restricted", "." ]
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/repo.py#L275-L284
ECESeniorDesign/lazy_record
lazy_record/repo.py
Repo.connect_db
def connect_db(Repo, database=":memory:"): """ Connect Repo to a database with path +database+ so all instances can interact with the database. """ Repo.db = sqlite3.connect(database, detect_types=sqlite3.PARSE_DECLTYPES) return Repo.db
python
def connect_db(Repo, database=":memory:"): """ Connect Repo to a database with path +database+ so all instances can interact with the database. """ Repo.db = sqlite3.connect(database, detect_types=sqlite3.PARSE_DECLTYPES) return Repo.db
[ "def", "connect_db", "(", "Repo", ",", "database", "=", "\":memory:\"", ")", ":", "Repo", ".", "db", "=", "sqlite3", ".", "connect", "(", "database", ",", "detect_types", "=", "sqlite3", ".", "PARSE_DECLTYPES", ")", "return", "Repo", ".", "db" ]
Connect Repo to a database with path +database+ so all instances can interact with the database.
[ "Connect", "Repo", "to", "a", "database", "with", "path", "+", "database", "+", "so", "all", "instances", "can", "interact", "with", "the", "database", "." ]
train
https://github.com/ECESeniorDesign/lazy_record/blob/929d3cc7c2538b0f792365c0d2b0e0d41084c2dd/lazy_record/repo.py#L294-L301
dcramer/peek
peek/tracer.py
Tracer._trace
def _trace(self, frame, event, arg_unused): """ The trace function passed to sys.settrace. """ cur_time = time.time() lineno = frame.f_lineno depth = self.depth filename = inspect.getfile(frame) if self.last_exc_back: if frame == self.last_e...
python
def _trace(self, frame, event, arg_unused): """ The trace function passed to sys.settrace. """ cur_time = time.time() lineno = frame.f_lineno depth = self.depth filename = inspect.getfile(frame) if self.last_exc_back: if frame == self.last_e...
[ "def", "_trace", "(", "self", ",", "frame", ",", "event", ",", "arg_unused", ")", ":", "cur_time", "=", "time", ".", "time", "(", ")", "lineno", "=", "frame", ".", "f_lineno", "depth", "=", "self", ".", "depth", "filename", "=", "inspect", ".", "getf...
The trace function passed to sys.settrace.
[ "The", "trace", "function", "passed", "to", "sys", ".", "settrace", "." ]
train
https://github.com/dcramer/peek/blob/da7c086660fc870c6632c4dc5ccb2ff9bfbee52e/peek/tracer.py#L153-L235
dcramer/peek
peek/tracer.py
Tracer.start
def start(self, origin): """ Start this Tracer. Return a Python function suitable for use with sys.settrace(). """ self.start_time = time.time() self.pause_until = None self.data.update(self._get_struct(origin, 'origin')) self.data_stack.append(self.data)...
python
def start(self, origin): """ Start this Tracer. Return a Python function suitable for use with sys.settrace(). """ self.start_time = time.time() self.pause_until = None self.data.update(self._get_struct(origin, 'origin')) self.data_stack.append(self.data)...
[ "def", "start", "(", "self", ",", "origin", ")", ":", "self", ".", "start_time", "=", "time", ".", "time", "(", ")", "self", ".", "pause_until", "=", "None", "self", ".", "data", ".", "update", "(", "self", ".", "_get_struct", "(", "origin", ",", "...
Start this Tracer. Return a Python function suitable for use with sys.settrace().
[ "Start", "this", "Tracer", "." ]
train
https://github.com/dcramer/peek/blob/da7c086660fc870c6632c4dc5ccb2ff9bfbee52e/peek/tracer.py#L237-L248
dcramer/peek
peek/tracer.py
Tracer.stop
def stop(self): """ Stop this Tracer. """ if hasattr(sys, "gettrace") and self.log: if sys.gettrace() != self._trace: msg = "Trace function changed, measurement is likely wrong: %r" print >> sys.stdout, msg % sys.gettrace() sys.settrace...
python
def stop(self): """ Stop this Tracer. """ if hasattr(sys, "gettrace") and self.log: if sys.gettrace() != self._trace: msg = "Trace function changed, measurement is likely wrong: %r" print >> sys.stdout, msg % sys.gettrace() sys.settrace...
[ "def", "stop", "(", "self", ")", ":", "if", "hasattr", "(", "sys", ",", "\"gettrace\"", ")", "and", "self", ".", "log", ":", "if", "sys", ".", "gettrace", "(", ")", "!=", "self", ".", "_trace", ":", "msg", "=", "\"Trace function changed, measurement is l...
Stop this Tracer.
[ "Stop", "this", "Tracer", "." ]
train
https://github.com/dcramer/peek/blob/da7c086660fc870c6632c4dc5ccb2ff9bfbee52e/peek/tracer.py#L250-L258
zzzsochi/resolver_deco
resolver_deco.py
resolver
def resolver(*for_resolve, attr_package='__package_for_resolve_deco__'): """ Resolve dotted names in function arguments Usage: >>> @resolver('obj') >>> def func(param, obj): >>> assert isinstance(param, str) >>> assert not isinstance(obj, str) >>> >>> fu...
python
def resolver(*for_resolve, attr_package='__package_for_resolve_deco__'): """ Resolve dotted names in function arguments Usage: >>> @resolver('obj') >>> def func(param, obj): >>> assert isinstance(param, str) >>> assert not isinstance(obj, str) >>> >>> fu...
[ "def", "resolver", "(", "*", "for_resolve", ",", "attr_package", "=", "'__package_for_resolve_deco__'", ")", ":", "def", "decorator", "(", "func", ")", ":", "spec", "=", "inspect", ".", "getargspec", "(", "func", ")", ".", "args", "if", "set", "(", "for_re...
Resolve dotted names in function arguments Usage: >>> @resolver('obj') >>> def func(param, obj): >>> assert isinstance(param, str) >>> assert not isinstance(obj, str) >>> >>> func('os.path', 'sys.exit')
[ "Resolve", "dotted", "names", "in", "function", "arguments" ]
train
https://github.com/zzzsochi/resolver_deco/blob/fe40ad5f931d1edd444d854cb2e3038a2cd16c7c/resolver_deco.py#L7-L49
MakerReduxCorp/rolne
rolne/__init__.py
rolne.append
def append(self, name, value=None, sublist=None, seq=None): """Add one name/value entry to the main context of the rolne. If you are wanting to "append" another rolne, see the 'extend' method instead. Example of use: >>> # setup an example rolne first >>> my_va...
python
def append(self, name, value=None, sublist=None, seq=None): """Add one name/value entry to the main context of the rolne. If you are wanting to "append" another rolne, see the 'extend' method instead. Example of use: >>> # setup an example rolne first >>> my_va...
[ "def", "append", "(", "self", ",", "name", ",", "value", "=", "None", ",", "sublist", "=", "None", ",", "seq", "=", "None", ")", ":", "if", "sublist", "is", "None", ":", "sublist", "=", "[", "]", "new_seq", "=", "lib", ".", "_seq", "(", "self", ...
Add one name/value entry to the main context of the rolne. If you are wanting to "append" another rolne, see the 'extend' method instead. Example of use: >>> # setup an example rolne first >>> my_var = rolne() >>> my_var.append("item", "zing") >>> my_va...
[ "Add", "one", "name", "/", "value", "entry", "to", "the", "main", "context", "of", "the", "rolne", "." ]
train
https://github.com/MakerReduxCorp/rolne/blob/67be510a5aeb1251228830fbb4525ed7fd43cd37/rolne/__init__.py#L494-L542
MakerReduxCorp/rolne
rolne/__init__.py
rolne.append_index
def append_index(self, name, value=None, sublist=None, seq=None): """Add one name/value entry to the main context of the rolne and return the index number for the new entry. If you are wanting to "append" another rolne, see the 'extend' method instead. Example of use: ...
python
def append_index(self, name, value=None, sublist=None, seq=None): """Add one name/value entry to the main context of the rolne and return the index number for the new entry. If you are wanting to "append" another rolne, see the 'extend' method instead. Example of use: ...
[ "def", "append_index", "(", "self", ",", "name", ",", "value", "=", "None", ",", "sublist", "=", "None", ",", "seq", "=", "None", ")", ":", "if", "sublist", "is", "None", ":", "sublist", "=", "[", "]", "new_tuple", "=", "(", "name", ",", "value", ...
Add one name/value entry to the main context of the rolne and return the index number for the new entry. If you are wanting to "append" another rolne, see the 'extend' method instead. Example of use: >>> # setup an example rolne first >>> my_var = rolne() >>> i...
[ "Add", "one", "name", "/", "value", "entry", "to", "the", "main", "context", "of", "the", "rolne", "and", "return", "the", "index", "number", "for", "the", "new", "entry", "." ]
train
https://github.com/MakerReduxCorp/rolne/blob/67be510a5aeb1251228830fbb4525ed7fd43cd37/rolne/__init__.py#L596-L651
MakerReduxCorp/rolne
rolne/__init__.py
rolne.upsert
def upsert(self, name, value=None, seq=None): """Add one name/value entry to the main context of the rolne, but only if an entry with that name does not already exist. If the an entry with name exists, then the first entry found has it's value changed. NOTE: the upsert only upd...
python
def upsert(self, name, value=None, seq=None): """Add one name/value entry to the main context of the rolne, but only if an entry with that name does not already exist. If the an entry with name exists, then the first entry found has it's value changed. NOTE: the upsert only upd...
[ "def", "upsert", "(", "self", ",", "name", ",", "value", "=", "None", ",", "seq", "=", "None", ")", ":", "for", "ctr", ",", "entry", "in", "enumerate", "(", "self", ".", "data", ")", ":", "if", "entry", "[", "TNAME", "]", "==", "name", ":", "ne...
Add one name/value entry to the main context of the rolne, but only if an entry with that name does not already exist. If the an entry with name exists, then the first entry found has it's value changed. NOTE: the upsert only updates the FIRST entry with the name found. The me...
[ "Add", "one", "name", "/", "value", "entry", "to", "the", "main", "context", "of", "the", "rolne", "but", "only", "if", "an", "entry", "with", "that", "name", "does", "not", "already", "exist", "." ]
train
https://github.com/MakerReduxCorp/rolne/blob/67be510a5aeb1251228830fbb4525ed7fd43cd37/rolne/__init__.py#L653-L709
ardydedase/pycouchbase
pycouchbase/viewsync.py
register_view
def register_view(design_doc, full_set=True): """Model document decorator to register its design document view:: @register_view('dev_books') class Book(Document): __bucket_name__ = 'mybucket' doc_type = 'book' structure = { # snip snip ...
python
def register_view(design_doc, full_set=True): """Model document decorator to register its design document view:: @register_view('dev_books') class Book(Document): __bucket_name__ = 'mybucket' doc_type = 'book' structure = { # snip snip ...
[ "def", "register_view", "(", "design_doc", ",", "full_set", "=", "True", ")", ":", "def", "_injector", "(", "doc", ")", ":", "if", "not", "isinstance", "(", "doc", ",", "type", ")", "or", "not", "issubclass", "(", "doc", ",", "Document", ")", ":", "r...
Model document decorator to register its design document view:: @register_view('dev_books') class Book(Document): __bucket_name__ = 'mybucket' doc_type = 'book' structure = { # snip snip } :param design_doc: The name of the design doc...
[ "Model", "document", "decorator", "to", "register", "its", "design", "document", "view", "::" ]
train
https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/pycouchbase/viewsync.py#L16-L39
ardydedase/pycouchbase
pycouchbase/viewsync.py
ViewSync.download
def download(cls): """Downloads all the views from server for the registered model documents into the defined :attr:`VIEW_PATHS` directory. This method **removes** previous views directory if exist. """ cls._check_folder() os.chdir(cls.VIEWS_PATH) # iterate docum...
python
def download(cls): """Downloads all the views from server for the registered model documents into the defined :attr:`VIEW_PATHS` directory. This method **removes** previous views directory if exist. """ cls._check_folder() os.chdir(cls.VIEWS_PATH) # iterate docum...
[ "def", "download", "(", "cls", ")", ":", "cls", ".", "_check_folder", "(", ")", "os", ".", "chdir", "(", "cls", ".", "VIEWS_PATH", ")", "# iterate documents", "for", "doc", "in", "cls", ".", "_documents", ":", "design_doc", "=", "doc", "(", ")", ".", ...
Downloads all the views from server for the registered model documents into the defined :attr:`VIEW_PATHS` directory. This method **removes** previous views directory if exist.
[ "Downloads", "all", "the", "views", "from", "server", "for", "the", "registered", "model", "documents", "into", "the", "defined", ":", "attr", ":", "VIEW_PATHS", "directory", "." ]
train
https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/pycouchbase/viewsync.py#L75-L114
ardydedase/pycouchbase
pycouchbase/viewsync.py
ViewSync.upload
def upload(cls): """Uploads all the local views from :attr:`VIEW_PATHS` directory to CouchBase server This method **over-writes** all the server-side views with the same named ones coming from :attr:`VIEW_PATHS` folder. """ cls._check_folder() os.chdir(cls.VIEWS_...
python
def upload(cls): """Uploads all the local views from :attr:`VIEW_PATHS` directory to CouchBase server This method **over-writes** all the server-side views with the same named ones coming from :attr:`VIEW_PATHS` folder. """ cls._check_folder() os.chdir(cls.VIEWS_...
[ "def", "upload", "(", "cls", ")", ":", "cls", ".", "_check_folder", "(", ")", "os", ".", "chdir", "(", "cls", ".", "VIEWS_PATH", ")", "buckets", "=", "dict", "(", ")", "# iterate local folders", "for", "bucket_name", "in", "os", ".", "listdir", "(", "c...
Uploads all the local views from :attr:`VIEW_PATHS` directory to CouchBase server This method **over-writes** all the server-side views with the same named ones coming from :attr:`VIEW_PATHS` folder.
[ "Uploads", "all", "the", "local", "views", "from", ":", "attr", ":", "VIEW_PATHS", "directory", "to", "CouchBase", "server" ]
train
https://github.com/ardydedase/pycouchbase/blob/6f010b4d2ef41aead2366878d0cf0b1284c0db0e/pycouchbase/viewsync.py#L117-L176
ttinies/sc2common
sc2common/commonUtilFuncs.py
relateObjectLocs
def relateObjectLocs(obj, entities, selectF): """calculate the minimum distance to reach any iterable of entities with a loc""" #if obj in entities: return 0 # is already one of the entities try: obj = obj.loc # get object's location, if it has one except AttributeError: pass # assum...
python
def relateObjectLocs(obj, entities, selectF): """calculate the minimum distance to reach any iterable of entities with a loc""" #if obj in entities: return 0 # is already one of the entities try: obj = obj.loc # get object's location, if it has one except AttributeError: pass # assum...
[ "def", "relateObjectLocs", "(", "obj", ",", "entities", ",", "selectF", ")", ":", "#if obj in entities: return 0 # is already one of the entities", "try", ":", "obj", "=", "obj", ".", "loc", "# get object's location, if it has one", "except", "AttributeError", ":", "pass"...
calculate the minimum distance to reach any iterable of entities with a loc
[ "calculate", "the", "minimum", "distance", "to", "reach", "any", "iterable", "of", "entities", "with", "a", "loc" ]
train
https://github.com/ttinies/sc2common/blob/469623c319c7ab7af799551055839ea3b3f87d54/sc2common/commonUtilFuncs.py#L52-L60
ttinies/sc2common
sc2common/commonUtilFuncs.py
gridSnap
def gridSnap(point, grid=1.0): """cause the given point to snap to nearest X/Y grid point""" def snapFunc(value): value += 0.000001 # ensure values that are close to a half grid value round up remainder = value%grid value -= remainder newAdd = round(remainder/grid)*grid r...
python
def gridSnap(point, grid=1.0): """cause the given point to snap to nearest X/Y grid point""" def snapFunc(value): value += 0.000001 # ensure values that are close to a half grid value round up remainder = value%grid value -= remainder newAdd = round(remainder/grid)*grid r...
[ "def", "gridSnap", "(", "point", ",", "grid", "=", "1.0", ")", ":", "def", "snapFunc", "(", "value", ")", ":", "value", "+=", "0.000001", "# ensure values that are close to a half grid value round up", "remainder", "=", "value", "%", "grid", "value", "-=", "rema...
cause the given point to snap to nearest X/Y grid point
[ "cause", "the", "given", "point", "to", "snap", "to", "nearest", "X", "/", "Y", "grid", "point" ]
train
https://github.com/ttinies/sc2common/blob/469623c319c7ab7af799551055839ea3b3f87d54/sc2common/commonUtilFuncs.py#L76-L85
ttinies/sc2common
sc2common/commonUtilFuncs.py
convertToMapPic
def convertToMapPic(byteString, mapWidth): """convert a bytestring into a 2D row x column array, representing an existing map of fog-of-war, creep, etc.""" data = [] line = "" for idx,char in enumerate(byteString): line += str(ord(char)) if ((idx+1)%mapWidth)==0: data.append(...
python
def convertToMapPic(byteString, mapWidth): """convert a bytestring into a 2D row x column array, representing an existing map of fog-of-war, creep, etc.""" data = [] line = "" for idx,char in enumerate(byteString): line += str(ord(char)) if ((idx+1)%mapWidth)==0: data.append(...
[ "def", "convertToMapPic", "(", "byteString", ",", "mapWidth", ")", ":", "data", "=", "[", "]", "line", "=", "\"\"", "for", "idx", ",", "char", "in", "enumerate", "(", "byteString", ")", ":", "line", "+=", "str", "(", "ord", "(", "char", ")", ")", "...
convert a bytestring into a 2D row x column array, representing an existing map of fog-of-war, creep, etc.
[ "convert", "a", "bytestring", "into", "a", "2D", "row", "x", "column", "array", "representing", "an", "existing", "map", "of", "fog", "-", "of", "-", "war", "creep", "etc", "." ]
train
https://github.com/ttinies/sc2common/blob/469623c319c7ab7af799551055839ea3b3f87d54/sc2common/commonUtilFuncs.py#L89-L98
ttinies/sc2common
sc2common/commonUtilFuncs.py
Dumper
def Dumper(obj, indent=0, increase=4, encoding='utf-8'): """appropriately view a given dict/list/tuple/object data structure""" ############################################################################## def p(given): """ensure proper decoding from unicode, if necessary""" if isinstance(g...
python
def Dumper(obj, indent=0, increase=4, encoding='utf-8'): """appropriately view a given dict/list/tuple/object data structure""" ############################################################################## def p(given): """ensure proper decoding from unicode, if necessary""" if isinstance(g...
[ "def", "Dumper", "(", "obj", ",", "indent", "=", "0", ",", "increase", "=", "4", ",", "encoding", "=", "'utf-8'", ")", ":", "##############################################################################", "def", "p", "(", "given", ")", ":", "\"\"\"ensure proper dec...
appropriately view a given dict/list/tuple/object data structure
[ "appropriately", "view", "a", "given", "dict", "/", "list", "/", "tuple", "/", "object", "data", "structure" ]
train
https://github.com/ttinies/sc2common/blob/469623c319c7ab7af799551055839ea3b3f87d54/sc2common/commonUtilFuncs.py#L102-L131
ttinies/sc2common
sc2common/commonUtilFuncs.py
quadraticEval
def quadraticEval(a, b, c, x): """given all params return the result of quadratic equation a*x^2 + b*x + c""" return a*(x**2) + b*x + c
python
def quadraticEval(a, b, c, x): """given all params return the result of quadratic equation a*x^2 + b*x + c""" return a*(x**2) + b*x + c
[ "def", "quadraticEval", "(", "a", ",", "b", ",", "c", ",", "x", ")", ":", "return", "a", "*", "(", "x", "**", "2", ")", "+", "b", "*", "x", "+", "c" ]
given all params return the result of quadratic equation a*x^2 + b*x + c
[ "given", "all", "params", "return", "the", "result", "of", "quadratic", "equation", "a", "*", "x^2", "+", "b", "*", "x", "+", "c" ]
train
https://github.com/ttinies/sc2common/blob/469623c319c7ab7af799551055839ea3b3f87d54/sc2common/commonUtilFuncs.py#L142-L144
ttinies/sc2common
sc2common/commonUtilFuncs.py
quadraticSolver
def quadraticSolver(a, b, c): """return solution(s) for x, to the quadratic equation a*x^2 + b*x + c when it equals zero using the quadratic formula""" if a == 0: if b == 0: return [] # attempting to solve an equation with infinite (0=0) or impossible (0=3) solutions for x else: retur...
python
def quadraticSolver(a, b, c): """return solution(s) for x, to the quadratic equation a*x^2 + b*x + c when it equals zero using the quadratic formula""" if a == 0: if b == 0: return [] # attempting to solve an equation with infinite (0=0) or impossible (0=3) solutions for x else: retur...
[ "def", "quadraticSolver", "(", "a", ",", "b", ",", "c", ")", ":", "if", "a", "==", "0", ":", "if", "b", "==", "0", ":", "return", "[", "]", "# attempting to solve an equation with infinite (0=0) or impossible (0=3) solutions for x", "else", ":", "return", "[", ...
return solution(s) for x, to the quadratic equation a*x^2 + b*x + c when it equals zero using the quadratic formula
[ "return", "solution", "(", "s", ")", "for", "x", "to", "the", "quadratic", "equation", "a", "*", "x^2", "+", "b", "*", "x", "+", "c", "when", "it", "equals", "zero", "using", "the", "quadratic", "formula" ]
train
https://github.com/ttinies/sc2common/blob/469623c319c7ab7af799551055839ea3b3f87d54/sc2common/commonUtilFuncs.py#L148-L162
fred49/linshare-api
linshareapi/user/users.py
Users.get
def get(self, mail): """ Get one document store into LinShare.""" users = (v for v in self.list() if v.get('mail') == mail) for i in users: self.log.debug(i) return i return None
python
def get(self, mail): """ Get one document store into LinShare.""" users = (v for v in self.list() if v.get('mail') == mail) for i in users: self.log.debug(i) return i return None
[ "def", "get", "(", "self", ",", "mail", ")", ":", "users", "=", "(", "v", "for", "v", "in", "self", ".", "list", "(", ")", "if", "v", ".", "get", "(", "'mail'", ")", "==", "mail", ")", "for", "i", "in", "users", ":", "self", ".", "log", "."...
Get one document store into LinShare.
[ "Get", "one", "document", "store", "into", "LinShare", "." ]
train
https://github.com/fred49/linshare-api/blob/be646c25aa8ba3718abb6869c620b157d53d6e41/linshareapi/user/users.py#L70-L76
tjomasc/snekbol
snekbol/document.py
Document.add_component_definition
def add_component_definition(self, definition): """ Add a ComponentDefinition to the document """ # definition.identity = self._to_uri_from_namespace(definition.identity) if definition.identity not in self._components.keys(): self._components[definition.identity] = de...
python
def add_component_definition(self, definition): """ Add a ComponentDefinition to the document """ # definition.identity = self._to_uri_from_namespace(definition.identity) if definition.identity not in self._components.keys(): self._components[definition.identity] = de...
[ "def", "add_component_definition", "(", "self", ",", "definition", ")", ":", "# definition.identity = self._to_uri_from_namespace(definition.identity)", "if", "definition", ".", "identity", "not", "in", "self", ".", "_components", ".", "keys", "(", ")", ":", "self", "...
Add a ComponentDefinition to the document
[ "Add", "a", "ComponentDefinition", "to", "the", "document" ]
train
https://github.com/tjomasc/snekbol/blob/0b491aa96e0b1bd09e6c80cfb43807dd8a876c83/snekbol/document.py#L79-L87
tjomasc/snekbol
snekbol/document.py
Document.assemble_component
def assemble_component(self, into_component, using_components): """ Assemble a list of already defined components into a structual hirearchy """ if not isinstance(using_components, list) or len(using_components) == 0: raise Exception('Must supply list of ComponentDefinitions'...
python
def assemble_component(self, into_component, using_components): """ Assemble a list of already defined components into a structual hirearchy """ if not isinstance(using_components, list) or len(using_components) == 0: raise Exception('Must supply list of ComponentDefinitions'...
[ "def", "assemble_component", "(", "self", ",", "into_component", ",", "using_components", ")", ":", "if", "not", "isinstance", "(", "using_components", ",", "list", ")", "or", "len", "(", "using_components", ")", "==", "0", ":", "raise", "Exception", "(", "'...
Assemble a list of already defined components into a structual hirearchy
[ "Assemble", "a", "list", "of", "already", "defined", "components", "into", "a", "structual", "hirearchy" ]
train
https://github.com/tjomasc/snekbol/blob/0b491aa96e0b1bd09e6c80cfb43807dd8a876c83/snekbol/document.py#L114-L168
tjomasc/snekbol
snekbol/document.py
Document._add_sequence
def _add_sequence(self, sequence): """ Add a Sequence to the document """ if sequence.identity not in self._sequences.keys(): self._sequences[sequence.identity] = sequence else: raise ValueError("{} has already been defined".format(sequence.identity))
python
def _add_sequence(self, sequence): """ Add a Sequence to the document """ if sequence.identity not in self._sequences.keys(): self._sequences[sequence.identity] = sequence else: raise ValueError("{} has already been defined".format(sequence.identity))
[ "def", "_add_sequence", "(", "self", ",", "sequence", ")", ":", "if", "sequence", ".", "identity", "not", "in", "self", ".", "_sequences", ".", "keys", "(", ")", ":", "self", ".", "_sequences", "[", "sequence", ".", "identity", "]", "=", "sequence", "e...
Add a Sequence to the document
[ "Add", "a", "Sequence", "to", "the", "document" ]
train
https://github.com/tjomasc/snekbol/blob/0b491aa96e0b1bd09e6c80cfb43807dd8a876c83/snekbol/document.py#L170-L177
tjomasc/snekbol
snekbol/document.py
Document.add_model
def add_model(self, model): """ Add a model to the document """ if model.identity not in self._models.keys(): self._models[model.identity] = model else: raise ValueError("{} has already been defined".format(model.identity))
python
def add_model(self, model): """ Add a model to the document """ if model.identity not in self._models.keys(): self._models[model.identity] = model else: raise ValueError("{} has already been defined".format(model.identity))
[ "def", "add_model", "(", "self", ",", "model", ")", ":", "if", "model", ".", "identity", "not", "in", "self", ".", "_models", ".", "keys", "(", ")", ":", "self", ".", "_models", "[", "model", ".", "identity", "]", "=", "model", "else", ":", "raise"...
Add a model to the document
[ "Add", "a", "model", "to", "the", "document" ]
train
https://github.com/tjomasc/snekbol/blob/0b491aa96e0b1bd09e6c80cfb43807dd8a876c83/snekbol/document.py#L179-L186
tjomasc/snekbol
snekbol/document.py
Document.add_module_definition
def add_module_definition(self, module_definition): """ Add a ModuleDefinition to the document """ if module_definition.identity not in self._module_definitions.keys(): self._module_definitions[module_definition.identity] = module_definition else: raise Va...
python
def add_module_definition(self, module_definition): """ Add a ModuleDefinition to the document """ if module_definition.identity not in self._module_definitions.keys(): self._module_definitions[module_definition.identity] = module_definition else: raise Va...
[ "def", "add_module_definition", "(", "self", ",", "module_definition", ")", ":", "if", "module_definition", ".", "identity", "not", "in", "self", ".", "_module_definitions", ".", "keys", "(", ")", ":", "self", ".", "_module_definitions", "[", "module_definition", ...
Add a ModuleDefinition to the document
[ "Add", "a", "ModuleDefinition", "to", "the", "document" ]
train
https://github.com/tjomasc/snekbol/blob/0b491aa96e0b1bd09e6c80cfb43807dd8a876c83/snekbol/document.py#L203-L210
tjomasc/snekbol
snekbol/document.py
Document.get_components
def get_components(self, uri): """ Get components from a component definition in order """ try: component_definition = self._components[uri] except KeyError: return False sorted_sequences = sorted(component_definition.sequence_annotations, ...
python
def get_components(self, uri): """ Get components from a component definition in order """ try: component_definition = self._components[uri] except KeyError: return False sorted_sequences = sorted(component_definition.sequence_annotations, ...
[ "def", "get_components", "(", "self", ",", "uri", ")", ":", "try", ":", "component_definition", "=", "self", ".", "_components", "[", "uri", "]", "except", "KeyError", ":", "return", "False", "sorted_sequences", "=", "sorted", "(", "component_definition", ".",...
Get components from a component definition in order
[ "Get", "components", "from", "a", "component", "definition", "in", "order" ]
train
https://github.com/tjomasc/snekbol/blob/0b491aa96e0b1bd09e6c80cfb43807dd8a876c83/snekbol/document.py#L233-L244
tjomasc/snekbol
snekbol/document.py
Document.clear_document
def clear_document(self): """ Clears ALL items from document, reseting it to clean """ self._components.clear() self._sequences.clear() self._namespaces.clear() self._models.clear() self._modules.clear() self._collections.clear() self._anno...
python
def clear_document(self): """ Clears ALL items from document, reseting it to clean """ self._components.clear() self._sequences.clear() self._namespaces.clear() self._models.clear() self._modules.clear() self._collections.clear() self._anno...
[ "def", "clear_document", "(", "self", ")", ":", "self", ".", "_components", ".", "clear", "(", ")", "self", ".", "_sequences", ".", "clear", "(", ")", "self", ".", "_namespaces", ".", "clear", "(", ")", "self", ".", "_models", ".", "clear", "(", ")",...
Clears ALL items from document, reseting it to clean
[ "Clears", "ALL", "items", "from", "document", "reseting", "it", "to", "clean" ]
train
https://github.com/tjomasc/snekbol/blob/0b491aa96e0b1bd09e6c80cfb43807dd8a876c83/snekbol/document.py#L246-L258
tjomasc/snekbol
snekbol/document.py
Document._get_triplet_value
def _get_triplet_value(self, graph, identity, rdf_type): """ Get a value from an RDF triple """ value = graph.value(subject=identity, predicate=rdf_type) return value.toPython() if value is not None else value
python
def _get_triplet_value(self, graph, identity, rdf_type): """ Get a value from an RDF triple """ value = graph.value(subject=identity, predicate=rdf_type) return value.toPython() if value is not None else value
[ "def", "_get_triplet_value", "(", "self", ",", "graph", ",", "identity", ",", "rdf_type", ")", ":", "value", "=", "graph", ".", "value", "(", "subject", "=", "identity", ",", "predicate", "=", "rdf_type", ")", "return", "value", ".", "toPython", "(", ")"...
Get a value from an RDF triple
[ "Get", "a", "value", "from", "an", "RDF", "triple" ]
train
https://github.com/tjomasc/snekbol/blob/0b491aa96e0b1bd09e6c80cfb43807dd8a876c83/snekbol/document.py#L263-L268
tjomasc/snekbol
snekbol/document.py
Document._get_triplet_value_list
def _get_triplet_value_list(self, graph, identity, rdf_type): """ Get a list of values from RDF triples when more than one may be present """ values = [] for elem in graph.objects(identity, rdf_type): values.append(elem.toPython()) return values
python
def _get_triplet_value_list(self, graph, identity, rdf_type): """ Get a list of values from RDF triples when more than one may be present """ values = [] for elem in graph.objects(identity, rdf_type): values.append(elem.toPython()) return values
[ "def", "_get_triplet_value_list", "(", "self", ",", "graph", ",", "identity", ",", "rdf_type", ")", ":", "values", "=", "[", "]", "for", "elem", "in", "graph", ".", "objects", "(", "identity", ",", "rdf_type", ")", ":", "values", ".", "append", "(", "e...
Get a list of values from RDF triples when more than one may be present
[ "Get", "a", "list", "of", "values", "from", "RDF", "triples", "when", "more", "than", "one", "may", "be", "present" ]
train
https://github.com/tjomasc/snekbol/blob/0b491aa96e0b1bd09e6c80cfb43807dd8a876c83/snekbol/document.py#L270-L277
tjomasc/snekbol
snekbol/document.py
Document._read_sequences
def _read_sequences(self, graph): """ Read graph and add sequences to document """ for e in self._get_elements(graph, SBOL.Sequence): identity = e[0] c = self._get_rdf_identified(graph, identity) c['elements'] = self._get_triplet_value(graph, identity,...
python
def _read_sequences(self, graph): """ Read graph and add sequences to document """ for e in self._get_elements(graph, SBOL.Sequence): identity = e[0] c = self._get_rdf_identified(graph, identity) c['elements'] = self._get_triplet_value(graph, identity,...
[ "def", "_read_sequences", "(", "self", ",", "graph", ")", ":", "for", "e", "in", "self", ".", "_get_elements", "(", "graph", ",", "SBOL", ".", "Sequence", ")", ":", "identity", "=", "e", "[", "0", "]", "c", "=", "self", ".", "_get_rdf_identified", "(...
Read graph and add sequences to document
[ "Read", "graph", "and", "add", "sequences", "to", "document" ]
train
https://github.com/tjomasc/snekbol/blob/0b491aa96e0b1bd09e6c80cfb43807dd8a876c83/snekbol/document.py#L306-L317
tjomasc/snekbol
snekbol/document.py
Document._read_component_definitions
def _read_component_definitions(self, graph): """ Read graph and add component defintions to document """ for e in self._get_elements(graph, SBOL.ComponentDefinition): identity = e[0] # Store component values in dict c = self._get_rdf_identified(graph,...
python
def _read_component_definitions(self, graph): """ Read graph and add component defintions to document """ for e in self._get_elements(graph, SBOL.ComponentDefinition): identity = e[0] # Store component values in dict c = self._get_rdf_identified(graph,...
[ "def", "_read_component_definitions", "(", "self", ",", "graph", ")", ":", "for", "e", "in", "self", ".", "_get_elements", "(", "graph", ",", "SBOL", ".", "ComponentDefinition", ")", ":", "identity", "=", "e", "[", "0", "]", "# Store component values in dict",...
Read graph and add component defintions to document
[ "Read", "graph", "and", "add", "component", "defintions", "to", "document" ]
train
https://github.com/tjomasc/snekbol/blob/0b491aa96e0b1bd09e6c80cfb43807dd8a876c83/snekbol/document.py#L319-L331
tjomasc/snekbol
snekbol/document.py
Document._extend_component_definitions
def _extend_component_definitions(self, graph): """ Read graph and update component definitions with related elements """ for def_uri, comp_def in self._components.items(): # Store created components indexed for later lookup component_index = {} identi...
python
def _extend_component_definitions(self, graph): """ Read graph and update component definitions with related elements """ for def_uri, comp_def in self._components.items(): # Store created components indexed for later lookup component_index = {} identi...
[ "def", "_extend_component_definitions", "(", "self", ",", "graph", ")", ":", "for", "def_uri", ",", "comp_def", "in", "self", ".", "_components", ".", "items", "(", ")", ":", "# Store created components indexed for later lookup", "component_index", "=", "{", "}", ...
Read graph and update component definitions with related elements
[ "Read", "graph", "and", "update", "component", "definitions", "with", "related", "elements" ]
train
https://github.com/tjomasc/snekbol/blob/0b491aa96e0b1bd09e6c80cfb43807dd8a876c83/snekbol/document.py#L333-L405
tjomasc/snekbol
snekbol/document.py
Document._read_models
def _read_models(self, graph): """ Read graph and add models to document """ for e in self._get_elements(graph, SBOL.Model): identity = e[0] m = self._get_rdf_identified(graph, identity) m['source'] = self._get_triplet_value(graph, identity, SBOL.sourc...
python
def _read_models(self, graph): """ Read graph and add models to document """ for e in self._get_elements(graph, SBOL.Model): identity = e[0] m = self._get_rdf_identified(graph, identity) m['source'] = self._get_triplet_value(graph, identity, SBOL.sourc...
[ "def", "_read_models", "(", "self", ",", "graph", ")", ":", "for", "e", "in", "self", ".", "_get_elements", "(", "graph", ",", "SBOL", ".", "Model", ")", ":", "identity", "=", "e", "[", "0", "]", "m", "=", "self", ".", "_get_rdf_identified", "(", "...
Read graph and add models to document
[ "Read", "graph", "and", "add", "models", "to", "document" ]
train
https://github.com/tjomasc/snekbol/blob/0b491aa96e0b1bd09e6c80cfb43807dd8a876c83/snekbol/document.py#L407-L419
tjomasc/snekbol
snekbol/document.py
Document._read_module_definitions
def _read_module_definitions(self, graph): """ Read graph and add module defintions to document """ for e in self._get_elements(graph, SBOL.ModuleDefinition): identity = e[0] m = self._get_rdf_identified(graph, identity) m['roles'] = self._get_triplet_...
python
def _read_module_definitions(self, graph): """ Read graph and add module defintions to document """ for e in self._get_elements(graph, SBOL.ModuleDefinition): identity = e[0] m = self._get_rdf_identified(graph, identity) m['roles'] = self._get_triplet_...
[ "def", "_read_module_definitions", "(", "self", ",", "graph", ")", ":", "for", "e", "in", "self", ".", "_get_elements", "(", "graph", ",", "SBOL", ".", "ModuleDefinition", ")", ":", "identity", "=", "e", "[", "0", "]", "m", "=", "self", ".", "_get_rdf_...
Read graph and add module defintions to document
[ "Read", "graph", "and", "add", "module", "defintions", "to", "document" ]
train
https://github.com/tjomasc/snekbol/blob/0b491aa96e0b1bd09e6c80cfb43807dd8a876c83/snekbol/document.py#L421-L458
tjomasc/snekbol
snekbol/document.py
Document._extend_module_definitions
def _extend_module_definitions(self, graph): """ Using collected module definitions extend linkages """ for mod_id in self._modules: mod_identity = self._get_triplet_value(graph, URIRef(mod_id), SBOL.module) modules = [] for mod in graph.triples((mod_i...
python
def _extend_module_definitions(self, graph): """ Using collected module definitions extend linkages """ for mod_id in self._modules: mod_identity = self._get_triplet_value(graph, URIRef(mod_id), SBOL.module) modules = [] for mod in graph.triples((mod_i...
[ "def", "_extend_module_definitions", "(", "self", ",", "graph", ")", ":", "for", "mod_id", "in", "self", ".", "_modules", ":", "mod_identity", "=", "self", ".", "_get_triplet_value", "(", "graph", ",", "URIRef", "(", "mod_id", ")", ",", "SBOL", ".", "modul...
Using collected module definitions extend linkages
[ "Using", "collected", "module", "definitions", "extend", "linkages" ]
train
https://github.com/tjomasc/snekbol/blob/0b491aa96e0b1bd09e6c80cfb43807dd8a876c83/snekbol/document.py#L460-L481
tjomasc/snekbol
snekbol/document.py
Document._read_annotations
def _read_annotations(self, graph): """ Find any non-defined elements at TopLevel and create annotations """ flipped_namespaces = {v: k for k, v in self._namespaces.items()} for triple in graph.triples((None, RDF.type, None)): namespace, obj = split_uri(triple[2]) ...
python
def _read_annotations(self, graph): """ Find any non-defined elements at TopLevel and create annotations """ flipped_namespaces = {v: k for k, v in self._namespaces.items()} for triple in graph.triples((None, RDF.type, None)): namespace, obj = split_uri(triple[2]) ...
[ "def", "_read_annotations", "(", "self", ",", "graph", ")", ":", "flipped_namespaces", "=", "{", "v", ":", "k", "for", "k", ",", "v", "in", "self", ".", "_namespaces", ".", "items", "(", ")", "}", "for", "triple", "in", "graph", ".", "triples", "(", ...
Find any non-defined elements at TopLevel and create annotations
[ "Find", "any", "non", "-", "defined", "elements", "at", "TopLevel", "and", "create", "annotations" ]
train
https://github.com/tjomasc/snekbol/blob/0b491aa96e0b1bd09e6c80cfb43807dd8a876c83/snekbol/document.py#L483-L499
tjomasc/snekbol
snekbol/document.py
Document._read_collections
def _read_collections(self, graph): """ Read graph and add collections to document """ for e in self._get_elements(graph, SBOL.Collection): identity = e[0] c = self._get_rdf_identified(graph, identity) members = [] # Need to handle other no...
python
def _read_collections(self, graph): """ Read graph and add collections to document """ for e in self._get_elements(graph, SBOL.Collection): identity = e[0] c = self._get_rdf_identified(graph, identity) members = [] # Need to handle other no...
[ "def", "_read_collections", "(", "self", ",", "graph", ")", ":", "for", "e", "in", "self", ".", "_get_elements", "(", "graph", ",", "SBOL", ".", "Collection", ")", ":", "identity", "=", "e", "[", "0", "]", "c", "=", "self", ".", "_get_rdf_identified", ...
Read graph and add collections to document
[ "Read", "graph", "and", "add", "collections", "to", "document" ]
train
https://github.com/tjomasc/snekbol/blob/0b491aa96e0b1bd09e6c80cfb43807dd8a876c83/snekbol/document.py#L501-L513
tjomasc/snekbol
snekbol/document.py
Document.read
def read(self, f): """ Read in an SBOL file, replacing current document contents """ self.clear_document() g = Graph() g.parse(f, format='xml') for n in g.namespaces(): ns = n[1].toPython() if not ns.endswith(('#', '/', ':')): ...
python
def read(self, f): """ Read in an SBOL file, replacing current document contents """ self.clear_document() g = Graph() g.parse(f, format='xml') for n in g.namespaces(): ns = n[1].toPython() if not ns.endswith(('#', '/', ':')): ...
[ "def", "read", "(", "self", ",", "f", ")", ":", "self", ".", "clear_document", "(", ")", "g", "=", "Graph", "(", ")", "g", ".", "parse", "(", "f", ",", "format", "=", "'xml'", ")", "for", "n", "in", "g", ".", "namespaces", "(", ")", ":", "ns"...
Read in an SBOL file, replacing current document contents
[ "Read", "in", "an", "SBOL", "file", "replacing", "current", "document", "contents" ]
train
https://github.com/tjomasc/snekbol/blob/0b491aa96e0b1bd09e6c80cfb43807dd8a876c83/snekbol/document.py#L515-L540
tjomasc/snekbol
snekbol/document.py
Document.write
def write(self, f): """ Write an SBOL file from current document contents """ rdf = ET.Element(NS('rdf', 'RDF'), nsmap=XML_NS) # TODO: TopLevel Annotations sequence_values = sorted(self._sequences.values(), key=lambda x: x.identity) self._add_to_root(rdf, sequenc...
python
def write(self, f): """ Write an SBOL file from current document contents """ rdf = ET.Element(NS('rdf', 'RDF'), nsmap=XML_NS) # TODO: TopLevel Annotations sequence_values = sorted(self._sequences.values(), key=lambda x: x.identity) self._add_to_root(rdf, sequenc...
[ "def", "write", "(", "self", ",", "f", ")", ":", "rdf", "=", "ET", ".", "Element", "(", "NS", "(", "'rdf'", ",", "'RDF'", ")", ",", "nsmap", "=", "XML_NS", ")", "# TODO: TopLevel Annotations", "sequence_values", "=", "sorted", "(", "self", ".", "_seque...
Write an SBOL file from current document contents
[ "Write", "an", "SBOL", "file", "from", "current", "document", "contents" ]
train
https://github.com/tjomasc/snekbol/blob/0b491aa96e0b1bd09e6c80cfb43807dd8a876c83/snekbol/document.py#L553-L576
FujiMakoto/IPS-Vagrant
ips_vagrant/models/sites.py
Domain.get
def get(cls, dname): """ Get the requested domain @param dname: Domain name @type dname: str @rtype: Domain or None """ Domain = cls dname = dname.hostname if hasattr(dname, 'hostname') else dname.lower() return Session.query(Domain).filter(Do...
python
def get(cls, dname): """ Get the requested domain @param dname: Domain name @type dname: str @rtype: Domain or None """ Domain = cls dname = dname.hostname if hasattr(dname, 'hostname') else dname.lower() return Session.query(Domain).filter(Do...
[ "def", "get", "(", "cls", ",", "dname", ")", ":", "Domain", "=", "cls", "dname", "=", "dname", ".", "hostname", "if", "hasattr", "(", "dname", ",", "'hostname'", ")", "else", "dname", ".", "lower", "(", ")", "return", "Session", ".", "query", "(", ...
Get the requested domain @param dname: Domain name @type dname: str @rtype: Domain or None
[ "Get", "the", "requested", "domain" ]
train
https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/models/sites.py#L56-L65
FujiMakoto/IPS-Vagrant
ips_vagrant/models/sites.py
Domain.get_or_create
def get_or_create(cls, dname): """ Get the requested domain, or create it if it doesn't exist already @param dname: Domain name @type dname: str @rtype: Domain """ Domain = cls dname = dname.hostname if hasattr(dname, 'hostname') else dname ex...
python
def get_or_create(cls, dname): """ Get the requested domain, or create it if it doesn't exist already @param dname: Domain name @type dname: str @rtype: Domain """ Domain = cls dname = dname.hostname if hasattr(dname, 'hostname') else dname ex...
[ "def", "get_or_create", "(", "cls", ",", "dname", ")", ":", "Domain", "=", "cls", "dname", "=", "dname", ".", "hostname", "if", "hasattr", "(", "dname", ",", "'hostname'", ")", "else", "dname", "extras", "=", "'www.{dn}'", ".", "format", "(", "dn", "="...
Get the requested domain, or create it if it doesn't exist already @param dname: Domain name @type dname: str @rtype: Domain
[ "Get", "the", "requested", "domain", "or", "create", "it", "if", "it", "doesn", "t", "exist", "already" ]
train
https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/models/sites.py#L68-L91
FujiMakoto/IPS-Vagrant
ips_vagrant/models/sites.py
Site.all
def all(cls, domain=None): """ Return all sites @param domain: The domain to filter by @type domain: Domain @rtype: list of Site """ Site = cls site = Session.query(Site) if domain: site.filter(Site.domain == domain) return s...
python
def all(cls, domain=None): """ Return all sites @param domain: The domain to filter by @type domain: Domain @rtype: list of Site """ Site = cls site = Session.query(Site) if domain: site.filter(Site.domain == domain) return s...
[ "def", "all", "(", "cls", ",", "domain", "=", "None", ")", ":", "Site", "=", "cls", "site", "=", "Session", ".", "query", "(", "Site", ")", "if", "domain", ":", "site", ".", "filter", "(", "Site", ".", "domain", "==", "domain", ")", "return", "si...
Return all sites @param domain: The domain to filter by @type domain: Domain @rtype: list of Site
[ "Return", "all", "sites" ]
train
https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/models/sites.py#L132-L143
FujiMakoto/IPS-Vagrant
ips_vagrant/models/sites.py
Site.get
def get(cls, domain, name): """ Get the requested site entry @param domain: Domain name @type domain: Domain @param name: Site name @type name: str @rtype: Domain """ Site = cls return Session.query(Site).filter(Site.domain == dom...
python
def get(cls, domain, name): """ Get the requested site entry @param domain: Domain name @type domain: Domain @param name: Site name @type name: str @rtype: Domain """ Site = cls return Session.query(Site).filter(Site.domain == dom...
[ "def", "get", "(", "cls", ",", "domain", ",", "name", ")", ":", "Site", "=", "cls", "return", "Session", ".", "query", "(", "Site", ")", ".", "filter", "(", "Site", ".", "domain", "==", "domain", ")", ".", "filter", "(", "collate", "(", "Site", "...
Get the requested site entry @param domain: Domain name @type domain: Domain @param name: Site name @type name: str @rtype: Domain
[ "Get", "the", "requested", "site", "entry" ]
train
https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/models/sites.py#L146-L156
FujiMakoto/IPS-Vagrant
ips_vagrant/models/sites.py
Site.delete
def delete(self, drop_database=True): """ Delete the site entry @param drop_database: Drop the sites associated MySQL database @type drop_database: bool """ self.disable() Session.delete(self) if drop_database and self.db_name: mysql = cr...
python
def delete(self, drop_database=True): """ Delete the site entry @param drop_database: Drop the sites associated MySQL database @type drop_database: bool """ self.disable() Session.delete(self) if drop_database and self.db_name: mysql = cr...
[ "def", "delete", "(", "self", ",", "drop_database", "=", "True", ")", ":", "self", ".", "disable", "(", ")", "Session", ".", "delete", "(", "self", ")", "if", "drop_database", "and", "self", ".", "db_name", ":", "mysql", "=", "create_engine", "(", "'my...
Delete the site entry @param drop_database: Drop the sites associated MySQL database @type drop_database: bool
[ "Delete", "the", "site", "entry" ]
train
https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/models/sites.py#L158-L173
FujiMakoto/IPS-Vagrant
ips_vagrant/models/sites.py
Site.name
def name(self, value): """ Generate the Site's slug (for file paths, URL's, etc.) """ self._name = value self.slug = re.sub('[^0-9a-zA-Z_-]+', '_', str(value).lower()) self.root = os.path.abspath(os.path.join(_cfg.get('Paths', 'HttpRoot'), self.domain.name, self.slug))
python
def name(self, value): """ Generate the Site's slug (for file paths, URL's, etc.) """ self._name = value self.slug = re.sub('[^0-9a-zA-Z_-]+', '_', str(value).lower()) self.root = os.path.abspath(os.path.join(_cfg.get('Paths', 'HttpRoot'), self.domain.name, self.slug))
[ "def", "name", "(", "self", ",", "value", ")", ":", "self", ".", "_name", "=", "value", "self", ".", "slug", "=", "re", ".", "sub", "(", "'[^0-9a-zA-Z_-]+'", ",", "'_'", ",", "str", "(", "value", ")", ".", "lower", "(", ")", ")", "self", ".", "...
Generate the Site's slug (for file paths, URL's, etc.)
[ "Generate", "the", "Site", "s", "slug", "(", "for", "file", "paths", "URL", "s", "etc", ".", ")" ]
train
https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/models/sites.py#L184-L190
FujiMakoto/IPS-Vagrant
ips_vagrant/models/sites.py
Site.version
def version(self, value): """ Save the Site's version from a string or version tuple @type value: tuple or str """ if isinstance(value, tuple): value = unparse_version(value) self._version = value
python
def version(self, value): """ Save the Site's version from a string or version tuple @type value: tuple or str """ if isinstance(value, tuple): value = unparse_version(value) self._version = value
[ "def", "version", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "tuple", ")", ":", "value", "=", "unparse_version", "(", "value", ")", "self", ".", "_version", "=", "value" ]
Save the Site's version from a string or version tuple @type value: tuple or str
[ "Save", "the", "Site", "s", "version", "from", "a", "string", "or", "version", "tuple" ]
train
https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/models/sites.py#L201-L209
FujiMakoto/IPS-Vagrant
ips_vagrant/models/sites.py
Site.enable
def enable(self, force=False): """ Enable this site """ log = logging.getLogger('ipsv.models.sites.site') log.debug('Disabling all other sites under the domain %s', self.domain.name) Session.query(Site).filter(Site.id != self.id).filter(Site.domain == self.domain).update(...
python
def enable(self, force=False): """ Enable this site """ log = logging.getLogger('ipsv.models.sites.site') log.debug('Disabling all other sites under the domain %s', self.domain.name) Session.query(Site).filter(Site.id != self.id).filter(Site.domain == self.domain).update(...
[ "def", "enable", "(", "self", ",", "force", "=", "False", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "'ipsv.models.sites.site'", ")", "log", ".", "debug", "(", "'Disabling all other sites under the domain %s'", ",", "self", ".", "domain", ".", "na...
Enable this site
[ "Enable", "this", "site" ]
train
https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/models/sites.py#L211-L245
FujiMakoto/IPS-Vagrant
ips_vagrant/models/sites.py
Site.disable
def disable(self): """ Disable this site """ log = logging.getLogger('ipsv.models.sites.site') sites_enabled_path = _cfg.get('Paths', 'NginxSitesEnabled') symlink_path = os.path.join(sites_enabled_path, '{domain}-{fn}.conf'.format(domain=self.domain.name, ...
python
def disable(self): """ Disable this site """ log = logging.getLogger('ipsv.models.sites.site') sites_enabled_path = _cfg.get('Paths', 'NginxSitesEnabled') symlink_path = os.path.join(sites_enabled_path, '{domain}-{fn}.conf'.format(domain=self.domain.name, ...
[ "def", "disable", "(", "self", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "'ipsv.models.sites.site'", ")", "sites_enabled_path", "=", "_cfg", ".", "get", "(", "'Paths'", ",", "'NginxSitesEnabled'", ")", "symlink_path", "=", "os", ".", "path", "....
Disable this site
[ "Disable", "this", "site" ]
train
https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/models/sites.py#L247-L261
FujiMakoto/IPS-Vagrant
ips_vagrant/models/sites.py
Site.write_nginx_config
def write_nginx_config(self): """ Write the Nginx configuration file for this Site """ log = logging.getLogger('ipsv.models.sites.site') if not os.path.exists(self.root): log.debug('Creating HTTP root directory: %s', self.root) os.makedirs(self.root, 0o755...
python
def write_nginx_config(self): """ Write the Nginx configuration file for this Site """ log = logging.getLogger('ipsv.models.sites.site') if not os.path.exists(self.root): log.debug('Creating HTTP root directory: %s', self.root) os.makedirs(self.root, 0o755...
[ "def", "write_nginx_config", "(", "self", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "'ipsv.models.sites.site'", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "root", ")", ":", "log", ".", "debug", "(", "'Creating HTT...
Write the Nginx configuration file for this Site
[ "Write", "the", "Nginx", "configuration", "file", "for", "this", "Site" ]
train
https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/models/sites.py#L263-L287
rackerlabs/rackspace-python-neutronclient
neutronclient/neutron/v2_0/network.py
ListNetwork.extend_list
def extend_list(self, data, parsed_args): """Add subnet information to a network list.""" neutron_client = self.get_client() search_opts = {'fields': ['id', 'cidr']} if self.pagination_support: page_size = parsed_args.page_size if page_size: search...
python
def extend_list(self, data, parsed_args): """Add subnet information to a network list.""" neutron_client = self.get_client() search_opts = {'fields': ['id', 'cidr']} if self.pagination_support: page_size = parsed_args.page_size if page_size: search...
[ "def", "extend_list", "(", "self", ",", "data", ",", "parsed_args", ")", ":", "neutron_client", "=", "self", ".", "get_client", "(", ")", "search_opts", "=", "{", "'fields'", ":", "[", "'id'", ",", "'cidr'", "]", "}", "if", "self", ".", "pagination_suppo...
Add subnet information to a network list.
[ "Add", "subnet", "information", "to", "a", "network", "list", "." ]
train
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/neutron/v2_0/network.py#L86-L123
mbarakaja/braulio
braulio/version.py
Version.bump
def bump(self, bump_part): """Return a new bumped version instance.""" major, minor, patch, stage, n = tuple(self) # stage bump if bump_part not in {"major", "minor", "patch"}: if bump_part not in self.stages: raise ValueError(f"Unknown {bump_part} stage") ...
python
def bump(self, bump_part): """Return a new bumped version instance.""" major, minor, patch, stage, n = tuple(self) # stage bump if bump_part not in {"major", "minor", "patch"}: if bump_part not in self.stages: raise ValueError(f"Unknown {bump_part} stage") ...
[ "def", "bump", "(", "self", ",", "bump_part", ")", ":", "major", ",", "minor", ",", "patch", ",", "stage", ",", "n", "=", "tuple", "(", "self", ")", "# stage bump", "if", "bump_part", "not", "in", "{", "\"major\"", ",", "\"minor\"", ",", "\"patch\"", ...
Return a new bumped version instance.
[ "Return", "a", "new", "bumped", "version", "instance", "." ]
train
https://github.com/mbarakaja/braulio/blob/70ab6f0dd631ef78c4da1b39d1c6fb6f9a995d2b/braulio/version.py#L108-L155
rorr73/LifeSOSpy
lifesospy/asynchelper.py
AsyncHelper.create_task
def create_task(self, target: Callable[..., Any], *args: Any)\ -> asyncio.tasks.Task: """Create task and add to our collection of pending tasks.""" if asyncio.iscoroutine(target): task = self._loop.create_task(target) elif asyncio.iscoroutinefunction(target): ...
python
def create_task(self, target: Callable[..., Any], *args: Any)\ -> asyncio.tasks.Task: """Create task and add to our collection of pending tasks.""" if asyncio.iscoroutine(target): task = self._loop.create_task(target) elif asyncio.iscoroutinefunction(target): ...
[ "def", "create_task", "(", "self", ",", "target", ":", "Callable", "[", "...", ",", "Any", "]", ",", "*", "args", ":", "Any", ")", "->", "asyncio", ".", "tasks", ".", "Task", ":", "if", "asyncio", ".", "iscoroutine", "(", "target", ")", ":", "task"...
Create task and add to our collection of pending tasks.
[ "Create", "task", "and", "add", "to", "our", "collection", "of", "pending", "tasks", "." ]
train
https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/asynchelper.py#L20-L30
rorr73/LifeSOSpy
lifesospy/asynchelper.py
AsyncHelper.cancel_pending_tasks
def cancel_pending_tasks(self): """Cancel all pending tasks.""" for task in self._pending_tasks: task.cancel() if not self._loop.is_running(): try: self._loop.run_until_complete(task) except asyncio.CancelledError: ...
python
def cancel_pending_tasks(self): """Cancel all pending tasks.""" for task in self._pending_tasks: task.cancel() if not self._loop.is_running(): try: self._loop.run_until_complete(task) except asyncio.CancelledError: ...
[ "def", "cancel_pending_tasks", "(", "self", ")", ":", "for", "task", "in", "self", ".", "_pending_tasks", ":", "task", ".", "cancel", "(", ")", "if", "not", "self", ".", "_loop", ".", "is_running", "(", ")", ":", "try", ":", "self", ".", "_loop", "."...
Cancel all pending tasks.
[ "Cancel", "all", "pending", "tasks", "." ]
train
https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/asynchelper.py#L32-L43
emilssolmanis/tapes
tapes/distributed/registry.py
RegistryAggregator.start
def start(self, fork=True): """Starts the registry aggregator. :param fork: whether to fork a process; if ``False``, blocks and stays in the existing process """ if not fork: distributed_logger.info('Starting metrics aggregator, not forking') _registry_aggregator...
python
def start(self, fork=True): """Starts the registry aggregator. :param fork: whether to fork a process; if ``False``, blocks and stays in the existing process """ if not fork: distributed_logger.info('Starting metrics aggregator, not forking') _registry_aggregator...
[ "def", "start", "(", "self", ",", "fork", "=", "True", ")", ":", "if", "not", "fork", ":", "distributed_logger", ".", "info", "(", "'Starting metrics aggregator, not forking'", ")", "_registry_aggregator", "(", "self", ".", "reporter", ",", "self", ".", "socke...
Starts the registry aggregator. :param fork: whether to fork a process; if ``False``, blocks and stays in the existing process
[ "Starts", "the", "registry", "aggregator", "." ]
train
https://github.com/emilssolmanis/tapes/blob/7797fc9ebcb359cb1ba5085570e3cab5ebcd1d3c/tapes/distributed/registry.py#L68-L81