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
Loudr/pale
pale/adapters/webapp2.py
pale_webapp2_request_handler_generator
def pale_webapp2_request_handler_generator(pale_endpoint): """Generate a webapp2.RequestHandler class for the pale endpoint. webapp2 handles requests with subclasses of the RequestHandler class, instead of using functions like Flask, so we need to generate a new class for each pale endpoint. """ ...
python
def pale_webapp2_request_handler_generator(pale_endpoint): """Generate a webapp2.RequestHandler class for the pale endpoint. webapp2 handles requests with subclasses of the RequestHandler class, instead of using functions like Flask, so we need to generate a new class for each pale endpoint. """ ...
[ "def", "pale_webapp2_request_handler_generator", "(", "pale_endpoint", ")", ":", "def", "pale_handler", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "request", ".", "method", "==", "\"OPTIONS\"", ":", "origin", "=", ...
Generate a webapp2.RequestHandler class for the pale endpoint. webapp2 handles requests with subclasses of the RequestHandler class, instead of using functions like Flask, so we need to generate a new class for each pale endpoint.
[ "Generate", "a", "webapp2", ".", "RequestHandler", "class", "for", "the", "pale", "endpoint", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/adapters/webapp2.py#L20-L44
train
Generate a webapp2. RequestHandler class for the pale endpoint.
Loudr/pale
pale/adapters/webapp2.py
bind_pale_to_webapp2
def bind_pale_to_webapp2(pale_app_module, webapp_wsgiapplication, route_prefix=None): """Binds a Pale API implementation to a webapp2 WSGIApplication""" if not isinstance(webapp_wsgiapplication, webapp2.WSGIApplication): raise TypeError("pale.adapters.webapp2.bind_pale_to_webapp2 expect...
python
def bind_pale_to_webapp2(pale_app_module, webapp_wsgiapplication, route_prefix=None): """Binds a Pale API implementation to a webapp2 WSGIApplication""" if not isinstance(webapp_wsgiapplication, webapp2.WSGIApplication): raise TypeError("pale.adapters.webapp2.bind_pale_to_webapp2 expect...
[ "def", "bind_pale_to_webapp2", "(", "pale_app_module", ",", "webapp_wsgiapplication", ",", "route_prefix", "=", "None", ")", ":", "if", "not", "isinstance", "(", "webapp_wsgiapplication", ",", "webapp2", ".", "WSGIApplication", ")", ":", "raise", "TypeError", "(", ...
Binds a Pale API implementation to a webapp2 WSGIApplication
[ "Binds", "a", "Pale", "API", "implementation", "to", "a", "webapp2", "WSGIApplication" ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/adapters/webapp2.py#L47-L84
train
Binds a Pale API implementation to a webapp2 WSGIApplication.
a1ezzz/wasp-general
wasp_general/network/messenger/coders.py
WMessengerFixedModificationLayer.__args_check
def __args_check(self, envelope, target, modification_code): """ Method checks arguments, that are specified to the :meth:`.WMessengerFixedModificationLayer.encode` and :meth:`.WMessengerFixedModificationLayer.decode` methods :param envelope: same as envelope in :meth:`.WMessengerFixedModificationLayer.encode`...
python
def __args_check(self, envelope, target, modification_code): """ Method checks arguments, that are specified to the :meth:`.WMessengerFixedModificationLayer.encode` and :meth:`.WMessengerFixedModificationLayer.decode` methods :param envelope: same as envelope in :meth:`.WMessengerFixedModificationLayer.encode`...
[ "def", "__args_check", "(", "self", ",", "envelope", ",", "target", ",", "modification_code", ")", ":", "if", "target", "is", "None", ":", "raise", "RuntimeError", "(", "'\"target\" argument must be specified for this layer'", ")", "if", "modification_code", "is", "...
Method checks arguments, that are specified to the :meth:`.WMessengerFixedModificationLayer.encode` and :meth:`.WMessengerFixedModificationLayer.decode` methods :param envelope: same as envelope in :meth:`.WMessengerFixedModificationLayer.encode` and \ :meth:`.WMessengerFixedModificationLayer.decode` methods ...
[ "Method", "checks", "arguments", "that", "are", "specified", "to", "the", ":", "meth", ":", ".", "WMessengerFixedModificationLayer", ".", "encode", "and", ":", "meth", ":", ".", "WMessengerFixedModificationLayer", ".", "decode", "methods" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/coders.py#L72-L99
train
Method checks the arguments for the object.
a1ezzz/wasp-general
wasp_general/network/messenger/coders.py
WMessengerFixedModificationLayer.encode
def encode(self, envelope, session, target=None, modification_code=None, **kwargs): """ Methods appends 'modification_code' to the specified envelope. :param envelope: original envelope :param session: original session :param target: flag, that specifies whether code must be appended to the start or to the end...
python
def encode(self, envelope, session, target=None, modification_code=None, **kwargs): """ Methods appends 'modification_code' to the specified envelope. :param envelope: original envelope :param session: original session :param target: flag, that specifies whether code must be appended to the start or to the end...
[ "def", "encode", "(", "self", ",", "envelope", ",", "session", ",", "target", "=", "None", ",", "modification_code", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "__args_check", "(", "envelope", ",", "target", ",", "modification_code", ")...
Methods appends 'modification_code' to the specified envelope. :param envelope: original envelope :param session: original session :param target: flag, that specifies whether code must be appended to the start or to the end :param modification_code: code to append :param kwargs: additional arguments :retu...
[ "Methods", "appends", "modification_code", "to", "the", "specified", "envelope", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/coders.py#L103-L124
train
Method appends modification_code to the specified envelope.
a1ezzz/wasp-general
wasp_general/network/messenger/coders.py
WMessengerFixedModificationLayer.decode
def decode(self, envelope, session, target=None, modification_code=None, **kwargs): """ Methods checks envelope for 'modification_code' existence and removes it. :param envelope: original envelope :param session: original session :param target: flag, that specifies whether code must be searched and removed at ...
python
def decode(self, envelope, session, target=None, modification_code=None, **kwargs): """ Methods checks envelope for 'modification_code' existence and removes it. :param envelope: original envelope :param session: original session :param target: flag, that specifies whether code must be searched and removed at ...
[ "def", "decode", "(", "self", ",", "envelope", ",", "session", ",", "target", "=", "None", ",", "modification_code", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "__args_check", "(", "envelope", ",", "target", ",", "modification_code", ")...
Methods checks envelope for 'modification_code' existence and removes it. :param envelope: original envelope :param session: original session :param target: flag, that specifies whether code must be searched and removed at the start or at the end :param modification_code: code to search/remove :param kwargs:...
[ "Methods", "checks", "envelope", "for", "modification_code", "existence", "and", "removes", "it", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/coders.py#L128-L157
train
This method decodes the given envelope and returns the decoded envelope.
a1ezzz/wasp-general
wasp_general/network/messenger/coders.py
WMessengerEncodingLayer.encode
def encode(self, envelope, session, encoding=None, **kwargs): """ :meth:`.WMessengerOnionCoderLayerProto.encode` method implementation. :param envelope: original envelope :param session: original session :param encoding: encoding to use (default is 'utf-8') :param kwargs: additional arguments :return: WMe...
python
def encode(self, envelope, session, encoding=None, **kwargs): """ :meth:`.WMessengerOnionCoderLayerProto.encode` method implementation. :param envelope: original envelope :param session: original session :param encoding: encoding to use (default is 'utf-8') :param kwargs: additional arguments :return: WMe...
[ "def", "encode", "(", "self", ",", "envelope", ",", "session", ",", "encoding", "=", "None", ",", "*", "*", "kwargs", ")", ":", "message", "=", "envelope", ".", "message", "(", ")", "message", "=", "message", ".", "encode", "(", ")", "if", "encoding"...
:meth:`.WMessengerOnionCoderLayerProto.encode` method implementation. :param envelope: original envelope :param session: original session :param encoding: encoding to use (default is 'utf-8') :param kwargs: additional arguments :return: WMessengerBytesEnvelope
[ ":", "meth", ":", ".", "WMessengerOnionCoderLayerProto", ".", "encode", "method", "implementation", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/coders.py#L176-L188
train
method implementation.
a1ezzz/wasp-general
wasp_general/network/messenger/coders.py
WMessengerEncodingLayer.decode
def decode(self, envelope, session, encoding=None, **kwargs): """ :meth:`.WMessengerOnionCoderLayerProto.decode` method implementation. :param envelope: original envelope :param session: original session :param encoding: encoding to use (default is 'utf-8') :param kwargs: additional arguments :return: WMe...
python
def decode(self, envelope, session, encoding=None, **kwargs): """ :meth:`.WMessengerOnionCoderLayerProto.decode` method implementation. :param envelope: original envelope :param session: original session :param encoding: encoding to use (default is 'utf-8') :param kwargs: additional arguments :return: WMe...
[ "def", "decode", "(", "self", ",", "envelope", ",", "session", ",", "encoding", "=", "None", ",", "*", "*", "kwargs", ")", ":", "message", "=", "envelope", ".", "message", "(", ")", "message", "=", "message", ".", "decode", "(", ")", "if", "encoding"...
:meth:`.WMessengerOnionCoderLayerProto.decode` method implementation. :param envelope: original envelope :param session: original session :param encoding: encoding to use (default is 'utf-8') :param kwargs: additional arguments :return: WMessengerTextEnvelope
[ ":", "meth", ":", ".", "WMessengerOnionCoderLayerProto", ".", "decode", "method", "implementation", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/coders.py#L192-L204
train
method implementation.
a1ezzz/wasp-general
wasp_general/network/messenger/coders.py
WMessengerHexLayer.encode
def encode(self, envelope, session, **kwargs): """ :meth:`.WMessengerOnionCoderLayerProto.encode` method implementation. :param envelope: original envelope :param session: original session :param kwargs: additional arguments :return: WMessengerTextEnvelope """ return WMessengerTextEnvelope(str(WHex(enve...
python
def encode(self, envelope, session, **kwargs): """ :meth:`.WMessengerOnionCoderLayerProto.encode` method implementation. :param envelope: original envelope :param session: original session :param kwargs: additional arguments :return: WMessengerTextEnvelope """ return WMessengerTextEnvelope(str(WHex(enve...
[ "def", "encode", "(", "self", ",", "envelope", ",", "session", ",", "*", "*", "kwargs", ")", ":", "return", "WMessengerTextEnvelope", "(", "str", "(", "WHex", "(", "envelope", ".", "message", "(", ")", ")", ")", ",", "meta", "=", "envelope", ")" ]
:meth:`.WMessengerOnionCoderLayerProto.encode` method implementation. :param envelope: original envelope :param session: original session :param kwargs: additional arguments :return: WMessengerTextEnvelope
[ ":", "meth", ":", ".", "WMessengerOnionCoderLayerProto", ".", "encode", "method", "implementation", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/coders.py#L223-L232
train
method implementation. encode
a1ezzz/wasp-general
wasp_general/network/messenger/coders.py
WMessengerHexLayer.decode
def decode(self, envelope, session, **kwargs): """ :meth:`.WMessengerOnionCoderLayerProto.decode` method implementation. :param envelope: original envelope :param session: original session :param kwargs: additional arguments :return: WMessengerBytesEnvelope """ return WMessengerBytesEnvelope(bytes(WUnHe...
python
def decode(self, envelope, session, **kwargs): """ :meth:`.WMessengerOnionCoderLayerProto.decode` method implementation. :param envelope: original envelope :param session: original session :param kwargs: additional arguments :return: WMessengerBytesEnvelope """ return WMessengerBytesEnvelope(bytes(WUnHe...
[ "def", "decode", "(", "self", ",", "envelope", ",", "session", ",", "*", "*", "kwargs", ")", ":", "return", "WMessengerBytesEnvelope", "(", "bytes", "(", "WUnHex", "(", "envelope", ".", "message", "(", ")", ")", ")", ",", "meta", "=", "envelope", ")" ]
:meth:`.WMessengerOnionCoderLayerProto.decode` method implementation. :param envelope: original envelope :param session: original session :param kwargs: additional arguments :return: WMessengerBytesEnvelope
[ ":", "meth", ":", ".", "WMessengerOnionCoderLayerProto", ".", "decode", "method", "implementation", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/coders.py#L236-L245
train
method implementation. decode
a1ezzz/wasp-general
wasp_general/network/messenger/coders.py
WMessengerBase64Layer.encode
def encode(self, envelope, session, **kwargs): """ :meth:`.WMessengerOnionCoderLayerProto.encode` method implementation. :param envelope: original envelope :param session: original session :param kwargs: additional arguments :return: WMessengerBytesEnvelope """ return WMessengerBytesEnvelope(b64encode(e...
python
def encode(self, envelope, session, **kwargs): """ :meth:`.WMessengerOnionCoderLayerProto.encode` method implementation. :param envelope: original envelope :param session: original session :param kwargs: additional arguments :return: WMessengerBytesEnvelope """ return WMessengerBytesEnvelope(b64encode(e...
[ "def", "encode", "(", "self", ",", "envelope", ",", "session", ",", "*", "*", "kwargs", ")", ":", "return", "WMessengerBytesEnvelope", "(", "b64encode", "(", "envelope", ".", "message", "(", ")", ")", ",", "meta", "=", "envelope", ")" ]
:meth:`.WMessengerOnionCoderLayerProto.encode` method implementation. :param envelope: original envelope :param session: original session :param kwargs: additional arguments :return: WMessengerBytesEnvelope
[ ":", "meth", ":", ".", "WMessengerOnionCoderLayerProto", ".", "encode", "method", "implementation", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/coders.py#L265-L274
train
method implementation. encode method implementation.
a1ezzz/wasp-general
wasp_general/network/messenger/coders.py
WMessengerBase64Layer.decode
def decode(self, envelope, session, **kwargs): """ :meth:`.WMessengerOnionCoderLayerProto.decode` method implementation. :param envelope: original envelope :param session: original session :param kwargs: additional arguments :return: WMessengerBytesEnvelope """ return WMessengerBytesEnvelope(b64decode(e...
python
def decode(self, envelope, session, **kwargs): """ :meth:`.WMessengerOnionCoderLayerProto.decode` method implementation. :param envelope: original envelope :param session: original session :param kwargs: additional arguments :return: WMessengerBytesEnvelope """ return WMessengerBytesEnvelope(b64decode(e...
[ "def", "decode", "(", "self", ",", "envelope", ",", "session", ",", "*", "*", "kwargs", ")", ":", "return", "WMessengerBytesEnvelope", "(", "b64decode", "(", "envelope", ".", "message", "(", ")", ")", ",", "meta", "=", "envelope", ")" ]
:meth:`.WMessengerOnionCoderLayerProto.decode` method implementation. :param envelope: original envelope :param session: original session :param kwargs: additional arguments :return: WMessengerBytesEnvelope
[ ":", "meth", ":", ".", "WMessengerOnionCoderLayerProto", ".", "decode", "method", "implementation", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/coders.py#L278-L287
train
method implementation. decode
a1ezzz/wasp-general
wasp_general/network/messenger/coders.py
WMessengerAESLayer.encode
def encode(self, envelope, session, aes_cipher=None, **kwargs): """ :meth:`.WMessengerOnionCoderLayerProto.encode` method implementation. :param envelope: original envelope :param session: original session :param aes_cipher: cipher to use :param kwargs: additional arguments :return: WMessengerBytesEnvelop...
python
def encode(self, envelope, session, aes_cipher=None, **kwargs): """ :meth:`.WMessengerOnionCoderLayerProto.encode` method implementation. :param envelope: original envelope :param session: original session :param aes_cipher: cipher to use :param kwargs: additional arguments :return: WMessengerBytesEnvelop...
[ "def", "encode", "(", "self", ",", "envelope", ",", "session", ",", "aes_cipher", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "WMessengerBytesEnvelope", "(", "aes_cipher", ".", "encrypt", "(", "envelope", ".", "message", "(", ")", ")", ",",...
:meth:`.WMessengerOnionCoderLayerProto.encode` method implementation. :param envelope: original envelope :param session: original session :param aes_cipher: cipher to use :param kwargs: additional arguments :return: WMessengerBytesEnvelope
[ ":", "meth", ":", ".", "WMessengerOnionCoderLayerProto", ".", "encode", "method", "implementation", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/coders.py#L307-L317
train
method implementation.
a1ezzz/wasp-general
wasp_general/network/messenger/coders.py
WMessengerAESLayer.decode
def decode(self, envelope, session, aes_cipher=None, **kwargs): """ :meth:`.WMessengerOnionCoderLayerProto.decode` method implementation. :param envelope: original envelope :param session: original session :param aes_cipher: cipher to use :param kwargs: additional arguments :return: WMessengerBytesEnvelop...
python
def decode(self, envelope, session, aes_cipher=None, **kwargs): """ :meth:`.WMessengerOnionCoderLayerProto.decode` method implementation. :param envelope: original envelope :param session: original session :param aes_cipher: cipher to use :param kwargs: additional arguments :return: WMessengerBytesEnvelop...
[ "def", "decode", "(", "self", ",", "envelope", ",", "session", ",", "aes_cipher", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "WMessengerBytesEnvelope", "(", "aes_cipher", ".", "decrypt", "(", "envelope", ".", "message", "(", ")", ",", "dec...
:meth:`.WMessengerOnionCoderLayerProto.decode` method implementation. :param envelope: original envelope :param session: original session :param aes_cipher: cipher to use :param kwargs: additional arguments :return: WMessengerBytesEnvelope
[ ":", "meth", ":", ".", "WMessengerOnionCoderLayerProto", ".", "decode", "method", "implementation", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/coders.py#L322-L332
train
method implementation. decode
a1ezzz/wasp-general
wasp_general/network/messenger/coders.py
WMessengerRSALayer.encode
def encode(self, envelope, session, public_key=None, oaep_hash_fn_name=None, mgf1_hash_fn_name=None, **kwargs): """ :meth:`.WMessengerOnionCoderLayerProto.encode` method implementation. :param envelope: original envelope :param session: original session :param public_key: public key to encrypt :param oaep_ha...
python
def encode(self, envelope, session, public_key=None, oaep_hash_fn_name=None, mgf1_hash_fn_name=None, **kwargs): """ :meth:`.WMessengerOnionCoderLayerProto.encode` method implementation. :param envelope: original envelope :param session: original session :param public_key: public key to encrypt :param oaep_ha...
[ "def", "encode", "(", "self", ",", "envelope", ",", "session", ",", "public_key", "=", "None", ",", "oaep_hash_fn_name", "=", "None", ",", "mgf1_hash_fn_name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "message", "=", "public_key", ".", "encrypt", ...
:meth:`.WMessengerOnionCoderLayerProto.encode` method implementation. :param envelope: original envelope :param session: original session :param public_key: public key to encrypt :param oaep_hash_fn_name: OAEP hash function name :param mgf1_hash_fn_name: MGF1 hash function name :param kwargs: additional ar...
[ ":", "meth", ":", ".", "WMessengerOnionCoderLayerProto", ".", "encode", "method", "implementation", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/coders.py#L353-L368
train
This method encrypts the given envelope with the given session.
a1ezzz/wasp-general
wasp_general/network/messenger/coders.py
WMessengerRSALayer.decode
def decode(self, envelope, session, private_key=None, oaep_hash_fn_name=None, mgf1_hash_fn_name=None, **kwargs): """ :meth:`.WMessengerOnionCoderLayerProto.decode` method implementation. :param envelope: original envelope :param session: original session :param private_key: private key to decrypt :param oaep...
python
def decode(self, envelope, session, private_key=None, oaep_hash_fn_name=None, mgf1_hash_fn_name=None, **kwargs): """ :meth:`.WMessengerOnionCoderLayerProto.decode` method implementation. :param envelope: original envelope :param session: original session :param private_key: private key to decrypt :param oaep...
[ "def", "decode", "(", "self", ",", "envelope", ",", "session", ",", "private_key", "=", "None", ",", "oaep_hash_fn_name", "=", "None", ",", "mgf1_hash_fn_name", "=", "None", ",", "*", "*", "kwargs", ")", ":", "message", "=", "private_key", ".", "decrypt", ...
:meth:`.WMessengerOnionCoderLayerProto.decode` method implementation. :param envelope: original envelope :param session: original session :param private_key: private key to decrypt :param oaep_hash_fn_name: hash function name :param mgf1_hash_fn_name: MGF1 hash function name :param kwargs: additional argum...
[ ":", "meth", ":", ".", "WMessengerOnionCoderLayerProto", ".", "decode", "method", "implementation", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/coders.py#L374-L389
train
method implementation.
a1ezzz/wasp-general
wasp_general/task/dependency.py
WTaskDependencyRegistryStorage.dependency_check
def dependency_check(self, task_cls, skip_unresolved=False): """ Check dependency of task for irresolvable conflicts (like task to task mutual dependency) :param task_cls: task to check :param skip_unresolved: flag controls this method behaviour for tasks that could not be found. \ When False, method will rais...
python
def dependency_check(self, task_cls, skip_unresolved=False): """ Check dependency of task for irresolvable conflicts (like task to task mutual dependency) :param task_cls: task to check :param skip_unresolved: flag controls this method behaviour for tasks that could not be found. \ When False, method will rais...
[ "def", "dependency_check", "(", "self", ",", "task_cls", ",", "skip_unresolved", "=", "False", ")", ":", "def", "check", "(", "check_task_cls", ",", "global_dependencies", ")", ":", "if", "check_task_cls", ".", "__registry_tag__", "in", "global_dependencies", ":",...
Check dependency of task for irresolvable conflicts (like task to task mutual dependency) :param task_cls: task to check :param skip_unresolved: flag controls this method behaviour for tasks that could not be found. \ When False, method will raise an exception if task tag was set in dependency and the related ta...
[ "Check", "dependency", "of", "task", "for", "irresolvable", "conflicts", "(", "like", "task", "to", "task", "mutual", "dependency", ")" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/dependency.py#L122-L151
train
Check dependency of task for irresolvable conflicts
a1ezzz/wasp-general
wasp_general/task/dependency.py
WTaskDependencyRegistryStorage.started_tasks
def started_tasks(self, task_registry_id=None, task_cls=None): """ Return tasks that was started. Result way be filtered by the given arguments. :param task_registry_id: if it is specified, then try to return single task which id is the same as \ this value. :param task_cls: if it is specified then result will...
python
def started_tasks(self, task_registry_id=None, task_cls=None): """ Return tasks that was started. Result way be filtered by the given arguments. :param task_registry_id: if it is specified, then try to return single task which id is the same as \ this value. :param task_cls: if it is specified then result will...
[ "def", "started_tasks", "(", "self", ",", "task_registry_id", "=", "None", ",", "task_cls", "=", "None", ")", ":", "if", "task_registry_id", "is", "not", "None", ":", "task", "=", "None", "for", "registered_task", "in", "self", ".", "__started", ":", "if",...
Return tasks that was started. Result way be filtered by the given arguments. :param task_registry_id: if it is specified, then try to return single task which id is the same as \ this value. :param task_cls: if it is specified then result will be consists of this subclass only :return: None or WTask or tuple...
[ "Return", "tasks", "that", "was", "started", ".", "Result", "way", "be", "filtered", "by", "the", "given", "arguments", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/dependency.py#L153-L178
train
Return tasks that were started. Result way be filtered by the given arguments.
a1ezzz/wasp-general
wasp_general/task/dependency.py
WTaskDependencyRegistryStorage.start_task
def start_task(self, task_tag, skip_unresolved=False): """ Check dependency for the given task_tag and start task. For dependency checking see :meth:`.WTaskDependencyRegistryStorage.dependency_check`. If task is already started then it must be stopped before it will be started again. :param task_tag: task to s...
python
def start_task(self, task_tag, skip_unresolved=False): """ Check dependency for the given task_tag and start task. For dependency checking see :meth:`.WTaskDependencyRegistryStorage.dependency_check`. If task is already started then it must be stopped before it will be started again. :param task_tag: task to s...
[ "def", "start_task", "(", "self", ",", "task_tag", ",", "skip_unresolved", "=", "False", ")", ":", "if", "self", ".", "started_tasks", "(", "task_registry_id", "=", "task_tag", ")", "is", "not", "None", ":", "return", "task_cls", "=", "self", ".", "tasks_b...
Check dependency for the given task_tag and start task. For dependency checking see :meth:`.WTaskDependencyRegistryStorage.dependency_check`. If task is already started then it must be stopped before it will be started again. :param task_tag: task to start. Any required dependencies will be started automatically...
[ "Check", "dependency", "for", "the", "given", "task_tag", "and", "start", "task", ".", "For", "dependency", "checking", "see", ":", "meth", ":", ".", "WTaskDependencyRegistryStorage", ".", "dependency_check", ".", "If", "task", "is", "already", "started", "then"...
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/dependency.py#L181-L215
train
Check dependency for the given task_tag and start task.
a1ezzz/wasp-general
wasp_general/task/dependency.py
WTaskDependencyRegistryStorage.stop_task
def stop_task(self, task_tag, stop_dependent=True, stop_requirements=False): """ Stop task with the given task tag. If task already stopped, then nothing happens. :param task_tag: task to stop :param stop_dependent: if True, then every task, that require the given task as dependency, will be \ stopped before. ...
python
def stop_task(self, task_tag, stop_dependent=True, stop_requirements=False): """ Stop task with the given task tag. If task already stopped, then nothing happens. :param task_tag: task to stop :param stop_dependent: if True, then every task, that require the given task as dependency, will be \ stopped before. ...
[ "def", "stop_task", "(", "self", ",", "task_tag", ",", "stop_dependent", "=", "True", ",", "stop_requirements", "=", "False", ")", ":", "# TODO: \"coverage\" requires more tests", "task", "=", "self", ".", "started_tasks", "(", "task_registry_id", "=", "task_tag", ...
Stop task with the given task tag. If task already stopped, then nothing happens. :param task_tag: task to stop :param stop_dependent: if True, then every task, that require the given task as dependency, will be \ stopped before. :param stop_requirements: if True, then every task, that is required as dependenc...
[ "Stop", "task", "with", "the", "given", "task", "tag", ".", "If", "task", "already", "stopped", "then", "nothing", "happens", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/dependency.py#L218-L312
train
Stop a task with the given task tag.
a1ezzz/wasp-general
wasp_general/task/dependency.py
WTaskDependencyRegistry.registry_storage
def registry_storage(cls): """ Get registry storage :return: WTaskDependencyRegistryStorage """ if cls.__registry_storage__ is None: raise ValueError('__registry_storage__ must be defined') if isinstance(cls.__registry_storage__, WTaskDependencyRegistryStorage) is False: raise TypeError( "Property ...
python
def registry_storage(cls): """ Get registry storage :return: WTaskDependencyRegistryStorage """ if cls.__registry_storage__ is None: raise ValueError('__registry_storage__ must be defined') if isinstance(cls.__registry_storage__, WTaskDependencyRegistryStorage) is False: raise TypeError( "Property ...
[ "def", "registry_storage", "(", "cls", ")", ":", "if", "cls", ".", "__registry_storage__", "is", "None", ":", "raise", "ValueError", "(", "'__registry_storage__ must be defined'", ")", "if", "isinstance", "(", "cls", ".", "__registry_storage__", ",", "WTaskDependenc...
Get registry storage :return: WTaskDependencyRegistryStorage
[ "Get", "registry", "storage" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/dependency.py#L323-L335
train
Get registry storage : return: WTaskDependencyRegistryStorage
a1ezzz/wasp-general
wasp_general/task/dependency.py
WTaskDependencyRegistry.start_task
def start_task(cls, task_tag, skip_unresolved=False): """ Start task from registry :param task_tag: same as in :meth:`.WTaskDependencyRegistryStorage.start_task` method :param skip_unresolved: same as in :meth:`.WTaskDependencyRegistryStorage.start_task` method :return: None """ registry = cls.registry_sto...
python
def start_task(cls, task_tag, skip_unresolved=False): """ Start task from registry :param task_tag: same as in :meth:`.WTaskDependencyRegistryStorage.start_task` method :param skip_unresolved: same as in :meth:`.WTaskDependencyRegistryStorage.start_task` method :return: None """ registry = cls.registry_sto...
[ "def", "start_task", "(", "cls", ",", "task_tag", ",", "skip_unresolved", "=", "False", ")", ":", "registry", "=", "cls", ".", "registry_storage", "(", ")", "registry", ".", "start_task", "(", "task_tag", ",", "skip_unresolved", "=", "skip_unresolved", ")" ]
Start task from registry :param task_tag: same as in :meth:`.WTaskDependencyRegistryStorage.start_task` method :param skip_unresolved: same as in :meth:`.WTaskDependencyRegistryStorage.start_task` method :return: None
[ "Start", "task", "from", "registry" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/dependency.py#L338-L346
train
Start task from registry
a1ezzz/wasp-general
wasp_general/task/dependency.py
WTaskDependencyRegistry.stop_task
def stop_task(cls, task_tag, stop_dependent=True, stop_requirements=False): """ Stop started task from registry :param task_tag: same as in :meth:`.WTaskDependencyRegistryStorage.stop_task` method :param stop_dependent: same as in :meth:`.WTaskDependencyRegistryStorage.stop_task` method :param stop_requirement...
python
def stop_task(cls, task_tag, stop_dependent=True, stop_requirements=False): """ Stop started task from registry :param task_tag: same as in :meth:`.WTaskDependencyRegistryStorage.stop_task` method :param stop_dependent: same as in :meth:`.WTaskDependencyRegistryStorage.stop_task` method :param stop_requirement...
[ "def", "stop_task", "(", "cls", ",", "task_tag", ",", "stop_dependent", "=", "True", ",", "stop_requirements", "=", "False", ")", ":", "registry", "=", "cls", ".", "registry_storage", "(", ")", "registry", ".", "stop_task", "(", "task_tag", ",", "stop_depend...
Stop started task from registry :param task_tag: same as in :meth:`.WTaskDependencyRegistryStorage.stop_task` method :param stop_dependent: same as in :meth:`.WTaskDependencyRegistryStorage.stop_task` method :param stop_requirements: same as in :meth:`.WTaskDependencyRegistryStorage.stop_task` method :return: ...
[ "Stop", "started", "task", "from", "registry" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/dependency.py#L349-L358
train
Stop started task from registry
jahuth/litus
__init__.py
snip
def snip(tag="",start=-2,write_date=True): """ This function records a previously execute notebook cell into a file (default: ipython_history.py) a tag can be added to sort the cell `start` defines which cell in the history to record. Default is -2, ie. the one executed previously to the ...
python
def snip(tag="",start=-2,write_date=True): """ This function records a previously execute notebook cell into a file (default: ipython_history.py) a tag can be added to sort the cell `start` defines which cell in the history to record. Default is -2, ie. the one executed previously to the ...
[ "def", "snip", "(", "tag", "=", "\"\"", ",", "start", "=", "-", "2", ",", "write_date", "=", "True", ")", ":", "import", "IPython", "i", "=", "IPython", ".", "get_ipython", "(", ")", "last_history", "=", "i", ".", "history_manager", ".", "get_range", ...
This function records a previously execute notebook cell into a file (default: ipython_history.py) a tag can be added to sort the cell `start` defines which cell in the history to record. Default is -2, ie. the one executed previously to the current one.
[ "This", "function", "records", "a", "previously", "execute", "notebook", "cell", "into", "a", "file", "(", "default", ":", "ipython_history", ".", "py", ")" ]
712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e
https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/__init__.py#L22-L49
train
This function records a previously executed notebook cell into a file.
jahuth/litus
__init__.py
snip_this
def snip_this(tag="",write_date=True): """ When this function is invoced in a notebook cell, the cell is snipped. """ snip(tag=tag,start=-1,write_date=write_date)
python
def snip_this(tag="",write_date=True): """ When this function is invoced in a notebook cell, the cell is snipped. """ snip(tag=tag,start=-1,write_date=write_date)
[ "def", "snip_this", "(", "tag", "=", "\"\"", ",", "write_date", "=", "True", ")", ":", "snip", "(", "tag", "=", "tag", ",", "start", "=", "-", "1", ",", "write_date", "=", "write_date", ")" ]
When this function is invoced in a notebook cell, the cell is snipped.
[ "When", "this", "function", "is", "invoced", "in", "a", "notebook", "cell", "the", "cell", "is", "snipped", "." ]
712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e
https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/__init__.py#L51-L53
train
This function is used to snip the current cell in a notebook cell.
jahuth/litus
__init__.py
unsnip
def unsnip(tag=None,start=-1): """ This function retrieves a tagged or untagged snippet. """ import IPython i = IPython.get_ipython() if tag in _tagged_inputs.keys(): if len(_tagged_inputs[tag]) > 0: i.set_next_input(_tagged_inputs[tag][start]) else: if len(_last_inputs) ...
python
def unsnip(tag=None,start=-1): """ This function retrieves a tagged or untagged snippet. """ import IPython i = IPython.get_ipython() if tag in _tagged_inputs.keys(): if len(_tagged_inputs[tag]) > 0: i.set_next_input(_tagged_inputs[tag][start]) else: if len(_last_inputs) ...
[ "def", "unsnip", "(", "tag", "=", "None", ",", "start", "=", "-", "1", ")", ":", "import", "IPython", "i", "=", "IPython", ".", "get_ipython", "(", ")", "if", "tag", "in", "_tagged_inputs", ".", "keys", "(", ")", ":", "if", "len", "(", "_tagged_inp...
This function retrieves a tagged or untagged snippet.
[ "This", "function", "retrieves", "a", "tagged", "or", "untagged", "snippet", "." ]
712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e
https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/__init__.py#L55-L64
train
This function retrieves a tagged or untagged snippet.
jahuth/litus
__init__.py
figure
def figure(path,display=False,close=True): """ Can be used with the **with** statement:: import litus import numpy as np import matplotlib.pylab as plt x = np.arange(0,10,0.1) with litus.figure("some_test.png") as f: plt.plot(x,np.cos(x)) # plots to a firs...
python
def figure(path,display=False,close=True): """ Can be used with the **with** statement:: import litus import numpy as np import matplotlib.pylab as plt x = np.arange(0,10,0.1) with litus.figure("some_test.png") as f: plt.plot(x,np.cos(x)) # plots to a firs...
[ "def", "figure", "(", "path", ",", "display", "=", "False", ",", "close", "=", "True", ")", ":", "return", "Figure", "(", "path", ",", "display", "=", "display", ",", "close", "=", "close", ")" ]
Can be used with the **with** statement:: import litus import numpy as np import matplotlib.pylab as plt x = np.arange(0,10,0.1) with litus.figure("some_test.png") as f: plt.plot(x,np.cos(x)) # plots to a first plot with litus.figure("some_other_test.p...
[ "Can", "be", "used", "with", "the", "**", "with", "**", "statement", "::" ]
712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e
https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/__init__.py#L232-L265
train
Returns a figure object with the specified path.
jahuth/litus
__init__.py
alert
def alert(msg,body="",icon=None): """ alerts the user of something happening via `notify-send`. If it is not installed, the alert will be printed to the console. """ if type(body) == str: body = body[:200] if call(["which","notify-send"]) == 0: if icon is not None: ca...
python
def alert(msg,body="",icon=None): """ alerts the user of something happening via `notify-send`. If it is not installed, the alert will be printed to the console. """ if type(body) == str: body = body[:200] if call(["which","notify-send"]) == 0: if icon is not None: ca...
[ "def", "alert", "(", "msg", ",", "body", "=", "\"\"", ",", "icon", "=", "None", ")", ":", "if", "type", "(", "body", ")", "==", "str", ":", "body", "=", "body", "[", ":", "200", "]", "if", "call", "(", "[", "\"which\"", ",", "\"notify-send\"", ...
alerts the user of something happening via `notify-send`. If it is not installed, the alert will be printed to the console.
[ "alerts", "the", "user", "of", "something", "happening", "via", "notify", "-", "send", ".", "If", "it", "is", "not", "installed", "the", "alert", "will", "be", "printed", "to", "the", "console", "." ]
712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e
https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/__init__.py#L271-L283
train
alerts the user of something happening via notify - send.
jahuth/litus
__init__.py
natural_sorted
def natural_sorted(l): """ sorts a sortable in human order (0 < 20 < 100) """ ll = copy(l) ll.sort(key=_natural_keys) return ll
python
def natural_sorted(l): """ sorts a sortable in human order (0 < 20 < 100) """ ll = copy(l) ll.sort(key=_natural_keys) return ll
[ "def", "natural_sorted", "(", "l", ")", ":", "ll", "=", "copy", "(", "l", ")", "ll", ".", "sort", "(", "key", "=", "_natural_keys", ")", "return", "ll" ]
sorts a sortable in human order (0 < 20 < 100)
[ "sorts", "a", "sortable", "in", "human", "order", "(", "0", "<", "20", "<", "100", ")" ]
712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e
https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/__init__.py#L351-L355
train
sorts a sortable in human order
jahuth/litus
__init__.py
fillzip
def fillzip(*l): """like zip (for things that have a length), but repeats the last element of all shorter lists such that the result is as long as the longest.""" maximum = max(len(el) for el in l) return zip(*[el + [el[-1]]*(maximum-len(el)) for el in l])
python
def fillzip(*l): """like zip (for things that have a length), but repeats the last element of all shorter lists such that the result is as long as the longest.""" maximum = max(len(el) for el in l) return zip(*[el + [el[-1]]*(maximum-len(el)) for el in l])
[ "def", "fillzip", "(", "*", "l", ")", ":", "maximum", "=", "max", "(", "len", "(", "el", ")", "for", "el", "in", "l", ")", "return", "zip", "(", "*", "[", "el", "+", "[", "el", "[", "-", "1", "]", "]", "*", "(", "maximum", "-", "len", "("...
like zip (for things that have a length), but repeats the last element of all shorter lists such that the result is as long as the longest.
[ "like", "zip", "(", "for", "things", "that", "have", "a", "length", ")", "but", "repeats", "the", "last", "element", "of", "all", "shorter", "lists", "such", "that", "the", "result", "is", "as", "long", "as", "the", "longest", "." ]
712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e
https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/__init__.py#L502-L505
train
like zip but repeats the last element of all shorter lists.
jahuth/litus
__init__.py
recgen_enumerate
def recgen_enumerate(gen,n=tuple(), fix_type_errors=True): """ Iterates through generators recursively and flattens them. (see `recgen`) This function adds a tuple with enumerators on each generator visited. """ if not hasattr(gen,'__iter__'): yield (n,gen) else: try: ...
python
def recgen_enumerate(gen,n=tuple(), fix_type_errors=True): """ Iterates through generators recursively and flattens them. (see `recgen`) This function adds a tuple with enumerators on each generator visited. """ if not hasattr(gen,'__iter__'): yield (n,gen) else: try: ...
[ "def", "recgen_enumerate", "(", "gen", ",", "n", "=", "tuple", "(", ")", ",", "fix_type_errors", "=", "True", ")", ":", "if", "not", "hasattr", "(", "gen", ",", "'__iter__'", ")", ":", "yield", "(", "n", ",", "gen", ")", "else", ":", "try", ":", ...
Iterates through generators recursively and flattens them. (see `recgen`) This function adds a tuple with enumerators on each generator visited.
[ "Iterates", "through", "generators", "recursively", "and", "flattens", "them", ".", "(", "see", "recgen", ")" ]
712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e
https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/__init__.py#L543-L559
train
Iterate through generators recursively and flattens them.
jahuth/litus
__init__.py
list_of_dicts_to_dict_of_lists
def list_of_dicts_to_dict_of_lists(list_of_dictionaries): """ Takes a list of dictionaries and creates a dictionary with the combined values for each key in each dicitonary. Missing values are set to `None` for each dicitonary that does not contain a key that is present in at least...
python
def list_of_dicts_to_dict_of_lists(list_of_dictionaries): """ Takes a list of dictionaries and creates a dictionary with the combined values for each key in each dicitonary. Missing values are set to `None` for each dicitonary that does not contain a key that is present in at least...
[ "def", "list_of_dicts_to_dict_of_lists", "(", "list_of_dictionaries", ")", ":", "result", "=", "{", "}", "all_keys", "=", "set", "(", "[", "k", "for", "d", "in", "list_of_dictionaries", "for", "k", "in", "d", ".", "keys", "(", ")", "]", ")", "for", "d", ...
Takes a list of dictionaries and creates a dictionary with the combined values for each key in each dicitonary. Missing values are set to `None` for each dicitonary that does not contain a key that is present in at least one other dicitonary. >>> litus.list_of_dicts_to_dict_of_lis...
[ "Takes", "a", "list", "of", "dictionaries", "and", "creates", "a", "dictionary", "with", "the", "combined", "values", "for", "each", "key", "in", "each", "dicitonary", ".", "Missing", "values", "are", "set", "to", "None", "for", "each", "dicitonary", "that",...
712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e
https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/__init__.py#L564-L582
train
Takes a list of dictionaries and creates a dictionary of lists for each key in each dicitonary.
jahuth/litus
__init__.py
dict_of_lists_to_list_of_dicts
def dict_of_lists_to_list_of_dicts(dictionary_of_lists): """ Takes a dictionary of lists and creates a list of dictionaries. If the lists are of unequal length, the remaining entries are set to `None`. Shorthand: `litus.dl2ld(..)`: >>> litus.dl2ld({'a': [1, 3, 1], 'b': [2, 4, 2...
python
def dict_of_lists_to_list_of_dicts(dictionary_of_lists): """ Takes a dictionary of lists and creates a list of dictionaries. If the lists are of unequal length, the remaining entries are set to `None`. Shorthand: `litus.dl2ld(..)`: >>> litus.dl2ld({'a': [1, 3, 1], 'b': [2, 4, 2...
[ "def", "dict_of_lists_to_list_of_dicts", "(", "dictionary_of_lists", ")", ":", "return", "[", "{", "key", ":", "dictionary_of_lists", "[", "key", "]", "[", "index", "]", "if", "len", "(", "dictionary_of_lists", "[", "key", "]", ")", ">", "index", "else", "No...
Takes a dictionary of lists and creates a list of dictionaries. If the lists are of unequal length, the remaining entries are set to `None`. Shorthand: `litus.dl2ld(..)`: >>> litus.dl2ld({'a': [1, 3, 1], 'b': [2, 4, 2], 'c': [3, 5, 3]}) [{'a': 1, 'b': 2, 'c': 3}, {'a': 3, 'b':...
[ "Takes", "a", "dictionary", "of", "lists", "and", "creates", "a", "list", "of", "dictionaries", ".", "If", "the", "lists", "are", "of", "unequal", "length", "the", "remaining", "entries", "are", "set", "to", "None", "." ]
712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e
https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/__init__.py#L586-L599
train
Takes a dictionary of lists and creates a list of dictionaries.
jahuth/litus
__init__.py
colorate
def colorate(sequence, colormap="", start=0, length=None): """ like enumerate, but with colors """ n = start colors = color_space(colormap, sequence, start=0.1, stop=0.9, length=length) for elem in sequence: yield n, colors[n-start], elem n += 1
python
def colorate(sequence, colormap="", start=0, length=None): """ like enumerate, but with colors """ n = start colors = color_space(colormap, sequence, start=0.1, stop=0.9, length=length) for elem in sequence: yield n, colors[n-start], elem n += 1
[ "def", "colorate", "(", "sequence", ",", "colormap", "=", "\"\"", ",", "start", "=", "0", ",", "length", "=", "None", ")", ":", "n", "=", "start", "colors", "=", "color_space", "(", "colormap", ",", "sequence", ",", "start", "=", "0.1", ",", "stop", ...
like enumerate, but with colors
[ "like", "enumerate", "but", "with", "colors" ]
712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e
https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/__init__.py#L618-L624
train
like enumerate but with colors
jahuth/litus
__init__.py
PDContainerList.generate
def generate(self,**kwargs): """run once to create all children containers for each combination of the keywords""" import collections all_params = cartesian_dicts({k:kwargs[k] for k in kwargs.keys() if isinstance(kwargs[k], collections.Iterable)}) for pi,p in enumerate(all_params): ...
python
def generate(self,**kwargs): """run once to create all children containers for each combination of the keywords""" import collections all_params = cartesian_dicts({k:kwargs[k] for k in kwargs.keys() if isinstance(kwargs[k], collections.Iterable)}) for pi,p in enumerate(all_params): ...
[ "def", "generate", "(", "self", ",", "*", "*", "kwargs", ")", ":", "import", "collections", "all_params", "=", "cartesian_dicts", "(", "{", "k", ":", "kwargs", "[", "k", "]", "for", "k", "in", "kwargs", ".", "keys", "(", ")", "if", "isinstance", "(",...
run once to create all children containers for each combination of the keywords
[ "run", "once", "to", "create", "all", "children", "containers", "for", "each", "combination", "of", "the", "keywords" ]
712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e
https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/__init__.py#L764-L775
train
run once to create all children containers for each combination of the keywords
jahuth/litus
__init__.py
PDContainerList.param
def param(self,key,default=None): """for accessing global parameters""" if key in self.parameters: return self.parameters[key] return default
python
def param(self,key,default=None): """for accessing global parameters""" if key in self.parameters: return self.parameters[key] return default
[ "def", "param", "(", "self", ",", "key", ",", "default", "=", "None", ")", ":", "if", "key", "in", "self", ".", "parameters", ":", "return", "self", ".", "parameters", "[", "key", "]", "return", "default" ]
for accessing global parameters
[ "for", "accessing", "global", "parameters" ]
712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e
https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/__init__.py#L811-L815
train
for accessing global parameters
jahuth/litus
__init__.py
Lists.array
def array(self,n=-1): """returns a numpy array created from the list that was closed last (if `n`=-1). If `n` is None, the lists of the current level are returned as an array. Other lists in the current level can also be accessed with `n` as the specific index. """ if n is None: ...
python
def array(self,n=-1): """returns a numpy array created from the list that was closed last (if `n`=-1). If `n` is None, the lists of the current level are returned as an array. Other lists in the current level can also be accessed with `n` as the specific index. """ if n is None: ...
[ "def", "array", "(", "self", ",", "n", "=", "-", "1", ")", ":", "if", "n", "is", "None", ":", "return", "np", ".", "array", "(", "self", ".", "list", ")", "return", "np", ".", "array", "(", "self", ".", "list", ")", "[", "n", "]" ]
returns a numpy array created from the list that was closed last (if `n`=-1). If `n` is None, the lists of the current level are returned as an array. Other lists in the current level can also be accessed with `n` as the specific index.
[ "returns", "a", "numpy", "array", "created", "from", "the", "list", "that", "was", "closed", "last", "(", "if", "n", "=", "-", "1", ")", ".", "If", "n", "is", "None", "the", "lists", "of", "the", "current", "level", "are", "returned", "as", "an", "...
712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e
https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/__init__.py#L919-L926
train
returns a numpy array created from the list that was closed last n
jahuth/litus
__init__.py
Lists.generator
def generator(self,gen,*args,**kwargs): """ Use this function to enter and exit the context at the beginning and end of a generator. Example:: li = litus.Lists() for i in li.generator(range(100)): li.append(i) """ wit...
python
def generator(self,gen,*args,**kwargs): """ Use this function to enter and exit the context at the beginning and end of a generator. Example:: li = litus.Lists() for i in li.generator(range(100)): li.append(i) """ wit...
[ "def", "generator", "(", "self", ",", "gen", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "with", "self", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "i", "in", "gen", ":", "yield", "i" ]
Use this function to enter and exit the context at the beginning and end of a generator. Example:: li = litus.Lists() for i in li.generator(range(100)): li.append(i)
[ "Use", "this", "function", "to", "enter", "and", "exit", "the", "context", "at", "the", "beginning", "and", "end", "of", "a", "generator", "." ]
712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e
https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/__init__.py#L962-L975
train
Generator function that yields all the available items in the sequence.
Loudr/pale
pale/arguments/url.py
URLArgument.validate_url
def validate_url(self, original_string): """Returns the original string if it was valid, raises an argument error if it's not. """ # nipped from stack overflow: http://stackoverflow.com/questions/827557/how-do-you-validate-a-url-with-a-regular-expression-in-python # I preferred ...
python
def validate_url(self, original_string): """Returns the original string if it was valid, raises an argument error if it's not. """ # nipped from stack overflow: http://stackoverflow.com/questions/827557/how-do-you-validate-a-url-with-a-regular-expression-in-python # I preferred ...
[ "def", "validate_url", "(", "self", ",", "original_string", ")", ":", "# nipped from stack overflow: http://stackoverflow.com/questions/827557/how-do-you-validate-a-url-with-a-regular-expression-in-python", "# I preferred this to the thorough regex approach for simplicity and", "# readability", ...
Returns the original string if it was valid, raises an argument error if it's not.
[ "Returns", "the", "original", "string", "if", "it", "was", "valid", "raises", "an", "argument", "error", "if", "it", "s", "not", "." ]
dc002ee6032c856551143af222ff8f71ed9853fe
https://github.com/Loudr/pale/blob/dc002ee6032c856551143af222ff8f71ed9853fe/pale/arguments/url.py#L15-L37
train
Validates that the URL is valid raises an argument error if it s not.
projectshift/shift-schema
shiftschema/validators/digits.py
Digits.validate
def validate(self, value, model=None, context=None): """ Validate Perform value validation and return result :param value: value to check, cast to string :param model: parent model being validated :param context: object or None, validation con...
python
def validate(self, value, model=None, context=None): """ Validate Perform value validation and return result :param value: value to check, cast to string :param model: parent model being validated :param context: object or None, validation con...
[ "def", "validate", "(", "self", ",", "value", ",", "model", "=", "None", ",", "context", "=", "None", ")", ":", "import", "re", "value", "=", "str", "(", "value", ")", "match", "=", "re", ".", "match", "(", "r'^\\d+'", ",", "value", ")", "if", "n...
Validate Perform value validation and return result :param value: value to check, cast to string :param model: parent model being validated :param context: object or None, validation context :return: shiftschema.results.SimpleResult
[ "Validate", "Perform", "value", "validation", "and", "return", "result" ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/validators/digits.py#L24-L42
train
Validates the value of a key - value pair and returns a SimpleResult object.
alextricity25/dwell_in_you_richly
diyr/utils/bible.py
Bible.build_recovery_online_url
def build_recovery_online_url(self, book_name, book_chapter): """ Returns a string composing the url of the online.recoveryversion.bible of the given book name and chapter TODO: Write notes here about how that URL is composed, and what is expected by online.recoveryversion.bible ...
python
def build_recovery_online_url(self, book_name, book_chapter): """ Returns a string composing the url of the online.recoveryversion.bible of the given book name and chapter TODO: Write notes here about how that URL is composed, and what is expected by online.recoveryversion.bible ...
[ "def", "build_recovery_online_url", "(", "self", ",", "book_name", ",", "book_chapter", ")", ":", "base_url", "=", "\"http://online.recoveryversion.bible/txo\"", "return", "\"{}/{}_{}{}.htm\"", ".", "format", "(", "base_url", ",", "self", ".", "get_book_number", "(", ...
Returns a string composing the url of the online.recoveryversion.bible of the given book name and chapter TODO: Write notes here about how that URL is composed, and what is expected by online.recoveryversion.bible
[ "Returns", "a", "string", "composing", "the", "url", "of", "the", "online", ".", "recoveryversion", ".", "bible", "of", "the", "given", "book", "name", "and", "chapter", "TODO", ":", "Write", "notes", "here", "about", "how", "that", "URL", "is", "composed"...
e705e1bc4fc0b8d2aa25680dfc432762b361c783
https://github.com/alextricity25/dwell_in_you_richly/blob/e705e1bc4fc0b8d2aa25680dfc432762b361c783/diyr/utils/bible.py#L106-L120
train
Builds the online. recoveryversion. bible URL for the given book name and chapter.
alextricity25/dwell_in_you_richly
diyr/utils/bible.py
Bible.get_chapter
def get_chapter(self, book_name, book_chapter, cache_chapter = True): """ Returns a chapter of the bible, first checking to see if that chapter is on disk. If not, hen it attempts to fetch it from the internet. NOTE: This is public facing method. If the method signature changes,...
python
def get_chapter(self, book_name, book_chapter, cache_chapter = True): """ Returns a chapter of the bible, first checking to see if that chapter is on disk. If not, hen it attempts to fetch it from the internet. NOTE: This is public facing method. If the method signature changes,...
[ "def", "get_chapter", "(", "self", ",", "book_name", ",", "book_chapter", ",", "cache_chapter", "=", "True", ")", ":", "try", ":", "logging", ".", "debug", "(", "\"Attempting to read chapter from disk\"", ")", "verses_list", "=", "self", ".", "_get_ondisk_chapter"...
Returns a chapter of the bible, first checking to see if that chapter is on disk. If not, hen it attempts to fetch it from the internet. NOTE: This is public facing method. If the method signature changes, then it needs to be documented and backwards-compatablity nee...
[ "Returns", "a", "chapter", "of", "the", "bible", "first", "checking", "to", "see", "if", "that", "chapter", "is", "on", "disk", ".", "If", "not", "hen", "it", "attempts", "to", "fetch", "it", "from", "the", "internet", "." ]
e705e1bc4fc0b8d2aa25680dfc432762b361c783
https://github.com/alextricity25/dwell_in_you_richly/blob/e705e1bc4fc0b8d2aa25680dfc432762b361c783/diyr/utils/bible.py#L122-L141
train
Returns a list of chapter verses for a given book.
alextricity25/dwell_in_you_richly
diyr/utils/bible.py
Bible._get_ondisk_chapter
def _get_ondisk_chapter(self, book_name, book_chapter): """ Retrieves the given bible chapter from it's on disk location. Currently, the location `~/.diyr/<book_name>/` is supported """ # First attempt to look up the chapter on the disk verses_list = [] filename =...
python
def _get_ondisk_chapter(self, book_name, book_chapter): """ Retrieves the given bible chapter from it's on disk location. Currently, the location `~/.diyr/<book_name>/` is supported """ # First attempt to look up the chapter on the disk verses_list = [] filename =...
[ "def", "_get_ondisk_chapter", "(", "self", ",", "book_name", ",", "book_chapter", ")", ":", "# First attempt to look up the chapter on the disk", "verses_list", "=", "[", "]", "filename", "=", "os", ".", "path", ".", "expanduser", "(", "\"~/.diyr/{}/{}\"", ")", ".",...
Retrieves the given bible chapter from it's on disk location. Currently, the location `~/.diyr/<book_name>/` is supported
[ "Retrieves", "the", "given", "bible", "chapter", "from", "it", "s", "on", "disk", "location", ".", "Currently", "the", "location", "~", "/", ".", "diyr", "/", "<book_name", ">", "/", "is", "supported" ]
e705e1bc4fc0b8d2aa25680dfc432762b361c783
https://github.com/alextricity25/dwell_in_you_richly/blob/e705e1bc4fc0b8d2aa25680dfc432762b361c783/diyr/utils/bible.py#L143-L167
train
Retrieves the bible chapter from the given bible chapter on disk location.
alextricity25/dwell_in_you_richly
diyr/utils/bible.py
Bible._get_online_chapter
def _get_online_chapter(self, book_name, book_chapter, cache_chapter): """ Retrieves an entire chapter of a book in the Bible in the form of a list. If cache_chapter is "True", this method will cache the chapter in "~/.diyr/bible/<book>/<chapter>.txt". """ ...
python
def _get_online_chapter(self, book_name, book_chapter, cache_chapter): """ Retrieves an entire chapter of a book in the Bible in the form of a list. If cache_chapter is "True", this method will cache the chapter in "~/.diyr/bible/<book>/<chapter>.txt". """ ...
[ "def", "_get_online_chapter", "(", "self", ",", "book_name", ",", "book_chapter", ",", "cache_chapter", ")", ":", "url", "=", "self", ".", "build_recovery_online_url", "(", "book_name", ",", "book_chapter", ")", "logging", ".", "debug", "(", "\"Looking up chapter ...
Retrieves an entire chapter of a book in the Bible in the form of a list. If cache_chapter is "True", this method will cache the chapter in "~/.diyr/bible/<book>/<chapter>.txt".
[ "Retrieves", "an", "entire", "chapter", "of", "a", "book", "in", "the", "Bible", "in", "the", "form", "of", "a", "list", ".", "If", "cache_chapter", "is", "True", "this", "method", "will", "cache", "the", "chapter", "in", "~", "/", ".", "diyr", "/", ...
e705e1bc4fc0b8d2aa25680dfc432762b361c783
https://github.com/alextricity25/dwell_in_you_richly/blob/e705e1bc4fc0b8d2aa25680dfc432762b361c783/diyr/utils/bible.py#L169-L228
train
Get an online chapter of a book in the Bible.
alextricity25/dwell_in_you_richly
diyr/utils/bible.py
Bible.verse_lookup
def verse_lookup(self, book_name, book_chapter, verse, cache_chapter = True): """ Looks up a verse from online.recoveryversion.bible, then returns it. """ verses_list = self.get_chapter( book_name, str(book_chapter), cache_chapter = cache_chapter) ...
python
def verse_lookup(self, book_name, book_chapter, verse, cache_chapter = True): """ Looks up a verse from online.recoveryversion.bible, then returns it. """ verses_list = self.get_chapter( book_name, str(book_chapter), cache_chapter = cache_chapter) ...
[ "def", "verse_lookup", "(", "self", ",", "book_name", ",", "book_chapter", ",", "verse", ",", "cache_chapter", "=", "True", ")", ":", "verses_list", "=", "self", ".", "get_chapter", "(", "book_name", ",", "str", "(", "book_chapter", ")", ",", "cache_chapter"...
Looks up a verse from online.recoveryversion.bible, then returns it.
[ "Looks", "up", "a", "verse", "from", "online", ".", "recoveryversion", ".", "bible", "then", "returns", "it", "." ]
e705e1bc4fc0b8d2aa25680dfc432762b361c783
https://github.com/alextricity25/dwell_in_you_richly/blob/e705e1bc4fc0b8d2aa25680dfc432762b361c783/diyr/utils/bible.py#L230-L238
train
Look up a verse from online. recoveryversion. bible then returns it.
projectshift/shift-schema
shiftschema/ext/flask_wtf.py
WtfSchemaMixin.validate_on_submit
def validate_on_submit(self): """ Extend validate on submit to allow validation with schema """ # validate form valid = FlaskWtf.validate_on_submit(self) # return in case no schema or not submitted if not self._schema or not self.is_submitted(): return valid ...
python
def validate_on_submit(self): """ Extend validate on submit to allow validation with schema """ # validate form valid = FlaskWtf.validate_on_submit(self) # return in case no schema or not submitted if not self._schema or not self.is_submitted(): return valid ...
[ "def", "validate_on_submit", "(", "self", ")", ":", "# validate form", "valid", "=", "FlaskWtf", ".", "validate_on_submit", "(", "self", ")", "# return in case no schema or not submitted", "if", "not", "self", ".", "_schema", "or", "not", "self", ".", "is_submitted"...
Extend validate on submit to allow validation with schema
[ "Extend", "validate", "on", "submit", "to", "allow", "validation", "with", "schema" ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/ext/flask_wtf.py#L13-L35
train
Extend validate on submit to allow validation with schema
projectshift/shift-schema
shiftschema/ext/flask_wtf.py
WtfSchemaMixin.set_errors
def set_errors(self, result): """ Populate field errors with errors from schema validation """ # todo: use wtf locale errors = result.get_messages() for property_name in errors: if not hasattr(self, property_name): continue # ignore errors for missing fields...
python
def set_errors(self, result): """ Populate field errors with errors from schema validation """ # todo: use wtf locale errors = result.get_messages() for property_name in errors: if not hasattr(self, property_name): continue # ignore errors for missing fields...
[ "def", "set_errors", "(", "self", ",", "result", ")", ":", "# todo: use wtf locale", "errors", "=", "result", ".", "get_messages", "(", ")", "for", "property_name", "in", "errors", ":", "if", "not", "hasattr", "(", "self", ",", "property_name", ")", ":", "...
Populate field errors with errors from schema validation
[ "Populate", "field", "errors", "with", "errors", "from", "schema", "validation" ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/ext/flask_wtf.py#L40-L56
train
Populate the errors field with errors from schema validation
mediawiki-utilities/python-mwpersistence
mwpersistence/utilities/diffs2persistence.py
diffs2persistence
def diffs2persistence(rev_docs, window_size=50, revert_radius=15, sunset=None, verbose=False): """ Processes a sorted and page-partitioned sequence of revision documents into and adds a 'persistence' field to them containing statistics about how each token "added" in the revision p...
python
def diffs2persistence(rev_docs, window_size=50, revert_radius=15, sunset=None, verbose=False): """ Processes a sorted and page-partitioned sequence of revision documents into and adds a 'persistence' field to them containing statistics about how each token "added" in the revision p...
[ "def", "diffs2persistence", "(", "rev_docs", ",", "window_size", "=", "50", ",", "revert_radius", "=", "15", ",", "sunset", "=", "None", ",", "verbose", "=", "False", ")", ":", "rev_docs", "=", "mwxml", ".", "utilities", ".", "normalize", "(", "rev_docs", ...
Processes a sorted and page-partitioned sequence of revision documents into and adds a 'persistence' field to them containing statistics about how each token "added" in the revision persisted through future revisions. :Parameters: rev_docs : `iterable` ( `dict` ) JSON documents of revis...
[ "Processes", "a", "sorted", "and", "page", "-", "partitioned", "sequence", "of", "revision", "documents", "into", "and", "adds", "a", "persistence", "field", "to", "them", "containing", "statistics", "about", "how", "each", "token", "added", "in", "the", "revi...
2b98847fb8acaca38b3cbf94bde3fd7e27d2b67d
https://github.com/mediawiki-utilities/python-mwpersistence/blob/2b98847fb8acaca38b3cbf94bde3fd7e27d2b67d/mwpersistence/utilities/diffs2persistence.py#L100-L197
train
Takes a list of revision documents and returns a generator of all the revision documents in order of their revision - related persistence fields.
tomatohater/django-pgcryptoauth
pgcryptoauth/hashers.py
PgCryptoPasswordHasher.salt
def salt(self): """ Generates a salt via pgcrypto.gen_salt('algorithm'). """ cursor = connections[PGCRYPTOAUTH_DATABASE].cursor() cursor.execute("SELECT gen_salt('%s')" % PGCRYPTOAUTH_ALGORITHM) return cursor.fetchall()[0][0]
python
def salt(self): """ Generates a salt via pgcrypto.gen_salt('algorithm'). """ cursor = connections[PGCRYPTOAUTH_DATABASE].cursor() cursor.execute("SELECT gen_salt('%s')" % PGCRYPTOAUTH_ALGORITHM) return cursor.fetchall()[0][0]
[ "def", "salt", "(", "self", ")", ":", "cursor", "=", "connections", "[", "PGCRYPTOAUTH_DATABASE", "]", ".", "cursor", "(", ")", "cursor", ".", "execute", "(", "\"SELECT gen_salt('%s')\"", "%", "PGCRYPTOAUTH_ALGORITHM", ")", "return", "cursor", ".", "fetchall", ...
Generates a salt via pgcrypto.gen_salt('algorithm').
[ "Generates", "a", "salt", "via", "pgcrypto", ".", "gen_salt", "(", "algorithm", ")", "." ]
dce0c80a8220a9a47f488195a08724114c4d7d80
https://github.com/tomatohater/django-pgcryptoauth/blob/dce0c80a8220a9a47f488195a08724114c4d7d80/pgcryptoauth/hashers.py#L26-L32
train
Returns the salt for the current session.
weijia/djangoautoconf
djangoautoconf/ajax_select_utils/ajax_select_channel_generator.py
register_channel
def register_channel(model_class, search_fields=()): """ Register channel for model :param model_class: model to register channel for :param search_fields: :return: """ if len(search_fields) == 0: search_fields = get_fields_with_icontains_filter(model_class) channel_class = type(...
python
def register_channel(model_class, search_fields=()): """ Register channel for model :param model_class: model to register channel for :param search_fields: :return: """ if len(search_fields) == 0: search_fields = get_fields_with_icontains_filter(model_class) channel_class = type(...
[ "def", "register_channel", "(", "model_class", ",", "search_fields", "=", "(", ")", ")", ":", "if", "len", "(", "search_fields", ")", "==", "0", ":", "search_fields", "=", "get_fields_with_icontains_filter", "(", "model_class", ")", "channel_class", "=", "type",...
Register channel for model :param model_class: model to register channel for :param search_fields: :return:
[ "Register", "channel", "for", "model", ":", "param", "model_class", ":", "model", "to", "register", "channel", "for", ":", "param", "search_fields", ":", ":", "return", ":" ]
b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0
https://github.com/weijia/djangoautoconf/blob/b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0/djangoautoconf/ajax_select_utils/ajax_select_channel_generator.py#L38-L53
train
Register a new channel for a given model class.
a1ezzz/wasp-general
wasp_general/crypto/hash.py
WPyCryptographyHashAdapter.generator_name
def generator_name(cls): """ :meth:`.WHashGeneratorProto.generator_name` implementation """ if cls.__generator_name__ is None: raise ValueError('"__generator_name__" should be override in a derived class') if isinstance(cls.__generator_name__, str) is False: raise TypeError('"__generator_name__" should be...
python
def generator_name(cls): """ :meth:`.WHashGeneratorProto.generator_name` implementation """ if cls.__generator_name__ is None: raise ValueError('"__generator_name__" should be override in a derived class') if isinstance(cls.__generator_name__, str) is False: raise TypeError('"__generator_name__" should be...
[ "def", "generator_name", "(", "cls", ")", ":", "if", "cls", ".", "__generator_name__", "is", "None", ":", "raise", "ValueError", "(", "'\"__generator_name__\" should be override in a derived class'", ")", "if", "isinstance", "(", "cls", ".", "__generator_name__", ",",...
:meth:`.WHashGeneratorProto.generator_name` implementation
[ ":", "meth", ":", ".", "WHashGeneratorProto", ".", "generator_name", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/hash.py#L151-L158
train
:meth:`. WHashGeneratorProto. generator_name` implementation if cls. generator_name is None is returned
a1ezzz/wasp-general
wasp_general/crypto/hash.py
WPyCryptographyHashAdapter.generator_family
def generator_family(cls): """ :meth:`.WHashGeneratorProto.generator_family` implementation """ if cls.__generator_family__ is not None: if isinstance(cls.__generator_family__, str) is False: raise TypeError('"__generator_class__" if defined must be a str instance') if cls.__generator_family__ is not N...
python
def generator_family(cls): """ :meth:`.WHashGeneratorProto.generator_family` implementation """ if cls.__generator_family__ is not None: if isinstance(cls.__generator_family__, str) is False: raise TypeError('"__generator_class__" if defined must be a str instance') if cls.__generator_family__ is not N...
[ "def", "generator_family", "(", "cls", ")", ":", "if", "cls", ".", "__generator_family__", "is", "not", "None", ":", "if", "isinstance", "(", "cls", ".", "__generator_family__", ",", "str", ")", "is", "False", ":", "raise", "TypeError", "(", "'\"__generator_...
:meth:`.WHashGeneratorProto.generator_family` implementation
[ ":", "meth", ":", ".", "WHashGeneratorProto", ".", "generator_family", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/hash.py#L161-L169
train
meth :. WHashGeneratorProto. generator_family
a1ezzz/wasp-general
wasp_general/crypto/hash.py
WPyCryptographyHashAdapter.new
def new(cls, data=None): """ :meth:`.WHashGeneratorProto.new` implementation """ obj = cls() if data is not None: obj.update(data) return obj
python
def new(cls, data=None): """ :meth:`.WHashGeneratorProto.new` implementation """ obj = cls() if data is not None: obj.update(data) return obj
[ "def", "new", "(", "cls", ",", "data", "=", "None", ")", ":", "obj", "=", "cls", "(", ")", "if", "data", "is", "not", "None", ":", "obj", ".", "update", "(", "data", ")", "return", "obj" ]
:meth:`.WHashGeneratorProto.new` implementation
[ ":", "meth", ":", ".", "WHashGeneratorProto", ".", "new", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/hash.py#L173-L179
train
Implementation . new
a1ezzz/wasp-general
wasp_general/crypto/hash.py
WHash.generator
def generator(name): """ Return generator by its name :param name: name of hash-generator :return: WHashGeneratorProto class """ name = name.upper() if name not in WHash.__hash_map__.keys(): raise ValueError('Hash generator "%s" not available' % name) return WHash.__hash_map__[name]
python
def generator(name): """ Return generator by its name :param name: name of hash-generator :return: WHashGeneratorProto class """ name = name.upper() if name not in WHash.__hash_map__.keys(): raise ValueError('Hash generator "%s" not available' % name) return WHash.__hash_map__[name]
[ "def", "generator", "(", "name", ")", ":", "name", "=", "name", ".", "upper", "(", ")", "if", "name", "not", "in", "WHash", ".", "__hash_map__", ".", "keys", "(", ")", ":", "raise", "ValueError", "(", "'Hash generator \"%s\" not available'", "%", "name", ...
Return generator by its name :param name: name of hash-generator :return: WHashGeneratorProto class
[ "Return", "generator", "by", "its", "name" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/hash.py#L241-L251
train
Return generator by its name
a1ezzz/wasp-general
wasp_general/crypto/hash.py
WHash.generator_by_digest
def generator_by_digest(family, digest_size): """ Return generator by hash generator family name and digest size :param family: name of hash-generator family :return: WHashGeneratorProto class """ for generator_name in WHash.available_generators(family=family): generator = WHash.generator(generator_name)...
python
def generator_by_digest(family, digest_size): """ Return generator by hash generator family name and digest size :param family: name of hash-generator family :return: WHashGeneratorProto class """ for generator_name in WHash.available_generators(family=family): generator = WHash.generator(generator_name)...
[ "def", "generator_by_digest", "(", "family", ",", "digest_size", ")", ":", "for", "generator_name", "in", "WHash", ".", "available_generators", "(", "family", "=", "family", ")", ":", "generator", "=", "WHash", ".", "generator", "(", "generator_name", ")", "if...
Return generator by hash generator family name and digest size :param family: name of hash-generator family :return: WHashGeneratorProto class
[ "Return", "generator", "by", "hash", "generator", "family", "name", "and", "digest", "size" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/hash.py#L254-L265
train
Return generator by family name and digest size
a1ezzz/wasp-general
wasp_general/crypto/hash.py
WHash.available_generators
def available_generators(family=None, name=None): """ Return names of available generators :param family: name of hash-generator family to select :param name: name of hash-generator to select (parameter may be used for availability check) :return: tuple of str """ generators = WHash.__hash_map__.values() ...
python
def available_generators(family=None, name=None): """ Return names of available generators :param family: name of hash-generator family to select :param name: name of hash-generator to select (parameter may be used for availability check) :return: tuple of str """ generators = WHash.__hash_map__.values() ...
[ "def", "available_generators", "(", "family", "=", "None", ",", "name", "=", "None", ")", ":", "generators", "=", "WHash", ".", "__hash_map__", ".", "values", "(", ")", "if", "family", "is", "not", "None", ":", "family", "=", "family", ".", "upper", "(...
Return names of available generators :param family: name of hash-generator family to select :param name: name of hash-generator to select (parameter may be used for availability check) :return: tuple of str
[ "Return", "names", "of", "available", "generators" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/hash.py#L269-L287
train
Return names of available hash - generators
a1ezzz/wasp-general
wasp_general/crypto/hash.py
WHash.available_digests
def available_digests(family=None, name=None): """ Return names of available generators :param family: name of hash-generator family to select :param name: name of hash-generator to select :return: set of int """ generators = WHash.available_generators(family=family, name=name) return set([WHash.generat...
python
def available_digests(family=None, name=None): """ Return names of available generators :param family: name of hash-generator family to select :param name: name of hash-generator to select :return: set of int """ generators = WHash.available_generators(family=family, name=name) return set([WHash.generat...
[ "def", "available_digests", "(", "family", "=", "None", ",", "name", "=", "None", ")", ":", "generators", "=", "WHash", ".", "available_generators", "(", "family", "=", "family", ",", "name", "=", "name", ")", "return", "set", "(", "[", "WHash", ".", "...
Return names of available generators :param family: name of hash-generator family to select :param name: name of hash-generator to select :return: set of int
[ "Return", "names", "of", "available", "generators" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/hash.py#L291-L300
train
Return names of available generators
a1ezzz/wasp-general
wasp_general/network/messenger/session.py
WMessengerOnionSessionFlow.sequence
def sequence(cls, *info): """ Useful method to generate iterator. It is generated by chaining the given info. If no info is specified, then None is returned :param info: iterator info sequence :return: WMessengerOnionSessionFlowProto.Iterator or None """ if len(info) == 0: return info = list(info) ...
python
def sequence(cls, *info): """ Useful method to generate iterator. It is generated by chaining the given info. If no info is specified, then None is returned :param info: iterator info sequence :return: WMessengerOnionSessionFlowProto.Iterator or None """ if len(info) == 0: return info = list(info) ...
[ "def", "sequence", "(", "cls", ",", "*", "info", ")", ":", "if", "len", "(", "info", ")", "==", "0", ":", "return", "info", "=", "list", "(", "info", ")", "info", ".", "reverse", "(", ")", "result", "=", "WMessengerOnionSessionFlowProto", ".", "Itera...
Useful method to generate iterator. It is generated by chaining the given info. If no info is specified, then None is returned :param info: iterator info sequence :return: WMessengerOnionSessionFlowProto.Iterator or None
[ "Useful", "method", "to", "generate", "iterator", ".", "It", "is", "generated", "by", "chaining", "the", "given", "info", ".", "If", "no", "info", "is", "specified", "then", "None", "is", "returned" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/session.py#L58-L80
train
This method returns a new iterator that can be used to chain the given info.
a1ezzz/wasp-general
wasp_general/network/messenger/session.py
WMessengerOnionSessionFlowSequence.iterator
def iterator(self, envelope): """ :meth:`WMessengerOnionSessionFlowProto.iterator` implementation """ iterator = WMessengerOnionSessionFlowSequence.FlowSequenceIterator( WMessengerOnionSessionFlowProto.IteratorInfo(''), *self.__flows ) return iterator.next(envelope)
python
def iterator(self, envelope): """ :meth:`WMessengerOnionSessionFlowProto.iterator` implementation """ iterator = WMessengerOnionSessionFlowSequence.FlowSequenceIterator( WMessengerOnionSessionFlowProto.IteratorInfo(''), *self.__flows ) return iterator.next(envelope)
[ "def", "iterator", "(", "self", ",", "envelope", ")", ":", "iterator", "=", "WMessengerOnionSessionFlowSequence", ".", "FlowSequenceIterator", "(", "WMessengerOnionSessionFlowProto", ".", "IteratorInfo", "(", "''", ")", ",", "*", "self", ".", "__flows", ")", "retu...
:meth:`WMessengerOnionSessionFlowProto.iterator` implementation
[ ":", "meth", ":", "WMessengerOnionSessionFlowProto", ".", "iterator", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/session.py#L175-L181
train
implementation of iterator
a1ezzz/wasp-general
wasp_general/network/messenger/session.py
WMessengerOnionSessionFlexFlow.iterator
def iterator(self, envelope): """ :meth:`WMessengerOnionSessionFlowProto.iterator` implementation """ for pair in self.__pairs: if pair.comparator().match(envelope) is True: return pair.flow().iterator(envelope) if self.__default_flow is not None: return self.__default_flow.iterator(envelope)
python
def iterator(self, envelope): """ :meth:`WMessengerOnionSessionFlowProto.iterator` implementation """ for pair in self.__pairs: if pair.comparator().match(envelope) is True: return pair.flow().iterator(envelope) if self.__default_flow is not None: return self.__default_flow.iterator(envelope)
[ "def", "iterator", "(", "self", ",", "envelope", ")", ":", "for", "pair", "in", "self", ".", "__pairs", ":", "if", "pair", ".", "comparator", "(", ")", ".", "match", "(", "envelope", ")", "is", "True", ":", "return", "pair", ".", "flow", "(", ")", ...
:meth:`WMessengerOnionSessionFlowProto.iterator` implementation
[ ":", "meth", ":", "WMessengerOnionSessionFlowProto", ".", "iterator", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/session.py#L271-L279
train
implementation Proto. iterator implementation Proto. iterator
a1ezzz/wasp-general
wasp_general/network/messenger/session.py
WMessengerOnionSession.process
def process(self, envelope): """ :meth:`.WMessengerOnionSessionProto.process` method implementation. """ def process_single_layer(iter_envelope, iter_obj): layer = self.onion().layer(iter_obj.layer_name()) layer_args = iter_obj.layer_args() return layer.process(iter_envelope, self, **layer_args) iter...
python
def process(self, envelope): """ :meth:`.WMessengerOnionSessionProto.process` method implementation. """ def process_single_layer(iter_envelope, iter_obj): layer = self.onion().layer(iter_obj.layer_name()) layer_args = iter_obj.layer_args() return layer.process(iter_envelope, self, **layer_args) iter...
[ "def", "process", "(", "self", ",", "envelope", ")", ":", "def", "process_single_layer", "(", "iter_envelope", ",", "iter_obj", ")", ":", "layer", "=", "self", ".", "onion", "(", ")", ".", "layer", "(", "iter_obj", ".", "layer_name", "(", ")", ")", "la...
:meth:`.WMessengerOnionSessionProto.process` method implementation.
[ ":", "meth", ":", ".", "WMessengerOnionSessionProto", ".", "process", "method", "implementation", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/messenger/session.py#L309-L323
train
meth :. WMessengerOnionSessionProto. process method implementation. """
Addvilz/hemp
hemp/workspace.py
create_temporary_workspace
def create_temporary_workspace(version=None, mode=0700): # type: (str, int) -> str """ Create a temporary directory, optionally by placing a subdirectory: version :rtype: str :return: Directory path """ workspace = mkdtemp('hemp_') if version is not None: workspace = join(workspa...
python
def create_temporary_workspace(version=None, mode=0700): # type: (str, int) -> str """ Create a temporary directory, optionally by placing a subdirectory: version :rtype: str :return: Directory path """ workspace = mkdtemp('hemp_') if version is not None: workspace = join(workspa...
[ "def", "create_temporary_workspace", "(", "version", "=", "None", ",", "mode", "=", "0700", ")", ":", "# type: (str, int) -> str", "workspace", "=", "mkdtemp", "(", "'hemp_'", ")", "if", "version", "is", "not", "None", ":", "workspace", "=", "join", "(", "wo...
Create a temporary directory, optionally by placing a subdirectory: version :rtype: str :return: Directory path
[ "Create", "a", "temporary", "directory", "optionally", "by", "placing", "a", "subdirectory", ":", "version", ":", "rtype", ":", "str", ":", "return", ":", "Directory", "path" ]
80d189f15ba20068a61efc2591070c80549c9d06
https://github.com/Addvilz/hemp/blob/80d189f15ba20068a61efc2591070c80549c9d06/hemp/workspace.py#L7-L19
train
Create a temporary directory optionally by placing a subdirectory.
a1ezzz/wasp-general
wasp_general/network/primitives.py
WMACAddress.from_string
def from_string(address): """ Return new object by the given MAC-address :param address: address to convert :return: WMACAddress """ str_address = None if WMACAddress.re_dash_format.match(address): str_address = "".join(address.split("-")) elif WMACAddress.re_colon_format.match(address): str_addre...
python
def from_string(address): """ Return new object by the given MAC-address :param address: address to convert :return: WMACAddress """ str_address = None if WMACAddress.re_dash_format.match(address): str_address = "".join(address.split("-")) elif WMACAddress.re_colon_format.match(address): str_addre...
[ "def", "from_string", "(", "address", ")", ":", "str_address", "=", "None", "if", "WMACAddress", ".", "re_dash_format", ".", "match", "(", "address", ")", ":", "str_address", "=", "\"\"", ".", "join", "(", "address", ".", "split", "(", "\"-\"", ")", ")",...
Return new object by the given MAC-address :param address: address to convert :return: WMACAddress
[ "Return", "new", "object", "by", "the", "given", "MAC", "-", "address" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/primitives.py#L87-L113
train
Return new object by the given MAC - address
a1ezzz/wasp-general
wasp_general/network/primitives.py
WIPV4Address.from_string
def from_string(address): """ Parse string for IPv4 address :param address: address to parse :return: """ address = address.split('.') if len(address) != WIPV4Address.octet_count: raise ValueError('Invalid ip address: %s' % address) result = WIPV4Address() for i in range(WIPV4Address.octet_count): ...
python
def from_string(address): """ Parse string for IPv4 address :param address: address to parse :return: """ address = address.split('.') if len(address) != WIPV4Address.octet_count: raise ValueError('Invalid ip address: %s' % address) result = WIPV4Address() for i in range(WIPV4Address.octet_count): ...
[ "def", "from_string", "(", "address", ")", ":", "address", "=", "address", ".", "split", "(", "'.'", ")", "if", "len", "(", "address", ")", "!=", "WIPV4Address", ".", "octet_count", ":", "raise", "ValueError", "(", "'Invalid ip address: %s'", "%", "address",...
Parse string for IPv4 address :param address: address to parse :return:
[ "Parse", "string", "for", "IPv4", "address" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/primitives.py#L173-L186
train
Parse IPv4 address from string
a1ezzz/wasp-general
wasp_general/network/primitives.py
WIPV4Address.to_string
def to_string(address, dns_format=False): """ Convert address to string :param address: WIPV4Address to convert :param dns_format: whether to use arpa-format or not :return: """ if isinstance(address, WIPV4Address) is False: raise TypeError('Invalid address type') address = [str(int(x)) for x in addr...
python
def to_string(address, dns_format=False): """ Convert address to string :param address: WIPV4Address to convert :param dns_format: whether to use arpa-format or not :return: """ if isinstance(address, WIPV4Address) is False: raise TypeError('Invalid address type') address = [str(int(x)) for x in addr...
[ "def", "to_string", "(", "address", ",", "dns_format", "=", "False", ")", ":", "if", "isinstance", "(", "address", ",", "WIPV4Address", ")", "is", "False", ":", "raise", "TypeError", "(", "'Invalid address type'", ")", "address", "=", "[", "str", "(", "int...
Convert address to string :param address: WIPV4Address to convert :param dns_format: whether to use arpa-format or not :return:
[ "Convert", "address", "to", "string" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/primitives.py#L190-L204
train
Convert WIPV4Address to string
a1ezzz/wasp-general
wasp_general/network/primitives.py
WNetworkIPV4.first_address
def first_address(self, skip_network_address=True): """ Return the first IP address of this network :param skip_network_address: this flag specifies whether this function returns address of the network \ or returns address that follows address of the network (address, that a host could have) :return: WIPV4Addr...
python
def first_address(self, skip_network_address=True): """ Return the first IP address of this network :param skip_network_address: this flag specifies whether this function returns address of the network \ or returns address that follows address of the network (address, that a host could have) :return: WIPV4Addr...
[ "def", "first_address", "(", "self", ",", "skip_network_address", "=", "True", ")", ":", "bin_address", "=", "self", ".", "__address", ".", "bin_address", "(", ")", "bin_address_length", "=", "len", "(", "bin_address", ")", "if", "self", ".", "__mask", ">", ...
Return the first IP address of this network :param skip_network_address: this flag specifies whether this function returns address of the network \ or returns address that follows address of the network (address, that a host could have) :return: WIPV4Address
[ "Return", "the", "first", "IP", "address", "of", "this", "network" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/primitives.py#L269-L287
train
Return the first IP address of this network
a1ezzz/wasp-general
wasp_general/network/primitives.py
WNetworkIPV4.last_address
def last_address(self, skip_broadcast_address=True): """ Return the last IP address of this network :param skip_broadcast_address: this flag specifies whether to skip the very last address (that is \ usually used as broadcast address) or not. :return: WIPV4Address """ bin_address = self.__address.bin_addre...
python
def last_address(self, skip_broadcast_address=True): """ Return the last IP address of this network :param skip_broadcast_address: this flag specifies whether to skip the very last address (that is \ usually used as broadcast address) or not. :return: WIPV4Address """ bin_address = self.__address.bin_addre...
[ "def", "last_address", "(", "self", ",", "skip_broadcast_address", "=", "True", ")", ":", "bin_address", "=", "self", ".", "__address", ".", "bin_address", "(", ")", "bin_address_length", "=", "len", "(", "bin_address", ")", "if", "self", ".", "__mask", ">",...
Return the last IP address of this network :param skip_broadcast_address: this flag specifies whether to skip the very last address (that is \ usually used as broadcast address) or not. :return: WIPV4Address
[ "Return", "the", "last", "IP", "address", "of", "this", "network" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/primitives.py#L290-L308
train
Return the last IP address of this network.
a1ezzz/wasp-general
wasp_general/network/primitives.py
WNetworkIPV4.iterator
def iterator(self, skip_network_address=True, skip_broadcast_address=True): """ Return iterator, that can iterate over network addresses :param skip_network_address: same as skip_network_address in :meth:`.NetworkIPV4.first_address` method :param skip_broadcast_address: same as skip_broadcast_address in :meth:`....
python
def iterator(self, skip_network_address=True, skip_broadcast_address=True): """ Return iterator, that can iterate over network addresses :param skip_network_address: same as skip_network_address in :meth:`.NetworkIPV4.first_address` method :param skip_broadcast_address: same as skip_broadcast_address in :meth:`....
[ "def", "iterator", "(", "self", ",", "skip_network_address", "=", "True", ",", "skip_broadcast_address", "=", "True", ")", ":", "return", "WNetworkIPV4Iterator", "(", "self", ",", "skip_network_address", ",", "skip_broadcast_address", ")" ]
Return iterator, that can iterate over network addresses :param skip_network_address: same as skip_network_address in :meth:`.NetworkIPV4.first_address` method :param skip_broadcast_address: same as skip_broadcast_address in :meth:`.NetworkIPV4.last_address` \ method :return: NetworkIPV4Iterator
[ "Return", "iterator", "that", "can", "iterate", "over", "network", "addresses" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/primitives.py#L310-L318
train
Return iterator that can iterate over network addresses
a1ezzz/wasp-general
wasp_general/network/primitives.py
WFQDN.from_string
def from_string(address): """ Convert doted-written FQDN address to WFQDN object :param address: address to convert :return: WFQDN """ if len(address) == 0: return WFQDN() if address[-1] == '.': address = address[:-1] if len(address) > WFQDN.maximum_fqdn_length: raise ValueError('Invalid addre...
python
def from_string(address): """ Convert doted-written FQDN address to WFQDN object :param address: address to convert :return: WFQDN """ if len(address) == 0: return WFQDN() if address[-1] == '.': address = address[:-1] if len(address) > WFQDN.maximum_fqdn_length: raise ValueError('Invalid addre...
[ "def", "from_string", "(", "address", ")", ":", "if", "len", "(", "address", ")", "==", "0", ":", "return", "WFQDN", "(", ")", "if", "address", "[", "-", "1", "]", "==", "'.'", ":", "address", "=", "address", "[", ":", "-", "1", "]", "if", "len...
Convert doted-written FQDN address to WFQDN object :param address: address to convert :return: WFQDN
[ "Convert", "doted", "-", "written", "FQDN", "address", "to", "WFQDN", "object" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/primitives.py#L443-L465
train
Convert doted - written FQDN address to WFQDN object
a1ezzz/wasp-general
wasp_general/network/primitives.py
WFQDN.to_string
def to_string(address, leading_dot=False): """ Return doted-written address by the given WFQDN object :param address: address to convert :param leading_dot: whether this function place leading dot to the result or not :return: str """ if isinstance(address, WFQDN) is False: raise TypeError('Invalid typ...
python
def to_string(address, leading_dot=False): """ Return doted-written address by the given WFQDN object :param address: address to convert :param leading_dot: whether this function place leading dot to the result or not :return: str """ if isinstance(address, WFQDN) is False: raise TypeError('Invalid typ...
[ "def", "to_string", "(", "address", ",", "leading_dot", "=", "False", ")", ":", "if", "isinstance", "(", "address", ",", "WFQDN", ")", "is", "False", ":", "raise", "TypeError", "(", "'Invalid type for FQDN address'", ")", "result", "=", "'.'", ".", "join", ...
Return doted-written address by the given WFQDN object :param address: address to convert :param leading_dot: whether this function place leading dot to the result or not :return: str
[ "Return", "doted", "-", "written", "address", "by", "the", "given", "WFQDN", "object" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/primitives.py#L469-L481
train
Return a doted - written address by the given WFQDN object.
a1ezzz/wasp-general
wasp_general/network/primitives.py
WIPV4SocketInfo.pair
def pair(self): """ Return tuple (address, port), where address is a string (empty string if self.address() is None) and port is an integer (zero if self.port() is None). Mainly, this tuple is used with python socket module (like in bind method) :return: 2 value tuple of str and int. """ address = str(self...
python
def pair(self): """ Return tuple (address, port), where address is a string (empty string if self.address() is None) and port is an integer (zero if self.port() is None). Mainly, this tuple is used with python socket module (like in bind method) :return: 2 value tuple of str and int. """ address = str(self...
[ "def", "pair", "(", "self", ")", ":", "address", "=", "str", "(", "self", ".", "__address", ")", "if", "self", ".", "__address", "is", "not", "None", "else", "''", "port", "=", "int", "(", "self", ".", "__port", ")", "if", "self", ".", "__port", ...
Return tuple (address, port), where address is a string (empty string if self.address() is None) and port is an integer (zero if self.port() is None). Mainly, this tuple is used with python socket module (like in bind method) :return: 2 value tuple of str and int.
[ "Return", "tuple", "(", "address", "port", ")", "where", "address", "is", "a", "string", "(", "empty", "string", "if", "self", ".", "address", "()", "is", "None", ")", "and", "port", "is", "an", "integer", "(", "zero", "if", "self", ".", "port", "()"...
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/primitives.py#L545-L554
train
Return tuple of address and port of this socket
a1ezzz/wasp-general
wasp_general/network/primitives.py
WIPV4SocketInfo.parse_address
def parse_address(address): """ Parse string and return :class:`.WIPV4Address` object if an IP address is specified, :class:`.WFQDN` if domain name is specified and None if the string is empty. :param address: string to parse :return: WIPV4Address or WFQDN or None """ if len(address) == 0: return None ...
python
def parse_address(address): """ Parse string and return :class:`.WIPV4Address` object if an IP address is specified, :class:`.WFQDN` if domain name is specified and None if the string is empty. :param address: string to parse :return: WIPV4Address or WFQDN or None """ if len(address) == 0: return None ...
[ "def", "parse_address", "(", "address", ")", ":", "if", "len", "(", "address", ")", "==", "0", ":", "return", "None", "try", ":", "return", "WIPV4Address", "(", "address", ")", "except", "ValueError", ":", "pass", "try", ":", "return", "WFQDN", "(", "a...
Parse string and return :class:`.WIPV4Address` object if an IP address is specified, :class:`.WFQDN` if domain name is specified and None if the string is empty. :param address: string to parse :return: WIPV4Address or WFQDN or None
[ "Parse", "string", "and", "return", ":", "class", ":", ".", "WIPV4Address", "object", "if", "an", "IP", "address", "is", "specified", ":", "class", ":", ".", "WFQDN", "if", "domain", "name", "is", "specified", "and", "None", "if", "the", "string", "is", ...
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/primitives.py#L558-L579
train
Parse string and return WIPV4Address or WFQDN object if an IP address is specified and None otherwise.
a1ezzz/wasp-general
wasp_general/network/primitives.py
WIPV4SocketInfo.parse_socket_info
def parse_socket_info(cls, info): """ Parse string that is formed like '[address]<:port>' and return corresponding :class:`.WIPV4ScketInfo` object :param info: string to parse :return: WIPV4ScketInfo """ info = info.split(':') if len(info) > 2: raise ValueError('Incorrect socket info specified') ad...
python
def parse_socket_info(cls, info): """ Parse string that is formed like '[address]<:port>' and return corresponding :class:`.WIPV4ScketInfo` object :param info: string to parse :return: WIPV4ScketInfo """ info = info.split(':') if len(info) > 2: raise ValueError('Incorrect socket info specified') ad...
[ "def", "parse_socket_info", "(", "cls", ",", "info", ")", ":", "info", "=", "info", ".", "split", "(", "':'", ")", "if", "len", "(", "info", ")", ">", "2", ":", "raise", "ValueError", "(", "'Incorrect socket info specified'", ")", "address", "=", "info",...
Parse string that is formed like '[address]<:port>' and return corresponding :class:`.WIPV4ScketInfo` object :param info: string to parse :return: WIPV4ScketInfo
[ "Parse", "string", "that", "is", "formed", "like", "[", "address", "]", "<", ":", "port", ">", "and", "return", "corresponding", ":", "class", ":", ".", "WIPV4ScketInfo", "object" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/primitives.py#L584-L597
train
Parse string that is formed like [ address : port ] and return corresponding : class :. WIPV4ScketInfo object
olitheolix/qtmacs
qtmacs/base_applet.py
QtmacsApplet.qteReparent
def qteReparent(self, parent): """ Re-parent the applet. This is little more then calling Qt's native ``setParent()`` method but also updates the ``qteParentWindow`` handle. This method is usually called when the applet is added/removed from a splitter and thus requires ...
python
def qteReparent(self, parent): """ Re-parent the applet. This is little more then calling Qt's native ``setParent()`` method but also updates the ``qteParentWindow`` handle. This method is usually called when the applet is added/removed from a splitter and thus requires ...
[ "def", "qteReparent", "(", "self", ",", "parent", ")", ":", "# Set the new parent.", "self", ".", "setParent", "(", "parent", ")", "# If this parent has a Qtmacs structure then query it for the", "# parent window, otherwise set the parent to None.", "try", ":", "self", ".", ...
Re-parent the applet. This is little more then calling Qt's native ``setParent()`` method but also updates the ``qteParentWindow`` handle. This method is usually called when the applet is added/removed from a splitter and thus requires re-parenting. |Args| * ``parent``...
[ "Re", "-", "parent", "the", "applet", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/base_applet.py#L222-L257
train
Re - parent the applet object.
olitheolix/qtmacs
qtmacs/base_applet.py
QtmacsApplet.qteAddWidget
def qteAddWidget(self, widgetObj: QtGui.QWidget, isFocusable: bool=True, widgetSignature: str=None, autoBind: bool=True): """ Augment the standard Qt ``widgetObj`` with Qtmacs specific fields. Example: from a programmers perspective there is no difference between:: ...
python
def qteAddWidget(self, widgetObj: QtGui.QWidget, isFocusable: bool=True, widgetSignature: str=None, autoBind: bool=True): """ Augment the standard Qt ``widgetObj`` with Qtmacs specific fields. Example: from a programmers perspective there is no difference between:: ...
[ "def", "qteAddWidget", "(", "self", ",", "widgetObj", ":", "QtGui", ".", "QWidget", ",", "isFocusable", ":", "bool", "=", "True", ",", "widgetSignature", ":", "str", "=", "None", ",", "autoBind", ":", "bool", "=", "True", ")", ":", "# Add a Qtmacs data str...
Augment the standard Qt ``widgetObj`` with Qtmacs specific fields. Example: from a programmers perspective there is no difference between:: wid = QtGui.QTextEdit(self) and:: wid = self.qteAddWidget(QtGui.QTextEdit(self)) Both return a handle to a Qt widget (a...
[ "Augment", "the", "standard", "Qt", "widgetObj", "with", "Qtmacs", "specific", "fields", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/base_applet.py#L260-L383
train
Add a widget to the object.
olitheolix/qtmacs
qtmacs/base_applet.py
QtmacsApplet.qteSetAppletSignature
def qteSetAppletSignature(self, signature: str): """ Specify the applet signature. This signature is used by Qtmacs at run time to determine which macros are compatible with the apple. Macros have an identically called method so that Qtmacs can determine which macros are...
python
def qteSetAppletSignature(self, signature: str): """ Specify the applet signature. This signature is used by Qtmacs at run time to determine which macros are compatible with the apple. Macros have an identically called method so that Qtmacs can determine which macros are...
[ "def", "qteSetAppletSignature", "(", "self", ",", "signature", ":", "str", ")", ":", "if", "'*'", "in", "signature", ":", "raise", "QtmacsOtherError", "(", "'The applet signature must not contain \"*\"'", ")", "if", "signature", "==", "''", ":", "raise", "QtmacsOt...
Specify the applet signature. This signature is used by Qtmacs at run time to determine which macros are compatible with the apple. Macros have an identically called method so that Qtmacs can determine which macros are compatible with which applets. This method is typically call...
[ "Specify", "the", "applet", "signature", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/base_applet.py#L386-L425
train
Set the applet signature at run time.
olitheolix/qtmacs
qtmacs/base_applet.py
QtmacsApplet.qteAutoremoveDeletedWidgets
def qteAutoremoveDeletedWidgets(self): """ Remove all widgets from the internal widget list that do not exist anymore according to SIP. |Args| * **None** |Returns| * **None** |Raises| * **None** """ widget_list = self._qteAdmi...
python
def qteAutoremoveDeletedWidgets(self): """ Remove all widgets from the internal widget list that do not exist anymore according to SIP. |Args| * **None** |Returns| * **None** |Raises| * **None** """ widget_list = self._qteAdmi...
[ "def", "qteAutoremoveDeletedWidgets", "(", "self", ")", ":", "widget_list", "=", "self", ".", "_qteAdmin", ".", "widgetList", "deleted_widgets", "=", "[", "_", "for", "_", "in", "widget_list", "if", "sip", ".", "isdeleted", "(", "_", ")", "]", "for", "widg...
Remove all widgets from the internal widget list that do not exist anymore according to SIP. |Args| * **None** |Returns| * **None** |Raises| * **None**
[ "Remove", "all", "widgets", "from", "the", "internal", "widget", "list", "that", "do", "not", "exist", "anymore", "according", "to", "SIP", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/base_applet.py#L446-L466
train
Remove all deleted widgets from the internal widget list.
olitheolix/qtmacs
qtmacs/base_applet.py
QtmacsApplet.qteSetWidgetFocusOrder
def qteSetWidgetFocusOrder(self, widList: tuple): """ Change the focus order of the widgets in this applet. This method re-arranges the internal (cyclic) widget list so that all widgets specified in ``widList`` will be focused in the given order. |Args| * ``wid...
python
def qteSetWidgetFocusOrder(self, widList: tuple): """ Change the focus order of the widgets in this applet. This method re-arranges the internal (cyclic) widget list so that all widgets specified in ``widList`` will be focused in the given order. |Args| * ``wid...
[ "def", "qteSetWidgetFocusOrder", "(", "self", ",", "widList", ":", "tuple", ")", ":", "# A list with less than two entries cannot be re-ordered.", "if", "len", "(", "widList", ")", "<", "2", ":", "return", "# Housekeeping: remove non-existing widgets from the admin structure....
Change the focus order of the widgets in this applet. This method re-arranges the internal (cyclic) widget list so that all widgets specified in ``widList`` will be focused in the given order. |Args| * ``widList`` (**tuple**): a tuple of widget objects. |Returns| ...
[ "Change", "the", "focus", "order", "of", "the", "widgets", "in", "this", "applet", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/base_applet.py#L469-L529
train
Change the focus order of the widgets in this applet.
olitheolix/qtmacs
qtmacs/base_applet.py
QtmacsApplet.qteNextWidget
def qteNextWidget(self, numSkip: int=1, ofsWidget: QtGui.QWidget=None, skipVisible: bool=False, skipInvisible: bool=True, skipFocusable: bool=False, skipUnfocusable: bool=True): """ Return the next widget in cyclic order. If ``of...
python
def qteNextWidget(self, numSkip: int=1, ofsWidget: QtGui.QWidget=None, skipVisible: bool=False, skipInvisible: bool=True, skipFocusable: bool=False, skipUnfocusable: bool=True): """ Return the next widget in cyclic order. If ``of...
[ "def", "qteNextWidget", "(", "self", ",", "numSkip", ":", "int", "=", "1", ",", "ofsWidget", ":", "QtGui", ".", "QWidget", "=", "None", ",", "skipVisible", ":", "bool", "=", "False", ",", "skipInvisible", ":", "bool", "=", "True", ",", "skipFocusable", ...
Return the next widget in cyclic order. If ``ofsWidget`` is **None** then start counting at the currently active widget and return the applet ``numSkip`` items away in cyclic order in the internal widget list. If ``numSkip`` is positive traverse the applet list forwards, otherwi...
[ "Return", "the", "next", "widget", "in", "cyclic", "order", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/base_applet.py#L532-L638
train
Return the next widget in the internal widget list.
olitheolix/qtmacs
qtmacs/base_applet.py
QtmacsApplet.qteMakeWidgetActive
def qteMakeWidgetActive(self, widgetObj: QtGui.QWidget): """ Give keyboard focus to ``widgetObj``. If ``widgetObj`` is **None** then the internal focus state is reset, but the focus manger will automatically activate the first available widget again. |Args| * `...
python
def qteMakeWidgetActive(self, widgetObj: QtGui.QWidget): """ Give keyboard focus to ``widgetObj``. If ``widgetObj`` is **None** then the internal focus state is reset, but the focus manger will automatically activate the first available widget again. |Args| * `...
[ "def", "qteMakeWidgetActive", "(", "self", ",", "widgetObj", ":", "QtGui", ".", "QWidget", ")", ":", "# Void the active widget information.", "if", "widgetObj", "is", "None", ":", "self", ".", "_qteActiveWidget", "=", "None", "return", "# Ensure that this applet is an...
Give keyboard focus to ``widgetObj``. If ``widgetObj`` is **None** then the internal focus state is reset, but the focus manger will automatically activate the first available widget again. |Args| * ``widgetObj`` (**QWidget**): the widget to focus on. |Returns| ...
[ "Give", "keyboard", "focus", "to", "widgetObj", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/base_applet.py#L641-L698
train
Make the widgetObj active.
olitheolix/qtmacs
qtmacs/base_applet.py
QtmacsApplet.loadFile
def loadFile(self, fileName: str=None): """ Overload this method with applet specific code that can make sense of the passed ``fileName`` argument. In many case this will literally mean a file name, but could equally well be a URL (eg. ``QWebView`` based applets) or any other res...
python
def loadFile(self, fileName: str=None): """ Overload this method with applet specific code that can make sense of the passed ``fileName`` argument. In many case this will literally mean a file name, but could equally well be a URL (eg. ``QWebView`` based applets) or any other res...
[ "def", "loadFile", "(", "self", ",", "fileName", ":", "str", "=", "None", ")", ":", "msg", "=", "(", "'The <b>{}</b> applet has not implemented the '", "'<b>LoadFile</b> method'", ")", "self", ".", "qteLogger", ".", "info", "(", "msg", ".", "format", "(", "sel...
Overload this method with applet specific code that can make sense of the passed ``fileName`` argument. In many case this will literally mean a file name, but could equally well be a URL (eg. ``QWebView`` based applets) or any other resource descriptor, as long as it is in text form. ...
[ "Overload", "this", "method", "with", "applet", "specific", "code", "that", "can", "make", "sense", "of", "the", "passed", "fileName", "argument", ".", "In", "many", "case", "this", "will", "literally", "mean", "a", "file", "name", "but", "could", "equally",...
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/base_applet.py#L876-L898
train
Overload this method with applet specific code that can make sense of the passed file name.
olitheolix/qtmacs
qtmacs/base_applet.py
QtmacsApplet.show
def show(self, fromQtmacs: bool=False): """ Overloaded ``show()`` function to avoid calling it accidentally. This method is a (weak) security mechanism to prevent programmers from using the ``show`` method as originally intended by Qt, ie. to show a window. In Qtmacs, ap...
python
def show(self, fromQtmacs: bool=False): """ Overloaded ``show()`` function to avoid calling it accidentally. This method is a (weak) security mechanism to prevent programmers from using the ``show`` method as originally intended by Qt, ie. to show a window. In Qtmacs, ap...
[ "def", "show", "(", "self", ",", "fromQtmacs", ":", "bool", "=", "False", ")", ":", "if", "not", "fromQtmacs", ":", "# Log a warning message if someone tries to call the", "# native show() method.", "msg", "=", "'show() command for applet <b>{}</b> ignored. '", "msg", "+=...
Overloaded ``show()`` function to avoid calling it accidentally. This method is a (weak) security mechanism to prevent programmers from using the ``show`` method as originally intended by Qt, ie. to show a window. In Qtmacs, applets can only be made visible with either ``qteMake...
[ "Overloaded", "show", "()", "function", "to", "avoid", "calling", "it", "accidentally", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/base_applet.py#L901-L968
train
Show the applet with the applet s current entry.
olitheolix/qtmacs
qtmacs/base_applet.py
QtmacsApplet.hide
def hide(self, fromQtmacs: bool=False): """ Overloaded ``hide()`` function to avoid calling it accidentally. This method is a (weak) security mechanism to prevent programmers from using the ``hide`` method as originally intended by Qt, ie. to hide a window. However, in Q...
python
def hide(self, fromQtmacs: bool=False): """ Overloaded ``hide()`` function to avoid calling it accidentally. This method is a (weak) security mechanism to prevent programmers from using the ``hide`` method as originally intended by Qt, ie. to hide a window. However, in Q...
[ "def", "hide", "(", "self", ",", "fromQtmacs", ":", "bool", "=", "False", ")", ":", "if", "not", "fromQtmacs", ":", "# Log a warning message if someone tries to call the", "# native hide() method.", "msg", "=", "(", "'hide() command for applet <b>{}</b> ignored. Use '", "...
Overloaded ``hide()`` function to avoid calling it accidentally. This method is a (weak) security mechanism to prevent programmers from using the ``hide`` method as originally intended by Qt, ie. to hide a window. However, in Qtmacs, applets can only be made invisible by either ...
[ "Overloaded", "hide", "()", "function", "to", "avoid", "calling", "it", "accidentally", "." ]
36253b082b82590f183fe154b053eb3a1e741be2
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/base_applet.py#L971-L1019
train
Hide the applet with the given internal key.
projectshift/shift-schema
shiftschema/validators/required.py
Required.validate
def validate(self, value, model=None, context=None): """ Validate Perform value validation and return result :param value: value to check :param model: parent model being validated :param context: object or None, validation context :re...
python
def validate(self, value, model=None, context=None): """ Validate Perform value validation and return result :param value: value to check :param model: parent model being validated :param context: object or None, validation context :re...
[ "def", "validate", "(", "self", ",", "value", ",", "model", "=", "None", ",", "context", "=", "None", ")", ":", "# ok if non-empty string", "if", "type", "(", "value", ")", "is", "str", ":", "value", "=", "value", ".", "strip", "(", ")", "if", "value...
Validate Perform value validation and return result :param value: value to check :param model: parent model being validated :param context: object or None, validation context :return: shiftschema.results.SimpleResult
[ "Validate", "Perform", "value", "validation", "and", "return", "result" ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/validators/required.py#L30-L60
train
Validate the value of the key in the object.
erikdejonge/consoleprinter
convertfile_ascii.py
main
def main(): """ main """ arguments = IArguments(__doc__) content = open(arguments.filepath).read() open(arguments.filepath + ".bak", "w").write(content) try: newcontent = transliterate(content) write_newcontent(arguments.filepath, newcontent) except UnicodeEncodeError as ...
python
def main(): """ main """ arguments = IArguments(__doc__) content = open(arguments.filepath).read() open(arguments.filepath + ".bak", "w").write(content) try: newcontent = transliterate(content) write_newcontent(arguments.filepath, newcontent) except UnicodeEncodeError as ...
[ "def", "main", "(", ")", ":", "arguments", "=", "IArguments", "(", "__doc__", ")", "content", "=", "open", "(", "arguments", ".", "filepath", ")", ".", "read", "(", ")", "open", "(", "arguments", ".", "filepath", "+", "\".bak\"", ",", "\"w\"", ")", "...
main
[ "main" ]
fa2d3de08a410fc32742f0b04c94b95aae408029
https://github.com/erikdejonge/consoleprinter/blob/fa2d3de08a410fc32742f0b04c94b95aae408029/convertfile_ascii.py#L49-L62
train
main function for the script
sublee/etc
etc/adapters/mock.py
split_key
def split_key(key): """Splits a node key.""" if key == KEY_SEP: return () key_chunks = tuple(key.strip(KEY_SEP).split(KEY_SEP)) if key_chunks[0].startswith(KEY_SEP): return (key_chunks[0][len(KEY_SEP):],) + key_chunks[1:] else: return key_chunks
python
def split_key(key): """Splits a node key.""" if key == KEY_SEP: return () key_chunks = tuple(key.strip(KEY_SEP).split(KEY_SEP)) if key_chunks[0].startswith(KEY_SEP): return (key_chunks[0][len(KEY_SEP):],) + key_chunks[1:] else: return key_chunks
[ "def", "split_key", "(", "key", ")", ":", "if", "key", "==", "KEY_SEP", ":", "return", "(", ")", "key_chunks", "=", "tuple", "(", "key", ".", "strip", "(", "KEY_SEP", ")", ".", "split", "(", "KEY_SEP", ")", ")", "if", "key_chunks", "[", "0", "]", ...
Splits a node key.
[ "Splits", "a", "node", "key", "." ]
f2be64604da5af0d7739cfacf36f55712f0fc5cb
https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/adapters/mock.py#L32-L40
train
Splits a node key into a list of node names.
sublee/etc
etc/adapters/mock.py
MockNode.set
def set(self, index, value=None, dir=False, ttl=None, expiration=None): """Updates the node data.""" if bool(dir) is (value is not None): raise TypeError('Choose one of value or directory') if (ttl is not None) is (expiration is None): raise TypeError('Both of ttl and exp...
python
def set(self, index, value=None, dir=False, ttl=None, expiration=None): """Updates the node data.""" if bool(dir) is (value is not None): raise TypeError('Choose one of value or directory') if (ttl is not None) is (expiration is None): raise TypeError('Both of ttl and exp...
[ "def", "set", "(", "self", ",", "index", ",", "value", "=", "None", ",", "dir", "=", "False", ",", "ttl", "=", "None", ",", "expiration", "=", "None", ")", ":", "if", "bool", "(", "dir", ")", "is", "(", "value", "is", "not", "None", ")", ":", ...
Updates the node data.
[ "Updates", "the", "node", "data", "." ]
f2be64604da5af0d7739cfacf36f55712f0fc5cb
https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/adapters/mock.py#L54-L66
train
Updates the node data.
sublee/etc
etc/adapters/mock.py
MockNode.canonicalize
def canonicalize(self, include_nodes=True, sorted=False): """Generates a canonical :class:`etc.Node` object from this mock node. """ node_class = Directory if self.dir else Value kwargs = {attr: getattr(self, attr) for attr in node_class.__slots__} if self.dir: if inc...
python
def canonicalize(self, include_nodes=True, sorted=False): """Generates a canonical :class:`etc.Node` object from this mock node. """ node_class = Directory if self.dir else Value kwargs = {attr: getattr(self, attr) for attr in node_class.__slots__} if self.dir: if inc...
[ "def", "canonicalize", "(", "self", ",", "include_nodes", "=", "True", ",", "sorted", "=", "False", ")", ":", "node_class", "=", "Directory", "if", "self", ".", "dir", "else", "Value", "kwargs", "=", "{", "attr", ":", "getattr", "(", "self", ",", "attr...
Generates a canonical :class:`etc.Node` object from this mock node.
[ "Generates", "a", "canonical", ":", "class", ":", "etc", ".", "Node", "object", "from", "this", "mock", "node", "." ]
f2be64604da5af0d7739cfacf36f55712f0fc5cb
https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/adapters/mock.py#L87-L101
train
Generates a canonical : class : etc. Node object from this mock node.
sublee/etc
etc/adapters/mock.py
MockAdapter.make_result
def make_result(self, result_class, node=None, prev_node=None, remember=True, key_chunks=None, notify=True, **kwargs): """Makes an etcd result. If `remember` is ``True``, it keeps the result in the history and triggers events if waiting. `key_chunks` is the result of ...
python
def make_result(self, result_class, node=None, prev_node=None, remember=True, key_chunks=None, notify=True, **kwargs): """Makes an etcd result. If `remember` is ``True``, it keeps the result in the history and triggers events if waiting. `key_chunks` is the result of ...
[ "def", "make_result", "(", "self", ",", "result_class", ",", "node", "=", "None", ",", "prev_node", "=", "None", ",", "remember", "=", "True", ",", "key_chunks", "=", "None", ",", "notify", "=", "True", ",", "*", "*", "kwargs", ")", ":", "def", "cano...
Makes an etcd result. If `remember` is ``True``, it keeps the result in the history and triggers events if waiting. `key_chunks` is the result of :func:`split_key` of the `node.key`. It is not required if `remember` is ``False``. Otherwise, it is optional but recommended to eliminate...
[ "Makes", "an", "etcd", "result", "." ]
f2be64604da5af0d7739cfacf36f55712f0fc5cb
https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/adapters/mock.py#L124-L161
train
Makes an etcd result.
sublee/etc
etc/adapters/mock.py
MockAdapter.compare
def compare(self, node, prev_value=None, prev_index=None): """Raises :exc:`TestFailed` if the node is not matched with `prev_value` or `prev_index`. """ if prev_value is not None and node.value != prev_value or \ prev_index is not None and node.index != prev_index: ...
python
def compare(self, node, prev_value=None, prev_index=None): """Raises :exc:`TestFailed` if the node is not matched with `prev_value` or `prev_index`. """ if prev_value is not None and node.value != prev_value or \ prev_index is not None and node.index != prev_index: ...
[ "def", "compare", "(", "self", ",", "node", ",", "prev_value", "=", "None", ",", "prev_index", "=", "None", ")", ":", "if", "prev_value", "is", "not", "None", "and", "node", ".", "value", "!=", "prev_value", "or", "prev_index", "is", "not", "None", "an...
Raises :exc:`TestFailed` if the node is not matched with `prev_value` or `prev_index`.
[ "Raises", ":", "exc", ":", "TestFailed", "if", "the", "node", "is", "not", "matched", "with", "prev_value", "or", "prev_index", "." ]
f2be64604da5af0d7739cfacf36f55712f0fc5cb
https://github.com/sublee/etc/blob/f2be64604da5af0d7739cfacf36f55712f0fc5cb/etc/adapters/mock.py#L163-L169
train
Compare the node with the previous value and index.
haum/hms_base
hms_base/client.py
Client.connect
def connect(self, host='localhost'): """Connect to the server and set everything up. Args: host: hostname to connect to """ # Connect get_logger().info("Connecting to RabbitMQ server...") self._conn = pika.BlockingConnection( pika.ConnectionPa...
python
def connect(self, host='localhost'): """Connect to the server and set everything up. Args: host: hostname to connect to """ # Connect get_logger().info("Connecting to RabbitMQ server...") self._conn = pika.BlockingConnection( pika.ConnectionPa...
[ "def", "connect", "(", "self", ",", "host", "=", "'localhost'", ")", ":", "# Connect", "get_logger", "(", ")", ".", "info", "(", "\"Connecting to RabbitMQ server...\"", ")", "self", ".", "_conn", "=", "pika", ".", "BlockingConnection", "(", "pika", ".", "Con...
Connect to the server and set everything up. Args: host: hostname to connect to
[ "Connect", "to", "the", "server", "and", "set", "everything", "up", "." ]
7c0aed961b43cba043c703102e503cb40db81f58
https://github.com/haum/hms_base/blob/7c0aed961b43cba043c703102e503cb40db81f58/hms_base/client.py#L45-L106
train
Connect to the server and set everything up.
haum/hms_base
hms_base/client.py
Client.publish
def publish(self, topic, dct): """Send a dict with internal routing key to the exchange. Args: topic: topic to publish the message to dct: dict object to send """ get_logger().info("Publishing message {} on routing key " "{}...".format(...
python
def publish(self, topic, dct): """Send a dict with internal routing key to the exchange. Args: topic: topic to publish the message to dct: dict object to send """ get_logger().info("Publishing message {} on routing key " "{}...".format(...
[ "def", "publish", "(", "self", ",", "topic", ",", "dct", ")", ":", "get_logger", "(", ")", ".", "info", "(", "\"Publishing message {} on routing key \"", "\"{}...\"", ".", "format", "(", "dct", ",", "topic", ")", ")", "self", ".", "_channel", ".", "basic_p...
Send a dict with internal routing key to the exchange. Args: topic: topic to publish the message to dct: dict object to send
[ "Send", "a", "dict", "with", "internal", "routing", "key", "to", "the", "exchange", "." ]
7c0aed961b43cba043c703102e503cb40db81f58
https://github.com/haum/hms_base/blob/7c0aed961b43cba043c703102e503cb40db81f58/hms_base/client.py#L108-L123
train
Send a dict with internal routing key to the exchange.
haum/hms_base
hms_base/client.py
Client._callback
def _callback(self, ch, method, properties, body): """Internal method that will be called when receiving message.""" get_logger().info("Message received! Calling listeners...") topic = method.routing_key dct = json.loads(body.decode('utf-8')) for listener in self.listeners: ...
python
def _callback(self, ch, method, properties, body): """Internal method that will be called when receiving message.""" get_logger().info("Message received! Calling listeners...") topic = method.routing_key dct = json.loads(body.decode('utf-8')) for listener in self.listeners: ...
[ "def", "_callback", "(", "self", ",", "ch", ",", "method", ",", "properties", ",", "body", ")", ":", "get_logger", "(", ")", ".", "info", "(", "\"Message received! Calling listeners...\"", ")", "topic", "=", "method", ".", "routing_key", "dct", "=", "json", ...
Internal method that will be called when receiving message.
[ "Internal", "method", "that", "will", "be", "called", "when", "receiving", "message", "." ]
7c0aed961b43cba043c703102e503cb40db81f58
https://github.com/haum/hms_base/blob/7c0aed961b43cba043c703102e503cb40db81f58/hms_base/client.py#L140-L149
train
Internal method that will be called when a message is received.
haum/hms_base
hms_base/client.py
Client._handle_ping
def _handle_ping(client, topic, dct): """Internal method that will be called when receiving ping message.""" if dct['type'] == 'request': resp = { 'type': 'answer', 'name': client.name, 'source': dct } client.publish('p...
python
def _handle_ping(client, topic, dct): """Internal method that will be called when receiving ping message.""" if dct['type'] == 'request': resp = { 'type': 'answer', 'name': client.name, 'source': dct } client.publish('p...
[ "def", "_handle_ping", "(", "client", ",", "topic", ",", "dct", ")", ":", "if", "dct", "[", "'type'", "]", "==", "'request'", ":", "resp", "=", "{", "'type'", ":", "'answer'", ",", "'name'", ":", "client", ".", "name", ",", "'source'", ":", "dct", ...
Internal method that will be called when receiving ping message.
[ "Internal", "method", "that", "will", "be", "called", "when", "receiving", "ping", "message", "." ]
7c0aed961b43cba043c703102e503cb40db81f58
https://github.com/haum/hms_base/blob/7c0aed961b43cba043c703102e503cb40db81f58/hms_base/client.py#L153-L162
train
Internal method that will be called when receiving ping message.
weijia/djangoautoconf
djangoautoconf/obs/auto_conf_admin_utils.py
register_to_sys_with_admin_list
def register_to_sys_with_admin_list(class_inst, admin_list=None, is_normal_admin_needed=False): """ :param class_inst: model class :param admin_list: admin class :param is_normal_admin_needed: is normal admin registration needed :return: """ if admin_list is None: admin_class = get_v...
python
def register_to_sys_with_admin_list(class_inst, admin_list=None, is_normal_admin_needed=False): """ :param class_inst: model class :param admin_list: admin class :param is_normal_admin_needed: is normal admin registration needed :return: """ if admin_list is None: admin_class = get_v...
[ "def", "register_to_sys_with_admin_list", "(", "class_inst", ",", "admin_list", "=", "None", ",", "is_normal_admin_needed", "=", "False", ")", ":", "if", "admin_list", "is", "None", ":", "admin_class", "=", "get_valid_admin_class_with_list", "(", "[", "]", ",", "c...
:param class_inst: model class :param admin_list: admin class :param is_normal_admin_needed: is normal admin registration needed :return:
[ ":", "param", "class_inst", ":", "model", "class", ":", "param", "admin_list", ":", "admin", "class", ":", "param", "is_normal_admin_needed", ":", "is", "normal", "admin", "registration", "needed", ":", "return", ":" ]
b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0
https://github.com/weijia/djangoautoconf/blob/b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0/djangoautoconf/obs/auto_conf_admin_utils.py#L61-L75
train
register to sys admin list
weijia/djangoautoconf
djangoautoconf/obs/auto_conf_admin_utils.py
register_all_in_module
def register_all_in_module(module_instance, exclude_name_list=[], admin_class_list=None): """ :param module_instance: mostly the models module :param exclude_name_list: class does not need to register or is already registered :param admin_class_list: :return: """ class_list = [] for name...
python
def register_all_in_module(module_instance, exclude_name_list=[], admin_class_list=None): """ :param module_instance: mostly the models module :param exclude_name_list: class does not need to register or is already registered :param admin_class_list: :return: """ class_list = [] for name...
[ "def", "register_all_in_module", "(", "module_instance", ",", "exclude_name_list", "=", "[", "]", ",", "admin_class_list", "=", "None", ")", ":", "class_list", "=", "[", "]", "for", "name", ",", "obj", "in", "inspect", ".", "getmembers", "(", "module_instance"...
:param module_instance: mostly the models module :param exclude_name_list: class does not need to register or is already registered :param admin_class_list: :return:
[ ":", "param", "module_instance", ":", "mostly", "the", "models", "module", ":", "param", "exclude_name_list", ":", "class", "does", "not", "need", "to", "register", "or", "is", "already", "registered", ":", "param", "admin_class_list", ":", ":", "return", ":" ...
b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0
https://github.com/weijia/djangoautoconf/blob/b7dbda2287ed8cb9de6d02cb3abaaa1c36b1ced0/djangoautoconf/obs/auto_conf_admin_utils.py#L88-L102
train
Registers all the classes in a module.
pmacosta/pexdoc
pexdoc/pcontracts.py
_create_argument_value_pairs
def _create_argument_value_pairs(func, *args, **kwargs): """ Create dictionary with argument names as keys and their passed values as values. An empty dictionary is returned if an error is detected, such as more arguments than in the function definition, argument(s) defined by position and keyword,...
python
def _create_argument_value_pairs(func, *args, **kwargs): """ Create dictionary with argument names as keys and their passed values as values. An empty dictionary is returned if an error is detected, such as more arguments than in the function definition, argument(s) defined by position and keyword,...
[ "def", "_create_argument_value_pairs", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Capture parameters that have been explicitly specified in function call", "try", ":", "arg_dict", "=", "signature", "(", "func", ")", ".", "bind_partial", "(", ...
Create dictionary with argument names as keys and their passed values as values. An empty dictionary is returned if an error is detected, such as more arguments than in the function definition, argument(s) defined by position and keyword, etc.
[ "Create", "dictionary", "with", "argument", "names", "as", "keys", "and", "their", "passed", "values", "as", "values", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pcontracts.py#L48-L69
train
Create dictionary with argument names as keys and their passed values as values.
pmacosta/pexdoc
pexdoc/pcontracts.py
_format_arg
def _format_arg(arg): """Validate one exception specification contract tuple/list.""" # Check that the argument conforms to one of the acceptable types, a string # (when the default exception type is used), an exception type (when the # default exception message is used) or a list/tuple to specify both ...
python
def _format_arg(arg): """Validate one exception specification contract tuple/list.""" # Check that the argument conforms to one of the acceptable types, a string # (when the default exception type is used), an exception type (when the # default exception message is used) or a list/tuple to specify both ...
[ "def", "_format_arg", "(", "arg", ")", ":", "# Check that the argument conforms to one of the acceptable types, a string", "# (when the default exception type is used), an exception type (when the", "# default exception message is used) or a list/tuple to specify both", "# exception type and excep...
Validate one exception specification contract tuple/list.
[ "Validate", "one", "exception", "specification", "contract", "tuple", "/", "list", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pcontracts.py#L72-L131
train
Validate one exception specification contract tuple or list.
pmacosta/pexdoc
pexdoc/pcontracts.py
_get_contract_exception_dict
def _get_contract_exception_dict(contract_msg): """Generate message for exception.""" # A pcontract-defined custom exception message is wrapped in a string # that starts with '[START CONTRACT MSG:' and ends with # '[STOP CONTRACT MSG]'. This is done to easily detect if an # exception raised is from ...
python
def _get_contract_exception_dict(contract_msg): """Generate message for exception.""" # A pcontract-defined custom exception message is wrapped in a string # that starts with '[START CONTRACT MSG:' and ends with # '[STOP CONTRACT MSG]'. This is done to easily detect if an # exception raised is from ...
[ "def", "_get_contract_exception_dict", "(", "contract_msg", ")", ":", "# A pcontract-defined custom exception message is wrapped in a string", "# that starts with '[START CONTRACT MSG:' and ends with", "# '[STOP CONTRACT MSG]'. This is done to easily detect if an", "# exception raised is from a cu...
Generate message for exception.
[ "Generate", "message", "for", "exception", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pcontracts.py#L134-L161
train
Generate message for exception.
pmacosta/pexdoc
pexdoc/pcontracts.py
_get_custom_contract
def _get_custom_contract(param_contract): """Return True if parameter contract is a custom contract, False otherwise.""" if not isinstance(param_contract, str): return None for custom_contract in _CUSTOM_CONTRACTS: if re.search(r"\b{0}\b".format(custom_contract), param_contract): ...
python
def _get_custom_contract(param_contract): """Return True if parameter contract is a custom contract, False otherwise.""" if not isinstance(param_contract, str): return None for custom_contract in _CUSTOM_CONTRACTS: if re.search(r"\b{0}\b".format(custom_contract), param_contract): ...
[ "def", "_get_custom_contract", "(", "param_contract", ")", ":", "if", "not", "isinstance", "(", "param_contract", ",", "str", ")", ":", "return", "None", "for", "custom_contract", "in", "_CUSTOM_CONTRACTS", ":", "if", "re", ".", "search", "(", "r\"\\b{0}\\b\"", ...
Return True if parameter contract is a custom contract, False otherwise.
[ "Return", "True", "if", "parameter", "contract", "is", "a", "custom", "contract", "False", "otherwise", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pcontracts.py#L164-L171
train
Return True if parameter contract is a custom contract False otherwise.
pmacosta/pexdoc
pexdoc/pcontracts.py
get_exdesc
def get_exdesc(): """ Retrieve contract exception(s) message(s). If the custom contract is specified with only one exception the return value is the message associated with that exception; if the custom contract is specified with several exceptions, the return value is a dictionary whose keys a...
python
def get_exdesc(): """ Retrieve contract exception(s) message(s). If the custom contract is specified with only one exception the return value is the message associated with that exception; if the custom contract is specified with several exceptions, the return value is a dictionary whose keys a...
[ "def", "get_exdesc", "(", ")", ":", "# First frame is own function (get_exdesc), next frame is the calling", "# function, of which its name is needed", "fname", "=", "inspect", ".", "getframeinfo", "(", "sys", ".", "_getframe", "(", "1", ")", ")", "[", "2", "]", "# Find...
Retrieve contract exception(s) message(s). If the custom contract is specified with only one exception the return value is the message associated with that exception; if the custom contract is specified with several exceptions, the return value is a dictionary whose keys are the exception names and who...
[ "Retrieve", "contract", "exception", "(", "s", ")", "message", "(", "s", ")", "." ]
201ac243e5781347feb75896a4231429fe6da4b1
https://github.com/pmacosta/pexdoc/blob/201ac243e5781347feb75896a4231429fe6da4b1/pexdoc/pcontracts.py#L215-L285
train
Retrieve exception message and exception names.