repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
casouri/launchdman
launchdman/__init__.py
combine
def combine(a1, a2): ''' Combine to argument into a single flat list It is used when you are not sure whether arguments are lists but want to combine them into one flat list Args: a1: list or other thing a2: list or other thing Returns: list: a flat list contain a1 and a2 ...
python
def combine(a1, a2): ''' Combine to argument into a single flat list It is used when you are not sure whether arguments are lists but want to combine them into one flat list Args: a1: list or other thing a2: list or other thing Returns: list: a flat list contain a1 and a2 ...
[ "def", "combine", "(", "a1", ",", "a2", ")", ":", "if", "not", "isinstance", "(", "a1", ",", "list", ")", ":", "a1", "=", "[", "a1", "]", "if", "not", "isinstance", "(", "a2", ",", "list", ")", ":", "a2", "=", "[", "a2", "]", "return", "a1", ...
Combine to argument into a single flat list It is used when you are not sure whether arguments are lists but want to combine them into one flat list Args: a1: list or other thing a2: list or other thing Returns: list: a flat list contain a1 and a2
[ "Combine", "to", "argument", "into", "a", "single", "flat", "list" ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L85-L101
train
Combine to argument into a single flat list containing a1 and a2.
casouri/launchdman
launchdman/__init__.py
singleOrPair
def singleOrPair(obj): '''Chech an object is single or pair or neither. Of course,, all pairs are single, so what the function is really detecting is whether an object is only single or at the same time a pair. Args: obj (object): Literally anything. Returns: str: 'Single', or 'Pair',...
python
def singleOrPair(obj): '''Chech an object is single or pair or neither. Of course,, all pairs are single, so what the function is really detecting is whether an object is only single or at the same time a pair. Args: obj (object): Literally anything. Returns: str: 'Single', or 'Pair',...
[ "def", "singleOrPair", "(", "obj", ")", ":", "if", "len", "(", "list", "(", "obj", ".", "__class__", ".", "__mro__", ")", ")", "<=", "2", ":", "return", "'Neither'", "else", ":", "# Pair check comes first for Pair is a subclass of Single", "if", "ancestorJr", ...
Chech an object is single or pair or neither. Of course,, all pairs are single, so what the function is really detecting is whether an object is only single or at the same time a pair. Args: obj (object): Literally anything. Returns: str: 'Single', or 'Pair', or 'Neither'
[ "Chech", "an", "object", "is", "single", "or", "pair", "or", "neither", "." ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L146-L166
train
Returns whether an object is single or pair or neither.
casouri/launchdman
launchdman/__init__.py
removeEverything
def removeEverything(toBeRemoved, l): '''Remove every instance that matches the input from a list Match with ==, operation, which can be defined in __eq__. Args: tobeRemoved (object): the same object you want to remove from the list. l (list): the llist you want to remove stuff from. '...
python
def removeEverything(toBeRemoved, l): '''Remove every instance that matches the input from a list Match with ==, operation, which can be defined in __eq__. Args: tobeRemoved (object): the same object you want to remove from the list. l (list): the llist you want to remove stuff from. '...
[ "def", "removeEverything", "(", "toBeRemoved", ",", "l", ")", ":", "successful", "=", "True", "while", "successful", ":", "try", ":", "# list.remove will remove item if equal,", "# which is evaluated by __eq__", "l", ".", "remove", "(", "toBeRemoved", ")", "except", ...
Remove every instance that matches the input from a list Match with ==, operation, which can be defined in __eq__. Args: tobeRemoved (object): the same object you want to remove from the list. l (list): the llist you want to remove stuff from.
[ "Remove", "every", "instance", "that", "matches", "the", "input", "from", "a", "list" ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L169-L185
train
Remove every item that matches the input from a list of objects.
casouri/launchdman
launchdman/__init__.py
Single.printMe
def printMe(self, selfTag, selfValue): '''Parse the single and its value and return the parsed str. Args: selfTag (str): The tag. Normally just ``self.tag`` selfValue (list): a list of value elements(single, subclasses, str, int). Normally just ``self.value`` Returns: ...
python
def printMe(self, selfTag, selfValue): '''Parse the single and its value and return the parsed str. Args: selfTag (str): The tag. Normally just ``self.tag`` selfValue (list): a list of value elements(single, subclasses, str, int). Normally just ``self.value`` Returns: ...
[ "def", "printMe", "(", "self", ",", "selfTag", ",", "selfValue", ")", ":", "if", "len", "(", "selfValue", ")", "==", "0", ":", "return", "''", "# if value have only one element and it is not another single", "# print differently", "elif", "len", "(", "selfValue", ...
Parse the single and its value and return the parsed str. Args: selfTag (str): The tag. Normally just ``self.tag`` selfValue (list): a list of value elements(single, subclasses, str, int). Normally just ``self.value`` Returns: str: A parsed text
[ "Parse", "the", "single", "and", "its", "value", "and", "return", "the", "parsed", "str", "." ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L225-L261
train
Parse the single and its value and return the parsed str.
casouri/launchdman
launchdman/__init__.py
Single.findAll
def findAll(self, selfValue): '''Looks for all the non single values(str, int) *recursively* and returns a list of them Args: selfValue: A list of single, str, int. Normally just ``self.value`` Returns: list: A list contains only non singles(str, int). ''' ...
python
def findAll(self, selfValue): '''Looks for all the non single values(str, int) *recursively* and returns a list of them Args: selfValue: A list of single, str, int. Normally just ``self.value`` Returns: list: A list contains only non singles(str, int). ''' ...
[ "def", "findAll", "(", "self", ",", "selfValue", ")", ":", "resultList", "=", "[", "]", "for", "element", "in", "selfValue", ":", "if", "isinstance", "(", "element", ",", "Single", ")", ":", "resultList", "+=", "element", ".", "findAll", "(", "element", ...
Looks for all the non single values(str, int) *recursively* and returns a list of them Args: selfValue: A list of single, str, int. Normally just ``self.value`` Returns: list: A list contains only non singles(str, int).
[ "Looks", "for", "all", "the", "non", "single", "values", "(", "str", "int", ")", "*", "recursively", "*", "and", "returns", "a", "list", "of", "them" ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L263-L278
train
Looks for all the non single values recursively and returns a list of them
casouri/launchdman
launchdman/__init__.py
Single.findAllSingle
def findAllSingle(self, selfValue): '''Looks for all the single values and subclasses *recursively* and returns a list of them Args: selfValue: A list of single, str, int. Normally just ``self.value`` Returns: list: A list contains only singles and subclasses. '...
python
def findAllSingle(self, selfValue): '''Looks for all the single values and subclasses *recursively* and returns a list of them Args: selfValue: A list of single, str, int. Normally just ``self.value`` Returns: list: A list contains only singles and subclasses. '...
[ "def", "findAllSingle", "(", "self", ",", "selfValue", ")", ":", "resultList", "=", "[", "]", "for", "element", "in", "selfValue", ":", "if", "isinstance", "(", "element", ",", "Single", ")", ":", "resultList", ".", "append", "(", "element", ")", "result...
Looks for all the single values and subclasses *recursively* and returns a list of them Args: selfValue: A list of single, str, int. Normally just ``self.value`` Returns: list: A list contains only singles and subclasses.
[ "Looks", "for", "all", "the", "single", "values", "and", "subclasses", "*", "recursively", "*", "and", "returns", "a", "list", "of", "them" ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L280-L294
train
Looks for all the single values and subclasses recursively and returns a list of them
casouri/launchdman
launchdman/__init__.py
Single.add
def add(self, *value): '''convert value and add to self.value Subclass must overwrite this method. Subclass are responsible of creating whatever single instance it need from its ``add(*value)`` and call ``_add()`` to add them to ``self.value`` Args: *value: the value to be ...
python
def add(self, *value): '''convert value and add to self.value Subclass must overwrite this method. Subclass are responsible of creating whatever single instance it need from its ``add(*value)`` and call ``_add()`` to add them to ``self.value`` Args: *value: the value to be ...
[ "def", "add", "(", "self", ",", "*", "value", ")", ":", "flattenedValueList", "=", "list", "(", "flatten", "(", "value", ")", ")", "return", "self", ".", "_add", "(", "flattenedValueList", ",", "self", ".", "value", ")" ]
convert value and add to self.value Subclass must overwrite this method. Subclass are responsible of creating whatever single instance it need from its ``add(*value)`` and call ``_add()`` to add them to ``self.value`` Args: *value: the value to be added
[ "convert", "value", "and", "add", "to", "self", ".", "value" ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L309-L319
train
convert value and add to self. value Subclass must overwrite this method.
casouri/launchdman
launchdman/__init__.py
Single._remove
def _remove(self, removeList, selfValue): '''Remove elements from a list by matching the elements in the other list. This method only looks inside current instance's value, not recursive. There is no need for a recursive one anyway. Match by == operation. Args: remo...
python
def _remove(self, removeList, selfValue): '''Remove elements from a list by matching the elements in the other list. This method only looks inside current instance's value, not recursive. There is no need for a recursive one anyway. Match by == operation. Args: remo...
[ "def", "_remove", "(", "self", ",", "removeList", ",", "selfValue", ")", ":", "for", "removeValue", "in", "removeList", ":", "print", "(", "removeValue", ",", "removeList", ")", "# if removeValue equal to selfValue, remove", "removeEverything", "(", "removeValue", "...
Remove elements from a list by matching the elements in the other list. This method only looks inside current instance's value, not recursive. There is no need for a recursive one anyway. Match by == operation. Args: removeList (list): The list of matching elements. ...
[ "Remove", "elements", "from", "a", "list", "by", "matching", "the", "elements", "in", "the", "other", "list", "." ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L321-L335
train
Remove elements from a list by matching the elements in the other list.
casouri/launchdman
launchdman/__init__.py
Single.remove
def remove(self, *l): ''' remove elements from self.value by matching. Create the exactly same single you want to delete and pass it(them) in. Normally this method needs to be overwrited by subclass. It only looks inside current instance's value, not recursive. There is no need for a recursive ...
python
def remove(self, *l): ''' remove elements from self.value by matching. Create the exactly same single you want to delete and pass it(them) in. Normally this method needs to be overwrited by subclass. It only looks inside current instance's value, not recursive. There is no need for a recursive ...
[ "def", "remove", "(", "self", ",", "*", "l", ")", ":", "removeList", "=", "list", "(", "flatten", "(", "l", ")", ")", "self", ".", "_remove", "(", "removeList", ",", "self", ".", "value", ")" ]
remove elements from self.value by matching. Create the exactly same single you want to delete and pass it(them) in. Normally this method needs to be overwrited by subclass. It only looks inside current instance's value, not recursive. There is no need for a recursive one anyway. Args: ...
[ "remove", "elements", "from", "self", ".", "value", "by", "matching", "." ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L337-L347
train
remove elements from self. value by matching.
casouri/launchdman
launchdman/__init__.py
Job.write
def write(self): '''Write the job to the corresponding plist.''' with open(self.me, 'w') as f: f.write(self.printMe(self.tag, self.value))
python
def write(self): '''Write the job to the corresponding plist.''' with open(self.me, 'w') as f: f.write(self.printMe(self.tag, self.value))
[ "def", "write", "(", "self", ")", ":", "with", "open", "(", "self", ".", "me", ",", "'w'", ")", "as", "f", ":", "f", ".", "write", "(", "self", ".", "printMe", "(", "self", ".", "tag", ",", "self", ".", "value", ")", ")" ]
Write the job to the corresponding plist.
[ "Write", "the", "job", "to", "the", "corresponding", "plist", "." ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L367-L370
train
Write the job to the corresponding plist.
casouri/launchdman
launchdman/__init__.py
Pair.printMe
def printMe(self, selfKey, selfValue): '''Parse the single and its value and return the parsed str. Args: selfTag (str): The tag. Normally just ``self.tag`` selfValue (list): a list of value elements(single, subclasses, str, int). Normally just ``self.value`` Returns: ...
python
def printMe(self, selfKey, selfValue): '''Parse the single and its value and return the parsed str. Args: selfTag (str): The tag. Normally just ``self.tag`` selfValue (list): a list of value elements(single, subclasses, str, int). Normally just ``self.value`` Returns: ...
[ "def", "printMe", "(", "self", ",", "selfKey", ",", "selfValue", ")", ":", "text", "=", "'<key>{keyName}</key>\\n'", ".", "format", "(", "keyName", "=", "selfKey", ")", "if", "len", "(", "selfValue", ")", "==", "0", ":", "return", "''", "else", ":", "v...
Parse the single and its value and return the parsed str. Args: selfTag (str): The tag. Normally just ``self.tag`` selfValue (list): a list of value elements(single, subclasses, str, int). Normally just ``self.value`` Returns: str: A parsed text
[ "Parse", "the", "single", "and", "its", "value", "and", "return", "the", "parsed", "str", "." ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L499-L523
train
Parse the single and its value and return the parsed str.
casouri/launchdman
launchdman/__init__.py
OuterOFInnerPair.add
def add(self, *l): '''add inner to outer Args: *l: element that is passed into Inner init ''' for a in flatten(l): self._add([self.Inner(a)], self.l)
python
def add(self, *l): '''add inner to outer Args: *l: element that is passed into Inner init ''' for a in flatten(l): self._add([self.Inner(a)], self.l)
[ "def", "add", "(", "self", ",", "*", "l", ")", ":", "for", "a", "in", "flatten", "(", "l", ")", ":", "self", ".", "_add", "(", "[", "self", ".", "Inner", "(", "a", ")", "]", ",", "self", ".", "l", ")" ]
add inner to outer Args: *l: element that is passed into Inner init
[ "add", "inner", "to", "outer" ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L593-L600
train
add inner to outer
casouri/launchdman
launchdman/__init__.py
OuterOFInnerPair.remove
def remove(self, *l): '''remove inner from outer Args: *l element that is passes into Inner init ''' for a in flatten(l): self._remove([self.Inner(a)], self.l)
python
def remove(self, *l): '''remove inner from outer Args: *l element that is passes into Inner init ''' for a in flatten(l): self._remove([self.Inner(a)], self.l)
[ "def", "remove", "(", "self", ",", "*", "l", ")", ":", "for", "a", "in", "flatten", "(", "l", ")", ":", "self", ".", "_remove", "(", "[", "self", ".", "Inner", "(", "a", ")", "]", ",", "self", ".", "l", ")" ]
remove inner from outer Args: *l element that is passes into Inner init
[ "remove", "inner", "from", "outer" ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L602-L609
train
remove inner from outer
casouri/launchdman
launchdman/__init__.py
SingleDictPair.add
def add(self, dic): '''adds a dict as pair Args: dic (dict): key and value ''' for kw in dic: checkKey(kw, self.keyWord) self._add([Pair(kw, StringSingle(dic[kw]))], self.d)
python
def add(self, dic): '''adds a dict as pair Args: dic (dict): key and value ''' for kw in dic: checkKey(kw, self.keyWord) self._add([Pair(kw, StringSingle(dic[kw]))], self.d)
[ "def", "add", "(", "self", ",", "dic", ")", ":", "for", "kw", "in", "dic", ":", "checkKey", "(", "kw", ",", "self", ".", "keyWord", ")", "self", ".", "_add", "(", "[", "Pair", "(", "kw", ",", "StringSingle", "(", "dic", "[", "kw", "]", ")", "...
adds a dict as pair Args: dic (dict): key and value
[ "adds", "a", "dict", "as", "pair" ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L661-L669
train
adds a dict as pair Args : dic ( dict )
casouri/launchdman
launchdman/__init__.py
SingleDictPair.remove
def remove(self, dic): '''remove the pair by passing a identical dict Args: dic (dict): key and value ''' for kw in dic: removePair = Pair(kw, dic[kw]) self._remove([removePair])
python
def remove(self, dic): '''remove the pair by passing a identical dict Args: dic (dict): key and value ''' for kw in dic: removePair = Pair(kw, dic[kw]) self._remove([removePair])
[ "def", "remove", "(", "self", ",", "dic", ")", ":", "for", "kw", "in", "dic", ":", "removePair", "=", "Pair", "(", "kw", ",", "dic", "[", "kw", "]", ")", "self", ".", "_remove", "(", "[", "removePair", "]", ")" ]
remove the pair by passing a identical dict Args: dic (dict): key and value
[ "remove", "the", "pair", "by", "passing", "a", "identical", "dict" ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L671-L679
train
remove the pair by passing a identical dict
casouri/launchdman
launchdman/__init__.py
EnvironmentVariables.changeTo
def changeTo(self, path): '''change value Args: path (str): the new environment path ''' dictionary = DictSingle(Pair('PATH', StringSingle(path))) self.value = [dictionary]
python
def changeTo(self, path): '''change value Args: path (str): the new environment path ''' dictionary = DictSingle(Pair('PATH', StringSingle(path))) self.value = [dictionary]
[ "def", "changeTo", "(", "self", ",", "path", ")", ":", "dictionary", "=", "DictSingle", "(", "Pair", "(", "'PATH'", ",", "StringSingle", "(", "path", ")", ")", ")", "self", ".", "value", "=", "[", "dictionary", "]" ]
change value Args: path (str): the new environment path
[ "change", "value" ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L746-L753
train
change value of
casouri/launchdman
launchdman/__init__.py
StartInterval._update
def _update(self, baseNumber, magnification): '''update self.value with basenumber and time interval Args: baseNumber (str): self.baseNumber magnification (str): self.magnification ''' interval = int(baseNumber * magnification) self.value = [IntegerSingle...
python
def _update(self, baseNumber, magnification): '''update self.value with basenumber and time interval Args: baseNumber (str): self.baseNumber magnification (str): self.magnification ''' interval = int(baseNumber * magnification) self.value = [IntegerSingle...
[ "def", "_update", "(", "self", ",", "baseNumber", ",", "magnification", ")", ":", "interval", "=", "int", "(", "baseNumber", "*", "magnification", ")", "self", ".", "value", "=", "[", "IntegerSingle", "(", "interval", ")", "]" ]
update self.value with basenumber and time interval Args: baseNumber (str): self.baseNumber magnification (str): self.magnification
[ "update", "self", ".", "value", "with", "basenumber", "and", "time", "interval" ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L876-L884
train
update self. value with basenumber and time interval
casouri/launchdman
launchdman/__init__.py
StartInterval.second
def second(self): '''set unit to second''' self.magnification = 1 self._update(self.baseNumber, self.magnification) return self
python
def second(self): '''set unit to second''' self.magnification = 1 self._update(self.baseNumber, self.magnification) return self
[ "def", "second", "(", "self", ")", ":", "self", ".", "magnification", "=", "1", "self", ".", "_update", "(", "self", ".", "baseNumber", ",", "self", ".", "magnification", ")", "return", "self" ]
set unit to second
[ "set", "unit", "to", "second" ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L887-L891
train
set unit to second
casouri/launchdman
launchdman/__init__.py
StartInterval.minute
def minute(self): '''set unit to minute''' self.magnification = 60 self._update(self.baseNumber, self.magnification) return self
python
def minute(self): '''set unit to minute''' self.magnification = 60 self._update(self.baseNumber, self.magnification) return self
[ "def", "minute", "(", "self", ")", ":", "self", ".", "magnification", "=", "60", "self", ".", "_update", "(", "self", ".", "baseNumber", ",", "self", ".", "magnification", ")", "return", "self" ]
set unit to minute
[ "set", "unit", "to", "minute" ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L894-L898
train
set unit to minute
casouri/launchdman
launchdman/__init__.py
StartInterval.hour
def hour(self): '''set unit to hour''' self.magnification = 3600 self._update(self.baseNumber, self.magnification) return self
python
def hour(self): '''set unit to hour''' self.magnification = 3600 self._update(self.baseNumber, self.magnification) return self
[ "def", "hour", "(", "self", ")", ":", "self", ".", "magnification", "=", "3600", "self", ".", "_update", "(", "self", ".", "baseNumber", ",", "self", ".", "magnification", ")", "return", "self" ]
set unit to hour
[ "set", "unit", "to", "hour" ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L901-L905
train
set unit to hour
casouri/launchdman
launchdman/__init__.py
StartInterval.day
def day(self): '''set unit to day''' self.magnification = 86400 self._update(self.baseNumber, self.magnification) return self
python
def day(self): '''set unit to day''' self.magnification = 86400 self._update(self.baseNumber, self.magnification) return self
[ "def", "day", "(", "self", ")", ":", "self", ".", "magnification", "=", "86400", "self", ".", "_update", "(", "self", ".", "baseNumber", ",", "self", ".", "magnification", ")", "return", "self" ]
set unit to day
[ "set", "unit", "to", "day" ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L908-L912
train
set unit to day
casouri/launchdman
launchdman/__init__.py
StartInterval.week
def week(self): '''set unit to week''' self.magnification = 345600 self._update(self.baseNumber, self.magnification) return self
python
def week(self): '''set unit to week''' self.magnification = 345600 self._update(self.baseNumber, self.magnification) return self
[ "def", "week", "(", "self", ")", ":", "self", ".", "magnification", "=", "345600", "self", ".", "_update", "(", "self", ".", "baseNumber", ",", "self", ".", "magnification", ")", "return", "self" ]
set unit to week
[ "set", "unit", "to", "week" ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L915-L919
train
set unit to week
casouri/launchdman
launchdman/__init__.py
StartCalendarInterval.add
def add(self, *dic): '''add a config to StartCalendarInterval. Args: *dic (dict): dictionary with format {'Day': 12, 'Hour': 34} Avaliable keys are Month, Day, Weekday, Hour, Minute. *Note the uppercase.* You can use gen(), genMix() to generate complex config dictionary. ''' ...
python
def add(self, *dic): '''add a config to StartCalendarInterval. Args: *dic (dict): dictionary with format {'Day': 12, 'Hour': 34} Avaliable keys are Month, Day, Weekday, Hour, Minute. *Note the uppercase.* You can use gen(), genMix() to generate complex config dictionary. ''' ...
[ "def", "add", "(", "self", ",", "*", "dic", ")", ":", "dicList", "=", "list", "(", "flatten", "(", "dic", ")", ")", "# for every dict in the list passed in", "for", "d", "in", "dicList", ":", "# make a dict single (list of pairs)", "di", "=", "[", "]", "for"...
add a config to StartCalendarInterval. Args: *dic (dict): dictionary with format {'Day': 12, 'Hour': 34} Avaliable keys are Month, Day, Weekday, Hour, Minute. *Note the uppercase.* You can use gen(), genMix() to generate complex config dictionary.
[ "add", "a", "config", "to", "StartCalendarInterval", "." ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L963-L979
train
add a config to StartCalendarInterval.
casouri/launchdman
launchdman/__init__.py
StartCalendarInterval.remove
def remove(self, *dic): '''remove a calendar config. Args: *dic (dict): dictionary with format {'Day': 12, 'Hour': 34} Avaliable keys are Month, Day, Weekday, Hour, Minute. *Note the uppercase.* You can use gen(), genMix() to generate complex config dictionary. ''' dicList =...
python
def remove(self, *dic): '''remove a calendar config. Args: *dic (dict): dictionary with format {'Day': 12, 'Hour': 34} Avaliable keys are Month, Day, Weekday, Hour, Minute. *Note the uppercase.* You can use gen(), genMix() to generate complex config dictionary. ''' dicList =...
[ "def", "remove", "(", "self", ",", "*", "dic", ")", ":", "dicList", "=", "list", "(", "flatten", "(", "dic", ")", ")", "for", "d", "in", "dicList", ":", "di", "=", "[", "]", "for", "k", "in", "d", ":", "# checkkey(k, self.keyword)", "di", ".", "a...
remove a calendar config. Args: *dic (dict): dictionary with format {'Day': 12, 'Hour': 34} Avaliable keys are Month, Day, Weekday, Hour, Minute. *Note the uppercase.* You can use gen(), genMix() to generate complex config dictionary.
[ "remove", "a", "calendar", "config", "." ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L981-L995
train
remove a calendar config.
casouri/launchdman
launchdman/__init__.py
StartCalendarInterval.gen
def gen(self, month=0, week=0, day=0, weekday=0, hour=0, minute=0): '''generate config dictionary to pass to add() or remove() Args: month (int): month in a year, from 1 to 12 week (int): week in a month, from 1 to 4 day (int): day in a month, from 1 to 31 ...
python
def gen(self, month=0, week=0, day=0, weekday=0, hour=0, minute=0): '''generate config dictionary to pass to add() or remove() Args: month (int): month in a year, from 1 to 12 week (int): week in a month, from 1 to 4 day (int): day in a month, from 1 to 31 ...
[ "def", "gen", "(", "self", ",", "month", "=", "0", ",", "week", "=", "0", ",", "day", "=", "0", ",", "weekday", "=", "0", ",", "hour", "=", "0", ",", "minute", "=", "0", ")", ":", "dic", "=", "{", "'Month'", ":", "month", ",", "'Day'", ":",...
generate config dictionary to pass to add() or remove() Args: month (int): month in a year, from 1 to 12 week (int): week in a month, from 1 to 4 day (int): day in a month, from 1 to 31 weekday (int): weekday in a week, from 0 to 7. 0 and 7 both represent Sunday ...
[ "generate", "config", "dictionary", "to", "pass", "to", "add", "()", "or", "remove", "()" ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L997-L1021
train
generate config dictionary to pass to add or remove
casouri/launchdman
launchdman/__init__.py
StartCalendarInterval.genInterval
def genInterval(self, month=(), day=(), week=(), weekday=(), hour=(), minute=()): '''Generate list of config dictionarie(s) that represent a interval of time. Used to be passed into add() or r...
python
def genInterval(self, month=(), day=(), week=(), weekday=(), hour=(), minute=()): '''Generate list of config dictionarie(s) that represent a interval of time. Used to be passed into add() or r...
[ "def", "genInterval", "(", "self", ",", "month", "=", "(", ")", ",", "day", "=", "(", ")", ",", "week", "=", "(", ")", ",", "weekday", "=", "(", ")", ",", "hour", "=", "(", ")", ",", "minute", "=", "(", ")", ")", ":", "dic", "=", "{", "'M...
Generate list of config dictionarie(s) that represent a interval of time. Used to be passed into add() or remove(). For example:: genInterval(month=(1,4), week(1,4)) # generate list contains from first to third week in from January to March Args: month (tuple): (sta...
[ "Generate", "list", "of", "config", "dictionarie", "(", "s", ")", "that", "represent", "a", "interval", "of", "time", ".", "Used", "to", "be", "passed", "into", "add", "()", "or", "remove", "()", ".", "For", "example", "::" ]
c83840e640cb075fab2534049f1e25fac6933c64
https://github.com/casouri/launchdman/blob/c83840e640cb075fab2534049f1e25fac6933c64/launchdman/__init__.py#L1062-L1111
train
Generate a list of config dictionarie s that represent a interval of time. Used to be passed into add or remove.
dmonroy/chilero
chilero/web/resource.py
Resource.get_index_url
def get_index_url(self, resource=None, **kwargs): """ Builds the url of the resource's index. :param resource: name of the resource or None :param kwargs: additional keyword arguments to build the url :return: url of the resource's index """ default_kwargs = self...
python
def get_index_url(self, resource=None, **kwargs): """ Builds the url of the resource's index. :param resource: name of the resource or None :param kwargs: additional keyword arguments to build the url :return: url of the resource's index """ default_kwargs = self...
[ "def", "get_index_url", "(", "self", ",", "resource", "=", "None", ",", "*", "*", "kwargs", ")", ":", "default_kwargs", "=", "self", ".", "default_kwargs_for_urls", "(", ")", "if", "resource", "==", "self", ".", "get_resource_name", "(", ")", "else", "{", ...
Builds the url of the resource's index. :param resource: name of the resource or None :param kwargs: additional keyword arguments to build the url :return: url of the resource's index
[ "Builds", "the", "url", "of", "the", "resource", "s", "index", "." ]
8f1118a60cb7eab3f9ad31cb8a14b30bc102893d
https://github.com/dmonroy/chilero/blob/8f1118a60cb7eab3f9ad31cb8a14b30bc102893d/chilero/web/resource.py#L40-L58
train
Builds the url of the resource s index.
dmonroy/chilero
chilero/web/resource.py
Resource.get_parent
def get_parent(self): """Returns the url to the parent endpoint.""" if self.is_entity(): return self.get_index_url(**self.default_kwargs_for_urls()) elif self._parent is not None: resource = self._parent.rsplit('_', 1)[0] parts = self.default_kwargs_for_urls()...
python
def get_parent(self): """Returns the url to the parent endpoint.""" if self.is_entity(): return self.get_index_url(**self.default_kwargs_for_urls()) elif self._parent is not None: resource = self._parent.rsplit('_', 1)[0] parts = self.default_kwargs_for_urls()...
[ "def", "get_parent", "(", "self", ")", ":", "if", "self", ".", "is_entity", "(", ")", ":", "return", "self", ".", "get_index_url", "(", "*", "*", "self", ".", "default_kwargs_for_urls", "(", ")", ")", "elif", "self", ".", "_parent", "is", "not", "None"...
Returns the url to the parent endpoint.
[ "Returns", "the", "url", "to", "the", "parent", "endpoint", "." ]
8f1118a60cb7eab3f9ad31cb8a14b30bc102893d
https://github.com/dmonroy/chilero/blob/8f1118a60cb7eab3f9ad31cb8a14b30bc102893d/chilero/web/resource.py#L143-L158
train
Returns the url to the parent endpoint.
a1ezzz/wasp-general
wasp_general/command/context.py
WContext.export_context
def export_context(cls, context): """ Export the specified context to be capable context transferring :param context: context to export :return: tuple """ if context is None: return result = [(x.context_name(), x.context_value()) for x in context] result.reverse() return tuple(result)
python
def export_context(cls, context): """ Export the specified context to be capable context transferring :param context: context to export :return: tuple """ if context is None: return result = [(x.context_name(), x.context_value()) for x in context] result.reverse() return tuple(result)
[ "def", "export_context", "(", "cls", ",", "context", ")", ":", "if", "context", "is", "None", ":", "return", "result", "=", "[", "(", "x", ".", "context_name", "(", ")", ",", "x", ".", "context_value", "(", ")", ")", "for", "x", "in", "context", "]...
Export the specified context to be capable context transferring :param context: context to export :return: tuple
[ "Export", "the", "specified", "context", "to", "be", "capable", "context", "transferring" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/command/context.py#L141-L151
train
Export the specified context to be capable context transferring
a1ezzz/wasp-general
wasp_general/command/context.py
WContext.import_context
def import_context(cls, context): """ Import context to corresponding WContextProto object (:meth:`WContext.export_context` reverse operation) :param context: context to import :return: WContext """ if context is None or len(context) == 0: return result = WContext(context[0][0], context[0][1]) for it...
python
def import_context(cls, context): """ Import context to corresponding WContextProto object (:meth:`WContext.export_context` reverse operation) :param context: context to import :return: WContext """ if context is None or len(context) == 0: return result = WContext(context[0][0], context[0][1]) for it...
[ "def", "import_context", "(", "cls", ",", "context", ")", ":", "if", "context", "is", "None", "or", "len", "(", "context", ")", "==", "0", ":", "return", "result", "=", "WContext", "(", "context", "[", "0", "]", "[", "0", "]", ",", "context", "[", ...
Import context to corresponding WContextProto object (:meth:`WContext.export_context` reverse operation) :param context: context to import :return: WContext
[ "Import", "context", "to", "corresponding", "WContextProto", "object", "(", ":", "meth", ":", "WContext", ".", "export_context", "reverse", "operation", ")" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/command/context.py#L155-L167
train
Imports context to corresponding WContextProto object
a1ezzz/wasp-general
wasp_general/command/context.py
WContext.specification
def specification(cls, *context_specs): """ Return linked context as adapter specification (is used by :class:`.WCommandContextAdapter`) :param context_specs: context names :return: WContext """ import_data = [] for name in context_specs: import_data.append((name, None)) return cls.import_context(impo...
python
def specification(cls, *context_specs): """ Return linked context as adapter specification (is used by :class:`.WCommandContextAdapter`) :param context_specs: context names :return: WContext """ import_data = [] for name in context_specs: import_data.append((name, None)) return cls.import_context(impo...
[ "def", "specification", "(", "cls", ",", "*", "context_specs", ")", ":", "import_data", "=", "[", "]", "for", "name", "in", "context_specs", ":", "import_data", ".", "append", "(", "(", "name", ",", "None", ")", ")", "return", "cls", ".", "import_context...
Return linked context as adapter specification (is used by :class:`.WCommandContextAdapter`) :param context_specs: context names :return: WContext
[ "Return", "linked", "context", "as", "adapter", "specification", "(", "is", "used", "by", ":", "class", ":", ".", "WCommandContextAdapter", ")" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/command/context.py#L171-L180
train
Return linked context as adapter specification
a1ezzz/wasp-general
wasp_general/command/context.py
WCommandContextAdapter.match
def match(self, command_context=None, **command_env): """ Check if context request is compatible with adapters specification. True - if compatible, False - otherwise :param command_context: context to check :param command_env: command environment :return: bool """ spec = self.specification() if command...
python
def match(self, command_context=None, **command_env): """ Check if context request is compatible with adapters specification. True - if compatible, False - otherwise :param command_context: context to check :param command_env: command environment :return: bool """ spec = self.specification() if command...
[ "def", "match", "(", "self", ",", "command_context", "=", "None", ",", "*", "*", "command_env", ")", ":", "spec", "=", "self", ".", "specification", "(", ")", "if", "command_context", "is", "None", "and", "spec", "is", "None", ":", "return", "True", "e...
Check if context request is compatible with adapters specification. True - if compatible, False - otherwise :param command_context: context to check :param command_env: command environment :return: bool
[ "Check", "if", "context", "request", "is", "compatible", "with", "adapters", "specification", ".", "True", "-", "if", "compatible", "False", "-", "otherwise" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/command/context.py#L214-L227
train
Check if context request is compatible with adapters specification.
a1ezzz/wasp-general
wasp_general/command/context.py
WCommandContext.match
def match(self, *command_tokens, command_context=None, **command_env): """ Match command :param command_tokens: command tokens to check :param command_context: command context :param command_env: command environment :return: bool """ if self.adapter().match(command_context, **command_env) is False: re...
python
def match(self, *command_tokens, command_context=None, **command_env): """ Match command :param command_tokens: command tokens to check :param command_context: command context :param command_env: command environment :return: bool """ if self.adapter().match(command_context, **command_env) is False: re...
[ "def", "match", "(", "self", ",", "*", "command_tokens", ",", "command_context", "=", "None", ",", "*", "*", "command_env", ")", ":", "if", "self", ".", "adapter", "(", ")", ".", "match", "(", "command_context", ",", "*", "*", "command_env", ")", "is",...
Match command :param command_tokens: command tokens to check :param command_context: command context :param command_env: command environment :return: bool
[ "Match", "command" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/command/context.py#L272-L284
train
Match command.
a1ezzz/wasp-general
wasp_general/command/context.py
WCommandContext.exec
def exec(self, *command_tokens, command_context=None, **command_env): """ Execute command :param command_tokens: command tokens to execute :param command_context: command context :param command_env: command environment :return: WCommandResultProto """ if self.adapter().match(command_context, **command_en...
python
def exec(self, *command_tokens, command_context=None, **command_env): """ Execute command :param command_tokens: command tokens to execute :param command_context: command context :param command_env: command environment :return: WCommandResultProto """ if self.adapter().match(command_context, **command_en...
[ "def", "exec", "(", "self", ",", "*", "command_tokens", ",", "command_context", "=", "None", ",", "*", "*", "command_env", ")", ":", "if", "self", ".", "adapter", "(", ")", ".", "match", "(", "command_context", ",", "*", "*", "command_env", ")", "is", ...
Execute command :param command_tokens: command tokens to execute :param command_context: command context :param command_env: command environment :return: WCommandResultProto
[ "Execute", "command" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/command/context.py#L287-L305
train
Execute command in command context
projectshift/shift-schema
shiftschema/validators/not_empty.py
NotEmpty.validate
def validate(self, value, model=None, context=None): """ Validate Perform value validation and return result :param value: value to check :param model: parent model being validated :param context: object or None, validation context :re...
python
def validate(self, value, model=None, context=None): """ Validate Perform value validation and return result :param value: value to check :param model: parent model being validated :param context: object or None, validation context :re...
[ "def", "validate", "(", "self", ",", "value", ",", "model", "=", "None", ",", "context", "=", "None", ")", ":", "if", "not", "isinstance", "(", "value", ",", "Iterable", ")", ":", "return", "Error", "(", "self", ".", "not_iterable", ")", "try", ":", ...
Validate Perform value validation and return result :param value: value to check :param model: parent model being validated :param context: object or None, validation context :return: shiftschema.results.Error
[ "Validate", "Perform", "value", "validation", "and", "return", "result" ]
07787b540d3369bb37217ffbfbe629118edaf0eb
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/validators/not_empty.py#L26-L45
train
Validate the value of the key field.
OpenGov/og-python-utils
ogutils/collections/checks.py
any_shared
def any_shared(enum_one, enum_two): ''' Truthy if any element in enum_one is present in enum_two ''' if not is_collection(enum_one) or not is_collection(enum_two): return False enum_one = enum_one if isinstance(enum_one, (set, dict)) else set(enum_one) enum_two = enum_two if isins...
python
def any_shared(enum_one, enum_two): ''' Truthy if any element in enum_one is present in enum_two ''' if not is_collection(enum_one) or not is_collection(enum_two): return False enum_one = enum_one if isinstance(enum_one, (set, dict)) else set(enum_one) enum_two = enum_two if isins...
[ "def", "any_shared", "(", "enum_one", ",", "enum_two", ")", ":", "if", "not", "is_collection", "(", "enum_one", ")", "or", "not", "is_collection", "(", "enum_two", ")", ":", "return", "False", "enum_one", "=", "enum_one", "if", "isinstance", "(", "enum_one",...
Truthy if any element in enum_one is present in enum_two
[ "Truthy", "if", "any", "element", "in", "enum_one", "is", "present", "in", "enum_two" ]
00f44927383dd1bd6348f47302c4453d56963479
https://github.com/OpenGov/og-python-utils/blob/00f44927383dd1bd6348f47302c4453d56963479/ogutils/collections/checks.py#L13-L21
train
Truthy if any element in enum_one is present in enum_two
a1ezzz/wasp-general
wasp_general/network/web/service.py
WSimpleErrorPresenter.error_code
def error_code(self, code): """ :meth:`.WWebErrorPresenter.error_code` method implementation """ return WWebResponse( status=code, headers=WHTTPHeaders(**{'Content-Type': 'text/plain; charset=utf-8'}), response_data=self.__message__(code).encode() )
python
def error_code(self, code): """ :meth:`.WWebErrorPresenter.error_code` method implementation """ return WWebResponse( status=code, headers=WHTTPHeaders(**{'Content-Type': 'text/plain; charset=utf-8'}), response_data=self.__message__(code).encode() )
[ "def", "error_code", "(", "self", ",", "code", ")", ":", "return", "WWebResponse", "(", "status", "=", "code", ",", "headers", "=", "WHTTPHeaders", "(", "*", "*", "{", "'Content-Type'", ":", "'text/plain; charset=utf-8'", "}", ")", ",", "response_data", "=",...
:meth:`.WWebErrorPresenter.error_code` method implementation
[ ":", "meth", ":", ".", "WWebErrorPresenter", ".", "error_code", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/service.py#L67-L74
train
:meth:`WWebErrorPresenter. error_code` method implementation
a1ezzz/wasp-general
wasp_general/network/web/service.py
WWebRoute.normalize_uri
def normalize_uri(cls, uri): """ Normalize the given URI (removes extra slashes) :param uri: uri to normalize :return: str """ uri = WWebRoute.multiple_slashes_re.sub("/", uri) # remove last slash if len(uri) > 1: if uri[-1] == '/': uri = uri[:-1] return uri
python
def normalize_uri(cls, uri): """ Normalize the given URI (removes extra slashes) :param uri: uri to normalize :return: str """ uri = WWebRoute.multiple_slashes_re.sub("/", uri) # remove last slash if len(uri) > 1: if uri[-1] == '/': uri = uri[:-1] return uri
[ "def", "normalize_uri", "(", "cls", ",", "uri", ")", ":", "uri", "=", "WWebRoute", ".", "multiple_slashes_re", ".", "sub", "(", "\"/\"", ",", "uri", ")", "# remove last slash", "if", "len", "(", "uri", ")", ">", "1", ":", "if", "uri", "[", "-", "1", ...
Normalize the given URI (removes extra slashes) :param uri: uri to normalize :return: str
[ "Normalize", "the", "given", "URI", "(", "removes", "extra", "slashes", ")" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/service.py#L322-L335
train
Normalizes the given URI
a1ezzz/wasp-general
wasp_general/network/web/service.py
WWebRoute.match
def match(self, request, service): """ Check this route for matching the given request. If this route is matched, then target route is returned. :param request: request to match :param service: source service :return: WWebTargetRoute or None """ uri = self.normalize_uri(request.path()) if request.sess...
python
def match(self, request, service): """ Check this route for matching the given request. If this route is matched, then target route is returned. :param request: request to match :param service: source service :return: WWebTargetRoute or None """ uri = self.normalize_uri(request.path()) if request.sess...
[ "def", "match", "(", "self", ",", "request", ",", "service", ")", ":", "uri", "=", "self", ".", "normalize_uri", "(", "request", ".", "path", "(", ")", ")", "if", "request", ".", "session", "(", ")", ".", "protocol", "(", ")", "not", "in", "self", ...
Check this route for matching the given request. If this route is matched, then target route is returned. :param request: request to match :param service: source service :return: WWebTargetRoute or None
[ "Check", "this", "route", "for", "matching", "the", "given", "request", ".", "If", "this", "route", "is", "matched", "then", "target", "route", "is", "returned", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/service.py#L338-L374
train
Check this route for matching the given request.
a1ezzz/wasp-general
wasp_general/network/web/service.py
WWebRoute.url_for
def url_for(self, **kwargs): """ Generate url for client with specified route arguments. For the source route '/page/{page_index}' this method must be called with 'page_index' parameter (for '3' as 'page_index' parameter result will be '/page/3' for 'foo_bar' - '/page/foo_bar'). If 'host', 'protocol' and 'ports' ...
python
def url_for(self, **kwargs): """ Generate url for client with specified route arguments. For the source route '/page/{page_index}' this method must be called with 'page_index' parameter (for '3' as 'page_index' parameter result will be '/page/3' for 'foo_bar' - '/page/foo_bar'). If 'host', 'protocol' and 'ports' ...
[ "def", "url_for", "(", "self", ",", "*", "*", "kwargs", ")", ":", "host", "=", "self", ".", "virtual_hosts", "[", "0", "]", "if", "self", ".", "virtual_hosts", "is", "not", "None", "and", "len", "(", "self", ".", "virtual_hosts", ")", "==", "1", "e...
Generate url for client with specified route arguments. For the source route '/page/{page_index}' this method must be called with 'page_index' parameter (for '3' as 'page_index' parameter result will be '/page/3' for 'foo_bar' - '/page/foo_bar'). If 'host', 'protocol' and 'ports' are set as single element list or...
[ "Generate", "url", "for", "client", "with", "specified", "route", "arguments", ".", "For", "the", "source", "route", "/", "page", "/", "{", "page_index", "}", "this", "method", "must", "be", "called", "with", "page_index", "parameter", "(", "for", "3", "as...
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/service.py#L376-L438
train
Generate url for client with specified route arguments.
a1ezzz/wasp-general
wasp_general/network/web/service.py
WWebRouteMap.route
def route(self, request, service): """ :meth:`.WWebRouteMapProto.route` method implementation """ for route in self.__routes: result = route.match(request, service) if result is not None: if self.target_route_valid(result) is True: return result
python
def route(self, request, service): """ :meth:`.WWebRouteMapProto.route` method implementation """ for route in self.__routes: result = route.match(request, service) if result is not None: if self.target_route_valid(result) is True: return result
[ "def", "route", "(", "self", ",", "request", ",", "service", ")", ":", "for", "route", "in", "self", ".", "__routes", ":", "result", "=", "route", ".", "match", "(", "request", ",", "service", ")", "if", "result", "is", "not", "None", ":", "if", "s...
:meth:`.WWebRouteMapProto.route` method implementation
[ ":", "meth", ":", ".", "WWebRouteMapProto", ".", "route", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/service.py#L516-L523
train
method implementation . route
a1ezzz/wasp-general
wasp_general/network/web/service.py
WWebRouteMap.connect
def connect(self, pattern, presenter, **kwargs): """ Connect the given pattern with the given presenter :param pattern: URI pattern :param presenter: target presenter name :param kwargs: route arguments (see :class:`.WWebRoute`) :return: None """ self.__routes.append(WWebRoute(pattern, presenter, **kwarg...
python
def connect(self, pattern, presenter, **kwargs): """ Connect the given pattern with the given presenter :param pattern: URI pattern :param presenter: target presenter name :param kwargs: route arguments (see :class:`.WWebRoute`) :return: None """ self.__routes.append(WWebRoute(pattern, presenter, **kwarg...
[ "def", "connect", "(", "self", ",", "pattern", ",", "presenter", ",", "*", "*", "kwargs", ")", ":", "self", ".", "__routes", ".", "append", "(", "WWebRoute", "(", "pattern", ",", "presenter", ",", "*", "*", "kwargs", ")", ")" ]
Connect the given pattern with the given presenter :param pattern: URI pattern :param presenter: target presenter name :param kwargs: route arguments (see :class:`.WWebRoute`) :return: None
[ "Connect", "the", "given", "pattern", "with", "the", "given", "presenter" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/service.py#L540-L548
train
Connect the given pattern with the given presenter.
a1ezzz/wasp-general
wasp_general/network/web/service.py
WWebRouteMap.import_route
def import_route(self, route_as_txt): """ Import route written as a string :param route_as_txt: single string (single route) to import :return: None """ route_match = WWebRouteMap.import_route_re.match(route_as_txt) if route_match is None: raise ValueError('Invalid route code') pattern = route_match....
python
def import_route(self, route_as_txt): """ Import route written as a string :param route_as_txt: single string (single route) to import :return: None """ route_match = WWebRouteMap.import_route_re.match(route_as_txt) if route_match is None: raise ValueError('Invalid route code') pattern = route_match....
[ "def", "import_route", "(", "self", ",", "route_as_txt", ")", ":", "route_match", "=", "WWebRouteMap", ".", "import_route_re", ".", "match", "(", "route_as_txt", ")", "if", "route_match", "is", "None", ":", "raise", "ValueError", "(", "'Invalid route code'", ")"...
Import route written as a string :param route_as_txt: single string (single route) to import :return: None
[ "Import", "route", "written", "as", "a", "string" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/service.py#L561-L585
train
Import route written as a string
a1ezzz/wasp-general
wasp_general/network/web/service.py
WSimplePresenterCollection.presenter
def presenter(self, presenter_name): """ :meth:`.WWebPresenterCollectionProto.presenter` method implementation """ if presenter_name in self.__presenters.keys(): return self.__presenters[presenter_name]
python
def presenter(self, presenter_name): """ :meth:`.WWebPresenterCollectionProto.presenter` method implementation """ if presenter_name in self.__presenters.keys(): return self.__presenters[presenter_name]
[ "def", "presenter", "(", "self", ",", "presenter_name", ")", ":", "if", "presenter_name", "in", "self", ".", "__presenters", ".", "keys", "(", ")", ":", "return", "self", ".", "__presenters", "[", "presenter_name", "]" ]
:meth:`.WWebPresenterCollectionProto.presenter` method implementation
[ ":", "meth", ":", ".", "WWebPresenterCollectionProto", ".", "presenter", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/service.py#L611-L615
train
returns the presenter with the given name
a1ezzz/wasp-general
wasp_general/network/web/service.py
WWebService.process_request
def process_request(self, session): """ Process single request from the given session :param session: session for reading requests and writing responses :return: None """ debugger = self.debugger() debugger_session_id = debugger.session_id() if debugger is not None else None try: request = session.r...
python
def process_request(self, session): """ Process single request from the given session :param session: session for reading requests and writing responses :return: None """ debugger = self.debugger() debugger_session_id = debugger.session_id() if debugger is not None else None try: request = session.r...
[ "def", "process_request", "(", "self", ",", "session", ")", ":", "debugger", "=", "self", ".", "debugger", "(", ")", "debugger_session_id", "=", "debugger", ".", "session_id", "(", ")", "if", "debugger", "is", "not", "None", "else", "None", "try", ":", "...
Process single request from the given session :param session: session for reading requests and writing responses :return: None
[ "Process", "single", "request", "from", "the", "given", "session" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/service.py#L670-L718
train
Process a single request from the given session and return the response.
a1ezzz/wasp-general
wasp_general/network/web/service.py
WWebService.create_presenter
def create_presenter(self, request, target_route): """ Create presenter from the given requests and target routes :param request: client request :param target_route: route to use :return: WWebPresenter """ presenter_name = target_route.presenter_name() if self.presenter_collection().has(presenter_name) i...
python
def create_presenter(self, request, target_route): """ Create presenter from the given requests and target routes :param request: client request :param target_route: route to use :return: WWebPresenter """ presenter_name = target_route.presenter_name() if self.presenter_collection().has(presenter_name) i...
[ "def", "create_presenter", "(", "self", ",", "request", ",", "target_route", ")", ":", "presenter_name", "=", "target_route", ".", "presenter_name", "(", ")", "if", "self", ".", "presenter_collection", "(", ")", ".", "has", "(", "presenter_name", ")", "is", ...
Create presenter from the given requests and target routes :param request: client request :param target_route: route to use :return: WWebPresenter
[ "Create", "presenter", "from", "the", "given", "requests", "and", "target", "routes" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/service.py#L721-L732
train
Create a new presenter from the given requests and target routes.
a1ezzz/wasp-general
wasp_general/network/web/service.py
WWebService.execute
def execute(self, request, target_route): """ :meth:`.WWebServiceProto.execute` method implementation """ presenter = self.create_presenter(request, target_route) presenter_name = target_route.presenter_name() action_name = target_route.presenter_action() presenter_args = target_route.presenter_args() if...
python
def execute(self, request, target_route): """ :meth:`.WWebServiceProto.execute` method implementation """ presenter = self.create_presenter(request, target_route) presenter_name = target_route.presenter_name() action_name = target_route.presenter_action() presenter_args = target_route.presenter_args() if...
[ "def", "execute", "(", "self", ",", "request", ",", "target_route", ")", ":", "presenter", "=", "self", ".", "create_presenter", "(", "request", ",", "target_route", ")", "presenter_name", "=", "target_route", ".", "presenter_name", "(", ")", "action_name", "=...
:meth:`.WWebServiceProto.execute` method implementation
[ ":", "meth", ":", ".", "WWebServiceProto", ".", "execute", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/service.py#L735-L769
train
method implementation
a1ezzz/wasp-general
wasp_general/network/web/service.py
WWebService.connect
def connect(self, pattern, presenter, **kwargs): """ Shortcut for self.route_map().connect() method. It is possible to pass presenter class instead of its name - in that case such class will be saved in presenter collection and it will be available in route matching. :param pattern: same as pattern in :meth:`....
python
def connect(self, pattern, presenter, **kwargs): """ Shortcut for self.route_map().connect() method. It is possible to pass presenter class instead of its name - in that case such class will be saved in presenter collection and it will be available in route matching. :param pattern: same as pattern in :meth:`....
[ "def", "connect", "(", "self", ",", "pattern", ",", "presenter", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "presenter", ",", "type", ")", "and", "issubclass", "(", "presenter", ",", "WWebPresenter", ")", "is", "True", ":", "self", "."...
Shortcut for self.route_map().connect() method. It is possible to pass presenter class instead of its name - in that case such class will be saved in presenter collection and it will be available in route matching. :param pattern: same as pattern in :meth:`.WWebRouteMap.connect` method :param presenter: presen...
[ "Shortcut", "for", "self", ".", "route_map", "()", ".", "connect", "()", "method", ".", "It", "is", "possible", "to", "pass", "presenter", "class", "instead", "of", "its", "name", "-", "in", "that", "case", "such", "class", "will", "be", "saved", "in", ...
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/service.py#L773-L786
train
Shortcut for route_map. connect method.
a1ezzz/wasp-general
wasp_general/network/web/service.py
WWebService.add_presenter
def add_presenter(self, presenter): """ Add presenter to a collection. If the given presenter is a :class:`.WWebEnhancedPresenter` instance then public routes are checked (via :meth:`..WWebEnhancedPresenter.__public_routes__` method) and are added in this route map :param presenter: presenter to add :return:...
python
def add_presenter(self, presenter): """ Add presenter to a collection. If the given presenter is a :class:`.WWebEnhancedPresenter` instance then public routes are checked (via :meth:`..WWebEnhancedPresenter.__public_routes__` method) and are added in this route map :param presenter: presenter to add :return:...
[ "def", "add_presenter", "(", "self", ",", "presenter", ")", ":", "self", ".", "__presenter_collection", ".", "add", "(", "presenter", ")", "if", "issubclass", "(", "presenter", ",", "WWebEnhancedPresenter", ")", "is", "True", ":", "for", "route", "in", "pres...
Add presenter to a collection. If the given presenter is a :class:`.WWebEnhancedPresenter` instance then public routes are checked (via :meth:`..WWebEnhancedPresenter.__public_routes__` method) and are added in this route map :param presenter: presenter to add :return: None
[ "Add", "presenter", "to", "a", "collection", ".", "If", "the", "given", "presenter", "is", "a", ":", "class", ":", ".", "WWebEnhancedPresenter", "instance", "then", "public", "routes", "are", "checked", "(", "via", ":", "meth", ":", "..", "WWebEnhancedPresen...
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/service.py#L789-L800
train
Adds a presenter to the collection.
a1ezzz/wasp-general
wasp_general/network/web/service.py
WWebService.proxy
def proxy(self, request, original_target_route, presenter_name, **kwargs): """ Execute the given presenter as a target for the given client request :param request: original client request :param original_target_route: previous target route :param presenter_name: target presenter name :param kwargs: presenter...
python
def proxy(self, request, original_target_route, presenter_name, **kwargs): """ Execute the given presenter as a target for the given client request :param request: original client request :param original_target_route: previous target route :param presenter_name: target presenter name :param kwargs: presenter...
[ "def", "proxy", "(", "self", ",", "request", ",", "original_target_route", ",", "presenter_name", ",", "*", "*", "kwargs", ")", ":", "action_kwargs", "=", "kwargs", ".", "copy", "(", ")", "action_name", "=", "'index'", "if", "'action'", "in", "action_kwargs"...
Execute the given presenter as a target for the given client request :param request: original client request :param original_target_route: previous target route :param presenter_name: target presenter name :param kwargs: presenter arguments :return: WWebResponseProto
[ "Execute", "the", "given", "presenter", "as", "a", "target", "for", "the", "given", "client", "request" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/service.py#L804-L825
train
Execute the given presenter as a target for the given client request.
a1ezzz/wasp-general
wasp_general/network/web/service.py
WWebPresenterFactory.instantiate
def instantiate(self, presenter_class, request, target_route, service, *args, **kwargs): """ :meth:`.WWebPresenterFactoryProto.instantiate` method implementation. Construct new presenter or raise en exception if it isn't possible. :param presenter_class: class to construct :param request: original client requ...
python
def instantiate(self, presenter_class, request, target_route, service, *args, **kwargs): """ :meth:`.WWebPresenterFactoryProto.instantiate` method implementation. Construct new presenter or raise en exception if it isn't possible. :param presenter_class: class to construct :param request: original client requ...
[ "def", "instantiate", "(", "self", ",", "presenter_class", ",", "request", ",", "target_route", ",", "service", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "instantiable", "(", "presenter_class", ")", "is", "False", ":", "rais...
:meth:`.WWebPresenterFactoryProto.instantiate` method implementation. Construct new presenter or raise en exception if it isn't possible. :param presenter_class: class to construct :param request: original client request :param target_route: target route to execute :param service: source (parent) service ...
[ ":", "meth", ":", ".", "WWebPresenterFactoryProto", ".", "instantiate", "method", "implementation", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/network/web/service.py#L941-L956
train
method implementation. instantiate
shaypal5/strct
strct/sortedlists/sortedlist.py
find_point_in_section_list
def find_point_in_section_list(point, section_list): """Returns the start of the section the given point belongs to. The given list is assumed to contain start points of consecutive sections, except for the final point, assumed to be the end point of the last section. For example, the list [5, 8, 30, 3...
python
def find_point_in_section_list(point, section_list): """Returns the start of the section the given point belongs to. The given list is assumed to contain start points of consecutive sections, except for the final point, assumed to be the end point of the last section. For example, the list [5, 8, 30, 3...
[ "def", "find_point_in_section_list", "(", "point", ",", "section_list", ")", ":", "if", "point", "<", "section_list", "[", "0", "]", "or", "point", ">", "section_list", "[", "-", "1", "]", ":", "return", "None", "if", "point", "in", "section_list", ":", ...
Returns the start of the section the given point belongs to. The given list is assumed to contain start points of consecutive sections, except for the final point, assumed to be the end point of the last section. For example, the list [5, 8, 30, 31] is interpreted as the following list of sections: [5-...
[ "Returns", "the", "start", "of", "the", "section", "the", "given", "point", "belongs", "to", "." ]
f3a301692d052ddb79331230b3c00625db1d83fc
https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/sortedlists/sortedlist.py#L4-L53
train
Returns the start of the section the given point belongs to.
shaypal5/strct
strct/sortedlists/sortedlist.py
find_range_ix_in_section_list
def find_range_ix_in_section_list(start, end, section_list): """Returns the index range all sections belonging to the given range. The given list is assumed to contain start points of consecutive sections, except for the final point, assumed to be the end point of the last section. For example, the lis...
python
def find_range_ix_in_section_list(start, end, section_list): """Returns the index range all sections belonging to the given range. The given list is assumed to contain start points of consecutive sections, except for the final point, assumed to be the end point of the last section. For example, the lis...
[ "def", "find_range_ix_in_section_list", "(", "start", ",", "end", ",", "section_list", ")", ":", "if", "start", ">", "section_list", "[", "-", "1", "]", "or", "end", "<", "section_list", "[", "0", "]", ":", "return", "[", "0", ",", "0", "]", "if", "s...
Returns the index range all sections belonging to the given range. The given list is assumed to contain start points of consecutive sections, except for the final point, assumed to be the end point of the last section. For example, the list [5, 8, 30, 31] is interpreted as the following list of section...
[ "Returns", "the", "index", "range", "all", "sections", "belonging", "to", "the", "given", "range", "." ]
f3a301692d052ddb79331230b3c00625db1d83fc
https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/sortedlists/sortedlist.py#L56-L107
train
Returns the index range all sections belonging to the given range.
shaypal5/strct
strct/sortedlists/sortedlist.py
find_range_in_section_list
def find_range_in_section_list(start, end, section_list): """Returns all sections belonging to the given range. The given list is assumed to contain start points of consecutive sections, except for the final point, assumed to be the end point of the last section. For example, the list [5, 8, 30, 31] is...
python
def find_range_in_section_list(start, end, section_list): """Returns all sections belonging to the given range. The given list is assumed to contain start points of consecutive sections, except for the final point, assumed to be the end point of the last section. For example, the list [5, 8, 30, 31] is...
[ "def", "find_range_in_section_list", "(", "start", ",", "end", ",", "section_list", ")", ":", "ind", "=", "find_range_ix_in_section_list", "(", "start", ",", "end", ",", "section_list", ")", "return", "section_list", "[", "ind", "[", "0", "]", ":", "ind", "[...
Returns all sections belonging to the given range. The given list is assumed to contain start points of consecutive sections, except for the final point, assumed to be the end point of the last section. For example, the list [5, 8, 30, 31] is interpreted as the following list of sections: [5-8), [8-30)...
[ "Returns", "all", "sections", "belonging", "to", "the", "given", "range", "." ]
f3a301692d052ddb79331230b3c00625db1d83fc
https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/sortedlists/sortedlist.py#L110-L151
train
This function returns all sections belonging to the given range.
shaypal5/strct
strct/sortedlists/sortedlist.py
find_range_ix_in_point_list
def find_range_ix_in_point_list(start, end, point_list): """Returns the index range all points inside the given range. Parameters --------- start : float The start of the desired range. end : float The end of the desired range. point_list : sortedcontainers.SortedList A ...
python
def find_range_ix_in_point_list(start, end, point_list): """Returns the index range all points inside the given range. Parameters --------- start : float The start of the desired range. end : float The end of the desired range. point_list : sortedcontainers.SortedList A ...
[ "def", "find_range_ix_in_point_list", "(", "start", ",", "end", ",", "point_list", ")", ":", "return", "[", "point_list", ".", "bisect_left", "(", "start", ")", ",", "point_list", ".", "bisect_right", "(", "end", ")", "]" ]
Returns the index range all points inside the given range. Parameters --------- start : float The start of the desired range. end : float The end of the desired range. point_list : sortedcontainers.SortedList A list of points. Returns ------- iterable Th...
[ "Returns", "the", "index", "range", "all", "points", "inside", "the", "given", "range", "." ]
f3a301692d052ddb79331230b3c00625db1d83fc
https://github.com/shaypal5/strct/blob/f3a301692d052ddb79331230b3c00625db1d83fc/strct/sortedlists/sortedlist.py#L154-L188
train
Returns the index range all points inside the given range.
a1ezzz/wasp-general
wasp_general/config.py
WConfig.merge
def merge(self, config): """ Load configuration from given configuration. :param config: config to load. If config is a string type, then it's treated as .ini filename :return: None """ if isinstance(config, ConfigParser) is True: self.update(config) elif isinstance(config, str): self.read(config)
python
def merge(self, config): """ Load configuration from given configuration. :param config: config to load. If config is a string type, then it's treated as .ini filename :return: None """ if isinstance(config, ConfigParser) is True: self.update(config) elif isinstance(config, str): self.read(config)
[ "def", "merge", "(", "self", ",", "config", ")", ":", "if", "isinstance", "(", "config", ",", "ConfigParser", ")", "is", "True", ":", "self", ".", "update", "(", "config", ")", "elif", "isinstance", "(", "config", ",", "str", ")", ":", "self", ".", ...
Load configuration from given configuration. :param config: config to load. If config is a string type, then it's treated as .ini filename :return: None
[ "Load", "configuration", "from", "given", "configuration", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/config.py#L54-L63
train
Load configuration from given configuration.
a1ezzz/wasp-general
wasp_general/config.py
WConfig.merge_section
def merge_section(self, config, section_to, section_from=None): """ Load configuration section from other configuration. If specified section doesn't exist in current configuration, then it will be added automatically. :param config: source configuration :param section_to: destination section name :param sec...
python
def merge_section(self, config, section_to, section_from=None): """ Load configuration section from other configuration. If specified section doesn't exist in current configuration, then it will be added automatically. :param config: source configuration :param section_to: destination section name :param sec...
[ "def", "merge_section", "(", "self", ",", "config", ",", "section_to", ",", "section_from", "=", "None", ")", ":", "section_from", "=", "section_from", "if", "section_from", "is", "not", "None", "else", "section_to", "if", "section_from", "not", "in", "config"...
Load configuration section from other configuration. If specified section doesn't exist in current configuration, then it will be added automatically. :param config: source configuration :param section_to: destination section name :param section_from: source section name (if it is None, then section_to is used...
[ "Load", "configuration", "section", "from", "other", "configuration", ".", "If", "specified", "section", "doesn", "t", "exist", "in", "current", "configuration", "then", "it", "will", "be", "added", "automatically", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/config.py#L66-L83
train
Load configuration section from other configuration.
a1ezzz/wasp-general
wasp_general/config.py
WConfigSelection.__option
def __option(self): """ Check and return option from section from configuration. Option name is equal to option prefix :return: tuple of section name and option prefix """ section = self.section() option = self.option_prefix() if self.config().has_option(section, option) is False: raise NoOptionError(op...
python
def __option(self): """ Check and return option from section from configuration. Option name is equal to option prefix :return: tuple of section name and option prefix """ section = self.section() option = self.option_prefix() if self.config().has_option(section, option) is False: raise NoOptionError(op...
[ "def", "__option", "(", "self", ")", ":", "section", "=", "self", ".", "section", "(", ")", "option", "=", "self", ".", "option_prefix", "(", ")", "if", "self", ".", "config", "(", ")", ".", "has_option", "(", "section", ",", "option", ")", "is", "...
Check and return option from section from configuration. Option name is equal to option prefix :return: tuple of section name and option prefix
[ "Check", "and", "return", "option", "from", "section", "from", "configuration", ".", "Option", "name", "is", "equal", "to", "option", "prefix" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/config.py#L139-L148
train
Check and return option from section from configuration.
a1ezzz/wasp-general
wasp_general/config.py
WConfigSelection.select_options
def select_options(self, options_prefix): """ Select options from this selection, that are started with the specified prefix :param options_prefix: name prefix of options that should be selected :return: WConfigSelection """ return WConfigSelection( self.config(), self.section(), self.option_prefix() + op...
python
def select_options(self, options_prefix): """ Select options from this selection, that are started with the specified prefix :param options_prefix: name prefix of options that should be selected :return: WConfigSelection """ return WConfigSelection( self.config(), self.section(), self.option_prefix() + op...
[ "def", "select_options", "(", "self", ",", "options_prefix", ")", ":", "return", "WConfigSelection", "(", "self", ".", "config", "(", ")", ",", "self", ".", "section", "(", ")", ",", "self", ".", "option_prefix", "(", ")", "+", "options_prefix", ")" ]
Select options from this selection, that are started with the specified prefix :param options_prefix: name prefix of options that should be selected :return: WConfigSelection
[ "Select", "options", "from", "this", "selection", "that", "are", "started", "with", "the", "specified", "prefix" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/config.py#L184-L192
train
Select options from this selection that are started with the specified prefix
a1ezzz/wasp-general
wasp_general/config.py
WConfigSelection.has_option
def has_option(self, option_name=None): """ Check whether configuration selection has the specified option. :param option_name: option name to check. If no option is specified, then check is made for this option :return: bool """ if option_name is None: option_name = '' return self.config().has_option(...
python
def has_option(self, option_name=None): """ Check whether configuration selection has the specified option. :param option_name: option name to check. If no option is specified, then check is made for this option :return: bool """ if option_name is None: option_name = '' return self.config().has_option(...
[ "def", "has_option", "(", "self", ",", "option_name", "=", "None", ")", ":", "if", "option_name", "is", "None", ":", "option_name", "=", "''", "return", "self", ".", "config", "(", ")", ".", "has_option", "(", "self", ".", "section", "(", ")", ",", "...
Check whether configuration selection has the specified option. :param option_name: option name to check. If no option is specified, then check is made for this option :return: bool
[ "Check", "whether", "configuration", "selection", "has", "the", "specified", "option", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/config.py#L205-L214
train
Check whether the configuration selection has the specified option.
a1ezzz/wasp-general
wasp_general/verify.py
Verifier.decorate_disabled
def decorate_disabled(self): """ Return True if this decoration must be omitted, otherwise - False. This class searches for tags values in environment variable (:attr:`.Verifier.__environment_var__`), Derived class can implement any logic :return: bool """ if len(self._tags) == 0: return False if sel...
python
def decorate_disabled(self): """ Return True if this decoration must be omitted, otherwise - False. This class searches for tags values in environment variable (:attr:`.Verifier.__environment_var__`), Derived class can implement any logic :return: bool """ if len(self._tags) == 0: return False if sel...
[ "def", "decorate_disabled", "(", "self", ")", ":", "if", "len", "(", "self", ".", "_tags", ")", "==", "0", ":", "return", "False", "if", "self", ".", "_env_var", "not", "in", "os", ".", "environ", ":", "return", "True", "env_tags", "=", "os", ".", ...
Return True if this decoration must be omitted, otherwise - False. This class searches for tags values in environment variable (:attr:`.Verifier.__environment_var__`), Derived class can implement any logic :return: bool
[ "Return", "True", "if", "this", "decoration", "must", "be", "omitted", "otherwise", "-", "False", ".", "This", "class", "searches", "for", "tags", "values", "in", "environment", "variable", "(", ":", "attr", ":", ".", "Verifier", ".", "__environment_var__", ...
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/verify.py#L85-L105
train
Return True if this decoration must be omitted otherwise - False. This class searches for tags values in environment variable (:attr :. Verifier. __environment_var__
a1ezzz/wasp-general
wasp_general/verify.py
Verifier._args_checks_gen
def _args_checks_gen(self, decorated_function, function_spec, arg_specs): """ Generate checks for positional argument testing :param decorated_function: function decorator :param function_spec: function inspect information :param arg_specs: argument specification (same as arg_specs in :meth:`.Verifier.decorate...
python
def _args_checks_gen(self, decorated_function, function_spec, arg_specs): """ Generate checks for positional argument testing :param decorated_function: function decorator :param function_spec: function inspect information :param arg_specs: argument specification (same as arg_specs in :meth:`.Verifier.decorate...
[ "def", "_args_checks_gen", "(", "self", ",", "decorated_function", ",", "function_spec", ",", "arg_specs", ")", ":", "inspected_args", "=", "function_spec", ".", "args", "args_check", "=", "{", "}", "for", "i", "in", "range", "(", "len", "(", "inspected_args",...
Generate checks for positional argument testing :param decorated_function: function decorator :param function_spec: function inspect information :param arg_specs: argument specification (same as arg_specs in :meth:`.Verifier.decorate`) :return: internal structure, that is used by :meth:`.Verifier._args_checks...
[ "Generate", "checks", "for", "positional", "argument", "testing" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/verify.py#L120-L137
train
Generates checks for positional argument testing
a1ezzz/wasp-general
wasp_general/verify.py
Verifier._varargs_checks_gen
def _varargs_checks_gen(self, decorated_function, function_spec, arg_specs): """ Generate checks for positional variable argument (varargs) testing :param decorated_function: function decorator :param function_spec: function inspect information :param arg_specs: argument specification (same as arg_specs in :me...
python
def _varargs_checks_gen(self, decorated_function, function_spec, arg_specs): """ Generate checks for positional variable argument (varargs) testing :param decorated_function: function decorator :param function_spec: function inspect information :param arg_specs: argument specification (same as arg_specs in :me...
[ "def", "_varargs_checks_gen", "(", "self", ",", "decorated_function", ",", "function_spec", ",", "arg_specs", ")", ":", "inspected_varargs", "=", "function_spec", ".", "varargs", "if", "inspected_varargs", "is", "not", "None", "and", "inspected_varargs", "in", "arg_...
Generate checks for positional variable argument (varargs) testing :param decorated_function: function decorator :param function_spec: function inspect information :param arg_specs: argument specification (same as arg_specs in :meth:`.Verifier.decorate`) :return: internal structure, that is used by :meth:`.Ve...
[ "Generate", "checks", "for", "positional", "variable", "argument", "(", "varargs", ")", "testing" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/verify.py#L161-L175
train
Generates checks for positional variable argument ( varargs ) testing
a1ezzz/wasp-general
wasp_general/verify.py
Verifier._kwargs_checks_gen
def _kwargs_checks_gen(self, decorated_function, function_spec, arg_specs): """ Generate checks for keyword argument testing :param decorated_function: function decorator :param function_spec: function inspect information :param arg_specs: argument specification (same as arg_specs in :meth:`.Verifier.decorate`...
python
def _kwargs_checks_gen(self, decorated_function, function_spec, arg_specs): """ Generate checks for keyword argument testing :param decorated_function: function decorator :param function_spec: function inspect information :param arg_specs: argument specification (same as arg_specs in :meth:`.Verifier.decorate`...
[ "def", "_kwargs_checks_gen", "(", "self", ",", "decorated_function", ",", "function_spec", ",", "arg_specs", ")", ":", "args_names", "=", "[", "]", "args_names", ".", "extend", "(", "function_spec", ".", "args", ")", "if", "function_spec", ".", "varargs", "is"...
Generate checks for keyword argument testing :param decorated_function: function decorator :param function_spec: function inspect information :param arg_specs: argument specification (same as arg_specs in :meth:`.Verifier.decorate`) :return: internal structure, that is used by :meth:`.Verifier._kwargs_checks_...
[ "Generate", "checks", "for", "keyword", "argument", "testing" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/verify.py#L199-L220
train
Generates checks for keyword argument testing
a1ezzz/wasp-general
wasp_general/verify.py
Verifier.decorator
def decorator(self, **arg_specs): """ Return decorator that can decorate target function :param arg_specs: dictionary where keys are parameters name and values are theirs specification.\ Specific specification is passed as is to :meth:`Verifier.check` method with corresponding \ parameter name. :return: fun...
python
def decorator(self, **arg_specs): """ Return decorator that can decorate target function :param arg_specs: dictionary where keys are parameters name and values are theirs specification.\ Specific specification is passed as is to :meth:`Verifier.check` method with corresponding \ parameter name. :return: fun...
[ "def", "decorator", "(", "self", ",", "*", "*", "arg_specs", ")", ":", "if", "self", ".", "decorate_disabled", "(", ")", "is", "True", ":", "def", "empty_decorator", "(", "decorated_function", ")", ":", "return", "decorated_function", "return", "empty_decorato...
Return decorator that can decorate target function :param arg_specs: dictionary where keys are parameters name and values are theirs specification.\ Specific specification is passed as is to :meth:`Verifier.check` method with corresponding \ parameter name. :return: function
[ "Return", "decorator", "that", "can", "decorate", "target", "function" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/verify.py#L241-L270
train
Return decorator that can decorate target function.
a1ezzz/wasp-general
wasp_general/verify.py
Verifier.help_info
def help_info(self, exc, decorated_function, arg_name, arg_spec): """ Print debug information to stderr. (Do nothing if object was constructed with silent_checks=True) :param exc: raised exception :param decorated_function: target function (function to decorate) :param arg_name: function parameter name :para...
python
def help_info(self, exc, decorated_function, arg_name, arg_spec): """ Print debug information to stderr. (Do nothing if object was constructed with silent_checks=True) :param exc: raised exception :param decorated_function: target function (function to decorate) :param arg_name: function parameter name :para...
[ "def", "help_info", "(", "self", ",", "exc", ",", "decorated_function", ",", "arg_name", ",", "arg_spec", ")", ":", "if", "self", ".", "_silent_checks", "is", "not", "True", ":", "print", "(", "'Exception raised:'", ",", "file", "=", "sys", ".", "stderr", ...
Print debug information to stderr. (Do nothing if object was constructed with silent_checks=True) :param exc: raised exception :param decorated_function: target function (function to decorate) :param arg_name: function parameter name :param arg_spec: function parameter specification :return: None
[ "Print", "debug", "information", "to", "stderr", ".", "(", "Do", "nothing", "if", "object", "was", "constructed", "with", "silent_checks", "=", "True", ")" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/verify.py#L272-L295
train
Print debug information to stderr.
a1ezzz/wasp-general
wasp_general/verify.py
Verifier.function_name
def function_name(fn): """ Return function name in pretty style :param fn: source function :return: str """ fn_name = fn.__name__ if hasattr(fn, '__qualname__'): return fn.__qualname__ elif hasattr(fn, '__self__'): owner = fn.__self__ if isclass(owner) is False: owner = owner.__class__ re...
python
def function_name(fn): """ Return function name in pretty style :param fn: source function :return: str """ fn_name = fn.__name__ if hasattr(fn, '__qualname__'): return fn.__qualname__ elif hasattr(fn, '__self__'): owner = fn.__self__ if isclass(owner) is False: owner = owner.__class__ re...
[ "def", "function_name", "(", "fn", ")", ":", "fn_name", "=", "fn", ".", "__name__", "if", "hasattr", "(", "fn", ",", "'__qualname__'", ")", ":", "return", "fn", ".", "__qualname__", "elif", "hasattr", "(", "fn", ",", "'__self__'", ")", ":", "owner", "=...
Return function name in pretty style :param fn: source function :return: str
[ "Return", "function", "name", "in", "pretty", "style" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/verify.py#L298-L312
train
Return function name in pretty style eliminates the owner class and the name of the function
a1ezzz/wasp-general
wasp_general/verify.py
TypeVerifier.check
def check(self, type_spec, arg_name, decorated_function): """ Return callable that checks function parameter for type validity. Checks parameter if it is instance of specified class or classes :param type_spec: type or list/tuple/set of types :param arg_name: function parameter name :param decorated_function...
python
def check(self, type_spec, arg_name, decorated_function): """ Return callable that checks function parameter for type validity. Checks parameter if it is instance of specified class or classes :param type_spec: type or list/tuple/set of types :param arg_name: function parameter name :param decorated_function...
[ "def", "check", "(", "self", ",", "type_spec", ",", "arg_name", ",", "decorated_function", ")", ":", "def", "raise_exception", "(", "x_spec", ")", ":", "exc_text", "=", "'Argument \"%s\" for function \"%s\" has invalid type'", "%", "(", "arg_name", ",", "Verifier", ...
Return callable that checks function parameter for type validity. Checks parameter if it is instance of specified class or classes :param type_spec: type or list/tuple/set of types :param arg_name: function parameter name :param decorated_function: target function :return: function
[ "Return", "callable", "that", "checks", "function", "parameter", "for", "type", "validity", ".", "Checks", "parameter", "if", "it", "is", "instance", "of", "specified", "class", "or", "classes" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/verify.py#L326-L360
train
Returns callable that checks function parameter for type validity. Checks parameter if it is instance of specified class or classes.
a1ezzz/wasp-general
wasp_general/verify.py
ValueVerifier.check
def check(self, value_spec, arg_name, decorated_function): """ Return callable that checks function parameter for value validity. Checks parameter if its value passes specified restrictions. :param value_spec: function or list/tuple/set of functions. Each function must accept one parameter and \ must return Tr...
python
def check(self, value_spec, arg_name, decorated_function): """ Return callable that checks function parameter for value validity. Checks parameter if its value passes specified restrictions. :param value_spec: function or list/tuple/set of functions. Each function must accept one parameter and \ must return Tr...
[ "def", "check", "(", "self", ",", "value_spec", ",", "arg_name", ",", "decorated_function", ")", ":", "def", "raise_exception", "(", "text_spec", ")", ":", "exc_text", "=", "'Argument \"%s\" for function \"%s\" has invalid value'", "%", "(", "arg_name", ",", "Verifi...
Return callable that checks function parameter for value validity. Checks parameter if its value passes specified restrictions. :param value_spec: function or list/tuple/set of functions. Each function must accept one parameter and \ must return True or False if it passed restrictions or not. :param arg_name: ...
[ "Return", "callable", "that", "checks", "function", "parameter", "for", "value", "validity", ".", "Checks", "parameter", "if", "its", "value", "passes", "specified", "restrictions", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/verify.py#L425-L461
train
Returns callable that checks function parameter for value validity.
a1ezzz/wasp-general
wasp_general/cache.py
cache_control
def cache_control(validator=None, storage=None): """ Decorator that is used for caching result. :param validator: function, that has following signature (decorated_function, \*args, \*\*kwargs), where \ decorated_function - original function, args - function arguments, kwargs - function keyword arguments. \ This f...
python
def cache_control(validator=None, storage=None): """ Decorator that is used for caching result. :param validator: function, that has following signature (decorated_function, \*args, \*\*kwargs), where \ decorated_function - original function, args - function arguments, kwargs - function keyword arguments. \ This f...
[ "def", "cache_control", "(", "validator", "=", "None", ",", "storage", "=", "None", ")", ":", "def", "default_validator", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "True", "if", "validator", "is", "None", ":", "validator", "=", "de...
Decorator that is used for caching result. :param validator: function, that has following signature (decorated_function, \*args, \*\*kwargs), where \ decorated_function - original function, args - function arguments, kwargs - function keyword arguments. \ This function must return True if cache is valid (old result...
[ "Decorator", "that", "is", "used", "for", "caching", "result", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cache.py#L384-L421
train
Decorator that will be used to cache the result of a function.
a1ezzz/wasp-general
wasp_general/cache.py
WCacheStorage.has
def has(self, decorated_function, *args, **kwargs): """ Check if there is a result for given function :param decorated_function: called function (original) :param args: args with which function is called :param kwargs: kwargs with which function is called :return: None """ return self.get_cache(decorate...
python
def has(self, decorated_function, *args, **kwargs): """ Check if there is a result for given function :param decorated_function: called function (original) :param args: args with which function is called :param kwargs: kwargs with which function is called :return: None """ return self.get_cache(decorate...
[ "def", "has", "(", "self", ",", "decorated_function", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "get_cache", "(", "decorated_function", ",", "*", "args", ",", "*", "*", "kwargs", ")", ".", "has_value" ]
Check if there is a result for given function :param decorated_function: called function (original) :param args: args with which function is called :param kwargs: kwargs with which function is called :return: None
[ "Check", "if", "there", "is", "a", "result", "for", "given", "function" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cache.py#L99-L108
train
Check if there is a result for given function in the cache.
a1ezzz/wasp-general
wasp_general/cache.py
WCacheStorage.get_result
def get_result(self, decorated_function, *args, **kwargs): """ Get result from storage for specified function. Will raise an exception (:class:`.WCacheStorage.CacheMissedException`) if there is no cached result. :param decorated_function: called function (original) :param args: args with which function is call...
python
def get_result(self, decorated_function, *args, **kwargs): """ Get result from storage for specified function. Will raise an exception (:class:`.WCacheStorage.CacheMissedException`) if there is no cached result. :param decorated_function: called function (original) :param args: args with which function is call...
[ "def", "get_result", "(", "self", ",", "decorated_function", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "cache_entry", "=", "self", ".", "get_cache", "(", "decorated_function", ",", "*", "args", ",", "*", "*", "kwargs", ")", "if", "cache_entry"...
Get result from storage for specified function. Will raise an exception (:class:`.WCacheStorage.CacheMissedException`) if there is no cached result. :param decorated_function: called function (original) :param args: args with which function is called :param kwargs: kwargs with which function is called :retu...
[ "Get", "result", "from", "storage", "for", "specified", "function", ".", "Will", "raise", "an", "exception", "(", ":", "class", ":", ".", "WCacheStorage", ".", "CacheMissedException", ")", "if", "there", "is", "no", "cached", "result", "." ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cache.py#L111-L124
train
Get result from storage for specified function. Will raise an exception if there is no result.
a1ezzz/wasp-general
wasp_general/cache.py
WGlobalSingletonCacheStorage.put
def put(self, result, decorated_function, *args, **kwargs): """ :meth:`WCacheStorage.put` method implementation """ self._storage[decorated_function] = result
python
def put(self, result, decorated_function, *args, **kwargs): """ :meth:`WCacheStorage.put` method implementation """ self._storage[decorated_function] = result
[ "def", "put", "(", "self", ",", "result", ",", "decorated_function", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_storage", "[", "decorated_function", "]", "=", "result" ]
:meth:`WCacheStorage.put` method implementation
[ ":", "meth", ":", "WCacheStorage", ".", "put", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cache.py#L138-L141
train
method implementation self. put
a1ezzz/wasp-general
wasp_general/cache.py
WGlobalSingletonCacheStorage.get_result
def get_result(self, decorated_function, *args, **kwargs): """ :meth:`WCacheStorage.get_result` method implementation """ try: return self._storage[decorated_function] except KeyError as e: raise WCacheStorage.CacheMissedException('No cache record found') from e
python
def get_result(self, decorated_function, *args, **kwargs): """ :meth:`WCacheStorage.get_result` method implementation """ try: return self._storage[decorated_function] except KeyError as e: raise WCacheStorage.CacheMissedException('No cache record found') from e
[ "def", "get_result", "(", "self", ",", "decorated_function", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "self", ".", "_storage", "[", "decorated_function", "]", "except", "KeyError", "as", "e", ":", "raise", "WCacheStorage",...
:meth:`WCacheStorage.get_result` method implementation
[ ":", "meth", ":", "WCacheStorage", ".", "get_result", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cache.py#L150-L156
train
This method is used to get the result of a decorated function.
a1ezzz/wasp-general
wasp_general/cache.py
WGlobalSingletonCacheStorage.get_cache
def get_cache(self, decorated_function, *args, **kwargs): """ :meth:`WCacheStorage.get_cache` method implementation """ has_value = self.has(decorated_function, *args, **kwargs) cached_value = None if has_value is True: cached_value = self.get_result(decorated_function, *args, **kwargs) return WCacheStor...
python
def get_cache(self, decorated_function, *args, **kwargs): """ :meth:`WCacheStorage.get_cache` method implementation """ has_value = self.has(decorated_function, *args, **kwargs) cached_value = None if has_value is True: cached_value = self.get_result(decorated_function, *args, **kwargs) return WCacheStor...
[ "def", "get_cache", "(", "self", ",", "decorated_function", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "has_value", "=", "self", ".", "has", "(", "decorated_function", ",", "*", "args", ",", "*", "*", "kwargs", ")", "cached_value", "=", "None...
:meth:`WCacheStorage.get_cache` method implementation
[ ":", "meth", ":", "WCacheStorage", ".", "get_cache", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cache.py#L159-L166
train
:meth:`WCacheStorage. get_cache` method implementation
a1ezzz/wasp-general
wasp_general/cache.py
WGlobalSingletonCacheStorage.clear
def clear(self, decorated_function=None): """ :meth:`WCacheStorage.clear` method implementation """ if decorated_function is not None and decorated_function in self._storage: self._storage.pop(decorated_function) else: self._storage.clear()
python
def clear(self, decorated_function=None): """ :meth:`WCacheStorage.clear` method implementation """ if decorated_function is not None and decorated_function in self._storage: self._storage.pop(decorated_function) else: self._storage.clear()
[ "def", "clear", "(", "self", ",", "decorated_function", "=", "None", ")", ":", "if", "decorated_function", "is", "not", "None", "and", "decorated_function", "in", "self", ".", "_storage", ":", "self", ".", "_storage", ".", "pop", "(", "decorated_function", "...
:meth:`WCacheStorage.clear` method implementation
[ ":", "meth", ":", "WCacheStorage", ".", "clear", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cache.py#L169-L175
train
method implementation . clear
a1ezzz/wasp-general
wasp_general/cache.py
WInstanceSingletonCacheStorage.__check
def __check(self, decorated_function, *args, **kwargs): """ Check whether function is a bounded method or not. If check fails then exception is raised :param decorated_function: called function (original) :param args: args with which function is called :param kwargs: kwargs with which function is called :ret...
python
def __check(self, decorated_function, *args, **kwargs): """ Check whether function is a bounded method or not. If check fails then exception is raised :param decorated_function: called function (original) :param args: args with which function is called :param kwargs: kwargs with which function is called :ret...
[ "def", "__check", "(", "self", ",", "decorated_function", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# TODO replace this function with decorator which can be turned off like verify_* does", "if", "len", "(", "args", ")", ">=", "1", ":", "obj", "=", "arg...
Check whether function is a bounded method or not. If check fails then exception is raised :param decorated_function: called function (original) :param args: args with which function is called :param kwargs: kwargs with which function is called :return: None
[ "Check", "whether", "function", "is", "a", "bounded", "method", "or", "not", ".", "If", "check", "fails", "then", "exception", "is", "raised" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cache.py#L279-L296
train
Check whether function is a bounded method or not.
a1ezzz/wasp-general
wasp_general/cache.py
WInstanceSingletonCacheStorage.put
def put(self, result, decorated_function, *args, **kwargs): """ :meth:`WCacheStorage.put` method implementation """ self.__check(decorated_function, *args, **kwargs) ref = weakref.ref(args[0]) if decorated_function not in self._storage: cache_entry = self._cache_record_cls.create(result, decorated_functio...
python
def put(self, result, decorated_function, *args, **kwargs): """ :meth:`WCacheStorage.put` method implementation """ self.__check(decorated_function, *args, **kwargs) ref = weakref.ref(args[0]) if decorated_function not in self._storage: cache_entry = self._cache_record_cls.create(result, decorated_functio...
[ "def", "put", "(", "self", ",", "result", ",", "decorated_function", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "__check", "(", "decorated_function", ",", "*", "args", ",", "*", "*", "kwargs", ")", "ref", "=", "weakref", ".", ...
:meth:`WCacheStorage.put` method implementation
[ ":", "meth", ":", "WCacheStorage", ".", "put", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cache.py#L299-L331
train
method implementation self. put
a1ezzz/wasp-general
wasp_general/cache.py
WInstanceSingletonCacheStorage.get_cache
def get_cache(self, decorated_function, *args, **kwargs): """ :meth:`WCacheStorage.get_cache` method implementation """ self.__check(decorated_function, *args, **kwargs) if decorated_function in self._storage: for i in self._storage[decorated_function]: if i['instance']() == args[0]: result = i['res...
python
def get_cache(self, decorated_function, *args, **kwargs): """ :meth:`WCacheStorage.get_cache` method implementation """ self.__check(decorated_function, *args, **kwargs) if decorated_function in self._storage: for i in self._storage[decorated_function]: if i['instance']() == args[0]: result = i['res...
[ "def", "get_cache", "(", "self", ",", "decorated_function", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "__check", "(", "decorated_function", ",", "*", "args", ",", "*", "*", "kwargs", ")", "if", "decorated_function", "in", "self", ...
:meth:`WCacheStorage.get_cache` method implementation
[ ":", "meth", ":", "WCacheStorage", ".", "get_cache", "method", "implementation" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cache.py#L334-L352
train
method implementation self. get_cache
a1ezzz/wasp-general
wasp_general/cache.py
WInstanceSingletonCacheStorage.clear
def clear(self, decorated_function=None): """ :meth:`WCacheStorage.clear` method implementation (Clears statistics also) """ if decorated_function is not None and decorated_function in self._storage: self._storage.pop(decorated_function) else: self._storage.clear() if self.__statistic is True: self....
python
def clear(self, decorated_function=None): """ :meth:`WCacheStorage.clear` method implementation (Clears statistics also) """ if decorated_function is not None and decorated_function in self._storage: self._storage.pop(decorated_function) else: self._storage.clear() if self.__statistic is True: self....
[ "def", "clear", "(", "self", ",", "decorated_function", "=", "None", ")", ":", "if", "decorated_function", "is", "not", "None", "and", "decorated_function", "in", "self", ".", "_storage", ":", "self", ".", "_storage", ".", "pop", "(", "decorated_function", "...
:meth:`WCacheStorage.clear` method implementation (Clears statistics also)
[ ":", "meth", ":", "WCacheStorage", ".", "clear", "method", "implementation", "(", "Clears", "statistics", "also", ")" ]
1029839d33eb663f8dec76c1c46754d53c1de4a9
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/cache.py#L355-L365
train
A clear method implementation.
alixnovosi/drewtilities
drewtilities/drewtilities.py
ensure_dir
def ensure_dir(directory: str) -> None: """Create a directory if it doesn't exist.""" if not os.path.isdir(directory): LOG.debug(f"Directory {directory} does not exist, creating it.") os.makedirs(directory)
python
def ensure_dir(directory: str) -> None: """Create a directory if it doesn't exist.""" if not os.path.isdir(directory): LOG.debug(f"Directory {directory} does not exist, creating it.") os.makedirs(directory)
[ "def", "ensure_dir", "(", "directory", ":", "str", ")", "->", "None", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "directory", ")", ":", "LOG", ".", "debug", "(", "f\"Directory {directory} does not exist, creating it.\"", ")", "os", ".", "makedir...
Create a directory if it doesn't exist.
[ "Create", "a", "directory", "if", "it", "doesn", "t", "exist", "." ]
4e9b7f65f11195dc48347bf9c6ca4e56baca8b45
https://github.com/alixnovosi/drewtilities/blob/4e9b7f65f11195dc48347bf9c6ca4e56baca8b45/drewtilities/drewtilities.py#L22-L26
train
Create a directory if it doesn t exist.
alixnovosi/drewtilities
drewtilities/drewtilities.py
expand
def expand(directory: str) -> str: """Apply expanduser and expandvars to directory to expand '~' and env vars.""" temp1 = os.path.expanduser(directory) return os.path.expandvars(temp1)
python
def expand(directory: str) -> str: """Apply expanduser and expandvars to directory to expand '~' and env vars.""" temp1 = os.path.expanduser(directory) return os.path.expandvars(temp1)
[ "def", "expand", "(", "directory", ":", "str", ")", "->", "str", ":", "temp1", "=", "os", ".", "path", ".", "expanduser", "(", "directory", ")", "return", "os", ".", "path", ".", "expandvars", "(", "temp1", ")" ]
Apply expanduser and expandvars to directory to expand '~' and env vars.
[ "Apply", "expanduser", "and", "expandvars", "to", "directory", "to", "expand", "~", "and", "env", "vars", "." ]
4e9b7f65f11195dc48347bf9c6ca4e56baca8b45
https://github.com/alixnovosi/drewtilities/blob/4e9b7f65f11195dc48347bf9c6ca4e56baca8b45/drewtilities/drewtilities.py#L28-L31
train
Apply expanduser and expandvars to directory to expand '~' and env vars.
alixnovosi/drewtilities
drewtilities/drewtilities.py
generate_downloader
def generate_downloader(headers: Dict[str, str], args: Any, max_per_hour: int=30 ) -> Callable[..., None]: """Create function to download with rate limiting and text progress.""" def _downloader(url: str, dest: str) -> None: @rate_limited(max_per_hour, args) def _rate_l...
python
def generate_downloader(headers: Dict[str, str], args: Any, max_per_hour: int=30 ) -> Callable[..., None]: """Create function to download with rate limiting and text progress.""" def _downloader(url: str, dest: str) -> None: @rate_limited(max_per_hour, args) def _rate_l...
[ "def", "generate_downloader", "(", "headers", ":", "Dict", "[", "str", ",", "str", "]", ",", "args", ":", "Any", ",", "max_per_hour", ":", "int", "=", "30", ")", "->", "Callable", "[", "...", ",", "None", "]", ":", "def", "_downloader", "(", "url", ...
Create function to download with rate limiting and text progress.
[ "Create", "function", "to", "download", "with", "rate", "limiting", "and", "text", "progress", "." ]
4e9b7f65f11195dc48347bf9c6ca4e56baca8b45
https://github.com/alixnovosi/drewtilities/blob/4e9b7f65f11195dc48347bf9c6ca4e56baca8b45/drewtilities/drewtilities.py#L33-L71
train
Create function to download with rate limiting and text progress.
alixnovosi/drewtilities
drewtilities/drewtilities.py
parse_int_string
def parse_int_string(int_string: str) -> List[int]: """ Given a string like "1 23 4-8 32 1", return a unique list of those integers in the string and the integers in the ranges in the string. Non-numbers ignored. Not necessarily sorted """ cleaned = " ".join(int_string.strip().split()) clean...
python
def parse_int_string(int_string: str) -> List[int]: """ Given a string like "1 23 4-8 32 1", return a unique list of those integers in the string and the integers in the ranges in the string. Non-numbers ignored. Not necessarily sorted """ cleaned = " ".join(int_string.strip().split()) clean...
[ "def", "parse_int_string", "(", "int_string", ":", "str", ")", "->", "List", "[", "int", "]", ":", "cleaned", "=", "\" \"", ".", "join", "(", "int_string", ".", "strip", "(", ")", ".", "split", "(", ")", ")", "cleaned", "=", "cleaned", ".", "replace"...
Given a string like "1 23 4-8 32 1", return a unique list of those integers in the string and the integers in the ranges in the string. Non-numbers ignored. Not necessarily sorted
[ "Given", "a", "string", "like", "1", "23", "4", "-", "8", "32", "1", "return", "a", "unique", "list", "of", "those", "integers", "in", "the", "string", "and", "the", "integers", "in", "the", "ranges", "in", "the", "string", ".", "Non", "-", "numbers"...
4e9b7f65f11195dc48347bf9c6ca4e56baca8b45
https://github.com/alixnovosi/drewtilities/blob/4e9b7f65f11195dc48347bf9c6ca4e56baca8b45/drewtilities/drewtilities.py#L77-L107
train
Given a string like 1 23 4 - 8 32 1 return a unique list of those integers in the string and the integers in the ranges in the string.
alixnovosi/drewtilities
drewtilities/drewtilities.py
rate_limited
def rate_limited(max_per_hour: int, *args: Any) -> Callable[..., Any]: """Decorator to limit function to N calls/hour.""" min_interval = 3600.0 / float(max_per_hour) def _decorate(func: Callable[..., Any]) -> Callable[..., Any]: things = [func.__name__] things.extend(args) key = ""....
python
def rate_limited(max_per_hour: int, *args: Any) -> Callable[..., Any]: """Decorator to limit function to N calls/hour.""" min_interval = 3600.0 / float(max_per_hour) def _decorate(func: Callable[..., Any]) -> Callable[..., Any]: things = [func.__name__] things.extend(args) key = ""....
[ "def", "rate_limited", "(", "max_per_hour", ":", "int", ",", "*", "args", ":", "Any", ")", "->", "Callable", "[", "...", ",", "Any", "]", ":", "min_interval", "=", "3600.0", "/", "float", "(", "max_per_hour", ")", "def", "_decorate", "(", "func", ":", ...
Decorator to limit function to N calls/hour.
[ "Decorator", "to", "limit", "function", "to", "N", "calls", "/", "hour", "." ]
4e9b7f65f11195dc48347bf9c6ca4e56baca8b45
https://github.com/alixnovosi/drewtilities/blob/4e9b7f65f11195dc48347bf9c6ca4e56baca8b45/drewtilities/drewtilities.py#L110-L142
train
Decorator to limit function to N calls per hour.
alixnovosi/drewtilities
drewtilities/drewtilities.py
sanitize
def sanitize(filename: str, platform: str=None) -> str: """ Remove disallowed characters from potential filename. Currently only guaranteed on Linux and OS X. """ win_map = { # taken from samba Catia module. # https://www.samba.org/samba/docs/current/man-html/vfs_catia.8.html ...
python
def sanitize(filename: str, platform: str=None) -> str: """ Remove disallowed characters from potential filename. Currently only guaranteed on Linux and OS X. """ win_map = { # taken from samba Catia module. # https://www.samba.org/samba/docs/current/man-html/vfs_catia.8.html ...
[ "def", "sanitize", "(", "filename", ":", "str", ",", "platform", ":", "str", "=", "None", ")", "->", "str", ":", "win_map", "=", "{", "# taken from samba Catia module.", "# https://www.samba.org/samba/docs/current/man-html/vfs_catia.8.html", "\"\\\"\"", ":", "\"¨\",", ...
Remove disallowed characters from potential filename. Currently only guaranteed on Linux and OS X.
[ "Remove", "disallowed", "characters", "from", "potential", "filename", ".", "Currently", "only", "guaranteed", "on", "Linux", "and", "OS", "X", "." ]
4e9b7f65f11195dc48347bf9c6ca4e56baca8b45
https://github.com/alixnovosi/drewtilities/blob/4e9b7f65f11195dc48347bf9c6ca4e56baca8b45/drewtilities/drewtilities.py#L144-L178
train
Sanitize a filename for use in a VFS file.
alixnovosi/drewtilities
drewtilities/drewtilities.py
set_up_logging
def set_up_logging(log_filename: str = "log", verbosity: int = 0) ->logging.Logger: """Set up proper logging.""" LOG.setLevel(logging.DEBUG) # Log everything verbosely to a file. file_handler = RotatingFileHandler(filename=log_filename, maxBytes=1024000000, backupCount=10) verbose_form = logging.Fo...
python
def set_up_logging(log_filename: str = "log", verbosity: int = 0) ->logging.Logger: """Set up proper logging.""" LOG.setLevel(logging.DEBUG) # Log everything verbosely to a file. file_handler = RotatingFileHandler(filename=log_filename, maxBytes=1024000000, backupCount=10) verbose_form = logging.Fo...
[ "def", "set_up_logging", "(", "log_filename", ":", "str", "=", "\"log\"", ",", "verbosity", ":", "int", "=", "0", ")", "->", "logging", ".", "Logger", ":", "LOG", ".", "setLevel", "(", "logging", ".", "DEBUG", ")", "# Log everything verbosely to a file.", "f...
Set up proper logging.
[ "Set", "up", "proper", "logging", "." ]
4e9b7f65f11195dc48347bf9c6ca4e56baca8b45
https://github.com/alixnovosi/drewtilities/blob/4e9b7f65f11195dc48347bf9c6ca4e56baca8b45/drewtilities/drewtilities.py#L180-L203
train
Set up proper logging.
alixnovosi/drewtilities
drewtilities/drewtilities.py
random_line
def random_line(file_path: str, encoding: str = FORCED_ENCODING) -> str: """Get random line from a file.""" # Fancy alg from http://stackoverflow.com/a/35579149 to avoid loading full file. line_num = 0 selected_line = "" with open(file_path, encoding=encoding) as stream: while True: ...
python
def random_line(file_path: str, encoding: str = FORCED_ENCODING) -> str: """Get random line from a file.""" # Fancy alg from http://stackoverflow.com/a/35579149 to avoid loading full file. line_num = 0 selected_line = "" with open(file_path, encoding=encoding) as stream: while True: ...
[ "def", "random_line", "(", "file_path", ":", "str", ",", "encoding", ":", "str", "=", "FORCED_ENCODING", ")", "->", "str", ":", "# Fancy alg from http://stackoverflow.com/a/35579149 to avoid loading full file.", "line_num", "=", "0", "selected_line", "=", "\"\"", "with"...
Get random line from a file.
[ "Get", "random", "line", "from", "a", "file", "." ]
4e9b7f65f11195dc48347bf9c6ca4e56baca8b45
https://github.com/alixnovosi/drewtilities/blob/4e9b7f65f11195dc48347bf9c6ca4e56baca8b45/drewtilities/drewtilities.py#L205-L219
train
Get random line from a file.
vecnet/vecnet.openmalaria
vecnet/openmalaria/healthsystem.py
get_percentage_from_prob
def get_percentage_from_prob(prob): """ Converted probability of being treated to total percentage of clinical cases treated """ assert isinstance(prob, (float, int)) prob = float(prob) assert prob >= 0 assert prob <= 1 percentages = list(probability_list.keys()) percentages.sort() ...
python
def get_percentage_from_prob(prob): """ Converted probability of being treated to total percentage of clinical cases treated """ assert isinstance(prob, (float, int)) prob = float(prob) assert prob >= 0 assert prob <= 1 percentages = list(probability_list.keys()) percentages.sort() ...
[ "def", "get_percentage_from_prob", "(", "prob", ")", ":", "assert", "isinstance", "(", "prob", ",", "(", "float", ",", "int", ")", ")", "prob", "=", "float", "(", "prob", ")", "assert", "prob", ">=", "0", "assert", "prob", "<=", "1", "percentages", "="...
Converted probability of being treated to total percentage of clinical cases treated
[ "Converted", "probability", "of", "being", "treated", "to", "total", "percentage", "of", "clinical", "cases", "treated" ]
795bc9d1b81a6c664f14879edda7a7c41188e95a
https://github.com/vecnet/vecnet.openmalaria/blob/795bc9d1b81a6c664f14879edda7a7c41188e95a/vecnet/openmalaria/healthsystem.py#L135-L149
train
Converts probability of being treated to total percentage of clinical cases treated
OpenGov/og-python-utils
ogutils/functions/decorators.py
listify
def listify(generator_func): ''' Converts generator functions into list returning functions. @listify def test(): yield 1 test() # => [1] ''' def list_func(*args, **kwargs): return degenerate(generator_func(*args, **kwargs)) return list_func
python
def listify(generator_func): ''' Converts generator functions into list returning functions. @listify def test(): yield 1 test() # => [1] ''' def list_func(*args, **kwargs): return degenerate(generator_func(*args, **kwargs)) return list_func
[ "def", "listify", "(", "generator_func", ")", ":", "def", "list_func", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "degenerate", "(", "generator_func", "(", "*", "args", ",", "*", "*", "kwargs", ")", ")", "return", "list_func" ]
Converts generator functions into list returning functions. @listify def test(): yield 1 test() # => [1]
[ "Converts", "generator", "functions", "into", "list", "returning", "functions", "." ]
00f44927383dd1bd6348f47302c4453d56963479
https://github.com/OpenGov/og-python-utils/blob/00f44927383dd1bd6348f47302c4453d56963479/ogutils/functions/decorators.py#L3-L15
train
Returns a function that returns a list of generator functions.
mangalam-research/selenic
selenic/util.py
locations_within
def locations_within(a, b, tolerance): """ Verifies whether two positions are the same. A tolerance value determines how close the two positions must be to be considered "same". The two locations must be dictionaries that have the same keys. If a key is pesent in one but not in the other, this ...
python
def locations_within(a, b, tolerance): """ Verifies whether two positions are the same. A tolerance value determines how close the two positions must be to be considered "same". The two locations must be dictionaries that have the same keys. If a key is pesent in one but not in the other, this ...
[ "def", "locations_within", "(", "a", ",", "b", ",", "tolerance", ")", ":", "ret", "=", "''", "# Clone b so that we can destroy it.", "b", "=", "dict", "(", "b", ")", "for", "(", "key", ",", "value", ")", "in", "a", ".", "items", "(", ")", ":", "if", ...
Verifies whether two positions are the same. A tolerance value determines how close the two positions must be to be considered "same". The two locations must be dictionaries that have the same keys. If a key is pesent in one but not in the other, this is an error. The values must be integers or any...
[ "Verifies", "whether", "two", "positions", "are", "the", "same", ".", "A", "tolerance", "value", "determines", "how", "close", "the", "two", "positions", "must", "be", "to", "be", "considered", "same", "." ]
2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad
https://github.com/mangalam-research/selenic/blob/2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad/selenic/util.py#L479-L525
train
Returns a string that contains the differences between two dicts a and b.
mangalam-research/selenic
selenic/util.py
Util.find_descendants_by_text_re
def find_descendants_by_text_re(self, parent, re, immediate=False): """ :param parent: The parent element into which to search. :type parent: :class:`selenium.webdriver.remote.webelement.WebElement` or :class:`str`. When a string is specified, it ...
python
def find_descendants_by_text_re(self, parent, re, immediate=False): """ :param parent: The parent element into which to search. :type parent: :class:`selenium.webdriver.remote.webelement.WebElement` or :class:`str`. When a string is specified, it ...
[ "def", "find_descendants_by_text_re", "(", "self", ",", "parent", ",", "re", ",", "immediate", "=", "False", ")", ":", "def", "cond", "(", "*", "_", ")", ":", "return", "self", ".", "driver", ".", "execute_script", "(", "\"\"\"\n var parent = argume...
:param parent: The parent element into which to search. :type parent: :class:`selenium.webdriver.remote.webelement.WebElement` or :class:`str`. When a string is specified, it is interpreted as a CSS selector. :param re: A regular expressi...
[ ":", "param", "parent", ":", "The", "parent", "element", "into", "which", "to", "search", ".", ":", "type", "parent", ":", ":", "class", ":", "selenium", ".", "webdriver", ".", "remote", ".", "webelement", ".", "WebElement", "or", ":", "class", ":", "s...
2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad
https://github.com/mangalam-research/selenic/blob/2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad/selenic/util.py#L87-L120
train
Searches for descendants of a parent element that matches a regular expression.
mangalam-research/selenic
selenic/util.py
Util.command_x
def command_x(self, x, to=None): """ Sends a character to the currently active element with Command pressed. This method takes care of pressing and releasing Command. """ if to is None: ActionChains(self.driver) \ .send_keys([Keys.COMMAND, x, K...
python
def command_x(self, x, to=None): """ Sends a character to the currently active element with Command pressed. This method takes care of pressing and releasing Command. """ if to is None: ActionChains(self.driver) \ .send_keys([Keys.COMMAND, x, K...
[ "def", "command_x", "(", "self", ",", "x", ",", "to", "=", "None", ")", ":", "if", "to", "is", "None", ":", "ActionChains", "(", "self", ".", "driver", ")", ".", "send_keys", "(", "[", "Keys", ".", "COMMAND", ",", "x", ",", "Keys", ".", "COMMAND"...
Sends a character to the currently active element with Command pressed. This method takes care of pressing and releasing Command.
[ "Sends", "a", "character", "to", "the", "currently", "active", "element", "with", "Command", "pressed", ".", "This", "method", "takes", "care", "of", "pressing", "and", "releasing", "Command", "." ]
2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad
https://github.com/mangalam-research/selenic/blob/2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad/selenic/util.py#L167-L178
train
Sends a character to the currently active element with Command pressed.
mangalam-research/selenic
selenic/util.py
Util.send_keys
def send_keys(self, element, x): """ Sends keys to the element. This method takes care of handling modifiers keys. To press and release a modifier key you must include it twice: once to press, once to release. """ ActionChains(self.driver) \ .send_keys_to_elem...
python
def send_keys(self, element, x): """ Sends keys to the element. This method takes care of handling modifiers keys. To press and release a modifier key you must include it twice: once to press, once to release. """ ActionChains(self.driver) \ .send_keys_to_elem...
[ "def", "send_keys", "(", "self", ",", "element", ",", "x", ")", ":", "ActionChains", "(", "self", ".", "driver", ")", ".", "send_keys_to_element", "(", "element", ",", "x", ")", ".", "perform", "(", ")" ]
Sends keys to the element. This method takes care of handling modifiers keys. To press and release a modifier key you must include it twice: once to press, once to release.
[ "Sends", "keys", "to", "the", "element", ".", "This", "method", "takes", "care", "of", "handling", "modifiers", "keys", ".", "To", "press", "and", "release", "a", "modifier", "key", "you", "must", "include", "it", "twice", ":", "once", "to", "press", "on...
2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad
https://github.com/mangalam-research/selenic/blob/2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad/selenic/util.py#L180-L188
train
Sends the specified modifiers key to the specified element.
mangalam-research/selenic
selenic/util.py
Util.element_screen_center
def element_screen_center(self, element): """ :returns: The center point of the element. :rtype: class:`dict` with the field "left" set to the X coordinate and the field "top" set to the Y coordinate. """ pos = self.element_screen_position(element...
python
def element_screen_center(self, element): """ :returns: The center point of the element. :rtype: class:`dict` with the field "left" set to the X coordinate and the field "top" set to the Y coordinate. """ pos = self.element_screen_position(element...
[ "def", "element_screen_center", "(", "self", ",", "element", ")", ":", "pos", "=", "self", ".", "element_screen_position", "(", "element", ")", "size", "=", "element", ".", "size", "pos", "[", "\"top\"", "]", "+=", "int", "(", "size", "[", "\"height\"", ...
:returns: The center point of the element. :rtype: class:`dict` with the field "left" set to the X coordinate and the field "top" set to the Y coordinate.
[ ":", "returns", ":", "The", "center", "point", "of", "the", "element", ".", ":", "rtype", ":", "class", ":", "dict", "with", "the", "field", "left", "set", "to", "the", "X", "coordinate", "and", "the", "field", "top", "set", "to", "the", "Y", "coordi...
2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad
https://github.com/mangalam-research/selenic/blob/2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad/selenic/util.py#L209-L221
train
Returns the center point of the element in the screen.
mangalam-research/selenic
selenic/util.py
Util.visible_to_user
def visible_to_user(self, element, *ignorable): """ Determines whether an element is visible to the user. A list of ignorable elements can be passed to this function. These would typically be things like invisible layers sitting atop other elements. This function ignores these el...
python
def visible_to_user(self, element, *ignorable): """ Determines whether an element is visible to the user. A list of ignorable elements can be passed to this function. These would typically be things like invisible layers sitting atop other elements. This function ignores these el...
[ "def", "visible_to_user", "(", "self", ",", "element", ",", "*", "ignorable", ")", ":", "if", "not", "element", ".", "is_displayed", "(", ")", ":", "return", "False", "return", "self", ".", "driver", ".", "execute_script", "(", "\"\"\"\n var el = argume...
Determines whether an element is visible to the user. A list of ignorable elements can be passed to this function. These would typically be things like invisible layers sitting atop other elements. This function ignores these elements by setting their CSS ``display`` parameter to ``none`...
[ "Determines", "whether", "an", "element", "is", "visible", "to", "the", "user", ".", "A", "list", "of", "ignorable", "elements", "can", "be", "passed", "to", "this", "function", ".", "These", "would", "typically", "be", "things", "like", "invisible", "layers...
2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad
https://github.com/mangalam-research/selenic/blob/2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad/selenic/util.py#L249-L310
train
Determines whether an element is visible to the user.
mangalam-research/selenic
selenic/util.py
Util.wait
def wait(self, condition): """ Waits for a condition to be true. :param condition: Should be a callable that operates in the same way ``WebDriverWait.until`` expects. :returns: Whatever ``WebDriverWait.until`` returns. """ return WebDriverWait(s...
python
def wait(self, condition): """ Waits for a condition to be true. :param condition: Should be a callable that operates in the same way ``WebDriverWait.until`` expects. :returns: Whatever ``WebDriverWait.until`` returns. """ return WebDriverWait(s...
[ "def", "wait", "(", "self", ",", "condition", ")", ":", "return", "WebDriverWait", "(", "self", ".", "driver", ",", "self", ".", "timeout", ")", ".", "until", "(", "condition", ")" ]
Waits for a condition to be true. :param condition: Should be a callable that operates in the same way ``WebDriverWait.until`` expects. :returns: Whatever ``WebDriverWait.until`` returns.
[ "Waits", "for", "a", "condition", "to", "be", "true", "." ]
2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad
https://github.com/mangalam-research/selenic/blob/2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad/selenic/util.py#L391-L399
train
Waits for a condition to be true.
mangalam-research/selenic
selenic/util.py
Util.wait_until_not
def wait_until_not(self, condition): """ Waits for a condition to be false. :param condition: Should be a callable that operates in the same way ``WebDriverWait.until_not`` expects. :returns: Whatever ``WebDriverWait.until_not`` returns. """ ret...
python
def wait_until_not(self, condition): """ Waits for a condition to be false. :param condition: Should be a callable that operates in the same way ``WebDriverWait.until_not`` expects. :returns: Whatever ``WebDriverWait.until_not`` returns. """ ret...
[ "def", "wait_until_not", "(", "self", ",", "condition", ")", ":", "return", "WebDriverWait", "(", "self", ".", "driver", ",", "self", ".", "timeout", ")", ".", "until_not", "(", "condition", ")" ]
Waits for a condition to be false. :param condition: Should be a callable that operates in the same way ``WebDriverWait.until_not`` expects. :returns: Whatever ``WebDriverWait.until_not`` returns.
[ "Waits", "for", "a", "condition", "to", "be", "false", "." ]
2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad
https://github.com/mangalam-research/selenic/blob/2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad/selenic/util.py#L401-L409
train
Waits for a condition to be false.
mangalam-research/selenic
selenic/util.py
Util.assert_same
def assert_same(self, first, second): """ Compares two items for identity. The items can be either single values or lists of values. When comparing lists, identity obtains when the two lists have the same number of elements and that the element at position in one list is identica...
python
def assert_same(self, first, second): """ Compares two items for identity. The items can be either single values or lists of values. When comparing lists, identity obtains when the two lists have the same number of elements and that the element at position in one list is identica...
[ "def", "assert_same", "(", "self", ",", "first", ",", "second", ")", ":", "if", "not", "isinstance", "(", "first", ",", "list", ")", ":", "first", "=", "[", "first", "]", "if", "not", "isinstance", "(", "second", ",", "list", ")", ":", "second", "=...
Compares two items for identity. The items can be either single values or lists of values. When comparing lists, identity obtains when the two lists have the same number of elements and that the element at position in one list is identical to the element at the same position in the other...
[ "Compares", "two", "items", "for", "identity", ".", "The", "items", "can", "be", "either", "single", "values", "or", "lists", "of", "values", ".", "When", "comparing", "lists", "identity", "obtains", "when", "the", "two", "lists", "have", "the", "same", "n...
2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad
https://github.com/mangalam-research/selenic/blob/2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad/selenic/util.py#L433-L476
train
Assert that two items for identity are equal.
mediawiki-utilities/python-mwpersistence
mwpersistence/utilities/persistence2stats.py
persistence2stats
def persistence2stats(rev_docs, min_persisted=5, min_visible=1209600, include=None, exclude=None, verbose=False): """ Processes a sorted and page-partitioned sequence of revision documents into and adds statistics to the 'persistence' field each token "added" in the revision persis...
python
def persistence2stats(rev_docs, min_persisted=5, min_visible=1209600, include=None, exclude=None, verbose=False): """ Processes a sorted and page-partitioned sequence of revision documents into and adds statistics to the 'persistence' field each token "added" in the revision persis...
[ "def", "persistence2stats", "(", "rev_docs", ",", "min_persisted", "=", "5", ",", "min_visible", "=", "1209600", ",", "include", "=", "None", ",", "exclude", "=", "None", ",", "verbose", "=", "False", ")", ":", "rev_docs", "=", "mwxml", ".", "utilities", ...
Processes a sorted and page-partitioned sequence of revision documents into and adds statistics to the 'persistence' field each token "added" in the revision persisted through future revisions. :Parameters: rev_docs : `iterable` ( `dict` ) JSON documents of revision data containing a 'd...
[ "Processes", "a", "sorted", "and", "page", "-", "partitioned", "sequence", "of", "revision", "documents", "into", "and", "adds", "statistics", "to", "the", "persistence", "field", "each", "token", "added", "in", "the", "revision", "persisted", "through", "future...
2b98847fb8acaca38b3cbf94bde3fd7e27d2b67d
https://github.com/mediawiki-utilities/python-mwpersistence/blob/2b98847fb8acaca38b3cbf94bde3fd7e27d2b67d/mwpersistence/utilities/persistence2stats.py#L88-L187
train
Generates a generator that returns a new revision document with the given persistence field.