repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
ossobv/dutree
dutree/bogofs.py
GeneratedFilesystem.get_content_size
def get_content_size(self, path): "Return size of files/dirs contents excluding parent node." node = self._get_node(path) return self._get_content_size(node) - node.size
python
def get_content_size(self, path): "Return size of files/dirs contents excluding parent node." node = self._get_node(path) return self._get_content_size(node) - node.size
[ "def", "get_content_size", "(", "self", ",", "path", ")", ":", "node", "=", "self", ".", "_get_node", "(", "path", ")", "return", "self", ".", "_get_content_size", "(", "node", ")", "-", "node", ".", "size" ]
Return size of files/dirs contents excluding parent node.
[ "Return", "size", "of", "files", "/", "dirs", "contents", "excluding", "parent", "node", "." ]
adceeeb17f9fd70a7ed9c674850d7015d820eb2a
https://github.com/ossobv/dutree/blob/adceeeb17f9fd70a7ed9c674850d7015d820eb2a/dutree/bogofs.py#L150-L153
train
Return size of files / dirs contents excluding parent node.
jstitch/MambuPy
MambuPy/rest/mambuclient.py
MambuClient.preprocess
def preprocess(self): """Preprocessing. Flattens the object. Important data comes on the 'client' dictionary inside of the response. Instead, every element of the 'client' dictionary is taken out to the main attrs dictionary. Removes repeated chars from firstName, middleName an...
python
def preprocess(self): """Preprocessing. Flattens the object. Important data comes on the 'client' dictionary inside of the response. Instead, every element of the 'client' dictionary is taken out to the main attrs dictionary. Removes repeated chars from firstName, middleName an...
[ "def", "preprocess", "(", "self", ")", ":", "super", "(", "MambuClient", ",", "self", ")", ".", "preprocess", "(", ")", "try", ":", "for", "k", ",", "v", "in", "self", "[", "'client'", "]", ".", "items", "(", ")", ":", "self", "[", "k", "]", "=...
Preprocessing. Flattens the object. Important data comes on the 'client' dictionary inside of the response. Instead, every element of the 'client' dictionary is taken out to the main attrs dictionary. Removes repeated chars from firstName, middleName and lastName fields. Adds a...
[ "Preprocessing", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambuclient.py#L41-L109
train
This method is used to preprocess the object attributes.
jstitch/MambuPy
MambuPy/rest/mambuclient.py
MambuClient.postprocess
def postprocess(self): """Postprocessing. Just in case some elements on the addresses was converted to anything but string, it gets converted back to only string (unicode). Things on addresses are not useful but by what they say, not what they are. .. todo:: do the same thing t...
python
def postprocess(self): """Postprocessing. Just in case some elements on the addresses was converted to anything but string, it gets converted back to only string (unicode). Things on addresses are not useful but by what they say, not what they are. .. todo:: do the same thing t...
[ "def", "postprocess", "(", "self", ")", ":", "try", ":", "for", "name", ",", "item", "in", "self", "[", "'addresses'", "]", "[", "0", "]", ".", "items", "(", ")", ":", "try", ":", "if", "name", "==", "\"indexInList\"", ":", "continue", "self", "[",...
Postprocessing. Just in case some elements on the addresses was converted to anything but string, it gets converted back to only string (unicode). Things on addresses are not useful but by what they say, not what they are. .. todo:: do the same thing to the 'address' field created on ...
[ "Postprocessing", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambuclient.py#L112-L134
train
Postprocessing.
jstitch/MambuPy
MambuPy/rest/mambuclient.py
MambuClient.setGroups
def setGroups(self, *args, **kwargs): """Adds the groups to which this client belongs. The 'groupKeys' field of the client holds a list of the encodedKeys of the groups to which this client belongs. Returns the number of requests done to Mambu. """ requests = 0 ...
python
def setGroups(self, *args, **kwargs): """Adds the groups to which this client belongs. The 'groupKeys' field of the client holds a list of the encodedKeys of the groups to which this client belongs. Returns the number of requests done to Mambu. """ requests = 0 ...
[ "def", "setGroups", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "requests", "=", "0", "groups", "=", "[", "]", "try", ":", "for", "gk", "in", "self", "[", "'groupKeys'", "]", ":", "try", ":", "g", "=", "self", ".", "mambug...
Adds the groups to which this client belongs. The 'groupKeys' field of the client holds a list of the encodedKeys of the groups to which this client belongs. Returns the number of requests done to Mambu.
[ "Adds", "the", "groups", "to", "which", "this", "client", "belongs", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambuclient.py#L136-L162
train
Adds the groups to which this client belongs. Returns the number of requests done to Mambu.
jstitch/MambuPy
MambuPy/rest/mambuclient.py
MambuClient.setBranch
def setBranch(self, *args, **kwargs): """Adds the branch to which the client belongs. """ try: branch = self.mambubranchclass(entid=self['assignedBranchKey'], *args, **kwargs) except AttributeError as ae: from .mambubranch import MambuBranch self.mamb...
python
def setBranch(self, *args, **kwargs): """Adds the branch to which the client belongs. """ try: branch = self.mambubranchclass(entid=self['assignedBranchKey'], *args, **kwargs) except AttributeError as ae: from .mambubranch import MambuBranch self.mamb...
[ "def", "setBranch", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "branch", "=", "self", ".", "mambubranchclass", "(", "entid", "=", "self", "[", "'assignedBranchKey'", "]", ",", "*", "args", ",", "*", "*", "kwargs", ...
Adds the branch to which the client belongs.
[ "Adds", "the", "branch", "to", "which", "the", "client", "belongs", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambuclient.py#L164-L177
train
Adds the branch to which the client belongs.
jstitch/MambuPy
MambuPy/rest/mambuclient.py
MambuClients.convertDict2Attrs
def convertDict2Attrs(self, *args, **kwargs): """The trick for iterable Mambu Objects comes here: You iterate over each element of the responded List from Mambu, and create a Mambu Client object for each one, initializing them one at a time, and changing the attrs attribute (which just ...
python
def convertDict2Attrs(self, *args, **kwargs): """The trick for iterable Mambu Objects comes here: You iterate over each element of the responded List from Mambu, and create a Mambu Client object for each one, initializing them one at a time, and changing the attrs attribute (which just ...
[ "def", "convertDict2Attrs", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "n", ",", "c", "in", "enumerate", "(", "self", ".", "attrs", ")", ":", "# ok ok, I'm modifying elements of a list while iterating it. BAD PRACTICE!", "try", ":",...
The trick for iterable Mambu Objects comes here: You iterate over each element of the responded List from Mambu, and create a Mambu Client object for each one, initializing them one at a time, and changing the attrs attribute (which just holds a list of plain dictionaries) with a MambuC...
[ "The", "trick", "for", "iterable", "Mambu", "Objects", "comes", "here", ":" ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/rest/mambuclient.py#L198-L226
train
This function converts a dictionary of Mambu objects into a list of MambuClient objects.
jpscaletti/authcode
authcode/auth_authorization_mixin.py
AuthorizationMixin.protected
def protected(self, *tests, **kwargs): """Factory of decorators for limit the access to views. :tests: *function, optional One or more functions that takes the args and kwargs of the view and returns either `True` or `False`. All test must return True to show the vie...
python
def protected(self, *tests, **kwargs): """Factory of decorators for limit the access to views. :tests: *function, optional One or more functions that takes the args and kwargs of the view and returns either `True` or `False`. All test must return True to show the vie...
[ "def", "protected", "(", "self", ",", "*", "tests", ",", "*", "*", "kwargs", ")", ":", "_role", "=", "kwargs", ".", "pop", "(", "'role'", ",", "None", ")", "_roles", "=", "kwargs", ".", "pop", "(", "'roles'", ",", "None", ")", "or", "[", "]", "...
Factory of decorators for limit the access to views. :tests: *function, optional One or more functions that takes the args and kwargs of the view and returns either `True` or `False`. All test must return True to show the view. Options: :role: str, optional...
[ "Factory", "of", "decorators", "for", "limit", "the", "access", "to", "views", "." ]
91529b6d0caec07d1452758d937e1e0745826139
https://github.com/jpscaletti/authcode/blob/91529b6d0caec07d1452758d937e1e0745826139/authcode/auth_authorization_mixin.py#L31-L117
train
Decorator for limit the access to views.
jpscaletti/authcode
authcode/auth_authorization_mixin.py
AuthorizationMixin.replace_flask_route
def replace_flask_route(self, bp, *args, **kwargs): """Replace the Flask `app.route` or `blueprint.route` with a version that first apply the protected decorator to the view, so all views are automatically protected.""" protected = self.protected def protected_route(rule, **opti...
python
def replace_flask_route(self, bp, *args, **kwargs): """Replace the Flask `app.route` or `blueprint.route` with a version that first apply the protected decorator to the view, so all views are automatically protected.""" protected = self.protected def protected_route(rule, **opti...
[ "def", "replace_flask_route", "(", "self", ",", "bp", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "protected", "=", "self", ".", "protected", "def", "protected_route", "(", "rule", ",", "*", "*", "options", ")", ":", "\"\"\"Like :meth:`Flask.route...
Replace the Flask `app.route` or `blueprint.route` with a version that first apply the protected decorator to the view, so all views are automatically protected.
[ "Replace", "the", "Flask", "app", ".", "route", "or", "blueprint", ".", "route", "with", "a", "version", "that", "first", "apply", "the", "protected", "decorator", "to", "the", "view", "so", "all", "views", "are", "automatically", "protected", "." ]
91529b6d0caec07d1452758d937e1e0745826139
https://github.com/jpscaletti/authcode/blob/91529b6d0caec07d1452758d937e1e0745826139/authcode/auth_authorization_mixin.py#L119-L136
train
Replace the Flask app. route or blueprint. route with a version that first applies the protected decorator to the view so all views are automatically protected.
inveniosoftware/invenio-query-parser
invenio_query_parser/contrib/spires/converter.py
SpiresToInvenioSyntaxConverter.parse_query
def parse_query(self, query): """Parse query string using given grammar""" tree = pypeg2.parse(query, Main, whitespace="") return tree.accept(self.converter)
python
def parse_query(self, query): """Parse query string using given grammar""" tree = pypeg2.parse(query, Main, whitespace="") return tree.accept(self.converter)
[ "def", "parse_query", "(", "self", ",", "query", ")", ":", "tree", "=", "pypeg2", ".", "parse", "(", "query", ",", "Main", ",", "whitespace", "=", "\"\"", ")", "return", "tree", ".", "accept", "(", "self", ".", "converter", ")" ]
Parse query string using given grammar
[ "Parse", "query", "string", "using", "given", "grammar" ]
21a2c36318003ff52d2e18e7196bb420db8ecb4b
https://github.com/inveniosoftware/invenio-query-parser/blob/21a2c36318003ff52d2e18e7196bb420db8ecb4b/invenio_query_parser/contrib/spires/converter.py#L39-L42
train
Parse a query string using given grammar
blockstack-packages/jsontokens-py
jsontokens/token_verifier.py
_unpack_token_compact
def _unpack_token_compact(token): """ Unpack a compact-form serialized JWT. Returns (header, payload, signature, signing_input) on success Raises DecodeError on bad input """ if isinstance(token, (str, unicode)): token = token.encode('utf-8') try: signing_input, crypto_segme...
python
def _unpack_token_compact(token): """ Unpack a compact-form serialized JWT. Returns (header, payload, signature, signing_input) on success Raises DecodeError on bad input """ if isinstance(token, (str, unicode)): token = token.encode('utf-8') try: signing_input, crypto_segme...
[ "def", "_unpack_token_compact", "(", "token", ")", ":", "if", "isinstance", "(", "token", ",", "(", "str", ",", "unicode", ")", ")", ":", "token", "=", "token", ".", "encode", "(", "'utf-8'", ")", "try", ":", "signing_input", ",", "crypto_segment", "=", ...
Unpack a compact-form serialized JWT. Returns (header, payload, signature, signing_input) on success Raises DecodeError on bad input
[ "Unpack", "a", "compact", "-", "form", "serialized", "JWT", ".", "Returns", "(", "header", "payload", "signature", "signing_input", ")", "on", "success", "Raises", "DecodeError", "on", "bad", "input" ]
1a4e71ed63456e8381b7d3fd566ce38e6ebfa7d3
https://github.com/blockstack-packages/jsontokens-py/blob/1a4e71ed63456e8381b7d3fd566ce38e6ebfa7d3/jsontokens/token_verifier.py#L27-L70
train
Unpack a compact - form serialized JWT.
blockstack-packages/jsontokens-py
jsontokens/token_verifier.py
_unpack_token_json
def _unpack_token_json(token): """ Unpack a JSON-serialized JWT Returns (headers, payload, signatures) on success Raises DecodeError on bad input """ if not isinstance(token, dict): raise DecodeError("Not a dict") if not token.has_key('payload'): raise DecodeError("Missing '...
python
def _unpack_token_json(token): """ Unpack a JSON-serialized JWT Returns (headers, payload, signatures) on success Raises DecodeError on bad input """ if not isinstance(token, dict): raise DecodeError("Not a dict") if not token.has_key('payload'): raise DecodeError("Missing '...
[ "def", "_unpack_token_json", "(", "token", ")", ":", "if", "not", "isinstance", "(", "token", ",", "dict", ")", ":", "raise", "DecodeError", "(", "\"Not a dict\"", ")", "if", "not", "token", ".", "has_key", "(", "'payload'", ")", ":", "raise", "DecodeError...
Unpack a JSON-serialized JWT Returns (headers, payload, signatures) on success Raises DecodeError on bad input
[ "Unpack", "a", "JSON", "-", "serialized", "JWT", "Returns", "(", "headers", "payload", "signatures", ")", "on", "success", "Raises", "DecodeError", "on", "bad", "input" ]
1a4e71ed63456e8381b7d3fd566ce38e6ebfa7d3
https://github.com/blockstack-packages/jsontokens-py/blob/1a4e71ed63456e8381b7d3fd566ce38e6ebfa7d3/jsontokens/token_verifier.py#L73-L120
train
Unpack a JSON - serialized JWT into a list of headers payload signatures and signing_inputs.
blockstack-packages/jsontokens-py
jsontokens/token_verifier.py
unpack_token
def unpack_token(token): """ Unpack a JSON-serialized JWT or a compact-serialized JWT Returns (header, payload, signature, signing_input) on success Raises DecodeError on bad input """ if isinstance(token, (unicode,str)): return _decode_token_compact(token) else: return _dec...
python
def unpack_token(token): """ Unpack a JSON-serialized JWT or a compact-serialized JWT Returns (header, payload, signature, signing_input) on success Raises DecodeError on bad input """ if isinstance(token, (unicode,str)): return _decode_token_compact(token) else: return _dec...
[ "def", "unpack_token", "(", "token", ")", ":", "if", "isinstance", "(", "token", ",", "(", "unicode", ",", "str", ")", ")", ":", "return", "_decode_token_compact", "(", "token", ")", "else", ":", "return", "_decode_token_json", "(", "token", ")" ]
Unpack a JSON-serialized JWT or a compact-serialized JWT Returns (header, payload, signature, signing_input) on success Raises DecodeError on bad input
[ "Unpack", "a", "JSON", "-", "serialized", "JWT", "or", "a", "compact", "-", "serialized", "JWT", "Returns", "(", "header", "payload", "signature", "signing_input", ")", "on", "success", "Raises", "DecodeError", "on", "bad", "input" ]
1a4e71ed63456e8381b7d3fd566ce38e6ebfa7d3
https://github.com/blockstack-packages/jsontokens-py/blob/1a4e71ed63456e8381b7d3fd566ce38e6ebfa7d3/jsontokens/token_verifier.py#L123-L133
train
Unpack a JSON - serialized JWT or a compact - serialized JWT returning a tuple of header payload signature signing_input
blockstack-packages/jsontokens-py
jsontokens/token_verifier.py
_decode_token_compact
def _decode_token_compact(token): """ Decode a compact-serialized JWT Returns {'header': ..., 'payload': ..., 'signature': ...} """ header, payload, raw_signature, signing_input = _unpack_token_compact(token) token = { "header": header, "payload": payload, "signature": b...
python
def _decode_token_compact(token): """ Decode a compact-serialized JWT Returns {'header': ..., 'payload': ..., 'signature': ...} """ header, payload, raw_signature, signing_input = _unpack_token_compact(token) token = { "header": header, "payload": payload, "signature": b...
[ "def", "_decode_token_compact", "(", "token", ")", ":", "header", ",", "payload", ",", "raw_signature", ",", "signing_input", "=", "_unpack_token_compact", "(", "token", ")", "token", "=", "{", "\"header\"", ":", "header", ",", "\"payload\"", ":", "payload", "...
Decode a compact-serialized JWT Returns {'header': ..., 'payload': ..., 'signature': ...}
[ "Decode", "a", "compact", "-", "serialized", "JWT", "Returns", "{", "header", ":", "...", "payload", ":", "...", "signature", ":", "...", "}" ]
1a4e71ed63456e8381b7d3fd566ce38e6ebfa7d3
https://github.com/blockstack-packages/jsontokens-py/blob/1a4e71ed63456e8381b7d3fd566ce38e6ebfa7d3/jsontokens/token_verifier.py#L136-L147
train
Decode a compact - serialized JWT Returns a compact - serialized JWT
blockstack-packages/jsontokens-py
jsontokens/token_verifier.py
_decode_token_json
def _decode_token_json(token): """ Decode a JSON-serialized JWT Returns {'header': ..., 'payload': ..., 'signature': ...} """ header, payload, raw_signatures, signing_inputs = _unpack_token_json(token) token = { 'header': header, 'payload': payload, 'signature': [base64ur...
python
def _decode_token_json(token): """ Decode a JSON-serialized JWT Returns {'header': ..., 'payload': ..., 'signature': ...} """ header, payload, raw_signatures, signing_inputs = _unpack_token_json(token) token = { 'header': header, 'payload': payload, 'signature': [base64ur...
[ "def", "_decode_token_json", "(", "token", ")", ":", "header", ",", "payload", ",", "raw_signatures", ",", "signing_inputs", "=", "_unpack_token_json", "(", "token", ")", "token", "=", "{", "'header'", ":", "header", ",", "'payload'", ":", "payload", ",", "'...
Decode a JSON-serialized JWT Returns {'header': ..., 'payload': ..., 'signature': ...}
[ "Decode", "a", "JSON", "-", "serialized", "JWT", "Returns", "{", "header", ":", "...", "payload", ":", "...", "signature", ":", "...", "}" ]
1a4e71ed63456e8381b7d3fd566ce38e6ebfa7d3
https://github.com/blockstack-packages/jsontokens-py/blob/1a4e71ed63456e8381b7d3fd566ce38e6ebfa7d3/jsontokens/token_verifier.py#L150-L161
train
Decode a JSON - serialized JWT Returns a dictionary with header payload and signature.
blockstack-packages/jsontokens-py
jsontokens/token_verifier.py
decode_token
def decode_token(token): """ Top-level method to decode a JWT. Takes either a compact-encoded JWT with a single signature, or a multi-sig JWT in the JSON-serialized format. Returns the deserialized token, as a dict. The signatures will still be base64-encoded """ if isinstance(token, (u...
python
def decode_token(token): """ Top-level method to decode a JWT. Takes either a compact-encoded JWT with a single signature, or a multi-sig JWT in the JSON-serialized format. Returns the deserialized token, as a dict. The signatures will still be base64-encoded """ if isinstance(token, (u...
[ "def", "decode_token", "(", "token", ")", ":", "if", "isinstance", "(", "token", ",", "(", "unicode", ",", "str", ")", ")", ":", "return", "_decode_token_compact", "(", "token", ")", "else", ":", "return", "_decode_token_json", "(", "token", ")" ]
Top-level method to decode a JWT. Takes either a compact-encoded JWT with a single signature, or a multi-sig JWT in the JSON-serialized format. Returns the deserialized token, as a dict. The signatures will still be base64-encoded
[ "Top", "-", "level", "method", "to", "decode", "a", "JWT", ".", "Takes", "either", "a", "compact", "-", "encoded", "JWT", "with", "a", "single", "signature", "or", "a", "multi", "-", "sig", "JWT", "in", "the", "JSON", "-", "serialized", "format", "." ]
1a4e71ed63456e8381b7d3fd566ce38e6ebfa7d3
https://github.com/blockstack-packages/jsontokens-py/blob/1a4e71ed63456e8381b7d3fd566ce38e6ebfa7d3/jsontokens/token_verifier.py#L164-L177
train
Decode a compact - encoded JWT into a dict.
blockstack-packages/jsontokens-py
jsontokens/token_verifier.py
TokenVerifier._verify_multi
def _verify_multi(self, token, verifying_keys, num_required=None): """ Verify a JSON-formatted JWT signed by multiple keys is authentic. Optionally set a threshold of required valid signatures with num_required. Return True if valid Return False if not TODO: support mult...
python
def _verify_multi(self, token, verifying_keys, num_required=None): """ Verify a JSON-formatted JWT signed by multiple keys is authentic. Optionally set a threshold of required valid signatures with num_required. Return True if valid Return False if not TODO: support mult...
[ "def", "_verify_multi", "(", "self", ",", "token", ",", "verifying_keys", ",", "num_required", "=", "None", ")", ":", "headers", ",", "payload", ",", "raw_signatures", ",", "signing_inputs", "=", "_unpack_token_json", "(", "token", ")", "if", "num_required", "...
Verify a JSON-formatted JWT signed by multiple keys is authentic. Optionally set a threshold of required valid signatures with num_required. Return True if valid Return False if not TODO: support multiple types of keys
[ "Verify", "a", "JSON", "-", "formatted", "JWT", "signed", "by", "multiple", "keys", "is", "authentic", ".", "Optionally", "set", "a", "threshold", "of", "required", "valid", "signatures", "with", "num_required", ".", "Return", "True", "if", "valid", "Return", ...
1a4e71ed63456e8381b7d3fd566ce38e6ebfa7d3
https://github.com/blockstack-packages/jsontokens-py/blob/1a4e71ed63456e8381b7d3fd566ce38e6ebfa7d3/jsontokens/token_verifier.py#L219-L266
train
Verify a JSON - formatted JWT signed by multiple keys.
blockstack-packages/jsontokens-py
jsontokens/token_verifier.py
TokenVerifier.verify
def verify(self, token, verifying_key_or_keys, num_required=None): """ Verify a compact-formated JWT or a JSON-formatted JWT signed by multiple keys. Return True if valid Return False if not valid TODO: support multiple types of keys """ if not isinstance(verifyi...
python
def verify(self, token, verifying_key_or_keys, num_required=None): """ Verify a compact-formated JWT or a JSON-formatted JWT signed by multiple keys. Return True if valid Return False if not valid TODO: support multiple types of keys """ if not isinstance(verifyi...
[ "def", "verify", "(", "self", ",", "token", ",", "verifying_key_or_keys", ",", "num_required", "=", "None", ")", ":", "if", "not", "isinstance", "(", "verifying_key_or_keys", ",", "(", "list", ",", "str", ",", "unicode", ")", ")", ":", "raise", "ValueError...
Verify a compact-formated JWT or a JSON-formatted JWT signed by multiple keys. Return True if valid Return False if not valid TODO: support multiple types of keys
[ "Verify", "a", "compact", "-", "formated", "JWT", "or", "a", "JSON", "-", "formatted", "JWT", "signed", "by", "multiple", "keys", ".", "Return", "True", "if", "valid", "Return", "False", "if", "not", "valid" ]
1a4e71ed63456e8381b7d3fd566ce38e6ebfa7d3
https://github.com/blockstack-packages/jsontokens-py/blob/1a4e71ed63456e8381b7d3fd566ce38e6ebfa7d3/jsontokens/token_verifier.py#L269-L284
train
Verify a compact - formated JWT or a JSON - formatted JWT signed by multiple keys.
cloudmesh-cmd3/cmd3
cmd3/plugins/script.py
script.activate_script
def activate_script(self): """activates the script command""" # must be rethought # ./scripts # deploydir/./scripts self._add_scope("script") self.scripts = {} self.script_files = [ "./scripts/script_*.txt", "~/.cloudmesh/scripts/script_*.txt"] ...
python
def activate_script(self): """activates the script command""" # must be rethought # ./scripts # deploydir/./scripts self._add_scope("script") self.scripts = {} self.script_files = [ "./scripts/script_*.txt", "~/.cloudmesh/scripts/script_*.txt"] ...
[ "def", "activate_script", "(", "self", ")", ":", "# must be rethought", "# ./scripts", "# deploydir/./scripts", "self", ".", "_add_scope", "(", "\"script\"", ")", "self", ".", "scripts", "=", "{", "}", "self", ".", "script_files", "=", "[", "\"./scripts/script_*.t...
activates the script command
[ "activates", "the", "script", "command" ]
92e33c96032fd3921f159198a0e57917c4dc34ed
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/plugins/script.py#L16-L26
train
activates the script command
cloudmesh-cmd3/cmd3
cmd3/plugins/script.py
script.do_script
def do_script(self, args, arguments): """ :: Usage: script script load script load LABEL FILENAME script load REGEXP script list script LABEL Arguments: ...
python
def do_script(self, args, arguments): """ :: Usage: script script load script load LABEL FILENAME script load REGEXP script list script LABEL Arguments: ...
[ "def", "do_script", "(", "self", ",", "args", ",", "arguments", ")", ":", "if", "args", "==", "\"load\"", ":", "self", ".", "_load_scripts", "(", "self", ".", "script_files", ")", "self", ".", "_list_scripts", "(", ")", "elif", "args", "==", "\"list\"", ...
:: Usage: script script load script load LABEL FILENAME script load REGEXP script list script LABEL Arguments: load indicates that we try to do act...
[ "::", "Usage", ":", "script", "script", "load", "script", "load", "LABEL", "FILENAME", "script", "load", "REGEXP", "script", "list", "script", "LABEL" ]
92e33c96032fd3921f159198a0e57917c4dc34ed
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/plugins/script.py#L82-L128
train
This function is called by the script module.
giancosta86/Iris
info/gianlucacosta/iris/io/utils.py
PathOperations.safeMakeDirs
def safeMakeDirs(path, mode=0o777): """ Creates the given directory path, as well as intermediate directories. Catches any I/O exception, returning False in that case; otherwise, True is returned. """ try: os.makedirs(path, mode) return True ...
python
def safeMakeDirs(path, mode=0o777): """ Creates the given directory path, as well as intermediate directories. Catches any I/O exception, returning False in that case; otherwise, True is returned. """ try: os.makedirs(path, mode) return True ...
[ "def", "safeMakeDirs", "(", "path", ",", "mode", "=", "0o777", ")", ":", "try", ":", "os", ".", "makedirs", "(", "path", ",", "mode", ")", "return", "True", "except", "OSError", ":", "return", "False" ]
Creates the given directory path, as well as intermediate directories. Catches any I/O exception, returning False in that case; otherwise, True is returned.
[ "Creates", "the", "given", "directory", "path", "as", "well", "as", "intermediate", "directories", ".", "Catches", "any", "I", "/", "O", "exception", "returning", "False", "in", "that", "case", ";", "otherwise", "True", "is", "returned", "." ]
b3d92cca5cce3653519bd032346b211c46a57d05
https://github.com/giancosta86/Iris/blob/b3d92cca5cce3653519bd032346b211c46a57d05/info/gianlucacosta/iris/io/utils.py#L17-L28
train
Makes the given directory path as well as intermediate directories. Returns True if successful False otherwise.
giancosta86/Iris
info/gianlucacosta/iris/io/utils.py
PathOperations.touch
def touch(path): """ Creates the given path as a file, also creating intermediate directories if required. """ parentDirPath = os.path.dirname(path) PathOperations.safeMakeDirs(parentDirPath) with open(path, "wb"): pass
python
def touch(path): """ Creates the given path as a file, also creating intermediate directories if required. """ parentDirPath = os.path.dirname(path) PathOperations.safeMakeDirs(parentDirPath) with open(path, "wb"): pass
[ "def", "touch", "(", "path", ")", ":", "parentDirPath", "=", "os", ".", "path", ".", "dirname", "(", "path", ")", "PathOperations", ".", "safeMakeDirs", "(", "parentDirPath", ")", "with", "open", "(", "path", ",", "\"wb\"", ")", ":", "pass" ]
Creates the given path as a file, also creating intermediate directories if required.
[ "Creates", "the", "given", "path", "as", "a", "file", "also", "creating", "intermediate", "directories", "if", "required", "." ]
b3d92cca5cce3653519bd032346b211c46a57d05
https://github.com/giancosta86/Iris/blob/b3d92cca5cce3653519bd032346b211c46a57d05/info/gianlucacosta/iris/io/utils.py#L47-L57
train
Creates a file with the given path as a file.
giancosta86/Iris
info/gianlucacosta/iris/io/utils.py
PathOperations.safeRmTree
def safeRmTree(rootPath): """ Deletes a tree and returns true if it was correctly deleted """ shutil.rmtree(rootPath, True) return not os.path.exists(rootPath)
python
def safeRmTree(rootPath): """ Deletes a tree and returns true if it was correctly deleted """ shutil.rmtree(rootPath, True) return not os.path.exists(rootPath)
[ "def", "safeRmTree", "(", "rootPath", ")", ":", "shutil", ".", "rmtree", "(", "rootPath", ",", "True", ")", "return", "not", "os", ".", "path", ".", "exists", "(", "rootPath", ")" ]
Deletes a tree and returns true if it was correctly deleted
[ "Deletes", "a", "tree", "and", "returns", "true", "if", "it", "was", "correctly", "deleted" ]
b3d92cca5cce3653519bd032346b211c46a57d05
https://github.com/giancosta86/Iris/blob/b3d92cca5cce3653519bd032346b211c46a57d05/info/gianlucacosta/iris/io/utils.py#L61-L67
train
Delete a tree and returns true if it was correctly deleted.
giancosta86/Iris
info/gianlucacosta/iris/io/utils.py
PathOperations.linearWalk
def linearWalk(rootPath, currentDirFilter=None): """ Returns a list of LinearWalkItem's, one for each file in the tree whose root is "rootPath". The parameter "currentDirFilter" is a method applied to every tuple (dirPath, dirNames, fileNames) automatically processed by os.walk(): ...
python
def linearWalk(rootPath, currentDirFilter=None): """ Returns a list of LinearWalkItem's, one for each file in the tree whose root is "rootPath". The parameter "currentDirFilter" is a method applied to every tuple (dirPath, dirNames, fileNames) automatically processed by os.walk(): ...
[ "def", "linearWalk", "(", "rootPath", ",", "currentDirFilter", "=", "None", ")", ":", "for", "dirTuple", "in", "os", ".", "walk", "(", "rootPath", ")", ":", "(", "dirPath", ",", "dirNames", ",", "fileNames", ")", "=", "dirTuple", "if", "currentDirFilter", ...
Returns a list of LinearWalkItem's, one for each file in the tree whose root is "rootPath". The parameter "currentDirFilter" is a method applied to every tuple (dirPath, dirNames, fileNames) automatically processed by os.walk(): --it can modify its "dirNames" parameter, so as to prevent ...
[ "Returns", "a", "list", "of", "LinearWalkItem", "s", "one", "for", "each", "file", "in", "the", "tree", "whose", "root", "is", "rootPath", "." ]
b3d92cca5cce3653519bd032346b211c46a57d05
https://github.com/giancosta86/Iris/blob/b3d92cca5cce3653519bd032346b211c46a57d05/info/gianlucacosta/iris/io/utils.py#L71-L99
train
Returns a list of LinearWalkItem s one for each file in the tree whose root is rootPath.
BernardFW/bernard
src/bernard/cli/_base.py
init_live_reload
def init_live_reload(run): """ Start the live reload task :param run: run the task inside of this function or just create it """ from asyncio import get_event_loop from ._live_reload import start_child loop = get_event_loop() if run: loop.run_until_complete(start_child()) ...
python
def init_live_reload(run): """ Start the live reload task :param run: run the task inside of this function or just create it """ from asyncio import get_event_loop from ._live_reload import start_child loop = get_event_loop() if run: loop.run_until_complete(start_child()) ...
[ "def", "init_live_reload", "(", "run", ")", ":", "from", "asyncio", "import", "get_event_loop", "from", ".", "_live_reload", "import", "start_child", "loop", "=", "get_event_loop", "(", ")", "if", "run", ":", "loop", ".", "run_until_complete", "(", "start_child"...
Start the live reload task :param run: run the task inside of this function or just create it
[ "Start", "the", "live", "reload", "task" ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/cli/_base.py#L20-L34
train
Start the live reload task
pyQode/pyqode.cobol
pyqode/cobol/api/parsers/names.py
cmp_name
def cmp_name(first_node, second_node): """ Compare two name recursively. :param first_node: First node :param second_node: Second state :return: 0 if same name, 1 if names are differents. """ if len(first_node.children) == len(second_node.children): for first_child, second_child i...
python
def cmp_name(first_node, second_node): """ Compare two name recursively. :param first_node: First node :param second_node: Second state :return: 0 if same name, 1 if names are differents. """ if len(first_node.children) == len(second_node.children): for first_child, second_child i...
[ "def", "cmp_name", "(", "first_node", ",", "second_node", ")", ":", "if", "len", "(", "first_node", ".", "children", ")", "==", "len", "(", "second_node", ".", "children", ")", ":", "for", "first_child", ",", "second_child", "in", "zip", "(", "first_node",...
Compare two name recursively. :param first_node: First node :param second_node: Second state :return: 0 if same name, 1 if names are differents.
[ "Compare", "two", "name", "recursively", "." ]
eedae4e320a4b2d0c44abb2c3061091321648fb7
https://github.com/pyQode/pyqode.cobol/blob/eedae4e320a4b2d0c44abb2c3061091321648fb7/pyqode/cobol/api/parsers/names.py#L99-L122
train
Compare two name recursively.
pyQode/pyqode.cobol
pyqode/cobol/api/parsers/names.py
parse_division
def parse_division(l, c, line, root_node, last_section_node): """ Extracts a division node from a line :param l: The line number (starting from 0) :param c: The column number :param line: The line string (without indentation) :param root_node: The document root node. :return: tuple(last...
python
def parse_division(l, c, line, root_node, last_section_node): """ Extracts a division node from a line :param l: The line number (starting from 0) :param c: The column number :param line: The line string (without indentation) :param root_node: The document root node. :return: tuple(last...
[ "def", "parse_division", "(", "l", ",", "c", ",", "line", ",", "root_node", ",", "last_section_node", ")", ":", "name", "=", "line", "name", "=", "name", ".", "replace", "(", "\".\"", ",", "\"\"", ")", "# trim whitespaces/tabs between XXX and DIVISION", "token...
Extracts a division node from a line :param l: The line number (starting from 0) :param c: The column number :param line: The line string (without indentation) :param root_node: The document root node. :return: tuple(last_div_node, last_section_node)
[ "Extracts", "a", "division", "node", "from", "a", "line" ]
eedae4e320a4b2d0c44abb2c3061091321648fb7
https://github.com/pyQode/pyqode.cobol/blob/eedae4e320a4b2d0c44abb2c3061091321648fb7/pyqode/cobol/api/parsers/names.py#L125-L150
train
Parses a line of a file into a node.
pyQode/pyqode.cobol
pyqode/cobol/api/parsers/names.py
parse_section
def parse_section(l, c, last_div_node, last_vars, line): """ Extracts a section node from a line. :param l: The line number (starting from 0) :param last_div_node: The last div node found :param last_vars: The last vars dict :param line: The line string (without indentation) :return: la...
python
def parse_section(l, c, last_div_node, last_vars, line): """ Extracts a section node from a line. :param l: The line number (starting from 0) :param last_div_node: The last div node found :param last_vars: The last vars dict :param line: The line string (without indentation) :return: la...
[ "def", "parse_section", "(", "l", ",", "c", ",", "last_div_node", ",", "last_vars", ",", "line", ")", ":", "name", "=", "line", "name", "=", "name", ".", "replace", "(", "\".\"", ",", "\"\"", ")", "node", "=", "Name", "(", "Name", ".", "Type", ".",...
Extracts a section node from a line. :param l: The line number (starting from 0) :param last_div_node: The last div node found :param last_vars: The last vars dict :param line: The line string (without indentation) :return: last_section_node
[ "Extracts", "a", "section", "node", "from", "a", "line", "." ]
eedae4e320a4b2d0c44abb2c3061091321648fb7
https://github.com/pyQode/pyqode.cobol/blob/eedae4e320a4b2d0c44abb2c3061091321648fb7/pyqode/cobol/api/parsers/names.py#L153-L174
train
Extracts a section node from a line.
pyQode/pyqode.cobol
pyqode/cobol/api/parsers/names.py
parse_pic_field
def parse_pic_field(l, c, last_section_node, last_vars, line): """ Parse a pic field line. Return A VariableNode or None in case of malformed code. :param l: The line number (starting from 0) :param c: The column number (starting from 0) :param last_section_node: The last section node found ...
python
def parse_pic_field(l, c, last_section_node, last_vars, line): """ Parse a pic field line. Return A VariableNode or None in case of malformed code. :param l: The line number (starting from 0) :param c: The column number (starting from 0) :param last_section_node: The last section node found ...
[ "def", "parse_pic_field", "(", "l", ",", "c", ",", "last_section_node", ",", "last_vars", ",", "line", ")", ":", "parent_node", "=", "None", "raw_tokens", "=", "line", ".", "split", "(", "\" \"", ")", "tokens", "=", "[", "]", "for", "t", "in", "raw_tok...
Parse a pic field line. Return A VariableNode or None in case of malformed code. :param l: The line number (starting from 0) :param c: The column number (starting from 0) :param last_section_node: The last section node found :param last_vars: The last vars dict :param line: The line string (wit...
[ "Parse", "a", "pic", "field", "line", ".", "Return", "A", "VariableNode", "or", "None", "in", "case", "of", "malformed", "code", "." ]
eedae4e320a4b2d0c44abb2c3061091321648fb7
https://github.com/pyQode/pyqode.cobol/blob/eedae4e320a4b2d0c44abb2c3061091321648fb7/pyqode/cobol/api/parsers/names.py#L177-L248
train
Parses a pic field line. Returns A VariableNode or None if the line is malformed.
pyQode/pyqode.cobol
pyqode/cobol/api/parsers/names.py
parse_paragraph
def parse_paragraph(l, c, last_div_node, last_section_node, line): """ Extracts a paragraph node :param l: The line number (starting from 0) :param last_div_node: The last div node found :param last_section_node: The last section node found :param line: The line string (without indentation) ...
python
def parse_paragraph(l, c, last_div_node, last_section_node, line): """ Extracts a paragraph node :param l: The line number (starting from 0) :param last_div_node: The last div node found :param last_section_node: The last section node found :param line: The line string (without indentation) ...
[ "def", "parse_paragraph", "(", "l", ",", "c", ",", "last_div_node", ",", "last_section_node", ",", "line", ")", ":", "if", "not", "line", ".", "endswith", "(", "'.'", ")", ":", "return", "None", "name", "=", "line", ".", "replace", "(", "\".\"", ",", ...
Extracts a paragraph node :param l: The line number (starting from 0) :param last_div_node: The last div node found :param last_section_node: The last section node found :param line: The line string (without indentation) :return: The extracted paragraph node
[ "Extracts", "a", "paragraph", "node" ]
eedae4e320a4b2d0c44abb2c3061091321648fb7
https://github.com/pyQode/pyqode.cobol/blob/eedae4e320a4b2d0c44abb2c3061091321648fb7/pyqode/cobol/api/parsers/names.py#L251-L273
train
Parses a line of text into a node.
pyQode/pyqode.cobol
pyqode/cobol/api/parsers/names.py
defined_names
def defined_names(code, free_format=False): """ Parses a cobol document and build a name tree. For convenience, it also returns the list of variables (PIC) and procedures (paragraphs). :param code: cobol code to parse. Default is None. :param free_format: True if the source code must be consid...
python
def defined_names(code, free_format=False): """ Parses a cobol document and build a name tree. For convenience, it also returns the list of variables (PIC) and procedures (paragraphs). :param code: cobol code to parse. Default is None. :param free_format: True if the source code must be consid...
[ "def", "defined_names", "(", "code", ",", "free_format", "=", "False", ")", ":", "root_node", "=", "Name", "(", "Name", ".", "Type", ".", "Root", ",", "0", ",", "0", ",", "'root'", ")", "variables", "=", "[", "]", "paragraphs", "=", "[", "]", "line...
Parses a cobol document and build a name tree. For convenience, it also returns the list of variables (PIC) and procedures (paragraphs). :param code: cobol code to parse. Default is None. :param free_format: True if the source code must be considered as coded in free format. :return: A tu...
[ "Parses", "a", "cobol", "document", "and", "build", "a", "name", "tree", "." ]
eedae4e320a4b2d0c44abb2c3061091321648fb7
https://github.com/pyQode/pyqode.cobol/blob/eedae4e320a4b2d0c44abb2c3061091321648fb7/pyqode/cobol/api/parsers/names.py#L276-L360
train
Parses a cobol code and returns a tuple of names and their associated procedures.
pyQode/pyqode.cobol
pyqode/cobol/api/parsers/names.py
Name.find
def find(self, name): """ Finds a possible child whose name match the name parameter. :param name: name of the child node to look up :type name: str :return: DocumentNode or None """ for c in self.children: if c.name == name: return c...
python
def find(self, name): """ Finds a possible child whose name match the name parameter. :param name: name of the child node to look up :type name: str :return: DocumentNode or None """ for c in self.children: if c.name == name: return c...
[ "def", "find", "(", "self", ",", "name", ")", ":", "for", "c", "in", "self", ".", "children", ":", "if", "c", ".", "name", "==", "name", ":", "return", "c", "result", "=", "c", ".", "find", "(", "name", ")", "if", "result", ":", "return", "resu...
Finds a possible child whose name match the name parameter. :param name: name of the child node to look up :type name: str :return: DocumentNode or None
[ "Finds", "a", "possible", "child", "whose", "name", "match", "the", "name", "parameter", "." ]
eedae4e320a4b2d0c44abb2c3061091321648fb7
https://github.com/pyQode/pyqode.cobol/blob/eedae4e320a4b2d0c44abb2c3061091321648fb7/pyqode/cobol/api/parsers/names.py#L55-L69
train
Finds a possible child whose name matches the name parameter.
pyQode/pyqode.cobol
pyqode/cobol/api/parsers/names.py
Name.to_definition
def to_definition(self): """ Converts the name instance to a pyqode.core.share.Definition """ icon = { Name.Type.Root: icons.ICON_MIMETYPE, Name.Type.Division: icons.ICON_DIVISION, Name.Type.Section: icons.ICON_SECTION, Name.Type.Variable: ...
python
def to_definition(self): """ Converts the name instance to a pyqode.core.share.Definition """ icon = { Name.Type.Root: icons.ICON_MIMETYPE, Name.Type.Division: icons.ICON_DIVISION, Name.Type.Section: icons.ICON_SECTION, Name.Type.Variable: ...
[ "def", "to_definition", "(", "self", ")", ":", "icon", "=", "{", "Name", ".", "Type", ".", "Root", ":", "icons", ".", "ICON_MIMETYPE", ",", "Name", ".", "Type", ".", "Division", ":", "icons", ".", "ICON_DIVISION", ",", "Name", ".", "Type", ".", "Sect...
Converts the name instance to a pyqode.core.share.Definition
[ "Converts", "the", "name", "instance", "to", "a", "pyqode", ".", "core", ".", "share", ".", "Definition" ]
eedae4e320a4b2d0c44abb2c3061091321648fb7
https://github.com/pyQode/pyqode.cobol/blob/eedae4e320a4b2d0c44abb2c3061091321648fb7/pyqode/cobol/api/parsers/names.py#L82-L96
train
Converts the name instance to a pyqode. core. share. Definition object.
jstitch/MambuPy
MambuPy/mambuutil.py
connectDb
def connectDb(engine = dbeng, user = dbuser, password = dbpwd, host = dbhost, port = dbport, database = dbname, params = "?charset=utf8&use_unicode=1", echoopt = False): """Connect to database utility ...
python
def connectDb(engine = dbeng, user = dbuser, password = dbpwd, host = dbhost, port = dbport, database = dbname, params = "?charset=utf8&use_unicode=1", echoopt = False): """Connect to database utility ...
[ "def", "connectDb", "(", "engine", "=", "dbeng", ",", "user", "=", "dbuser", ",", "password", "=", "dbpwd", ",", "host", "=", "dbhost", ",", "port", "=", "dbport", ",", "database", "=", "dbname", ",", "params", "=", "\"?charset=utf8&use_unicode=1\"", ",", ...
Connect to database utility function. Uses SQLAlchemy ORM library. Useful when using schema modules in MambuPy
[ "Connect", "to", "database", "utility", "function", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/mambuutil.py#L67-L81
train
Connect to database utility function.
jstitch/MambuPy
MambuPy/mambuutil.py
getbranchesurl
def getbranchesurl(idbranch, *args, **kwargs): """Request Branches URL. If idbranch is set, you'll get a response adequate for a MambuBranch object. If not set, you'll get a response adequate for a MambuBranches object. See mambubranch module and pydoc for further information. Currently implemente...
python
def getbranchesurl(idbranch, *args, **kwargs): """Request Branches URL. If idbranch is set, you'll get a response adequate for a MambuBranch object. If not set, you'll get a response adequate for a MambuBranches object. See mambubranch module and pydoc for further information. Currently implemente...
[ "def", "getbranchesurl", "(", "idbranch", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "getparams", "=", "[", "]", "if", "kwargs", ":", "try", ":", "if", "kwargs", "[", "\"fullDetails\"", "]", "==", "True", ":", "getparams", ".", "append", "(...
Request Branches URL. If idbranch is set, you'll get a response adequate for a MambuBranch object. If not set, you'll get a response adequate for a MambuBranches object. See mambubranch module and pydoc for further information. Currently implemented filter parameters: * fullDetails * limit ...
[ "Request", "Branches", "URL", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/mambuutil.py#L100-L135
train
Request Branches URL.
jstitch/MambuPy
MambuPy/mambuutil.py
getcentresurl
def getcentresurl(idcentre, *args, **kwargs): """Request Centres URL. If idcentre is set, you'll get a response adequate for a MambuCentre object. If not set, you'll get a response adequate for a MambuCentres object. See mambucentre module and pydoc for further information. Currently implemented f...
python
def getcentresurl(idcentre, *args, **kwargs): """Request Centres URL. If idcentre is set, you'll get a response adequate for a MambuCentre object. If not set, you'll get a response adequate for a MambuCentres object. See mambucentre module and pydoc for further information. Currently implemented f...
[ "def", "getcentresurl", "(", "idcentre", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "getparams", "=", "[", "]", "if", "kwargs", ":", "try", ":", "if", "kwargs", "[", "\"fullDetails\"", "]", "==", "True", ":", "getparams", ".", "append", "("...
Request Centres URL. If idcentre is set, you'll get a response adequate for a MambuCentre object. If not set, you'll get a response adequate for a MambuCentres object. See mambucentre module and pydoc for further information. Currently implemented filter parameters: * fullDetails * limit *...
[ "Request", "Centres", "URL", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/mambuutil.py#L137-L172
train
Request Centres URL.
jstitch/MambuPy
MambuPy/mambuutil.py
getrepaymentsurl
def getrepaymentsurl(idcred, *args, **kwargs): """Request loan Repayments URL. If idcred is set, you'll get a response adequate for a MambuRepayments object. There's a MambuRepayment object too, but you'll get a list first and each element of it will be automatically converted to a MambuRepayment o...
python
def getrepaymentsurl(idcred, *args, **kwargs): """Request loan Repayments URL. If idcred is set, you'll get a response adequate for a MambuRepayments object. There's a MambuRepayment object too, but you'll get a list first and each element of it will be automatically converted to a MambuRepayment o...
[ "def", "getrepaymentsurl", "(", "idcred", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "url", "=", "getmambuurl", "(", "*", "args", ",", "*", "*", "kwargs", ")", "+", "\"loans/\"", "+", "idcred", "+", "\"/repayments\"", "return", "url" ]
Request loan Repayments URL. If idcred is set, you'll get a response adequate for a MambuRepayments object. There's a MambuRepayment object too, but you'll get a list first and each element of it will be automatically converted to a MambuRepayment object that you may use. If not set, you'll get a ...
[ "Request", "loan", "Repayments", "URL", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/mambuutil.py#L174-L195
train
Request loan Repayments URL.
jstitch/MambuPy
MambuPy/mambuutil.py
getloansurl
def getloansurl(idcred, *args, **kwargs): """Request Loans URL. If idcred is set, you'll get a response adequate for a MambuLoan object. If not set, you'll get a response adequate for a MambuLoans object. See mambuloan module and pydoc for further information. Currently implemented filter paramete...
python
def getloansurl(idcred, *args, **kwargs): """Request Loans URL. If idcred is set, you'll get a response adequate for a MambuLoan object. If not set, you'll get a response adequate for a MambuLoans object. See mambuloan module and pydoc for further information. Currently implemented filter paramete...
[ "def", "getloansurl", "(", "idcred", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "getparams", "=", "[", "]", "if", "kwargs", ":", "try", ":", "if", "kwargs", "[", "\"fullDetails\"", "]", "==", "True", ":", "getparams", ".", "append", "(", ...
Request Loans URL. If idcred is set, you'll get a response adequate for a MambuLoan object. If not set, you'll get a response adequate for a MambuLoans object. See mambuloan module and pydoc for further information. Currently implemented filter parameters: * fullDetails * accountState * br...
[ "Request", "Loans", "URL", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/mambuutil.py#L197-L252
train
Request Loans URL.
jstitch/MambuPy
MambuPy/mambuutil.py
getgroupurl
def getgroupurl(idgroup, *args, **kwargs): """Request Groups URL. If idgroup is set, you'll get a response adequate for a MambuGroup object. If not set, you'll get a response adequate for a MambuGroups object. See mambugroup module and pydoc for further information. Currently implemented filter pa...
python
def getgroupurl(idgroup, *args, **kwargs): """Request Groups URL. If idgroup is set, you'll get a response adequate for a MambuGroup object. If not set, you'll get a response adequate for a MambuGroups object. See mambugroup module and pydoc for further information. Currently implemented filter pa...
[ "def", "getgroupurl", "(", "idgroup", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "getparams", "=", "[", "]", "if", "kwargs", ":", "try", ":", "if", "kwargs", "[", "\"fullDetails\"", "]", "==", "True", ":", "getparams", ".", "append", "(", ...
Request Groups URL. If idgroup is set, you'll get a response adequate for a MambuGroup object. If not set, you'll get a response adequate for a MambuGroups object. See mambugroup module and pydoc for further information. Currently implemented filter parameters: * fullDetails * creditOfficerUse...
[ "Request", "Groups", "URL", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/mambuutil.py#L254-L303
train
Request Groups URL.
jstitch/MambuPy
MambuPy/mambuutil.py
getgrouploansurl
def getgrouploansurl(idgroup, *args, **kwargs): """Request Group loans URL. How to use it? By default MambuLoan uses getloansurl as the urlfunc. Override that behaviour by sending getgrouploansurl (this function) as the urlfunc to the constructor of MambuLoans (note the final 's') and voila! you ge...
python
def getgrouploansurl(idgroup, *args, **kwargs): """Request Group loans URL. How to use it? By default MambuLoan uses getloansurl as the urlfunc. Override that behaviour by sending getgrouploansurl (this function) as the urlfunc to the constructor of MambuLoans (note the final 's') and voila! you ge...
[ "def", "getgrouploansurl", "(", "idgroup", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "getparams", "=", "[", "]", "if", "kwargs", ":", "try", ":", "if", "kwargs", "[", "\"fullDetails\"", "]", "==", "True", ":", "getparams", ".", "append", "...
Request Group loans URL. How to use it? By default MambuLoan uses getloansurl as the urlfunc. Override that behaviour by sending getgrouploansurl (this function) as the urlfunc to the constructor of MambuLoans (note the final 's') and voila! you get the Loans just for a certain group. If idgroup i...
[ "Request", "Group", "loans", "URL", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/mambuutil.py#L305-L344
train
Request Group loans URL.
jstitch/MambuPy
MambuPy/mambuutil.py
getgroupcustominformationurl
def getgroupcustominformationurl(idgroup, customfield="", *args, **kwargs): """Request Group Custom Information URL. See mambugroup module and pydoc for further information. See Mambu official developer documentation for further details, and info on parameters that may be implemented here in the futur...
python
def getgroupcustominformationurl(idgroup, customfield="", *args, **kwargs): """Request Group Custom Information URL. See mambugroup module and pydoc for further information. See Mambu official developer documentation for further details, and info on parameters that may be implemented here in the futur...
[ "def", "getgroupcustominformationurl", "(", "idgroup", ",", "customfield", "=", "\"\"", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "groupidparam", "=", "\"/\"", "+", "idgroup", "url", "=", "getmambuurl", "(", "*", "args", ",", "*", "*", "kwargs...
Request Group Custom Information URL. See mambugroup module and pydoc for further information. See Mambu official developer documentation for further details, and info on parameters that may be implemented here in the future.
[ "Request", "Group", "Custom", "Information", "URL", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/mambuutil.py#L346-L356
train
Request Group Custom Information URL.
jstitch/MambuPy
MambuPy/mambuutil.py
gettransactionsurl
def gettransactionsurl(idcred, *args, **kwargs): """Request loan Transactions URL. If idcred is set, you'll get a response adequate for a MambuTransactions object. There's a MambuTransaction object too, but you'll get a list first and each element of it will be automatically converted to a MambuTra...
python
def gettransactionsurl(idcred, *args, **kwargs): """Request loan Transactions URL. If idcred is set, you'll get a response adequate for a MambuTransactions object. There's a MambuTransaction object too, but you'll get a list first and each element of it will be automatically converted to a MambuTra...
[ "def", "gettransactionsurl", "(", "idcred", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "getparams", "=", "[", "]", "if", "kwargs", ":", "try", ":", "getparams", ".", "append", "(", "\"offset=%s\"", "%", "kwargs", "[", "\"offset\"", "]", ")", ...
Request loan Transactions URL. If idcred is set, you'll get a response adequate for a MambuTransactions object. There's a MambuTransaction object too, but you'll get a list first and each element of it will be automatically converted to a MambuTransaction object that you may use. If not set, you'l...
[ "Request", "loan", "Transactions", "URL", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/mambuutil.py#L358-L391
train
Request loan Transactions URL.
jstitch/MambuPy
MambuPy/mambuutil.py
getclienturl
def getclienturl(idclient, *args, **kwargs): """Request Clients URL. If idclient is set, you'll get a response adequate for a MambuClient object. If not set, you'll get a response adequate for a MambuClients object. See mambuclient module and pydoc for further information. Currently implemented fi...
python
def getclienturl(idclient, *args, **kwargs): """Request Clients URL. If idclient is set, you'll get a response adequate for a MambuClient object. If not set, you'll get a response adequate for a MambuClients object. See mambuclient module and pydoc for further information. Currently implemented fi...
[ "def", "getclienturl", "(", "idclient", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "getparams", "=", "[", "]", "if", "kwargs", ":", "try", ":", "if", "kwargs", "[", "\"fullDetails\"", "]", "==", "True", ":", "getparams", ".", "append", "(",...
Request Clients URL. If idclient is set, you'll get a response adequate for a MambuClient object. If not set, you'll get a response adequate for a MambuClients object. See mambuclient module and pydoc for further information. Currently implemented filter parameters: * fullDetails * firstName ...
[ "Request", "Clients", "URL", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/mambuutil.py#L393-L452
train
Request Clients URL.
jstitch/MambuPy
MambuPy/mambuutil.py
getclientloansurl
def getclientloansurl(idclient, *args, **kwargs): """Request Client loans URL. How to use it? By default MambuLoan uses getloansurl as the urlfunc. Override that behaviour by sending getclientloansurl (this function) as the urlfunc to the constructor of MambuLoans (note the final 's') and voila! yo...
python
def getclientloansurl(idclient, *args, **kwargs): """Request Client loans URL. How to use it? By default MambuLoan uses getloansurl as the urlfunc. Override that behaviour by sending getclientloansurl (this function) as the urlfunc to the constructor of MambuLoans (note the final 's') and voila! yo...
[ "def", "getclientloansurl", "(", "idclient", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "getparams", "=", "[", "]", "if", "kwargs", ":", "try", ":", "if", "kwargs", "[", "\"fullDetails\"", "]", "==", "True", ":", "getparams", ".", "append", ...
Request Client loans URL. How to use it? By default MambuLoan uses getloansurl as the urlfunc. Override that behaviour by sending getclientloansurl (this function) as the urlfunc to the constructor of MambuLoans (note the final 's') and voila! you get the Loans just for a certain client. If idclie...
[ "Request", "Client", "loans", "URL", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/mambuutil.py#L454-L493
train
Request Client loans URL.
jstitch/MambuPy
MambuPy/mambuutil.py
getclientcustominformationurl
def getclientcustominformationurl(idclient, customfield="", *args, **kwargs): """Request Client Custom Information URL. See mambugroup module and pydoc for further information. See Mambu official developer documentation for further details, and info on parameters that may be implemented here in the fu...
python
def getclientcustominformationurl(idclient, customfield="", *args, **kwargs): """Request Client Custom Information URL. See mambugroup module and pydoc for further information. See Mambu official developer documentation for further details, and info on parameters that may be implemented here in the fu...
[ "def", "getclientcustominformationurl", "(", "idclient", ",", "customfield", "=", "\"\"", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "clientidparam", "=", "\"/\"", "+", "idclient", "url", "=", "getmambuurl", "(", "*", "args", ",", "*", "*", "kw...
Request Client Custom Information URL. See mambugroup module and pydoc for further information. See Mambu official developer documentation for further details, and info on parameters that may be implemented here in the future.
[ "Request", "Client", "Custom", "Information", "URL", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/mambuutil.py#L495-L505
train
Request Client Custom Information URL.
jstitch/MambuPy
MambuPy/mambuutil.py
getuserurl
def getuserurl(iduser, *args, **kwargs): """Request Users URL. If iduser is set, you'll get a response adequate for a MambuUser object. If not set, you'll get a response adequate for a MambuUsers object. See mambuuser module and pydoc for further information. Currently implemented filter parameter...
python
def getuserurl(iduser, *args, **kwargs): """Request Users URL. If iduser is set, you'll get a response adequate for a MambuUser object. If not set, you'll get a response adequate for a MambuUsers object. See mambuuser module and pydoc for further information. Currently implemented filter parameter...
[ "def", "getuserurl", "(", "iduser", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "getparams", "=", "[", "]", "if", "kwargs", ":", "try", ":", "if", "kwargs", "[", "\"fullDetails\"", "]", "==", "True", ":", "getparams", ".", "append", "(", "...
Request Users URL. If iduser is set, you'll get a response adequate for a MambuUser object. If not set, you'll get a response adequate for a MambuUsers object. See mambuuser module and pydoc for further information. Currently implemented filter parameters: * fullDetails * branchId * limit ...
[ "Request", "Users", "URL", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/mambuutil.py#L507-L546
train
Request Users URL.
jstitch/MambuPy
MambuPy/mambuutil.py
getproductsurl
def getproductsurl(idproduct, *args, **kwargs): """Request loan Products URL. If idproduct is set, you'll get a response adequate for a MambuProduct object. If not set, you'll get a response adequate for a MambuProducts object. See mambuproduct module and pydoc for further information. No current ...
python
def getproductsurl(idproduct, *args, **kwargs): """Request loan Products URL. If idproduct is set, you'll get a response adequate for a MambuProduct object. If not set, you'll get a response adequate for a MambuProducts object. See mambuproduct module and pydoc for further information. No current ...
[ "def", "getproductsurl", "(", "idproduct", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "productidparam", "=", "\"\"", "if", "idproduct", "==", "\"\"", "else", "\"/\"", "+", "idproduct", "url", "=", "getmambuurl", "(", "*", "args", ",", "*", "*...
Request loan Products URL. If idproduct is set, you'll get a response adequate for a MambuProduct object. If not set, you'll get a response adequate for a MambuProducts object. See mambuproduct module and pydoc for further information. No current implemented filter parameters. See Mambu official ...
[ "Request", "loan", "Products", "URL", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/mambuutil.py#L548-L562
train
Request loan Products URL.
jstitch/MambuPy
MambuPy/mambuutil.py
gettasksurl
def gettasksurl(dummyId='', *args, **kwargs): """Request Tasks URL. dummyId is used because MambuStruct always requires an Id from an entity, but the Mambu API doesn't requires it for Tasks, because of that dummyId defaults to '', but in practice it is never used (if someone sends dummyId='someId' ...
python
def gettasksurl(dummyId='', *args, **kwargs): """Request Tasks URL. dummyId is used because MambuStruct always requires an Id from an entity, but the Mambu API doesn't requires it for Tasks, because of that dummyId defaults to '', but in practice it is never used (if someone sends dummyId='someId' ...
[ "def", "gettasksurl", "(", "dummyId", "=", "''", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "getparams", "=", "[", "]", "if", "kwargs", ":", "try", ":", "getparams", ".", "append", "(", "\"username=%s\"", "%", "kwargs", "[", "\"username\"", ...
Request Tasks URL. dummyId is used because MambuStruct always requires an Id from an entity, but the Mambu API doesn't requires it for Tasks, because of that dummyId defaults to '', but in practice it is never used (if someone sends dummyId='someId' nothing happens). The fact of forcing to send an ...
[ "Request", "Tasks", "URL", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/mambuutil.py#L564-L620
train
Request Tasks URL.
jstitch/MambuPy
MambuPy/mambuutil.py
getactivitiesurl
def getactivitiesurl(dummyId='', *args, **kwargs): """Request Activities URL. dummyId is used because MambuStruct always requires an Id from an entity, but the Mambu API doesn't requires it for Activities, because of that dummyId defaults to '', but in practice it is never used (if someone sends du...
python
def getactivitiesurl(dummyId='', *args, **kwargs): """Request Activities URL. dummyId is used because MambuStruct always requires an Id from an entity, but the Mambu API doesn't requires it for Activities, because of that dummyId defaults to '', but in practice it is never used (if someone sends du...
[ "def", "getactivitiesurl", "(", "dummyId", "=", "''", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "datetime", "import", "datetime", "getparams", "=", "[", "]", "if", "kwargs", ":", "try", ":", "getparams", ".", "append", "(", "\"from=%...
Request Activities URL. dummyId is used because MambuStruct always requires an Id from an entity, but the Mambu API doesn't requires it for Activities, because of that dummyId defaults to '', but in practice it is never used (if someone sends dummyId='someId' nothing happens). The fact of forcing t...
[ "Request", "Activities", "URL", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/mambuutil.py#L622-L697
train
Request Activities URL.
jstitch/MambuPy
MambuPy/mambuutil.py
getrolesurl
def getrolesurl(idrole='', *args, **kwargs): """Request Roles URL. If idrole is set, you'll get a response adequate for a MambuRole object. If not set, you'll get a response adequate for a MambuRoles object too. See mamburoles module and pydoc for further information. See Mambu official deve...
python
def getrolesurl(idrole='', *args, **kwargs): """Request Roles URL. If idrole is set, you'll get a response adequate for a MambuRole object. If not set, you'll get a response adequate for a MambuRoles object too. See mamburoles module and pydoc for further information. See Mambu official deve...
[ "def", "getrolesurl", "(", "idrole", "=", "''", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "url", "=", "getmambuurl", "(", "*", "args", ",", "*", "*", "kwargs", ")", "+", "\"userroles\"", "+", "(", "(", "\"/\"", "+", "idrole", ")", "if"...
Request Roles URL. If idrole is set, you'll get a response adequate for a MambuRole object. If not set, you'll get a response adequate for a MambuRoles object too. See mamburoles module and pydoc for further information. See Mambu official developer documentation for further details.
[ "Request", "Roles", "URL", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/mambuutil.py#L699-L710
train
Request Roles URL.
jstitch/MambuPy
MambuPy/mambuutil.py
strip_tags
def strip_tags(html): """Stripts HTML tags from text. Note fields on several Mambu entities come with additional HTML tags (they are rich text fields, I guess that's why). Sometimes they are useless, so stripping them is a good idea. """ from html.parser import HTMLParser class MLStripper(H...
python
def strip_tags(html): """Stripts HTML tags from text. Note fields on several Mambu entities come with additional HTML tags (they are rich text fields, I guess that's why). Sometimes they are useless, so stripping them is a good idea. """ from html.parser import HTMLParser class MLStripper(H...
[ "def", "strip_tags", "(", "html", ")", ":", "from", "html", ".", "parser", "import", "HTMLParser", "class", "MLStripper", "(", "HTMLParser", ")", ":", "\"\"\"Aux class for stripping HTML tags.\n\n fields on several Mambu entities come with additional HTML tags\n (t...
Stripts HTML tags from text. Note fields on several Mambu entities come with additional HTML tags (they are rich text fields, I guess that's why). Sometimes they are useless, so stripping them is a good idea.
[ "Stripts", "HTML", "tags", "from", "text", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/mambuutil.py#L715-L744
train
Stripts HTML tags from text.
jstitch/MambuPy
MambuPy/mambuutil.py
strip_consecutive_repeated_char
def strip_consecutive_repeated_char(s, ch): """Strip characters in a string which are consecutively repeated. Useful when in notes or some other free text fields on Mambu, users capture anything and a lot of capture errors not always detected by Mambu get through. You want some cleaning? this may be us...
python
def strip_consecutive_repeated_char(s, ch): """Strip characters in a string which are consecutively repeated. Useful when in notes or some other free text fields on Mambu, users capture anything and a lot of capture errors not always detected by Mambu get through. You want some cleaning? this may be us...
[ "def", "strip_consecutive_repeated_char", "(", "s", ",", "ch", ")", ":", "sdest", "=", "\"\"", "for", "i", ",", "c", "in", "enumerate", "(", "s", ")", ":", "if", "i", "!=", "0", "and", "s", "[", "i", "]", "==", "ch", "and", "s", "[", "i", "]", ...
Strip characters in a string which are consecutively repeated. Useful when in notes or some other free text fields on Mambu, users capture anything and a lot of capture errors not always detected by Mambu get through. You want some cleaning? this may be useful. This is a string processing function.
[ "Strip", "characters", "in", "a", "string", "which", "are", "consecutively", "repeated", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/mambuutil.py#L747-L761
train
Strip characters in a string which are consecutively repeated.
jstitch/MambuPy
MambuPy/mambuutil.py
iriToUri
def iriToUri(iri): """Change an IRI (internationalized R) to an URI. Used at MambuStruct.connect() method for any requests done to Mambu. Perfect example of unicode getting in the way. Illustrative (I hope) example: I have Mambu usernames with special chars in them. When retrieving them and then ...
python
def iriToUri(iri): """Change an IRI (internationalized R) to an URI. Used at MambuStruct.connect() method for any requests done to Mambu. Perfect example of unicode getting in the way. Illustrative (I hope) example: I have Mambu usernames with special chars in them. When retrieving them and then ...
[ "def", "iriToUri", "(", "iri", ")", ":", "def", "urlEncodeNonAscii", "(", "b", ")", ":", "\"\"\"Encode Non ASCII chars to URL-friendly chars.\n\n Sometimes unicode gets in the way. A shame, I know. And perhaps the\n biggest shame is not me correctly handling it.\n \"\"\"...
Change an IRI (internationalized R) to an URI. Used at MambuStruct.connect() method for any requests done to Mambu. Perfect example of unicode getting in the way. Illustrative (I hope) example: I have Mambu usernames with special chars in them. When retrieving them and then trying to build a Mamb...
[ "Change", "an", "IRI", "(", "internationalized", "R", ")", "to", "an", "URI", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/mambuutil.py#L769-L808
train
Change an IRI to an URI.
jstitch/MambuPy
MambuPy/mambuutil.py
encoded_dict
def encoded_dict(in_dict): """Encode every value of a dict to UTF-8. Useful for POSTing requests on the 'data' parameter of urlencode. """ out_dict = {} for k, v in in_dict.items(): if isinstance(v, unicode): if sys.version_info < (3, 0): v = v.encode('utf8') ...
python
def encoded_dict(in_dict): """Encode every value of a dict to UTF-8. Useful for POSTing requests on the 'data' parameter of urlencode. """ out_dict = {} for k, v in in_dict.items(): if isinstance(v, unicode): if sys.version_info < (3, 0): v = v.encode('utf8') ...
[ "def", "encoded_dict", "(", "in_dict", ")", ":", "out_dict", "=", "{", "}", "for", "k", ",", "v", "in", "in_dict", ".", "items", "(", ")", ":", "if", "isinstance", "(", "v", ",", "unicode", ")", ":", "if", "sys", ".", "version_info", "<", "(", "3...
Encode every value of a dict to UTF-8. Useful for POSTing requests on the 'data' parameter of urlencode.
[ "Encode", "every", "value", "of", "a", "dict", "to", "UTF", "-", "8", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/mambuutil.py#L811-L826
train
Encode every value of a dict to UTF - 8.
jstitch/MambuPy
MambuPy/mambuutil.py
backup_db
def backup_db(callback, bool_func, output_fname, *args, **kwargs): """Backup Mambu Database via REST API. Makes two calls to Mambu API: - a POST to request a backup to be made - a GET, once the backup is ready, to download the latest backup * callback is a string to a callback URL Mambu will int...
python
def backup_db(callback, bool_func, output_fname, *args, **kwargs): """Backup Mambu Database via REST API. Makes two calls to Mambu API: - a POST to request a backup to be made - a GET, once the backup is ready, to download the latest backup * callback is a string to a callback URL Mambu will int...
[ "def", "backup_db", "(", "callback", ",", "bool_func", ",", "output_fname", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "datetime", "import", "datetime", "try", ":", "verbose", "=", "kwargs", "[", "'verbose'", "]", "except", "KeyError", ...
Backup Mambu Database via REST API. Makes two calls to Mambu API: - a POST to request a backup to be made - a GET, once the backup is ready, to download the latest backup * callback is a string to a callback URL Mambu will internally call when the backup is ready to download. You should have a...
[ "Backup", "Mambu", "Database", "via", "REST", "API", "." ]
2af98cc12e7ed5ec183b3e97644e880e70b79ee8
https://github.com/jstitch/MambuPy/blob/2af98cc12e7ed5ec183b3e97644e880e70b79ee8/MambuPy/mambuutil.py#L831-L959
train
Backup Mambu Database via REST API.
rsgalloway/grit
grit/server/cherrypy/ssl_builtin.py
BuiltinSSLAdapter.wrap
def wrap(self, sock): """Wrap and return the given socket, plus WSGI environ entries.""" try: s = ssl.wrap_socket(sock, do_handshake_on_connect=True, server_side=True, certfile=self.certificate, keyfile=self.private_key, ssl_version=ssl.PROTOCOL_SSLv23...
python
def wrap(self, sock): """Wrap and return the given socket, plus WSGI environ entries.""" try: s = ssl.wrap_socket(sock, do_handshake_on_connect=True, server_side=True, certfile=self.certificate, keyfile=self.private_key, ssl_version=ssl.PROTOCOL_SSLv23...
[ "def", "wrap", "(", "self", ",", "sock", ")", ":", "try", ":", "s", "=", "ssl", ".", "wrap_socket", "(", "sock", ",", "do_handshake_on_connect", "=", "True", ",", "server_side", "=", "True", ",", "certfile", "=", "self", ".", "certificate", ",", "keyfi...
Wrap and return the given socket, plus WSGI environ entries.
[ "Wrap", "and", "return", "the", "given", "socket", "plus", "WSGI", "environ", "entries", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/ssl_builtin.py#L37-L54
train
Wrap and return the given socket plus WSGI environ entries.
rsgalloway/grit
grit/server/cherrypy/ssl_builtin.py
BuiltinSSLAdapter.get_environ
def get_environ(self, sock): """Create WSGI environ entries to be merged into each request.""" cipher = sock.cipher() ssl_environ = { "wsgi.url_scheme": "https", "HTTPS": "on", 'SSL_PROTOCOL': cipher[1], 'SSL_CIPHER': cipher[0] ## SSL_VE...
python
def get_environ(self, sock): """Create WSGI environ entries to be merged into each request.""" cipher = sock.cipher() ssl_environ = { "wsgi.url_scheme": "https", "HTTPS": "on", 'SSL_PROTOCOL': cipher[1], 'SSL_CIPHER': cipher[0] ## SSL_VE...
[ "def", "get_environ", "(", "self", ",", "sock", ")", ":", "cipher", "=", "sock", ".", "cipher", "(", ")", "ssl_environ", "=", "{", "\"wsgi.url_scheme\"", ":", "\"https\"", ",", "\"HTTPS\"", ":", "\"on\"", ",", "'SSL_PROTOCOL'", ":", "cipher", "[", "1", "...
Create WSGI environ entries to be merged into each request.
[ "Create", "WSGI", "environ", "entries", "to", "be", "merged", "into", "each", "request", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/cherrypy/ssl_builtin.py#L57-L68
train
Create WSGI environ entries to be merged into each request.
polyaxon/hestia
hestia/memoize_decorators.py
memoize
def memoize(func): """ Provides memoization for methods on a specific instance. Results are cached for given parameter list. See also: http://en.wikipedia.org/wiki/Memoization N.B. The cache object gets added to the instance instead of the global scope. Therefore cached results are restricted ...
python
def memoize(func): """ Provides memoization for methods on a specific instance. Results are cached for given parameter list. See also: http://en.wikipedia.org/wiki/Memoization N.B. The cache object gets added to the instance instead of the global scope. Therefore cached results are restricted ...
[ "def", "memoize", "(", "func", ")", ":", "cache_name", "=", "'__CACHED_{}'", ".", "format", "(", "func", ".", "__name__", ")", "def", "wrapper", "(", "self", ",", "*", "args", ")", ":", "cache", "=", "getattr", "(", "self", ",", "cache_name", ",", "N...
Provides memoization for methods on a specific instance. Results are cached for given parameter list. See also: http://en.wikipedia.org/wiki/Memoization N.B. The cache object gets added to the instance instead of the global scope. Therefore cached results are restricted to that instance. The cache...
[ "Provides", "memoization", "for", "methods", "on", "a", "specific", "instance", ".", "Results", "are", "cached", "for", "given", "parameter", "list", "." ]
382ed139cff8bf35c987cfc30a31b72c0d6b808e
https://github.com/polyaxon/hestia/blob/382ed139cff8bf35c987cfc30a31b72c0d6b808e/hestia/memoize_decorators.py#L1-L34
train
Decorator that memoizes the results of a function on a specific instance.
greenelab/PathCORE-T
pathcore/feature_pathway_overrepresentation.py
pathway_enrichment_with_overlap_correction
def pathway_enrichment_with_overlap_correction(feature_weight_vector, pathway_definitions, gene_signature_definition, alpha=0.05, co...
python
def pathway_enrichment_with_overlap_correction(feature_weight_vector, pathway_definitions, gene_signature_definition, alpha=0.05, co...
[ "def", "pathway_enrichment_with_overlap_correction", "(", "feature_weight_vector", ",", "pathway_definitions", ",", "gene_signature_definition", ",", "alpha", "=", "0.05", ",", "correct_all_genes", "=", "True", ",", "metadata", "=", "False", ")", ":", "genes_in_pathway_de...
Identify pathways overrepresented in a constructed feature according to a user-specified criterion (see `gene_signature_definitions` in the parameters list below) for identifying the feature's gene signature. Donato et al.'s (2013) algorithm for pathway crosstalk correction (removes gene overlap between...
[ "Identify", "pathways", "overrepresented", "in", "a", "constructed", "feature", "according", "to", "a", "user", "-", "specified", "criterion", "(", "see", "gene_signature_definitions", "in", "the", "parameters", "list", "below", ")", "for", "identifying", "the", "...
9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c
https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/feature_pathway_overrepresentation.py#L15-L111
train
This function is used to identify pathways overrepresented in a feature by specifying gene signatures and their weight distribution.
greenelab/PathCORE-T
pathcore/feature_pathway_overrepresentation.py
_pathway_side_information
def _pathway_side_information(pathway_positive_series, pathway_negative_series, index): """Create the pandas.Series containing the side labels that correspond to each pathway, based on the user-specified gene signature definition. """ positive_...
python
def _pathway_side_information(pathway_positive_series, pathway_negative_series, index): """Create the pandas.Series containing the side labels that correspond to each pathway, based on the user-specified gene signature definition. """ positive_...
[ "def", "_pathway_side_information", "(", "pathway_positive_series", ",", "pathway_negative_series", ",", "index", ")", ":", "positive_series_label", "=", "pd", ".", "Series", "(", "[", "\"pos\"", "]", "*", "len", "(", "pathway_positive_series", ")", ")", "negative_s...
Create the pandas.Series containing the side labels that correspond to each pathway, based on the user-specified gene signature definition.
[ "Create", "the", "pandas", ".", "Series", "containing", "the", "side", "labels", "that", "correspond", "to", "each", "pathway", "based", "on", "the", "user", "-", "specified", "gene", "signature", "definition", "." ]
9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c
https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/feature_pathway_overrepresentation.py#L114-L126
train
Create the pandas. Series containing the side labels that correspond to each pathway based on the user - specified gene signature definition.
greenelab/PathCORE-T
pathcore/feature_pathway_overrepresentation.py
_significant_pathways_dataframe
def _significant_pathways_dataframe(pvalue_information, side_information, alpha): """Create the significant pathways pandas.DataFrame. Given the p-values corresponding to each pathway in a feature, apply the FDR correction for multiple ...
python
def _significant_pathways_dataframe(pvalue_information, side_information, alpha): """Create the significant pathways pandas.DataFrame. Given the p-values corresponding to each pathway in a feature, apply the FDR correction for multiple ...
[ "def", "_significant_pathways_dataframe", "(", "pvalue_information", ",", "side_information", ",", "alpha", ")", ":", "significant_pathways", "=", "pd", ".", "concat", "(", "[", "pvalue_information", ",", "side_information", "]", ",", "axis", "=", "1", ")", "# fdr...
Create the significant pathways pandas.DataFrame. Given the p-values corresponding to each pathway in a feature, apply the FDR correction for multiple testing and remove those that do not have a q-value of less than `alpha`.
[ "Create", "the", "significant", "pathways", "pandas", ".", "DataFrame", ".", "Given", "the", "p", "-", "values", "corresponding", "to", "each", "pathway", "in", "a", "feature", "apply", "the", "FDR", "correction", "for", "multiple", "testing", "and", "remove",...
9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c
https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/feature_pathway_overrepresentation.py#L129-L151
train
Create the significant pathways pandas. DataFrame.
greenelab/PathCORE-T
pathcore/feature_pathway_overrepresentation.py
single_side_pathway_enrichment
def single_side_pathway_enrichment(pathway_definitions, gene_signature, n_genes): """Identify overrepresented pathways using the Fisher's exact test for significance on a given pathway definition and gene signature. (FDR correction for mu...
python
def single_side_pathway_enrichment(pathway_definitions, gene_signature, n_genes): """Identify overrepresented pathways using the Fisher's exact test for significance on a given pathway definition and gene signature. (FDR correction for mu...
[ "def", "single_side_pathway_enrichment", "(", "pathway_definitions", ",", "gene_signature", ",", "n_genes", ")", ":", "if", "not", "gene_signature", ":", "return", "pd", ".", "Series", "(", "name", "=", "\"p-value\"", ")", "pvalues_list", "=", "[", "]", "for", ...
Identify overrepresented pathways using the Fisher's exact test for significance on a given pathway definition and gene signature. (FDR correction for multiple testing is applied in `_significant_pathways_dataframe`). Parameters ----------- pathway_definitions : dict(str -> set(str)) Path...
[ "Identify", "overrepresented", "pathways", "using", "the", "Fisher", "s", "exact", "test", "for", "significance", "on", "a", "given", "pathway", "definition", "and", "gene", "signature", ".", "(", "FDR", "correction", "for", "multiple", "testing", "is", "applied...
9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c
https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/feature_pathway_overrepresentation.py#L154-L208
train
Identify overrepresented pathways using the Fisher s exact test for a given pathway definition and gene signature.
greenelab/PathCORE-T
pathcore/feature_pathway_overrepresentation.py
pathway_enrichment_no_overlap_correction
def pathway_enrichment_no_overlap_correction(feature_weight_vector, pathway_definitions, gene_signature_definition, alpha=0.05, metadata=Fal...
python
def pathway_enrichment_no_overlap_correction(feature_weight_vector, pathway_definitions, gene_signature_definition, alpha=0.05, metadata=Fal...
[ "def", "pathway_enrichment_no_overlap_correction", "(", "feature_weight_vector", ",", "pathway_definitions", ",", "gene_signature_definition", ",", "alpha", "=", "0.05", ",", "metadata", "=", "False", ")", ":", "genes_in_pathway_definitions", "=", "set", ".", "union", "...
Identify pathways overrepresented in a constructed feature according to a user-specified criterion (see `gene_signature_definitions` in the parameters list below) for identifying the feature's gene signature. Overlap-correction is not applied to the pathway definitions. Parameters ----------- f...
[ "Identify", "pathways", "overrepresented", "in", "a", "constructed", "feature", "according", "to", "a", "user", "-", "specified", "criterion", "(", "see", "gene_signature_definitions", "in", "the", "parameters", "list", "below", ")", "for", "identifying", "the", "...
9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c
https://github.com/greenelab/PathCORE-T/blob/9d079d5ebffea2fe9fb9ab557588d51ad67d2c9c/pathcore/feature_pathway_overrepresentation.py#L211-L290
train
This function is used to determine if a pathway is overrepresented in a constructed feature pathway.
BernardFW/bernard
src/bernard/middleware/_builtins.py
AutoSleep.flush
async def flush(self, request: Request, stacks: List[Stack]): """ For all stacks to be sent, append a pause after each text layer. """ ns = await self.expand_stacks(request, stacks) ns = self.split_stacks(ns) ns = self.clean_stacks(ns) await self.next(request, [...
python
async def flush(self, request: Request, stacks: List[Stack]): """ For all stacks to be sent, append a pause after each text layer. """ ns = await self.expand_stacks(request, stacks) ns = self.split_stacks(ns) ns = self.clean_stacks(ns) await self.next(request, [...
[ "async", "def", "flush", "(", "self", ",", "request", ":", "Request", ",", "stacks", ":", "List", "[", "Stack", "]", ")", ":", "ns", "=", "await", "self", ".", "expand_stacks", "(", "request", ",", "stacks", ")", "ns", "=", "self", ".", "split_stacks...
For all stacks to be sent, append a pause after each text layer.
[ "For", "all", "stacks", "to", "be", "sent", "append", "a", "pause", "after", "each", "text", "layer", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/middleware/_builtins.py#L45-L54
train
Flushes the given list of stacks.
BernardFW/bernard
src/bernard/middleware/_builtins.py
AutoSleep.split_stacks
def split_stacks(self, stacks: List[List[BaseLayer]]) \ -> List[List[BaseLayer]]: """ First step of the stacks cleanup process. We consider that if inside a stack there's a text layer showing up then it's the beginning of a new stack and split upon that. """ ...
python
def split_stacks(self, stacks: List[List[BaseLayer]]) \ -> List[List[BaseLayer]]: """ First step of the stacks cleanup process. We consider that if inside a stack there's a text layer showing up then it's the beginning of a new stack and split upon that. """ ...
[ "def", "split_stacks", "(", "self", ",", "stacks", ":", "List", "[", "List", "[", "BaseLayer", "]", "]", ")", "->", "List", "[", "List", "[", "BaseLayer", "]", "]", ":", "ns", ":", "List", "[", "List", "[", "BaseLayer", "]", "]", "=", "[", "]", ...
First step of the stacks cleanup process. We consider that if inside a stack there's a text layer showing up then it's the beginning of a new stack and split upon that.
[ "First", "step", "of", "the", "stacks", "cleanup", "process", ".", "We", "consider", "that", "if", "inside", "a", "stack", "there", "s", "a", "text", "layer", "showing", "up", "then", "it", "s", "the", "beginning", "of", "a", "new", "stack", "and", "sp...
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/middleware/_builtins.py#L70-L93
train
This function splits the stacks into individual stacks.
BernardFW/bernard
src/bernard/middleware/_builtins.py
AutoSleep.clean_stacks
def clean_stacks(self, stacks: List[List[BaseLayer]]) \ -> List[List[BaseLayer]]: """ Two cases: if a stack finishes by a sleep then let's keep it (it means that there was nothing after the text). However if the stack finishes with something else (like a quick reply) then we ...
python
def clean_stacks(self, stacks: List[List[BaseLayer]]) \ -> List[List[BaseLayer]]: """ Two cases: if a stack finishes by a sleep then let's keep it (it means that there was nothing after the text). However if the stack finishes with something else (like a quick reply) then we ...
[ "def", "clean_stacks", "(", "self", ",", "stacks", ":", "List", "[", "List", "[", "BaseLayer", "]", "]", ")", "->", "List", "[", "List", "[", "BaseLayer", "]", "]", ":", "ns", ":", "List", "[", "List", "[", "BaseLayer", "]", "]", "=", "[", "]", ...
Two cases: if a stack finishes by a sleep then let's keep it (it means that there was nothing after the text). However if the stack finishes with something else (like a quick reply) then we don't risk an is preserved.
[ "Two", "cases", ":", "if", "a", "stack", "finishes", "by", "a", "sleep", "then", "let", "s", "keep", "it", "(", "it", "means", "that", "there", "was", "nothing", "after", "the", "text", ")", ".", "However", "if", "the", "stack", "finishes", "with", "...
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/middleware/_builtins.py#L95-L119
train
Clean up stacks to ensure that the stack is not sleep or sleep.
BernardFW/bernard
src/bernard/middleware/_builtins.py
AutoSleep.expand
async def expand(self, request: Request, layer: BaseLayer): """ Expand a layer into a list of layers including the pauses. """ if isinstance(layer, lyr.RawText): t = self.reading_time(layer.text) yield layer yield lyr.Sleep(t) elif isinstance...
python
async def expand(self, request: Request, layer: BaseLayer): """ Expand a layer into a list of layers including the pauses. """ if isinstance(layer, lyr.RawText): t = self.reading_time(layer.text) yield layer yield lyr.Sleep(t) elif isinstance...
[ "async", "def", "expand", "(", "self", ",", "request", ":", "Request", ",", "layer", ":", "BaseLayer", ")", ":", "if", "isinstance", "(", "layer", ",", "lyr", ".", "RawText", ")", ":", "t", "=", "self", ".", "reading_time", "(", "layer", ".", "text",...
Expand a layer into a list of layers including the pauses.
[ "Expand", "a", "layer", "into", "a", "list", "of", "layers", "including", "the", "pauses", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/middleware/_builtins.py#L121-L146
train
Expand a layer into a list of layers including the pauses.
BernardFW/bernard
src/bernard/middleware/_builtins.py
AutoSleep.reading_time
def reading_time(self, text: TextT): """ Computes the time in seconds that the user will need to read a bubble containing the text passed as parameter. """ wc = re.findall(r'\w+', text) period = 60.0 / settings.USERS_READING_SPEED return float(len(wc)) * period +...
python
def reading_time(self, text: TextT): """ Computes the time in seconds that the user will need to read a bubble containing the text passed as parameter. """ wc = re.findall(r'\w+', text) period = 60.0 / settings.USERS_READING_SPEED return float(len(wc)) * period +...
[ "def", "reading_time", "(", "self", ",", "text", ":", "TextT", ")", ":", "wc", "=", "re", ".", "findall", "(", "r'\\w+'", ",", "text", ")", "period", "=", "60.0", "/", "settings", ".", "USERS_READING_SPEED", "return", "float", "(", "len", "(", "wc", ...
Computes the time in seconds that the user will need to read a bubble containing the text passed as parameter.
[ "Computes", "the", "time", "in", "seconds", "that", "the", "user", "will", "need", "to", "read", "a", "bubble", "containing", "the", "text", "passed", "as", "parameter", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/middleware/_builtins.py#L148-L156
train
Computes the time that the user will need to read a bubble from the given text.
BernardFW/bernard
src/bernard/middleware/_builtins.py
AutoType.flush
async def flush(self, request: Request, stacks: List[Stack]): """ Add a typing stack after each stack. """ ns: List[Stack] = [] for stack in stacks: ns.extend(self.typify(stack)) if len(ns) > 1 and ns[-1] == Stack([lyr.Typing()]): ns[-1].get_lay...
python
async def flush(self, request: Request, stacks: List[Stack]): """ Add a typing stack after each stack. """ ns: List[Stack] = [] for stack in stacks: ns.extend(self.typify(stack)) if len(ns) > 1 and ns[-1] == Stack([lyr.Typing()]): ns[-1].get_lay...
[ "async", "def", "flush", "(", "self", ",", "request", ":", "Request", ",", "stacks", ":", "List", "[", "Stack", "]", ")", ":", "ns", ":", "List", "[", "Stack", "]", "=", "[", "]", "for", "stack", "in", "stacks", ":", "ns", ".", "extend", "(", "...
Add a typing stack after each stack.
[ "Add", "a", "typing", "stack", "after", "each", "stack", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/middleware/_builtins.py#L165-L178
train
Flushes the typing stack after each stack.
BernardFW/bernard
src/bernard/middleware/_builtins.py
AutoType.pre_handle
async def pre_handle(self, request: Request, responder: 'Responder'): """ Start typing right when the message is received. """ responder.send([lyr.Typing()]) await responder.flush(request) responder.clear() await self.next(request, responder)
python
async def pre_handle(self, request: Request, responder: 'Responder'): """ Start typing right when the message is received. """ responder.send([lyr.Typing()]) await responder.flush(request) responder.clear() await self.next(request, responder)
[ "async", "def", "pre_handle", "(", "self", ",", "request", ":", "Request", ",", "responder", ":", "'Responder'", ")", ":", "responder", ".", "send", "(", "[", "lyr", ".", "Typing", "(", ")", "]", ")", "await", "responder", ".", "flush", "(", "request",...
Start typing right when the message is received.
[ "Start", "typing", "right", "when", "the", "message", "is", "received", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/middleware/_builtins.py#L180-L189
train
Start typing right when the message is received.
BernardFW/bernard
src/bernard/middleware/_builtins.py
AutoType.typify
def typify(self, stack: Stack) -> List[Stack]: """ Appends a typing stack after the given stack, but only if required (aka don't have two typing layers following each other). """ if len(stack.layers) == 1 and isinstance(stack.layers[0], lyr.Typing): return [stack] ...
python
def typify(self, stack: Stack) -> List[Stack]: """ Appends a typing stack after the given stack, but only if required (aka don't have two typing layers following each other). """ if len(stack.layers) == 1 and isinstance(stack.layers[0], lyr.Typing): return [stack] ...
[ "def", "typify", "(", "self", ",", "stack", ":", "Stack", ")", "->", "List", "[", "Stack", "]", ":", "if", "len", "(", "stack", ".", "layers", ")", "==", "1", "and", "isinstance", "(", "stack", ".", "layers", "[", "0", "]", ",", "lyr", ".", "Ty...
Appends a typing stack after the given stack, but only if required (aka don't have two typing layers following each other).
[ "Appends", "a", "typing", "stack", "after", "the", "given", "stack", "but", "only", "if", "required", "(", "aka", "don", "t", "have", "two", "typing", "layers", "following", "each", "other", ")", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/middleware/_builtins.py#L191-L200
train
Adds a typing stack after the given stack.
BernardFW/bernard
src/bernard/platforms/telegram/platform.py
TelegramUser._get_full_user
async def _get_full_user(self) -> Dict: """ Sometimes Telegram does not provide all the user info with the message. In order to get the full profile (aka the language code) you need to call this method which will make sure that the full User object is loaded. The result ...
python
async def _get_full_user(self) -> Dict: """ Sometimes Telegram does not provide all the user info with the message. In order to get the full profile (aka the language code) you need to call this method which will make sure that the full User object is loaded. The result ...
[ "async", "def", "_get_full_user", "(", "self", ")", "->", "Dict", ":", "if", "'language_code'", "in", "self", ".", "_user", ":", "return", "self", ".", "_user", "async", "with", "self", ".", "_lock", ":", "if", "self", ".", "_full_user", "is", "None", ...
Sometimes Telegram does not provide all the user info with the message. In order to get the full profile (aka the language code) you need to call this method which will make sure that the full User object is loaded. The result is cached for the lifetime of the object, so if the function...
[ "Sometimes", "Telegram", "does", "not", "provide", "all", "the", "user", "info", "with", "the", "message", ".", "In", "order", "to", "get", "the", "full", "profile", "(", "aka", "the", "language", "code", ")", "you", "need", "to", "call", "this", "method...
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/telegram/platform.py#L126-L150
train
Get the full User object.
BernardFW/bernard
src/bernard/platforms/telegram/platform.py
TelegramUser.get_friendly_name
async def get_friendly_name(self) -> Text: """ Let's use the first name of the user as friendly name. In some cases the user object is incomplete, and in those cases the full user is fetched. """ if 'first_name' not in self._user: user = await self._get_full_...
python
async def get_friendly_name(self) -> Text: """ Let's use the first name of the user as friendly name. In some cases the user object is incomplete, and in those cases the full user is fetched. """ if 'first_name' not in self._user: user = await self._get_full_...
[ "async", "def", "get_friendly_name", "(", "self", ")", "->", "Text", ":", "if", "'first_name'", "not", "in", "self", ".", "_user", ":", "user", "=", "await", "self", ".", "_get_full_user", "(", ")", "else", ":", "user", "=", "self", ".", "_user", "retu...
Let's use the first name of the user as friendly name. In some cases the user object is incomplete, and in those cases the full user is fetched.
[ "Let", "s", "use", "the", "first", "name", "of", "the", "user", "as", "friendly", "name", ".", "In", "some", "cases", "the", "user", "object", "is", "incomplete", "and", "in", "those", "cases", "the", "full", "user", "is", "fetched", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/telegram/platform.py#L152-L164
train
Get the first name of the user as friendly name.
BernardFW/bernard
src/bernard/platforms/telegram/platform.py
TelegramMessage._get_chat
def _get_chat(self) -> Dict: """ As Telegram changes where the chat object is located in the response, this method tries to be smart about finding it in the right place. """ if 'callback_query' in self._update: query = self._update['callback_query'] if 'm...
python
def _get_chat(self) -> Dict: """ As Telegram changes where the chat object is located in the response, this method tries to be smart about finding it in the right place. """ if 'callback_query' in self._update: query = self._update['callback_query'] if 'm...
[ "def", "_get_chat", "(", "self", ")", "->", "Dict", ":", "if", "'callback_query'", "in", "self", ".", "_update", ":", "query", "=", "self", ".", "_update", "[", "'callback_query'", "]", "if", "'message'", "in", "query", ":", "return", "query", "[", "'mes...
As Telegram changes where the chat object is located in the response, this method tries to be smart about finding it in the right place.
[ "As", "Telegram", "changes", "where", "the", "chat", "object", "is", "located", "in", "the", "response", "this", "method", "tries", "to", "be", "smart", "about", "finding", "it", "in", "the", "right", "place", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/telegram/platform.py#L238-L256
train
Get the chat object from the update.
BernardFW/bernard
src/bernard/platforms/telegram/platform.py
TelegramMessage._get_user
def _get_user(self) -> Dict: """ Same thing as for `_get_chat()` but for the user related to the message. """ if 'callback_query' in self._update: return self._update['callback_query']['from'] elif 'inline_query' in self._update: return self._upda...
python
def _get_user(self) -> Dict: """ Same thing as for `_get_chat()` but for the user related to the message. """ if 'callback_query' in self._update: return self._update['callback_query']['from'] elif 'inline_query' in self._update: return self._upda...
[ "def", "_get_user", "(", "self", ")", "->", "Dict", ":", "if", "'callback_query'", "in", "self", ".", "_update", ":", "return", "self", ".", "_update", "[", "'callback_query'", "]", "[", "'from'", "]", "elif", "'inline_query'", "in", "self", ".", "_update"...
Same thing as for `_get_chat()` but for the user related to the message.
[ "Same", "thing", "as", "for", "_get_chat", "()", "but", "for", "the", "user", "related", "to", "the", "message", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/telegram/platform.py#L258-L269
train
Get the user related to the current user.
BernardFW/bernard
src/bernard/platforms/telegram/platform.py
TelegramResponder.send
def send(self, stack: Layers): """ Intercept any potential "AnswerCallbackQuery" before adding the stack to the output buffer. """ if not isinstance(stack, Stack): stack = Stack(stack) if 'callback_query' in self._update and stack.has_layer(Update): ...
python
def send(self, stack: Layers): """ Intercept any potential "AnswerCallbackQuery" before adding the stack to the output buffer. """ if not isinstance(stack, Stack): stack = Stack(stack) if 'callback_query' in self._update and stack.has_layer(Update): ...
[ "def", "send", "(", "self", ",", "stack", ":", "Layers", ")", ":", "if", "not", "isinstance", "(", "stack", ",", "Stack", ")", ":", "stack", "=", "Stack", "(", "stack", ")", "if", "'callback_query'", "in", "self", ".", "_update", "and", "stack", ".",...
Intercept any potential "AnswerCallbackQuery" before adding the stack to the output buffer.
[ "Intercept", "any", "potential", "AnswerCallbackQuery", "before", "adding", "the", "stack", "to", "the", "output", "buffer", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/telegram/platform.py#L313-L355
train
Send a stack to the Telegram.
BernardFW/bernard
src/bernard/platforms/telegram/platform.py
TelegramResponder.flush
async def flush(self, request: BernardRequest): """ If there's a AnswerCallbackQuery scheduled for reply, place the call before actually flushing the buffer. """ if self._acq and 'callback_query' in self._update: try: cbq_id = self._update['callback_q...
python
async def flush(self, request: BernardRequest): """ If there's a AnswerCallbackQuery scheduled for reply, place the call before actually flushing the buffer. """ if self._acq and 'callback_query' in self._update: try: cbq_id = self._update['callback_q...
[ "async", "def", "flush", "(", "self", ",", "request", ":", "BernardRequest", ")", ":", "if", "self", ".", "_acq", "and", "'callback_query'", "in", "self", ".", "_update", ":", "try", ":", "cbq_id", "=", "self", ".", "_update", "[", "'callback_query'", "]...
If there's a AnswerCallbackQuery scheduled for reply, place the call before actually flushing the buffer.
[ "If", "there", "s", "a", "AnswerCallbackQuery", "scheduled", "for", "reply", "place", "the", "call", "before", "actually", "flushing", "the", "buffer", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/telegram/platform.py#L357-L374
train
Flushes the buffer.
BernardFW/bernard
src/bernard/platforms/telegram/platform.py
Telegram.self_check
async def self_check(cls): """ Check that the configuration is correct - Presence of "token" in the settings - Presence of "BERNARD_BASE_URL" in the global configuration """ # noinspection PyTypeChecker async for check in super(Telegram, cls).self_check(): ...
python
async def self_check(cls): """ Check that the configuration is correct - Presence of "token" in the settings - Presence of "BERNARD_BASE_URL" in the global configuration """ # noinspection PyTypeChecker async for check in super(Telegram, cls).self_check(): ...
[ "async", "def", "self_check", "(", "cls", ")", ":", "# noinspection PyTypeChecker", "async", "for", "check", "in", "super", "(", "Telegram", ",", "cls", ")", ".", "self_check", "(", ")", ":", "yield", "check", "s", "=", "cls", ".", "settings", "(", ")", ...
Check that the configuration is correct - Presence of "token" in the settings - Presence of "BERNARD_BASE_URL" in the global configuration
[ "Check", "that", "the", "configuration", "is", "correct" ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/telegram/platform.py#L396-L433
train
Check that the configuration is correct.
BernardFW/bernard
src/bernard/platforms/telegram/platform.py
Telegram.receive_updates
async def receive_updates(self, request: Request): """ Handle updates from Telegram """ body = await request.read() try: content = ujson.loads(body) except ValueError: return json_response({ 'error': True, 'message...
python
async def receive_updates(self, request: Request): """ Handle updates from Telegram """ body = await request.read() try: content = ujson.loads(body) except ValueError: return json_response({ 'error': True, 'message...
[ "async", "def", "receive_updates", "(", "self", ",", "request", ":", "Request", ")", ":", "body", "=", "await", "request", ".", "read", "(", ")", "try", ":", "content", "=", "ujson", ".", "loads", "(", "body", ")", "except", "ValueError", ":", "return"...
Handle updates from Telegram
[ "Handle", "updates", "from", "Telegram" ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/telegram/platform.py#L438-L461
train
Handle updates from Telegram
BernardFW/bernard
src/bernard/platforms/telegram/platform.py
Telegram.make_url
def make_url(self, method): """ Generate a Telegram URL for this bot. """ token = self.settings()['token'] return TELEGRAM_URL.format( token=quote(token), method=quote(method), )
python
def make_url(self, method): """ Generate a Telegram URL for this bot. """ token = self.settings()['token'] return TELEGRAM_URL.format( token=quote(token), method=quote(method), )
[ "def", "make_url", "(", "self", ",", "method", ")", ":", "token", "=", "self", ".", "settings", "(", ")", "[", "'token'", "]", "return", "TELEGRAM_URL", ".", "format", "(", "token", "=", "quote", "(", "token", ")", ",", "method", "=", "quote", "(", ...
Generate a Telegram URL for this bot.
[ "Generate", "a", "Telegram", "URL", "for", "this", "bot", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/telegram/platform.py#L503-L513
train
Generate a Telegram URL for this bot.
BernardFW/bernard
src/bernard/platforms/telegram/platform.py
Telegram.call
async def call(self, method: Text, _ignore: Set[Text] = None, **params: Any): """ Call a telegram method :param _ignore: List of reasons to ignore :param method: Name of the method to call :param params: Dictionary of the ...
python
async def call(self, method: Text, _ignore: Set[Text] = None, **params: Any): """ Call a telegram method :param _ignore: List of reasons to ignore :param method: Name of the method to call :param params: Dictionary of the ...
[ "async", "def", "call", "(", "self", ",", "method", ":", "Text", ",", "_ignore", ":", "Set", "[", "Text", "]", "=", "None", ",", "*", "*", "params", ":", "Any", ")", ":", "logger", ".", "debug", "(", "'Calling Telegram %s(%s)'", ",", "method", ",", ...
Call a telegram method :param _ignore: List of reasons to ignore :param method: Name of the method to call :param params: Dictionary of the parameters to send :return: Returns the API response
[ "Call", "a", "telegram", "method" ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/telegram/platform.py#L515-L546
train
Call a Telegram method and return the API response
BernardFW/bernard
src/bernard/platforms/telegram/platform.py
Telegram._handle_telegram_response
async def _handle_telegram_response(self, response, ignore=None): """ Parse a response from Telegram. If there's an error, an exception will be raised with an explicative message. :param response: Response to parse :return: Data """ if ignore is None: ...
python
async def _handle_telegram_response(self, response, ignore=None): """ Parse a response from Telegram. If there's an error, an exception will be raised with an explicative message. :param response: Response to parse :return: Data """ if ignore is None: ...
[ "async", "def", "_handle_telegram_response", "(", "self", ",", "response", ",", "ignore", "=", "None", ")", ":", "if", "ignore", "is", "None", ":", "ignore", "=", "set", "(", ")", "ok", "=", "response", ".", "status", "==", "200", "try", ":", "data", ...
Parse a response from Telegram. If there's an error, an exception will be raised with an explicative message. :param response: Response to parse :return: Data
[ "Parse", "a", "response", "from", "Telegram", ".", "If", "there", "s", "an", "error", "an", "exception", "will", "be", "raised", "with", "an", "explicative", "message", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/telegram/platform.py#L548-L578
train
Parse a Telegram response from Telegram and return a DataONE object.
BernardFW/bernard
src/bernard/platforms/telegram/platform.py
Telegram.make_hook_path
def make_hook_path(self): """ Compute the path to the hook URL """ token = self.settings()['token'] h = sha256() h.update(token.encode()) key = str(h.hexdigest()) return f'/hooks/telegram/{key}'
python
def make_hook_path(self): """ Compute the path to the hook URL """ token = self.settings()['token'] h = sha256() h.update(token.encode()) key = str(h.hexdigest()) return f'/hooks/telegram/{key}'
[ "def", "make_hook_path", "(", "self", ")", ":", "token", "=", "self", ".", "settings", "(", ")", "[", "'token'", "]", "h", "=", "sha256", "(", ")", "h", ".", "update", "(", "token", ".", "encode", "(", ")", ")", "key", "=", "str", "(", "h", "."...
Compute the path to the hook URL
[ "Compute", "the", "path", "to", "the", "hook", "URL" ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/telegram/platform.py#L580-L589
train
Compute the path to the hook URL
BernardFW/bernard
src/bernard/platforms/telegram/platform.py
Telegram._deferred_init
async def _deferred_init(self): """ Register the web hook onto which Telegram should send its messages. """ hook_path = self.make_hook_path() url = urljoin(settings.BERNARD_BASE_URL, hook_path) await self.call('setWebhook', url=url) logger.info('Setting Telegram ...
python
async def _deferred_init(self): """ Register the web hook onto which Telegram should send its messages. """ hook_path = self.make_hook_path() url = urljoin(settings.BERNARD_BASE_URL, hook_path) await self.call('setWebhook', url=url) logger.info('Setting Telegram ...
[ "async", "def", "_deferred_init", "(", "self", ")", ":", "hook_path", "=", "self", ".", "make_hook_path", "(", ")", "url", "=", "urljoin", "(", "settings", ".", "BERNARD_BASE_URL", ",", "hook_path", ")", "await", "self", ".", "call", "(", "'setWebhook'", "...
Register the web hook onto which Telegram should send its messages.
[ "Register", "the", "web", "hook", "onto", "which", "Telegram", "should", "send", "its", "messages", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/telegram/platform.py#L591-L599
train
Register the web hook onto which Telegram should send its messages.
BernardFW/bernard
src/bernard/platforms/telegram/platform.py
Telegram._send_text
async def _send_text(self, request: Request, stack: Stack, parse_mode: Optional[Text] = None): """ Base function for sending text """ parts = [] chat_id = request.message.get_chat_id() for layer ...
python
async def _send_text(self, request: Request, stack: Stack, parse_mode: Optional[Text] = None): """ Base function for sending text """ parts = [] chat_id = request.message.get_chat_id() for layer ...
[ "async", "def", "_send_text", "(", "self", ",", "request", ":", "Request", ",", "stack", ":", "Stack", ",", "parse_mode", ":", "Optional", "[", "Text", "]", "=", "None", ")", ":", "parts", "=", "[", "]", "chat_id", "=", "request", ".", "message", "."...
Base function for sending text
[ "Base", "function", "for", "sending", "text" ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/telegram/platform.py#L601-L654
train
Send text to the user.
BernardFW/bernard
src/bernard/platforms/telegram/platform.py
Telegram._send_plain_text
async def _send_plain_text(self, request: Request, stack: Stack): """ Sends plain text using `_send_text()`. """ await self._send_text(request, stack, None)
python
async def _send_plain_text(self, request: Request, stack: Stack): """ Sends plain text using `_send_text()`. """ await self._send_text(request, stack, None)
[ "async", "def", "_send_plain_text", "(", "self", ",", "request", ":", "Request", ",", "stack", ":", "Stack", ")", ":", "await", "self", ".", "_send_text", "(", "request", ",", "stack", ",", "None", ")" ]
Sends plain text using `_send_text()`.
[ "Sends", "plain", "text", "using", "_send_text", "()", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/telegram/platform.py#L656-L661
train
Sends plain text using _send_text.
BernardFW/bernard
src/bernard/platforms/telegram/platform.py
Telegram._send_markdown
async def _send_markdown(self, request: Request, stack: Stack): """ Sends Markdown using `_send_text()` """ await self._send_text(request, stack, 'Markdown')
python
async def _send_markdown(self, request: Request, stack: Stack): """ Sends Markdown using `_send_text()` """ await self._send_text(request, stack, 'Markdown')
[ "async", "def", "_send_markdown", "(", "self", ",", "request", ":", "Request", ",", "stack", ":", "Stack", ")", ":", "await", "self", ".", "_send_text", "(", "request", ",", "stack", ",", "'Markdown'", ")" ]
Sends Markdown using `_send_text()`
[ "Sends", "Markdown", "using", "_send_text", "()" ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/telegram/platform.py#L663-L668
train
Sends Markdown using _send_text
BernardFW/bernard
src/bernard/platforms/telegram/platform.py
Telegram._send_sleep
async def _send_sleep(self, request: Request, stack: Stack): """ Sleep for the amount of time specified in the Sleep layer """ duration = stack.get_layer(lyr.Sleep).duration await sleep(duration)
python
async def _send_sleep(self, request: Request, stack: Stack): """ Sleep for the amount of time specified in the Sleep layer """ duration = stack.get_layer(lyr.Sleep).duration await sleep(duration)
[ "async", "def", "_send_sleep", "(", "self", ",", "request", ":", "Request", ",", "stack", ":", "Stack", ")", ":", "duration", "=", "stack", ".", "get_layer", "(", "lyr", ".", "Sleep", ")", ".", "duration", "await", "sleep", "(", "duration", ")" ]
Sleep for the amount of time specified in the Sleep layer
[ "Sleep", "for", "the", "amount", "of", "time", "specified", "in", "the", "Sleep", "layer" ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/telegram/platform.py#L670-L676
train
Send a sleep to the stack.
BernardFW/bernard
src/bernard/platforms/telegram/platform.py
Telegram._send_typing
async def _send_typing(self, request: Request, stack: Stack): """ In telegram, the typing stops when the message is received. Thus, there is no "typing stops" messages to send. The API is only called when typing must start. """ t = stack.get_layer(lyr.Typing) if...
python
async def _send_typing(self, request: Request, stack: Stack): """ In telegram, the typing stops when the message is received. Thus, there is no "typing stops" messages to send. The API is only called when typing must start. """ t = stack.get_layer(lyr.Typing) if...
[ "async", "def", "_send_typing", "(", "self", ",", "request", ":", "Request", ",", "stack", ":", "Stack", ")", ":", "t", "=", "stack", ".", "get_layer", "(", "lyr", ".", "Typing", ")", "if", "t", ".", "active", ":", "await", "self", ".", "call", "("...
In telegram, the typing stops when the message is received. Thus, there is no "typing stops" messages to send. The API is only called when typing must start.
[ "In", "telegram", "the", "typing", "stops", "when", "the", "message", "is", "received", ".", "Thus", "there", "is", "no", "typing", "stops", "messages", "to", "send", ".", "The", "API", "is", "only", "called", "when", "typing", "must", "start", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/telegram/platform.py#L683-L697
train
Send typing stops when the message is received.
ikalnytskyi/holocron
src/holocron/core/factories.py
create_app
def create_app(metadata, processors=None, pipes=None): """Return an application instance with processors & pipes setup.""" instance = Application(metadata) # In order to avoid code duplication, we use existing built-in import # processor to import and register built-in processors on the application ...
python
def create_app(metadata, processors=None, pipes=None): """Return an application instance with processors & pipes setup.""" instance = Application(metadata) # In order to avoid code duplication, we use existing built-in import # processor to import and register built-in processors on the application ...
[ "def", "create_app", "(", "metadata", ",", "processors", "=", "None", ",", "pipes", "=", "None", ")", ":", "instance", "=", "Application", "(", "metadata", ")", "# In order to avoid code duplication, we use existing built-in import", "# processor to import and register buil...
Return an application instance with processors & pipes setup.
[ "Return", "an", "application", "instance", "with", "processors", "&", "pipes", "setup", "." ]
d202f6bccfeca64162857c6d0ee5bb53e773d2f2
https://github.com/ikalnytskyi/holocron/blob/d202f6bccfeca64162857c6d0ee5bb53e773d2f2/src/holocron/core/factories.py#L7-L42
train
Create an application instance with processors & pipes setup.
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/model/labeled_network.py
LabeledNetwork.write_index_labels
def write_index_labels(self, targets, output_path): """Write the mappings between vertex indices and labels(target vs. not) to a file. :param list targets: List of known targets. :param str output_path: Path to the output file. """ label_mappings = self.get_index_labels(targets)...
python
def write_index_labels(self, targets, output_path): """Write the mappings between vertex indices and labels(target vs. not) to a file. :param list targets: List of known targets. :param str output_path: Path to the output file. """ label_mappings = self.get_index_labels(targets)...
[ "def", "write_index_labels", "(", "self", ",", "targets", ",", "output_path", ")", ":", "label_mappings", "=", "self", ".", "get_index_labels", "(", "targets", ")", "with", "open", "(", "output_path", ",", "\"w\"", ")", "as", "file", ":", "for", "k", ",", ...
Write the mappings between vertex indices and labels(target vs. not) to a file. :param list targets: List of known targets. :param str output_path: Path to the output file.
[ "Write", "the", "mappings", "between", "vertex", "indices", "and", "labels", "(", "target", "vs", ".", "not", ")", "to", "a", "file", "." ]
4d7b6713485f2d0a0957e6457edc1b1b5a237460
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/model/labeled_network.py#L24-L34
train
Write the mappings between vertex indices and labels ( target vs. not
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/model/labeled_network.py
LabeledNetwork.get_index_labels
def get_index_labels(self, targets): """Get the labels(known target/not) mapped to indices. :param targets: List of known targets :return: Dictionary of index-label mappings """ target_ind = self.graph.vs.select(name_in=targets).indices rest_ind = self.graph.vs.select(na...
python
def get_index_labels(self, targets): """Get the labels(known target/not) mapped to indices. :param targets: List of known targets :return: Dictionary of index-label mappings """ target_ind = self.graph.vs.select(name_in=targets).indices rest_ind = self.graph.vs.select(na...
[ "def", "get_index_labels", "(", "self", ",", "targets", ")", ":", "target_ind", "=", "self", ".", "graph", ".", "vs", ".", "select", "(", "name_in", "=", "targets", ")", ".", "indices", "rest_ind", "=", "self", ".", "graph", ".", "vs", ".", "select", ...
Get the labels(known target/not) mapped to indices. :param targets: List of known targets :return: Dictionary of index-label mappings
[ "Get", "the", "labels", "(", "known", "target", "/", "not", ")", "mapped", "to", "indices", "." ]
4d7b6713485f2d0a0957e6457edc1b1b5a237460
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/model/labeled_network.py#L36-L46
train
Get the labels mapped to indices.
cloudmesh-cmd3/cmd3
cmd3/generate.py
generate_command
def generate_command(command=None, package=None, path="~", topic="mycommands" ): """ the command will generate the package and code for a sample cmd3 module. :param command: the name of the command :param package: name ...
python
def generate_command(command=None, package=None, path="~", topic="mycommands" ): """ the command will generate the package and code for a sample cmd3 module. :param command: the name of the command :param package: name ...
[ "def", "generate_command", "(", "command", "=", "None", ",", "package", "=", "None", ",", "path", "=", "\"~\"", ",", "topic", "=", "\"mycommands\"", ")", ":", "if", "command", "is", "None", ":", "Console", ".", "error", "(", "\"command not specified\"", ")...
the command will generate the package and code for a sample cmd3 module. :param command: the name of the command :param package: name of the new package. Often this will be cloudmesh_COMMAND which will be used if not specified. :param path: path where to place the directory :para...
[ "the", "command", "will", "generate", "the", "package", "and", "code", "for", "a", "sample", "cmd3", "module", "." ]
92e33c96032fd3921f159198a0e57917c4dc34ed
https://github.com/cloudmesh-cmd3/cmd3/blob/92e33c96032fd3921f159198a0e57917c4dc34ed/cmd3/generate.py#L41-L122
train
This function generates the command and code for a sample cmd3 module.
BernardFW/bernard
src/bernard/analytics/ga/_ga.py
GoogleAnalytics.page_view
async def page_view(self, url: str, title: str, user_id: str, user_lang: str='') -> None: """ Log a page view. :param url: URL of the "page" :param title: Title of the "page" :param u...
python
async def page_view(self, url: str, title: str, user_id: str, user_lang: str='') -> None: """ Log a page view. :param url: URL of the "page" :param title: Title of the "page" :param u...
[ "async", "def", "page_view", "(", "self", ",", "url", ":", "str", ",", "title", ":", "str", ",", "user_id", ":", "str", ",", "user_lang", ":", "str", "=", "''", ")", "->", "None", ":", "ga_url", "=", "'https://www.google-analytics.com/collect'", "args", ...
Log a page view. :param url: URL of the "page" :param title: Title of the "page" :param user_id: ID of the user seeing the page. :param user_lang: Current language of the UI.
[ "Log", "a", "page", "view", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/analytics/ga/_ga.py#L37-L74
train
Log a page view.
transifex/transifex-python-library
txlib/http/auth.py
AuthInfo.get
def get(self, username=None, password=None, headers={}): """Factory method to get the correct AuthInfo object. The returned value depends on the arguments given. In case the username and password don't have a value (ie evaluate to False), return an object for anonymous access. Else, ret...
python
def get(self, username=None, password=None, headers={}): """Factory method to get the correct AuthInfo object. The returned value depends on the arguments given. In case the username and password don't have a value (ie evaluate to False), return an object for anonymous access. Else, ret...
[ "def", "get", "(", "self", ",", "username", "=", "None", ",", "password", "=", "None", ",", "headers", "=", "{", "}", ")", ":", "if", "all", "(", "(", "username", ",", "password", ",", ")", ")", ":", "return", "BasicAuth", "(", "username", ",", "...
Factory method to get the correct AuthInfo object. The returned value depends on the arguments given. In case the username and password don't have a value (ie evaluate to False), return an object for anonymous access. Else, return an auth object that supports basic authentication. ...
[ "Factory", "method", "to", "get", "the", "correct", "AuthInfo", "object", "." ]
9fea86b718973de35ccca6d54bd1f445c9632406
https://github.com/transifex/transifex-python-library/blob/9fea86b718973de35ccca6d54bd1f445c9632406/txlib/http/auth.py#L14-L40
train
Returns the correct AuthInfo object.
transifex/transifex-python-library
txlib/http/auth.py
BasicAuth.populate_request_data
def populate_request_data(self, request_args): """Add the authentication info to the supplied dictionary. We use the `requests.HTTPBasicAuth` class as the `auth` param. Args: `request_args`: The arguments that will be passed to the request. Returns: The updated ...
python
def populate_request_data(self, request_args): """Add the authentication info to the supplied dictionary. We use the `requests.HTTPBasicAuth` class as the `auth` param. Args: `request_args`: The arguments that will be passed to the request. Returns: The updated ...
[ "def", "populate_request_data", "(", "self", ",", "request_args", ")", ":", "request_args", "[", "'auth'", "]", "=", "HTTPBasicAuth", "(", "self", ".", "_username", ",", "self", ".", "_password", ")", "return", "request_args" ]
Add the authentication info to the supplied dictionary. We use the `requests.HTTPBasicAuth` class as the `auth` param. Args: `request_args`: The arguments that will be passed to the request. Returns: The updated arguments for the request.
[ "Add", "the", "authentication", "info", "to", "the", "supplied", "dictionary", "." ]
9fea86b718973de35ccca6d54bd1f445c9632406
https://github.com/transifex/transifex-python-library/blob/9fea86b718973de35ccca6d54bd1f445c9632406/txlib/http/auth.py#L74-L86
train
Add the authentication info to the supplied dictionary.
inveniosoftware-contrib/invenio-workflows
invenio_workflows/ext.py
_WorkflowState.register_workflow
def register_workflow(self, name, workflow): """Register an workflow to be showed in the workflows list.""" assert name not in self.workflows self.workflows[name] = workflow
python
def register_workflow(self, name, workflow): """Register an workflow to be showed in the workflows list.""" assert name not in self.workflows self.workflows[name] = workflow
[ "def", "register_workflow", "(", "self", ",", "name", ",", "workflow", ")", ":", "assert", "name", "not", "in", "self", ".", "workflows", "self", ".", "workflows", "[", "name", "]", "=", "workflow" ]
Register an workflow to be showed in the workflows list.
[ "Register", "an", "workflow", "to", "be", "showed", "in", "the", "workflows", "list", "." ]
9c09fd29509a3db975ac2aba337e6760d8cfd3c2
https://github.com/inveniosoftware-contrib/invenio-workflows/blob/9c09fd29509a3db975ac2aba337e6760d8cfd3c2/invenio_workflows/ext.py#L52-L55
train
Register a workflow to be shown in the workflows list.
inveniosoftware-contrib/invenio-workflows
invenio_workflows/ext.py
InvenioWorkflows.init_app
def init_app(self, app, entry_point_group='invenio_workflows.workflows', **kwargs): """Flask application initialization.""" app.config.setdefault( "WORKFLOWS_OBJECT_CLASS", "invenio_workflows.api.WorkflowObject" ) state = _Workflo...
python
def init_app(self, app, entry_point_group='invenio_workflows.workflows', **kwargs): """Flask application initialization.""" app.config.setdefault( "WORKFLOWS_OBJECT_CLASS", "invenio_workflows.api.WorkflowObject" ) state = _Workflo...
[ "def", "init_app", "(", "self", ",", "app", ",", "entry_point_group", "=", "'invenio_workflows.workflows'", ",", "*", "*", "kwargs", ")", ":", "app", ".", "config", ".", "setdefault", "(", "\"WORKFLOWS_OBJECT_CLASS\"", ",", "\"invenio_workflows.api.WorkflowObject\"", ...
Flask application initialization.
[ "Flask", "application", "initialization", "." ]
9c09fd29509a3db975ac2aba337e6760d8cfd3c2
https://github.com/inveniosoftware-contrib/invenio-workflows/blob/9c09fd29509a3db975ac2aba337e6760d8cfd3c2/invenio_workflows/ext.py#L71-L83
train
Initialize the application with the given entry_point_group and return the state of the application.
samghelms/mathviz
mathviz_hopper/src/bottle.py
static_file
def static_file(filename, root, mimetype=True, download=False, charset='UTF-8', etag=None): """ Open a file in a safe way and return an instance of :exc:`HTTPResponse` that can be sent back to the client. :param filename: Name or path ...
python
def static_file(filename, root, mimetype=True, download=False, charset='UTF-8', etag=None): """ Open a file in a safe way and return an instance of :exc:`HTTPResponse` that can be sent back to the client. :param filename: Name or path ...
[ "def", "static_file", "(", "filename", ",", "root", ",", "mimetype", "=", "True", ",", "download", "=", "False", ",", "charset", "=", "'UTF-8'", ",", "etag", "=", "None", ")", ":", "root", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path"...
Open a file in a safe way and return an instance of :exc:`HTTPResponse` that can be sent back to the client. :param filename: Name or path of the file to send, relative to ``root``. :param root: Root path for file lookups. Should be an absolute directory path. :param mimetyp...
[ "Open", "a", "file", "in", "a", "safe", "way", "and", "return", "an", "instance", "of", ":", "exc", ":", "HTTPResponse", "that", "can", "be", "sent", "back", "to", "the", "client", "." ]
30fe89537379faea4de8c8b568ac6e52e4d15353
https://github.com/samghelms/mathviz/blob/30fe89537379faea4de8c8b568ac6e52e4d15353/mathviz_hopper/src/bottle.py#L2821-L2923
train
Open a file in a safe way and return a response object that can be sent back to the client.
samghelms/mathviz
mathviz_hopper/src/bottle.py
_parse_http_header
def _parse_http_header(h): """ Parses a typical multi-valued and parametrised HTTP header (e.g. Accept headers) and returns a list of values and parameters. For non-standard or broken input, this implementation may return partial results. :param h: A header string (e.g. ``text/html,text/plain;q=0.9,*/*;...
python
def _parse_http_header(h): """ Parses a typical multi-valued and parametrised HTTP header (e.g. Accept headers) and returns a list of values and parameters. For non-standard or broken input, this implementation may return partial results. :param h: A header string (e.g. ``text/html,text/plain;q=0.9,*/*;...
[ "def", "_parse_http_header", "(", "h", ")", ":", "values", "=", "[", "]", "if", "'\"'", "not", "in", "h", ":", "# INFO: Fast path without regexp (~2x faster)", "for", "value", "in", "h", ".", "split", "(", "','", ")", ":", "parts", "=", "value", ".", "sp...
Parses a typical multi-valued and parametrised HTTP header (e.g. Accept headers) and returns a list of values and parameters. For non-standard or broken input, this implementation may return partial results. :param h: A header string (e.g. ``text/html,text/plain;q=0.9,*/*;q=0.8``) :return: List of (valu...
[ "Parses", "a", "typical", "multi", "-", "valued", "and", "parametrised", "HTTP", "header", "(", "e", ".", "g", ".", "Accept", "headers", ")", "and", "returns", "a", "list", "of", "values", "and", "parameters", ".", "For", "non", "-", "standard", "or", ...
30fe89537379faea4de8c8b568ac6e52e4d15353
https://github.com/samghelms/mathviz/blob/30fe89537379faea4de8c8b568ac6e52e4d15353/mathviz_hopper/src/bottle.py#L2990-L3020
train
Parses a typical multi - valued and parametrised HTTP header string and returns a list of values and parameters.
samghelms/mathviz
mathviz_hopper/src/bottle.py
cookie_encode
def cookie_encode(data, key, digestmod=None): """ Encode and sign a pickle-able object. Return a (byte) string """ depr(0, 13, "cookie_encode() will be removed soon.", "Do not use this API directly.") digestmod = digestmod or hashlib.sha256 msg = base64.b64encode(pickle.dumps(data, -1)) ...
python
def cookie_encode(data, key, digestmod=None): """ Encode and sign a pickle-able object. Return a (byte) string """ depr(0, 13, "cookie_encode() will be removed soon.", "Do not use this API directly.") digestmod = digestmod or hashlib.sha256 msg = base64.b64encode(pickle.dumps(data, -1)) ...
[ "def", "cookie_encode", "(", "data", ",", "key", ",", "digestmod", "=", "None", ")", ":", "depr", "(", "0", ",", "13", ",", "\"cookie_encode() will be removed soon.\"", ",", "\"Do not use this API directly.\"", ")", "digestmod", "=", "digestmod", "or", "hashlib", ...
Encode and sign a pickle-able object. Return a (byte) string
[ "Encode", "and", "sign", "a", "pickle", "-", "able", "object", ".", "Return", "a", "(", "byte", ")", "string" ]
30fe89537379faea4de8c8b568ac6e52e4d15353
https://github.com/samghelms/mathviz/blob/30fe89537379faea4de8c8b568ac6e52e4d15353/mathviz_hopper/src/bottle.py#L3042-L3049
train
Encode and sign a pickle - able object. Return a byte string.