repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
jonaprieto/ponywhoosh | ponywhoosh/core.py | PonyWhoosh.create_index | def create_index(self, index):
"""Creates and opens index folder for given index.
If the index already exists, it just opens it, otherwise it creates it first.
"""
index._path = os.path.join(self.indexes_path, index._name)
if whoosh.index.exists_in(index._path):
_whoosh = whoosh.index.open_d... | python | def create_index(self, index):
"""Creates and opens index folder for given index.
If the index already exists, it just opens it, otherwise it creates it first.
"""
index._path = os.path.join(self.indexes_path, index._name)
if whoosh.index.exists_in(index._path):
_whoosh = whoosh.index.open_d... | [
"def",
"create_index",
"(",
"self",
",",
"index",
")",
":",
"index",
".",
"_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"indexes_path",
",",
"index",
".",
"_name",
")",
"if",
"whoosh",
".",
"index",
".",
"exists_in",
"(",
"index",
... | Creates and opens index folder for given index.
If the index already exists, it just opens it, otherwise it creates it first. | [
"Creates",
"and",
"opens",
"index",
"folder",
"for",
"given",
"index",
".",
"If",
"the",
"index",
"already",
"exists",
"it",
"just",
"opens",
"it",
"otherwise",
"it",
"creates",
"it",
"first",
"."
] | train | https://github.com/jonaprieto/ponywhoosh/blob/1915ac015a61229dbdefd1ac8a73adce732b4a39/ponywhoosh/core.py#L76-L88 |
jonaprieto/ponywhoosh | ponywhoosh/core.py | PonyWhoosh.register_index | def register_index(self, index):
"""Registers a given index:
* Creates and opens an index for it (if it doesn't exist yet)
* Sets some default values on it (unless they're already set)
Args:
index (PonyWhoosh.Index): An instance of PonyWhoosh.Index class
"""
self._indexes[index._name]... | python | def register_index(self, index):
"""Registers a given index:
* Creates and opens an index for it (if it doesn't exist yet)
* Sets some default values on it (unless they're already set)
Args:
index (PonyWhoosh.Index): An instance of PonyWhoosh.Index class
"""
self._indexes[index._name]... | [
"def",
"register_index",
"(",
"self",
",",
"index",
")",
":",
"self",
".",
"_indexes",
"[",
"index",
".",
"_name",
"]",
"=",
"index",
"self",
".",
"create_index",
"(",
"index",
")",
"return",
"index"
] | Registers a given index:
* Creates and opens an index for it (if it doesn't exist yet)
* Sets some default values on it (unless they're already set)
Args:
index (PonyWhoosh.Index): An instance of PonyWhoosh.Index class | [
"Registers",
"a",
"given",
"index",
":"
] | train | https://github.com/jonaprieto/ponywhoosh/blob/1915ac015a61229dbdefd1ac8a73adce732b4a39/ponywhoosh/core.py#L90-L102 |
jonaprieto/ponywhoosh | ponywhoosh/core.py | PonyWhoosh.register_model | def register_model(self, *fields, **kw):
"""Registers a single model for fulltext search. This basically creates
a simple PonyWhoosh.Index for the model and calls self.register_index on it.
Args:
*fields: all the fields indexed from the model.
**kw: The options for each field, sortedby, sto... | python | def register_model(self, *fields, **kw):
"""Registers a single model for fulltext search. This basically creates
a simple PonyWhoosh.Index for the model and calls self.register_index on it.
Args:
*fields: all the fields indexed from the model.
**kw: The options for each field, sortedby, sto... | [
"def",
"register_model",
"(",
"self",
",",
"*",
"fields",
",",
"*",
"*",
"kw",
")",
":",
"index",
"=",
"PonyWhooshIndex",
"(",
"pw",
"=",
"self",
")",
"index",
".",
"_kw",
"=",
"kw",
"index",
".",
"_fields",
"=",
"fields",
"def",
"inner",
"(",
"mod... | Registers a single model for fulltext search. This basically creates
a simple PonyWhoosh.Index for the model and calls self.register_index on it.
Args:
*fields: all the fields indexed from the model.
**kw: The options for each field, sortedby, stored ... | [
"Registers",
"a",
"single",
"model",
"for",
"fulltext",
"search",
".",
"This",
"basically",
"creates",
"a",
"simple",
"PonyWhoosh",
".",
"Index",
"for",
"the",
"model",
"and",
"calls",
"self",
".",
"register_index",
"on",
"it",
"."
] | train | https://github.com/jonaprieto/ponywhoosh/blob/1915ac015a61229dbdefd1ac8a73adce732b4a39/ponywhoosh/core.py#L104-L234 |
jonaprieto/ponywhoosh | ponywhoosh/core.py | PonyWhoosh.search | def search(self, *arg, **kw):
"""A full search function. This allows you to search expression
using the following arguments.
Arg:
query (str): The search string expression.
Optional Args:
- include_entity (bool): include in each result the entity values associated of the fields stored.... | python | def search(self, *arg, **kw):
"""A full search function. This allows you to search expression
using the following arguments.
Arg:
query (str): The search string expression.
Optional Args:
- include_entity (bool): include in each result the entity values associated of the fields stored.... | [
"def",
"search",
"(",
"self",
",",
"*",
"arg",
",",
"*",
"*",
"kw",
")",
":",
"output",
"=",
"{",
"'cant_results'",
":",
"0",
",",
"'matched_terms'",
":",
"defaultdict",
"(",
"set",
")",
",",
"'results'",
":",
"{",
"}",
",",
"'runtime'",
":",
"0",
... | A full search function. This allows you to search expression
using the following arguments.
Arg:
query (str): The search string expression.
Optional Args:
- include_entity (bool): include in each result the entity values associated of the fields stored.
- add_wildcards (bool): set ... | [
"A",
"full",
"search",
"function",
".",
"This",
"allows",
"you",
"to",
"search",
"expression",
"using",
"the",
"following",
"arguments",
"."
] | train | https://github.com/jonaprieto/ponywhoosh/blob/1915ac015a61229dbdefd1ac8a73adce732b4a39/ponywhoosh/core.py#L237-L305 |
bcaller/pinyin_markdown | pinyin_markdown/pinyin_regex.py | _sounds_re | def _sounds_re(include_erhua=False):
"""Sounds are syllables + tones"""
tone = '[1-5]'
optional_final_erhua = '|r\\b' if include_erhua else ''
pattern = '({}{}{})'.format(_joined_syllables_re(), tone, optional_final_erhua)
return re.compile(pattern, re.IGNORECASE) | python | def _sounds_re(include_erhua=False):
"""Sounds are syllables + tones"""
tone = '[1-5]'
optional_final_erhua = '|r\\b' if include_erhua else ''
pattern = '({}{}{})'.format(_joined_syllables_re(), tone, optional_final_erhua)
return re.compile(pattern, re.IGNORECASE) | [
"def",
"_sounds_re",
"(",
"include_erhua",
"=",
"False",
")",
":",
"tone",
"=",
"'[1-5]'",
"optional_final_erhua",
"=",
"'|r\\\\b'",
"if",
"include_erhua",
"else",
"''",
"pattern",
"=",
"'({}{}{})'",
".",
"format",
"(",
"_joined_syllables_re",
"(",
")",
",",
"... | Sounds are syllables + tones | [
"Sounds",
"are",
"syllables",
"+",
"tones"
] | train | https://github.com/bcaller/pinyin_markdown/blob/d2f07233b37a885478198fb2fdf9978a250d82d3/pinyin_markdown/pinyin_regex.py#L43-L49 |
KelSolaar/Foundations | utilities/sanitizer.py | bleach | def bleach(file):
"""
Sanitizes given python module.
:param file: Python module file.
:type file: unicode
:return: Definition success.
:rtype: bool
"""
LOGGER.info("{0} | Sanitizing '{1}' python module!".format(__name__, file))
source_file = File(file)
content = source_file.re... | python | def bleach(file):
"""
Sanitizes given python module.
:param file: Python module file.
:type file: unicode
:return: Definition success.
:rtype: bool
"""
LOGGER.info("{0} | Sanitizing '{1}' python module!".format(__name__, file))
source_file = File(file)
content = source_file.re... | [
"def",
"bleach",
"(",
"file",
")",
":",
"LOGGER",
".",
"info",
"(",
"\"{0} | Sanitizing '{1}' python module!\"",
".",
"format",
"(",
"__name__",
",",
"file",
")",
")",
"source_file",
"=",
"File",
"(",
"file",
")",
"content",
"=",
"source_file",
".",
"read",
... | Sanitizes given python module.
:param file: Python module file.
:type file: unicode
:return: Definition success.
:rtype: bool | [
"Sanitizes",
"given",
"python",
"module",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/utilities/sanitizer.py#L47-L81 |
jrabbit/taskd-client-py | taskc/transaction.py | mk_message | def mk_message(org, user, key):
"""
Make message
"""
m = Message()
m['client'] = "taskc-py {0}".format(__version__)
m['protocol'] = "v1"
m['org'] = org
m['user'] = user
m['key'] = key
return m | python | def mk_message(org, user, key):
"""
Make message
"""
m = Message()
m['client'] = "taskc-py {0}".format(__version__)
m['protocol'] = "v1"
m['org'] = org
m['user'] = user
m['key'] = key
return m | [
"def",
"mk_message",
"(",
"org",
",",
"user",
",",
"key",
")",
":",
"m",
"=",
"Message",
"(",
")",
"m",
"[",
"'client'",
"]",
"=",
"\"taskc-py {0}\"",
".",
"format",
"(",
"__version__",
")",
"m",
"[",
"'protocol'",
"]",
"=",
"\"v1\"",
"m",
"[",
"'o... | Make message | [
"Make",
"message"
] | train | https://github.com/jrabbit/taskd-client-py/blob/473f121eca7fdb358874c9c00827f9a6ecdcda4e/taskc/transaction.py#L12-L24 |
jrabbit/taskd-client-py | taskc/transaction.py | prep_message | def prep_message(msg):
"""
Add the size header
"""
if six.PY3:
msg_out = msg.as_string().encode("utf-8")
else:
msg_out = msg.as_string()
our_len = len(msg_out) + 4
size = struct.pack('>L', our_len)
# why the hell is this "bytes" on python3?
return size + msg_out | python | def prep_message(msg):
"""
Add the size header
"""
if six.PY3:
msg_out = msg.as_string().encode("utf-8")
else:
msg_out = msg.as_string()
our_len = len(msg_out) + 4
size = struct.pack('>L', our_len)
# why the hell is this "bytes" on python3?
return size + msg_out | [
"def",
"prep_message",
"(",
"msg",
")",
":",
"if",
"six",
".",
"PY3",
":",
"msg_out",
"=",
"msg",
".",
"as_string",
"(",
")",
".",
"encode",
"(",
"\"utf-8\"",
")",
"else",
":",
"msg_out",
"=",
"msg",
".",
"as_string",
"(",
")",
"our_len",
"=",
"len... | Add the size header | [
"Add",
"the",
"size",
"header"
] | train | https://github.com/jrabbit/taskd-client-py/blob/473f121eca7fdb358874c9c00827f9a6ecdcda4e/taskc/transaction.py#L27-L40 |
btr1975/ipaddresstools | ipaddresstools/ipaddresstools.py | ucast_ip_mask | def ucast_ip_mask(ip_addr_and_mask, return_tuple=True):
"""
Function to check if a address is unicast and that the CIDR mask is good
Args:
ip_addr_and_mask: Unicast IP address and mask in the following format 192.168.1.1/24
return_tuple: Set to True it returns a IP and mask in a tuple, set t... | python | def ucast_ip_mask(ip_addr_and_mask, return_tuple=True):
"""
Function to check if a address is unicast and that the CIDR mask is good
Args:
ip_addr_and_mask: Unicast IP address and mask in the following format 192.168.1.1/24
return_tuple: Set to True it returns a IP and mask in a tuple, set t... | [
"def",
"ucast_ip_mask",
"(",
"ip_addr_and_mask",
",",
"return_tuple",
"=",
"True",
")",
":",
"regex_ucast_ip_and_mask",
"=",
"__re",
".",
"compile",
"(",
"\"^((22[0-3])|(2[0-1][0-9])|(1[0-9][0-9])|([1-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9]?[0-9]))\\.((25[0-5])|(2[... | Function to check if a address is unicast and that the CIDR mask is good
Args:
ip_addr_and_mask: Unicast IP address and mask in the following format 192.168.1.1/24
return_tuple: Set to True it returns a IP and mask in a tuple, set to False returns True or False
Returns: see return_tuple for ret... | [
"Function",
"to",
"check",
"if",
"a",
"address",
"is",
"unicast",
"and",
"that",
"the",
"CIDR",
"mask",
"is",
"good",
"Args",
":",
"ip_addr_and_mask",
":",
"Unicast",
"IP",
"address",
"and",
"mask",
"in",
"the",
"following",
"format",
"192",
".",
"168",
... | train | https://github.com/btr1975/ipaddresstools/blob/759e91b3fdf1e8a8eea55337b09f53a94ad2016e/ipaddresstools/ipaddresstools.py#L147-L171 |
btr1975/ipaddresstools | ipaddresstools/ipaddresstools.py | ucast_ip | def ucast_ip(ip_addr, return_tuple=True):
"""
Function to check if a address is unicast
Args:
ip_addr: Unicast IP address in the following format 192.168.1.1
return_tuple: Set to True it returns a IP, set to False returns True or False
Returns: see return_tuple for return options
"... | python | def ucast_ip(ip_addr, return_tuple=True):
"""
Function to check if a address is unicast
Args:
ip_addr: Unicast IP address in the following format 192.168.1.1
return_tuple: Set to True it returns a IP, set to False returns True or False
Returns: see return_tuple for return options
"... | [
"def",
"ucast_ip",
"(",
"ip_addr",
",",
"return_tuple",
"=",
"True",
")",
":",
"regex_ucast_ip",
"=",
"__re",
".",
"compile",
"(",
"\"^((22[0-3])|(2[0-1][0-9])|(1[0-9][0-9])|([1-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9]... | Function to check if a address is unicast
Args:
ip_addr: Unicast IP address in the following format 192.168.1.1
return_tuple: Set to True it returns a IP, set to False returns True or False
Returns: see return_tuple for return options | [
"Function",
"to",
"check",
"if",
"a",
"address",
"is",
"unicast",
"Args",
":",
"ip_addr",
":",
"Unicast",
"IP",
"address",
"in",
"the",
"following",
"format",
"192",
".",
"168",
".",
"1",
".",
"1",
"return_tuple",
":",
"Set",
"to",
"True",
"it",
"retur... | train | https://github.com/btr1975/ipaddresstools/blob/759e91b3fdf1e8a8eea55337b09f53a94ad2016e/ipaddresstools/ipaddresstools.py#L174-L195 |
btr1975/ipaddresstools | ipaddresstools/ipaddresstools.py | mcast_ip_mask | def mcast_ip_mask(ip_addr_and_mask, return_tuple=True):
"""
Function to check if a address is multicast and that the CIDR mask is good
Args:
ip_addr_and_mask: Multicast IP address and mask in the following format 239.1.1.1/24
return_tuple: Set to True it returns a IP and mask in a tuple, set... | python | def mcast_ip_mask(ip_addr_and_mask, return_tuple=True):
"""
Function to check if a address is multicast and that the CIDR mask is good
Args:
ip_addr_and_mask: Multicast IP address and mask in the following format 239.1.1.1/24
return_tuple: Set to True it returns a IP and mask in a tuple, set... | [
"def",
"mcast_ip_mask",
"(",
"ip_addr_and_mask",
",",
"return_tuple",
"=",
"True",
")",
":",
"regex_mcast_ip_and_mask",
"=",
"__re",
".",
"compile",
"(",
"\"^(((2[2-3][4-9])|(23[0-3]))\\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([... | Function to check if a address is multicast and that the CIDR mask is good
Args:
ip_addr_and_mask: Multicast IP address and mask in the following format 239.1.1.1/24
return_tuple: Set to True it returns a IP and mask in a tuple, set to False returns True or False
Returns: see return_tuple for r... | [
"Function",
"to",
"check",
"if",
"a",
"address",
"is",
"multicast",
"and",
"that",
"the",
"CIDR",
"mask",
"is",
"good",
"Args",
":",
"ip_addr_and_mask",
":",
"Multicast",
"IP",
"address",
"and",
"mask",
"in",
"the",
"following",
"format",
"239",
".",
"1",
... | train | https://github.com/btr1975/ipaddresstools/blob/759e91b3fdf1e8a8eea55337b09f53a94ad2016e/ipaddresstools/ipaddresstools.py#L198-L222 |
btr1975/ipaddresstools | ipaddresstools/ipaddresstools.py | mcast_ip | def mcast_ip(ip_addr, return_tuple=True):
"""
Function to check if a address is multicast
Args:
ip_addr: Multicast IP address in the following format 239.1.1.1
return_tuple: Set to True it returns a IP, set to False returns True or False
Returns: see return_tuple for return options
... | python | def mcast_ip(ip_addr, return_tuple=True):
"""
Function to check if a address is multicast
Args:
ip_addr: Multicast IP address in the following format 239.1.1.1
return_tuple: Set to True it returns a IP, set to False returns True or False
Returns: see return_tuple for return options
... | [
"def",
"mcast_ip",
"(",
"ip_addr",
",",
"return_tuple",
"=",
"True",
")",
":",
"regex_mcast_ip",
"=",
"__re",
".",
"compile",
"(",
"\"^(((2[2-3][4-9])|(23[0-3]))\\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9]?[0-9]))\\.((25[0-5... | Function to check if a address is multicast
Args:
ip_addr: Multicast IP address in the following format 239.1.1.1
return_tuple: Set to True it returns a IP, set to False returns True or False
Returns: see return_tuple for return options | [
"Function",
"to",
"check",
"if",
"a",
"address",
"is",
"multicast",
"Args",
":",
"ip_addr",
":",
"Multicast",
"IP",
"address",
"in",
"the",
"following",
"format",
"239",
".",
"1",
".",
"1",
".",
"1",
"return_tuple",
":",
"Set",
"to",
"True",
"it",
"ret... | train | https://github.com/btr1975/ipaddresstools/blob/759e91b3fdf1e8a8eea55337b09f53a94ad2016e/ipaddresstools/ipaddresstools.py#L225-L246 |
btr1975/ipaddresstools | ipaddresstools/ipaddresstools.py | ip_mask | def ip_mask(ip_addr_and_mask, return_tuple=True):
"""
Function to check if a address and CIDR mask is good
Args:
ip_addr_and_mask: IP address and mask in the following format 192.168.1.1/24
return_tuple: Set to True it returns a IP and mask in a tuple, set to False returns True or False
... | python | def ip_mask(ip_addr_and_mask, return_tuple=True):
"""
Function to check if a address and CIDR mask is good
Args:
ip_addr_and_mask: IP address and mask in the following format 192.168.1.1/24
return_tuple: Set to True it returns a IP and mask in a tuple, set to False returns True or False
... | [
"def",
"ip_mask",
"(",
"ip_addr_and_mask",
",",
"return_tuple",
"=",
"True",
")",
":",
"regex_ip_and_mask",
"=",
"__re",
".",
"compile",
"(",
"\"^((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|(... | Function to check if a address and CIDR mask is good
Args:
ip_addr_and_mask: IP address and mask in the following format 192.168.1.1/24
return_tuple: Set to True it returns a IP and mask in a tuple, set to False returns True or False
Returns: see return_tuple for return options | [
"Function",
"to",
"check",
"if",
"a",
"address",
"and",
"CIDR",
"mask",
"is",
"good",
"Args",
":",
"ip_addr_and_mask",
":",
"IP",
"address",
"and",
"mask",
"in",
"the",
"following",
"format",
"192",
".",
"168",
".",
"1",
".",
"1",
"/",
"24",
"return_tu... | train | https://github.com/btr1975/ipaddresstools/blob/759e91b3fdf1e8a8eea55337b09f53a94ad2016e/ipaddresstools/ipaddresstools.py#L249-L273 |
btr1975/ipaddresstools | ipaddresstools/ipaddresstools.py | ip | def ip(ip_addr, return_tuple=True):
"""
Function to check if a address is good
Args:
ip_addr: IP address in the following format 192.168.1.1
return_tuple: Set to True it returns a IP, set to False returns True or False
Returns: see return_tuple for return options
"""
regex_ip =... | python | def ip(ip_addr, return_tuple=True):
"""
Function to check if a address is good
Args:
ip_addr: IP address in the following format 192.168.1.1
return_tuple: Set to True it returns a IP, set to False returns True or False
Returns: see return_tuple for return options
"""
regex_ip =... | [
"def",
"ip",
"(",
"ip_addr",
",",
"return_tuple",
"=",
"True",
")",
":",
"regex_ip",
"=",
"__re",
".",
"compile",
"(",
"\"^((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|(1[0-9][0-9])|([1-9]?[0-... | Function to check if a address is good
Args:
ip_addr: IP address in the following format 192.168.1.1
return_tuple: Set to True it returns a IP, set to False returns True or False
Returns: see return_tuple for return options | [
"Function",
"to",
"check",
"if",
"a",
"address",
"is",
"good",
"Args",
":",
"ip_addr",
":",
"IP",
"address",
"in",
"the",
"following",
"format",
"192",
".",
"168",
".",
"1",
".",
"1",
"return_tuple",
":",
"Set",
"to",
"True",
"it",
"returns",
"a",
"I... | train | https://github.com/btr1975/ipaddresstools/blob/759e91b3fdf1e8a8eea55337b09f53a94ad2016e/ipaddresstools/ipaddresstools.py#L276-L297 |
btr1975/ipaddresstools | ipaddresstools/ipaddresstools.py | cidr_check | def cidr_check(cidr, return_cidr=True):
"""
Function to verify a good CIDR value
Args:
cidr: CIDR value 0 to 32
return_cidr: Set to True it returns a CIDR value, set to False returns True or False
Returns: see return_cidr for return options
"""
try:
if int(cidr) < 0 or ... | python | def cidr_check(cidr, return_cidr=True):
"""
Function to verify a good CIDR value
Args:
cidr: CIDR value 0 to 32
return_cidr: Set to True it returns a CIDR value, set to False returns True or False
Returns: see return_cidr for return options
"""
try:
if int(cidr) < 0 or ... | [
"def",
"cidr_check",
"(",
"cidr",
",",
"return_cidr",
"=",
"True",
")",
":",
"try",
":",
"if",
"int",
"(",
"cidr",
")",
"<",
"0",
"or",
"int",
"(",
"cidr",
")",
">",
"32",
":",
"good_cidr",
"=",
"False",
"else",
":",
"good_cidr",
"=",
"True",
"if... | Function to verify a good CIDR value
Args:
cidr: CIDR value 0 to 32
return_cidr: Set to True it returns a CIDR value, set to False returns True or False
Returns: see return_cidr for return options | [
"Function",
"to",
"verify",
"a",
"good",
"CIDR",
"value",
"Args",
":",
"cidr",
":",
"CIDR",
"value",
"0",
"to",
"32",
"return_cidr",
":",
"Set",
"to",
"True",
"it",
"returns",
"a",
"CIDR",
"value",
"set",
"to",
"False",
"returns",
"True",
"or",
"False"... | train | https://github.com/btr1975/ipaddresstools/blob/759e91b3fdf1e8a8eea55337b09f53a94ad2016e/ipaddresstools/ipaddresstools.py#L300-L329 |
btr1975/ipaddresstools | ipaddresstools/ipaddresstools.py | get_neighbor_ip | def get_neighbor_ip(ip_addr, cidr="30"):
"""
Function to figure out the IP's between neighbors address
Args:
ip_addr: Unicast IP address in the following format 192.168.1.1
cidr: CIDR value of 30, or 31
Returns: returns Our IP and the Neighbor IP in a tuple
"""
our_octet = None... | python | def get_neighbor_ip(ip_addr, cidr="30"):
"""
Function to figure out the IP's between neighbors address
Args:
ip_addr: Unicast IP address in the following format 192.168.1.1
cidr: CIDR value of 30, or 31
Returns: returns Our IP and the Neighbor IP in a tuple
"""
our_octet = None... | [
"def",
"get_neighbor_ip",
"(",
"ip_addr",
",",
"cidr",
"=",
"\"30\"",
")",
":",
"our_octet",
"=",
"None",
"neighbor_octet",
"=",
"None",
"try",
":",
"ip_addr_split",
"=",
"ip_addr",
".",
"split",
"(",
"\".\"",
")",
"max_counter",
"=",
"0",
"if",
"int",
"... | Function to figure out the IP's between neighbors address
Args:
ip_addr: Unicast IP address in the following format 192.168.1.1
cidr: CIDR value of 30, or 31
Returns: returns Our IP and the Neighbor IP in a tuple | [
"Function",
"to",
"figure",
"out",
"the",
"IP",
"s",
"between",
"neighbors",
"address",
"Args",
":",
"ip_addr",
":",
"Unicast",
"IP",
"address",
"in",
"the",
"following",
"format",
"192",
".",
"168",
".",
"1",
".",
"1",
"cidr",
":",
"CIDR",
"value",
"o... | train | https://github.com/btr1975/ipaddresstools/blob/759e91b3fdf1e8a8eea55337b09f53a94ad2016e/ipaddresstools/ipaddresstools.py#L332-L379 |
btr1975/ipaddresstools | ipaddresstools/ipaddresstools.py | whole_subnet_maker | def whole_subnet_maker(ip_addr, cidr):
"""
Function to return a whole subnet value from a IP address and CIDR pair
Args:
ip_addr: Unicast or Multicast IP address or subnet in the following format 192.168.1.1, 239.1.1.1
cidr: CIDR value of 0 to 32
Returns: returns the corrected whole sub... | python | def whole_subnet_maker(ip_addr, cidr):
"""
Function to return a whole subnet value from a IP address and CIDR pair
Args:
ip_addr: Unicast or Multicast IP address or subnet in the following format 192.168.1.1, 239.1.1.1
cidr: CIDR value of 0 to 32
Returns: returns the corrected whole sub... | [
"def",
"whole_subnet_maker",
"(",
"ip_addr",
",",
"cidr",
")",
":",
"if",
"ucast_ip",
"(",
"ip_addr",
",",
"False",
")",
"==",
"False",
"and",
"mcast_ip",
"(",
"ip_addr",
",",
"False",
")",
"==",
"False",
":",
"LOGGER",
".",
"critical",
"(",
"'Function w... | Function to return a whole subnet value from a IP address and CIDR pair
Args:
ip_addr: Unicast or Multicast IP address or subnet in the following format 192.168.1.1, 239.1.1.1
cidr: CIDR value of 0 to 32
Returns: returns the corrected whole subnet | [
"Function",
"to",
"return",
"a",
"whole",
"subnet",
"value",
"from",
"a",
"IP",
"address",
"and",
"CIDR",
"pair",
"Args",
":",
"ip_addr",
":",
"Unicast",
"or",
"Multicast",
"IP",
"address",
"or",
"subnet",
"in",
"the",
"following",
"format",
"192",
".",
... | train | https://github.com/btr1975/ipaddresstools/blob/759e91b3fdf1e8a8eea55337b09f53a94ad2016e/ipaddresstools/ipaddresstools.py#L382-L438 |
btr1975/ipaddresstools | ipaddresstools/ipaddresstools.py | subnet_range | def subnet_range(ip_net, cidr):
"""
Function to return a subnet range value from a IP address and CIDR pair
Args:
ip_net: Unicast or Multicast IP address or subnet in the following format 192.168.1.1, 239.1.1.1
cidr: CIDR value of 1 to 32
Returns: returns a dictionary of info
"""
... | python | def subnet_range(ip_net, cidr):
"""
Function to return a subnet range value from a IP address and CIDR pair
Args:
ip_net: Unicast or Multicast IP address or subnet in the following format 192.168.1.1, 239.1.1.1
cidr: CIDR value of 1 to 32
Returns: returns a dictionary of info
"""
... | [
"def",
"subnet_range",
"(",
"ip_net",
",",
"cidr",
")",
":",
"subnets_dict",
"=",
"dict",
"(",
")",
"subnet",
"=",
"whole_subnet_maker",
"(",
"ip_net",
",",
"cidr",
")",
"subnets_dict",
"[",
"'IP'",
"]",
"=",
"ip_net",
"subnets_dict",
"[",
"'NET'",
"]",
... | Function to return a subnet range value from a IP address and CIDR pair
Args:
ip_net: Unicast or Multicast IP address or subnet in the following format 192.168.1.1, 239.1.1.1
cidr: CIDR value of 1 to 32
Returns: returns a dictionary of info | [
"Function",
"to",
"return",
"a",
"subnet",
"range",
"value",
"from",
"a",
"IP",
"address",
"and",
"CIDR",
"pair",
"Args",
":",
"ip_net",
":",
"Unicast",
"or",
"Multicast",
"IP",
"address",
"or",
"subnet",
"in",
"the",
"following",
"format",
"192",
".",
"... | train | https://github.com/btr1975/ipaddresstools/blob/759e91b3fdf1e8a8eea55337b09f53a94ad2016e/ipaddresstools/ipaddresstools.py#L441-L499 |
btr1975/ipaddresstools | ipaddresstools/ipaddresstools.py | all_subnets_longer_prefix | def all_subnets_longer_prefix(ip_net, cidr):
"""
Function to return every subnet a ip can belong to with a longer prefix
Args:
ip_net: Unicast or Multicast IP address or subnet in the following format 192.168.1.1, 239.1.1.1
cidr: CIDR value of 0 to 32
Returns: returns a list of subnets
... | python | def all_subnets_longer_prefix(ip_net, cidr):
"""
Function to return every subnet a ip can belong to with a longer prefix
Args:
ip_net: Unicast or Multicast IP address or subnet in the following format 192.168.1.1, 239.1.1.1
cidr: CIDR value of 0 to 32
Returns: returns a list of subnets
... | [
"def",
"all_subnets_longer_prefix",
"(",
"ip_net",
",",
"cidr",
")",
":",
"subnets_list",
"=",
"list",
"(",
")",
"while",
"int",
"(",
"cidr",
")",
"<=",
"32",
":",
"try",
":",
"subnets_list",
".",
"append",
"(",
"'%s/%s'",
"%",
"(",
"whole_subnet_maker",
... | Function to return every subnet a ip can belong to with a longer prefix
Args:
ip_net: Unicast or Multicast IP address or subnet in the following format 192.168.1.1, 239.1.1.1
cidr: CIDR value of 0 to 32
Returns: returns a list of subnets | [
"Function",
"to",
"return",
"every",
"subnet",
"a",
"ip",
"can",
"belong",
"to",
"with",
"a",
"longer",
"prefix",
"Args",
":",
"ip_net",
":",
"Unicast",
"or",
"Multicast",
"IP",
"address",
"or",
"subnet",
"in",
"the",
"following",
"format",
"192",
".",
"... | train | https://github.com/btr1975/ipaddresstools/blob/759e91b3fdf1e8a8eea55337b09f53a94ad2016e/ipaddresstools/ipaddresstools.py#L515-L533 |
btr1975/ipaddresstools | ipaddresstools/ipaddresstools.py | all_subnets_shorter_prefix | def all_subnets_shorter_prefix(ip_net, cidr, include_default=False):
"""
Function to return every subnet a ip can belong to with a shorter prefix
Args:
ip_net: Unicast or Multicast IP address or subnet in the following format 192.168.1.1, 239.1.1.1
cidr: CIDR value of 0 to 32
include... | python | def all_subnets_shorter_prefix(ip_net, cidr, include_default=False):
"""
Function to return every subnet a ip can belong to with a shorter prefix
Args:
ip_net: Unicast or Multicast IP address or subnet in the following format 192.168.1.1, 239.1.1.1
cidr: CIDR value of 0 to 32
include... | [
"def",
"all_subnets_shorter_prefix",
"(",
"ip_net",
",",
"cidr",
",",
"include_default",
"=",
"False",
")",
":",
"subnets_list",
"=",
"list",
"(",
")",
"if",
"include_default",
":",
"while",
"int",
"(",
"cidr",
")",
">=",
"0",
":",
"try",
":",
"subnets_lis... | Function to return every subnet a ip can belong to with a shorter prefix
Args:
ip_net: Unicast or Multicast IP address or subnet in the following format 192.168.1.1, 239.1.1.1
cidr: CIDR value of 0 to 32
include_default: If you want the list to inlclude the default route set to True
Ret... | [
"Function",
"to",
"return",
"every",
"subnet",
"a",
"ip",
"can",
"belong",
"to",
"with",
"a",
"shorter",
"prefix",
"Args",
":",
"ip_net",
":",
"Unicast",
"or",
"Multicast",
"IP",
"address",
"or",
"subnet",
"in",
"the",
"following",
"format",
"192",
".",
... | train | https://github.com/btr1975/ipaddresstools/blob/759e91b3fdf1e8a8eea55337b09f53a94ad2016e/ipaddresstools/ipaddresstools.py#L536-L562 |
btr1975/ipaddresstools | ipaddresstools/ipaddresstools.py | all_ip_address_in_subnet | def all_ip_address_in_subnet(ip_net, cidr):
"""
Function to return every ip in a subnet
:param ip_net: Unicast or Multicast IP address or subnet in the following format 192.168.1.1, 239.1.1.1
:param cidr: CIDR value of 0 to 32
:return:
A list of ip address's
"""
ip_address_list... | python | def all_ip_address_in_subnet(ip_net, cidr):
"""
Function to return every ip in a subnet
:param ip_net: Unicast or Multicast IP address or subnet in the following format 192.168.1.1, 239.1.1.1
:param cidr: CIDR value of 0 to 32
:return:
A list of ip address's
"""
ip_address_list... | [
"def",
"all_ip_address_in_subnet",
"(",
"ip_net",
",",
"cidr",
")",
":",
"ip_address_list",
"=",
"list",
"(",
")",
"if",
"not",
"ip_mask",
"(",
"'{ip_net}/{cidr}'",
".",
"format",
"(",
"ip_net",
"=",
"ip_net",
",",
"cidr",
"=",
"cidr",
")",
",",
"return_tu... | Function to return every ip in a subnet
:param ip_net: Unicast or Multicast IP address or subnet in the following format 192.168.1.1, 239.1.1.1
:param cidr: CIDR value of 0 to 32
:return:
A list of ip address's | [
"Function",
"to",
"return",
"every",
"ip",
"in",
"a",
"subnet",
":",
"param",
"ip_net",
":",
"Unicast",
"or",
"Multicast",
"IP",
"address",
"or",
"subnet",
"in",
"the",
"following",
"format",
"192",
".",
"168",
".",
"1",
".",
"1",
"239",
".",
"1",
".... | train | https://github.com/btr1975/ipaddresstools/blob/759e91b3fdf1e8a8eea55337b09f53a94ad2016e/ipaddresstools/ipaddresstools.py#L565-L587 |
btr1975/ipaddresstools | ipaddresstools/ipaddresstools.py | number_check | def number_check(check, return_number=True):
"""
Function to verify item entered is a number
Args:
check: Thing to check for a number
return_number: Set to True it returns a number value, set to False returns True or False
Returns: Check return_number for return options
"""
try... | python | def number_check(check, return_number=True):
"""
Function to verify item entered is a number
Args:
check: Thing to check for a number
return_number: Set to True it returns a number value, set to False returns True or False
Returns: Check return_number for return options
"""
try... | [
"def",
"number_check",
"(",
"check",
",",
"return_number",
"=",
"True",
")",
":",
"try",
":",
"int",
"(",
"check",
")",
"good",
"=",
"True",
"except",
"ValueError",
":",
"LOGGER",
".",
"critical",
"(",
"'Function number_check ValueError {item}'",
".",
"format"... | Function to verify item entered is a number
Args:
check: Thing to check for a number
return_number: Set to True it returns a number value, set to False returns True or False
Returns: Check return_number for return options | [
"Function",
"to",
"verify",
"item",
"entered",
"is",
"a",
"number",
"Args",
":",
"check",
":",
"Thing",
"to",
"check",
"for",
"a",
"number",
"return_number",
":",
"Set",
"to",
"True",
"it",
"returns",
"a",
"number",
"value",
"set",
"to",
"False",
"return... | train | https://github.com/btr1975/ipaddresstools/blob/759e91b3fdf1e8a8eea55337b09f53a94ad2016e/ipaddresstools/ipaddresstools.py#L590-L619 |
btr1975/ipaddresstools | ipaddresstools/ipaddresstools.py | random_cidr_mask | def random_cidr_mask(lowest_mask=16):
"""
Function to generate a random CIDR value
:param
lowest_mask: An integer value for the lowest mask you want it to generate
:return:
A string of a random CIDR mask
"""
if lowest_mask < 33:
return str(__random.randran... | python | def random_cidr_mask(lowest_mask=16):
"""
Function to generate a random CIDR value
:param
lowest_mask: An integer value for the lowest mask you want it to generate
:return:
A string of a random CIDR mask
"""
if lowest_mask < 33:
return str(__random.randran... | [
"def",
"random_cidr_mask",
"(",
"lowest_mask",
"=",
"16",
")",
":",
"if",
"lowest_mask",
"<",
"33",
":",
"return",
"str",
"(",
"__random",
".",
"randrange",
"(",
"lowest_mask",
",",
"33",
")",
")",
"else",
":",
"LOGGER",
".",
"critical",
"(",
"'{lowest_m... | Function to generate a random CIDR value
:param
lowest_mask: An integer value for the lowest mask you want it to generate
:return:
A string of a random CIDR mask | [
"Function",
"to",
"generate",
"a",
"random",
"CIDR",
"value",
":",
"param",
"lowest_mask",
":",
"An",
"integer",
"value",
"for",
"the",
"lowest",
"mask",
"you",
"want",
"it",
"to",
"generate",
":",
"return",
":",
"A",
"string",
"of",
"a",
"random",
"CIDR... | train | https://github.com/btr1975/ipaddresstools/blob/759e91b3fdf1e8a8eea55337b09f53a94ad2016e/ipaddresstools/ipaddresstools.py#L622-L637 |
btr1975/ipaddresstools | ipaddresstools/ipaddresstools.py | random_ucast_ip | def random_ucast_ip():
"""
Function to generate a random unicast ip address
:return:
A unicast IP Address
"""
first_octet = str(__random.randrange(1, 224))
def get_other_octetes():
return str(__random.randrange(0, 255))
return '{first_octet}.{second_octet}.{third_octe... | python | def random_ucast_ip():
"""
Function to generate a random unicast ip address
:return:
A unicast IP Address
"""
first_octet = str(__random.randrange(1, 224))
def get_other_octetes():
return str(__random.randrange(0, 255))
return '{first_octet}.{second_octet}.{third_octe... | [
"def",
"random_ucast_ip",
"(",
")",
":",
"first_octet",
"=",
"str",
"(",
"__random",
".",
"randrange",
"(",
"1",
",",
"224",
")",
")",
"def",
"get_other_octetes",
"(",
")",
":",
"return",
"str",
"(",
"__random",
".",
"randrange",
"(",
"0",
",",
"255",
... | Function to generate a random unicast ip address
:return:
A unicast IP Address | [
"Function",
"to",
"generate",
"a",
"random",
"unicast",
"ip",
"address",
":",
"return",
":",
"A",
"unicast",
"IP",
"Address"
] | train | https://github.com/btr1975/ipaddresstools/blob/759e91b3fdf1e8a8eea55337b09f53a94ad2016e/ipaddresstools/ipaddresstools.py#L640-L655 |
inveniosoftware-contrib/invenio-classifier | invenio_classifier/keyworder.py | get_single_keywords | def get_single_keywords(skw_db, fulltext):
"""Find single keywords in the fulltext.
:param skw_db: list of KeywordToken objects
:param fulltext: string, which will be searched
:return : dictionary of matches in a format {
<keyword object>, [[position, position...], ],
..
}
"""
... | python | def get_single_keywords(skw_db, fulltext):
"""Find single keywords in the fulltext.
:param skw_db: list of KeywordToken objects
:param fulltext: string, which will be searched
:return : dictionary of matches in a format {
<keyword object>, [[position, position...], ],
..
}
"""
... | [
"def",
"get_single_keywords",
"(",
"skw_db",
",",
"fulltext",
")",
":",
"timer_start",
"=",
"time",
".",
"clock",
"(",
")",
"# single keyword -> [spans]",
"records",
"=",
"[",
"]",
"for",
"single_keyword",
"in",
"skw_db",
".",
"values",
"(",
")",
":",
"for",... | Find single keywords in the fulltext.
:param skw_db: list of KeywordToken objects
:param fulltext: string, which will be searched
:return : dictionary of matches in a format {
<keyword object>, [[position, position...], ],
..
} | [
"Find",
"single",
"keywords",
"in",
"the",
"fulltext",
"."
] | train | https://github.com/inveniosoftware-contrib/invenio-classifier/blob/3c758cf34dca6bf0548e7da5de34e5f72e3b255e/invenio_classifier/keyworder.py#L37-L88 |
inveniosoftware-contrib/invenio-classifier | invenio_classifier/keyworder.py | get_composite_keywords | def get_composite_keywords(ckw_db, fulltext, skw_spans):
"""Return a list of composite keywords bound with number of occurrences.
:param ckw_db: list of KewordToken objects
(they are supposed to be composite ones)
:param fulltext: string to search in
:param skw_spans: dictionary of a... | python | def get_composite_keywords(ckw_db, fulltext, skw_spans):
"""Return a list of composite keywords bound with number of occurrences.
:param ckw_db: list of KewordToken objects
(they are supposed to be composite ones)
:param fulltext: string to search in
:param skw_spans: dictionary of a... | [
"def",
"get_composite_keywords",
"(",
"ckw_db",
",",
"fulltext",
",",
"skw_spans",
")",
":",
"timer_start",
"=",
"time",
".",
"clock",
"(",
")",
"# Build the list of composite candidates",
"ckw_out",
"=",
"{",
"}",
"skw_as_components",
"=",
"[",
"]",
"for",
"com... | Return a list of composite keywords bound with number of occurrences.
:param ckw_db: list of KewordToken objects
(they are supposed to be composite ones)
:param fulltext: string to search in
:param skw_spans: dictionary of already identified single keywords
:return : dictionary of m... | [
"Return",
"a",
"list",
"of",
"composite",
"keywords",
"bound",
"with",
"number",
"of",
"occurrences",
"."
] | train | https://github.com/inveniosoftware-contrib/invenio-classifier/blob/3c758cf34dca6bf0548e7da5de34e5f72e3b255e/invenio_classifier/keyworder.py#L91-L244 |
inveniosoftware-contrib/invenio-classifier | invenio_classifier/keyworder.py | get_author_keywords | def get_author_keywords(skw_db, ckw_db, fulltext):
"""Find out human defined keywords in a text string.
Searches for the string "Keywords:" and its declinations and matches the
following words.
"""
timer_start = time.clock()
out = {}
split_string = current_app.config[
"CLASSIFIER_A... | python | def get_author_keywords(skw_db, ckw_db, fulltext):
"""Find out human defined keywords in a text string.
Searches for the string "Keywords:" and its declinations and matches the
following words.
"""
timer_start = time.clock()
out = {}
split_string = current_app.config[
"CLASSIFIER_A... | [
"def",
"get_author_keywords",
"(",
"skw_db",
",",
"ckw_db",
",",
"fulltext",
")",
":",
"timer_start",
"=",
"time",
".",
"clock",
"(",
")",
"out",
"=",
"{",
"}",
"split_string",
"=",
"current_app",
".",
"config",
"[",
"\"CLASSIFIER_AUTHOR_KW_START\"",
"]",
".... | Find out human defined keywords in a text string.
Searches for the string "Keywords:" and its declinations and matches the
following words. | [
"Find",
"out",
"human",
"defined",
"keywords",
"in",
"a",
"text",
"string",
"."
] | train | https://github.com/inveniosoftware-contrib/invenio-classifier/blob/3c758cf34dca6bf0548e7da5de34e5f72e3b255e/invenio_classifier/keyworder.py#L247-L308 |
inveniosoftware-contrib/invenio-classifier | invenio_classifier/keyworder.py | _get_ckw_span | def _get_ckw_span(fulltext, spans):
"""Return the span of the composite keyword if it is valid."""
_MAXIMUM_SEPARATOR_LENGTH = max(
[len(_separator)
for _separator in
current_app.config["CLASSIFIER_VALID_SEPARATORS"]]
)
if spans[0] < spans[1]:
words = (spans[0], spans[1... | python | def _get_ckw_span(fulltext, spans):
"""Return the span of the composite keyword if it is valid."""
_MAXIMUM_SEPARATOR_LENGTH = max(
[len(_separator)
for _separator in
current_app.config["CLASSIFIER_VALID_SEPARATORS"]]
)
if spans[0] < spans[1]:
words = (spans[0], spans[1... | [
"def",
"_get_ckw_span",
"(",
"fulltext",
",",
"spans",
")",
":",
"_MAXIMUM_SEPARATOR_LENGTH",
"=",
"max",
"(",
"[",
"len",
"(",
"_separator",
")",
"for",
"_separator",
"in",
"current_app",
".",
"config",
"[",
"\"CLASSIFIER_VALID_SEPARATORS\"",
"]",
"]",
")",
"... | Return the span of the composite keyword if it is valid. | [
"Return",
"the",
"span",
"of",
"the",
"composite",
"keyword",
"if",
"it",
"is",
"valid",
"."
] | train | https://github.com/inveniosoftware-contrib/invenio-classifier/blob/3c758cf34dca6bf0548e7da5de34e5f72e3b255e/invenio_classifier/keyworder.py#L311-L337 |
inveniosoftware-contrib/invenio-classifier | invenio_classifier/keyworder.py | _contains_span | def _contains_span(span0, span1):
"""Return true if span0 contains span1, False otherwise."""
if (span0 == span1 or span0[0] > span1[0] or span0[1] < span1[1]):
return False
return True | python | def _contains_span(span0, span1):
"""Return true if span0 contains span1, False otherwise."""
if (span0 == span1 or span0[0] > span1[0] or span0[1] < span1[1]):
return False
return True | [
"def",
"_contains_span",
"(",
"span0",
",",
"span1",
")",
":",
"if",
"(",
"span0",
"==",
"span1",
"or",
"span0",
"[",
"0",
"]",
">",
"span1",
"[",
"0",
"]",
"or",
"span0",
"[",
"1",
"]",
"<",
"span1",
"[",
"1",
"]",
")",
":",
"return",
"False",... | Return true if span0 contains span1, False otherwise. | [
"Return",
"true",
"if",
"span0",
"contains",
"span1",
"False",
"otherwise",
"."
] | train | https://github.com/inveniosoftware-contrib/invenio-classifier/blob/3c758cf34dca6bf0548e7da5de34e5f72e3b255e/invenio_classifier/keyworder.py#L340-L344 |
goshuirc/irc | girc/types.py | Channel.has_privs | def has_privs(self, user, lowest_mode='o'):
"""Return True if user has the given mode or higher."""
if isinstance(user, User):
user = user.nick
user_prefixes = self.prefixes.get(user, None)
if not user_prefixes:
return False
mode_dict = self.s.features.... | python | def has_privs(self, user, lowest_mode='o'):
"""Return True if user has the given mode or higher."""
if isinstance(user, User):
user = user.nick
user_prefixes = self.prefixes.get(user, None)
if not user_prefixes:
return False
mode_dict = self.s.features.... | [
"def",
"has_privs",
"(",
"self",
",",
"user",
",",
"lowest_mode",
"=",
"'o'",
")",
":",
"if",
"isinstance",
"(",
"user",
",",
"User",
")",
":",
"user",
"=",
"user",
".",
"nick",
"user_prefixes",
"=",
"self",
".",
"prefixes",
".",
"get",
"(",
"user",
... | Return True if user has the given mode or higher. | [
"Return",
"True",
"if",
"user",
"has",
"the",
"given",
"mode",
"or",
"higher",
"."
] | train | https://github.com/goshuirc/irc/blob/d6a5e3e04d337566c009b087f108cd76f9e122cc/girc/types.py#L126-L149 |
goshuirc/irc | girc/types.py | Channel.add_user | def add_user(self, nick, prefixes=None):
"""Add a user to our internal list of nicks."""
if nick not in self._user_nicks:
self._user_nicks.append(nick)
self.prefixes[nick] = prefixes | python | def add_user(self, nick, prefixes=None):
"""Add a user to our internal list of nicks."""
if nick not in self._user_nicks:
self._user_nicks.append(nick)
self.prefixes[nick] = prefixes | [
"def",
"add_user",
"(",
"self",
",",
"nick",
",",
"prefixes",
"=",
"None",
")",
":",
"if",
"nick",
"not",
"in",
"self",
".",
"_user_nicks",
":",
"self",
".",
"_user_nicks",
".",
"append",
"(",
"nick",
")",
"self",
".",
"prefixes",
"[",
"nick",
"]",
... | Add a user to our internal list of nicks. | [
"Add",
"a",
"user",
"to",
"our",
"internal",
"list",
"of",
"nicks",
"."
] | train | https://github.com/goshuirc/irc/blob/d6a5e3e04d337566c009b087f108cd76f9e122cc/girc/types.py#L151-L156 |
jhshi/wltrace | wltrace/wltrace.py | is_packet_trace | def is_packet_trace(path):
"""Determine if a file is a packet trace that is supported by this module.
Args:
path (str): path to the trace file.
Returns:
bool: True if the file is a valid packet trace.
"""
path = os.path.abspath(path)
if not os.path.isfile(path):
return ... | python | def is_packet_trace(path):
"""Determine if a file is a packet trace that is supported by this module.
Args:
path (str): path to the trace file.
Returns:
bool: True if the file is a valid packet trace.
"""
path = os.path.abspath(path)
if not os.path.isfile(path):
return ... | [
"def",
"is_packet_trace",
"(",
"path",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"path",
")",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
":",
"return",
"False",
"try",
":",
"f",
"=",
"open",
"(",
"path",... | Determine if a file is a packet trace that is supported by this module.
Args:
path (str): path to the trace file.
Returns:
bool: True if the file is a valid packet trace. | [
"Determine",
"if",
"a",
"file",
"is",
"a",
"packet",
"trace",
"that",
"is",
"supported",
"by",
"this",
"module",
"."
] | train | https://github.com/jhshi/wltrace/blob/4c8441162f7cddd47375da2effc52c95b97dc81d/wltrace/wltrace.py#L35-L56 |
jhshi/wltrace | wltrace/wltrace.py | load_trace | def load_trace(path, *args, **kwargs):
"""Read a packet trace file, return a :class:`wltrace.common.WlTrace` object.
This function first reads the file's magic
(first ``FILE_TYPE_HANDLER`` bytes), and automatically determine the
file type, and call appropriate handler to process the file.
Args:
... | python | def load_trace(path, *args, **kwargs):
"""Read a packet trace file, return a :class:`wltrace.common.WlTrace` object.
This function first reads the file's magic
(first ``FILE_TYPE_HANDLER`` bytes), and automatically determine the
file type, and call appropriate handler to process the file.
Args:
... | [
"def",
"load_trace",
"(",
"path",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"open",
"(",
"path",
",",
"'rb'",
")",
"as",
"f",
":",
"magic",
"=",
"f",
".",
"read",
"(",
"MAGIC_LEN",
")",
"if",
"magic",
"not",
"in",
"FILE_TYPE_HA... | Read a packet trace file, return a :class:`wltrace.common.WlTrace` object.
This function first reads the file's magic
(first ``FILE_TYPE_HANDLER`` bytes), and automatically determine the
file type, and call appropriate handler to process the file.
Args:
path (str): the file's path to be loaded... | [
"Read",
"a",
"packet",
"trace",
"file",
"return",
"a",
":",
"class",
":",
"wltrace",
".",
"common",
".",
"WlTrace",
"object",
"."
] | train | https://github.com/jhshi/wltrace/blob/4c8441162f7cddd47375da2effc52c95b97dc81d/wltrace/wltrace.py#L59-L77 |
heuer/cablemap | examples/cablepersonstocsv.py | generate_csv | def generate_csv(path, out):
"""\
Walks through the `path` and generates the CSV file `out`
"""
known_persons = ()
with codecs.open(os.path.join(os.path.dirname(__file__), 'person_names.txt'), 'rb', 'utf-8') as f:
known_persons = set((l.rstrip() for l in f))
writer = UnicodeWriter(open(o... | python | def generate_csv(path, out):
"""\
Walks through the `path` and generates the CSV file `out`
"""
known_persons = ()
with codecs.open(os.path.join(os.path.dirname(__file__), 'person_names.txt'), 'rb', 'utf-8') as f:
known_persons = set((l.rstrip() for l in f))
writer = UnicodeWriter(open(o... | [
"def",
"generate_csv",
"(",
"path",
",",
"out",
")",
":",
"known_persons",
"=",
"(",
")",
"with",
"codecs",
".",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'person_names.txt'",
")"... | \
Walks through the `path` and generates the CSV file `out` | [
"\\",
"Walks",
"through",
"the",
"path",
"and",
"generates",
"the",
"CSV",
"file",
"out"
] | train | https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/examples/cablepersonstocsv.py#L50-L66 |
andycasey/sick | sick/plot.py | chains | def chains(xs, labels=None, truths=None, truth_color=u"#4682b4", burn=None,
alpha=0.5, fig=None):
"""
Create a plot showing the walker values for each parameter at every step.
:param xs:
The samples. This should be a 3D :class:`numpy.ndarray` of size
(``n_walkers``, ``n_steps``, ``n_pa... | python | def chains(xs, labels=None, truths=None, truth_color=u"#4682b4", burn=None,
alpha=0.5, fig=None):
"""
Create a plot showing the walker values for each parameter at every step.
:param xs:
The samples. This should be a 3D :class:`numpy.ndarray` of size
(``n_walkers``, ``n_steps``, ``n_pa... | [
"def",
"chains",
"(",
"xs",
",",
"labels",
"=",
"None",
",",
"truths",
"=",
"None",
",",
"truth_color",
"=",
"u\"#4682b4\"",
",",
"burn",
"=",
"None",
",",
"alpha",
"=",
"0.5",
",",
"fig",
"=",
"None",
")",
":",
"n_walkers",
",",
"n_steps",
",",
"K... | Create a plot showing the walker values for each parameter at every step.
:param xs:
The samples. This should be a 3D :class:`numpy.ndarray` of size
(``n_walkers``, ``n_steps``, ``n_parameters``).
:type xs:
:class:`numpy.ndarray`
:param labels: [optional]
Labels for all t... | [
"Create",
"a",
"plot",
"showing",
"the",
"walker",
"values",
"for",
"each",
"parameter",
"at",
"every",
"step",
"."
] | train | https://github.com/andycasey/sick/blob/6c37686182794c4cafea45abf7062b30b789b1a2/sick/plot.py#L150-L263 |
andycasey/sick | sick/plot.py | acceptance_fractions | def acceptance_fractions(mean_acceptance_fractions, burn=None, ax=None):
"""
Plot the meana cceptance fractions for each MCMC step.
:param mean_acceptance_fractions:
The acceptance fractions at each MCMC step.
:type mean_acceptance_fractions:
:class:`numpy.array`
:param burn: [opt... | python | def acceptance_fractions(mean_acceptance_fractions, burn=None, ax=None):
"""
Plot the meana cceptance fractions for each MCMC step.
:param mean_acceptance_fractions:
The acceptance fractions at each MCMC step.
:type mean_acceptance_fractions:
:class:`numpy.array`
:param burn: [opt... | [
"def",
"acceptance_fractions",
"(",
"mean_acceptance_fractions",
",",
"burn",
"=",
"None",
",",
"ax",
"=",
"None",
")",
":",
"factor",
"=",
"2.0",
"lbdim",
"=",
"0.2",
"*",
"factor",
"trdim",
"=",
"0.2",
"*",
"factor",
"whspace",
"=",
"0.10",
"dimy",
"="... | Plot the meana cceptance fractions for each MCMC step.
:param mean_acceptance_fractions:
The acceptance fractions at each MCMC step.
:type mean_acceptance_fractions:
:class:`numpy.array`
:param burn: [optional]
The burn-in point. If provided, a dashed vertical line will be shown a... | [
"Plot",
"the",
"meana",
"cceptance",
"fractions",
"for",
"each",
"MCMC",
"step",
"."
] | train | https://github.com/andycasey/sick/blob/6c37686182794c4cafea45abf7062b30b789b1a2/sick/plot.py#L266-L328 |
andycasey/sick | sick/plot.py | normalised_autocorrelation_function | def normalised_autocorrelation_function(chain, index=0, burn=None,
limit=None, fig=None, figsize=None):
"""
Plot the autocorrelation function for each parameter of a sampler chain.
:param chain:
The sampled parameter values.
:type chain:
:class:`numpy.ndarray`
:param index: [... | python | def normalised_autocorrelation_function(chain, index=0, burn=None,
limit=None, fig=None, figsize=None):
"""
Plot the autocorrelation function for each parameter of a sampler chain.
:param chain:
The sampled parameter values.
:type chain:
:class:`numpy.ndarray`
:param index: [... | [
"def",
"normalised_autocorrelation_function",
"(",
"chain",
",",
"index",
"=",
"0",
",",
"burn",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"fig",
"=",
"None",
",",
"figsize",
"=",
"None",
")",
":",
"factor",
"=",
"2.0",
"lbdim",
"=",
"0.2",
"*",
"... | Plot the autocorrelation function for each parameter of a sampler chain.
:param chain:
The sampled parameter values.
:type chain:
:class:`numpy.ndarray`
:param index: [optional]
Index to calculate the autocorrelation from.
:type index:
int
:param limit: [optional... | [
"Plot",
"the",
"autocorrelation",
"function",
"for",
"each",
"parameter",
"of",
"a",
"sampler",
"chain",
"."
] | train | https://github.com/andycasey/sick/blob/6c37686182794c4cafea45abf7062b30b789b1a2/sick/plot.py#L331-L413 |
andycasey/sick | sick/plot.py | old_projection | def old_projection(model, data, theta=None, chain=None, n=100, extents=None,
uncertainties=True, title=None, fig=None, figsize=None):
"""
Project the maximum likelihood values and sampled posterior points as
spectra.
:param model:
The model employed.
:type model:
:class:`sick... | python | def old_projection(model, data, theta=None, chain=None, n=100, extents=None,
uncertainties=True, title=None, fig=None, figsize=None):
"""
Project the maximum likelihood values and sampled posterior points as
spectra.
:param model:
The model employed.
:type model:
:class:`sick... | [
"def",
"old_projection",
"(",
"model",
",",
"data",
",",
"theta",
"=",
"None",
",",
"chain",
"=",
"None",
",",
"n",
"=",
"100",
",",
"extents",
"=",
"None",
",",
"uncertainties",
"=",
"True",
",",
"title",
"=",
"None",
",",
"fig",
"=",
"None",
",",... | Project the maximum likelihood values and sampled posterior points as
spectra.
:param model:
The model employed.
:type model:
:class:`sick.models.Model`
:param data:
The observed spectra.
:type data:
iterable of :class:`sick.specutils.Spectrum1D` objects
:pa... | [
"Project",
"the",
"maximum",
"likelihood",
"values",
"and",
"sampled",
"posterior",
"points",
"as",
"spectra",
"."
] | train | https://github.com/andycasey/sick/blob/6c37686182794c4cafea45abf7062b30b789b1a2/sick/plot.py#L535-L738 |
leosartaj/tvstats | tvstats/scraper.py | get_a | def get_a(html, find=''):
"""Finds all the 'a' tags with find in their href"""
links = []
for a in html.find_all('a'):
if a.get('href').find(find) != -1:
links.append(a)
return links | python | def get_a(html, find=''):
"""Finds all the 'a' tags with find in their href"""
links = []
for a in html.find_all('a'):
if a.get('href').find(find) != -1:
links.append(a)
return links | [
"def",
"get_a",
"(",
"html",
",",
"find",
"=",
"''",
")",
":",
"links",
"=",
"[",
"]",
"for",
"a",
"in",
"html",
".",
"find_all",
"(",
"'a'",
")",
":",
"if",
"a",
".",
"get",
"(",
"'href'",
")",
".",
"find",
"(",
"find",
")",
"!=",
"-",
"1"... | Finds all the 'a' tags with find in their href | [
"Finds",
"all",
"the",
"a",
"tags",
"with",
"find",
"in",
"their",
"href"
] | train | https://github.com/leosartaj/tvstats/blob/164fe736111d43869f8c9686e07a5ab1b9f22444/tvstats/scraper.py#L15-L21 |
leosartaj/tvstats | tvstats/scraper.py | episode_list | def episode_list(a):
"""List of all episodes of a season"""
html = get_html(ROOT + a.get('href'))
div = html.find('div', {'class': "list detail eplist"})
links = []
for tag in div.find_all('a', {'itemprop': "name"}):
links.append(tag)
return links | python | def episode_list(a):
"""List of all episodes of a season"""
html = get_html(ROOT + a.get('href'))
div = html.find('div', {'class': "list detail eplist"})
links = []
for tag in div.find_all('a', {'itemprop': "name"}):
links.append(tag)
return links | [
"def",
"episode_list",
"(",
"a",
")",
":",
"html",
"=",
"get_html",
"(",
"ROOT",
"+",
"a",
".",
"get",
"(",
"'href'",
")",
")",
"div",
"=",
"html",
".",
"find",
"(",
"'div'",
",",
"{",
"'class'",
":",
"\"list detail eplist\"",
"}",
")",
"links",
"=... | List of all episodes of a season | [
"List",
"of",
"all",
"episodes",
"of",
"a",
"season"
] | train | https://github.com/leosartaj/tvstats/blob/164fe736111d43869f8c9686e07a5ab1b9f22444/tvstats/scraper.py#L24-L31 |
leosartaj/tvstats | tvstats/scraper.py | parse_episode | def parse_episode(a):
"""Collects data related to an episode"""
d = {}
html = get_html(ROOT + a.get('href'))
d['rating'] = get_rating(html)
d['episode-name'], d['date'] = get_name_date(html)
season, d['episode-num'] = get_season_epi_num(html)
return season, d | python | def parse_episode(a):
"""Collects data related to an episode"""
d = {}
html = get_html(ROOT + a.get('href'))
d['rating'] = get_rating(html)
d['episode-name'], d['date'] = get_name_date(html)
season, d['episode-num'] = get_season_epi_num(html)
return season, d | [
"def",
"parse_episode",
"(",
"a",
")",
":",
"d",
"=",
"{",
"}",
"html",
"=",
"get_html",
"(",
"ROOT",
"+",
"a",
".",
"get",
"(",
"'href'",
")",
")",
"d",
"[",
"'rating'",
"]",
"=",
"get_rating",
"(",
"html",
")",
"d",
"[",
"'episode-name'",
"]",
... | Collects data related to an episode | [
"Collects",
"data",
"related",
"to",
"an",
"episode"
] | train | https://github.com/leosartaj/tvstats/blob/164fe736111d43869f8c9686e07a5ab1b9f22444/tvstats/scraper.py#L69-L76 |
leosartaj/tvstats | tvstats/scraper.py | parse | def parse(link):
"""Parses a Tv Series
returns the dataset as a dictionary
"""
html = get_html(link)
data = {'rating': get_rating(html),
'name': get_name_date(html)[0]}
div = html.find(id="title-episode-widget")
season_tags = get_a(div, find="season=")
episodes = {}
for... | python | def parse(link):
"""Parses a Tv Series
returns the dataset as a dictionary
"""
html = get_html(link)
data = {'rating': get_rating(html),
'name': get_name_date(html)[0]}
div = html.find(id="title-episode-widget")
season_tags = get_a(div, find="season=")
episodes = {}
for... | [
"def",
"parse",
"(",
"link",
")",
":",
"html",
"=",
"get_html",
"(",
"link",
")",
"data",
"=",
"{",
"'rating'",
":",
"get_rating",
"(",
"html",
")",
",",
"'name'",
":",
"get_name_date",
"(",
"html",
")",
"[",
"0",
"]",
"}",
"div",
"=",
"html",
".... | Parses a Tv Series
returns the dataset as a dictionary | [
"Parses",
"a",
"Tv",
"Series",
"returns",
"the",
"dataset",
"as",
"a",
"dictionary"
] | train | https://github.com/leosartaj/tvstats/blob/164fe736111d43869f8c9686e07a5ab1b9f22444/tvstats/scraper.py#L79-L99 |
garnertb/django-classification-banner | django_classification_banner/context_processors.py | classification | def classification(request):
"""
Adds classification context to views.
"""
ctx = {
'classification_text': getattr(settings, 'CLASSIFICATION_TEXT', 'UNCLASSIFIED'),
'classification_text_color': getattr(settings, 'CLASSIFICATION_TEXT_COLOR', 'white'),
'classification_background_co... | python | def classification(request):
"""
Adds classification context to views.
"""
ctx = {
'classification_text': getattr(settings, 'CLASSIFICATION_TEXT', 'UNCLASSIFIED'),
'classification_text_color': getattr(settings, 'CLASSIFICATION_TEXT_COLOR', 'white'),
'classification_background_co... | [
"def",
"classification",
"(",
"request",
")",
":",
"ctx",
"=",
"{",
"'classification_text'",
":",
"getattr",
"(",
"settings",
",",
"'CLASSIFICATION_TEXT'",
",",
"'UNCLASSIFIED'",
")",
",",
"'classification_text_color'",
":",
"getattr",
"(",
"settings",
",",
"'CLAS... | Adds classification context to views. | [
"Adds",
"classification",
"context",
"to",
"views",
"."
] | train | https://github.com/garnertb/django-classification-banner/blob/dfe47e510efcce7eb0023e0d756eb2a0906bf9af/django_classification_banner/context_processors.py#L4-L17 |
JNRowe/upoints | upoints/tzdata.py | Zones.import_locations | def import_locations(self, zone_file):
"""Parse zoneinfo zone description data files.
``import_locations()`` returns a list of :class:`Zone` objects.
It expects data files in one of the following formats::
AN +1211-06900 America/Curacao
AO -0848+01314 Africa/Luanda
... | python | def import_locations(self, zone_file):
"""Parse zoneinfo zone description data files.
``import_locations()`` returns a list of :class:`Zone` objects.
It expects data files in one of the following formats::
AN +1211-06900 America/Curacao
AO -0848+01314 Africa/Luanda
... | [
"def",
"import_locations",
"(",
"self",
",",
"zone_file",
")",
":",
"self",
".",
"_zone_file",
"=",
"zone_file",
"field_names",
"=",
"(",
"'country'",
",",
"'location'",
",",
"'zone'",
",",
"'comments'",
")",
"data",
"=",
"utils",
".",
"prepare_csv_read",
"(... | Parse zoneinfo zone description data files.
``import_locations()`` returns a list of :class:`Zone` objects.
It expects data files in one of the following formats::
AN +1211-06900 America/Curacao
AO -0848+01314 Africa/Luanda
AQ -7750+16636 Antarctica/McMurdo McMurdo... | [
"Parse",
"zoneinfo",
"zone",
"description",
"data",
"files",
"."
] | train | https://github.com/JNRowe/upoints/blob/1e4b7a53ed2a06cd854523d54c36aabdccea3830/upoints/tzdata.py#L91-L134 |
JNRowe/upoints | upoints/tzdata.py | Zones.dump_zone_file | def dump_zone_file(self):
"""Generate a zoneinfo compatible zone description table.
Returns:
list: zoneinfo descriptions
"""
data = []
for zone in sorted(self, key=attrgetter('country')):
text = ['%s %s %s'
% (zone.country,
... | python | def dump_zone_file(self):
"""Generate a zoneinfo compatible zone description table.
Returns:
list: zoneinfo descriptions
"""
data = []
for zone in sorted(self, key=attrgetter('country')):
text = ['%s %s %s'
% (zone.country,
... | [
"def",
"dump_zone_file",
"(",
"self",
")",
":",
"data",
"=",
"[",
"]",
"for",
"zone",
"in",
"sorted",
"(",
"self",
",",
"key",
"=",
"attrgetter",
"(",
"'country'",
")",
")",
":",
"text",
"=",
"[",
"'%s\t%s\t%s'",
"%",
"(",
"zone",
".",
"country",
"... | Generate a zoneinfo compatible zone description table.
Returns:
list: zoneinfo descriptions | [
"Generate",
"a",
"zoneinfo",
"compatible",
"zone",
"description",
"table",
"."
] | train | https://github.com/JNRowe/upoints/blob/1e4b7a53ed2a06cd854523d54c36aabdccea3830/upoints/tzdata.py#L136-L152 |
JNRowe/upoints | upoints/weather_stations.py | Stations.import_locations | def import_locations(self, data, index='WMO'):
"""Parse NOAA weather station data files.
``import_locations()`` returns a dictionary with keys containing either
the WMO or ICAO identifier, and values that are ``Station`` objects
that describes the large variety of data exported by NOAA_... | python | def import_locations(self, data, index='WMO'):
"""Parse NOAA weather station data files.
``import_locations()`` returns a dictionary with keys containing either
the WMO or ICAO identifier, and values that are ``Station`` objects
that describes the large variety of data exported by NOAA_... | [
"def",
"import_locations",
"(",
"self",
",",
"data",
",",
"index",
"=",
"'WMO'",
")",
":",
"self",
".",
"_data",
"=",
"data",
"data",
"=",
"utils",
".",
"prepare_read",
"(",
"data",
")",
"for",
"line",
"in",
"data",
":",
"line",
"=",
"line",
".",
"... | Parse NOAA weather station data files.
``import_locations()`` returns a dictionary with keys containing either
the WMO or ICAO identifier, and values that are ``Station`` objects
that describes the large variety of data exported by NOAA_.
It expects data files in one of the following f... | [
"Parse",
"NOAA",
"weather",
"station",
"data",
"files",
"."
] | train | https://github.com/JNRowe/upoints/blob/1e4b7a53ed2a06cd854523d54c36aabdccea3830/upoints/weather_stations.py#L107-L229 |
klen/adrest | adrest/utils/throttle.py | AbstractThrottle.convert_identifier_to_key | def convert_identifier_to_key(identifier):
""" Takes an identifier (like a username or IP address) and converts it
into a key usable by the cache system.
"""
key = ''.join(c for c in identifier if c.isalnum() or c in '_.-')
if len(key) > 230:
key = key[:150] + '-'... | python | def convert_identifier_to_key(identifier):
""" Takes an identifier (like a username or IP address) and converts it
into a key usable by the cache system.
"""
key = ''.join(c for c in identifier if c.isalnum() or c in '_.-')
if len(key) > 230:
key = key[:150] + '-'... | [
"def",
"convert_identifier_to_key",
"(",
"identifier",
")",
":",
"key",
"=",
"''",
".",
"join",
"(",
"c",
"for",
"c",
"in",
"identifier",
"if",
"c",
".",
"isalnum",
"(",
")",
"or",
"c",
"in",
"'_.-'",
")",
"if",
"len",
"(",
"key",
")",
">",
"230",
... | Takes an identifier (like a username or IP address) and converts it
into a key usable by the cache system. | [
"Takes",
"an",
"identifier",
"(",
"like",
"a",
"username",
"or",
"IP",
"address",
")",
"and",
"converts",
"it",
"into",
"a",
"key",
"usable",
"by",
"the",
"cache",
"system",
"."
] | train | https://github.com/klen/adrest/blob/8b75c67123cffabe5ed98c222bb7ab43c904d89c/adrest/utils/throttle.py#L29-L37 |
liminspace/dju-common | dju_common/templatetags/dju_common.py | is_in | def is_in(val, items):
"""
{% if tag|is_in:'div|p|span' %}is block tag{% endif %}
{% if tag|is_in:tags_list %}is block tag{% endif %}
"""
if isinstance(items, basestring):
items = items.split('|')
return val in items | python | def is_in(val, items):
"""
{% if tag|is_in:'div|p|span' %}is block tag{% endif %}
{% if tag|is_in:tags_list %}is block tag{% endif %}
"""
if isinstance(items, basestring):
items = items.split('|')
return val in items | [
"def",
"is_in",
"(",
"val",
",",
"items",
")",
":",
"if",
"isinstance",
"(",
"items",
",",
"basestring",
")",
":",
"items",
"=",
"items",
".",
"split",
"(",
"'|'",
")",
"return",
"val",
"in",
"items"
] | {% if tag|is_in:'div|p|span' %}is block tag{% endif %}
{% if tag|is_in:tags_list %}is block tag{% endif %} | [
"{",
"%",
"if",
"tag|is_in",
":",
"div|p|span",
"%",
"}",
"is",
"block",
"tag",
"{",
"%",
"endif",
"%",
"}",
"{",
"%",
"if",
"tag|is_in",
":",
"tags_list",
"%",
"}",
"is",
"block",
"tag",
"{",
"%",
"endif",
"%",
"}"
] | train | https://github.com/liminspace/dju-common/blob/c68860bb84d454a35e66275841c20f38375c2135/dju_common/templatetags/dju_common.py#L40-L47 |
liminspace/dju-common | dju_common/templatetags/dju_common.py | captureas | def captureas(parser, arg):
"""
example: {% captureas myvar 1 %}content...{% endcaptureas %} - {{ myvar }}
result: content... - content...
example: {% captureas myvar %}content...{% endcaptureas %} - {{ myvar }}
result: - content...
"""
args = arg.contents.split()
if not 2 <= len(args) ... | python | def captureas(parser, arg):
"""
example: {% captureas myvar 1 %}content...{% endcaptureas %} - {{ myvar }}
result: content... - content...
example: {% captureas myvar %}content...{% endcaptureas %} - {{ myvar }}
result: - content...
"""
args = arg.contents.split()
if not 2 <= len(args) ... | [
"def",
"captureas",
"(",
"parser",
",",
"arg",
")",
":",
"args",
"=",
"arg",
".",
"contents",
".",
"split",
"(",
")",
"if",
"not",
"2",
"<=",
"len",
"(",
"args",
")",
"<=",
"3",
":",
"raise",
"template",
".",
"TemplateSyntaxError",
"(",
"'\"captureas... | example: {% captureas myvar 1 %}content...{% endcaptureas %} - {{ myvar }}
result: content... - content...
example: {% captureas myvar %}content...{% endcaptureas %} - {{ myvar }}
result: - content... | [
"example",
":",
"{",
"%",
"captureas",
"myvar",
"1",
"%",
"}",
"content",
"...",
"{",
"%",
"endcaptureas",
"%",
"}",
"-",
"{{",
"myvar",
"}}",
"result",
":",
"content",
"...",
"-",
"content",
"..."
] | train | https://github.com/liminspace/dju-common/blob/c68860bb84d454a35e66275841c20f38375c2135/dju_common/templatetags/dju_common.py#L63-L76 |
liminspace/dju-common | dju_common/templatetags/dju_common.py | strip | def strip(parser, arg):
"""
example:
{% strip '<br>' %}
content...
content...
{% endstrip %}
result:
content...<br>content...
arg special symbols: {\n} = \n
"""
nodelist = parser.parse(('endstrip',))
parser.delete_first_token()
return Strip... | python | def strip(parser, arg):
"""
example:
{% strip '<br>' %}
content...
content...
{% endstrip %}
result:
content...<br>content...
arg special symbols: {\n} = \n
"""
nodelist = parser.parse(('endstrip',))
parser.delete_first_token()
return Strip... | [
"def",
"strip",
"(",
"parser",
",",
"arg",
")",
":",
"nodelist",
"=",
"parser",
".",
"parse",
"(",
"(",
"'endstrip'",
",",
")",
")",
"parser",
".",
"delete_first_token",
"(",
")",
"return",
"StripNode",
"(",
"nodelist",
",",
"arg",
".",
"split_contents",... | example:
{% strip '<br>' %}
content...
content...
{% endstrip %}
result:
content...<br>content...
arg special symbols: {\n} = \n | [
"example",
":",
"{",
"%",
"strip",
"<br",
">",
"%",
"}",
"content",
"...",
"content",
"...",
"{",
"%",
"endstrip",
"%",
"}",
"result",
":",
"content",
"...",
"<br",
">",
"content",
"...",
"arg",
"special",
"symbols",
":",
"{",
"\\",
"n",
"}",
"=",
... | train | https://github.com/liminspace/dju-common/blob/c68860bb84d454a35e66275841c20f38375c2135/dju_common/templatetags/dju_common.py#L93-L106 |
liminspace/dju-common | dju_common/templatetags/dju_common.py | recurse | def recurse(parser, token):
"""
Iterate recurse data structure.
<ul>
{% recurse items %}
<li>
{{ item.name }}
{% if item.children %}
<ul>
{{ subitems }}
</ul>
{% endif %}
... | python | def recurse(parser, token):
"""
Iterate recurse data structure.
<ul>
{% recurse items %}
<li>
{{ item.name }}
{% if item.children %}
<ul>
{{ subitems }}
</ul>
{% endif %}
... | [
"def",
"recurse",
"(",
"parser",
",",
"token",
")",
":",
"params",
"=",
"token",
".",
"contents",
".",
"split",
"(",
")",
"if",
"not",
"2",
"<=",
"len",
"(",
"params",
")",
"<=",
"3",
":",
"raise",
"template",
".",
"TemplateSyntaxError",
"(",
"'%s pa... | Iterate recurse data structure.
<ul>
{% recurse items %}
<li>
{{ item.name }}
{% if item.children %}
<ul>
{{ subitems }}
</ul>
{% endif %}
</li>
{% endrecurse %}
... | [
"Iterate",
"recurse",
"data",
"structure",
".",
"<ul",
">",
"{",
"%",
"recurse",
"items",
"%",
"}",
"<li",
">",
"{{",
"item",
".",
"name",
"}}",
"{",
"%",
"if",
"item",
".",
"children",
"%",
"}",
"<ul",
">",
"{{",
"subitems",
"}}",
"<",
"/",
"ul"... | train | https://github.com/liminspace/dju-common/blob/c68860bb84d454a35e66275841c20f38375c2135/dju_common/templatetags/dju_common.py#L170-L196 |
liminspace/dju-common | dju_common/templatetags/dju_common.py | paginator | def paginator(context, page, leading=8, out=3, adjacent=3, sep='...'):
"""
Render paginator.
<<_1_2 3 4 5 6 7 8 9 ... 55 56 57 >> # leading=9 (1..9) out=3 (55..57)
<< 1 2 3 ... 23 24 25 26_27_28 29 30 31 ... 55 56 57 >> # adjacent = 4 (23..26, 28..31)
"""
leading_pages, out_left_pages, out_ri... | python | def paginator(context, page, leading=8, out=3, adjacent=3, sep='...'):
"""
Render paginator.
<<_1_2 3 4 5 6 7 8 9 ... 55 56 57 >> # leading=9 (1..9) out=3 (55..57)
<< 1 2 3 ... 23 24 25 26_27_28 29 30 31 ... 55 56 57 >> # adjacent = 4 (23..26, 28..31)
"""
leading_pages, out_left_pages, out_ri... | [
"def",
"paginator",
"(",
"context",
",",
"page",
",",
"leading",
"=",
"8",
",",
"out",
"=",
"3",
",",
"adjacent",
"=",
"3",
",",
"sep",
"=",
"'...'",
")",
":",
"leading_pages",
",",
"out_left_pages",
",",
"out_right_pages",
",",
"pages",
"=",
"[",
"]... | Render paginator.
<<_1_2 3 4 5 6 7 8 9 ... 55 56 57 >> # leading=9 (1..9) out=3 (55..57)
<< 1 2 3 ... 23 24 25 26_27_28 29 30 31 ... 55 56 57 >> # adjacent = 4 (23..26, 28..31) | [
"Render",
"paginator",
".",
"<<_1_2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"...",
"55",
"56",
"57",
">>",
"#",
"leading",
"=",
"9",
"(",
"1",
"..",
"9",
")",
"out",
"=",
"3",
"(",
"55",
"..",
"57",
")",
"<<",
"1",
"2",
"3",
"...",
"23",
"24... | train | https://github.com/liminspace/dju-common/blob/c68860bb84d454a35e66275841c20f38375c2135/dju_common/templatetags/dju_common.py#L258-L294 |
9wfox/tornadoweb | tornadoweb/app.py | Application._get_handlers | def _get_handlers(self):
"""
获取 action.handlers
添加路径 __conf__.ACTION_DIR_NAME 列表中的 action by ABeen
"""
# 查找所有 Handler。
members = {}
for d in __conf__.ACTION_DIR_NAME:
members.update(get_members(d,
None,
... | python | def _get_handlers(self):
"""
获取 action.handlers
添加路径 __conf__.ACTION_DIR_NAME 列表中的 action by ABeen
"""
# 查找所有 Handler。
members = {}
for d in __conf__.ACTION_DIR_NAME:
members.update(get_members(d,
None,
... | [
"def",
"_get_handlers",
"(",
"self",
")",
":",
"# 查找所有 Handler。\r",
"members",
"=",
"{",
"}",
"for",
"d",
"in",
"__conf__",
".",
"ACTION_DIR_NAME",
":",
"members",
".",
"update",
"(",
"get_members",
"(",
"d",
",",
"None",
",",
"lambda",
"m",
":",
"isclas... | 获取 action.handlers
添加路径 __conf__.ACTION_DIR_NAME 列表中的 action by ABeen | [
"获取",
"action",
".",
"handlers",
"添加路径",
"__conf__",
".",
"ACTION_DIR_NAME",
"列表中的",
"action",
"by",
"ABeen"
] | train | https://github.com/9wfox/tornadoweb/blob/2286b66fbe10e4d9f212b979664c15fa17adf378/tornadoweb/app.py#L40-L67 |
9wfox/tornadoweb | tornadoweb/app.py | Application._get_webapp | def _get_webapp(self):
"""
创建 tornado.web.Application
"""
settings = {
"PORT" : self._port,
#"static_path" : app_path(__conf__.STATIC_DIR_NAME),
#"template_path" : app_path(__conf__.TEMPLATE_DIR_NAME),
"debug" ... | python | def _get_webapp(self):
"""
创建 tornado.web.Application
"""
settings = {
"PORT" : self._port,
#"static_path" : app_path(__conf__.STATIC_DIR_NAME),
#"template_path" : app_path(__conf__.TEMPLATE_DIR_NAME),
"debug" ... | [
"def",
"_get_webapp",
"(",
"self",
")",
":",
"settings",
"=",
"{",
"\"PORT\"",
":",
"self",
".",
"_port",
",",
"#\"static_path\" : app_path(__conf__.STATIC_DIR_NAME),\r",
"#\"template_path\" : app_path(__conf__.TEMPLATE_DIR_NAME),\r",
"\"debug\"",
":",
"__conf__",
".",
"D... | 创建 tornado.web.Application | [
"创建",
"tornado",
".",
"web",
".",
"Application"
] | train | https://github.com/9wfox/tornadoweb/blob/2286b66fbe10e4d9f212b979664c15fa17adf378/tornadoweb/app.py#L71-L84 |
9wfox/tornadoweb | tornadoweb/app.py | Application._run_server | def _run_server(self):
"""
启动 HTTP Server
"""
try:
if __conf__.DEBUG:
self._webapp.listen(self._port)
else:
server = HTTPServer(self._webapp)
server.bind(self._port)
server.start(0)
... | python | def _run_server(self):
"""
启动 HTTP Server
"""
try:
if __conf__.DEBUG:
self._webapp.listen(self._port)
else:
server = HTTPServer(self._webapp)
server.bind(self._port)
server.start(0)
... | [
"def",
"_run_server",
"(",
"self",
")",
":",
"try",
":",
"if",
"__conf__",
".",
"DEBUG",
":",
"self",
".",
"_webapp",
".",
"listen",
"(",
"self",
".",
"_port",
")",
"else",
":",
"server",
"=",
"HTTPServer",
"(",
"self",
".",
"_webapp",
")",
"server",... | 启动 HTTP Server | [
"启动",
"HTTP",
"Server"
] | train | https://github.com/9wfox/tornadoweb/blob/2286b66fbe10e4d9f212b979664c15fa17adf378/tornadoweb/app.py#L87-L101 |
timstaley/voeventdb | voeventdb/server/bin/voeventdb_create.py | handle_args | def handle_args():
"""
Default values are defined here.
"""
default_database_name = dbconfig.testdb_corpus_url.database
parser = argparse.ArgumentParser(
prog=os.path.basename(__file__),
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('dbname',
... | python | def handle_args():
"""
Default values are defined here.
"""
default_database_name = dbconfig.testdb_corpus_url.database
parser = argparse.ArgumentParser(
prog=os.path.basename(__file__),
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('dbname',
... | [
"def",
"handle_args",
"(",
")",
":",
"default_database_name",
"=",
"dbconfig",
".",
"testdb_corpus_url",
".",
"database",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"prog",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"__file__",
")",
",",
"form... | Default values are defined here. | [
"Default",
"values",
"are",
"defined",
"here",
"."
] | train | https://github.com/timstaley/voeventdb/blob/e37b176d65fced4ca4f059109a95d6974bb8a091/voeventdb/server/bin/voeventdb_create.py#L23-L37 |
draperunner/fjlc | fjlc/preprocessing/filters/filters.py | Filters.string_chain | def string_chain(text, filters):
"""
Chain several filters after each other, applies the filter on the entire string
:param text: String to format
:param filters: Sequence of filters to apply on String
:return: The formatted String
"""
if filters is None:
... | python | def string_chain(text, filters):
"""
Chain several filters after each other, applies the filter on the entire string
:param text: String to format
:param filters: Sequence of filters to apply on String
:return: The formatted String
"""
if filters is None:
... | [
"def",
"string_chain",
"(",
"text",
",",
"filters",
")",
":",
"if",
"filters",
"is",
"None",
":",
"return",
"text",
"for",
"filter_function",
"in",
"filters",
":",
"text",
"=",
"filter_function",
"(",
"text",
")",
"return",
"text"
] | Chain several filters after each other, applies the filter on the entire string
:param text: String to format
:param filters: Sequence of filters to apply on String
:return: The formatted String | [
"Chain",
"several",
"filters",
"after",
"each",
"other",
"applies",
"the",
"filter",
"on",
"the",
"entire",
"string",
":",
"param",
"text",
":",
"String",
"to",
"format",
":",
"param",
"filters",
":",
"Sequence",
"of",
"filters",
"to",
"apply",
"on",
"Stri... | train | https://github.com/draperunner/fjlc/blob/d2cc8cf1244984e7caf0bf95b11ed1677a94c994/fjlc/preprocessing/filters/filters.py#L25-L38 |
draperunner/fjlc | fjlc/preprocessing/filters/filters.py | Filters.token_chain | def token_chain(text, filters):
"""
Chain several filters after each other, applying filters only on non special class tokens as detected by
{@link ClassifierOptions#isSpecialClassWord(String)}
:param text: String to format
:param filters: Sequence of filters to apply to tokens
... | python | def token_chain(text, filters):
"""
Chain several filters after each other, applying filters only on non special class tokens as detected by
{@link ClassifierOptions#isSpecialClassWord(String)}
:param text: String to format
:param filters: Sequence of filters to apply to tokens
... | [
"def",
"token_chain",
"(",
"text",
",",
"filters",
")",
":",
"if",
"filters",
"is",
"None",
":",
"return",
"text",
"sb",
"=",
"\"\"",
"for",
"token",
"in",
"RegexFilters",
".",
"WHITESPACE",
".",
"split",
"(",
"text",
")",
":",
"if",
"not",
"classifier... | Chain several filters after each other, applying filters only on non special class tokens as detected by
{@link ClassifierOptions#isSpecialClassWord(String)}
:param text: String to format
:param filters: Sequence of filters to apply to tokens
:return: The formatted String | [
"Chain",
"several",
"filters",
"after",
"each",
"other",
"applying",
"filters",
"only",
"on",
"non",
"special",
"class",
"tokens",
"as",
"detected",
"by",
"{",
"@link",
"ClassifierOptions#isSpecialClassWord",
"(",
"String",
")",
"}"
] | train | https://github.com/draperunner/fjlc/blob/d2cc8cf1244984e7caf0bf95b11ed1677a94c994/fjlc/preprocessing/filters/filters.py#L41-L60 |
HydrelioxGitHub/pybbox | pybbox/__init__.py | Bbox.set_display_luminosity | def set_display_luminosity(self, luminosity):
"""
Change the intensity of light of the front panel of the box
:param luminosity: must be between 0 (light off) and 100
:type luminosity: int
"""
if (luminosity < 0) or (luminosity > 100):
raise ValueError("Lumino... | python | def set_display_luminosity(self, luminosity):
"""
Change the intensity of light of the front panel of the box
:param luminosity: must be between 0 (light off) and 100
:type luminosity: int
"""
if (luminosity < 0) or (luminosity > 100):
raise ValueError("Lumino... | [
"def",
"set_display_luminosity",
"(",
"self",
",",
"luminosity",
")",
":",
"if",
"(",
"luminosity",
"<",
"0",
")",
"or",
"(",
"luminosity",
">",
"100",
")",
":",
"raise",
"ValueError",
"(",
"\"Luminosity must be between 0 and 100\"",
")",
"self",
".",
"bbox_au... | Change the intensity of light of the front panel of the box
:param luminosity: must be between 0 (light off) and 100
:type luminosity: int | [
"Change",
"the",
"intensity",
"of",
"light",
"of",
"the",
"front",
"panel",
"of",
"the",
"box",
":",
"param",
"luminosity",
":",
"must",
"be",
"between",
"0",
"(",
"light",
"off",
")",
"and",
"100",
":",
"type",
"luminosity",
":",
"int"
] | train | https://github.com/HydrelioxGitHub/pybbox/blob/bedcdccab5d18d36890ef8bf414845f2dec18b5c/pybbox/__init__.py#L54-L68 |
HydrelioxGitHub/pybbox | pybbox/__init__.py | Bbox.reboot | def reboot(self):
"""
Reboot the device
Useful when trying to get xDSL sync
"""
token = self.get_token()
self.bbox_auth.set_access(BboxConstant.AUTHENTICATION_LEVEL_PRIVATE, BboxConstant.AUTHENTICATION_LEVEL_PRIVATE)
url_suffix = "reboot?btoken={}".format(token)
... | python | def reboot(self):
"""
Reboot the device
Useful when trying to get xDSL sync
"""
token = self.get_token()
self.bbox_auth.set_access(BboxConstant.AUTHENTICATION_LEVEL_PRIVATE, BboxConstant.AUTHENTICATION_LEVEL_PRIVATE)
url_suffix = "reboot?btoken={}".format(token)
... | [
"def",
"reboot",
"(",
"self",
")",
":",
"token",
"=",
"self",
".",
"get_token",
"(",
")",
"self",
".",
"bbox_auth",
".",
"set_access",
"(",
"BboxConstant",
".",
"AUTHENTICATION_LEVEL_PRIVATE",
",",
"BboxConstant",
".",
"AUTHENTICATION_LEVEL_PRIVATE",
")",
"url_s... | Reboot the device
Useful when trying to get xDSL sync | [
"Reboot",
"the",
"device",
"Useful",
"when",
"trying",
"to",
"get",
"xDSL",
"sync"
] | train | https://github.com/HydrelioxGitHub/pybbox/blob/bedcdccab5d18d36890ef8bf414845f2dec18b5c/pybbox/__init__.py#L70-L81 |
HydrelioxGitHub/pybbox | pybbox/__init__.py | Bbox.get_token | def get_token(self):
"""
Return a string which is a token, needed for some API calls
:return: Token (can be used with some API call
:rtype: str
.. todo:: make a token class to be able to store date of expiration
"""
self.bbox_auth.set_access(BboxConstant.AUTHENTI... | python | def get_token(self):
"""
Return a string which is a token, needed for some API calls
:return: Token (can be used with some API call
:rtype: str
.. todo:: make a token class to be able to store date of expiration
"""
self.bbox_auth.set_access(BboxConstant.AUTHENTI... | [
"def",
"get_token",
"(",
"self",
")",
":",
"self",
".",
"bbox_auth",
".",
"set_access",
"(",
"BboxConstant",
".",
"AUTHENTICATION_LEVEL_PRIVATE",
",",
"BboxConstant",
".",
"AUTHENTICATION_LEVEL_PRIVATE",
")",
"self",
".",
"bbox_url",
".",
"set_api_name",
"(",
"Bbo... | Return a string which is a token, needed for some API calls
:return: Token (can be used with some API call
:rtype: str
.. todo:: make a token class to be able to store date of expiration | [
"Return",
"a",
"string",
"which",
"is",
"a",
"token",
"needed",
"for",
"some",
"API",
"calls",
":",
"return",
":",
"Token",
"(",
"can",
"be",
"used",
"with",
"some",
"API",
"call",
":",
"rtype",
":",
"str"
] | train | https://github.com/HydrelioxGitHub/pybbox/blob/bedcdccab5d18d36890ef8bf414845f2dec18b5c/pybbox/__init__.py#L83-L96 |
HydrelioxGitHub/pybbox | pybbox/__init__.py | Bbox.get_all_connected_devices | def get_all_connected_devices(self):
"""
Get all info about devices connected to the box
:return: a list with each device info
:rtype: list
"""
self.bbox_auth.set_access(BboxConstant.AUTHENTICATION_LEVEL_PUBLIC, BboxConstant.AUTHENTICATION_LEVEL_PRIVATE)
self.bbox... | python | def get_all_connected_devices(self):
"""
Get all info about devices connected to the box
:return: a list with each device info
:rtype: list
"""
self.bbox_auth.set_access(BboxConstant.AUTHENTICATION_LEVEL_PUBLIC, BboxConstant.AUTHENTICATION_LEVEL_PRIVATE)
self.bbox... | [
"def",
"get_all_connected_devices",
"(",
"self",
")",
":",
"self",
".",
"bbox_auth",
".",
"set_access",
"(",
"BboxConstant",
".",
"AUTHENTICATION_LEVEL_PUBLIC",
",",
"BboxConstant",
".",
"AUTHENTICATION_LEVEL_PRIVATE",
")",
"self",
".",
"bbox_url",
".",
"set_api_name"... | Get all info about devices connected to the box
:return: a list with each device info
:rtype: list | [
"Get",
"all",
"info",
"about",
"devices",
"connected",
"to",
"the",
"box",
":",
"return",
":",
"a",
"list",
"with",
"each",
"device",
"info",
":",
"rtype",
":",
"list"
] | train | https://github.com/HydrelioxGitHub/pybbox/blob/bedcdccab5d18d36890ef8bf414845f2dec18b5c/pybbox/__init__.py#L102-L113 |
HydrelioxGitHub/pybbox | pybbox/__init__.py | Bbox.is_device_connected | def is_device_connected(self, ip):
"""
Check if a device identified by it IP is connected to the box
:param ip: IP of the device you want to test
:type ip: str
:return: True is the device is connected, False if it's not
:rtype: bool
"""
all_devices = self.... | python | def is_device_connected(self, ip):
"""
Check if a device identified by it IP is connected to the box
:param ip: IP of the device you want to test
:type ip: str
:return: True is the device is connected, False if it's not
:rtype: bool
"""
all_devices = self.... | [
"def",
"is_device_connected",
"(",
"self",
",",
"ip",
")",
":",
"all_devices",
"=",
"self",
".",
"get_all_connected_devices",
"(",
")",
"for",
"device",
"in",
"all_devices",
":",
"if",
"ip",
"==",
"device",
"[",
"'ipaddress'",
"]",
":",
"return",
"device",
... | Check if a device identified by it IP is connected to the box
:param ip: IP of the device you want to test
:type ip: str
:return: True is the device is connected, False if it's not
:rtype: bool | [
"Check",
"if",
"a",
"device",
"identified",
"by",
"it",
"IP",
"is",
"connected",
"to",
"the",
"box",
":",
"param",
"ip",
":",
"IP",
"of",
"the",
"device",
"you",
"want",
"to",
"test",
":",
"type",
"ip",
":",
"str",
":",
"return",
":",
"True",
"is",... | train | https://github.com/HydrelioxGitHub/pybbox/blob/bedcdccab5d18d36890ef8bf414845f2dec18b5c/pybbox/__init__.py#L115-L127 |
HydrelioxGitHub/pybbox | pybbox/__init__.py | Bbox.login | def login(self, password):
"""
Authentify yourself against the box,
:param password: Admin password of the box
:type password: str
:return: True if your auth is successful
:rtype: bool
"""
self.bbox_auth.set_access(BboxConstant.AUTHENTICATION_LEVEL_PUBLIC,... | python | def login(self, password):
"""
Authentify yourself against the box,
:param password: Admin password of the box
:type password: str
:return: True if your auth is successful
:rtype: bool
"""
self.bbox_auth.set_access(BboxConstant.AUTHENTICATION_LEVEL_PUBLIC,... | [
"def",
"login",
"(",
"self",
",",
"password",
")",
":",
"self",
".",
"bbox_auth",
".",
"set_access",
"(",
"BboxConstant",
".",
"AUTHENTICATION_LEVEL_PUBLIC",
",",
"BboxConstant",
".",
"AUTHENTICATION_LEVEL_PUBLIC",
")",
"self",
".",
"bbox_url",
".",
"set_api_name"... | Authentify yourself against the box,
:param password: Admin password of the box
:type password: str
:return: True if your auth is successful
:rtype: bool | [
"Authentify",
"yourself",
"against",
"the",
"box",
":",
"param",
"password",
":",
"Admin",
"password",
"of",
"the",
"box",
":",
"type",
"password",
":",
"str",
":",
"return",
":",
"True",
"if",
"your",
"auth",
"is",
"successful",
":",
"rtype",
":",
"bool... | train | https://github.com/HydrelioxGitHub/pybbox/blob/bedcdccab5d18d36890ef8bf414845f2dec18b5c/pybbox/__init__.py#L133-L149 |
HydrelioxGitHub/pybbox | pybbox/__init__.py | Bbox.logout | def logout(self):
"""
Destroy the auth session against the box
:return: True if your logout is successful
:rtype: bool
"""
self.bbox_auth.set_access(BboxConstant.AUTHENTICATION_LEVEL_PUBLIC, BboxConstant.AUTHENTICATION_LEVEL_PUBLIC)
self.bbox_url.set_api_name("log... | python | def logout(self):
"""
Destroy the auth session against the box
:return: True if your logout is successful
:rtype: bool
"""
self.bbox_auth.set_access(BboxConstant.AUTHENTICATION_LEVEL_PUBLIC, BboxConstant.AUTHENTICATION_LEVEL_PUBLIC)
self.bbox_url.set_api_name("log... | [
"def",
"logout",
"(",
"self",
")",
":",
"self",
".",
"bbox_auth",
".",
"set_access",
"(",
"BboxConstant",
".",
"AUTHENTICATION_LEVEL_PUBLIC",
",",
"BboxConstant",
".",
"AUTHENTICATION_LEVEL_PUBLIC",
")",
"self",
".",
"bbox_url",
".",
"set_api_name",
"(",
"\"logout... | Destroy the auth session against the box
:return: True if your logout is successful
:rtype: bool | [
"Destroy",
"the",
"auth",
"session",
"against",
"the",
"box",
":",
"return",
":",
"True",
"if",
"your",
"logout",
"is",
"successful",
":",
"rtype",
":",
"bool"
] | train | https://github.com/HydrelioxGitHub/pybbox/blob/bedcdccab5d18d36890ef8bf414845f2dec18b5c/pybbox/__init__.py#L151-L164 |
HydrelioxGitHub/pybbox | pybbox/__init__.py | Bbox.get_xdsl_stats | def get_xdsl_stats(self):
"""
Get all stats about your xDSL connection
:return: A dict with all stats about your xdsl connection (see API doc)
:rtype: dict
"""
self.bbox_auth.set_access(BboxConstant.AUTHENTICATION_LEVEL_PUBLIC, BboxConstant.AUTHENTICATION_LEVEL_PRIVATE)
... | python | def get_xdsl_stats(self):
"""
Get all stats about your xDSL connection
:return: A dict with all stats about your xdsl connection (see API doc)
:rtype: dict
"""
self.bbox_auth.set_access(BboxConstant.AUTHENTICATION_LEVEL_PUBLIC, BboxConstant.AUTHENTICATION_LEVEL_PRIVATE)
... | [
"def",
"get_xdsl_stats",
"(",
"self",
")",
":",
"self",
".",
"bbox_auth",
".",
"set_access",
"(",
"BboxConstant",
".",
"AUTHENTICATION_LEVEL_PUBLIC",
",",
"BboxConstant",
".",
"AUTHENTICATION_LEVEL_PRIVATE",
")",
"self",
".",
"bbox_url",
".",
"set_api_name",
"(",
... | Get all stats about your xDSL connection
:return: A dict with all stats about your xdsl connection (see API doc)
:rtype: dict | [
"Get",
"all",
"stats",
"about",
"your",
"xDSL",
"connection",
":",
"return",
":",
"A",
"dict",
"with",
"all",
"stats",
"about",
"your",
"xdsl",
"connection",
"(",
"see",
"API",
"doc",
")",
":",
"rtype",
":",
"dict"
] | train | https://github.com/HydrelioxGitHub/pybbox/blob/bedcdccab5d18d36890ef8bf414845f2dec18b5c/pybbox/__init__.py#L183-L194 |
HydrelioxGitHub/pybbox | pybbox/__init__.py | Bbox.get_up_used_bandwith | def get_up_used_bandwith(self):
"""
Return a percentage of the current used xdsl upload bandwith
Instant measure, can be very different from one call to another
:return: 0 no bandwith is used, 100 all your bandwith is used
:rtype: int
"""
ip_stats_up = self.get_ip... | python | def get_up_used_bandwith(self):
"""
Return a percentage of the current used xdsl upload bandwith
Instant measure, can be very different from one call to another
:return: 0 no bandwith is used, 100 all your bandwith is used
:rtype: int
"""
ip_stats_up = self.get_ip... | [
"def",
"get_up_used_bandwith",
"(",
"self",
")",
":",
"ip_stats_up",
"=",
"self",
".",
"get_ip_stats",
"(",
")",
"[",
"'tx'",
"]",
"percent",
"=",
"ip_stats_up",
"[",
"'bandwidth'",
"]",
"*",
"100",
"/",
"ip_stats_up",
"[",
"'maxBandwidth'",
"]",
"return",
... | Return a percentage of the current used xdsl upload bandwith
Instant measure, can be very different from one call to another
:return: 0 no bandwith is used, 100 all your bandwith is used
:rtype: int | [
"Return",
"a",
"percentage",
"of",
"the",
"current",
"used",
"xdsl",
"upload",
"bandwith",
"Instant",
"measure",
"can",
"be",
"very",
"different",
"from",
"one",
"call",
"to",
"another",
":",
"return",
":",
"0",
"no",
"bandwith",
"is",
"used",
"100",
"all"... | train | https://github.com/HydrelioxGitHub/pybbox/blob/bedcdccab5d18d36890ef8bf414845f2dec18b5c/pybbox/__init__.py#L234-L243 |
HydrelioxGitHub/pybbox | pybbox/__init__.py | Bbox.get_down_used_bandwith | def get_down_used_bandwith(self):
"""
Return a percentage of the current used xdsl download bandwith
Instant measure, can be very different from one call to another
:return: 0 no bandwith is used, 100 all your bandwith is used
:rtype: int
"""
ip_stats_up = self.ge... | python | def get_down_used_bandwith(self):
"""
Return a percentage of the current used xdsl download bandwith
Instant measure, can be very different from one call to another
:return: 0 no bandwith is used, 100 all your bandwith is used
:rtype: int
"""
ip_stats_up = self.ge... | [
"def",
"get_down_used_bandwith",
"(",
"self",
")",
":",
"ip_stats_up",
"=",
"self",
".",
"get_ip_stats",
"(",
")",
"[",
"'rx'",
"]",
"percent",
"=",
"ip_stats_up",
"[",
"'bandwidth'",
"]",
"*",
"100",
"/",
"ip_stats_up",
"[",
"'maxBandwidth'",
"]",
"return",... | Return a percentage of the current used xdsl download bandwith
Instant measure, can be very different from one call to another
:return: 0 no bandwith is used, 100 all your bandwith is used
:rtype: int | [
"Return",
"a",
"percentage",
"of",
"the",
"current",
"used",
"xdsl",
"download",
"bandwith",
"Instant",
"measure",
"can",
"be",
"very",
"different",
"from",
"one",
"call",
"to",
"another",
":",
"return",
":",
"0",
"no",
"bandwith",
"is",
"used",
"100",
"al... | train | https://github.com/HydrelioxGitHub/pybbox/blob/bedcdccab5d18d36890ef8bf414845f2dec18b5c/pybbox/__init__.py#L245-L254 |
Zephor5/pooled-pika | pooled_pika.py | PooledConn._clear | def _clear(reason, idle_pool, using_pool, channel_pool, conn_id):
"""
clear the bad connection
:param reason:
:param idle_pool:
:param using_pool:
:param channel_pool:
:param conn_id:
:return:
"""
with _lock():
try:
... | python | def _clear(reason, idle_pool, using_pool, channel_pool, conn_id):
"""
clear the bad connection
:param reason:
:param idle_pool:
:param using_pool:
:param channel_pool:
:param conn_id:
:return:
"""
with _lock():
try:
... | [
"def",
"_clear",
"(",
"reason",
",",
"idle_pool",
",",
"using_pool",
",",
"channel_pool",
",",
"conn_id",
")",
":",
"with",
"_lock",
"(",
")",
":",
"try",
":",
"idle_pool",
".",
"pop",
"(",
"conn_id",
")",
"logger",
".",
"info",
"(",
"'a connection lost ... | clear the bad connection
:param reason:
:param idle_pool:
:param using_pool:
:param channel_pool:
:param conn_id:
:return: | [
"clear",
"the",
"bad",
"connection",
":",
"param",
"reason",
":",
":",
"param",
"idle_pool",
":",
":",
"param",
"using_pool",
":",
":",
"param",
"channel_pool",
":",
":",
"param",
"conn_id",
":",
":",
"return",
":"
] | train | https://github.com/Zephor5/pooled-pika/blob/4ed30b3713a543c23b65b141f9187a7eea43f1f9/pooled_pika.py#L123-L142 |
operasoftware/twisted-apns | apns/errorresponse.py | ErrorResponse.from_binary_string | def from_binary_string(self, stream):
"""Unpack the error response from a stream."""
command, code, identifier = struct.unpack(self.FORMAT, stream)
if command != self.COMMAND:
raise ErrorResponseInvalidCommandError()
if code not in self.CODES:
raise ErrorRespons... | python | def from_binary_string(self, stream):
"""Unpack the error response from a stream."""
command, code, identifier = struct.unpack(self.FORMAT, stream)
if command != self.COMMAND:
raise ErrorResponseInvalidCommandError()
if code not in self.CODES:
raise ErrorRespons... | [
"def",
"from_binary_string",
"(",
"self",
",",
"stream",
")",
":",
"command",
",",
"code",
",",
"identifier",
"=",
"struct",
".",
"unpack",
"(",
"self",
".",
"FORMAT",
",",
"stream",
")",
"if",
"command",
"!=",
"self",
".",
"COMMAND",
":",
"raise",
"Er... | Unpack the error response from a stream. | [
"Unpack",
"the",
"error",
"response",
"from",
"a",
"stream",
"."
] | train | https://github.com/operasoftware/twisted-apns/blob/c7bd460100067e0c96c440ac0f5516485ac7313f/apns/errorresponse.py#L67-L79 |
operasoftware/twisted-apns | apns/errorresponse.py | ErrorResponse.to_binary_string | def to_binary_string(self, code, identifier):
"""Pack the error response to binary string and return it."""
return struct.pack(self.FORMAT, self.COMMAND, code, identifier) | python | def to_binary_string(self, code, identifier):
"""Pack the error response to binary string and return it."""
return struct.pack(self.FORMAT, self.COMMAND, code, identifier) | [
"def",
"to_binary_string",
"(",
"self",
",",
"code",
",",
"identifier",
")",
":",
"return",
"struct",
".",
"pack",
"(",
"self",
".",
"FORMAT",
",",
"self",
".",
"COMMAND",
",",
"code",
",",
"identifier",
")"
] | Pack the error response to binary string and return it. | [
"Pack",
"the",
"error",
"response",
"to",
"binary",
"string",
"and",
"return",
"it",
"."
] | train | https://github.com/operasoftware/twisted-apns/blob/c7bd460100067e0c96c440ac0f5516485ac7313f/apns/errorresponse.py#L81-L83 |
mosesschwartz/scrypture | scrypture/demo_scripts/Security/quick_hash.py | hash | def hash(hash_type, input_text):
'''Hash input_text with the algorithm choice'''
hash_funcs = {'MD5' : hashlib.md5,
'SHA1' : hashlib.sha1,
'SHA224' : hashlib.sha224,
'SHA256' : hashlib.sha256,
'SHA384' : hashlib.sha384,
'S... | python | def hash(hash_type, input_text):
'''Hash input_text with the algorithm choice'''
hash_funcs = {'MD5' : hashlib.md5,
'SHA1' : hashlib.sha1,
'SHA224' : hashlib.sha224,
'SHA256' : hashlib.sha256,
'SHA384' : hashlib.sha384,
'S... | [
"def",
"hash",
"(",
"hash_type",
",",
"input_text",
")",
":",
"hash_funcs",
"=",
"{",
"'MD5'",
":",
"hashlib",
".",
"md5",
",",
"'SHA1'",
":",
"hashlib",
".",
"sha1",
",",
"'SHA224'",
":",
"hashlib",
".",
"sha224",
",",
"'SHA256'",
":",
"hashlib",
".",... | Hash input_text with the algorithm choice | [
"Hash",
"input_text",
"with",
"the",
"algorithm",
"choice"
] | train | https://github.com/mosesschwartz/scrypture/blob/d51eb0c9835a5122a655078268185ce8ab9ec86a/scrypture/demo_scripts/Security/quick_hash.py#L12-L25 |
inspirehep/inspire-utils | inspire_utils/dedupers.py | dedupe_list_of_dicts | def dedupe_list_of_dicts(ld):
"""Remove duplicates from a list of dictionaries preserving the order.
We can't use the generic list helper because a dictionary isn't hashable.
Adapted from http://stackoverflow.com/a/9427216/374865.
"""
def _freeze(o):
"""Recursively freezes a dict into an ha... | python | def dedupe_list_of_dicts(ld):
"""Remove duplicates from a list of dictionaries preserving the order.
We can't use the generic list helper because a dictionary isn't hashable.
Adapted from http://stackoverflow.com/a/9427216/374865.
"""
def _freeze(o):
"""Recursively freezes a dict into an ha... | [
"def",
"dedupe_list_of_dicts",
"(",
"ld",
")",
":",
"def",
"_freeze",
"(",
"o",
")",
":",
"\"\"\"Recursively freezes a dict into an hashable object.\n\n Adapted from http://stackoverflow.com/a/21614155/374865.\n \"\"\"",
"if",
"isinstance",
"(",
"o",
",",
"dict",
... | Remove duplicates from a list of dictionaries preserving the order.
We can't use the generic list helper because a dictionary isn't hashable.
Adapted from http://stackoverflow.com/a/9427216/374865. | [
"Remove",
"duplicates",
"from",
"a",
"list",
"of",
"dictionaries",
"preserving",
"the",
"order",
"."
] | train | https://github.com/inspirehep/inspire-utils/blob/b0b5983c58700735dfde75e4c8bd32834f2473d4/inspire_utils/dedupers.py#L43-L70 |
JNRowe/upoints | upoints/edist.py | destination | def destination(globs, locator, distance, bearing):
"""Calculate destination from locations."""
globs.locations.destination(distance, bearing, locator) | python | def destination(globs, locator, distance, bearing):
"""Calculate destination from locations."""
globs.locations.destination(distance, bearing, locator) | [
"def",
"destination",
"(",
"globs",
",",
"locator",
",",
"distance",
",",
"bearing",
")",
":",
"globs",
".",
"locations",
".",
"destination",
"(",
"distance",
",",
"bearing",
",",
"locator",
")"
] | Calculate destination from locations. | [
"Calculate",
"destination",
"from",
"locations",
"."
] | train | https://github.com/JNRowe/upoints/blob/1e4b7a53ed2a06cd854523d54c36aabdccea3830/upoints/edist.py#L427-L429 |
JNRowe/upoints | upoints/edist.py | read_locations | def read_locations(filename):
"""Pull locations from a user's config file.
Args:
filename (str): Config file to parse
Returns:
dict: List of locations from config file
"""
data = ConfigParser()
if filename == '-':
data.read_file(sys.stdin)
else:
data.read(fi... | python | def read_locations(filename):
"""Pull locations from a user's config file.
Args:
filename (str): Config file to parse
Returns:
dict: List of locations from config file
"""
data = ConfigParser()
if filename == '-':
data.read_file(sys.stdin)
else:
data.read(fi... | [
"def",
"read_locations",
"(",
"filename",
")",
":",
"data",
"=",
"ConfigParser",
"(",
")",
"if",
"filename",
"==",
"'-'",
":",
"data",
".",
"read_file",
"(",
"sys",
".",
"stdin",
")",
"else",
":",
"data",
".",
"read",
"(",
"filename",
")",
"if",
"not... | Pull locations from a user's config file.
Args:
filename (str): Config file to parse
Returns:
dict: List of locations from config file | [
"Pull",
"locations",
"from",
"a",
"user",
"s",
"config",
"file",
"."
] | train | https://github.com/JNRowe/upoints/blob/1e4b7a53ed2a06cd854523d54c36aabdccea3830/upoints/edist.py#L491-L517 |
JNRowe/upoints | upoints/edist.py | read_csv | def read_csv(filename):
"""Pull locations from a user's CSV file.
Read gpsbabel_'s CSV output format
.. _gpsbabel: http://www.gpsbabel.org/
Args:
filename (str): CSV file to parse
Returns:
tuple of dict and list: List of locations as ``str`` objects
"""
field_names = ('la... | python | def read_csv(filename):
"""Pull locations from a user's CSV file.
Read gpsbabel_'s CSV output format
.. _gpsbabel: http://www.gpsbabel.org/
Args:
filename (str): CSV file to parse
Returns:
tuple of dict and list: List of locations as ``str`` objects
"""
field_names = ('la... | [
"def",
"read_csv",
"(",
"filename",
")",
":",
"field_names",
"=",
"(",
"'latitude'",
",",
"'longitude'",
",",
"'name'",
")",
"data",
"=",
"utils",
".",
"prepare_csv_read",
"(",
"filename",
",",
"field_names",
",",
"skipinitialspace",
"=",
"True",
")",
"locat... | Pull locations from a user's CSV file.
Read gpsbabel_'s CSV output format
.. _gpsbabel: http://www.gpsbabel.org/
Args:
filename (str): CSV file to parse
Returns:
tuple of dict and list: List of locations as ``str`` objects | [
"Pull",
"locations",
"from",
"a",
"user",
"s",
"CSV",
"file",
"."
] | train | https://github.com/JNRowe/upoints/blob/1e4b7a53ed2a06cd854523d54c36aabdccea3830/upoints/edist.py#L520-L541 |
JNRowe/upoints | upoints/edist.py | main | def main():
"""Main script handler.
Returns:
int: 0 for success, >1 error code
"""
logging.basicConfig(format='%(asctime)s %(levelname)s:%(message)s')
try:
cli()
return 0
except LocationsError as error:
print(error)
return 2
except RuntimeError as er... | python | def main():
"""Main script handler.
Returns:
int: 0 for success, >1 error code
"""
logging.basicConfig(format='%(asctime)s %(levelname)s:%(message)s')
try:
cli()
return 0
except LocationsError as error:
print(error)
return 2
except RuntimeError as er... | [
"def",
"main",
"(",
")",
":",
"logging",
".",
"basicConfig",
"(",
"format",
"=",
"'%(asctime)s %(levelname)s:%(message)s'",
")",
"try",
":",
"cli",
"(",
")",
"return",
"0",
"except",
"LocationsError",
"as",
"error",
":",
"print",
"(",
"error",
")",
"return",... | Main script handler.
Returns:
int: 0 for success, >1 error code | [
"Main",
"script",
"handler",
"."
] | train | https://github.com/JNRowe/upoints/blob/1e4b7a53ed2a06cd854523d54c36aabdccea3830/upoints/edist.py#L544-L562 |
aodag/WebDispatch | webdispatch/paster.py | make_urldispatch_application | def make_urldispatch_application(_, **settings):
""" paste.app_factory interface for URLDispatcher"""
patterns = [p.split("=", 1)
for p in settings['patterns'].split('\n')
if p]
application = URLDispatcher()
for pattern, app in patterns:
pattern = pattern.strip()... | python | def make_urldispatch_application(_, **settings):
""" paste.app_factory interface for URLDispatcher"""
patterns = [p.split("=", 1)
for p in settings['patterns'].split('\n')
if p]
application = URLDispatcher()
for pattern, app in patterns:
pattern = pattern.strip()... | [
"def",
"make_urldispatch_application",
"(",
"_",
",",
"*",
"*",
"settings",
")",
":",
"patterns",
"=",
"[",
"p",
".",
"split",
"(",
"\"=\"",
",",
"1",
")",
"for",
"p",
"in",
"settings",
"[",
"'patterns'",
"]",
".",
"split",
"(",
"'\\n'",
")",
"if",
... | paste.app_factory interface for URLDispatcher | [
"paste",
".",
"app_factory",
"interface",
"for",
"URLDispatcher"
] | train | https://github.com/aodag/WebDispatch/blob/55f8658a2b4100498e098a80303a346c3940f1bc/webdispatch/paster.py#L7-L24 |
srevenant/dictlib | dictlib/__init__.py | _splice_index | def _splice_index(*key):
"""
Utility for key management in dig/dug
If first elem of key list contains an index[], spread it out as a second
numeric index.
>>> _splice_index('abc[0]', 'def')
('abc', 0, 'def')
>>> _splice_index('abc[a]', 'def')
('abc[a]', 'def')
>>> _splice_index('ab... | python | def _splice_index(*key):
"""
Utility for key management in dig/dug
If first elem of key list contains an index[], spread it out as a second
numeric index.
>>> _splice_index('abc[0]', 'def')
('abc', 0, 'def')
>>> _splice_index('abc[a]', 'def')
('abc[a]', 'def')
>>> _splice_index('ab... | [
"def",
"_splice_index",
"(",
"*",
"key",
")",
":",
"if",
"isinstance",
"(",
"key",
"[",
"0",
"]",
",",
"str",
")",
":",
"result",
"=",
"rx_index",
".",
"search",
"(",
"key",
"[",
"0",
"]",
")",
"if",
"result",
":",
"return",
"tuple",
"(",
"[",
... | Utility for key management in dig/dug
If first elem of key list contains an index[], spread it out as a second
numeric index.
>>> _splice_index('abc[0]', 'def')
('abc', 0, 'def')
>>> _splice_index('abc[a]', 'def')
('abc[a]', 'def')
>>> _splice_index('abc[200]', 'def')
('abc', 200, 'def... | [
"Utility",
"for",
"key",
"management",
"in",
"dig",
"/",
"dug"
] | train | https://github.com/srevenant/dictlib/blob/88d743aa897d9c2c6de3c405522f9de3ba2aa869/dictlib/__init__.py#L29-L51 |
srevenant/dictlib | dictlib/__init__.py | _dig | def _dig(obj, *key):
"""
Recursively lookup an item in a nested dictionary,
using an array of indexes
>>> _dig({"a":{"b":{"c":1}}}, "a", "b", "c")
1
"""
key = _splice_index(*key)
if len(key) == 1:
return obj[key[0]]
return _dig(obj[key[0]], *key[1:]) | python | def _dig(obj, *key):
"""
Recursively lookup an item in a nested dictionary,
using an array of indexes
>>> _dig({"a":{"b":{"c":1}}}, "a", "b", "c")
1
"""
key = _splice_index(*key)
if len(key) == 1:
return obj[key[0]]
return _dig(obj[key[0]], *key[1:]) | [
"def",
"_dig",
"(",
"obj",
",",
"*",
"key",
")",
":",
"key",
"=",
"_splice_index",
"(",
"*",
"key",
")",
"if",
"len",
"(",
"key",
")",
"==",
"1",
":",
"return",
"obj",
"[",
"key",
"[",
"0",
"]",
"]",
"return",
"_dig",
"(",
"obj",
"[",
"key",
... | Recursively lookup an item in a nested dictionary,
using an array of indexes
>>> _dig({"a":{"b":{"c":1}}}, "a", "b", "c")
1 | [
"Recursively",
"lookup",
"an",
"item",
"in",
"a",
"nested",
"dictionary",
"using",
"an",
"array",
"of",
"indexes"
] | train | https://github.com/srevenant/dictlib/blob/88d743aa897d9c2c6de3c405522f9de3ba2aa869/dictlib/__init__.py#L62-L74 |
srevenant/dictlib | dictlib/__init__.py | dig_get | def dig_get(obj, key, *default):
"""
Recursively pull from a dictionary, using dot notation, with default value
instead of raised error (similar to dict.get()).
>>> dig_get({"a":{"b":{"c":1}}}, "a.b.d")
>>> dig_get({"a":{"b":{"c":1}}}, "a.b.d", 2)
2
>>> dig_get({"a":{"b":[{"c":1},{"d":4}]}}... | python | def dig_get(obj, key, *default):
"""
Recursively pull from a dictionary, using dot notation, with default value
instead of raised error (similar to dict.get()).
>>> dig_get({"a":{"b":{"c":1}}}, "a.b.d")
>>> dig_get({"a":{"b":{"c":1}}}, "a.b.d", 2)
2
>>> dig_get({"a":{"b":[{"c":1},{"d":4}]}}... | [
"def",
"dig_get",
"(",
"obj",
",",
"key",
",",
"*",
"default",
")",
":",
"array",
"=",
"key",
".",
"split",
"(",
"\".\"",
")",
"if",
"default",
":",
"default",
"=",
"default",
"[",
"0",
"]",
"else",
":",
"default",
"=",
"None",
"return",
"_dig_get"... | Recursively pull from a dictionary, using dot notation, with default value
instead of raised error (similar to dict.get()).
>>> dig_get({"a":{"b":{"c":1}}}, "a.b.d")
>>> dig_get({"a":{"b":{"c":1}}}, "a.b.d", 2)
2
>>> dig_get({"a":{"b":[{"c":1},{"d":4}]}}, "a.b[1].d", 2)
4 | [
"Recursively",
"pull",
"from",
"a",
"dictionary",
"using",
"dot",
"notation",
"with",
"default",
"value",
"instead",
"of",
"raised",
"error",
"(",
"similar",
"to",
"dict",
".",
"get",
"()",
")",
"."
] | train | https://github.com/srevenant/dictlib/blob/88d743aa897d9c2c6de3c405522f9de3ba2aa869/dictlib/__init__.py#L77-L93 |
srevenant/dictlib | dictlib/__init__.py | _dig_get | def _dig_get(obj, default, *key):
"""
Recursively lookup an item in a nested dictionary,
using an array of indexes
>>> _dig_get({"a":{"b":{"c":1}}}, 2, "a", "b", "d")
2
"""
key = _splice_index(*key)
if len(key) == 1:
if isinstance(key[0], str):
return obj.get(key[0]... | python | def _dig_get(obj, default, *key):
"""
Recursively lookup an item in a nested dictionary,
using an array of indexes
>>> _dig_get({"a":{"b":{"c":1}}}, 2, "a", "b", "d")
2
"""
key = _splice_index(*key)
if len(key) == 1:
if isinstance(key[0], str):
return obj.get(key[0]... | [
"def",
"_dig_get",
"(",
"obj",
",",
"default",
",",
"*",
"key",
")",
":",
"key",
"=",
"_splice_index",
"(",
"*",
"key",
")",
"if",
"len",
"(",
"key",
")",
"==",
"1",
":",
"if",
"isinstance",
"(",
"key",
"[",
"0",
"]",
",",
"str",
")",
":",
"r... | Recursively lookup an item in a nested dictionary,
using an array of indexes
>>> _dig_get({"a":{"b":{"c":1}}}, 2, "a", "b", "d")
2 | [
"Recursively",
"lookup",
"an",
"item",
"in",
"a",
"nested",
"dictionary",
"using",
"an",
"array",
"of",
"indexes"
] | train | https://github.com/srevenant/dictlib/blob/88d743aa897d9c2c6de3c405522f9de3ba2aa869/dictlib/__init__.py#L95-L114 |
srevenant/dictlib | dictlib/__init__.py | dug | def dug(obj, key, value):
"""
Inverse of dig: recursively set a value in a dictionary, using
dot notation.
>>> test = {"a":{"b":{"c":1}}}
>>> dug(test, "a.b.c", 10)
>>> test
{'a': {'b': {'c': 10}}}
"""
array = key.split(".")
return _dug(obj, value, *array) | python | def dug(obj, key, value):
"""
Inverse of dig: recursively set a value in a dictionary, using
dot notation.
>>> test = {"a":{"b":{"c":1}}}
>>> dug(test, "a.b.c", 10)
>>> test
{'a': {'b': {'c': 10}}}
"""
array = key.split(".")
return _dug(obj, value, *array) | [
"def",
"dug",
"(",
"obj",
",",
"key",
",",
"value",
")",
":",
"array",
"=",
"key",
".",
"split",
"(",
"\".\"",
")",
"return",
"_dug",
"(",
"obj",
",",
"value",
",",
"*",
"array",
")"
] | Inverse of dig: recursively set a value in a dictionary, using
dot notation.
>>> test = {"a":{"b":{"c":1}}}
>>> dug(test, "a.b.c", 10)
>>> test
{'a': {'b': {'c': 10}}} | [
"Inverse",
"of",
"dig",
":",
"recursively",
"set",
"a",
"value",
"in",
"a",
"dictionary",
"using",
"dot",
"notation",
"."
] | train | https://github.com/srevenant/dictlib/blob/88d743aa897d9c2c6de3c405522f9de3ba2aa869/dictlib/__init__.py#L116-L127 |
srevenant/dictlib | dictlib/__init__.py | union | def union(dict1, dict2):
"""
Deep merge of dict2 into dict1. May be dictionaries or dictobj's.
Values in dict2 will replace values in dict1 where they vary but have
the same key.
When lists are encountered, the dict2 list will replace the dict1 list.
This will alter the first dictionary. The... | python | def union(dict1, dict2):
"""
Deep merge of dict2 into dict1. May be dictionaries or dictobj's.
Values in dict2 will replace values in dict1 where they vary but have
the same key.
When lists are encountered, the dict2 list will replace the dict1 list.
This will alter the first dictionary. The... | [
"def",
"union",
"(",
"dict1",
",",
"dict2",
")",
":",
"for",
"key",
",",
"value",
"in",
"dict2",
".",
"items",
"(",
")",
":",
"if",
"key",
"in",
"dict1",
"and",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"dict1",
"[",
"key",
"]",
"=",
"... | Deep merge of dict2 into dict1. May be dictionaries or dictobj's.
Values in dict2 will replace values in dict1 where they vary but have
the same key.
When lists are encountered, the dict2 list will replace the dict1 list.
This will alter the first dictionary. The returned result is dict1, but
it... | [
"Deep",
"merge",
"of",
"dict2",
"into",
"dict1",
".",
"May",
"be",
"dictionaries",
"or",
"dictobj",
"s",
".",
"Values",
"in",
"dict2",
"will",
"replace",
"values",
"in",
"dict1",
"where",
"they",
"vary",
"but",
"have",
"the",
"same",
"key",
"."
] | train | https://github.com/srevenant/dictlib/blob/88d743aa897d9c2c6de3c405522f9de3ba2aa869/dictlib/__init__.py#L138-L171 |
srevenant/dictlib | dictlib/__init__.py | union_setadd | def union_setadd(dict1, dict2):
"""
Similar to dictlib.union(), but following a setadd logic (with strings and ints),
and a union (with dictionaries). Assumption is that all elements of the list
are of the same type (i.e. if first element is a dict, it tries to union all
elements)
NOT data saf... | python | def union_setadd(dict1, dict2):
"""
Similar to dictlib.union(), but following a setadd logic (with strings and ints),
and a union (with dictionaries). Assumption is that all elements of the list
are of the same type (i.e. if first element is a dict, it tries to union all
elements)
NOT data saf... | [
"def",
"union_setadd",
"(",
"dict1",
",",
"dict2",
")",
":",
"for",
"key2",
",",
"val2",
"in",
"dict2",
".",
"items",
"(",
")",
":",
"# if key is in both places, do a union",
"if",
"key2",
"in",
"dict1",
":",
"# if dict2 val2 is a dict, assume dict1 val2 is as well"... | Similar to dictlib.union(), but following a setadd logic (with strings and ints),
and a union (with dictionaries). Assumption is that all elements of the list
are of the same type (i.e. if first element is a dict, it tries to union all
elements)
NOT data safe, it mangles both dict1 and dict2
>>> ... | [
"Similar",
"to",
"dictlib",
".",
"union",
"()",
"but",
"following",
"a",
"setadd",
"logic",
"(",
"with",
"strings",
"and",
"ints",
")",
"and",
"a",
"union",
"(",
"with",
"dictionaries",
")",
".",
"Assumption",
"is",
"that",
"all",
"elements",
"of",
"the"... | train | https://github.com/srevenant/dictlib/blob/88d743aa897d9c2c6de3c405522f9de3ba2aa869/dictlib/__init__.py#L174-L229 |
srevenant/dictlib | dictlib/__init__.py | _union_copy | def _union_copy(dict1, dict2):
"""
Internal wrapper to keep one level of copying out of play, for efficiency.
Only copies data on dict2, but will alter dict1.
"""
for key, value in dict2.items():
if key in dict1 and isinstance(value, dict):
dict1[key] = _union_copy(dict1[key], ... | python | def _union_copy(dict1, dict2):
"""
Internal wrapper to keep one level of copying out of play, for efficiency.
Only copies data on dict2, but will alter dict1.
"""
for key, value in dict2.items():
if key in dict1 and isinstance(value, dict):
dict1[key] = _union_copy(dict1[key], ... | [
"def",
"_union_copy",
"(",
"dict1",
",",
"dict2",
")",
":",
"for",
"key",
",",
"value",
"in",
"dict2",
".",
"items",
"(",
")",
":",
"if",
"key",
"in",
"dict1",
"and",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"dict1",
"[",
"key",
"]",
"=... | Internal wrapper to keep one level of copying out of play, for efficiency.
Only copies data on dict2, but will alter dict1. | [
"Internal",
"wrapper",
"to",
"keep",
"one",
"level",
"of",
"copying",
"out",
"of",
"play",
"for",
"efficiency",
"."
] | train | https://github.com/srevenant/dictlib/blob/88d743aa897d9c2c6de3c405522f9de3ba2aa869/dictlib/__init__.py#L260-L272 |
pyrapt/rapt | rapt/treebrd/grammars/condition_grammar.py | get_attribute_references | def get_attribute_references(instring):
"""
Return a list of attribute references in the condition expression.
attribute_reference ::= relation_name "." attribute_name | attribute_name
:param instring: a condition expression.
:return: a list of attribute references.
"""
parsed = ConditionG... | python | def get_attribute_references(instring):
"""
Return a list of attribute references in the condition expression.
attribute_reference ::= relation_name "." attribute_name | attribute_name
:param instring: a condition expression.
:return: a list of attribute references.
"""
parsed = ConditionG... | [
"def",
"get_attribute_references",
"(",
"instring",
")",
":",
"parsed",
"=",
"ConditionGrammar",
"(",
")",
".",
"conditions",
".",
"parseString",
"(",
"instring",
")",
"result",
"=",
"parsed",
"if",
"isinstance",
"(",
"parsed",
"[",
"0",
"]",
",",
"str",
"... | Return a list of attribute references in the condition expression.
attribute_reference ::= relation_name "." attribute_name | attribute_name
:param instring: a condition expression.
:return: a list of attribute references. | [
"Return",
"a",
"list",
"of",
"attribute",
"references",
"in",
"the",
"condition",
"expression",
"."
] | train | https://github.com/pyrapt/rapt/blob/0193a07aafff83a887fdc9e5e0f25eafa5b1b205/rapt/treebrd/grammars/condition_grammar.py#L7-L18 |
pyrapt/rapt | rapt/treebrd/grammars/condition_grammar.py | ConditionGrammar.logical_binary_op | def logical_binary_op(self):
"""
logical_binary_op ::= and_op | or_op
"""
return (CaselessKeyword(self.syntax.and_op) |
CaselessKeyword(self.syntax.or_op)) | python | def logical_binary_op(self):
"""
logical_binary_op ::= and_op | or_op
"""
return (CaselessKeyword(self.syntax.and_op) |
CaselessKeyword(self.syntax.or_op)) | [
"def",
"logical_binary_op",
"(",
"self",
")",
":",
"return",
"(",
"CaselessKeyword",
"(",
"self",
".",
"syntax",
".",
"and_op",
")",
"|",
"CaselessKeyword",
"(",
"self",
".",
"syntax",
".",
"or_op",
")",
")"
] | logical_binary_op ::= and_op | or_op | [
"logical_binary_op",
"::",
"=",
"and_op",
"|",
"or_op"
] | train | https://github.com/pyrapt/rapt/blob/0193a07aafff83a887fdc9e5e0f25eafa5b1b205/rapt/treebrd/grammars/condition_grammar.py#L50-L55 |
pyrapt/rapt | rapt/treebrd/grammars/condition_grammar.py | ConditionGrammar.conditions | def conditions(self):
"""
conditions ::= condition | condition logical_binary_op conditions
Note: By default lpar and rpar arguments are suppressed.
"""
return operatorPrecedence(
baseExpr=self.condition,
opList=[(self.not_op, 1, opAssoc.RIGHT),
... | python | def conditions(self):
"""
conditions ::= condition | condition logical_binary_op conditions
Note: By default lpar and rpar arguments are suppressed.
"""
return operatorPrecedence(
baseExpr=self.condition,
opList=[(self.not_op, 1, opAssoc.RIGHT),
... | [
"def",
"conditions",
"(",
"self",
")",
":",
"return",
"operatorPrecedence",
"(",
"baseExpr",
"=",
"self",
".",
"condition",
",",
"opList",
"=",
"[",
"(",
"self",
".",
"not_op",
",",
"1",
",",
"opAssoc",
".",
"RIGHT",
")",
",",
"(",
"self",
".",
"logi... | conditions ::= condition | condition logical_binary_op conditions
Note: By default lpar and rpar arguments are suppressed. | [
"conditions",
"::",
"=",
"condition",
"|",
"condition",
"logical_binary_op",
"conditions",
"Note",
":",
"By",
"default",
"lpar",
"and",
"rpar",
"arguments",
"are",
"suppressed",
"."
] | train | https://github.com/pyrapt/rapt/blob/0193a07aafff83a887fdc9e5e0f25eafa5b1b205/rapt/treebrd/grammars/condition_grammar.py#L77-L87 |
luizirber/bioinfo | bioinfo/__init__.py | main | def main():
'''Main entry point for the bioinfo CLI.'''
args = docopt(__doc__, version=__version__)
if 'bam_coverage' in args:
bam_coverage(args['<reference>'],
args['<alignments>'],
int(args['<minmatch>']),
min_mapq=int(args['--mapq'])... | python | def main():
'''Main entry point for the bioinfo CLI.'''
args = docopt(__doc__, version=__version__)
if 'bam_coverage' in args:
bam_coverage(args['<reference>'],
args['<alignments>'],
int(args['<minmatch>']),
min_mapq=int(args['--mapq'])... | [
"def",
"main",
"(",
")",
":",
"args",
"=",
"docopt",
"(",
"__doc__",
",",
"version",
"=",
"__version__",
")",
"if",
"'bam_coverage'",
"in",
"args",
":",
"bam_coverage",
"(",
"args",
"[",
"'<reference>'",
"]",
",",
"args",
"[",
"'<alignments>'",
"]",
",",... | Main entry point for the bioinfo CLI. | [
"Main",
"entry",
"point",
"for",
"the",
"bioinfo",
"CLI",
"."
] | train | https://github.com/luizirber/bioinfo/blob/756758f62b4f7136cdb54de2f79033ff0226a6b7/bioinfo/__init__.py#L37-L46 |
toumorokoshi/miura | miura/runner.py | JobParser.parse_job | def parse_job(self, run_method, options):
"""
Generates and returns a job object with the following:
* a run method, as defined in the readme
* a list of posix-like arguments
* a dictionary of data
* templates: a dict-like interface of (template_name, template_body) pair... | python | def parse_job(self, run_method, options):
"""
Generates and returns a job object with the following:
* a run method, as defined in the readme
* a list of posix-like arguments
* a dictionary of data
* templates: a dict-like interface of (template_name, template_body) pair... | [
"def",
"parse_job",
"(",
"self",
",",
"run_method",
",",
"options",
")",
":",
"for",
"job_dict",
"in",
"run_method",
"(",
"options",
",",
"self",
".",
"_data",
")",
":",
"# unpackaging dict",
"host",
"=",
"job_dict",
"[",
"'host'",
"]",
"name",
"=",
"job... | Generates and returns a job object with the following:
* a run method, as defined in the readme
* a list of posix-like arguments
* a dictionary of data
* templates: a dict-like interface of (template_name, template_body) pairs | [
"Generates",
"and",
"returns",
"a",
"job",
"object",
"with",
"the",
"following",
":"
] | train | https://github.com/toumorokoshi/miura/blob/f23e270a9507e5946798b1e897220c9fb1b8d5fa/miura/runner.py#L23-L52 |
toumorokoshi/miura | miura/runner.py | MiuraJenkinsJob.upsert | def upsert(self):
""" create or update the jenkins job """
if not self.jenkins_host.has_job(self.name):
LOGGER.info("creating {0}...".format(self.name))
self.jenkins_host.create_job(self.name, self.config_xml)
else:
jenkins_job = self.jenkins_host[self.name]
... | python | def upsert(self):
""" create or update the jenkins job """
if not self.jenkins_host.has_job(self.name):
LOGGER.info("creating {0}...".format(self.name))
self.jenkins_host.create_job(self.name, self.config_xml)
else:
jenkins_job = self.jenkins_host[self.name]
... | [
"def",
"upsert",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"jenkins_host",
".",
"has_job",
"(",
"self",
".",
"name",
")",
":",
"LOGGER",
".",
"info",
"(",
"\"creating {0}...\"",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"self",
".",
... | create or update the jenkins job | [
"create",
"or",
"update",
"the",
"jenkins",
"job"
] | train | https://github.com/toumorokoshi/miura/blob/f23e270a9507e5946798b1e897220c9fb1b8d5fa/miura/runner.py#L69-L77 |
toumorokoshi/miura | miura/runner.py | MiuraJenkinsJob.delete | def delete(self):
""" delete the jenkins job, if it exists """
if self.jenkins_host.has_job(self.name):
LOGGER.info("deleting {0}...".format(self.name))
self.jenkins_host.delete_job(self.name) | python | def delete(self):
""" delete the jenkins job, if it exists """
if self.jenkins_host.has_job(self.name):
LOGGER.info("deleting {0}...".format(self.name))
self.jenkins_host.delete_job(self.name) | [
"def",
"delete",
"(",
"self",
")",
":",
"if",
"self",
".",
"jenkins_host",
".",
"has_job",
"(",
"self",
".",
"name",
")",
":",
"LOGGER",
".",
"info",
"(",
"\"deleting {0}...\"",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"self",
".",
"jenkins... | delete the jenkins job, if it exists | [
"delete",
"the",
"jenkins",
"job",
"if",
"it",
"exists"
] | train | https://github.com/toumorokoshi/miura/blob/f23e270a9507e5946798b1e897220c9fb1b8d5fa/miura/runner.py#L79-L83 |
toumorokoshi/miura | miura/runner.py | MiuraJenkinsJob.dry_run | def dry_run(self):
""" print information about the jenkins job """
LOGGER.info("Job Info: {name} -> {host}".format(
name=self.name,
host=self.jenkins_host.baseurl
)) | python | def dry_run(self):
""" print information about the jenkins job """
LOGGER.info("Job Info: {name} -> {host}".format(
name=self.name,
host=self.jenkins_host.baseurl
)) | [
"def",
"dry_run",
"(",
"self",
")",
":",
"LOGGER",
".",
"info",
"(",
"\"Job Info: {name} -> {host}\"",
".",
"format",
"(",
"name",
"=",
"self",
".",
"name",
",",
"host",
"=",
"self",
".",
"jenkins_host",
".",
"baseurl",
")",
")"
] | print information about the jenkins job | [
"print",
"information",
"about",
"the",
"jenkins",
"job"
] | train | https://github.com/toumorokoshi/miura/blob/f23e270a9507e5946798b1e897220c9fb1b8d5fa/miura/runner.py#L100-L105 |
waveform80/ElementTreeFactory | ElementTreeFactory/__init__.py | ElementTreeFactory._find | def _find(self, root, tagname, id=None):
"""Returns the first element with the specified tagname and id"""
if id is None:
result = root.find('.//%s' % tagname)
if result is None:
raise LookupError('Cannot find any %s elements' % tagname)
else:
... | python | def _find(self, root, tagname, id=None):
"""Returns the first element with the specified tagname and id"""
if id is None:
result = root.find('.//%s' % tagname)
if result is None:
raise LookupError('Cannot find any %s elements' % tagname)
else:
... | [
"def",
"_find",
"(",
"self",
",",
"root",
",",
"tagname",
",",
"id",
"=",
"None",
")",
":",
"if",
"id",
"is",
"None",
":",
"result",
"=",
"root",
".",
"find",
"(",
"'.//%s'",
"%",
"tagname",
")",
"if",
"result",
"is",
"None",
":",
"raise",
"Looku... | Returns the first element with the specified tagname and id | [
"Returns",
"the",
"first",
"element",
"with",
"the",
"specified",
"tagname",
"and",
"id"
] | train | https://github.com/waveform80/ElementTreeFactory/blob/83d93b9c2640fc052a7c621089fccca5b30845dc/ElementTreeFactory/__init__.py#L54-L72 |
waveform80/ElementTreeFactory | ElementTreeFactory/__init__.py | ElementTreeFactory._append | def _append(self, node, contents):
"""Adds content (string, node, node-list, etc.) to a node"""
if isinstance(contents, basestring):
if contents != '':
if len(node) == 0:
if node.text is None:
node.text = contents
... | python | def _append(self, node, contents):
"""Adds content (string, node, node-list, etc.) to a node"""
if isinstance(contents, basestring):
if contents != '':
if len(node) == 0:
if node.text is None:
node.text = contents
... | [
"def",
"_append",
"(",
"self",
",",
"node",
",",
"contents",
")",
":",
"if",
"isinstance",
"(",
"contents",
",",
"basestring",
")",
":",
"if",
"contents",
"!=",
"''",
":",
"if",
"len",
"(",
"node",
")",
"==",
"0",
":",
"if",
"node",
".",
"text",
... | Adds content (string, node, node-list, etc.) to a node | [
"Adds",
"content",
"(",
"string",
"node",
"node",
"-",
"list",
"etc",
".",
")",
"to",
"a",
"node"
] | train | https://github.com/waveform80/ElementTreeFactory/blob/83d93b9c2640fc052a7c621089fccca5b30845dc/ElementTreeFactory/__init__.py#L83-L106 |
ssaavedra/drf-swagger-extras | drf_swagger_extras/decorators.py | responds | def responds(status=status.HTTP_200_OK,
meaning='Undocumented status code',
schema=None,
schema_name=None,
**kwargs):
"""Documents the status code per handled case.
Additional parameters may make it into the OpenAPI documentation
per view. Examples of tho... | python | def responds(status=status.HTTP_200_OK,
meaning='Undocumented status code',
schema=None,
schema_name=None,
**kwargs):
"""Documents the status code per handled case.
Additional parameters may make it into the OpenAPI documentation
per view. Examples of tho... | [
"def",
"responds",
"(",
"status",
"=",
"status",
".",
"HTTP_200_OK",
",",
"meaning",
"=",
"'Undocumented status code'",
",",
"schema",
"=",
"None",
",",
"schema_name",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: Document syntax in above docstring",
... | Documents the status code per handled case.
Additional parameters may make it into the OpenAPI documentation
per view. Examples of those parameters include
examples={'application/json': <example>}. As schemata are needed
in order to render the examples in the Web UI, an error will be
signaled if ex... | [
"Documents",
"the",
"status",
"code",
"per",
"handled",
"case",
"."
] | train | https://github.com/ssaavedra/drf-swagger-extras/blob/c9cb698de6be1265e4f67381cc63b279e38d46a4/drf_swagger_extras/decorators.py#L58-L98 |
mosesschwartz/scrypture | scrypture/webapi.py | text_input | def text_input(*args, **kwargs):
'''
Get multi-line text input as a strong from a textarea form element.
'''
text_input = wtforms.TextAreaField(*args, **kwargs)
text_input.input_type = 'text'
return text_input | python | def text_input(*args, **kwargs):
'''
Get multi-line text input as a strong from a textarea form element.
'''
text_input = wtforms.TextAreaField(*args, **kwargs)
text_input.input_type = 'text'
return text_input | [
"def",
"text_input",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"text_input",
"=",
"wtforms",
".",
"TextAreaField",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"text_input",
".",
"input_type",
"=",
"'text'",
"return",
"text_input"
] | Get multi-line text input as a strong from a textarea form element. | [
"Get",
"multi",
"-",
"line",
"text",
"input",
"as",
"a",
"strong",
"from",
"a",
"textarea",
"form",
"element",
"."
] | train | https://github.com/mosesschwartz/scrypture/blob/d51eb0c9835a5122a655078268185ce8ab9ec86a/scrypture/webapi.py#L8-L14 |
mosesschwartz/scrypture | scrypture/webapi.py | list_input | def list_input(*args, **kwargs):
'''
Get a list parsed from newline-delimited entries from a textarea
'''
list_input = wtforms.TextAreaField(*args, **kwargs)
list_input.input_type = 'list'
return list_input | python | def list_input(*args, **kwargs):
'''
Get a list parsed from newline-delimited entries from a textarea
'''
list_input = wtforms.TextAreaField(*args, **kwargs)
list_input.input_type = 'list'
return list_input | [
"def",
"list_input",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"list_input",
"=",
"wtforms",
".",
"TextAreaField",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"list_input",
".",
"input_type",
"=",
"'list'",
"return",
"list_input"
] | Get a list parsed from newline-delimited entries from a textarea | [
"Get",
"a",
"list",
"parsed",
"from",
"newline",
"-",
"delimited",
"entries",
"from",
"a",
"textarea"
] | train | https://github.com/mosesschwartz/scrypture/blob/d51eb0c9835a5122a655078268185ce8ab9ec86a/scrypture/webapi.py#L16-L22 |
mosesschwartz/scrypture | scrypture/webapi.py | line_input | def line_input(*args, **kwargs):
'''
Get a single line of input as a string from a textfield
'''
line_input = wtforms.TextField(*args, **kwargs)
line_input.input_type = 'line'
return line_input | python | def line_input(*args, **kwargs):
'''
Get a single line of input as a string from a textfield
'''
line_input = wtforms.TextField(*args, **kwargs)
line_input.input_type = 'line'
return line_input | [
"def",
"line_input",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"line_input",
"=",
"wtforms",
".",
"TextField",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"line_input",
".",
"input_type",
"=",
"'line'",
"return",
"line_input"
] | Get a single line of input as a string from a textfield | [
"Get",
"a",
"single",
"line",
"of",
"input",
"as",
"a",
"string",
"from",
"a",
"textfield"
] | train | https://github.com/mosesschwartz/scrypture/blob/d51eb0c9835a5122a655078268185ce8ab9ec86a/scrypture/webapi.py#L24-L30 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.