repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
PyMLGame/pymlgame
pymlgame/controller.py
Controller._del_controller
def _del_controller(self, uid): """ Remove controller from internal list and tell the game. :param uid: Unique id of the controller :type uid: str """ try: self.controllers.pop(uid) e = Event(uid, E_DISCONNECT) self.queue.put_nowait(e)...
python
def _del_controller(self, uid): """ Remove controller from internal list and tell the game. :param uid: Unique id of the controller :type uid: str """ try: self.controllers.pop(uid) e = Event(uid, E_DISCONNECT) self.queue.put_nowait(e)...
[ "def", "_del_controller", "(", "self", ",", "uid", ")", ":", "try", ":", "self", ".", "controllers", ".", "pop", "(", "uid", ")", "e", "=", "Event", "(", "uid", ",", "E_DISCONNECT", ")", "self", ".", "queue", ".", "put_nowait", "(", "e", ")", "exce...
Remove controller from internal list and tell the game. :param uid: Unique id of the controller :type uid: str
[ "Remove", "controller", "from", "internal", "list", "and", "tell", "the", "game", "." ]
train
https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/controller.py#L72-L85
PyMLGame/pymlgame
pymlgame/controller.py
Controller._ping
def _ping(self, uid, addr, port): """ Just say hello so that pymlgame knows that your controller is still alive. Unused controllers will be deleted after a while. This function is also used to update the address and port of the controller if it has changed. :param uid: Unique id of the ...
python
def _ping(self, uid, addr, port): """ Just say hello so that pymlgame knows that your controller is still alive. Unused controllers will be deleted after a while. This function is also used to update the address and port of the controller if it has changed. :param uid: Unique id of the ...
[ "def", "_ping", "(", "self", ",", "uid", ",", "addr", ",", "port", ")", ":", "try", ":", "self", ".", "controllers", "[", "uid", "]", "[", "0", "]", "=", "addr", "self", ".", "controllers", "[", "uid", "]", "[", "1", "]", "=", "port", "self", ...
Just say hello so that pymlgame knows that your controller is still alive. Unused controllers will be deleted after a while. This function is also used to update the address and port of the controller if it has changed. :param uid: Unique id of the controller :param addr: Address of the control...
[ "Just", "say", "hello", "so", "that", "pymlgame", "knows", "that", "your", "controller", "is", "still", "alive", ".", "Unused", "controllers", "will", "be", "deleted", "after", "a", "while", ".", "This", "function", "is", "also", "used", "to", "update", "t...
train
https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/controller.py#L87-L108
PyMLGame/pymlgame
pymlgame/controller.py
Controller._update_states
def _update_states(self, uid, states): """ Got states of all buttons from a controller. Now check if something changed and create events if neccesary. :param uid: Unique id of the controller :param states: Buttons states :type uid: str :type states: str """ ...
python
def _update_states(self, uid, states): """ Got states of all buttons from a controller. Now check if something changed and create events if neccesary. :param uid: Unique id of the controller :param states: Buttons states :type uid: str :type states: str """ ...
[ "def", "_update_states", "(", "self", ",", "uid", ",", "states", ")", ":", "#TODO: use try and catch all exceptions", "# test if uid exists", "if", "self", ".", "controllers", "[", "uid", "]", ":", "# test if states have correct lenght", "if", "len", "(", "states", ...
Got states of all buttons from a controller. Now check if something changed and create events if neccesary. :param uid: Unique id of the controller :param states: Buttons states :type uid: str :type states: str
[ "Got", "states", "of", "all", "buttons", "from", "a", "controller", ".", "Now", "check", "if", "something", "changed", "and", "create", "events", "if", "neccesary", "." ]
train
https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/controller.py#L110-L134
PyMLGame/pymlgame
pymlgame/controller.py
Controller._got_message
def _got_message(self, uid, text): """ The controller has send us a message. :param uid: Unique id of the controller :param text: Text to display :type uid: str :type text: str """ #TODO: use try e = Event(uid, E_MESSAGE, text) self.queue....
python
def _got_message(self, uid, text): """ The controller has send us a message. :param uid: Unique id of the controller :param text: Text to display :type uid: str :type text: str """ #TODO: use try e = Event(uid, E_MESSAGE, text) self.queue....
[ "def", "_got_message", "(", "self", ",", "uid", ",", "text", ")", ":", "#TODO: use try", "e", "=", "Event", "(", "uid", ",", "E_MESSAGE", ",", "text", ")", "self", ".", "queue", ".", "put_nowait", "(", "e", ")", "self", ".", "controllers", "[", "uid"...
The controller has send us a message. :param uid: Unique id of the controller :param text: Text to display :type uid: str :type text: str
[ "The", "controller", "has", "send", "us", "a", "message", "." ]
train
https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/controller.py#L136-L149
PyMLGame/pymlgame
pymlgame/controller.py
Controller.send
def send(self, uid, event, payload=None): """ Send an event to a connected controller. Use pymlgame event type and correct payload. To send a message to the controller use pymlgame.E_MESSAGE event and a string as payload. :param uid: Unique id of the controller :param event: Eve...
python
def send(self, uid, event, payload=None): """ Send an event to a connected controller. Use pymlgame event type and correct payload. To send a message to the controller use pymlgame.E_MESSAGE event and a string as payload. :param uid: Unique id of the controller :param event: Eve...
[ "def", "send", "(", "self", ",", "uid", ",", "event", ",", "payload", "=", "None", ")", ":", "sock", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_DGRAM", ")", "if", "uid", "in", "self", ".", "controllers", ...
Send an event to a connected controller. Use pymlgame event type and correct payload. To send a message to the controller use pymlgame.E_MESSAGE event and a string as payload. :param uid: Unique id of the controller :param event: Event type :param payload: Payload of the event :...
[ "Send", "an", "event", "to", "a", "connected", "controller", ".", "Use", "pymlgame", "event", "type", "and", "correct", "payload", ".", "To", "send", "a", "message", "to", "the", "controller", "use", "pymlgame", ".", "E_MESSAGE", "event", "and", "a", "stri...
train
https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/controller.py#L151-L179
PyMLGame/pymlgame
pymlgame/controller.py
Controller.run
def run(self): """ Listen for controllers. """ while True: data, sender = self.sock.recvfrom(1024) addr = sender[0] msg = data.decode('utf-8') if msg.startswith('/controller/'): try: uid = msg.split('/')[...
python
def run(self): """ Listen for controllers. """ while True: data, sender = self.sock.recvfrom(1024) addr = sender[0] msg = data.decode('utf-8') if msg.startswith('/controller/'): try: uid = msg.split('/')[...
[ "def", "run", "(", "self", ")", ":", "while", "True", ":", "data", ",", "sender", "=", "self", ".", "sock", ".", "recvfrom", "(", "1024", ")", "addr", "=", "sender", "[", "0", "]", "msg", "=", "data", ".", "decode", "(", "'utf-8'", ")", "if", "...
Listen for controllers.
[ "Listen", "for", "controllers", "." ]
train
https://github.com/PyMLGame/pymlgame/blob/450fe77d35f9a26c107586d6954f69c3895bf504/pymlgame/controller.py#L181-L218
KnowledgeLinks/rdfframework
rdfframework/utilities/baseutilities.py
get_obj_frm_str
def get_obj_frm_str(obj_str, **kwargs): """ Returns a python object from a python object string args: obj_str: python object path expamle "rdfframework.connections.ConnManager[{param1}]" kwargs: * kwargs used to format the 'obj_str' """ obj_str = obj_str.for...
python
def get_obj_frm_str(obj_str, **kwargs): """ Returns a python object from a python object string args: obj_str: python object path expamle "rdfframework.connections.ConnManager[{param1}]" kwargs: * kwargs used to format the 'obj_str' """ obj_str = obj_str.for...
[ "def", "get_obj_frm_str", "(", "obj_str", ",", "*", "*", "kwargs", ")", ":", "obj_str", "=", "obj_str", ".", "format", "(", "*", "*", "kwargs", ")", "args", "=", "[", "]", "kwargs", "=", "{", "}", "params", "=", "[", "]", "# parse the call portion of t...
Returns a python object from a python object string args: obj_str: python object path expamle "rdfframework.connections.ConnManager[{param1}]" kwargs: * kwargs used to format the 'obj_str'
[ "Returns", "a", "python", "object", "from", "a", "python", "object", "string" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L36-L83
KnowledgeLinks/rdfframework
rdfframework/utilities/baseutilities.py
pyfile_path
def pyfile_path(path): """ converst a file path argment to the is path within the framework args: path: filepath to the python file """ if "/" in path: parts = path.split("/") join_term = "/" elif "\\" in path: parts =path.split("\\") join_term = "\\" par...
python
def pyfile_path(path): """ converst a file path argment to the is path within the framework args: path: filepath to the python file """ if "/" in path: parts = path.split("/") join_term = "/" elif "\\" in path: parts =path.split("\\") join_term = "\\" par...
[ "def", "pyfile_path", "(", "path", ")", ":", "if", "\"/\"", "in", "path", ":", "parts", "=", "path", ".", "split", "(", "\"/\"", ")", "join_term", "=", "\"/\"", "elif", "\"\\\\\"", "in", "path", ":", "parts", "=", "path", ".", "split", "(", "\"\\\\\"...
converst a file path argment to the is path within the framework args: path: filepath to the python file
[ "converst", "a", "file", "path", "argment", "to", "the", "is", "path", "within", "the", "framework" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L146-L161
KnowledgeLinks/rdfframework
rdfframework/utilities/baseutilities.py
nz
def nz(value, none_value, strict=True): ''' This function is named after an old VBA function. It returns a default value if the passed in value is None. If strict is False it will treat an empty string as None as well. example: x = None nz(x,"hello") --> "hello" ...
python
def nz(value, none_value, strict=True): ''' This function is named after an old VBA function. It returns a default value if the passed in value is None. If strict is False it will treat an empty string as None as well. example: x = None nz(x,"hello") --> "hello" ...
[ "def", "nz", "(", "value", ",", "none_value", ",", "strict", "=", "True", ")", ":", "if", "not", "DEBUG", ":", "debug", "=", "False", "else", ":", "debug", "=", "False", "if", "debug", ":", "print", "(", "\"START nz frameworkutilities.py --------------------...
This function is named after an old VBA function. It returns a default value if the passed in value is None. If strict is False it will treat an empty string as None as well. example: x = None nz(x,"hello") --> "hello" nz(x,"") --> "" y = "" ...
[ "This", "function", "is", "named", "after", "an", "old", "VBA", "function", ".", "It", "returns", "a", "default", "value", "if", "the", "passed", "in", "value", "is", "None", ".", "If", "strict", "is", "False", "it", "will", "treat", "an", "empty", "st...
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L170-L202
KnowledgeLinks/rdfframework
rdfframework/utilities/baseutilities.py
render_without_request
def render_without_request(template_name, template_path=None, **template_vars): """ Usage is the same as flask.render_template: render_without_request('my_template.html', var1='foo', var2='bar') """ if template_path: env = Environment(loader=FileSystemLoader([os.path.join(template_path)])) ...
python
def render_without_request(template_name, template_path=None, **template_vars): """ Usage is the same as flask.render_template: render_without_request('my_template.html', var1='foo', var2='bar') """ if template_path: env = Environment(loader=FileSystemLoader([os.path.join(template_path)])) ...
[ "def", "render_without_request", "(", "template_name", ",", "template_path", "=", "None", ",", "*", "*", "template_vars", ")", ":", "if", "template_path", ":", "env", "=", "Environment", "(", "loader", "=", "FileSystemLoader", "(", "[", "os", ".", "path", "....
Usage is the same as flask.render_template: render_without_request('my_template.html', var1='foo', var2='bar')
[ "Usage", "is", "the", "same", "as", "flask", ".", "render_template", ":" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L204-L215
KnowledgeLinks/rdfframework
rdfframework/utilities/baseutilities.py
cbool
def cbool(value, strict=True): ''' converts a value to true or false. Python's default bool() function does not handle 'true' of 'false' strings ''' return_val = value if is_not_null(value): if isinstance(value, bool): return_val = value else: value = str(value) ...
python
def cbool(value, strict=True): ''' converts a value to true or false. Python's default bool() function does not handle 'true' of 'false' strings ''' return_val = value if is_not_null(value): if isinstance(value, bool): return_val = value else: value = str(value) ...
[ "def", "cbool", "(", "value", ",", "strict", "=", "True", ")", ":", "return_val", "=", "value", "if", "is_not_null", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "bool", ")", ":", "return_val", "=", "value", "else", ":", "value", "=...
converts a value to true or false. Python's default bool() function does not handle 'true' of 'false' strings
[ "converts", "a", "value", "to", "true", "or", "false", ".", "Python", "s", "default", "bool", "()", "function", "does", "not", "handle", "true", "of", "false", "strings" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L218-L237
KnowledgeLinks/rdfframework
rdfframework/utilities/baseutilities.py
make_set
def make_set(value): ''' Takes a value and turns it into a set !!!! This is important because set(string) will parse a string to individual characters vs. adding the string as an element of the set i.e. x = 'setvalue' set(x) = {'t', 'a', 'e', 'v', 'u', 's', 'l'} make_set(x) = {'...
python
def make_set(value): ''' Takes a value and turns it into a set !!!! This is important because set(string) will parse a string to individual characters vs. adding the string as an element of the set i.e. x = 'setvalue' set(x) = {'t', 'a', 'e', 'v', 'u', 's', 'l'} make_set(x) = {'...
[ "def", "make_set", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "list", ")", ":", "value", "=", "set", "(", "value", ")", "elif", "not", "isinstance", "(", "value", ",", "set", ")", ":", "value", "=", "set", "(", "[", "value", "...
Takes a value and turns it into a set !!!! This is important because set(string) will parse a string to individual characters vs. adding the string as an element of the set i.e. x = 'setvalue' set(x) = {'t', 'a', 'e', 'v', 'u', 's', 'l'} make_set(x) = {'setvalue'} or use set...
[ "Takes", "a", "value", "and", "turns", "it", "into", "a", "set" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L259-L274
KnowledgeLinks/rdfframework
rdfframework/utilities/baseutilities.py
make_triple
def make_triple(sub, pred, obj): """Takes a subject predicate and object and joins them with a space in between Args: sub -- Subject pred -- Predicate obj -- Object Returns str """ return "{s} {p} {o} .".format(s=sub, p=pred, o=obj)
python
def make_triple(sub, pred, obj): """Takes a subject predicate and object and joins them with a space in between Args: sub -- Subject pred -- Predicate obj -- Object Returns str """ return "{s} {p} {o} .".format(s=sub, p=pred, o=obj)
[ "def", "make_triple", "(", "sub", ",", "pred", ",", "obj", ")", ":", "return", "\"{s} {p} {o} .\"", ".", "format", "(", "s", "=", "sub", ",", "p", "=", "pred", ",", "o", "=", "obj", ")" ]
Takes a subject predicate and object and joins them with a space in between Args: sub -- Subject pred -- Predicate obj -- Object Returns str
[ "Takes", "a", "subject", "predicate", "and", "object", "and", "joins", "them", "with", "a", "space", "in", "between" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L277-L288
KnowledgeLinks/rdfframework
rdfframework/utilities/baseutilities.py
remove_null
def remove_null(obj): ''' reads through a list or set and strips any null values''' if isinstance(obj, set): try: obj.remove(None) except: pass elif isinstance(obj, list): for item in obj: if not is_not_null(item): obj.remove(item) ...
python
def remove_null(obj): ''' reads through a list or set and strips any null values''' if isinstance(obj, set): try: obj.remove(None) except: pass elif isinstance(obj, list): for item in obj: if not is_not_null(item): obj.remove(item) ...
[ "def", "remove_null", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "set", ")", ":", "try", ":", "obj", ".", "remove", "(", "None", ")", "except", ":", "pass", "elif", "isinstance", "(", "obj", ",", "list", ")", ":", "for", "item", "...
reads through a list or set and strips any null values
[ "reads", "through", "a", "list", "or", "set", "and", "strips", "any", "null", "values" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L290-L301
KnowledgeLinks/rdfframework
rdfframework/utilities/baseutilities.py
copy_obj
def copy_obj(obj): ''' does a deepcopy of an object, but does not copy a class i.e. x = {"key":[<classInstance1>,<classInstance2>,<classInstance3>]} y = copy_obj(x) y --> {"key":[<classInstance1>,<classInstance2>,<classInstance3>]} del y['key'][0] y --> {"key":[<class...
python
def copy_obj(obj): ''' does a deepcopy of an object, but does not copy a class i.e. x = {"key":[<classInstance1>,<classInstance2>,<classInstance3>]} y = copy_obj(x) y --> {"key":[<classInstance1>,<classInstance2>,<classInstance3>]} del y['key'][0] y --> {"key":[<class...
[ "def", "copy_obj", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "dict", ")", ":", "return_obj", "=", "{", "}", "for", "key", ",", "value", "in", "obj", ".", "items", "(", ")", ":", "if", "isinstance", "(", "value", ",", "dict", ")",...
does a deepcopy of an object, but does not copy a class i.e. x = {"key":[<classInstance1>,<classInstance2>,<classInstance3>]} y = copy_obj(x) y --> {"key":[<classInstance1>,<classInstance2>,<classInstance3>]} del y['key'][0] y --> {"key":[<classInstance2>,<classInstance3>...
[ "does", "a", "deepcopy", "of", "an", "object", "but", "does", "not", "copy", "a", "class", "i", ".", "e", ".", "x", "=", "{", "key", ":", "[", "<classInstance1", ">", "<classInstance2", ">", "<classInstance3", ">", "]", "}", "y", "=", "copy_obj", "("...
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L316-L347
KnowledgeLinks/rdfframework
rdfframework/utilities/baseutilities.py
delete_key_pattern
def delete_key_pattern(obj, regx_pattern): ''' takes a dictionary object and a regular expression pattern and removes all keys that match the pattern. args: obj: dictionay object to search trhough regx_pattern: string without beginning and ending / ''' if isinstance(obj, list): ...
python
def delete_key_pattern(obj, regx_pattern): ''' takes a dictionary object and a regular expression pattern and removes all keys that match the pattern. args: obj: dictionay object to search trhough regx_pattern: string without beginning and ending / ''' if isinstance(obj, list): ...
[ "def", "delete_key_pattern", "(", "obj", ",", "regx_pattern", ")", ":", "if", "isinstance", "(", "obj", ",", "list", ")", ":", "_return_list", "=", "[", "]", "for", "item", "in", "obj", ":", "if", "isinstance", "(", "item", ",", "list", ")", ":", "_r...
takes a dictionary object and a regular expression pattern and removes all keys that match the pattern. args: obj: dictionay object to search trhough regx_pattern: string without beginning and ending /
[ "takes", "a", "dictionary", "object", "and", "a", "regular", "expression", "pattern", "and", "removes", "all", "keys", "that", "match", "the", "pattern", "." ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L423-L471
KnowledgeLinks/rdfframework
rdfframework/utilities/baseutilities.py
get_dict_key
def get_dict_key(data, key): ''' will serach a mulitdemensional dictionary for a key name and return a value list of matching results ''' if isinstance(data, Mapping): if key in data: yield data[key] for key_data in data.values(): for found in get_dict_key(key_da...
python
def get_dict_key(data, key): ''' will serach a mulitdemensional dictionary for a key name and return a value list of matching results ''' if isinstance(data, Mapping): if key in data: yield data[key] for key_data in data.values(): for found in get_dict_key(key_da...
[ "def", "get_dict_key", "(", "data", ",", "key", ")", ":", "if", "isinstance", "(", "data", ",", "Mapping", ")", ":", "if", "key", "in", "data", ":", "yield", "data", "[", "key", "]", "for", "key_data", "in", "data", ".", "values", "(", ")", ":", ...
will serach a mulitdemensional dictionary for a key name and return a value list of matching results
[ "will", "serach", "a", "mulitdemensional", "dictionary", "for", "a", "key", "name", "and", "return", "a", "value", "list", "of", "matching", "results" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L473-L482
KnowledgeLinks/rdfframework
rdfframework/utilities/baseutilities.py
get_attr
def get_attr(item, name, default=None): ''' similar to getattr and get but will test for class or dict ''' try: val = item[name] except (KeyError, TypeError): try: val = getattr(item, name) except AttributeError: val = default return val
python
def get_attr(item, name, default=None): ''' similar to getattr and get but will test for class or dict ''' try: val = item[name] except (KeyError, TypeError): try: val = getattr(item, name) except AttributeError: val = default return val
[ "def", "get_attr", "(", "item", ",", "name", ",", "default", "=", "None", ")", ":", "try", ":", "val", "=", "item", "[", "name", "]", "except", "(", "KeyError", ",", "TypeError", ")", ":", "try", ":", "val", "=", "getattr", "(", "item", ",", "nam...
similar to getattr and get but will test for class or dict
[ "similar", "to", "getattr", "and", "get", "but", "will", "test", "for", "class", "or", "dict" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L484-L493
KnowledgeLinks/rdfframework
rdfframework/utilities/baseutilities.py
get2
def get2(item, key, if_none=None, strict=True): ''' similar to dict.get functionality but None value will return then if_none value args: item: dictionary to search key: the dictionary key if_none: the value to return if None is passed in strict: if False an empty string...
python
def get2(item, key, if_none=None, strict=True): ''' similar to dict.get functionality but None value will return then if_none value args: item: dictionary to search key: the dictionary key if_none: the value to return if None is passed in strict: if False an empty string...
[ "def", "get2", "(", "item", ",", "key", ",", "if_none", "=", "None", ",", "strict", "=", "True", ")", ":", "if", "not", "strict", "and", "item", ".", "get", "(", "key", ")", "==", "\"\"", ":", "return", "if_none", "elif", "item", ".", "get", "(",...
similar to dict.get functionality but None value will return then if_none value args: item: dictionary to search key: the dictionary key if_none: the value to return if None is passed in strict: if False an empty string is treated as None
[ "similar", "to", "dict", ".", "get", "functionality", "but", "None", "value", "will", "return", "then", "if_none", "value" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L538-L553
KnowledgeLinks/rdfframework
rdfframework/utilities/baseutilities.py
initialized
def initialized(func): """ decorator for testing if a class has been initialized prior to calling any attribute """ def wrapper(self, *args, **kwargs): """ internal wrapper function """ if not self.__is_initialized__: return EmptyDot() return func(self, *args, **kwar...
python
def initialized(func): """ decorator for testing if a class has been initialized prior to calling any attribute """ def wrapper(self, *args, **kwargs): """ internal wrapper function """ if not self.__is_initialized__: return EmptyDot() return func(self, *args, **kwar...
[ "def", "initialized", "(", "func", ")", ":", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\" internal wrapper function \"\"\"", "if", "not", "self", ".", "__is_initialized__", ":", "return", "EmptyDot", "(", ")", ...
decorator for testing if a class has been initialized prior to calling any attribute
[ "decorator", "for", "testing", "if", "a", "class", "has", "been", "initialized", "prior", "to", "calling", "any", "attribute" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L750-L759
KnowledgeLinks/rdfframework
rdfframework/utilities/baseutilities.py
clean_iri
def clean_iri(uri_string): '''removes the <> signs from a string start and end''' uri_string = str(uri_string).strip() if uri_string[:1] == "<" and uri_string[len(uri_string)-1:] == ">": uri_string = uri_string[1:len(uri_string)-1] return uri_string
python
def clean_iri(uri_string): '''removes the <> signs from a string start and end''' uri_string = str(uri_string).strip() if uri_string[:1] == "<" and uri_string[len(uri_string)-1:] == ">": uri_string = uri_string[1:len(uri_string)-1] return uri_string
[ "def", "clean_iri", "(", "uri_string", ")", ":", "uri_string", "=", "str", "(", "uri_string", ")", ".", "strip", "(", ")", "if", "uri_string", "[", ":", "1", "]", "==", "\"<\"", "and", "uri_string", "[", "len", "(", "uri_string", ")", "-", "1", ":", ...
removes the <> signs from a string start and end
[ "removes", "the", "<", ">", "signs", "from", "a", "string", "start", "and", "end" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L790-L795
KnowledgeLinks/rdfframework
rdfframework/utilities/baseutilities.py
RegistryDictionary.find
def find(self, value): """ returns a dictionary of items based on the a lowercase search args: value: the value to search by """ value = str(value).lower() rtn_dict = RegistryDictionary() for key, item in self.items(): if value in key.lowe...
python
def find(self, value): """ returns a dictionary of items based on the a lowercase search args: value: the value to search by """ value = str(value).lower() rtn_dict = RegistryDictionary() for key, item in self.items(): if value in key.lowe...
[ "def", "find", "(", "self", ",", "value", ")", ":", "value", "=", "str", "(", "value", ")", ".", "lower", "(", ")", "rtn_dict", "=", "RegistryDictionary", "(", ")", "for", "key", ",", "item", "in", "self", ".", "items", "(", ")", ":", "if", "valu...
returns a dictionary of items based on the a lowercase search args: value: the value to search by
[ "returns", "a", "dictionary", "of", "items", "based", "on", "the", "a", "lowercase", "search" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L89-L101
KnowledgeLinks/rdfframework
rdfframework/utilities/baseutilities.py
Dot.get
def get(self, prop): """ get the value off the passed in dot notation args: prop: a string of the property to retreive "a.b.c" ~ dictionary['a']['b']['c'] """ prop_parts = prop.split(".") val = None for part in prop_parts: if val i...
python
def get(self, prop): """ get the value off the passed in dot notation args: prop: a string of the property to retreive "a.b.c" ~ dictionary['a']['b']['c'] """ prop_parts = prop.split(".") val = None for part in prop_parts: if val i...
[ "def", "get", "(", "self", ",", "prop", ")", ":", "prop_parts", "=", "prop", ".", "split", "(", "\".\"", ")", "val", "=", "None", "for", "part", "in", "prop_parts", ":", "if", "val", "is", "None", ":", "val", "=", "self", ".", "obj", ".", "get", ...
get the value off the passed in dot notation args: prop: a string of the property to retreive "a.b.c" ~ dictionary['a']['b']['c']
[ "get", "the", "value", "off", "the", "passed", "in", "dot", "notation" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L365-L379
KnowledgeLinks/rdfframework
rdfframework/utilities/baseutilities.py
Dot.set
def set(self, prop, value): """ sets the dot notated property to the passed in value args: prop: a string of the property to retreive "a.b.c" ~ dictionary['a']['b']['c'] value: the value to set the prop object """ prop_parts = prop.split(".") ...
python
def set(self, prop, value): """ sets the dot notated property to the passed in value args: prop: a string of the property to retreive "a.b.c" ~ dictionary['a']['b']['c'] value: the value to set the prop object """ prop_parts = prop.split(".") ...
[ "def", "set", "(", "self", ",", "prop", ",", "value", ")", ":", "prop_parts", "=", "prop", ".", "split", "(", "\".\"", ")", "if", "self", ".", "copy_dict", ":", "new_dict", "=", "copy", ".", "deepcopy", "(", "self", ".", "obj", ")", "else", ":", ...
sets the dot notated property to the passed in value args: prop: a string of the property to retreive "a.b.c" ~ dictionary['a']['b']['c'] value: the value to set the prop object
[ "sets", "the", "dot", "notated", "property", "to", "the", "passed", "in", "value" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L381-L406
KnowledgeLinks/rdfframework
rdfframework/utilities/baseutilities.py
DictClass.dict
def dict(self): """ converts the class to a dictionary object """ return_obj = {} for attr in dir(self): if not attr.startswith('__') and attr not in self.__reserved: if isinstance(getattr(self, attr), list): return_val = [] for...
python
def dict(self): """ converts the class to a dictionary object """ return_obj = {} for attr in dir(self): if not attr.startswith('__') and attr not in self.__reserved: if isinstance(getattr(self, attr), list): return_val = [] for...
[ "def", "dict", "(", "self", ")", ":", "return_obj", "=", "{", "}", "for", "attr", "in", "dir", "(", "self", ")", ":", "if", "not", "attr", ".", "startswith", "(", "'__'", ")", "and", "attr", "not", "in", "self", ".", "__reserved", ":", "if", "isi...
converts the class to a dictionary object
[ "converts", "the", "class", "to", "a", "dictionary", "object" ]
train
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/utilities/baseutilities.py#L638-L662
alexhayes/django-toolkit
django_toolkit/markup/html.py
get_anchor_href
def get_anchor_href(markup): """ Given HTML markup, return a list of hrefs for each anchor tag. """ soup = BeautifulSoup(markup, 'lxml') return ['%s' % link.get('href') for link in soup.find_all('a')]
python
def get_anchor_href(markup): """ Given HTML markup, return a list of hrefs for each anchor tag. """ soup = BeautifulSoup(markup, 'lxml') return ['%s' % link.get('href') for link in soup.find_all('a')]
[ "def", "get_anchor_href", "(", "markup", ")", ":", "soup", "=", "BeautifulSoup", "(", "markup", ",", "'lxml'", ")", "return", "[", "'%s'", "%", "link", ".", "get", "(", "'href'", ")", "for", "link", "in", "soup", ".", "find_all", "(", "'a'", ")", "]"...
Given HTML markup, return a list of hrefs for each anchor tag.
[ "Given", "HTML", "markup", "return", "a", "list", "of", "hrefs", "for", "each", "anchor", "tag", "." ]
train
https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/markup/html.py#L3-L8
alexhayes/django-toolkit
django_toolkit/markup/html.py
get_anchor_contents
def get_anchor_contents(markup): """ Given HTML markup, return a list of href inner html for each anchor tag. """ soup = BeautifulSoup(markup, 'lxml') return ['%s' % link.contents[0] for link in soup.find_all('a')]
python
def get_anchor_contents(markup): """ Given HTML markup, return a list of href inner html for each anchor tag. """ soup = BeautifulSoup(markup, 'lxml') return ['%s' % link.contents[0] for link in soup.find_all('a')]
[ "def", "get_anchor_contents", "(", "markup", ")", ":", "soup", "=", "BeautifulSoup", "(", "markup", ",", "'lxml'", ")", "return", "[", "'%s'", "%", "link", ".", "contents", "[", "0", "]", "for", "link", "in", "soup", ".", "find_all", "(", "'a'", ")", ...
Given HTML markup, return a list of href inner html for each anchor tag.
[ "Given", "HTML", "markup", "return", "a", "list", "of", "href", "inner", "html", "for", "each", "anchor", "tag", "." ]
train
https://github.com/alexhayes/django-toolkit/blob/b64106392fad596defc915b8235fe6e1d0013b5b/django_toolkit/markup/html.py#L10-L15
abe-winter/pg13-py
pg13/weval.py
names_from_exp
def names_from_exp(exp): "Return a list of AttrX and NameX from the expression." def match(exp): return isinstance(exp, (sqparse2.NameX, sqparse2.AttrX)) paths = treepath.sub_slots(exp, match, match=True, recurse_into_matches=False) return [exp[path] for path in paths]
python
def names_from_exp(exp): "Return a list of AttrX and NameX from the expression." def match(exp): return isinstance(exp, (sqparse2.NameX, sqparse2.AttrX)) paths = treepath.sub_slots(exp, match, match=True, recurse_into_matches=False) return [exp[path] for path in paths]
[ "def", "names_from_exp", "(", "exp", ")", ":", "def", "match", "(", "exp", ")", ":", "return", "isinstance", "(", "exp", ",", "(", "sqparse2", ".", "NameX", ",", "sqparse2", ".", "AttrX", ")", ")", "paths", "=", "treepath", ".", "sub_slots", "(", "ex...
Return a list of AttrX and NameX from the expression.
[ "Return", "a", "list", "of", "AttrX", "and", "NameX", "from", "the", "expression", "." ]
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/weval.py#L31-L36
abe-winter/pg13-py
pg13/weval.py
classify_wherex
def classify_wherex(scope_, fromx, wherex): "helper for wherex_to_rowlist. returns [SingleTableCond,...], [CartesianCond,...]" exprs = [] for exp in fromx: if isinstance(exp, sqparse2.JoinX): # todo: probably just add exp.on_stmt as a CartesianCond. don't write this until tests are ready. # todo: ...
python
def classify_wherex(scope_, fromx, wherex): "helper for wherex_to_rowlist. returns [SingleTableCond,...], [CartesianCond,...]" exprs = [] for exp in fromx: if isinstance(exp, sqparse2.JoinX): # todo: probably just add exp.on_stmt as a CartesianCond. don't write this until tests are ready. # todo: ...
[ "def", "classify_wherex", "(", "scope_", ",", "fromx", ",", "wherex", ")", ":", "exprs", "=", "[", "]", "for", "exp", "in", "fromx", ":", "if", "isinstance", "(", "exp", ",", "sqparse2", ".", "JoinX", ")", ":", "# todo: probably just add exp.on_stmt as a Car...
helper for wherex_to_rowlist. returns [SingleTableCond,...], [CartesianCond,...]
[ "helper", "for", "wherex_to_rowlist", ".", "returns", "[", "SingleTableCond", "...", "]", "[", "CartesianCond", "...", "]" ]
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/weval.py#L38-L65
abe-winter/pg13-py
pg13/weval.py
table_to_rowlist
def table_to_rowlist(table_, conds): "helper for wherex_to_rowlist. (table.Table, [exp, ...]) -> [Row, ...]" if isinstance(table_, scope.SyntheticTable): raise NotImplementedError('todo: synthetic tables to Row[]') elif isinstance(table_, table.Table): rowtype = RowType([(colx.name, colx) for colx in tabl...
python
def table_to_rowlist(table_, conds): "helper for wherex_to_rowlist. (table.Table, [exp, ...]) -> [Row, ...]" if isinstance(table_, scope.SyntheticTable): raise NotImplementedError('todo: synthetic tables to Row[]') elif isinstance(table_, table.Table): rowtype = RowType([(colx.name, colx) for colx in tabl...
[ "def", "table_to_rowlist", "(", "table_", ",", "conds", ")", ":", "if", "isinstance", "(", "table_", ",", "scope", ".", "SyntheticTable", ")", ":", "raise", "NotImplementedError", "(", "'todo: synthetic tables to Row[]'", ")", "elif", "isinstance", "(", "table_", ...
helper for wherex_to_rowlist. (table.Table, [exp, ...]) -> [Row, ...]
[ "helper", "for", "wherex_to_rowlist", ".", "(", "table", ".", "Table", "[", "exp", "...", "]", ")", "-", ">", "[", "Row", "...", "]" ]
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/weval.py#L67-L79
abe-winter/pg13-py
pg13/weval.py
wherex_to_rowlist
def wherex_to_rowlist(scope_, fromx, wherex): """return a RowList with the rows included from scope by the fromx and wherex. When the scope has more than one name in it, the output will be a list of composite row (i.e. a row whose field types are themselves RowType). """ single, multi = classify_wherex(scop...
python
def wherex_to_rowlist(scope_, fromx, wherex): """return a RowList with the rows included from scope by the fromx and wherex. When the scope has more than one name in it, the output will be a list of composite row (i.e. a row whose field types are themselves RowType). """ single, multi = classify_wherex(scop...
[ "def", "wherex_to_rowlist", "(", "scope_", ",", "fromx", ",", "wherex", ")", ":", "single", ",", "multi", "=", "classify_wherex", "(", "scope_", ",", "fromx", ",", "wherex", ")", "single_rowlists", "=", "{", "tablename", ":", "table_to_rowlist", "(", "scope_...
return a RowList with the rows included from scope by the fromx and wherex. When the scope has more than one name in it, the output will be a list of composite row (i.e. a row whose field types are themselves RowType).
[ "return", "a", "RowList", "with", "the", "rows", "included", "from", "scope", "by", "the", "fromx", "and", "wherex", ".", "When", "the", "scope", "has", "more", "than", "one", "name", "in", "it", "the", "output", "will", "be", "a", "list", "of", "compo...
train
https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/weval.py#L81-L91
lizardsystem/tags2sdists
tags2sdists/packagedir.py
PackageDir.parse
def parse(self): """Iterate through the directory and extract package/version info.""" for package in os.listdir(self.root_directory): directory = os.path.join(self.root_directory, package) if not os.path.isdir(directory): continue dir_contents = os.li...
python
def parse(self): """Iterate through the directory and extract package/version info.""" for package in os.listdir(self.root_directory): directory = os.path.join(self.root_directory, package) if not os.path.isdir(directory): continue dir_contents = os.li...
[ "def", "parse", "(", "self", ")", ":", "for", "package", "in", "os", ".", "listdir", "(", "self", ".", "root_directory", ")", ":", "directory", "=", "os", ".", "path", ".", "join", "(", "self", ".", "root_directory", ",", "package", ")", "if", "not",...
Iterate through the directory and extract package/version info.
[ "Iterate", "through", "the", "directory", "and", "extract", "package", "/", "version", "info", "." ]
train
https://github.com/lizardsystem/tags2sdists/blob/72f3c664940133e3238fca4d87edcc36b9775e48/tags2sdists/packagedir.py#L22-L35
lizardsystem/tags2sdists
tags2sdists/packagedir.py
PackageDir.add_tarball
def add_tarball(self, tarball, package): """Add a tarball, possibly creating the directory if needed.""" if tarball is None: logger.error( "No tarball found for %s: probably a renamed project?", package) return target_dir = os.path.join(sel...
python
def add_tarball(self, tarball, package): """Add a tarball, possibly creating the directory if needed.""" if tarball is None: logger.error( "No tarball found for %s: probably a renamed project?", package) return target_dir = os.path.join(sel...
[ "def", "add_tarball", "(", "self", ",", "tarball", ",", "package", ")", ":", "if", "tarball", "is", "None", ":", "logger", ".", "error", "(", "\"No tarball found for %s: probably a renamed project?\"", ",", "package", ")", "return", "target_dir", "=", "os", ".",...
Add a tarball, possibly creating the directory if needed.
[ "Add", "a", "tarball", "possibly", "creating", "the", "directory", "if", "needed", "." ]
train
https://github.com/lizardsystem/tags2sdists/blob/72f3c664940133e3238fca4d87edcc36b9775e48/tags2sdists/packagedir.py#L37-L49
oubiwann/carapace
carapace/app/shell/pythonshell.py
CommandAPI.ls
def ls(self): """ List the objects in the current namespace, in alphabetical order. """ width = max([len(x) for x in self.namespace.keys()]) for key, value in sorted(self.namespace.items()): if key == "_": continue info = "" if ...
python
def ls(self): """ List the objects in the current namespace, in alphabetical order. """ width = max([len(x) for x in self.namespace.keys()]) for key, value in sorted(self.namespace.items()): if key == "_": continue info = "" if ...
[ "def", "ls", "(", "self", ")", ":", "width", "=", "max", "(", "[", "len", "(", "x", ")", "for", "x", "in", "self", ".", "namespace", ".", "keys", "(", ")", "]", ")", "for", "key", ",", "value", "in", "sorted", "(", "self", ".", "namespace", "...
List the objects in the current namespace, in alphabetical order.
[ "List", "the", "objects", "in", "the", "current", "namespace", "in", "alphabetical", "order", "." ]
train
https://github.com/oubiwann/carapace/blob/88470b12c198bea5067dcff1a26aa4400b73632c/carapace/app/shell/pythonshell.py#L51-L72
cogniteev/docido-python-sdk
docido_sdk/toolbox/text.py
to_unicode
def to_unicode(text, charset=None): """Convert input to an `unicode` object. For a `str` object, we'll first try to decode the bytes using the given `charset` encoding (or UTF-8 if none is specified), then we fall back to the latin1 encoding which might be correct or not, but at least preserves the...
python
def to_unicode(text, charset=None): """Convert input to an `unicode` object. For a `str` object, we'll first try to decode the bytes using the given `charset` encoding (or UTF-8 if none is specified), then we fall back to the latin1 encoding which might be correct or not, but at least preserves the...
[ "def", "to_unicode", "(", "text", ",", "charset", "=", "None", ")", ":", "if", "isinstance", "(", "text", ",", "str", ")", ":", "try", ":", "return", "unicode", "(", "text", ",", "charset", "or", "'utf-8'", ")", "except", "UnicodeDecodeError", ":", "re...
Convert input to an `unicode` object. For a `str` object, we'll first try to decode the bytes using the given `charset` encoding (or UTF-8 if none is specified), then we fall back to the latin1 encoding which might be correct or not, but at least preserves the original byte sequence by mapping each byt...
[ "Convert", "input", "to", "an", "unicode", "object", "." ]
train
https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/text.py#L4-L37
cogniteev/docido-python-sdk
docido_sdk/toolbox/text.py
exception_to_unicode
def exception_to_unicode(e, traceback=False): """Convert an `Exception` to an `unicode` object. In addition to `to_unicode`, this representation of the exception also contains the class name and optionally the traceback. """ message = '%s: %s' % (e.__class__.__name__, to_unicode(e)) if tracebac...
python
def exception_to_unicode(e, traceback=False): """Convert an `Exception` to an `unicode` object. In addition to `to_unicode`, this representation of the exception also contains the class name and optionally the traceback. """ message = '%s: %s' % (e.__class__.__name__, to_unicode(e)) if tracebac...
[ "def", "exception_to_unicode", "(", "e", ",", "traceback", "=", "False", ")", ":", "message", "=", "'%s: %s'", "%", "(", "e", ".", "__class__", ".", "__name__", ",", "to_unicode", "(", "e", ")", ")", "if", "traceback", ":", "from", "docido_sdk", ".", "...
Convert an `Exception` to an `unicode` object. In addition to `to_unicode`, this representation of the exception also contains the class name and optionally the traceback.
[ "Convert", "an", "Exception", "to", "an", "unicode", "object", "." ]
train
https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/text.py#L40-L51
cogniteev/docido-python-sdk
docido_sdk/toolbox/text.py
levenshtein
def levenshtein(s, t): """ Compute the Levenshtein distance between 2 strings, which is the minimum number of operations required to perform on a string to get another one. code taken from https://en.wikibooks.org :param basestring s: :param basestring t: :rtype: int """ ''' From W...
python
def levenshtein(s, t): """ Compute the Levenshtein distance between 2 strings, which is the minimum number of operations required to perform on a string to get another one. code taken from https://en.wikibooks.org :param basestring s: :param basestring t: :rtype: int """ ''' From W...
[ "def", "levenshtein", "(", "s", ",", "t", ")", ":", "''' From Wikipedia article; Iterative with two matrix rows. '''", "if", "s", "==", "t", ":", "return", "0", "elif", "len", "(", "s", ")", "==", "0", ":", "return", "len", "(", "t", ")", "elif", "len", ...
Compute the Levenshtein distance between 2 strings, which is the minimum number of operations required to perform on a string to get another one. code taken from https://en.wikibooks.org :param basestring s: :param basestring t: :rtype: int
[ "Compute", "the", "Levenshtein", "distance", "between", "2", "strings", "which", "is", "the", "minimum", "number", "of", "operations", "required", "to", "perform", "on", "a", "string", "to", "get", "another", "one", "." ]
train
https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/text.py#L54-L84
etscrivner/nose-perfdump
perfdump/console.py
Console.precmd
def precmd(self, line): """Parse the command on the given line. :param line: The raw input line :type line: str """ line = line.lower() if line == 'exit' or line == 'help': return line try: parts = stmt.p...
python
def precmd(self, line): """Parse the command on the given line. :param line: The raw input line :type line: str """ line = line.lower() if line == 'exit' or line == 'help': return line try: parts = stmt.p...
[ "def", "precmd", "(", "self", ",", "line", ")", ":", "line", "=", "line", ".", "lower", "(", ")", "if", "line", "==", "'exit'", "or", "line", "==", "'help'", ":", "return", "line", "try", ":", "parts", "=", "stmt", ".", "parseString", "(", "line", ...
Parse the command on the given line. :param line: The raw input line :type line: str
[ "Parse", "the", "command", "on", "the", "given", "line", ".", ":", "param", "line", ":", "The", "raw", "input", "line", ":", "type", "line", ":", "str" ]
train
https://github.com/etscrivner/nose-perfdump/blob/a203a68495d30346fab43fb903cb60cd29b17d49/perfdump/console.py#L70-L92
etscrivner/nose-perfdump
perfdump/console.py
Console.do_help
def do_help(self, line): """Displays help information.""" print "" print "Perfdump CLI provides a handful of simple ways to query your" print "performance data." print "" print "The simplest queries are of the form:" print "" print "\t[slowest|fastest] [te...
python
def do_help(self, line): """Displays help information.""" print "" print "Perfdump CLI provides a handful of simple ways to query your" print "performance data." print "" print "The simplest queries are of the form:" print "" print "\t[slowest|fastest] [te...
[ "def", "do_help", "(", "self", ",", "line", ")", ":", "print", "\"\"", "print", "\"Perfdump CLI provides a handful of simple ways to query your\"", "print", "\"performance data.\"", "print", "\"\"", "print", "\"The simplest queries are of the form:\"", "print", "\"\"", "print...
Displays help information.
[ "Displays", "help", "information", "." ]
train
https://github.com/etscrivner/nose-perfdump/blob/a203a68495d30346fab43fb903cb60cd29b17d49/perfdump/console.py#L139-L162
Phasemix/phasetumblr
phasetumblr/phasetumblr.py
TumblrBlog.get_allposts
def get_allposts(self): ''' Return all posts in blog sorted by date ''' result = self.client.posts(self.blog, offset = 0, limit = 1) try: total_posts = result['total_posts'] except: raise phasetumblr_errors.TumblrBlogException(result['meta']['msg']) delta = (total_posts / 10) + 1 all_posts = [] ...
python
def get_allposts(self): ''' Return all posts in blog sorted by date ''' result = self.client.posts(self.blog, offset = 0, limit = 1) try: total_posts = result['total_posts'] except: raise phasetumblr_errors.TumblrBlogException(result['meta']['msg']) delta = (total_posts / 10) + 1 all_posts = [] ...
[ "def", "get_allposts", "(", "self", ")", ":", "result", "=", "self", ".", "client", ".", "posts", "(", "self", ".", "blog", ",", "offset", "=", "0", ",", "limit", "=", "1", ")", "try", ":", "total_posts", "=", "result", "[", "'total_posts'", "]", "...
Return all posts in blog sorted by date
[ "Return", "all", "posts", "in", "blog", "sorted", "by", "date" ]
train
https://github.com/Phasemix/phasetumblr/blob/1b699ac3fc6a903fc0a9bfdc9d1f76cb57f679f1/phasetumblr/phasetumblr.py#L24-L60
eddiejessup/metropack
metropack/pack.py
n_to_pf
def n_to_pf(L, n, R): """Returns the packing fraction for a number of non-intersecting spheres. Parameters ---------- L: float array, shape (d,) System lengths. n: integer Number of spheres. R: float Sphere radius. Returns ------- pf: float Fraction ...
python
def n_to_pf(L, n, R): """Returns the packing fraction for a number of non-intersecting spheres. Parameters ---------- L: float array, shape (d,) System lengths. n: integer Number of spheres. R: float Sphere radius. Returns ------- pf: float Fraction ...
[ "def", "n_to_pf", "(", "L", ",", "n", ",", "R", ")", ":", "dim", "=", "L", ".", "shape", "[", "0", "]", "return", "(", "n", "*", "sphere_volume", "(", "R", "=", "R", ",", "n", "=", "dim", ")", ")", "/", "np", ".", "product", "(", "L", ")"...
Returns the packing fraction for a number of non-intersecting spheres. Parameters ---------- L: float array, shape (d,) System lengths. n: integer Number of spheres. R: float Sphere radius. Returns ------- pf: float Fraction of space occupied by the sphe...
[ "Returns", "the", "packing", "fraction", "for", "a", "number", "of", "non", "-", "intersecting", "spheres", "." ]
train
https://github.com/eddiejessup/metropack/blob/528b47d0f2f70f39e1490e41433f2da8c8b9d63c/metropack/pack.py#L14-L32
eddiejessup/metropack
metropack/pack.py
pf_to_n
def pf_to_n(L, pf, R): """Returns the number of non-intersecting spheres required to achieve as close to a given packing fraction as possible, along with the actual achieved packing fraction. for a number of non-intersecting spheres. Parameters ---------- L: float array, shape (d,) Syst...
python
def pf_to_n(L, pf, R): """Returns the number of non-intersecting spheres required to achieve as close to a given packing fraction as possible, along with the actual achieved packing fraction. for a number of non-intersecting spheres. Parameters ---------- L: float array, shape (d,) Syst...
[ "def", "pf_to_n", "(", "L", ",", "pf", ",", "R", ")", ":", "dim", "=", "L", ".", "shape", "[", "0", "]", "n", "=", "int", "(", "round", "(", "pf", "*", "np", ".", "product", "(", "L", ")", "/", "sphere_volume", "(", "R", ",", "dim", ")", ...
Returns the number of non-intersecting spheres required to achieve as close to a given packing fraction as possible, along with the actual achieved packing fraction. for a number of non-intersecting spheres. Parameters ---------- L: float array, shape (d,) System lengths. pf: float ...
[ "Returns", "the", "number", "of", "non", "-", "intersecting", "spheres", "required", "to", "achieve", "as", "close", "to", "a", "given", "packing", "fraction", "as", "possible", "along", "with", "the", "actual", "achieved", "packing", "fraction", ".", "for", ...
train
https://github.com/eddiejessup/metropack/blob/528b47d0f2f70f39e1490e41433f2da8c8b9d63c/metropack/pack.py#L35-L60
eddiejessup/metropack
metropack/pack.py
pack_simple
def pack_simple(R, L, pf=None, n=None, rng=None, periodic=False): """Pack a number of non-intersecting spheres into a system. Can specify packing by number of spheres or packing fraction. This implementation uses a naive uniform distribution of spheres, and the Tabula Rasa rule (start from scratch if ...
python
def pack_simple(R, L, pf=None, n=None, rng=None, periodic=False): """Pack a number of non-intersecting spheres into a system. Can specify packing by number of spheres or packing fraction. This implementation uses a naive uniform distribution of spheres, and the Tabula Rasa rule (start from scratch if ...
[ "def", "pack_simple", "(", "R", ",", "L", ",", "pf", "=", "None", ",", "n", "=", "None", ",", "rng", "=", "None", ",", "periodic", "=", "False", ")", ":", "if", "rng", "is", "None", ":", "rng", "=", "np", ".", "random", "if", "pf", "is", "not...
Pack a number of non-intersecting spheres into a system. Can specify packing by number of spheres or packing fraction. This implementation uses a naive uniform distribution of spheres, and the Tabula Rasa rule (start from scratch if an intersection occurs). This is likely to be very slow for high pac...
[ "Pack", "a", "number", "of", "non", "-", "intersecting", "spheres", "into", "a", "system", "." ]
train
https://github.com/eddiejessup/metropack/blob/528b47d0f2f70f39e1490e41433f2da8c8b9d63c/metropack/pack.py#L85-L134
eddiejessup/metropack
metropack/pack.py
pack
def pack(R, L, pf=None, n=None, rng=None, periodic=False, beta_max=1e4, dL_max=0.02, dr_max=0.02): """Pack a number of non-intersecting spheres into a periodic system. Can specify packing by number of spheres or packing fraction. This implementation uses the Metropolis-Hastings algorithm for an ...
python
def pack(R, L, pf=None, n=None, rng=None, periodic=False, beta_max=1e4, dL_max=0.02, dr_max=0.02): """Pack a number of non-intersecting spheres into a periodic system. Can specify packing by number of spheres or packing fraction. This implementation uses the Metropolis-Hastings algorithm for an ...
[ "def", "pack", "(", "R", ",", "L", ",", "pf", "=", "None", ",", "n", "=", "None", ",", "rng", "=", "None", ",", "periodic", "=", "False", ",", "beta_max", "=", "1e4", ",", "dL_max", "=", "0.02", ",", "dr_max", "=", "0.02", ")", ":", "if", "pf...
Pack a number of non-intersecting spheres into a periodic system. Can specify packing by number of spheres or packing fraction. This implementation uses the Metropolis-Hastings algorithm for an NPT system. Parameters ---------- R: float Sphere radius. L: float array, shape (d,) ...
[ "Pack", "a", "number", "of", "non", "-", "intersecting", "spheres", "into", "a", "periodic", "system", "." ]
train
https://github.com/eddiejessup/metropack/blob/528b47d0f2f70f39e1490e41433f2da8c8b9d63c/metropack/pack.py#L137-L218
delfick/gitmit
gitmit/mit.py
GitTimes.relpath_for
def relpath_for(self, path): """Find the relative path from here from the parent_dir""" if self.parent_dir in (".", ""): return path if path == self.parent_dir: return "" dirname = os.path.dirname(path) or "." basename = os.path.basename(path) c...
python
def relpath_for(self, path): """Find the relative path from here from the parent_dir""" if self.parent_dir in (".", ""): return path if path == self.parent_dir: return "" dirname = os.path.dirname(path) or "." basename = os.path.basename(path) c...
[ "def", "relpath_for", "(", "self", ",", "path", ")", ":", "if", "self", ".", "parent_dir", "in", "(", "\".\"", ",", "\"\"", ")", ":", "return", "path", "if", "path", "==", "self", ".", "parent_dir", ":", "return", "\"\"", "dirname", "=", "os", ".", ...
Find the relative path from here from the parent_dir
[ "Find", "the", "relative", "path", "from", "here", "from", "the", "parent_dir" ]
train
https://github.com/delfick/gitmit/blob/ae0aef14a06b25ad2811f8f47cc97e68a0910eae/gitmit/mit.py#L57-L72
delfick/gitmit
gitmit/mit.py
GitTimes.find
def find(self): """ Find all the files we want to find commit times for, and any extra files under symlinks. Then find the commit times for those files and return a dictionary of {relative_path: commit_time_as_epoch} """ mtimes = {} git = Repo(self.root_...
python
def find(self): """ Find all the files we want to find commit times for, and any extra files under symlinks. Then find the commit times for those files and return a dictionary of {relative_path: commit_time_as_epoch} """ mtimes = {} git = Repo(self.root_...
[ "def", "find", "(", "self", ")", ":", "mtimes", "=", "{", "}", "git", "=", "Repo", "(", "self", ".", "root_folder", ")", "all_files", "=", "git", ".", "all_files", "(", ")", "use_files", "=", "set", "(", "self", ".", "find_files_for_use", "(", "all_f...
Find all the files we want to find commit times for, and any extra files under symlinks. Then find the commit times for those files and return a dictionary of {relative_path: commit_time_as_epoch}
[ "Find", "all", "the", "files", "we", "want", "to", "find", "commit", "times", "for", "and", "any", "extra", "files", "under", "symlinks", "." ]
train
https://github.com/delfick/gitmit/blob/ae0aef14a06b25ad2811f8f47cc97e68a0910eae/gitmit/mit.py#L74-L101
delfick/gitmit
gitmit/mit.py
GitTimes.commit_times_for
def commit_times_for(self, git, use_files): """ Return commit times for the use_files specified. We will use a cache of commit times if self.with_cache is Truthy. Finally, we yield (relpath: epoch) pairs where path is relative to self.parent_dir and epoch is the commit time in ...
python
def commit_times_for(self, git, use_files): """ Return commit times for the use_files specified. We will use a cache of commit times if self.with_cache is Truthy. Finally, we yield (relpath: epoch) pairs where path is relative to self.parent_dir and epoch is the commit time in ...
[ "def", "commit_times_for", "(", "self", ",", "git", ",", "use_files", ")", ":", "# Use real_relpath if it exists (SymlinkdPath) and default to just the path", "# This is because we _want_ to compare the commits to the _real paths_", "# As git only cares about the symlink itself, rather than ...
Return commit times for the use_files specified. We will use a cache of commit times if self.with_cache is Truthy. Finally, we yield (relpath: epoch) pairs where path is relative to self.parent_dir and epoch is the commit time in UTC for that path.
[ "Return", "commit", "times", "for", "the", "use_files", "specified", "." ]
train
https://github.com/delfick/gitmit/blob/ae0aef14a06b25ad2811f8f47cc97e68a0910eae/gitmit/mit.py#L103-L150
delfick/gitmit
gitmit/mit.py
GitTimes.extra_symlinked_files
def extra_symlinked_files(self, potential_symlinks): """ Find any symlinkd folders and yield SymlinkdPath objects for each file that is found under the symlink. """ for key in list(potential_symlinks): location = os.path.join(self.root_folder, key.path) re...
python
def extra_symlinked_files(self, potential_symlinks): """ Find any symlinkd folders and yield SymlinkdPath objects for each file that is found under the symlink. """ for key in list(potential_symlinks): location = os.path.join(self.root_folder, key.path) re...
[ "def", "extra_symlinked_files", "(", "self", ",", "potential_symlinks", ")", ":", "for", "key", "in", "list", "(", "potential_symlinks", ")", ":", "location", "=", "os", ".", "path", ".", "join", "(", "self", ".", "root_folder", ",", "key", ".", "path", ...
Find any symlinkd folders and yield SymlinkdPath objects for each file that is found under the symlink.
[ "Find", "any", "symlinkd", "folders", "and", "yield", "SymlinkdPath", "objects", "for", "each", "file", "that", "is", "found", "under", "the", "symlink", "." ]
train
https://github.com/delfick/gitmit/blob/ae0aef14a06b25ad2811f8f47cc97e68a0910eae/gitmit/mit.py#L152-L181
delfick/gitmit
gitmit/mit.py
GitTimes.find_files_for_use
def find_files_for_use(self, all_files): """ Given a list of all the files to consider, only yield Path objects for those we care about, given our filters """ for path in all_files: # Find the path relative to the parent dir relpath = self.relpath_for(path...
python
def find_files_for_use(self, all_files): """ Given a list of all the files to consider, only yield Path objects for those we care about, given our filters """ for path in all_files: # Find the path relative to the parent dir relpath = self.relpath_for(path...
[ "def", "find_files_for_use", "(", "self", ",", "all_files", ")", ":", "for", "path", "in", "all_files", ":", "# Find the path relative to the parent dir", "relpath", "=", "self", ".", "relpath_for", "(", "path", ")", "# Don't care about the ./", "if", "relpath", "."...
Given a list of all the files to consider, only yield Path objects for those we care about, given our filters
[ "Given", "a", "list", "of", "all", "the", "files", "to", "consider", "only", "yield", "Path", "objects", "for", "those", "we", "care", "about", "given", "our", "filters" ]
train
https://github.com/delfick/gitmit/blob/ae0aef14a06b25ad2811f8f47cc97e68a0910eae/gitmit/mit.py#L183-L198
delfick/gitmit
gitmit/mit.py
GitTimes.is_filtered
def is_filtered(self, relpath): """Say whether this relpath is filtered out""" # Only include files under the parent_dir if relpath.startswith("../"): return True # Ignore files that we don't want timestamps from if self.timestamps_for is not None and type(self.times...
python
def is_filtered(self, relpath): """Say whether this relpath is filtered out""" # Only include files under the parent_dir if relpath.startswith("../"): return True # Ignore files that we don't want timestamps from if self.timestamps_for is not None and type(self.times...
[ "def", "is_filtered", "(", "self", ",", "relpath", ")", ":", "# Only include files under the parent_dir", "if", "relpath", ".", "startswith", "(", "\"../\"", ")", ":", "return", "True", "# Ignore files that we don't want timestamps from", "if", "self", ".", "timestamps_...
Say whether this relpath is filtered out
[ "Say", "whether", "this", "relpath", "is", "filtered", "out" ]
train
https://github.com/delfick/gitmit/blob/ae0aef14a06b25ad2811f8f47cc97e68a0910eae/gitmit/mit.py#L200-L234
bertrandvidal/parse_this
parse_this/core.py
_get_args_and_defaults
def _get_args_and_defaults(args, defaults): """Return a list of 2-tuples - the argument name and its default value or a special value that indicates there is no default value. Args: args: list of argument name defaults: tuple of default values """ defaults = defaults or [] a...
python
def _get_args_and_defaults(args, defaults): """Return a list of 2-tuples - the argument name and its default value or a special value that indicates there is no default value. Args: args: list of argument name defaults: tuple of default values """ defaults = defaults or [] a...
[ "def", "_get_args_and_defaults", "(", "args", ",", "defaults", ")", ":", "defaults", "=", "defaults", "or", "[", "]", "args_and_defaults", "=", "[", "(", "argument", ",", "default", ")", "for", "(", "argument", ",", "default", ")", "in", "zip_longest", "("...
Return a list of 2-tuples - the argument name and its default value or a special value that indicates there is no default value. Args: args: list of argument name defaults: tuple of default values
[ "Return", "a", "list", "of", "2", "-", "tuples", "-", "the", "argument", "name", "and", "its", "default", "value", "or", "a", "special", "value", "that", "indicates", "there", "is", "no", "default", "value", "." ]
train
https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/core.py#L51-L63
bertrandvidal/parse_this
parse_this/core.py
_prepare_doc
def _prepare_doc(func, args, delimiter_chars): """From the function docstring get the arg parse description and arguments help message. If there is no docstring simple description and help message are created. Args: func: the function that needs argument parsing args: name of th...
python
def _prepare_doc(func, args, delimiter_chars): """From the function docstring get the arg parse description and arguments help message. If there is no docstring simple description and help message are created. Args: func: the function that needs argument parsing args: name of th...
[ "def", "_prepare_doc", "(", "func", ",", "args", ",", "delimiter_chars", ")", ":", "_LOG", ".", "debug", "(", "\"Preparing doc for '%s'\"", ",", "func", ".", "__name__", ")", "if", "not", "func", ".", "__doc__", ":", "return", "_get_default_help_message", "(",...
From the function docstring get the arg parse description and arguments help message. If there is no docstring simple description and help message are created. Args: func: the function that needs argument parsing args: name of the function arguments delimiter_chars: characte...
[ "From", "the", "function", "docstring", "get", "the", "arg", "parse", "description", "and", "arguments", "help", "message", ".", "If", "there", "is", "no", "docstring", "simple", "description", "and", "help", "message", "are", "created", "." ]
train
https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/core.py#L66-L115
bertrandvidal/parse_this
parse_this/core.py
_get_parseable_methods
def _get_parseable_methods(cls): """Return all methods of cls that are parseable i.e. have been decorated by '@create_parser'. Args: cls: the class currently being decorated Note: classmethods will not be included as they can only be referenced once the class has been defined ...
python
def _get_parseable_methods(cls): """Return all methods of cls that are parseable i.e. have been decorated by '@create_parser'. Args: cls: the class currently being decorated Note: classmethods will not be included as they can only be referenced once the class has been defined ...
[ "def", "_get_parseable_methods", "(", "cls", ")", ":", "_LOG", ".", "debug", "(", "\"Retrieving parseable methods for '%s'\"", ",", "cls", ".", "__name__", ")", "init_parser", "=", "None", "methods_to_parse", "=", "{", "}", "for", "name", ",", "obj", "in", "va...
Return all methods of cls that are parseable i.e. have been decorated by '@create_parser'. Args: cls: the class currently being decorated Note: classmethods will not be included as they can only be referenced once the class has been defined Returns: a 2-tuple with the p...
[ "Return", "all", "methods", "of", "cls", "that", "are", "parseable", "i", ".", "e", ".", "have", "been", "decorated", "by", "@create_parser", "." ]
train
https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/core.py#L118-L148
bertrandvidal/parse_this
parse_this/core.py
_get_default_help_message
def _get_default_help_message(func, args, description=None, args_help=None): """Create a default description for the parser and help message for the agurments if they are missing. Args: func: the method we are creating a parser for args: the argument names of the method description:...
python
def _get_default_help_message(func, args, description=None, args_help=None): """Create a default description for the parser and help message for the agurments if they are missing. Args: func: the method we are creating a parser for args: the argument names of the method description:...
[ "def", "_get_default_help_message", "(", "func", ",", "args", ",", "description", "=", "None", ",", "args_help", "=", "None", ")", ":", "if", "description", "is", "None", ":", "description", "=", "\"Argument parsing for %s\"", "%", "func", ".", "__name__", "ar...
Create a default description for the parser and help message for the agurments if they are missing. Args: func: the method we are creating a parser for args: the argument names of the method description: a potentially existing description created from the function docstring ...
[ "Create", "a", "default", "description", "for", "the", "parser", "and", "help", "message", "for", "the", "agurments", "if", "they", "are", "missing", "." ]
train
https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/core.py#L151-L172
bertrandvidal/parse_this
parse_this/core.py
_get_arg_parser
def _get_arg_parser(func, types, args_and_defaults, delimiter_chars): """Return an ArgumentParser for the given function. Arguments are defined from the function arguments and their associated defaults. Args: func: function for which we want an ArgumentParser types: types to which the c...
python
def _get_arg_parser(func, types, args_and_defaults, delimiter_chars): """Return an ArgumentParser for the given function. Arguments are defined from the function arguments and their associated defaults. Args: func: function for which we want an ArgumentParser types: types to which the c...
[ "def", "_get_arg_parser", "(", "func", ",", "types", ",", "args_and_defaults", ",", "delimiter_chars", ")", ":", "_LOG", ".", "debug", "(", "\"Creating ArgumentParser for '%s'\"", ",", "func", ".", "__name__", ")", "(", "description", ",", "arg_help", ")", "=", ...
Return an ArgumentParser for the given function. Arguments are defined from the function arguments and their associated defaults. Args: func: function for which we want an ArgumentParser types: types to which the command line arguments should be converted to args_and_defaults: list ...
[ "Return", "an", "ArgumentParser", "for", "the", "given", "function", ".", "Arguments", "are", "defined", "from", "the", "function", "arguments", "and", "their", "associated", "defaults", "." ]
train
https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/core.py#L175-L221
bertrandvidal/parse_this
parse_this/core.py
_get_args_to_parse
def _get_args_to_parse(args, sys_argv): """Return the given arguments if it is not None else sys.argv if it contains something, an empty list otherwise. Args: args: argument to be parsed sys_argv: arguments of the command line i.e. sys.argv """ arguments = args if args is not No...
python
def _get_args_to_parse(args, sys_argv): """Return the given arguments if it is not None else sys.argv if it contains something, an empty list otherwise. Args: args: argument to be parsed sys_argv: arguments of the command line i.e. sys.argv """ arguments = args if args is not No...
[ "def", "_get_args_to_parse", "(", "args", ",", "sys_argv", ")", ":", "arguments", "=", "args", "if", "args", "is", "not", "None", "else", "sys_argv", "[", "1", ":", "]", "_LOG", ".", "debug", "(", "\"Parsing arguments: %s\"", ",", "arguments", ")", "return...
Return the given arguments if it is not None else sys.argv if it contains something, an empty list otherwise. Args: args: argument to be parsed sys_argv: arguments of the command line i.e. sys.argv
[ "Return", "the", "given", "arguments", "if", "it", "is", "not", "None", "else", "sys", ".", "argv", "if", "it", "contains", "something", "an", "empty", "list", "otherwise", "." ]
train
https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/core.py#L224-L234
bertrandvidal/parse_this
parse_this/core.py
_check_types
def _check_types(func_name, types, func_args, defaults): """Make sure that enough types were given to ensure conversion. Also remove potential Self/Class arguments. Args: func_name: name of the decorated function types: a list of Python types to which the argument will be converted ...
python
def _check_types(func_name, types, func_args, defaults): """Make sure that enough types were given to ensure conversion. Also remove potential Self/Class arguments. Args: func_name: name of the decorated function types: a list of Python types to which the argument will be converted ...
[ "def", "_check_types", "(", "func_name", ",", "types", ",", "func_args", ",", "defaults", ")", ":", "defaults", "=", "defaults", "or", "[", "]", "if", "len", "(", "types", ")", ">", "len", "(", "func_args", ")", ":", "raise", "ParseThisError", "(", "\"...
Make sure that enough types were given to ensure conversion. Also remove potential Self/Class arguments. Args: func_name: name of the decorated function types: a list of Python types to which the argument will be converted func_args: list of function arguments name defaults: ...
[ "Make", "sure", "that", "enough", "types", "were", "given", "to", "ensure", "conversion", ".", "Also", "remove", "potential", "Self", "/", "Class", "arguments", "." ]
train
https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/core.py#L237-L261
bertrandvidal/parse_this
parse_this/core.py
_get_parser_call_method
def _get_parser_call_method(func): """Returns the method that is linked to the 'call' method of the parser Args: func: the decorated function Raises: ParseThisError if the decorated method is __init__, __init__ can only be decorated in a class decorated by parse_class """ f...
python
def _get_parser_call_method(func): """Returns the method that is linked to the 'call' method of the parser Args: func: the decorated function Raises: ParseThisError if the decorated method is __init__, __init__ can only be decorated in a class decorated by parse_class """ f...
[ "def", "_get_parser_call_method", "(", "func", ")", ":", "func_name", "=", "func", ".", "__name__", "parser", "=", "func", ".", "parser", "def", "inner_call", "(", "instance", "=", "None", ",", "args", "=", "None", ")", ":", "\"\"\"This is method attached to <...
Returns the method that is linked to the 'call' method of the parser Args: func: the decorated function Raises: ParseThisError if the decorated method is __init__, __init__ can only be decorated in a class decorated by parse_class
[ "Returns", "the", "method", "that", "is", "linked", "to", "the", "call", "method", "of", "the", "parser" ]
train
https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/core.py#L264-L299
bertrandvidal/parse_this
parse_this/core.py
_get_args_name_from_parser
def _get_args_name_from_parser(parser): """Retrieve the name of the function argument linked to the given parser. Args: parser: a function parser """ # Retrieve the 'action' destination of the method parser i.e. its # argument name. The HelpAction is ignored. return [action.dest for act...
python
def _get_args_name_from_parser(parser): """Retrieve the name of the function argument linked to the given parser. Args: parser: a function parser """ # Retrieve the 'action' destination of the method parser i.e. its # argument name. The HelpAction is ignored. return [action.dest for act...
[ "def", "_get_args_name_from_parser", "(", "parser", ")", ":", "# Retrieve the 'action' destination of the method parser i.e. its", "# argument name. The HelpAction is ignored.", "return", "[", "action", ".", "dest", "for", "action", "in", "parser", ".", "_actions", "if", "not...
Retrieve the name of the function argument linked to the given parser. Args: parser: a function parser
[ "Retrieve", "the", "name", "of", "the", "function", "argument", "linked", "to", "the", "given", "parser", "." ]
train
https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/core.py#L302-L311
bertrandvidal/parse_this
parse_this/core.py
_call
def _call(callable_obj, arg_names, namespace): """Actually calls the callable with the namespace parsed from the command line. Args: callable_obj: a callable object arg_names: name of the function arguments namespace: the namespace object parsed from the command line """ arg...
python
def _call(callable_obj, arg_names, namespace): """Actually calls the callable with the namespace parsed from the command line. Args: callable_obj: a callable object arg_names: name of the function arguments namespace: the namespace object parsed from the command line """ arg...
[ "def", "_call", "(", "callable_obj", ",", "arg_names", ",", "namespace", ")", ":", "arguments", "=", "{", "arg_name", ":", "getattr", "(", "namespace", ",", "arg_name", ")", "for", "arg_name", "in", "arg_names", "}", "return", "callable_obj", "(", "*", "*"...
Actually calls the callable with the namespace parsed from the command line. Args: callable_obj: a callable object arg_names: name of the function arguments namespace: the namespace object parsed from the command line
[ "Actually", "calls", "the", "callable", "with", "the", "namespace", "parsed", "from", "the", "command", "line", "." ]
train
https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/core.py#L314-L325
bertrandvidal/parse_this
parse_this/core.py
_call_method_from_namespace
def _call_method_from_namespace(obj, method_name, namespace): """Call the method, retrieved from obj, with the correct arguments via the namespace Args: obj: any kind of object method_name: method to be called namespace: an argparse.Namespace object containing parsed command ...
python
def _call_method_from_namespace(obj, method_name, namespace): """Call the method, retrieved from obj, with the correct arguments via the namespace Args: obj: any kind of object method_name: method to be called namespace: an argparse.Namespace object containing parsed command ...
[ "def", "_call_method_from_namespace", "(", "obj", ",", "method_name", ",", "namespace", ")", ":", "method", "=", "getattr", "(", "obj", ",", "method_name", ")", "method_parser", "=", "method", ".", "parser", "arg_names", "=", "_get_args_name_from_parser", "(", "...
Call the method, retrieved from obj, with the correct arguments via the namespace Args: obj: any kind of object method_name: method to be called namespace: an argparse.Namespace object containing parsed command line arguments
[ "Call", "the", "method", "retrieved", "from", "obj", "with", "the", "correct", "arguments", "via", "the", "namespace" ]
train
https://github.com/bertrandvidal/parse_this/blob/aa2e3737f19642300ef1ca65cae21c90049718a2/parse_this/core.py#L328-L343
jtpaasch/simplygithub
simplygithub/internals/api.py
get_url
def get_url(profile, resource): """Get the URL for a resource. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. resource ...
python
def get_url(profile, resource): """Get the URL for a resource. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. resource ...
[ "def", "get_url", "(", "profile", ",", "resource", ")", ":", "repo", "=", "profile", "[", "\"repo\"", "]", "url", "=", "GITHUB_API_BASE_URL", "+", "\"repos/\"", "+", "repo", "+", "\"/git\"", "+", "resource", "return", "url" ]
Get the URL for a resource. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. resource The part of a Github API URL ...
[ "Get", "the", "URL", "for", "a", "resource", "." ]
train
https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/api.py#L23-L43
jtpaasch/simplygithub
simplygithub/internals/api.py
post_merge_request
def post_merge_request(profile, payload): """Do a POST request to Github's API to merge. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect ...
python
def post_merge_request(profile, payload): """Do a POST request to Github's API to merge. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect ...
[ "def", "post_merge_request", "(", "profile", ",", "payload", ")", ":", "repo", "=", "profile", "[", "\"repo\"", "]", "url", "=", "GITHUB_API_BASE_URL", "+", "\"repos/\"", "+", "repo", "+", "\"/merges\"", "headers", "=", "get_headers", "(", "profile", ")", "r...
Do a POST request to Github's API to merge. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. payload A dict of info...
[ "Do", "a", "POST", "request", "to", "Github", "s", "API", "to", "merge", "." ]
train
https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/api.py#L46-L71
jtpaasch/simplygithub
simplygithub/internals/api.py
get_request
def get_request(profile, resource): """Do a GET request to Github's API. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. r...
python
def get_request(profile, resource): """Do a GET request to Github's API. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. r...
[ "def", "get_request", "(", "profile", ",", "resource", ")", ":", "url", "=", "get_url", "(", "profile", ",", "resource", ")", "headers", "=", "get_headers", "(", "profile", ")", "response", "=", "requests", ".", "get", "(", "url", ",", "headers", "=", ...
Do a GET request to Github's API. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. resource The part of a Github AP...
[ "Do", "a", "GET", "request", "to", "Github", "s", "API", "." ]
train
https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/api.py#L95-L116
jtpaasch/simplygithub
simplygithub/internals/api.py
post_request
def post_request(profile, resource, payload): """Do a POST request to Github's API. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with....
python
def post_request(profile, resource, payload): """Do a POST request to Github's API. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with....
[ "def", "post_request", "(", "profile", ",", "resource", ",", "payload", ")", ":", "url", "=", "get_url", "(", "profile", ",", "resource", ")", "headers", "=", "get_headers", "(", "profile", ")", "response", "=", "requests", ".", "post", "(", "url", ",", ...
Do a POST request to Github's API. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. resource The part of a Github A...
[ "Do", "a", "POST", "request", "to", "Github", "s", "API", "." ]
train
https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/api.py#L119-L144
jtpaasch/simplygithub
simplygithub/internals/api.py
delete_request
def delete_request(profile, resource): """Do a DELETE request to Github's API. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. ...
python
def delete_request(profile, resource): """Do a DELETE request to Github's API. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. ...
[ "def", "delete_request", "(", "profile", ",", "resource", ")", ":", "url", "=", "get_url", "(", "profile", ",", "resource", ")", "headers", "=", "get_headers", "(", "profile", ")", "return", "requests", ".", "delete", "(", "url", ",", "headers", "=", "he...
Do a DELETE request to Github's API. Args: profile A profile generated from ``simplygithub.authentication.profile``. Such profiles tell this module (i) the ``repo`` to connect to, and (ii) the ``token`` to connect with. resource The part of a Github...
[ "Do", "a", "DELETE", "request", "to", "Github", "s", "API", "." ]
train
https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/api.py#L175-L196
lehins/python-wepay
wepay/calls/oauth2.py
OAuth2.authorize
def authorize(self, client_id, redirect_uri, scope, state=None, user_name=None, user_email=None): """Documentation: `/oauth2/authorize <https://www.wepay.com/developer/reference/oauth2#authorize>`_. .. note:: This is not an API call but an actual uri that you ...
python
def authorize(self, client_id, redirect_uri, scope, state=None, user_name=None, user_email=None): """Documentation: `/oauth2/authorize <https://www.wepay.com/developer/reference/oauth2#authorize>`_. .. note:: This is not an API call but an actual uri that you ...
[ "def", "authorize", "(", "self", ",", "client_id", ",", "redirect_uri", ",", "scope", ",", "state", "=", "None", ",", "user_name", "=", "None", ",", "user_email", "=", "None", ")", ":", "query", "=", "[", "(", "'client_id'", ",", "client_id", ")", ",",...
Documentation: `/oauth2/authorize <https://www.wepay.com/developer/reference/oauth2#authorize>`_. .. note:: This is not an API call but an actual uri that you send the user to.
[ "Documentation", ":", "/", "oauth2", "/", "authorize", "<https", ":", "//", "www", ".", "wepay", ".", "com", "/", "developer", "/", "reference", "/", "oauth2#authorize", ">", "_", "." ]
train
https://github.com/lehins/python-wepay/blob/414d25a1a8d0ecb22a3ddd1f16c60b805bb52a1f/wepay/calls/oauth2.py#L9-L31
lehins/python-wepay
wepay/calls/oauth2.py
OAuth2.__token
def __token(self, client_id, redirect_uri, client_secret, code, **kwargs): """Call documentation: `/oauth2/token <https://www.wepay.com/developer/reference/oauth2#token>`_, plus extra keyword parameter: :keyword bool batch_mode: turn on/off the batch_mode, see :class...
python
def __token(self, client_id, redirect_uri, client_secret, code, **kwargs): """Call documentation: `/oauth2/token <https://www.wepay.com/developer/reference/oauth2#token>`_, plus extra keyword parameter: :keyword bool batch_mode: turn on/off the batch_mode, see :class...
[ "def", "__token", "(", "self", ",", "client_id", ",", "redirect_uri", ",", "client_secret", ",", "code", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "'client_id'", ":", "client_id", ",", "'redirect_uri'", ":", "redirect_uri", ",", "'client_secret'...
Call documentation: `/oauth2/token <https://www.wepay.com/developer/reference/oauth2#token>`_, plus extra keyword parameter: :keyword bool batch_mode: turn on/off the batch_mode, see :class:`wepay.api.WePay` :keyword str batch_reference_id: `reference_id` param for ...
[ "Call", "documentation", ":", "/", "oauth2", "/", "token", "<https", ":", "//", "www", ".", "wepay", ".", "com", "/", "developer", "/", "reference", "/", "oauth2#token", ">", "_", "plus", "extra", "keyword", "parameter", ":", ":", "keyword", "bool", "bat...
train
https://github.com/lehins/python-wepay/blob/414d25a1a8d0ecb22a3ddd1f16c60b805bb52a1f/wepay/calls/oauth2.py#L33-L54
koheimiya/extheano
extheano/nodebuffer.py
NodeBuffer._extract_updater
def _extract_updater(self): """ Get the update and reset the buffer. Return `None` if there is no update. """ if self._node is self._buffer: return None else: updater = (self._node, self._buffer) self._buffer = self._node return updater
python
def _extract_updater(self): """ Get the update and reset the buffer. Return `None` if there is no update. """ if self._node is self._buffer: return None else: updater = (self._node, self._buffer) self._buffer = self._node return updater
[ "def", "_extract_updater", "(", "self", ")", ":", "if", "self", ".", "_node", "is", "self", ".", "_buffer", ":", "return", "None", "else", ":", "updater", "=", "(", "self", ".", "_node", ",", "self", ".", "_buffer", ")", "self", ".", "_buffer", "=", ...
Get the update and reset the buffer. Return `None` if there is no update.
[ "Get", "the", "update", "and", "reset", "the", "buffer", ".", "Return", "None", "if", "there", "is", "no", "update", "." ]
train
https://github.com/koheimiya/extheano/blob/ea099a6395ca8772660b2c715fb26cde12738181/extheano/nodebuffer.py#L32-L40
hmartiniano/faz
faz/graph.py
DependencyGraph._build_graph
def _build_graph(self): """ Produce a dependency graph based on a list of tasks produced by the parser. """ self._graph.add_nodes_from(self.tasks) for node1 in self._graph.nodes: for node2 in self._graph.nodes: for input_file in node1.inputs: ...
python
def _build_graph(self): """ Produce a dependency graph based on a list of tasks produced by the parser. """ self._graph.add_nodes_from(self.tasks) for node1 in self._graph.nodes: for node2 in self._graph.nodes: for input_file in node1.inputs: ...
[ "def", "_build_graph", "(", "self", ")", ":", "self", ".", "_graph", ".", "add_nodes_from", "(", "self", ".", "tasks", ")", "for", "node1", "in", "self", ".", "_graph", ".", "nodes", ":", "for", "node2", "in", "self", ".", "_graph", ".", "nodes", ":"...
Produce a dependency graph based on a list of tasks produced by the parser.
[ "Produce", "a", "dependency", "graph", "based", "on", "a", "list", "of", "tasks", "produced", "by", "the", "parser", "." ]
train
https://github.com/hmartiniano/faz/blob/36a58c45e8c0718d38cb3c533542c8743e7e7a65/faz/graph.py#L48-L61
miquelo/resort
packages/resort/component/maven.py
Project.insert
def insert(self, context): """ Build the project. :param resort.engine.execution.Context context: Current execution context. """ if self.__dependency: self.__execute(context, "install") else: self.__execute(context, "package")
python
def insert(self, context): """ Build the project. :param resort.engine.execution.Context context: Current execution context. """ if self.__dependency: self.__execute(context, "install") else: self.__execute(context, "package")
[ "def", "insert", "(", "self", ",", "context", ")", ":", "if", "self", ".", "__dependency", ":", "self", ".", "__execute", "(", "context", ",", "\"install\"", ")", "else", ":", "self", ".", "__execute", "(", "context", ",", "\"package\"", ")" ]
Build the project. :param resort.engine.execution.Context context: Current execution context.
[ "Build", "the", "project", ".", ":", "param", "resort", ".", "engine", ".", "execution", ".", "Context", "context", ":", "Current", "execution", "context", "." ]
train
https://github.com/miquelo/resort/blob/097a25d3257c91a75c194fd44c2797ab356f85dd/packages/resort/component/maven.py#L66-L78
blubberdiblub/eztemplate
eztemplate/engines/string_formatter_engine.py
FormatterWrapper.get_value
def get_value(self, key, args, kwargs): """Get value only from mapping and possibly convert key to string.""" if (self.tolerant and not isinstance(key, basestring) and key not in kwargs): key = str(key) return kwargs[key]
python
def get_value(self, key, args, kwargs): """Get value only from mapping and possibly convert key to string.""" if (self.tolerant and not isinstance(key, basestring) and key not in kwargs): key = str(key) return kwargs[key]
[ "def", "get_value", "(", "self", ",", "key", ",", "args", ",", "kwargs", ")", ":", "if", "(", "self", ".", "tolerant", "and", "not", "isinstance", "(", "key", ",", "basestring", ")", "and", "key", "not", "in", "kwargs", ")", ":", "key", "=", "str",...
Get value only from mapping and possibly convert key to string.
[ "Get", "value", "only", "from", "mapping", "and", "possibly", "convert", "key", "to", "string", "." ]
train
https://github.com/blubberdiblub/eztemplate/blob/ab5b2b4987c045116d130fd83e216704b8edfb5d/eztemplate/engines/string_formatter_engine.py#L49-L56
blubberdiblub/eztemplate
eztemplate/engines/string_formatter_engine.py
FormatterWrapper.get_field
def get_field(self, field_name, args, kwargs): """Create a special value when field missing and tolerant.""" try: obj, arg_used = super(FormatterWrapper, self).get_field( field_name, args, kwargs) except (KeyError, IndexError, AttributeError): if not s...
python
def get_field(self, field_name, args, kwargs): """Create a special value when field missing and tolerant.""" try: obj, arg_used = super(FormatterWrapper, self).get_field( field_name, args, kwargs) except (KeyError, IndexError, AttributeError): if not s...
[ "def", "get_field", "(", "self", ",", "field_name", ",", "args", ",", "kwargs", ")", ":", "try", ":", "obj", ",", "arg_used", "=", "super", "(", "FormatterWrapper", ",", "self", ")", ".", "get_field", "(", "field_name", ",", "args", ",", "kwargs", ")",...
Create a special value when field missing and tolerant.
[ "Create", "a", "special", "value", "when", "field", "missing", "and", "tolerant", "." ]
train
https://github.com/blubberdiblub/eztemplate/blob/ab5b2b4987c045116d130fd83e216704b8edfb5d/eztemplate/engines/string_formatter_engine.py#L58-L70
blubberdiblub/eztemplate
eztemplate/engines/string_formatter_engine.py
FormatterWrapper.convert_field
def convert_field(self, value, conversion): """When field missing, store conversion specifier.""" if isinstance(value, MissingField): if conversion is not None: value.conversion = conversion return value return super(FormatterWrapper, self).convert_field(...
python
def convert_field(self, value, conversion): """When field missing, store conversion specifier.""" if isinstance(value, MissingField): if conversion is not None: value.conversion = conversion return value return super(FormatterWrapper, self).convert_field(...
[ "def", "convert_field", "(", "self", ",", "value", ",", "conversion", ")", ":", "if", "isinstance", "(", "value", ",", "MissingField", ")", ":", "if", "conversion", "is", "not", "None", ":", "value", ".", "conversion", "=", "conversion", "return", "value",...
When field missing, store conversion specifier.
[ "When", "field", "missing", "store", "conversion", "specifier", "." ]
train
https://github.com/blubberdiblub/eztemplate/blob/ab5b2b4987c045116d130fd83e216704b8edfb5d/eztemplate/engines/string_formatter_engine.py#L72-L79
blubberdiblub/eztemplate
eztemplate/engines/string_formatter_engine.py
FormatterWrapper.format_field
def format_field(self, value, format_spec): """When field missing, return original spec.""" if isinstance(value, MissingField): if format_spec is not None: value.format_spec = format_spec return str(value) return super(FormatterWrapper, self).format_field...
python
def format_field(self, value, format_spec): """When field missing, return original spec.""" if isinstance(value, MissingField): if format_spec is not None: value.format_spec = format_spec return str(value) return super(FormatterWrapper, self).format_field...
[ "def", "format_field", "(", "self", ",", "value", ",", "format_spec", ")", ":", "if", "isinstance", "(", "value", ",", "MissingField", ")", ":", "if", "format_spec", "is", "not", "None", ":", "value", ".", "format_spec", "=", "format_spec", "return", "str"...
When field missing, return original spec.
[ "When", "field", "missing", "return", "original", "spec", "." ]
train
https://github.com/blubberdiblub/eztemplate/blob/ab5b2b4987c045116d130fd83e216704b8edfb5d/eztemplate/engines/string_formatter_engine.py#L81-L88
swans-one/django-kittens
settings.py
configure_settings
def configure_settings(): """ Configures settings for manage.py and for run_tests.py. """ if not settings.configured: db_config = { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'django_kittens_db.sqlite3', } settings.configure( TEST_RUNNER=...
python
def configure_settings(): """ Configures settings for manage.py and for run_tests.py. """ if not settings.configured: db_config = { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'django_kittens_db.sqlite3', } settings.configure( TEST_RUNNER=...
[ "def", "configure_settings", "(", ")", ":", "if", "not", "settings", ".", "configured", ":", "db_config", "=", "{", "'ENGINE'", ":", "'django.db.backends.sqlite3'", ",", "'NAME'", ":", "'django_kittens_db.sqlite3'", ",", "}", "settings", ".", "configure", "(", "...
Configures settings for manage.py and for run_tests.py.
[ "Configures", "settings", "for", "manage", ".", "py", "and", "for", "run_tests", ".", "py", "." ]
train
https://github.com/swans-one/django-kittens/blob/31e1ff54737c8ba3e99880dbff285a730ddac851/settings.py#L6-L33
sci-bots/mpm
mpm/ui/gtk/__init__.py
update_plugin_dialog
def update_plugin_dialog(package_name=None, update_args=None, update_kwargs=None, ignore_not_installed=True): ''' Launch dialog to track status of update of specified plugin package. .. versionadded:: 0.19 .. versionchanged:: 0.20 Add support for updating multiple pack...
python
def update_plugin_dialog(package_name=None, update_args=None, update_kwargs=None, ignore_not_installed=True): ''' Launch dialog to track status of update of specified plugin package. .. versionadded:: 0.19 .. versionchanged:: 0.20 Add support for updating multiple pack...
[ "def", "update_plugin_dialog", "(", "package_name", "=", "None", ",", "update_args", "=", "None", ",", "update_kwargs", "=", "None", ",", "ignore_not_installed", "=", "True", ")", ":", "thread_context", "=", "{", "}", "if", "package_name", "is", "None", ":", ...
Launch dialog to track status of update of specified plugin package. .. versionadded:: 0.19 .. versionchanged:: 0.20 Add support for updating multiple packages (update all **installed** plugins by default). Add :data:`update_args` and :data:`update_kwargs` arguments. .. versionch...
[ "Launch", "dialog", "to", "track", "status", "of", "update", "of", "specified", "plugin", "package", "." ]
train
https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/ui/gtk/__init__.py#L21-L277
emencia/emencia-django-forum
forum/models.py
Category.get_last_thread
def get_last_thread(self): """ Return the last modified thread """ cache_key = '_get_last_thread_cache' if not hasattr(self, cache_key): item = None res = self.thread_set.filter(visible=True).order_by('-modified')[0:1] if len(res)>0: ...
python
def get_last_thread(self): """ Return the last modified thread """ cache_key = '_get_last_thread_cache' if not hasattr(self, cache_key): item = None res = self.thread_set.filter(visible=True).order_by('-modified')[0:1] if len(res)>0: ...
[ "def", "get_last_thread", "(", "self", ")", ":", "cache_key", "=", "'_get_last_thread_cache'", "if", "not", "hasattr", "(", "self", ",", "cache_key", ")", ":", "item", "=", "None", "res", "=", "self", ".", "thread_set", ".", "filter", "(", "visible", "=", ...
Return the last modified thread
[ "Return", "the", "last", "modified", "thread" ]
train
https://github.com/emencia/emencia-django-forum/blob/cda74ed7e5822675c340ee5ec71548d981bccd3b/forum/models.py#L31-L42
emencia/emencia-django-forum
forum/models.py
Thread.get_first_post
def get_first_post(self): """ Retourne le premier post en date, celui créé lors de la création du fil """ cache_key = '_get_starter_cache' if not hasattr(self, cache_key): item = None res = self.post_set.all().order_by('created')[0:1] if len(re...
python
def get_first_post(self): """ Retourne le premier post en date, celui créé lors de la création du fil """ cache_key = '_get_starter_cache' if not hasattr(self, cache_key): item = None res = self.post_set.all().order_by('created')[0:1] if len(re...
[ "def", "get_first_post", "(", "self", ")", ":", "cache_key", "=", "'_get_starter_cache'", "if", "not", "hasattr", "(", "self", ",", "cache_key", ")", ":", "item", "=", "None", "res", "=", "self", ".", "post_set", ".", "all", "(", ")", ".", "order_by", ...
Retourne le premier post en date, celui créé lors de la création du fil
[ "Retourne", "le", "premier", "post", "en", "date", "celui", "créé", "lors", "de", "la", "création", "du", "fil" ]
train
https://github.com/emencia/emencia-django-forum/blob/cda74ed7e5822675c340ee5ec71548d981bccd3b/forum/models.py#L73-L84
emencia/emencia-django-forum
forum/models.py
Thread.save
def save(self, *args, **kwargs): """ Fill 'created' and 'modified' attributes on first create """ if self.created is None: self.created = tz_now() if self.modified is None: self.modified = self.created super(Thread, self).save...
python
def save(self, *args, **kwargs): """ Fill 'created' and 'modified' attributes on first create """ if self.created is None: self.created = tz_now() if self.modified is None: self.modified = self.created super(Thread, self).save...
[ "def", "save", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "created", "is", "None", ":", "self", ".", "created", "=", "tz_now", "(", ")", "if", "self", ".", "modified", "is", "None", ":", "self", ".", "m...
Fill 'created' and 'modified' attributes on first create
[ "Fill", "created", "and", "modified", "attributes", "on", "first", "create" ]
train
https://github.com/emencia/emencia-django-forum/blob/cda74ed7e5822675c340ee5ec71548d981bccd3b/forum/models.py#L99-L109
emencia/emencia-django-forum
forum/models.py
Post.get_paginated_urlargs
def get_paginated_urlargs(self): """ Return url arguments to retrieve the Post in a paginated list """ position = self.get_paginated_position() if not position: return '#forum-post-{0}'.format(self.id) return '?page={0}#forum-post-{1}'.format...
python
def get_paginated_urlargs(self): """ Return url arguments to retrieve the Post in a paginated list """ position = self.get_paginated_position() if not position: return '#forum-post-{0}'.format(self.id) return '?page={0}#forum-post-{1}'.format...
[ "def", "get_paginated_urlargs", "(", "self", ")", ":", "position", "=", "self", ".", "get_paginated_position", "(", ")", "if", "not", "position", ":", "return", "'#forum-post-{0}'", ".", "format", "(", "self", ".", "id", ")", "return", "'?page={0}#forum-post-{1}...
Return url arguments to retrieve the Post in a paginated list
[ "Return", "url", "arguments", "to", "retrieve", "the", "Post", "in", "a", "paginated", "list" ]
train
https://github.com/emencia/emencia-django-forum/blob/cda74ed7e5822675c340ee5ec71548d981bccd3b/forum/models.py#L150-L159
emencia/emencia-django-forum
forum/models.py
Post.get_paginated_position
def get_paginated_position(self): """ Return the Post position in the paginated list """ # If Post list is not paginated if not settings.FORUM_THREAD_DETAIL_PAGINATE: return 0 count = Post.objects.filter(thread=self.thread_id, created__lt=self.created...
python
def get_paginated_position(self): """ Return the Post position in the paginated list """ # If Post list is not paginated if not settings.FORUM_THREAD_DETAIL_PAGINATE: return 0 count = Post.objects.filter(thread=self.thread_id, created__lt=self.created...
[ "def", "get_paginated_position", "(", "self", ")", ":", "# If Post list is not paginated", "if", "not", "settings", ".", "FORUM_THREAD_DETAIL_PAGINATE", ":", "return", "0", "count", "=", "Post", ".", "objects", ".", "filter", "(", "thread", "=", "self", ".", "th...
Return the Post position in the paginated list
[ "Return", "the", "Post", "position", "in", "the", "paginated", "list" ]
train
https://github.com/emencia/emencia-django-forum/blob/cda74ed7e5822675c340ee5ec71548d981bccd3b/forum/models.py#L161-L171
emencia/emencia-django-forum
forum/models.py
Post.save
def save(self, *args, **kwargs): """ Fill 'created' and 'modified' attributes on first create and allways update the thread's 'modified' attribute """ edited = not(self.created is None) if self.created is None: self.created = tz_now() ...
python
def save(self, *args, **kwargs): """ Fill 'created' and 'modified' attributes on first create and allways update the thread's 'modified' attribute """ edited = not(self.created is None) if self.created is None: self.created = tz_now() ...
[ "def", "save", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "edited", "=", "not", "(", "self", ".", "created", "is", "None", ")", "if", "self", ".", "created", "is", "None", ":", "self", ".", "created", "=", "tz_now", "(", ...
Fill 'created' and 'modified' attributes on first create and allways update the thread's 'modified' attribute
[ "Fill", "created", "and", "modified", "attributes", "on", "first", "create", "and", "allways", "update", "the", "thread", "s", "modified", "attribute" ]
train
https://github.com/emencia/emencia-django-forum/blob/cda74ed7e5822675c340ee5ec71548d981bccd3b/forum/models.py#L173-L194
opinkerfi/nago
nago/extensions/plugins.py
get
def get(search="unsigned"): """ List all available plugins""" plugins = [] for i in os.walk('/usr/lib/nagios/plugins'): for f in i[2]: plugins.append(f) return plugins
python
def get(search="unsigned"): """ List all available plugins""" plugins = [] for i in os.walk('/usr/lib/nagios/plugins'): for f in i[2]: plugins.append(f) return plugins
[ "def", "get", "(", "search", "=", "\"unsigned\"", ")", ":", "plugins", "=", "[", "]", "for", "i", "in", "os", ".", "walk", "(", "'/usr/lib/nagios/plugins'", ")", ":", "for", "f", "in", "i", "[", "2", "]", ":", "plugins", ".", "append", "(", "f", ...
List all available plugins
[ "List", "all", "available", "plugins" ]
train
https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/extensions/plugins.py#L13-L19
opinkerfi/nago
nago/extensions/plugins.py
run
def run(plugin_name, *args, **kwargs): """ Run a specific plugin """ plugindir = nago.settings.get_option('plugin_dir') plugin = plugindir + "/" + plugin_name if not os.path.isfile(plugin): raise ValueError("Plugin %s not found" % plugin) command = [plugin] + list(args) p = subprocess.P...
python
def run(plugin_name, *args, **kwargs): """ Run a specific plugin """ plugindir = nago.settings.get_option('plugin_dir') plugin = plugindir + "/" + plugin_name if not os.path.isfile(plugin): raise ValueError("Plugin %s not found" % plugin) command = [plugin] + list(args) p = subprocess.P...
[ "def", "run", "(", "plugin_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "plugindir", "=", "nago", ".", "settings", ".", "get_option", "(", "'plugin_dir'", ")", "plugin", "=", "plugindir", "+", "\"/\"", "+", "plugin_name", "if", "not", "o...
Run a specific plugin
[ "Run", "a", "specific", "plugin" ]
train
https://github.com/opinkerfi/nago/blob/85e1bdd1de0122f56868a483e7599e1b36a439b0/nago/extensions/plugins.py#L22-L36
joshblum/beanstalk-dispatch
beanstalk_dispatch/safe_task.py
SafeTask.process
def process(self, *args, **kwargs): """ args: list of arguments for the `runnable` kwargs: dictionary of arguments for the `runnable` """ try: timeout_seconds = self.timeout_timedelta.total_seconds() with timeout(self.run, timeout_seconds) as run: ...
python
def process(self, *args, **kwargs): """ args: list of arguments for the `runnable` kwargs: dictionary of arguments for the `runnable` """ try: timeout_seconds = self.timeout_timedelta.total_seconds() with timeout(self.run, timeout_seconds) as run: ...
[ "def", "process", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "timeout_seconds", "=", "self", ".", "timeout_timedelta", ".", "total_seconds", "(", ")", "with", "timeout", "(", "self", ".", "run", ",", "timeout_seconds", ...
args: list of arguments for the `runnable` kwargs: dictionary of arguments for the `runnable`
[ "args", ":", "list", "of", "arguments", "for", "the", "runnable", "kwargs", ":", "dictionary", "of", "arguments", "for", "the", "runnable" ]
train
https://github.com/joshblum/beanstalk-dispatch/blob/1cc57e5496bb7114dba6de7c7988e5680d791603/beanstalk_dispatch/safe_task.py#L53-L73
b3j0f/utils
b3j0f/utils/property.py
find_ctx
def find_ctx(elt): """Get the right ctx related to input elt. In order to keep safe memory as much as possible, it is important to find the right context element. For example, instead of putting properties on a function at the level of an instance, it is important to save such property on the insta...
python
def find_ctx(elt): """Get the right ctx related to input elt. In order to keep safe memory as much as possible, it is important to find the right context element. For example, instead of putting properties on a function at the level of an instance, it is important to save such property on the insta...
[ "def", "find_ctx", "(", "elt", ")", ":", "result", "=", "elt", "# by default, result is ctx", "# if elt is ctx and elt is a method, it is possible to find the best ctx", "if", "ismethod", "(", "elt", ")", ":", "# get instance and class of the elt", "instance", "=", "get_metho...
Get the right ctx related to input elt. In order to keep safe memory as much as possible, it is important to find the right context element. For example, instead of putting properties on a function at the level of an instance, it is important to save such property on the instance because the function._...
[ "Get", "the", "right", "ctx", "related", "to", "input", "elt", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L81-L107
b3j0f/utils
b3j0f/utils/property.py
free_cache
def free_cache(ctx, *elts): """Free properties bound to input cached elts. If empty, free the whole cache. """ for elt in elts: if isinstance(elt, Hashable): cache = __STATIC_ELEMENTS_CACHE__ else: cache = __UNHASHABLE_ELTS_CACHE__ elt = id(elt) ...
python
def free_cache(ctx, *elts): """Free properties bound to input cached elts. If empty, free the whole cache. """ for elt in elts: if isinstance(elt, Hashable): cache = __STATIC_ELEMENTS_CACHE__ else: cache = __UNHASHABLE_ELTS_CACHE__ elt = id(elt) ...
[ "def", "free_cache", "(", "ctx", ",", "*", "elts", ")", ":", "for", "elt", "in", "elts", ":", "if", "isinstance", "(", "elt", ",", "Hashable", ")", ":", "cache", "=", "__STATIC_ELEMENTS_CACHE__", "else", ":", "cache", "=", "__UNHASHABLE_ELTS_CACHE__", "elt...
Free properties bound to input cached elts. If empty, free the whole cache.
[ "Free", "properties", "bound", "to", "input", "cached", "elts", ".", "If", "empty", "free", "the", "whole", "cache", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L110-L126
b3j0f/utils
b3j0f/utils/property.py
_ctx_elt_properties
def _ctx_elt_properties(elt, ctx=None, create=False): """Get elt properties related to a ctx. :param elt: property component elt. Not None methods or unhashable types. :param ctx: elt ctx from where get properties. Equals elt if None. It allows to get function properties related to a class or insta...
python
def _ctx_elt_properties(elt, ctx=None, create=False): """Get elt properties related to a ctx. :param elt: property component elt. Not None methods or unhashable types. :param ctx: elt ctx from where get properties. Equals elt if None. It allows to get function properties related to a class or insta...
[ "def", "_ctx_elt_properties", "(", "elt", ",", "ctx", "=", "None", ",", "create", "=", "False", ")", ":", "result", "=", "None", "if", "ctx", "is", "None", ":", "ctx", "=", "find_ctx", "(", "elt", "=", "elt", ")", "ctx_properties", "=", "None", "# in...
Get elt properties related to a ctx. :param elt: property component elt. Not None methods or unhashable types. :param ctx: elt ctx from where get properties. Equals elt if None. It allows to get function properties related to a class or instance if related function is defined in base class. ...
[ "Get", "elt", "properties", "related", "to", "a", "ctx", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L129-L184
b3j0f/utils
b3j0f/utils/property.py
get_properties
def get_properties(elt, keys=None, ctx=None): """Get elt properties. :param elt: properties elt. Not None methods or unhashable types. :param keys: key(s) of properties to get from elt. If None, get all properties. :type keys: list or str :param ctx: elt ctx from where get properties. Equal...
python
def get_properties(elt, keys=None, ctx=None): """Get elt properties. :param elt: properties elt. Not None methods or unhashable types. :param keys: key(s) of properties to get from elt. If None, get all properties. :type keys: list or str :param ctx: elt ctx from where get properties. Equal...
[ "def", "get_properties", "(", "elt", ",", "keys", "=", "None", ",", "ctx", "=", "None", ")", ":", "# initialize keys if str", "if", "isinstance", "(", "keys", ",", "string_types", ")", ":", "keys", "=", "(", "keys", ",", ")", "result", "=", "_get_propert...
Get elt properties. :param elt: properties elt. Not None methods or unhashable types. :param keys: key(s) of properties to get from elt. If None, get all properties. :type keys: list or str :param ctx: elt ctx from where get properties. Equals elt if None. It allows to get function prop...
[ "Get", "elt", "properties", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L187-L208
b3j0f/utils
b3j0f/utils/property.py
get_property
def get_property(elt, key, ctx=None): """Get elt key property. :param elt: property elt. Not None methods. :param key: property key to get from elt. :param ctx: elt ctx from where get properties. Equals elt if None. It allows to get function properties related to a class or instance if ...
python
def get_property(elt, key, ctx=None): """Get elt key property. :param elt: property elt. Not None methods. :param key: property key to get from elt. :param ctx: elt ctx from where get properties. Equals elt if None. It allows to get function properties related to a class or instance if ...
[ "def", "get_property", "(", "elt", ",", "key", ",", "ctx", "=", "None", ")", ":", "result", "=", "[", "]", "properties", "=", "get_properties", "(", "elt", "=", "elt", ",", "ctx", "=", "ctx", ",", "keys", "=", "key", ")", "if", "key", "in", "prop...
Get elt key property. :param elt: property elt. Not None methods. :param key: property key to get from elt. :param ctx: elt ctx from where get properties. Equals elt if None. It allows to get function properties related to a class or instance if related function is defined in base class. ...
[ "Get", "elt", "key", "property", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L211-L231
b3j0f/utils
b3j0f/utils/property.py
get_first_properties
def get_first_properties(elt, keys=None, ctx=None): """Get first properties related to one input key. :param elt: first property elt. Not None methods. :param list keys: property keys to get. :param ctx: elt ctx from where get properties. Equals elt if None. It allows to get function properties...
python
def get_first_properties(elt, keys=None, ctx=None): """Get first properties related to one input key. :param elt: first property elt. Not None methods. :param list keys: property keys to get. :param ctx: elt ctx from where get properties. Equals elt if None. It allows to get function properties...
[ "def", "get_first_properties", "(", "elt", ",", "keys", "=", "None", ",", "ctx", "=", "None", ")", ":", "# ensure keys is an iterable if not None", "if", "isinstance", "(", "keys", ",", "string_types", ")", ":", "keys", "=", "(", "keys", ",", ")", "result", ...
Get first properties related to one input key. :param elt: first property elt. Not None methods. :param list keys: property keys to get. :param ctx: elt ctx from where get properties. Equals elt if None. It allows to get function properties related to a class or instance if related function...
[ "Get", "first", "properties", "related", "to", "one", "input", "key", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L234-L252
b3j0f/utils
b3j0f/utils/property.py
get_first_property
def get_first_property(elt, key, default=None, ctx=None): """Get first property related to one input key. :param elt: first property elt. Not None methods. :param str key: property key to get. :param default: default value to return if key does not exist in elt. properties :param ctx: elt c...
python
def get_first_property(elt, key, default=None, ctx=None): """Get first property related to one input key. :param elt: first property elt. Not None methods. :param str key: property key to get. :param default: default value to return if key does not exist in elt. properties :param ctx: elt c...
[ "def", "get_first_property", "(", "elt", ",", "key", ",", "default", "=", "None", ",", "ctx", "=", "None", ")", ":", "result", "=", "default", "properties", "=", "_get_properties", "(", "elt", ",", "keys", "=", "(", "key", ",", ")", ",", "ctx", "=", ...
Get first property related to one input key. :param elt: first property elt. Not None methods. :param str key: property key to get. :param default: default value to return if key does not exist in elt. properties :param ctx: elt ctx from where get properties. Equals elt if None. It allo...
[ "Get", "first", "property", "related", "to", "one", "input", "key", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L255-L275
b3j0f/utils
b3j0f/utils/property.py
get_local_properties
def get_local_properties(elt, keys=None, ctx=None): """Get local elt properties (not defined in elt type or base classes). :param elt: local properties elt. Not None methods. :param keys: keys of properties to get from elt. :param ctx: elt ctx from where get properties. Equals elt if None. It a...
python
def get_local_properties(elt, keys=None, ctx=None): """Get local elt properties (not defined in elt type or base classes). :param elt: local properties elt. Not None methods. :param keys: keys of properties to get from elt. :param ctx: elt ctx from where get properties. Equals elt if None. It a...
[ "def", "get_local_properties", "(", "elt", ",", "keys", "=", "None", ",", "ctx", "=", "None", ")", ":", "if", "isinstance", "(", "keys", ",", "string_types", ")", ":", "keys", "=", "(", "keys", ",", ")", "result", "=", "_get_properties", "(", "elt", ...
Get local elt properties (not defined in elt type or base classes). :param elt: local properties elt. Not None methods. :param keys: keys of properties to get from elt. :param ctx: elt ctx from where get properties. Equals elt if None. It allows to get function properties related to a class or inst...
[ "Get", "local", "elt", "properties", "(", "not", "defined", "in", "elt", "type", "or", "base", "classes", ")", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L278-L296
b3j0f/utils
b3j0f/utils/property.py
get_local_property
def get_local_property(elt, key, default=None, ctx=None): """Get one local property related to one input key or default value if key is not found. :param elt: local property elt. Not None methods. :param str key: property key to get. :param default: default value to return if key does not exist in ...
python
def get_local_property(elt, key, default=None, ctx=None): """Get one local property related to one input key or default value if key is not found. :param elt: local property elt. Not None methods. :param str key: property key to get. :param default: default value to return if key does not exist in ...
[ "def", "get_local_property", "(", "elt", ",", "key", ",", "default", "=", "None", ",", "ctx", "=", "None", ")", ":", "result", "=", "default", "local_properties", "=", "get_local_properties", "(", "elt", "=", "elt", ",", "keys", "=", "(", "key", ",", "...
Get one local property related to one input key or default value if key is not found. :param elt: local property elt. Not None methods. :param str key: property key to get. :param default: default value to return if key does not exist in elt properties. :param ctx: elt ctx from where get pr...
[ "Get", "one", "local", "property", "related", "to", "one", "input", "key", "or", "default", "value", "if", "key", "is", "not", "found", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L299-L321
b3j0f/utils
b3j0f/utils/property.py
_get_properties
def _get_properties( elt, keys=None, local=False, exclude=None, first=False, ctx=None, _found_keys=None ): """Get a dictionary of elt properties. Such dictionary is filled related to the elt properties, and from all base elts properties if not local. :param elt: properties elt. Not None me...
python
def _get_properties( elt, keys=None, local=False, exclude=None, first=False, ctx=None, _found_keys=None ): """Get a dictionary of elt properties. Such dictionary is filled related to the elt properties, and from all base elts properties if not local. :param elt: properties elt. Not None me...
[ "def", "_get_properties", "(", "elt", ",", "keys", "=", "None", ",", "local", "=", "False", ",", "exclude", "=", "None", ",", "first", "=", "False", ",", "ctx", "=", "None", ",", "_found_keys", "=", "None", ")", ":", "result", "=", "{", "}", "# get...
Get a dictionary of elt properties. Such dictionary is filled related to the elt properties, and from all base elts properties if not local. :param elt: properties elt. Not None methods. :param ctx: elt ctx from where get properties. Equals elt if None. It allows to get function properties...
[ "Get", "a", "dictionary", "of", "elt", "properties", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L324-L510
b3j0f/utils
b3j0f/utils/property.py
put_property
def put_property(elt, key, value, ttl=None, ctx=None): """Put properties in elt. :param elt: properties elt to put. Not None methods. :param number ttl: If not None, property time to leave. :param ctx: elt ctx from where put properties. Equals elt if None. It allows to get function properties r...
python
def put_property(elt, key, value, ttl=None, ctx=None): """Put properties in elt. :param elt: properties elt to put. Not None methods. :param number ttl: If not None, property time to leave. :param ctx: elt ctx from where put properties. Equals elt if None. It allows to get function properties r...
[ "def", "put_property", "(", "elt", ",", "key", ",", "value", ",", "ttl", "=", "None", ",", "ctx", "=", "None", ")", ":", "return", "put_properties", "(", "elt", "=", "elt", ",", "properties", "=", "{", "key", ":", "value", "}", ",", "ttl", "=", "...
Put properties in elt. :param elt: properties elt to put. Not None methods. :param number ttl: If not None, property time to leave. :param ctx: elt ctx from where put properties. Equals elt if None. It allows to get function properties related to a class or instance if related function is d...
[ "Put", "properties", "in", "elt", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L513-L526
b3j0f/utils
b3j0f/utils/property.py
put_properties
def put_properties(elt, properties, ttl=None, ctx=None): """Put properties in elt. :param elt: properties elt to put. Not None methods. :param number ttl: If not None, property time to leave. :param ctx: elt ctx from where put properties. Equals elt if None. It allows to get function properties...
python
def put_properties(elt, properties, ttl=None, ctx=None): """Put properties in elt. :param elt: properties elt to put. Not None methods. :param number ttl: If not None, property time to leave. :param ctx: elt ctx from where put properties. Equals elt if None. It allows to get function properties...
[ "def", "put_properties", "(", "elt", ",", "properties", ",", "ttl", "=", "None", ",", "ctx", "=", "None", ")", ":", "result", "=", "None", "if", "properties", ":", "# get the best context", "if", "ctx", "is", "None", ":", "ctx", "=", "find_ctx", "(", "...
Put properties in elt. :param elt: properties elt to put. Not None methods. :param number ttl: If not None, property time to leave. :param ctx: elt ctx from where put properties. Equals elt if None. It allows to get function properties related to a class or instance if related function is d...
[ "Put", "properties", "in", "elt", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L529-L566
b3j0f/utils
b3j0f/utils/property.py
put
def put(properties, ttl=None, ctx=None): """Decorator dedicated to put properties on an element. """ def put_on(elt): return put_properties(elt=elt, properties=properties, ttl=ttl, ctx=ctx) return put_on
python
def put(properties, ttl=None, ctx=None): """Decorator dedicated to put properties on an element. """ def put_on(elt): return put_properties(elt=elt, properties=properties, ttl=ttl, ctx=ctx) return put_on
[ "def", "put", "(", "properties", ",", "ttl", "=", "None", ",", "ctx", "=", "None", ")", ":", "def", "put_on", "(", "elt", ")", ":", "return", "put_properties", "(", "elt", "=", "elt", ",", "properties", "=", "properties", ",", "ttl", "=", "ttl", ",...
Decorator dedicated to put properties on an element.
[ "Decorator", "dedicated", "to", "put", "properties", "on", "an", "element", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L569-L576
b3j0f/utils
b3j0f/utils/property.py
del_properties
def del_properties(elt, keys=None, ctx=None): """Delete elt property. :param elt: properties elt to del. Not None methods. :param keys: property keys to delete from elt. If empty, delete all properties. """ # get the best context if ctx is None: ctx = find_ctx(elt=elt) elt...
python
def del_properties(elt, keys=None, ctx=None): """Delete elt property. :param elt: properties elt to del. Not None methods. :param keys: property keys to delete from elt. If empty, delete all properties. """ # get the best context if ctx is None: ctx = find_ctx(elt=elt) elt...
[ "def", "del_properties", "(", "elt", ",", "keys", "=", "None", ",", "ctx", "=", "None", ")", ":", "# get the best context", "if", "ctx", "is", "None", ":", "ctx", "=", "find_ctx", "(", "elt", "=", "elt", ")", "elt_properties", "=", "_ctx_elt_properties", ...
Delete elt property. :param elt: properties elt to del. Not None methods. :param keys: property keys to delete from elt. If empty, delete all properties.
[ "Delete", "elt", "property", "." ]
train
https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/property.py#L579-L635