repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
rameshg87/pyremotevbox
pyremotevbox/ZSI/TC.py
QName.set_prefix
def set_prefix(self, elt, pyobj): '''use this method to set the prefix of the QName, method looks in DOM to find prefix or set new prefix. This method must be called before get_formatted_content. ''' if isinstance(pyobj, tuple): namespaceURI,localName = pyobj ...
python
def set_prefix(self, elt, pyobj): '''use this method to set the prefix of the QName, method looks in DOM to find prefix or set new prefix. This method must be called before get_formatted_content. ''' if isinstance(pyobj, tuple): namespaceURI,localName = pyobj ...
[ "def", "set_prefix", "(", "self", ",", "elt", ",", "pyobj", ")", ":", "if", "isinstance", "(", "pyobj", ",", "tuple", ")", ":", "namespaceURI", ",", "localName", "=", "pyobj", "self", ".", "prefix", "=", "elt", ".", "getPrefix", "(", "namespaceURI", ")...
use this method to set the prefix of the QName, method looks in DOM to find prefix or set new prefix. This method must be called before get_formatted_content.
[ "use", "this", "method", "to", "set", "the", "prefix", "of", "the", "QName", "method", "looks", "in", "DOM", "to", "find", "prefix", "or", "set", "new", "prefix", ".", "This", "method", "must", "be", "called", "before", "get_formatted_content", "." ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TC.py#L771-L778
rameshg87/pyremotevbox
pyremotevbox/ZSI/TC.py
QName.text_to_data
def text_to_data(self, text, elt, ps): '''convert text into typecode specific data. ''' prefix,localName = SplitQName(text) nsdict = ps.GetElementNSdict(elt) prefix = prefix or '' try: namespaceURI = nsdict[prefix] except KeyError, ex: rais...
python
def text_to_data(self, text, elt, ps): '''convert text into typecode specific data. ''' prefix,localName = SplitQName(text) nsdict = ps.GetElementNSdict(elt) prefix = prefix or '' try: namespaceURI = nsdict[prefix] except KeyError, ex: rais...
[ "def", "text_to_data", "(", "self", ",", "text", ",", "elt", ",", "ps", ")", ":", "prefix", ",", "localName", "=", "SplitQName", "(", "text", ")", "nsdict", "=", "ps", ".", "GetElementNSdict", "(", "elt", ")", "prefix", "=", "prefix", "or", "''", "tr...
convert text into typecode specific data.
[ "convert", "text", "into", "typecode", "specific", "data", "." ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TC.py#L780-L795
rameshg87/pyremotevbox
pyremotevbox/ZSI/TC.py
QName.serialize_text_node
def serialize_text_node(self, elt, sw, pyobj): '''Serialize without an element node. ''' self.set_prefix(elt, pyobj) return String.serialize_text_node(self, elt, sw, pyobj)
python
def serialize_text_node(self, elt, sw, pyobj): '''Serialize without an element node. ''' self.set_prefix(elt, pyobj) return String.serialize_text_node(self, elt, sw, pyobj)
[ "def", "serialize_text_node", "(", "self", ",", "elt", ",", "sw", ",", "pyobj", ")", ":", "self", ".", "set_prefix", "(", "elt", ",", "pyobj", ")", "return", "String", ".", "serialize_text_node", "(", "self", ",", "elt", ",", "sw", ",", "pyobj", ")" ]
Serialize without an element node.
[ "Serialize", "without", "an", "element", "node", "." ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TC.py#L797-L801
rameshg87/pyremotevbox
pyremotevbox/ZSI/TC.py
Base64String.text_to_data
def text_to_data(self, text, elt, ps): '''convert text into typecode specific data. ''' val = b64decode(text.replace(' ', '').replace('\n','').replace('\r','')) if self.pyclass is not None: return self.pyclass(val) return val
python
def text_to_data(self, text, elt, ps): '''convert text into typecode specific data. ''' val = b64decode(text.replace(' ', '').replace('\n','').replace('\r','')) if self.pyclass is not None: return self.pyclass(val) return val
[ "def", "text_to_data", "(", "self", ",", "text", ",", "elt", ",", "ps", ")", ":", "val", "=", "b64decode", "(", "text", ".", "replace", "(", "' '", ",", "''", ")", ".", "replace", "(", "'\\n'", ",", "''", ")", ".", "replace", "(", "'\\r'", ",", ...
convert text into typecode specific data.
[ "convert", "text", "into", "typecode", "specific", "data", "." ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TC.py#L819-L825
rameshg87/pyremotevbox
pyremotevbox/ZSI/TC.py
HexBinaryString.text_to_data
def text_to_data(self, text, elt, ps): '''convert text into typecode specific data. ''' val = hexdecode(text) if self.pyclass is not None: return self.pyclass(val) return val
python
def text_to_data(self, text, elt, ps): '''convert text into typecode specific data. ''' val = hexdecode(text) if self.pyclass is not None: return self.pyclass(val) return val
[ "def", "text_to_data", "(", "self", ",", "text", ",", "elt", ",", "ps", ")", ":", "val", "=", "hexdecode", "(", "text", ")", "if", "self", ".", "pyclass", "is", "not", "None", ":", "return", "self", ".", "pyclass", "(", "val", ")", "return", "val" ...
convert text into typecode specific data.
[ "convert", "text", "into", "typecode", "specific", "data", "." ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TC.py#L857-L863
rameshg87/pyremotevbox
pyremotevbox/ZSI/TC.py
Integer.text_to_data
def text_to_data(self, text, elt, ps): '''convert text into typecode specific data. ''' if self.pyclass is not None: v = self.pyclass(text) else: try: v = int(text) except: try: v = long(text) ...
python
def text_to_data(self, text, elt, ps): '''convert text into typecode specific data. ''' if self.pyclass is not None: v = self.pyclass(text) else: try: v = int(text) except: try: v = long(text) ...
[ "def", "text_to_data", "(", "self", ",", "text", ",", "elt", ",", "ps", ")", ":", "if", "self", ".", "pyclass", "is", "not", "None", ":", "v", "=", "self", ".", "pyclass", "(", "text", ")", "else", ":", "try", ":", "v", "=", "int", "(", "text",...
convert text into typecode specific data.
[ "convert", "text", "into", "typecode", "specific", "data", "." ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TC.py#L958-L972
rameshg87/pyremotevbox
pyremotevbox/ZSI/TC.py
Decimal.text_to_data
def text_to_data(self, text, elt, ps): '''convert text into typecode specific data. ''' v = text if self.pyclass is not None: return self.pyclass(v) m = _magicnums.get(v) if m: return m try: return float(v) except: rai...
python
def text_to_data(self, text, elt, ps): '''convert text into typecode specific data. ''' v = text if self.pyclass is not None: return self.pyclass(v) m = _magicnums.get(v) if m: return m try: return float(v) except: rai...
[ "def", "text_to_data", "(", "self", ",", "text", ",", "elt", ",", "ps", ")", ":", "v", "=", "text", "if", "self", ".", "pyclass", "is", "not", "None", ":", "return", "self", ".", "pyclass", "(", "v", ")", "m", "=", "_magicnums", ".", "get", "(", ...
convert text into typecode specific data.
[ "convert", "text", "into", "typecode", "specific", "data", "." ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TC.py#L1090-L1104
rameshg87/pyremotevbox
pyremotevbox/ZSI/TC.py
Boolean.text_to_data
def text_to_data(self, text, elt, ps): '''convert text into typecode specific data. ''' v = text if v == 'false': if self.pyclass is None: return False return self.pyclass(False) if v == 'true': if self.pyclass is None: ...
python
def text_to_data(self, text, elt, ps): '''convert text into typecode specific data. ''' v = text if v == 'false': if self.pyclass is None: return False return self.pyclass(False) if v == 'true': if self.pyclass is None: ...
[ "def", "text_to_data", "(", "self", ",", "text", ",", "elt", ",", "ps", ")", ":", "v", "=", "text", "if", "v", "==", "'false'", ":", "if", "self", ".", "pyclass", "is", "None", ":", "return", "False", "return", "self", ".", "pyclass", "(", "False",...
convert text into typecode specific data.
[ "convert", "text", "into", "typecode", "specific", "data", "." ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TC.py#L1165-L1195
rameshg87/pyremotevbox
pyremotevbox/ZSI/TC.py
XML.cb
def cb(self, elt, sw, pyobj, unsuppressedPrefixes=[]): """pyobj -- xml.dom.Node.ELEMENT_NODE """ #if sw.Known(pyobj): # return if type(pyobj) in _stringtypes: elt.createAppendTextNode(pyobj) return ## grab document and import node, and append...
python
def cb(self, elt, sw, pyobj, unsuppressedPrefixes=[]): """pyobj -- xml.dom.Node.ELEMENT_NODE """ #if sw.Known(pyobj): # return if type(pyobj) in _stringtypes: elt.createAppendTextNode(pyobj) return ## grab document and import node, and append...
[ "def", "cb", "(", "self", ",", "elt", ",", "sw", ",", "pyobj", ",", "unsuppressedPrefixes", "=", "[", "]", ")", ":", "#if sw.Known(pyobj): ", "# return", "if", "type", "(", "pyobj", ")", "in", "_stringtypes", ":", "elt", ".", "createAppendTextNode", "("...
pyobj -- xml.dom.Node.ELEMENT_NODE
[ "pyobj", "--", "xml", ".", "dom", ".", "Node", ".", "ELEMENT_NODE" ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TC.py#L1276-L1297
rameshg87/pyremotevbox
pyremotevbox/ZSI/TC.py
AnyElement.serialize
def serialize(self, elt, sw, pyobj, **kw): '''Must provice typecode to AnyElement for serialization, else try to use TC.Any to serialize instance which will serialize based on the data type of pyobj w/o reference to XML schema instance. ''' if isinstance(pyobj, TypeCode...
python
def serialize(self, elt, sw, pyobj, **kw): '''Must provice typecode to AnyElement for serialization, else try to use TC.Any to serialize instance which will serialize based on the data type of pyobj w/o reference to XML schema instance. ''' if isinstance(pyobj, TypeCode...
[ "def", "serialize", "(", "self", ",", "elt", ",", "sw", ",", "pyobj", ",", "*", "*", "kw", ")", ":", "if", "isinstance", "(", "pyobj", ",", "TypeCode", ")", ":", "raise", "TypeError", ",", "'pyobj is a typecode instance.'", "what", "=", "getattr", "(", ...
Must provice typecode to AnyElement for serialization, else try to use TC.Any to serialize instance which will serialize based on the data type of pyobj w/o reference to XML schema instance.
[ "Must", "provice", "typecode", "to", "AnyElement", "for", "serialization", "else", "try", "to", "use", "TC", ".", "Any", "to", "serialize", "instance", "which", "will", "serialize", "based", "on", "the", "data", "type", "of", "pyobj", "w", "/", "o", "refer...
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TC.py#L1402-L1428
rameshg87/pyremotevbox
pyremotevbox/ZSI/TC.py
AnyElement.parse
def parse(self, elt, ps): ''' processContents -- 'lax' | 'skip' | 'strict', 'strict' 1) if 'skip' check namespaces, and return the DOM node. 2) if 'lax' look for declaration, or definition. If not found return DOM node. 3) if 'strict' get declaration, or raise. ...
python
def parse(self, elt, ps): ''' processContents -- 'lax' | 'skip' | 'strict', 'strict' 1) if 'skip' check namespaces, and return the DOM node. 2) if 'lax' look for declaration, or definition. If not found return DOM node. 3) if 'strict' get declaration, or raise. ...
[ "def", "parse", "(", "self", ",", "elt", ",", "ps", ")", ":", "skip", "=", "self", ".", "processContents", "==", "'skip'", "nspname", ",", "pname", "=", "_get_element_nsuri_name", "(", "elt", ")", "what", "=", "GED", "(", "nspname", ",", "pname", ")", ...
processContents -- 'lax' | 'skip' | 'strict', 'strict' 1) if 'skip' check namespaces, and return the DOM node. 2) if 'lax' look for declaration, or definition. If not found return DOM node. 3) if 'strict' get declaration, or raise.
[ "processContents", "--", "lax", "|", "skip", "|", "strict", "strict", "1", ")", "if", "skip", "check", "namespaces", "and", "return", "the", "DOM", "node", ".", "2", ")", "if", "lax", "look", "for", "declaration", "or", "definition", ".", "If", "not", ...
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TC.py#L1430-L1502
rameshg87/pyremotevbox
pyremotevbox/ZSI/TC.py
Union.parse
def parse(self, elt, ps, **kw): '''attempt to parse sequentially. No way to know ahead of time what this instance represents. Must be simple type so it can not have attributes nor children, so this isn't too bad. ''' self.setMemberTypeCodes() (nsuri,typeName) = self.che...
python
def parse(self, elt, ps, **kw): '''attempt to parse sequentially. No way to know ahead of time what this instance represents. Must be simple type so it can not have attributes nor children, so this isn't too bad. ''' self.setMemberTypeCodes() (nsuri,typeName) = self.che...
[ "def", "parse", "(", "self", ",", "elt", ",", "ps", ",", "*", "*", "kw", ")", ":", "self", ".", "setMemberTypeCodes", "(", ")", "(", "nsuri", ",", "typeName", ")", "=", "self", ".", "checkname", "(", "elt", ",", "ps", ")", "#if (nsuri,typeName) not i...
attempt to parse sequentially. No way to know ahead of time what this instance represents. Must be simple type so it can not have attributes nor children, so this isn't too bad.
[ "attempt", "to", "parse", "sequentially", ".", "No", "way", "to", "know", "ahead", "of", "time", "what", "this", "instance", "represents", ".", "Must", "be", "simple", "type", "so", "it", "can", "not", "have", "attributes", "nor", "children", "so", "this",...
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TC.py#L1540-L1570
rameshg87/pyremotevbox
pyremotevbox/ZSI/TC.py
List.text_to_data
def text_to_data(self, text, elt, ps): '''convert text into typecode specific data. items in list are space separated. ''' v = [] items = text.split() for item in items: v.append(self.itemTypeCode.text_to_data(item, elt, ps)) if self.pyclass is not N...
python
def text_to_data(self, text, elt, ps): '''convert text into typecode specific data. items in list are space separated. ''' v = [] items = text.split() for item in items: v.append(self.itemTypeCode.text_to_data(item, elt, ps)) if self.pyclass is not N...
[ "def", "text_to_data", "(", "self", ",", "text", ",", "elt", ",", "ps", ")", ":", "v", "=", "[", "]", "items", "=", "text", ".", "split", "(", ")", "for", "item", "in", "items", ":", "v", ".", "append", "(", "self", ".", "itemTypeCode", ".", "t...
convert text into typecode specific data. items in list are space separated.
[ "convert", "text", "into", "typecode", "specific", "data", ".", "items", "in", "list", "are", "space", "separated", "." ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TC.py#L1636-L1647
rameshg87/pyremotevbox
pyremotevbox/ZSI/TC.py
List.parse
def parse(self, elt, ps): '''elt -- the DOM element being parsed ps -- the ParsedSoap object. ''' self.checkname(elt, ps) if len(_children(elt)) == 0: href = _find_href(elt) if not href: if self.nilled(elt, ps) is False: ...
python
def parse(self, elt, ps): '''elt -- the DOM element being parsed ps -- the ParsedSoap object. ''' self.checkname(elt, ps) if len(_children(elt)) == 0: href = _find_href(elt) if not href: if self.nilled(elt, ps) is False: ...
[ "def", "parse", "(", "self", ",", "elt", ",", "ps", ")", ":", "self", ".", "checkname", "(", "elt", ",", "ps", ")", "if", "len", "(", "_children", "(", "elt", ")", ")", "==", "0", ":", "href", "=", "_find_href", "(", "elt", ")", "if", "not", ...
elt -- the DOM element being parsed ps -- the ParsedSoap object.
[ "elt", "--", "the", "DOM", "element", "being", "parsed", "ps", "--", "the", "ParsedSoap", "object", "." ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TC.py#L1649-L1672
rameshg87/pyremotevbox
pyremotevbox/ZSI/TC.py
List.serialize
def serialize(self, elt, sw, pyobj, name=None, orig=None, **kw): '''elt -- the current DOMWrapper element sw -- soapWriter object pyobj -- python object to serialize ''' if pyobj is not None and type(pyobj) not in _seqtypes: raise EvaluateException, 'expecting ...
python
def serialize(self, elt, sw, pyobj, name=None, orig=None, **kw): '''elt -- the current DOMWrapper element sw -- soapWriter object pyobj -- python object to serialize ''' if pyobj is not None and type(pyobj) not in _seqtypes: raise EvaluateException, 'expecting ...
[ "def", "serialize", "(", "self", ",", "elt", ",", "sw", ",", "pyobj", ",", "name", "=", "None", ",", "orig", "=", "None", ",", "*", "*", "kw", ")", ":", "if", "pyobj", "is", "not", "None", "and", "type", "(", "pyobj", ")", "not", "in", "_seqtyp...
elt -- the current DOMWrapper element sw -- soapWriter object pyobj -- python object to serialize
[ "elt", "--", "the", "current", "DOMWrapper", "element", "sw", "--", "soapWriter", "object", "pyobj", "--", "python", "object", "to", "serialize" ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TC.py#L1675-L1696
nefarioustim/parker
parker/workers.py
consumer
def consumer(site, uri): """Consume URI using site config.""" config = load_site_config(site) model = _get_model('consume', config, uri) consumestore = get_consumestore( model=model, method=_config.get('storage', 'file'), bucket=_config.get('s3_data_bucket', None) ) consu...
python
def consumer(site, uri): """Consume URI using site config.""" config = load_site_config(site) model = _get_model('consume', config, uri) consumestore = get_consumestore( model=model, method=_config.get('storage', 'file'), bucket=_config.get('s3_data_bucket', None) ) consu...
[ "def", "consumer", "(", "site", ",", "uri", ")", ":", "config", "=", "load_site_config", "(", "site", ")", "model", "=", "_get_model", "(", "'consume'", ",", "config", ",", "uri", ")", "consumestore", "=", "get_consumestore", "(", "model", "=", "model", ...
Consume URI using site config.
[ "Consume", "URI", "using", "site", "config", "." ]
train
https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/workers.py#L21-L31
nefarioustim/parker
parker/workers.py
crawler
def crawler(site, uri=None): """Crawl URI using site config.""" config = load_site_config(site) model = _get_model('crawl', config, uri) visited_set, visited_uri_set, consume_set, crawl_set = get_site_sets( site, config ) if not visited_set.has(model.hash): visited_set.add(model...
python
def crawler(site, uri=None): """Crawl URI using site config.""" config = load_site_config(site) model = _get_model('crawl', config, uri) visited_set, visited_uri_set, consume_set, crawl_set = get_site_sets( site, config ) if not visited_set.has(model.hash): visited_set.add(model...
[ "def", "crawler", "(", "site", ",", "uri", "=", "None", ")", ":", "config", "=", "load_site_config", "(", "site", ")", "model", "=", "_get_model", "(", "'crawl'", ",", "config", ",", "uri", ")", "visited_set", ",", "visited_uri_set", ",", "consume_set", ...
Crawl URI using site config.
[ "Crawl", "URI", "using", "site", "config", "." ]
train
https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/workers.py#L34-L67
nefarioustim/parker
parker/workers.py
killer
def killer(site): """Kill queues and Redis sets.""" config = load_site_config(site) crawl_q.empty() consume_q.empty() for site_set in get_site_sets(site, config): site_set.destroy()
python
def killer(site): """Kill queues and Redis sets.""" config = load_site_config(site) crawl_q.empty() consume_q.empty() for site_set in get_site_sets(site, config): site_set.destroy()
[ "def", "killer", "(", "site", ")", ":", "config", "=", "load_site_config", "(", "site", ")", "crawl_q", ".", "empty", "(", ")", "consume_q", ".", "empty", "(", ")", "for", "site_set", "in", "get_site_sets", "(", "site", ",", "config", ")", ":", "site_s...
Kill queues and Redis sets.
[ "Kill", "queues", "and", "Redis", "sets", "." ]
train
https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/workers.py#L70-L77
rameshg87/pyremotevbox
pyremotevbox/ZSI/auth.py
ClientBinding.GetAuth
def GetAuth(self): '''Return a tuple containing client authentication data. ''' if self.auth: return self.auth for elt in self.ps.GetMyHeaderElements(): if elt.localName == 'BasicAuth' \ and elt.namespaceURI == ZSI_SCHEMA_URI: d = _auth_tc.parse(el...
python
def GetAuth(self): '''Return a tuple containing client authentication data. ''' if self.auth: return self.auth for elt in self.ps.GetMyHeaderElements(): if elt.localName == 'BasicAuth' \ and elt.namespaceURI == ZSI_SCHEMA_URI: d = _auth_tc.parse(el...
[ "def", "GetAuth", "(", "self", ")", ":", "if", "self", ".", "auth", ":", "return", "self", ".", "auth", "for", "elt", "in", "self", ".", "ps", ".", "GetMyHeaderElements", "(", ")", ":", "if", "elt", ".", "localName", "==", "'BasicAuth'", "and", "elt"...
Return a tuple containing client authentication data.
[ "Return", "a", "tuple", "containing", "client", "authentication", "data", "." ]
train
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/auth.py#L35-L53
emory-libraries/eulcommon
eulcommon/djangoextras/auth/decorators.py
permission_required_with_403
def permission_required_with_403(perm, login_url=None): """ Decorator for views that checks whether a user has a particular permission enabled, redirecting to the login page or rendering a 403 as necessary. See :meth:`django.contrib.auth.decorators.permission_required`. """ return user_passes_t...
python
def permission_required_with_403(perm, login_url=None): """ Decorator for views that checks whether a user has a particular permission enabled, redirecting to the login page or rendering a 403 as necessary. See :meth:`django.contrib.auth.decorators.permission_required`. """ return user_passes_t...
[ "def", "permission_required_with_403", "(", "perm", ",", "login_url", "=", "None", ")", ":", "return", "user_passes_test_with_403", "(", "lambda", "u", ":", "u", ".", "has_perm", "(", "perm", ")", ",", "login_url", "=", "login_url", ")" ]
Decorator for views that checks whether a user has a particular permission enabled, redirecting to the login page or rendering a 403 as necessary. See :meth:`django.contrib.auth.decorators.permission_required`.
[ "Decorator", "for", "views", "that", "checks", "whether", "a", "user", "has", "a", "particular", "permission", "enabled", "redirecting", "to", "the", "login", "page", "or", "rendering", "a", "403", "as", "necessary", "." ]
train
https://github.com/emory-libraries/eulcommon/blob/dc63a9b3b5e38205178235e0d716d1b28158d3a9/eulcommon/djangoextras/auth/decorators.py#L52-L59
emory-libraries/eulcommon
eulcommon/djangoextras/auth/decorators.py
login_required_with_ajax
def login_required_with_ajax(function=None, redirect_field_name=REDIRECT_FIELD_NAME): """ Decorator for views that checks that the user is logged in, redirecting to the log-in page if necessary, but returns a special response for ajax requests. See :meth:`eulcommon.djangoextras.auth.decorators.user...
python
def login_required_with_ajax(function=None, redirect_field_name=REDIRECT_FIELD_NAME): """ Decorator for views that checks that the user is logged in, redirecting to the log-in page if necessary, but returns a special response for ajax requests. See :meth:`eulcommon.djangoextras.auth.decorators.user...
[ "def", "login_required_with_ajax", "(", "function", "=", "None", ",", "redirect_field_name", "=", "REDIRECT_FIELD_NAME", ")", ":", "# NOTE: currently only this format works: @login_required_with_ajax()", "# But this format errors: @login_required_with_ajax", "if", "function", "is", ...
Decorator for views that checks that the user is logged in, redirecting to the log-in page if necessary, but returns a special response for ajax requests. See :meth:`eulcommon.djangoextras.auth.decorators.user_passes_test_with_ajax`. Example usage:: @login_required_with_ajax() def my_...
[ "Decorator", "for", "views", "that", "checks", "that", "the", "user", "is", "logged", "in", "redirecting", "to", "the", "log", "-", "in", "page", "if", "necessary", "but", "returns", "a", "special", "response", "for", "ajax", "requests", ".", "See", ":", ...
train
https://github.com/emory-libraries/eulcommon/blob/dc63a9b3b5e38205178235e0d716d1b28158d3a9/eulcommon/djangoextras/auth/decorators.py#L111-L129
emory-libraries/eulcommon
eulcommon/djangoextras/auth/decorators.py
permission_required_with_ajax
def permission_required_with_ajax(perm, login_url=None): """ Decorator for views that checks whether a user has a particular permission enabled, redirecting to the log-in page if necessary, but returns a special response for ajax requests. See :meth:`eulcore.django.auth.decorators.user_passes_test_...
python
def permission_required_with_ajax(perm, login_url=None): """ Decorator for views that checks whether a user has a particular permission enabled, redirecting to the log-in page if necessary, but returns a special response for ajax requests. See :meth:`eulcore.django.auth.decorators.user_passes_test_...
[ "def", "permission_required_with_ajax", "(", "perm", ",", "login_url", "=", "None", ")", ":", "return", "user_passes_test_with_ajax", "(", "lambda", "u", ":", "u", ".", "has_perm", "(", "perm", ")", ",", "login_url", "=", "login_url", ")" ]
Decorator for views that checks whether a user has a particular permission enabled, redirecting to the log-in page if necessary, but returns a special response for ajax requests. See :meth:`eulcore.django.auth.decorators.user_passes_test_with_ajax`. Usage is the same as :meth:`django.contrib.auth....
[ "Decorator", "for", "views", "that", "checks", "whether", "a", "user", "has", "a", "particular", "permission", "enabled", "redirecting", "to", "the", "log", "-", "in", "page", "if", "necessary", "but", "returns", "a", "special", "response", "for", "ajax", "r...
train
https://github.com/emory-libraries/eulcommon/blob/dc63a9b3b5e38205178235e0d716d1b28158d3a9/eulcommon/djangoextras/auth/decorators.py#L132-L147
callowayproject/Transmogrify
transmogrify/optimize.py
convert_to_rgb
def convert_to_rgb(img): """ Convert an image to RGB if it isn't already RGB or grayscale """ if img.mode == 'CMYK' and HAS_PROFILE_TO_PROFILE: profile_dir = os.path.join(os.path.dirname(__file__), 'profiles') input_profile = os.path.join(profile_dir, "USWebUncoated.icc") output_...
python
def convert_to_rgb(img): """ Convert an image to RGB if it isn't already RGB or grayscale """ if img.mode == 'CMYK' and HAS_PROFILE_TO_PROFILE: profile_dir = os.path.join(os.path.dirname(__file__), 'profiles') input_profile = os.path.join(profile_dir, "USWebUncoated.icc") output_...
[ "def", "convert_to_rgb", "(", "img", ")", ":", "if", "img", ".", "mode", "==", "'CMYK'", "and", "HAS_PROFILE_TO_PROFILE", ":", "profile_dir", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "'prof...
Convert an image to RGB if it isn't already RGB or grayscale
[ "Convert", "an", "image", "to", "RGB", "if", "it", "isn", "t", "already", "RGB", "or", "grayscale" ]
train
https://github.com/callowayproject/Transmogrify/blob/f1f891b8b923b3a1ede5eac7f60531c1c472379e/transmogrify/optimize.py#L20-L29
callowayproject/Transmogrify
transmogrify/optimize.py
optimize
def optimize(image, fmt='jpeg', quality=80): """ Optimize the image if the IMAGE_OPTIMIZATION_CMD is set. IMAGE_OPTIMIZATION_CMD must accept piped input """ from io import BytesIO if IMAGE_OPTIMIZATION_CMD and is_tool(IMAGE_OPTIMIZATION_CMD): image_buffer = BytesIO() image.save...
python
def optimize(image, fmt='jpeg', quality=80): """ Optimize the image if the IMAGE_OPTIMIZATION_CMD is set. IMAGE_OPTIMIZATION_CMD must accept piped input """ from io import BytesIO if IMAGE_OPTIMIZATION_CMD and is_tool(IMAGE_OPTIMIZATION_CMD): image_buffer = BytesIO() image.save...
[ "def", "optimize", "(", "image", ",", "fmt", "=", "'jpeg'", ",", "quality", "=", "80", ")", ":", "from", "io", "import", "BytesIO", "if", "IMAGE_OPTIMIZATION_CMD", "and", "is_tool", "(", "IMAGE_OPTIMIZATION_CMD", ")", ":", "image_buffer", "=", "BytesIO", "("...
Optimize the image if the IMAGE_OPTIMIZATION_CMD is set. IMAGE_OPTIMIZATION_CMD must accept piped input
[ "Optimize", "the", "image", "if", "the", "IMAGE_OPTIMIZATION_CMD", "is", "set", "." ]
train
https://github.com/callowayproject/Transmogrify/blob/f1f891b8b923b3a1ede5eac7f60531c1c472379e/transmogrify/optimize.py#L32-L53
cahya-wirawan/opentc-util
opentc/util/__init__.py
setup_logging
def setup_logging( config_directories=None, config_file=None, default_level=logging.INFO, default_filename="logging.yml" ): """Setup logging configuration """ config_found = False config_file_path = None if config_file: config_file_path = config_file ...
python
def setup_logging( config_directories=None, config_file=None, default_level=logging.INFO, default_filename="logging.yml" ): """Setup logging configuration """ config_found = False config_file_path = None if config_file: config_file_path = config_file ...
[ "def", "setup_logging", "(", "config_directories", "=", "None", ",", "config_file", "=", "None", ",", "default_level", "=", "logging", ".", "INFO", ",", "default_filename", "=", "\"logging.yml\"", ")", ":", "config_found", "=", "False", "config_file_path", "=", ...
Setup logging configuration
[ "Setup", "logging", "configuration" ]
train
https://github.com/cahya-wirawan/opentc-util/blob/d8f3af78c97296e07a0dd470a144caaff92aa7d6/opentc/util/__init__.py#L9-L37
cahya-wirawan/opentc-util
opentc/util/__init__.py
setup_config
def setup_config( config_directories=None, config_file=None, default_filename="opentc.yml" ): """Setup configuration """ config_found = False config_file_path = None if config_file: config_file_path = config_file if os.path.isfile(config_file_path) and os.acc...
python
def setup_config( config_directories=None, config_file=None, default_filename="opentc.yml" ): """Setup configuration """ config_found = False config_file_path = None if config_file: config_file_path = config_file if os.path.isfile(config_file_path) and os.acc...
[ "def", "setup_config", "(", "config_directories", "=", "None", ",", "config_file", "=", "None", ",", "default_filename", "=", "\"opentc.yml\"", ")", ":", "config_found", "=", "False", "config_file_path", "=", "None", "if", "config_file", ":", "config_file_path", "...
Setup configuration
[ "Setup", "configuration" ]
train
https://github.com/cahya-wirawan/opentc-util/blob/d8f3af78c97296e07a0dd470a144caaff92aa7d6/opentc/util/__init__.py#L40-L68
pydsigner/pygu
pygu/pyslim.py
load
def load(filename, default=None): ''' Try to load @filename. If there is no loader for @filename's filetype, return @default. ''' ext = get_ext(filename) if ext in ldict: return ldict[ext](filename) else: return default
python
def load(filename, default=None): ''' Try to load @filename. If there is no loader for @filename's filetype, return @default. ''' ext = get_ext(filename) if ext in ldict: return ldict[ext](filename) else: return default
[ "def", "load", "(", "filename", ",", "default", "=", "None", ")", ":", "ext", "=", "get_ext", "(", "filename", ")", "if", "ext", "in", "ldict", ":", "return", "ldict", "[", "ext", "]", "(", "filename", ")", "else", ":", "return", "default" ]
Try to load @filename. If there is no loader for @filename's filetype, return @default.
[ "Try", "to", "load" ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyslim.py#L33-L42
edwards-lab/MVtest
meanvar/simple_timer.py
SimpleTimer.report
def report(self, msg, do_reset=False, file=sys.stdout): """Print to stdout msg followed by the runtime. When true, do_reset will result in a reset of start time. """ print >> file, "%s (%s s)" % (msg, time.time() - self.start) if do_reset: self.start = time.time()
python
def report(self, msg, do_reset=False, file=sys.stdout): """Print to stdout msg followed by the runtime. When true, do_reset will result in a reset of start time. """ print >> file, "%s (%s s)" % (msg, time.time() - self.start) if do_reset: self.start = time.time()
[ "def", "report", "(", "self", ",", "msg", ",", "do_reset", "=", "False", ",", "file", "=", "sys", ".", "stdout", ")", ":", "print", ">>", "file", ",", "\"%s (%s s)\"", "%", "(", "msg", ",", "time", ".", "time", "(", ")", "-", "self", ".", "start"...
Print to stdout msg followed by the runtime. When true, do_reset will result in a reset of start time.
[ "Print", "to", "stdout", "msg", "followed", "by", "the", "runtime", "." ]
train
https://github.com/edwards-lab/MVtest/blob/fe8cf627464ef59d68b7eda628a19840d033882f/meanvar/simple_timer.py#L28-L36
edwards-lab/MVtest
meanvar/simple_timer.py
SimpleTimer.result
def result(self, msg, do_reset=False): """Return log message containing ellapsed time as a string. When true, do_reset will result in a reset of start time. """ result = "%s (%s s)" % (msg, time.time() - self.start) if do_reset: self.start = time.time() retu...
python
def result(self, msg, do_reset=False): """Return log message containing ellapsed time as a string. When true, do_reset will result in a reset of start time. """ result = "%s (%s s)" % (msg, time.time() - self.start) if do_reset: self.start = time.time() retu...
[ "def", "result", "(", "self", ",", "msg", ",", "do_reset", "=", "False", ")", ":", "result", "=", "\"%s (%s s)\"", "%", "(", "msg", ",", "time", ".", "time", "(", ")", "-", "self", ".", "start", ")", "if", "do_reset", ":", "self", ".", "start", "...
Return log message containing ellapsed time as a string. When true, do_reset will result in a reset of start time.
[ "Return", "log", "message", "containing", "ellapsed", "time", "as", "a", "string", "." ]
train
https://github.com/edwards-lab/MVtest/blob/fe8cf627464ef59d68b7eda628a19840d033882f/meanvar/simple_timer.py#L38-L47
edwards-lab/MVtest
meanvar/simple_timer.py
SimpleTimer.runtime
def runtime(self): """Return ellapsed time and reset start. """ t = time.time() - self.start self.start = time.time() return t
python
def runtime(self): """Return ellapsed time and reset start. """ t = time.time() - self.start self.start = time.time() return t
[ "def", "runtime", "(", "self", ")", ":", "t", "=", "time", ".", "time", "(", ")", "-", "self", ".", "start", "self", ".", "start", "=", "time", ".", "time", "(", ")", "return", "t" ]
Return ellapsed time and reset start.
[ "Return", "ellapsed", "time", "and", "reset", "start", "." ]
train
https://github.com/edwards-lab/MVtest/blob/fe8cf627464ef59d68b7eda628a19840d033882f/meanvar/simple_timer.py#L54-L58
delfick/aws_syncr
aws_syncr/option_spec/apigateway.py
Gateways.sync_one
def sync_one(self, aws_syncr, amazon, gateway): """Make sure this gateway exists and has only attributes we want it to have""" gateway_info = amazon.apigateway.gateway_info(gateway.name, gateway.location) if not gateway_info: amazon.apigateway.create_gateway(gateway.name, gateway.loc...
python
def sync_one(self, aws_syncr, amazon, gateway): """Make sure this gateway exists and has only attributes we want it to have""" gateway_info = amazon.apigateway.gateway_info(gateway.name, gateway.location) if not gateway_info: amazon.apigateway.create_gateway(gateway.name, gateway.loc...
[ "def", "sync_one", "(", "self", ",", "aws_syncr", ",", "amazon", ",", "gateway", ")", ":", "gateway_info", "=", "amazon", ".", "apigateway", ".", "gateway_info", "(", "gateway", ".", "name", ",", "gateway", ".", "location", ")", "if", "not", "gateway_info"...
Make sure this gateway exists and has only attributes we want it to have
[ "Make", "sure", "this", "gateway", "exists", "and", "has", "only", "attributes", "we", "want", "it", "to", "have" ]
train
https://github.com/delfick/aws_syncr/blob/8cd214b27c1eee98dfba4632cbb8bc0ae36356bd/aws_syncr/option_spec/apigateway.py#L362-L368
fizyk/pyramid_yml
tzf/pyramid_yml/__init__.py
includeme
def includeme(configurator): """ Add yaml configuration utilities. :param pyramid.config.Configurator configurator: pyramid's app configurator """ settings = configurator.registry.settings # lets default it to running path yaml_locations = settings.get('yaml.location', ...
python
def includeme(configurator): """ Add yaml configuration utilities. :param pyramid.config.Configurator configurator: pyramid's app configurator """ settings = configurator.registry.settings # lets default it to running path yaml_locations = settings.get('yaml.location', ...
[ "def", "includeme", "(", "configurator", ")", ":", "settings", "=", "configurator", ".", "registry", ".", "settings", "# lets default it to running path", "yaml_locations", "=", "settings", ".", "get", "(", "'yaml.location'", ",", "settings", ".", "get", "(", "'ym...
Add yaml configuration utilities. :param pyramid.config.Configurator configurator: pyramid's app configurator
[ "Add", "yaml", "configuration", "utilities", "." ]
train
https://github.com/fizyk/pyramid_yml/blob/1b36c4e74194c04d7d69b4d7f86801757e78f0a6/tzf/pyramid_yml/__init__.py#L21-L55
fizyk/pyramid_yml
tzf/pyramid_yml/__init__.py
config_defaults
def config_defaults( configurator, config_locations, files=None): """ Read and extends/creates configuration from yaml source. .. note:: If exists, this method extends config with defaults, so it will not override existing values, merely add those, that were not defined alre...
python
def config_defaults( configurator, config_locations, files=None): """ Read and extends/creates configuration from yaml source. .. note:: If exists, this method extends config with defaults, so it will not override existing values, merely add those, that were not defined alre...
[ "def", "config_defaults", "(", "configurator", ",", "config_locations", ",", "files", "=", "None", ")", ":", "if", "files", "is", "None", ":", "files", "=", "[", "'config.yaml'", ",", "'config.yml'", "]", "if", "not", "isinstance", "(", "config_locations", "...
Read and extends/creates configuration from yaml source. .. note:: If exists, this method extends config with defaults, so it will not override existing values, merely add those, that were not defined already! :param pyramid.config.Configurator configurator: pyramid's app configurator ...
[ "Read", "and", "extends", "/", "creates", "configuration", "from", "yaml", "source", "." ]
train
https://github.com/fizyk/pyramid_yml/blob/1b36c4e74194c04d7d69b4d7f86801757e78f0a6/tzf/pyramid_yml/__init__.py#L58-L102
fizyk/pyramid_yml
tzf/pyramid_yml/__init__.py
_translate_config_path
def _translate_config_path(location): """ Translate location into fullpath according asset specification. Might be package:path for package related paths, or simply path :param str location: resource location :returns: fullpath :rtype: str """ # getting spec path package_name, fil...
python
def _translate_config_path(location): """ Translate location into fullpath according asset specification. Might be package:path for package related paths, or simply path :param str location: resource location :returns: fullpath :rtype: str """ # getting spec path package_name, fil...
[ "def", "_translate_config_path", "(", "location", ")", ":", "# getting spec path", "package_name", ",", "filename", "=", "resolve_asset_spec", "(", "location", ".", "strip", "(", ")", ")", "if", "not", "package_name", ":", "path", "=", "filename", "else", ":", ...
Translate location into fullpath according asset specification. Might be package:path for package related paths, or simply path :param str location: resource location :returns: fullpath :rtype: str
[ "Translate", "location", "into", "fullpath", "according", "asset", "specification", "." ]
train
https://github.com/fizyk/pyramid_yml/blob/1b36c4e74194c04d7d69b4d7f86801757e78f0a6/tzf/pyramid_yml/__init__.py#L105-L124
fizyk/pyramid_yml
tzf/pyramid_yml/__init__.py
_env_filenames
def _env_filenames(filenames, env): """ Extend filenames with ennv indication of environments. :param list filenames: list of strings indicating filenames :param str env: environment indicator :returns: list of filenames extended with environment version :rtype: list """ env_filenames ...
python
def _env_filenames(filenames, env): """ Extend filenames with ennv indication of environments. :param list filenames: list of strings indicating filenames :param str env: environment indicator :returns: list of filenames extended with environment version :rtype: list """ env_filenames ...
[ "def", "_env_filenames", "(", "filenames", ",", "env", ")", ":", "env_filenames", "=", "[", "]", "for", "filename", "in", "filenames", ":", "filename_parts", "=", "filename", ".", "split", "(", "'.'", ")", "filename_parts", ".", "insert", "(", "1", ",", ...
Extend filenames with ennv indication of environments. :param list filenames: list of strings indicating filenames :param str env: environment indicator :returns: list of filenames extended with environment version :rtype: list
[ "Extend", "filenames", "with", "ennv", "indication", "of", "environments", "." ]
train
https://github.com/fizyk/pyramid_yml/blob/1b36c4e74194c04d7d69b4d7f86801757e78f0a6/tzf/pyramid_yml/__init__.py#L127-L143
fizyk/pyramid_yml
tzf/pyramid_yml/__init__.py
_extend_settings
def _extend_settings(settings, configurator_config, prefix=None): """ Extend settings dictionary with content of yaml's configurator key. .. note:: This methods changes multilayered subkeys defined within **configurator** into dotted keys in settings dictionary: .. code-block:: y...
python
def _extend_settings(settings, configurator_config, prefix=None): """ Extend settings dictionary with content of yaml's configurator key. .. note:: This methods changes multilayered subkeys defined within **configurator** into dotted keys in settings dictionary: .. code-block:: y...
[ "def", "_extend_settings", "(", "settings", ",", "configurator_config", ",", "prefix", "=", "None", ")", ":", "for", "key", "in", "configurator_config", ":", "settings_key", "=", "'.'", ".", "join", "(", "[", "prefix", ",", "key", "]", ")", "if", "prefix",...
Extend settings dictionary with content of yaml's configurator key. .. note:: This methods changes multilayered subkeys defined within **configurator** into dotted keys in settings dictionary: .. code-block:: yaml configurator: sqlalchemy: ...
[ "Extend", "settings", "dictionary", "with", "content", "of", "yaml", "s", "configurator", "key", "." ]
train
https://github.com/fizyk/pyramid_yml/blob/1b36c4e74194c04d7d69b4d7f86801757e78f0a6/tzf/pyramid_yml/__init__.py#L146-L177
fizyk/pyramid_yml
tzf/pyramid_yml/__init__.py
_run_includemes
def _run_includemes(configurator, includemes): """ Automatically include packages defined in **include** configuration key. :param pyramid.config.Configurator configurator: pyramid's app configurator :param dict includemes: include, a list of includes or dictionary """ for include in includemes...
python
def _run_includemes(configurator, includemes): """ Automatically include packages defined in **include** configuration key. :param pyramid.config.Configurator configurator: pyramid's app configurator :param dict includemes: include, a list of includes or dictionary """ for include in includemes...
[ "def", "_run_includemes", "(", "configurator", ",", "includemes", ")", ":", "for", "include", "in", "includemes", ":", "if", "includemes", "[", "include", "]", ":", "try", ":", "configurator", ".", "include", "(", "include", ",", "includemes", "[", "include"...
Automatically include packages defined in **include** configuration key. :param pyramid.config.Configurator configurator: pyramid's app configurator :param dict includemes: include, a list of includes or dictionary
[ "Automatically", "include", "packages", "defined", "in", "**", "include", "**", "configuration", "key", "." ]
train
https://github.com/fizyk/pyramid_yml/blob/1b36c4e74194c04d7d69b4d7f86801757e78f0a6/tzf/pyramid_yml/__init__.py#L180-L192
nefarioustim/parker
parker/page.py
get_instance
def get_instance(uri): """Return an instance of Page.""" global _instances try: instance = _instances[uri] except KeyError: instance = Page( uri, client.get_instance() ) _instances[uri] = instance return instance
python
def get_instance(uri): """Return an instance of Page.""" global _instances try: instance = _instances[uri] except KeyError: instance = Page( uri, client.get_instance() ) _instances[uri] = instance return instance
[ "def", "get_instance", "(", "uri", ")", ":", "global", "_instances", "try", ":", "instance", "=", "_instances", "[", "uri", "]", "except", "KeyError", ":", "instance", "=", "Page", "(", "uri", ",", "client", ".", "get_instance", "(", ")", ")", "_instance...
Return an instance of Page.
[ "Return", "an", "instance", "of", "Page", "." ]
train
https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/page.py#L10-L22
nefarioustim/parker
parker/page.py
Page.fetch
def fetch(self): """Fetch Page.content from client.""" self.content = self.client.get_content( uri=self.uri ) self.hash = hashlib.sha256( self.content ).hexdigest()
python
def fetch(self): """Fetch Page.content from client.""" self.content = self.client.get_content( uri=self.uri ) self.hash = hashlib.sha256( self.content ).hexdigest()
[ "def", "fetch", "(", "self", ")", ":", "self", ".", "content", "=", "self", ".", "client", ".", "get_content", "(", "uri", "=", "self", ".", "uri", ")", "self", ".", "hash", "=", "hashlib", ".", "sha256", "(", "self", ".", "content", ")", ".", "h...
Fetch Page.content from client.
[ "Fetch", "Page", ".", "content", "from", "client", "." ]
train
https://github.com/nefarioustim/parker/blob/ccc1de1ac6bfb5e0a8cfa4fdebb2f38f2ee027d6/parker/page.py#L39-L46
pydsigner/pygu
pygu/pyramid.py
Resources.load_image
def load_image(self, loc, title, group): ''' Used internally when loading images. You should probably use load_objects(). ''' self.images.setdefault(group, {}) self.images[group][title] = pygame.image.load(loc).convert_alpha()
python
def load_image(self, loc, title, group): ''' Used internally when loading images. You should probably use load_objects(). ''' self.images.setdefault(group, {}) self.images[group][title] = pygame.image.load(loc).convert_alpha()
[ "def", "load_image", "(", "self", ",", "loc", ",", "title", ",", "group", ")", ":", "self", ".", "images", ".", "setdefault", "(", "group", ",", "{", "}", ")", "self", ".", "images", "[", "group", "]", "[", "title", "]", "=", "pygame", ".", "imag...
Used internally when loading images. You should probably use load_objects().
[ "Used", "internally", "when", "loading", "images", ".", "You", "should", "probably", "use", "load_objects", "()", "." ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L170-L176
pydsigner/pygu
pygu/pyramid.py
Resources.load_music
def load_music(self, loc, title, group): ''' Used internally when loading music. You should probably use load_objects(). ''' self.music.setdefault(group, {}) self.music[group][title] = loc
python
def load_music(self, loc, title, group): ''' Used internally when loading music. You should probably use load_objects(). ''' self.music.setdefault(group, {}) self.music[group][title] = loc
[ "def", "load_music", "(", "self", ",", "loc", ",", "title", ",", "group", ")", ":", "self", ".", "music", ".", "setdefault", "(", "group", ",", "{", "}", ")", "self", ".", "music", "[", "group", "]", "[", "title", "]", "=", "loc" ]
Used internally when loading music. You should probably use load_objects().
[ "Used", "internally", "when", "loading", "music", ".", "You", "should", "probably", "use", "load_objects", "()", "." ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L178-L184
pydsigner/pygu
pygu/pyramid.py
Resources.load_playlist
def load_playlist(self, loc, title): ''' Used internally when loading playlists. You should probably use load_objects(). ''' lines = [l.strip() for l in open(loc).readlines()] self.playlists.setdefault(title, []) self.playlists[title].append(Playlist(lines, True)...
python
def load_playlist(self, loc, title): ''' Used internally when loading playlists. You should probably use load_objects(). ''' lines = [l.strip() for l in open(loc).readlines()] self.playlists.setdefault(title, []) self.playlists[title].append(Playlist(lines, True)...
[ "def", "load_playlist", "(", "self", ",", "loc", ",", "title", ")", ":", "lines", "=", "[", "l", ".", "strip", "(", ")", "for", "l", "in", "open", "(", "loc", ")", ".", "readlines", "(", ")", "]", "self", ".", "playlists", ".", "setdefault", "(",...
Used internally when loading playlists. You should probably use load_objects().
[ "Used", "internally", "when", "loading", "playlists", ".", "You", "should", "probably", "use", "load_objects", "()", "." ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L186-L193
pydsigner/pygu
pygu/pyramid.py
Resources.load_sound
def load_sound(self, loc, title, group): ''' Used internally when loading sounds. You should probably use load_objects(). ''' self.sounds.setdefault(group, {}) self.sounds[group][title] = Sound(loc, self)
python
def load_sound(self, loc, title, group): ''' Used internally when loading sounds. You should probably use load_objects(). ''' self.sounds.setdefault(group, {}) self.sounds[group][title] = Sound(loc, self)
[ "def", "load_sound", "(", "self", ",", "loc", ",", "title", ",", "group", ")", ":", "self", ".", "sounds", ".", "setdefault", "(", "group", ",", "{", "}", ")", "self", ".", "sounds", "[", "group", "]", "[", "title", "]", "=", "Sound", "(", "loc",...
Used internally when loading sounds. You should probably use load_objects().
[ "Used", "internally", "when", "loading", "sounds", ".", "You", "should", "probably", "use", "load_objects", "()", "." ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L195-L201
pydsigner/pygu
pygu/pyramid.py
Resources.load_code
def load_code(self, path, package, callwith): ''' Used internally when loading code. You should probably use load_objects(). ''' sys.path = [path] + sys.path g_o = importlib.import_module(package).get_objects del sys.path[0] for obj in g_o(callwith): ...
python
def load_code(self, path, package, callwith): ''' Used internally when loading code. You should probably use load_objects(). ''' sys.path = [path] + sys.path g_o = importlib.import_module(package).get_objects del sys.path[0] for obj in g_o(callwith): ...
[ "def", "load_code", "(", "self", ",", "path", ",", "package", ",", "callwith", ")", ":", "sys", ".", "path", "=", "[", "path", "]", "+", "sys", ".", "path", "g_o", "=", "importlib", ".", "import_module", "(", "package", ")", ".", "get_objects", "del"...
Used internally when loading code. You should probably use load_objects().
[ "Used", "internally", "when", "loading", "code", ".", "You", "should", "probably", "use", "load_objects", "()", "." ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L203-L212
pydsigner/pygu
pygu/pyramid.py
Resources.load_objects
def load_objects(self, dirs=[], callwith={}): ''' Call this to load resources from each dir in @dirs. Code resources will receive @callwith as an argument. ''' for d in dirs: contents = ls(d) for t in contents: first = join(d, t) ...
python
def load_objects(self, dirs=[], callwith={}): ''' Call this to load resources from each dir in @dirs. Code resources will receive @callwith as an argument. ''' for d in dirs: contents = ls(d) for t in contents: first = join(d, t) ...
[ "def", "load_objects", "(", "self", ",", "dirs", "=", "[", "]", ",", "callwith", "=", "{", "}", ")", ":", "for", "d", "in", "dirs", ":", "contents", "=", "ls", "(", "d", ")", "for", "t", "in", "contents", ":", "first", "=", "join", "(", "d", ...
Call this to load resources from each dir in @dirs. Code resources will receive @callwith as an argument.
[ "Call", "this", "to", "load", "resources", "from", "each", "dir", "in" ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L215-L242
pydsigner/pygu
pygu/pyramid.py
Resources.set_music
def set_music(self, plylst, force=False): ''' Use to set the playlist to @plylst. If @force is False, the playlist will not be set if it is @plylst already. ''' plylst = plylst.lower() if plylst != self.cur_playlist or force: self.cur_playlist = plylst ...
python
def set_music(self, plylst, force=False): ''' Use to set the playlist to @plylst. If @force is False, the playlist will not be set if it is @plylst already. ''' plylst = plylst.lower() if plylst != self.cur_playlist or force: self.cur_playlist = plylst ...
[ "def", "set_music", "(", "self", ",", "plylst", ",", "force", "=", "False", ")", ":", "plylst", "=", "plylst", ".", "lower", "(", ")", "if", "plylst", "!=", "self", ".", "cur_playlist", "or", "force", ":", "self", ".", "cur_playlist", "=", "plylst", ...
Use to set the playlist to @plylst. If @force is False, the playlist will not be set if it is @plylst already.
[ "Use", "to", "set", "the", "playlist", "to" ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L248-L256
pydsigner/pygu
pygu/pyramid.py
Resources.set_m_vol
def set_m_vol(self, vol=None, relative=False): ''' Set the music volume. If @vol != None, It will be changed to it (or by it, if @relative is True.) ''' if vol != None: if relative: vol += self.m_vol self.m_vol = min(max(vol, 0), 1) ...
python
def set_m_vol(self, vol=None, relative=False): ''' Set the music volume. If @vol != None, It will be changed to it (or by it, if @relative is True.) ''' if vol != None: if relative: vol += self.m_vol self.m_vol = min(max(vol, 0), 1) ...
[ "def", "set_m_vol", "(", "self", ",", "vol", "=", "None", ",", "relative", "=", "False", ")", ":", "if", "vol", "!=", "None", ":", "if", "relative", ":", "vol", "+=", "self", ".", "m_vol", "self", ".", "m_vol", "=", "min", "(", "max", "(", "vol",...
Set the music volume. If @vol != None, It will be changed to it (or by it, if @relative is True.)
[ "Set", "the", "music", "volume", ".", "If" ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L274-L283
pydsigner/pygu
pygu/pyramid.py
Resources.set_s_vol
def set_s_vol(self, vol=None, relative=False): ''' Set the volume of all sounds. If @vol != None, It will be changed to it (or by it, if @relative is True.) ''' if vol != None: if relative: vol += self.s_vol self.s_vol = min(max(vol, 0), 1...
python
def set_s_vol(self, vol=None, relative=False): ''' Set the volume of all sounds. If @vol != None, It will be changed to it (or by it, if @relative is True.) ''' if vol != None: if relative: vol += self.s_vol self.s_vol = min(max(vol, 0), 1...
[ "def", "set_s_vol", "(", "self", ",", "vol", "=", "None", ",", "relative", "=", "False", ")", ":", "if", "vol", "!=", "None", ":", "if", "relative", ":", "vol", "+=", "self", ".", "s_vol", "self", ".", "s_vol", "=", "min", "(", "max", "(", "vol",...
Set the volume of all sounds. If @vol != None, It will be changed to it (or by it, if @relative is True.)
[ "Set", "the", "volume", "of", "all", "sounds", ".", "If" ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L285-L296
pydsigner/pygu
pygu/pyramid.py
Resources.get_sound
def get_sound(self, title, group): ''' Retrieve sound @title from group @group. ''' return self.sounds[group.lower()][title.lower()]
python
def get_sound(self, title, group): ''' Retrieve sound @title from group @group. ''' return self.sounds[group.lower()][title.lower()]
[ "def", "get_sound", "(", "self", ",", "title", ",", "group", ")", ":", "return", "self", ".", "sounds", "[", "group", ".", "lower", "(", ")", "]", "[", "title", ".", "lower", "(", ")", "]" ]
Retrieve sound @title from group @group.
[ "Retrieve", "sound" ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L300-L304
pydsigner/pygu
pygu/pyramid.py
Resources.get_image
def get_image(self, title, group): ''' Retrieve image @title from group @group. ''' return self.images[group.lower()][title.lower()]
python
def get_image(self, title, group): ''' Retrieve image @title from group @group. ''' return self.images[group.lower()][title.lower()]
[ "def", "get_image", "(", "self", ",", "title", ",", "group", ")", ":", "return", "self", ".", "images", "[", "group", ".", "lower", "(", ")", "]", "[", "title", ".", "lower", "(", ")", "]" ]
Retrieve image @title from group @group.
[ "Retrieve", "image" ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L305-L309
pydsigner/pygu
pygu/pyramid.py
Resources.get_channel
def get_channel(self): ''' Used internally when playing sounds. ''' c = pygame.mixer.find_channel(not self.dynamic) while c is None: self.channels += 1 pygame.mixer.set_num_channels(self.channels) c = pygame.mixer.find_channel() return ...
python
def get_channel(self): ''' Used internally when playing sounds. ''' c = pygame.mixer.find_channel(not self.dynamic) while c is None: self.channels += 1 pygame.mixer.set_num_channels(self.channels) c = pygame.mixer.find_channel() return ...
[ "def", "get_channel", "(", "self", ")", ":", "c", "=", "pygame", ".", "mixer", ".", "find_channel", "(", "not", "self", ".", "dynamic", ")", "while", "c", "is", "None", ":", "self", ".", "channels", "+=", "1", "pygame", ".", "mixer", ".", "set_num_ch...
Used internally when playing sounds.
[ "Used", "internally", "when", "playing", "sounds", "." ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L316-L325
pydsigner/pygu
pygu/pyramid.py
EventManager.bind
def bind(self, func, etype): ''' Register @func for execution when events with `.type` of @etype or meta-events with `.utype` of @etype are handled. @func will be called with self, self.gstate, and the event as arguments. ''' self.event_funcs.setdefault(etype, []) ...
python
def bind(self, func, etype): ''' Register @func for execution when events with `.type` of @etype or meta-events with `.utype` of @etype are handled. @func will be called with self, self.gstate, and the event as arguments. ''' self.event_funcs.setdefault(etype, []) ...
[ "def", "bind", "(", "self", ",", "func", ",", "etype", ")", ":", "self", ".", "event_funcs", ".", "setdefault", "(", "etype", ",", "[", "]", ")", "# Don't add multiple times!", "if", "func", "not", "in", "self", ".", "event_funcs", "[", "etype", "]", "...
Register @func for execution when events with `.type` of @etype or meta-events with `.utype` of @etype are handled. @func will be called with self, self.gstate, and the event as arguments.
[ "Register" ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L391-L400
pydsigner/pygu
pygu/pyramid.py
EventManager.unbind
def unbind(self, func, etype): ''' Remove @func from the execution list for events with `.type` of @etype or meta-events with `.utype` of @etype. If @func is not in said list, a ValueError will be raised. ''' i= self.event_funcs[etype].index(func) del self.event...
python
def unbind(self, func, etype): ''' Remove @func from the execution list for events with `.type` of @etype or meta-events with `.utype` of @etype. If @func is not in said list, a ValueError will be raised. ''' i= self.event_funcs[etype].index(func) del self.event...
[ "def", "unbind", "(", "self", ",", "func", ",", "etype", ")", ":", "i", "=", "self", ".", "event_funcs", "[", "etype", "]", ".", "index", "(", "func", ")", "del", "self", ".", "event_funcs", "[", "etype", "]", "[", "i", "]" ]
Remove @func from the execution list for events with `.type` of @etype or meta-events with `.utype` of @etype. If @func is not in said list, a ValueError will be raised.
[ "Remove" ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L402-L409
pydsigner/pygu
pygu/pyramid.py
EventManager.event
def event(self, utype, **kw): ''' Make a meta-event with a utype of @type. **@kw works the same as for pygame.event.Event(). ''' d = {'utype': utype} d.update(kw) pygame.event.post(pygame.event.Event(METAEVENT, d))
python
def event(self, utype, **kw): ''' Make a meta-event with a utype of @type. **@kw works the same as for pygame.event.Event(). ''' d = {'utype': utype} d.update(kw) pygame.event.post(pygame.event.Event(METAEVENT, d))
[ "def", "event", "(", "self", ",", "utype", ",", "*", "*", "kw", ")", ":", "d", "=", "{", "'utype'", ":", "utype", "}", "d", ".", "update", "(", "kw", ")", "pygame", ".", "event", ".", "post", "(", "pygame", ".", "event", ".", "Event", "(", "M...
Make a meta-event with a utype of @type. **@kw works the same as for pygame.event.Event().
[ "Make", "a", "meta", "-", "event", "with", "a", "utype", "of" ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L431-L438
pydsigner/pygu
pygu/pyramid.py
EventManager.loop
def loop(self, events=[]): ''' Run the loop. ''' try: for e in events: if e.type == METAEVENT: e = self.MetaEvent(e) for func in self.event_funcs.get(e.type, []): func(self, self.gstate, e) except...
python
def loop(self, events=[]): ''' Run the loop. ''' try: for e in events: if e.type == METAEVENT: e = self.MetaEvent(e) for func in self.event_funcs.get(e.type, []): func(self, self.gstate, e) except...
[ "def", "loop", "(", "self", ",", "events", "=", "[", "]", ")", ":", "try", ":", "for", "e", "in", "events", ":", "if", "e", ".", "type", "==", "METAEVENT", ":", "e", "=", "self", ".", "MetaEvent", "(", "e", ")", "for", "func", "in", "self", "...
Run the loop.
[ "Run", "the", "loop", "." ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L442-L453
pydsigner/pygu
pygu/pyramid.py
StateManager.add_states
def add_states(self, *states): ''' Add @states. ''' for state in states: self.states[state] = EventManagerPlus(self)
python
def add_states(self, *states): ''' Add @states. ''' for state in states: self.states[state] = EventManagerPlus(self)
[ "def", "add_states", "(", "self", ",", "*", "states", ")", ":", "for", "state", "in", "states", ":", "self", ".", "states", "[", "state", "]", "=", "EventManagerPlus", "(", "self", ")" ]
Add @states.
[ "Add" ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pyramid.py#L562-L567
edeposit/edeposit.amqp.ftp
src/edeposit/amqp/ftp/__init__.py
reactToAMQPMessage
def reactToAMQPMessage(message, send_back): """ React to given (AMQP) message. `message` is expected to be :py:func:`collections.namedtuple` structure from :mod:`.structures` filled with all necessary data. Args: message (object): One of the request objects defined in ...
python
def reactToAMQPMessage(message, send_back): """ React to given (AMQP) message. `message` is expected to be :py:func:`collections.namedtuple` structure from :mod:`.structures` filled with all necessary data. Args: message (object): One of the request objects defined in ...
[ "def", "reactToAMQPMessage", "(", "message", ",", "send_back", ")", ":", "if", "_instanceof", "(", "message", ",", "structures", ".", "AddUser", ")", ":", "api", ".", "add_user", "(", "username", "=", "message", ".", "username", ",", "password", "=", "mess...
React to given (AMQP) message. `message` is expected to be :py:func:`collections.namedtuple` structure from :mod:`.structures` filled with all necessary data. Args: message (object): One of the request objects defined in :mod:`.structures`. send_back (fn reference)...
[ "React", "to", "given", "(", "AMQP", ")", "message", ".", "message", "is", "expected", "to", "be", ":", "py", ":", "func", ":", "collections", ".", "namedtuple", "structure", "from", ":", "mod", ":", ".", "structures", "filled", "with", "all", "necessary...
train
https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/__init__.py#L62-L121
johnwlockwood/cooperative
cooperative/__init__.py
accumulate
def accumulate(a_generator, cooperator=None): """ Start a Deferred whose callBack arg is a deque of the accumulation of the values yielded from a_generator. :param a_generator: An iterator which yields some not None values. :return: A Deferred to which the next callback will be called with the...
python
def accumulate(a_generator, cooperator=None): """ Start a Deferred whose callBack arg is a deque of the accumulation of the values yielded from a_generator. :param a_generator: An iterator which yields some not None values. :return: A Deferred to which the next callback will be called with the...
[ "def", "accumulate", "(", "a_generator", ",", "cooperator", "=", "None", ")", ":", "if", "cooperator", ":", "own_cooperate", "=", "cooperator", ".", "cooperate", "else", ":", "own_cooperate", "=", "cooperate", "spigot", "=", "ValueBucket", "(", ")", "items", ...
Start a Deferred whose callBack arg is a deque of the accumulation of the values yielded from a_generator. :param a_generator: An iterator which yields some not None values. :return: A Deferred to which the next callback will be called with the yielded contents of the generator function.
[ "Start", "a", "Deferred", "whose", "callBack", "arg", "is", "a", "deque", "of", "the", "accumulation", "of", "the", "values", "yielded", "from", "a_generator", "." ]
train
https://github.com/johnwlockwood/cooperative/blob/bec25451a6d2b06260be809b72cfd6287c75da39/cooperative/__init__.py#L59-L77
johnwlockwood/cooperative
cooperative/__init__.py
batch_accumulate
def batch_accumulate(max_batch_size, a_generator, cooperator=None): """ Start a Deferred whose callBack arg is a deque of the accumulation of the values yielded from a_generator which is iterated over in batches the size of max_batch_size. It should be more efficient to iterate over the generator i...
python
def batch_accumulate(max_batch_size, a_generator, cooperator=None): """ Start a Deferred whose callBack arg is a deque of the accumulation of the values yielded from a_generator which is iterated over in batches the size of max_batch_size. It should be more efficient to iterate over the generator i...
[ "def", "batch_accumulate", "(", "max_batch_size", ",", "a_generator", ",", "cooperator", "=", "None", ")", ":", "if", "cooperator", ":", "own_cooperate", "=", "cooperator", ".", "cooperate", "else", ":", "own_cooperate", "=", "cooperate", "spigot", "=", "ValueBu...
Start a Deferred whose callBack arg is a deque of the accumulation of the values yielded from a_generator which is iterated over in batches the size of max_batch_size. It should be more efficient to iterate over the generator in batches and still provide enough speed for non-blocking execution. :...
[ "Start", "a", "Deferred", "whose", "callBack", "arg", "is", "a", "deque", "of", "the", "accumulation", "of", "the", "values", "yielded", "from", "a_generator", "which", "is", "iterated", "over", "in", "batches", "the", "size", "of", "max_batch_size", "." ]
train
https://github.com/johnwlockwood/cooperative/blob/bec25451a6d2b06260be809b72cfd6287c75da39/cooperative/__init__.py#L80-L105
alexpearce/jobmonitor
jobmonitor/start_worker.py
create_connection
def create_connection(): """Return a redis.Redis instance connected to REDIS_URL.""" # REDIS_URL is defined in .env and loaded into the environment by Honcho redis_url = os.getenv('REDIS_URL') # If it's not defined, use the Redis default if not redis_url: redis_url = 'redis://localhost:6379'...
python
def create_connection(): """Return a redis.Redis instance connected to REDIS_URL.""" # REDIS_URL is defined in .env and loaded into the environment by Honcho redis_url = os.getenv('REDIS_URL') # If it's not defined, use the Redis default if not redis_url: redis_url = 'redis://localhost:6379'...
[ "def", "create_connection", "(", ")", ":", "# REDIS_URL is defined in .env and loaded into the environment by Honcho", "redis_url", "=", "os", ".", "getenv", "(", "'REDIS_URL'", ")", "# If it's not defined, use the Redis default", "if", "not", "redis_url", ":", "redis_url", "...
Return a redis.Redis instance connected to REDIS_URL.
[ "Return", "a", "redis", ".", "Redis", "instance", "connected", "to", "REDIS_URL", "." ]
train
https://github.com/alexpearce/jobmonitor/blob/c08955ed3c357b2b3518aa0853b43bc237bc0814/jobmonitor/start_worker.py#L16-L30
alexpearce/jobmonitor
jobmonitor/start_worker.py
work
def work(): """Start an rq worker on the connection provided by create_connection.""" with rq.Connection(create_connection()): worker = rq.Worker(list(map(rq.Queue, listen))) worker.work()
python
def work(): """Start an rq worker on the connection provided by create_connection.""" with rq.Connection(create_connection()): worker = rq.Worker(list(map(rq.Queue, listen))) worker.work()
[ "def", "work", "(", ")", ":", "with", "rq", ".", "Connection", "(", "create_connection", "(", ")", ")", ":", "worker", "=", "rq", ".", "Worker", "(", "list", "(", "map", "(", "rq", ".", "Queue", ",", "listen", ")", ")", ")", "worker", ".", "work"...
Start an rq worker on the connection provided by create_connection.
[ "Start", "an", "rq", "worker", "on", "the", "connection", "provided", "by", "create_connection", "." ]
train
https://github.com/alexpearce/jobmonitor/blob/c08955ed3c357b2b3518aa0853b43bc237bc0814/jobmonitor/start_worker.py#L33-L37
sassoo/goldman
goldman/types/phonenumber.py
Type.to_native
def to_native(self, value, context=None): """ Schematics deserializer override We return a phoenumbers.PhoneNumber object so any kind of formatting can be trivially performed. Additionally, some convenient properties have been added: e164: string formatted '+11234567890' ...
python
def to_native(self, value, context=None): """ Schematics deserializer override We return a phoenumbers.PhoneNumber object so any kind of formatting can be trivially performed. Additionally, some convenient properties have been added: e164: string formatted '+11234567890' ...
[ "def", "to_native", "(", "self", ",", "value", ",", "context", "=", "None", ")", ":", "if", "isinstance", "(", "value", ",", "pn", ".", "phonenumber", ".", "PhoneNumber", ")", ":", "return", "value", "try", ":", "phone", "=", "pn", ".", "parse", "(",...
Schematics deserializer override We return a phoenumbers.PhoneNumber object so any kind of formatting can be trivially performed. Additionally, some convenient properties have been added: e164: string formatted '+11234567890' pretty: string formatted '(123) 456-7890' ...
[ "Schematics", "deserializer", "override" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/types/phonenumber.py#L23-L53
pydsigner/pygu
pygu/pms.py
Playlist._gen_shuffles
def _gen_shuffles(self): ''' Used internally to build a list for mapping between a random number and a song index. ''' # The current metasong index si = 0 # The shuffle mapper list self.shuffles = [] # Go through all our songs... for song...
python
def _gen_shuffles(self): ''' Used internally to build a list for mapping between a random number and a song index. ''' # The current metasong index si = 0 # The shuffle mapper list self.shuffles = [] # Go through all our songs... for song...
[ "def", "_gen_shuffles", "(", "self", ")", ":", "# The current metasong index ", "si", "=", "0", "# The shuffle mapper list", "self", ".", "shuffles", "=", "[", "]", "# Go through all our songs...", "for", "song", "in", "self", ".", "loop", ":", "# And add them to th...
Used internally to build a list for mapping between a random number and a song index.
[ "Used", "internally", "to", "build", "a", "list", "for", "mapping", "between", "a", "random", "number", "and", "a", "song", "index", "." ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pms.py#L109-L123
pydsigner/pygu
pygu/pms.py
Playlist._new_song
def _new_song(self): ''' Used internally to get a metasong index. ''' # We'll need this later s = self.song if self.shuffle: # If shuffle is on, we need to (1) get a random song that # (2) accounts for weighting. This line does both. ...
python
def _new_song(self): ''' Used internally to get a metasong index. ''' # We'll need this later s = self.song if self.shuffle: # If shuffle is on, we need to (1) get a random song that # (2) accounts for weighting. This line does both. ...
[ "def", "_new_song", "(", "self", ")", ":", "# We'll need this later", "s", "=", "self", ".", "song", "if", "self", ".", "shuffle", ":", "# If shuffle is on, we need to (1) get a random song that ", "# (2) accounts for weighting. This line does both.", "self", ".", "song", ...
Used internally to get a metasong index.
[ "Used", "internally", "to", "get", "a", "metasong", "index", "." ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pms.py#L125-L146
pydsigner/pygu
pygu/pms.py
Playlist._get_selectable
def _get_selectable(self): ''' Used internally to get a group of choosable tracks. ''' # Save some typing cursong = self.loop[self.song][0] if self.dif_song and len(cursong) > 1: # Position is relative to the intro of the track, # so we we...
python
def _get_selectable(self): ''' Used internally to get a group of choosable tracks. ''' # Save some typing cursong = self.loop[self.song][0] if self.dif_song and len(cursong) > 1: # Position is relative to the intro of the track, # so we we...
[ "def", "_get_selectable", "(", "self", ")", ":", "# Save some typing", "cursong", "=", "self", ".", "loop", "[", "self", ".", "song", "]", "[", "0", "]", "if", "self", ".", "dif_song", "and", "len", "(", "cursong", ")", ">", "1", ":", "# Position is re...
Used internally to get a group of choosable tracks.
[ "Used", "internally", "to", "get", "a", "group", "of", "choosable", "tracks", "." ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pms.py#L148-L163
pydsigner/pygu
pygu/pms.py
Playlist._get_song
def _get_song(self): ''' Used internally to get the current track and make sure it exists. ''' # Try to get the current track from the start metasong if self.at_beginning: # Make sure it exists. if self.pos < len(self.start): # It exists, s...
python
def _get_song(self): ''' Used internally to get the current track and make sure it exists. ''' # Try to get the current track from the start metasong if self.at_beginning: # Make sure it exists. if self.pos < len(self.start): # It exists, s...
[ "def", "_get_song", "(", "self", ")", ":", "# Try to get the current track from the start metasong", "if", "self", ".", "at_beginning", ":", "# Make sure it exists.", "if", "self", ".", "pos", "<", "len", "(", "self", ".", "start", ")", ":", "# It exists, so return ...
Used internally to get the current track and make sure it exists.
[ "Used", "internally", "to", "get", "the", "current", "track", "and", "make", "sure", "it", "exists", "." ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pms.py#L165-L190
pydsigner/pygu
pygu/pms.py
Playlist.begin
def begin(self): ''' Start over and get a track. ''' # Check for a start metasong if self.start: # We are in the beginning song self.at_beginning = True # And on the first track. self.pos = 0 else: # We aren't in...
python
def begin(self): ''' Start over and get a track. ''' # Check for a start metasong if self.start: # We are in the beginning song self.at_beginning = True # And on the first track. self.pos = 0 else: # We aren't in...
[ "def", "begin", "(", "self", ")", ":", "# Check for a start metasong", "if", "self", ".", "start", ":", "# We are in the beginning song", "self", ".", "at_beginning", "=", "True", "# And on the first track.", "self", ".", "pos", "=", "0", "else", ":", "# We aren't...
Start over and get a track.
[ "Start", "over", "and", "get", "a", "track", "." ]
train
https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pms.py#L192-L207
Nixiware/viper
nx/viper/service/mysql.py
Service._applicationStart
def _applicationStart(self, data): """ Initializes the database connection pool. :param data: <object> event data object :return: <void> """ checkup = False if "viper.mysql" in self.application.config \ and isinstance(self.application.config["vipe...
python
def _applicationStart(self, data): """ Initializes the database connection pool. :param data: <object> event data object :return: <void> """ checkup = False if "viper.mysql" in self.application.config \ and isinstance(self.application.config["vipe...
[ "def", "_applicationStart", "(", "self", ",", "data", ")", ":", "checkup", "=", "False", "if", "\"viper.mysql\"", "in", "self", ".", "application", ".", "config", "and", "isinstance", "(", "self", ".", "application", ".", "config", "[", "\"viper.mysql\"", "]...
Initializes the database connection pool. :param data: <object> event data object :return: <void>
[ "Initializes", "the", "database", "connection", "pool", "." ]
train
https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/service/mysql.py#L27-L82
Nixiware/viper
nx/viper/service/mysql.py
Service._checkIfDatabaseIsEmpty
def _checkIfDatabaseIsEmpty(self, successHandler=None, failHandler=None): """ Check if database contains any tables. :param successHandler: <function(<bool>)> method called if interrogation was successful where the first argument is a boolean flag specifying if t...
python
def _checkIfDatabaseIsEmpty(self, successHandler=None, failHandler=None): """ Check if database contains any tables. :param successHandler: <function(<bool>)> method called if interrogation was successful where the first argument is a boolean flag specifying if t...
[ "def", "_checkIfDatabaseIsEmpty", "(", "self", ",", "successHandler", "=", "None", ",", "failHandler", "=", "None", ")", ":", "def", "failCallback", "(", "error", ")", ":", "errorMessage", "=", "str", "(", "error", ")", "if", "isinstance", "(", "error", ",...
Check if database contains any tables. :param successHandler: <function(<bool>)> method called if interrogation was successful where the first argument is a boolean flag specifying if the database is empty or not :param failHandler: <function(<str>)> method called if int...
[ "Check", "if", "database", "contains", "any", "tables", "." ]
train
https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/service/mysql.py#L84-L125
Nixiware/viper
nx/viper/service/mysql.py
Service._initDatabase
def _initDatabase(self): """ Initializes the database structure based on application configuration. :return: <void> """ queries = [] if len(self.application.config["viper.mysql"]["init"]["scripts"]) > 0: for scriptFilePath in self.application.config["viper.m...
python
def _initDatabase(self): """ Initializes the database structure based on application configuration. :return: <void> """ queries = [] if len(self.application.config["viper.mysql"]["init"]["scripts"]) > 0: for scriptFilePath in self.application.config["viper.m...
[ "def", "_initDatabase", "(", "self", ")", ":", "queries", "=", "[", "]", "if", "len", "(", "self", ".", "application", ".", "config", "[", "\"viper.mysql\"", "]", "[", "\"init\"", "]", "[", "\"scripts\"", "]", ")", ">", "0", ":", "for", "scriptFilePath...
Initializes the database structure based on application configuration. :return: <void>
[ "Initializes", "the", "database", "structure", "based", "on", "application", "configuration", "." ]
train
https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/service/mysql.py#L127-L162
Nixiware/viper
nx/viper/service/mysql.py
Service.extractFromSQLFile
def extractFromSQLFile(self, filePointer, delimiter=";"): """ Process an SQL file and extract all the queries sorted. :param filePointer: <io.TextIOWrapper> file pointer to SQL file :return: <list> list of queries """ data = filePointer.read() # reading file and...
python
def extractFromSQLFile(self, filePointer, delimiter=";"): """ Process an SQL file and extract all the queries sorted. :param filePointer: <io.TextIOWrapper> file pointer to SQL file :return: <list> list of queries """ data = filePointer.read() # reading file and...
[ "def", "extractFromSQLFile", "(", "self", ",", "filePointer", ",", "delimiter", "=", "\";\"", ")", ":", "data", "=", "filePointer", ".", "read", "(", ")", "# reading file and splitting it into lines", "dataLines", "=", "[", "]", "dataLinesIndex", "=", "0", "for"...
Process an SQL file and extract all the queries sorted. :param filePointer: <io.TextIOWrapper> file pointer to SQL file :return: <list> list of queries
[ "Process", "an", "SQL", "file", "and", "extract", "all", "the", "queries", "sorted", "." ]
train
https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/service/mysql.py#L174-L226
Nixiware/viper
nx/viper/service/mysql.py
Service.runInteraction
def runInteraction(self, interaction, *args, **kwargs): """ Interact with the database and return the result. :param interaction: <function> method with first argument is a <adbapi.Transaction> instance :param args: additional positional arguments to be passed to interaction :pa...
python
def runInteraction(self, interaction, *args, **kwargs): """ Interact with the database and return the result. :param interaction: <function> method with first argument is a <adbapi.Transaction> instance :param args: additional positional arguments to be passed to interaction :pa...
[ "def", "runInteraction", "(", "self", ",", "interaction", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "self", ".", "_connectionPool", ".", "runInteraction", "(", "interaction", ",", "*", "args", ",", "*", "*", "kwargs", "...
Interact with the database and return the result. :param interaction: <function> method with first argument is a <adbapi.Transaction> instance :param args: additional positional arguments to be passed to interaction :param kwargs: keyword arguments to be passed to interaction :return: <...
[ "Interact", "with", "the", "database", "and", "return", "the", "result", "." ]
train
https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/service/mysql.py#L228-L246
Nixiware/viper
nx/viper/service/mysql.py
Service.runQuery
def runQuery(self, *args, **kwargs): """ Execute an SQL query and return the result. :param args: additional positional arguments to be passed to cursor execute method :param kwargs: keyword arguments to be passed to cursor execute method :return: <defer> """ try...
python
def runQuery(self, *args, **kwargs): """ Execute an SQL query and return the result. :param args: additional positional arguments to be passed to cursor execute method :param kwargs: keyword arguments to be passed to cursor execute method :return: <defer> """ try...
[ "def", "runQuery", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "self", ".", "_connectionPool", ".", "runQuery", "(", "*", "args", ",", "*", "*", "kwargs", ")", "except", ":", "d", "=", "defer", ".", "De...
Execute an SQL query and return the result. :param args: additional positional arguments to be passed to cursor execute method :param kwargs: keyword arguments to be passed to cursor execute method :return: <defer>
[ "Execute", "an", "SQL", "query", "and", "return", "the", "result", "." ]
train
https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/service/mysql.py#L248-L261
glue-viz/echo
echo/qt/autoconnect.py
autoconnect_callbacks_to_qt
def autoconnect_callbacks_to_qt(instance, widget, connect_kwargs={}): """ Given a class instance with callback properties and a Qt widget/window, connect callback properties to Qt widgets automatically. The matching is done based on the objectName of the Qt widgets. Qt widgets that need to be conne...
python
def autoconnect_callbacks_to_qt(instance, widget, connect_kwargs={}): """ Given a class instance with callback properties and a Qt widget/window, connect callback properties to Qt widgets automatically. The matching is done based on the objectName of the Qt widgets. Qt widgets that need to be conne...
[ "def", "autoconnect_callbacks_to_qt", "(", "instance", ",", "widget", ",", "connect_kwargs", "=", "{", "}", ")", ":", "if", "not", "hasattr", "(", "widget", ",", "'children'", ")", ":", "return", "for", "child", "in", "widget", ".", "findChildren", "(", "Q...
Given a class instance with callback properties and a Qt widget/window, connect callback properties to Qt widgets automatically. The matching is done based on the objectName of the Qt widgets. Qt widgets that need to be connected should be named using the syntax ``type_name`` where ``type`` describes t...
[ "Given", "a", "class", "instance", "with", "callback", "properties", "and", "a", "Qt", "widget", "/", "window", "connect", "callback", "properties", "to", "Qt", "widgets", "automatically", "." ]
train
https://github.com/glue-viz/echo/blob/6ad54cc5e869de27c34e8716f2619ddc640f08fe/echo/qt/autoconnect.py#L27-L105
twidi/py-dataql
dataql/solvers/resources.py
Solver.solve
def solve(self, value, resource): """Solve a resource with a value. Arguments --------- value : ? A value to solve in combination with the given resource. The first filter of the resource will be applied on this value (next filters on the result of the previous ...
python
def solve(self, value, resource): """Solve a resource with a value. Arguments --------- value : ? A value to solve in combination with the given resource. The first filter of the resource will be applied on this value (next filters on the result of the previous ...
[ "def", "solve", "(", "self", ",", "value", ",", "resource", ")", ":", "result", "=", "self", ".", "solve_value", "(", "value", ",", "resource", ")", "return", "self", ".", "coerce", "(", "result", ",", "resource", ")" ]
Solve a resource with a value. Arguments --------- value : ? A value to solve in combination with the given resource. The first filter of the resource will be applied on this value (next filters on the result of the previous filter). resource : dataql...
[ "Solve", "a", "resource", "with", "a", "value", "." ]
train
https://github.com/twidi/py-dataql/blob/5841a3fd559829193ed709c255166085bdde1c52/dataql/solvers/resources.py#L80-L110
twidi/py-dataql
dataql/solvers/resources.py
Solver.solve_value
def solve_value(self, value, resource): """Solve a resource with a value, without coercing. Arguments --------- value : ? A value to solve in combination with the given resource. The first filter of the resource will be applied on this value (next filters on the ...
python
def solve_value(self, value, resource): """Solve a resource with a value, without coercing. Arguments --------- value : ? A value to solve in combination with the given resource. The first filter of the resource will be applied on this value (next filters on the ...
[ "def", "solve_value", "(", "self", ",", "value", ",", "resource", ")", ":", "# The given value is the starting point on which we apply the first filter.", "result", "=", "value", "# Apply filters one by one on the previous result.", "if", "result", "is", "not", "None", ":", ...
Solve a resource with a value, without coercing. Arguments --------- value : ? A value to solve in combination with the given resource. The first filter of the resource will be applied on this value (next filters on the result of the previous filter). ...
[ "Solve", "a", "resource", "with", "a", "value", "without", "coercing", "." ]
train
https://github.com/twidi/py-dataql/blob/5841a3fd559829193ed709c255166085bdde1c52/dataql/solvers/resources.py#L112-L192
twidi/py-dataql
dataql/solvers/resources.py
Solver.can_solve
def can_solve(cls, resource): """Tells if the solver is able to resolve the given resource. Arguments --------- resource : subclass of ``dataql.resources.Resource`` The resource to check if it is solvable by the current solver class Returns ------- b...
python
def can_solve(cls, resource): """Tells if the solver is able to resolve the given resource. Arguments --------- resource : subclass of ``dataql.resources.Resource`` The resource to check if it is solvable by the current solver class Returns ------- b...
[ "def", "can_solve", "(", "cls", ",", "resource", ")", ":", "for", "solvable_resource", "in", "cls", ".", "solvable_resources", ":", "if", "isinstance", "(", "resource", ",", "solvable_resource", ")", ":", "return", "True", "return", "False" ]
Tells if the solver is able to resolve the given resource. Arguments --------- resource : subclass of ``dataql.resources.Resource`` The resource to check if it is solvable by the current solver class Returns ------- boolean ``True`` if the curren...
[ "Tells", "if", "the", "solver", "is", "able", "to", "resolve", "the", "given", "resource", "." ]
train
https://github.com/twidi/py-dataql/blob/5841a3fd559829193ed709c255166085bdde1c52/dataql/solvers/resources.py#L205-L233
twidi/py-dataql
dataql/solvers/resources.py
AttributeSolver.coerce
def coerce(self, value, resource): """Coerce the value to an acceptable one. Only these kinds of values are returned as is: - str - int - float - True - False - None For all others values, it will be coerced using ``self.coerce_default`` (with co...
python
def coerce(self, value, resource): """Coerce the value to an acceptable one. Only these kinds of values are returned as is: - str - int - float - True - False - None For all others values, it will be coerced using ``self.coerce_default`` (with co...
[ "def", "coerce", "(", "self", ",", "value", ",", "resource", ")", ":", "if", "value", "in", "(", "True", ",", "False", ",", "None", ")", ":", "return", "value", "if", "isinstance", "(", "value", ",", "(", "int", ",", "float", ")", ")", ":", "retu...
Coerce the value to an acceptable one. Only these kinds of values are returned as is: - str - int - float - True - False - None For all others values, it will be coerced using ``self.coerce_default`` (with convert the value to a string in the def...
[ "Coerce", "the", "value", "to", "an", "acceptable", "one", "." ]
train
https://github.com/twidi/py-dataql/blob/5841a3fd559829193ed709c255166085bdde1c52/dataql/solvers/resources.py#L261-L316
twidi/py-dataql
dataql/solvers/resources.py
ObjectSolver.coerce
def coerce(self, value, resource): """Get a dict with attributes from ``value``. Arguments --------- value : ? The value to get some resources from. resource : dataql.resources.Object The ``Object`` object used to obtain this value from the original one. ...
python
def coerce(self, value, resource): """Get a dict with attributes from ``value``. Arguments --------- value : ? The value to get some resources from. resource : dataql.resources.Object The ``Object`` object used to obtain this value from the original one. ...
[ "def", "coerce", "(", "self", ",", "value", ",", "resource", ")", ":", "return", "{", "r", ".", "name", ":", "self", ".", "registry", ".", "solve_resource", "(", "value", ",", "r", ")", "for", "r", "in", "resource", ".", "resources", "}" ]
Get a dict with attributes from ``value``. Arguments --------- value : ? The value to get some resources from. resource : dataql.resources.Object The ``Object`` object used to obtain this value from the original one. Returns ------- dict ...
[ "Get", "a", "dict", "with", "attributes", "from", "value", "." ]
train
https://github.com/twidi/py-dataql/blob/5841a3fd559829193ed709c255166085bdde1c52/dataql/solvers/resources.py#L382-L400
twidi/py-dataql
dataql/solvers/resources.py
ListSolver.coerce
def coerce(self, value, resource): """Convert a list of objects in a list of dicts. Arguments --------- value : iterable The list (or other iterable) to get values to get some resources from. resource : dataql.resources.List The ``List`` object used to ob...
python
def coerce(self, value, resource): """Convert a list of objects in a list of dicts. Arguments --------- value : iterable The list (or other iterable) to get values to get some resources from. resource : dataql.resources.List The ``List`` object used to ob...
[ "def", "coerce", "(", "self", ",", "value", ",", "resource", ")", ":", "if", "not", "isinstance", "(", "value", ",", "Iterable", ")", ":", "raise", "NotIterable", "(", "resource", ",", "self", ".", "registry", "[", "value", "]", ")", "# Case #1: we only ...
Convert a list of objects in a list of dicts. Arguments --------- value : iterable The list (or other iterable) to get values to get some resources from. resource : dataql.resources.List The ``List`` object used to obtain this value from the original one. ...
[ "Convert", "a", "list", "of", "objects", "in", "a", "list", "of", "dicts", "." ]
train
https://github.com/twidi/py-dataql/blob/5841a3fd559829193ed709c255166085bdde1c52/dataql/solvers/resources.py#L469-L509
rikrd/inspire
inspirespeech/common.py
create_recordings_dictionary
def create_recordings_dictionary(list_selected, pronunciation_dictionary_filename, out_dictionary_filename, htk_trace, additional_dictionary_filenames=[]): """Create a pronunciation dictionary specific to a list of recordings""" temp_words_fd, temp_words_file = tempfile.mkstemp(...
python
def create_recordings_dictionary(list_selected, pronunciation_dictionary_filename, out_dictionary_filename, htk_trace, additional_dictionary_filenames=[]): """Create a pronunciation dictionary specific to a list of recordings""" temp_words_fd, temp_words_file = tempfile.mkstemp(...
[ "def", "create_recordings_dictionary", "(", "list_selected", ",", "pronunciation_dictionary_filename", ",", "out_dictionary_filename", ",", "htk_trace", ",", "additional_dictionary_filenames", "=", "[", "]", ")", ":", "temp_words_fd", ",", "temp_words_file", "=", "tempfile"...
Create a pronunciation dictionary specific to a list of recordings
[ "Create", "a", "pronunciation", "dictionary", "specific", "to", "a", "list", "of", "recordings" ]
train
https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/common.py#L197-L218
rikrd/inspire
inspirespeech/common.py
utf8_normalize
def utf8_normalize(input_filename, comment_char='#', to_upper=False): """Normalize UTF-8 characters of a file """ # Prepare the input dictionary file in UTF-8 and NFC temp_dict_fd, output_filename = tempfile.mkstemp() logging.debug('to_nfc from file {} to file {}'.format(input_filename, output_file...
python
def utf8_normalize(input_filename, comment_char='#', to_upper=False): """Normalize UTF-8 characters of a file """ # Prepare the input dictionary file in UTF-8 and NFC temp_dict_fd, output_filename = tempfile.mkstemp() logging.debug('to_nfc from file {} to file {}'.format(input_filename, output_file...
[ "def", "utf8_normalize", "(", "input_filename", ",", "comment_char", "=", "'#'", ",", "to_upper", "=", "False", ")", ":", "# Prepare the input dictionary file in UTF-8 and NFC", "temp_dict_fd", ",", "output_filename", "=", "tempfile", ".", "mkstemp", "(", ")", "loggin...
Normalize UTF-8 characters of a file
[ "Normalize", "UTF", "-", "8", "characters", "of", "a", "file" ]
train
https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/common.py#L244-L262
rikrd/inspire
inspirespeech/common.py
parse_instance_count
def parse_instance_count(instance_count, speaker_total_count): """This parses the instance count dictionary (that may contain floats from 0.0 to 1.0 representing a percentage) and converts it to actual instance count. """ # Use all the instances of a speaker unless specified result = copy.copy(...
python
def parse_instance_count(instance_count, speaker_total_count): """This parses the instance count dictionary (that may contain floats from 0.0 to 1.0 representing a percentage) and converts it to actual instance count. """ # Use all the instances of a speaker unless specified result = copy.copy(...
[ "def", "parse_instance_count", "(", "instance_count", ",", "speaker_total_count", ")", ":", "# Use all the instances of a speaker unless specified", "result", "=", "copy", ".", "copy", "(", "speaker_total_count", ")", "for", "speaker_id", ",", "count", "in", "instance_cou...
This parses the instance count dictionary (that may contain floats from 0.0 to 1.0 representing a percentage) and converts it to actual instance count.
[ "This", "parses", "the", "instance", "count", "dictionary", "(", "that", "may", "contain", "floats", "from", "0", ".", "0", "to", "1", ".", "0", "representing", "a", "percentage", ")", "and", "converts", "it", "to", "actual", "instance", "count", "." ]
train
https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/common.py#L354-L372
rikrd/inspire
inspirespeech/common.py
create_flat_start_model
def create_flat_start_model(feature_filename, state_stay_probabilities, symbol_list, output_model_directory, output_prototype_filename, htk_trace): """ Creates a flat start...
python
def create_flat_start_model(feature_filename, state_stay_probabilities, symbol_list, output_model_directory, output_prototype_filename, htk_trace): """ Creates a flat start...
[ "def", "create_flat_start_model", "(", "feature_filename", ",", "state_stay_probabilities", ",", "symbol_list", ",", "output_model_directory", ",", "output_prototype_filename", ",", "htk_trace", ")", ":", "# Create a prototype model", "create_prototype_model", "(", "feature_fil...
Creates a flat start model by using HCompV to compute the global mean and variance. Then uses these global mean and variance to create an N-state model for each symbol in the given list. :param feature_filename: The filename containing the audio and feature file pairs :param output_model_directory: The dir...
[ "Creates", "a", "flat", "start", "model", "by", "using", "HCompV", "to", "compute", "the", "global", "mean", "and", "variance", ".", "Then", "uses", "these", "global", "mean", "and", "variance", "to", "create", "an", "N", "-", "state", "model", "for", "e...
train
https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/common.py#L571-L615
rikrd/inspire
inspirespeech/common.py
recognise_model
def recognise_model(feature_filename, symbollist_filename, model_directory, recognition_filename, pronunciation_dictionary_filename, list_words_filename='', cmllr_directory=None, t...
python
def recognise_model(feature_filename, symbollist_filename, model_directory, recognition_filename, pronunciation_dictionary_filename, list_words_filename='', cmllr_directory=None, t...
[ "def", "recognise_model", "(", "feature_filename", ",", "symbollist_filename", ",", "model_directory", ",", "recognition_filename", ",", "pronunciation_dictionary_filename", ",", "list_words_filename", "=", "''", ",", "cmllr_directory", "=", "None", ",", "tokens_count", "...
Perform recognition using a model and assuming a single word language. If the list_words_filename is == '' then all the words in the dictionary are used as language words.
[ "Perform", "recognition", "using", "a", "model", "and", "assuming", "a", "single", "word", "language", "." ]
train
https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/common.py#L989-L1061
rikrd/inspire
inspirespeech/common.py
create_language_model
def create_language_model(list_words, grammar_filename, wdnet_filename): """Create a language model (wdnet) for HTK using a very simple single-word grammar""" # Create the temporary grammar file grammar = u'' grammar += u'$possible_words = ' gramm...
python
def create_language_model(list_words, grammar_filename, wdnet_filename): """Create a language model (wdnet) for HTK using a very simple single-word grammar""" # Create the temporary grammar file grammar = u'' grammar += u'$possible_words = ' gramm...
[ "def", "create_language_model", "(", "list_words", ",", "grammar_filename", ",", "wdnet_filename", ")", ":", "# Create the temporary grammar file", "grammar", "=", "u''", "grammar", "+=", "u'$possible_words = '", "grammar", "+=", "u' | '", ".", "join", "(", "[", "word...
Create a language model (wdnet) for HTK using a very simple single-word grammar
[ "Create", "a", "language", "model", "(", "wdnet", ")", "for", "HTK", "using", "a", "very", "simple", "single", "-", "word", "grammar" ]
train
https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/common.py#L1064-L1083
sassoo/goldman
goldman/stores/postgres/connect.py
Connect.connect
def connect(self): """ Construct the psycopg2 connection instance :return: psycopg2.connect instance """ if self._conn: return self._conn self._conn = psycopg2.connect( self.config, cursor_factory=psycopg2.extras.RealDictCursor, ) ...
python
def connect(self): """ Construct the psycopg2 connection instance :return: psycopg2.connect instance """ if self._conn: return self._conn self._conn = psycopg2.connect( self.config, cursor_factory=psycopg2.extras.RealDictCursor, ) ...
[ "def", "connect", "(", "self", ")", ":", "if", "self", ".", "_conn", ":", "return", "self", ".", "_conn", "self", ".", "_conn", "=", "psycopg2", ".", "connect", "(", "self", ".", "config", ",", "cursor_factory", "=", "psycopg2", ".", "extras", ".", "...
Construct the psycopg2 connection instance :return: psycopg2.connect instance
[ "Construct", "the", "psycopg2", "connection", "instance" ]
train
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/stores/postgres/connect.py#L27-L44
praekelt/panya
panya/templatetags/panya_inclusion_tags.py
pager
def pager(parser, token): """ Output pagination links. """ try: tag_name, page_obj = token.split_contents() except ValueError: raise template.TemplateSyntaxError('pager tag requires 1 argument (page_obj), %s given' % (len(token.split_contents()) - 1)) return PagerNode(page_obj)
python
def pager(parser, token): """ Output pagination links. """ try: tag_name, page_obj = token.split_contents() except ValueError: raise template.TemplateSyntaxError('pager tag requires 1 argument (page_obj), %s given' % (len(token.split_contents()) - 1)) return PagerNode(page_obj)
[ "def", "pager", "(", "parser", ",", "token", ")", ":", "try", ":", "tag_name", ",", "page_obj", "=", "token", ".", "split_contents", "(", ")", "except", "ValueError", ":", "raise", "template", ".", "TemplateSyntaxError", "(", "'pager tag requires 1 argument (pag...
Output pagination links.
[ "Output", "pagination", "links", "." ]
train
https://github.com/praekelt/panya/blob/0fd621e15a7c11a2716a9554a2f820d6259818e5/panya/templatetags/panya_inclusion_tags.py#L34-L42
praekelt/panya
panya/templatetags/panya_inclusion_tags.py
view_modifier
def view_modifier(parser, token): """ Output view modifier. """ try: tag_name, view_modifier = token.split_contents() except ValueError: raise template.TemplateSyntaxError('view_modifier tag requires 1 argument (view_modifier), %s given' % (len(token.split_contents()) - 1)) retur...
python
def view_modifier(parser, token): """ Output view modifier. """ try: tag_name, view_modifier = token.split_contents() except ValueError: raise template.TemplateSyntaxError('view_modifier tag requires 1 argument (view_modifier), %s given' % (len(token.split_contents()) - 1)) retur...
[ "def", "view_modifier", "(", "parser", ",", "token", ")", ":", "try", ":", "tag_name", ",", "view_modifier", "=", "token", ".", "split_contents", "(", ")", "except", "ValueError", ":", "raise", "template", ".", "TemplateSyntaxError", "(", "'view_modifier tag req...
Output view modifier.
[ "Output", "view", "modifier", "." ]
train
https://github.com/praekelt/panya/blob/0fd621e15a7c11a2716a9554a2f820d6259818e5/panya/templatetags/panya_inclusion_tags.py#L94-L102
caseyjlaw/activegit
activegit/activegit.py
ActiveGit.initializerepo
def initializerepo(self): """ Fill empty directory with products and make first commit """ try: os.mkdir(self.repopath) except OSError: pass cmd = self.repo.init(bare=self.bare, shared=self.shared) if not self.bare: self.write_testing_data([...
python
def initializerepo(self): """ Fill empty directory with products and make first commit """ try: os.mkdir(self.repopath) except OSError: pass cmd = self.repo.init(bare=self.bare, shared=self.shared) if not self.bare: self.write_testing_data([...
[ "def", "initializerepo", "(", "self", ")", ":", "try", ":", "os", ".", "mkdir", "(", "self", ".", "repopath", ")", "except", "OSError", ":", "pass", "cmd", "=", "self", ".", "repo", ".", "init", "(", "bare", "=", "self", ".", "bare", ",", "shared",...
Fill empty directory with products and make first commit
[ "Fill", "empty", "directory", "with", "products", "and", "make", "first", "commit" ]
train
https://github.com/caseyjlaw/activegit/blob/2b4a0ee0fecf13345b5257130ba98b48f46e1098/activegit/activegit.py#L54-L75
caseyjlaw/activegit
activegit/activegit.py
ActiveGit.isvalid
def isvalid(self): """ Checks whether contents of repo are consistent with standard set. """ gcontents = [gf.rstrip('\n') for gf in self.repo.bake('ls-files')()] fcontents = os.listdir(self.repopath) return all([sf in gcontents for sf in std_files]) and all([sf in fcontents for sf in st...
python
def isvalid(self): """ Checks whether contents of repo are consistent with standard set. """ gcontents = [gf.rstrip('\n') for gf in self.repo.bake('ls-files')()] fcontents = os.listdir(self.repopath) return all([sf in gcontents for sf in std_files]) and all([sf in fcontents for sf in st...
[ "def", "isvalid", "(", "self", ")", ":", "gcontents", "=", "[", "gf", ".", "rstrip", "(", "'\\n'", ")", "for", "gf", "in", "self", ".", "repo", ".", "bake", "(", "'ls-files'", ")", "(", ")", "]", "fcontents", "=", "os", ".", "listdir", "(", "self...
Checks whether contents of repo are consistent with standard set.
[ "Checks", "whether", "contents", "of", "repo", "are", "consistent", "with", "standard", "set", "." ]
train
https://github.com/caseyjlaw/activegit/blob/2b4a0ee0fecf13345b5257130ba98b48f46e1098/activegit/activegit.py#L97-L102
caseyjlaw/activegit
activegit/activegit.py
ActiveGit.set_version
def set_version(self, version, force=True): """ Sets the version name for the current state of repo """ if version in self.versions: self._version = version if 'working' in self.repo.branch().stdout: if force: logger.info('Found working branch...
python
def set_version(self, version, force=True): """ Sets the version name for the current state of repo """ if version in self.versions: self._version = version if 'working' in self.repo.branch().stdout: if force: logger.info('Found working branch...
[ "def", "set_version", "(", "self", ",", "version", ",", "force", "=", "True", ")", ":", "if", "version", "in", "self", ".", "versions", ":", "self", ".", "_version", "=", "version", "if", "'working'", "in", "self", ".", "repo", ".", "branch", "(", ")...
Sets the version name for the current state of repo
[ "Sets", "the", "version", "name", "for", "the", "current", "state", "of", "repo" ]
train
https://github.com/caseyjlaw/activegit/blob/2b4a0ee0fecf13345b5257130ba98b48f46e1098/activegit/activegit.py#L105-L122
caseyjlaw/activegit
activegit/activegit.py
ActiveGit.show_version_info
def show_version_info(self, version): """ Summarizes info of a particular version (a la "git show version") """ if version in self.versions: stdout = self.repo.show(version, '--summary').stdout logger.info(stdout) else: logger.info('Version {0} not found'.for...
python
def show_version_info(self, version): """ Summarizes info of a particular version (a la "git show version") """ if version in self.versions: stdout = self.repo.show(version, '--summary').stdout logger.info(stdout) else: logger.info('Version {0} not found'.for...
[ "def", "show_version_info", "(", "self", ",", "version", ")", ":", "if", "version", "in", "self", ".", "versions", ":", "stdout", "=", "self", ".", "repo", ".", "show", "(", "version", ",", "'--summary'", ")", ".", "stdout", "logger", ".", "info", "(",...
Summarizes info of a particular version (a la "git show version")
[ "Summarizes", "info", "of", "a", "particular", "version", "(", "a", "la", "git", "show", "version", ")" ]
train
https://github.com/caseyjlaw/activegit/blob/2b4a0ee0fecf13345b5257130ba98b48f46e1098/activegit/activegit.py#L125-L132
caseyjlaw/activegit
activegit/activegit.py
ActiveGit.training_data
def training_data(self): """ Returns data dictionary from training.pkl """ data = pickle.load(open(os.path.join(self.repopath, 'training.pkl'))) return data.keys(), data.values()
python
def training_data(self): """ Returns data dictionary from training.pkl """ data = pickle.load(open(os.path.join(self.repopath, 'training.pkl'))) return data.keys(), data.values()
[ "def", "training_data", "(", "self", ")", ":", "data", "=", "pickle", ".", "load", "(", "open", "(", "os", ".", "path", ".", "join", "(", "self", ".", "repopath", ",", "'training.pkl'", ")", ")", ")", "return", "data", ".", "keys", "(", ")", ",", ...
Returns data dictionary from training.pkl
[ "Returns", "data", "dictionary", "from", "training", ".", "pkl" ]
train
https://github.com/caseyjlaw/activegit/blob/2b4a0ee0fecf13345b5257130ba98b48f46e1098/activegit/activegit.py#L137-L141
caseyjlaw/activegit
activegit/activegit.py
ActiveGit.classifier
def classifier(self): """ Returns classifier from classifier.pkl """ clf = pickle.load(open(os.path.join(self.repopath, 'classifier.pkl'))) return clf
python
def classifier(self): """ Returns classifier from classifier.pkl """ clf = pickle.load(open(os.path.join(self.repopath, 'classifier.pkl'))) return clf
[ "def", "classifier", "(", "self", ")", ":", "clf", "=", "pickle", ".", "load", "(", "open", "(", "os", ".", "path", ".", "join", "(", "self", ".", "repopath", ",", "'classifier.pkl'", ")", ")", ")", "return", "clf" ]
Returns classifier from classifier.pkl
[ "Returns", "classifier", "from", "classifier", ".", "pkl" ]
train
https://github.com/caseyjlaw/activegit/blob/2b4a0ee0fecf13345b5257130ba98b48f46e1098/activegit/activegit.py#L153-L157
caseyjlaw/activegit
activegit/activegit.py
ActiveGit.write_training_data
def write_training_data(self, features, targets): """ Writes data dictionary to filename """ assert len(features) == len(targets) data = dict(zip(features, targets)) with open(os.path.join(self.repopath, 'training.pkl'), 'w') as fp: pickle.dump(data, fp)
python
def write_training_data(self, features, targets): """ Writes data dictionary to filename """ assert len(features) == len(targets) data = dict(zip(features, targets)) with open(os.path.join(self.repopath, 'training.pkl'), 'w') as fp: pickle.dump(data, fp)
[ "def", "write_training_data", "(", "self", ",", "features", ",", "targets", ")", ":", "assert", "len", "(", "features", ")", "==", "len", "(", "targets", ")", "data", "=", "dict", "(", "zip", "(", "features", ",", "targets", ")", ")", "with", "open", ...
Writes data dictionary to filename
[ "Writes", "data", "dictionary", "to", "filename" ]
train
https://github.com/caseyjlaw/activegit/blob/2b4a0ee0fecf13345b5257130ba98b48f46e1098/activegit/activegit.py#L161-L169
caseyjlaw/activegit
activegit/activegit.py
ActiveGit.write_classifier
def write_classifier(self, clf): """ Writes classifier object to pickle file """ with open(os.path.join(self.repopath, 'classifier.pkl'), 'w') as fp: pickle.dump(clf, fp)
python
def write_classifier(self, clf): """ Writes classifier object to pickle file """ with open(os.path.join(self.repopath, 'classifier.pkl'), 'w') as fp: pickle.dump(clf, fp)
[ "def", "write_classifier", "(", "self", ",", "clf", ")", ":", "with", "open", "(", "os", ".", "path", ".", "join", "(", "self", ".", "repopath", ",", "'classifier.pkl'", ")", ",", "'w'", ")", "as", "fp", ":", "pickle", ".", "dump", "(", "clf", ",",...
Writes classifier object to pickle file
[ "Writes", "classifier", "object", "to", "pickle", "file" ]
train
https://github.com/caseyjlaw/activegit/blob/2b4a0ee0fecf13345b5257130ba98b48f46e1098/activegit/activegit.py#L183-L187
caseyjlaw/activegit
activegit/activegit.py
ActiveGit.commit_version
def commit_version(self, version, msg=None): """ Add tag, commit, and push changes """ assert version not in self.versions, 'Will not overwrite a version name.' if not msg: feat, targ = self.training_data msg = 'Training set has {0} examples. '.format(len(feat)) ...
python
def commit_version(self, version, msg=None): """ Add tag, commit, and push changes """ assert version not in self.versions, 'Will not overwrite a version name.' if not msg: feat, targ = self.training_data msg = 'Training set has {0} examples. '.format(len(feat)) ...
[ "def", "commit_version", "(", "self", ",", "version", ",", "msg", "=", "None", ")", ":", "assert", "version", "not", "in", "self", ".", "versions", ",", "'Will not overwrite a version name.'", "if", "not", "msg", ":", "feat", ",", "targ", "=", "self", ".",...
Add tag, commit, and push changes
[ "Add", "tag", "commit", "and", "push", "changes" ]
train
https://github.com/caseyjlaw/activegit/blob/2b4a0ee0fecf13345b5257130ba98b48f46e1098/activegit/activegit.py#L191-L214
caseyjlaw/activegit
activegit/activegit.py
ActiveGit.update
def update(self): """ Pull latest versions/tags, if linked to a remote (e.g., github). """ try: stdout = self.repo.pull().stdout logger.info(stdout) except: logger.info('Pull not working. Remote not defined?')
python
def update(self): """ Pull latest versions/tags, if linked to a remote (e.g., github). """ try: stdout = self.repo.pull().stdout logger.info(stdout) except: logger.info('Pull not working. Remote not defined?')
[ "def", "update", "(", "self", ")", ":", "try", ":", "stdout", "=", "self", ".", "repo", ".", "pull", "(", ")", ".", "stdout", "logger", ".", "info", "(", "stdout", ")", "except", ":", "logger", ".", "info", "(", "'Pull not working. Remote not defined?'",...
Pull latest versions/tags, if linked to a remote (e.g., github).
[ "Pull", "latest", "versions", "/", "tags", "if", "linked", "to", "a", "remote", "(", "e", ".", "g", ".", "github", ")", "." ]
train
https://github.com/caseyjlaw/activegit/blob/2b4a0ee0fecf13345b5257130ba98b48f46e1098/activegit/activegit.py#L217-L224
pioneers/python-grizzly
grizzly/__init__.py
GrizzlyUSB.get_all_usb_devices
def get_all_usb_devices(idVendor, idProduct): """ Returns a list of all the usb devices matching the provided vendor ID and product ID.""" all_dev = list(usb.core.find(find_all = True, idVendor = idVendor, idProduct = idProduct)) for dev in all_dev: try: dev.detach_ke...
python
def get_all_usb_devices(idVendor, idProduct): """ Returns a list of all the usb devices matching the provided vendor ID and product ID.""" all_dev = list(usb.core.find(find_all = True, idVendor = idVendor, idProduct = idProduct)) for dev in all_dev: try: dev.detach_ke...
[ "def", "get_all_usb_devices", "(", "idVendor", ",", "idProduct", ")", ":", "all_dev", "=", "list", "(", "usb", ".", "core", ".", "find", "(", "find_all", "=", "True", ",", "idVendor", "=", "idVendor", ",", "idProduct", "=", "idProduct", ")", ")", "for", ...
Returns a list of all the usb devices matching the provided vendor ID and product ID.
[ "Returns", "a", "list", "of", "all", "the", "usb", "devices", "matching", "the", "provided", "vendor", "ID", "and", "product", "ID", "." ]
train
https://github.com/pioneers/python-grizzly/blob/a6482c722d5712d6ebe12d48921815276c826c7f/grizzly/__init__.py#L41-L49