partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
HX711._validate_measure_count
check if "times" is within the borders defined in the class :param times: "times" to check :type times: int
hx711/__init__.py
def _validate_measure_count(self, times): """ check if "times" is within the borders defined in the class :param times: "times" to check :type times: int """ if not self.min_measures <= times <= self.max_measures: raise ParameterValidationError( ...
def _validate_measure_count(self, times): """ check if "times" is within the borders defined in the class :param times: "times" to check :type times: int """ if not self.min_measures <= times <= self.max_measures: raise ParameterValidationError( ...
[ "check", "if", "times", "is", "within", "the", "borders", "defined", "in", "the", "class" ]
mpibpc-mroose/hx711
python
https://github.com/mpibpc-mroose/hx711/blob/2f3a39880cdd2d2fa8ba79a7f9245d1a35d89f1d/hx711/__init__.py#L132-L144
[ "def", "_validate_measure_count", "(", "self", ",", "times", ")", ":", "if", "not", "self", ".", "min_measures", "<=", "times", "<=", "self", ".", "max_measures", ":", "raise", "ParameterValidationError", "(", "\"{times} is not within the borders defined in the class\""...
2f3a39880cdd2d2fa8ba79a7f9245d1a35d89f1d
train
HX711._validate_gain_A_value
validate a given value for gain_A :type gain_A: int :raises: ValueError
hx711/__init__.py
def _validate_gain_A_value(self, gain_A): """ validate a given value for gain_A :type gain_A: int :raises: ValueError """ if gain_A not in self._valid_gains_for_channel_A: raise ParameterValidationError("{gain_A} is not a valid gain".format(gain_A=gain_A))
def _validate_gain_A_value(self, gain_A): """ validate a given value for gain_A :type gain_A: int :raises: ValueError """ if gain_A not in self._valid_gains_for_channel_A: raise ParameterValidationError("{gain_A} is not a valid gain".format(gain_A=gain_A))
[ "validate", "a", "given", "value", "for", "gain_A" ]
mpibpc-mroose/hx711
python
https://github.com/mpibpc-mroose/hx711/blob/2f3a39880cdd2d2fa8ba79a7f9245d1a35d89f1d/hx711/__init__.py#L155-L163
[ "def", "_validate_gain_A_value", "(", "self", ",", "gain_A", ")", ":", "if", "gain_A", "not", "in", "self", ".", "_valid_gains_for_channel_A", ":", "raise", "ParameterValidationError", "(", "\"{gain_A} is not a valid gain\"", ".", "format", "(", "gain_A", "=", "gain...
2f3a39880cdd2d2fa8ba79a7f9245d1a35d89f1d
train
HX711._ready
check if ther is som data is ready to get read. :return True if there is some date :rtype bool
hx711/__init__.py
def _ready(self): """ check if ther is som data is ready to get read. :return True if there is some date :rtype bool """ # if DOUT pin is low, data is ready for reading _is_ready = GPIO.input(self._dout) == 0 logging.debug("check data ready for reading: {r...
def _ready(self): """ check if ther is som data is ready to get read. :return True if there is some date :rtype bool """ # if DOUT pin is low, data is ready for reading _is_ready = GPIO.input(self._dout) == 0 logging.debug("check data ready for reading: {r...
[ "check", "if", "ther", "is", "som", "data", "is", "ready", "to", "get", "read", ".", ":", "return", "True", "if", "there", "is", "some", "date", ":", "rtype", "bool" ]
mpibpc-mroose/hx711
python
https://github.com/mpibpc-mroose/hx711/blob/2f3a39880cdd2d2fa8ba79a7f9245d1a35d89f1d/hx711/__init__.py#L179-L190
[ "def", "_ready", "(", "self", ")", ":", "# if DOUT pin is low, data is ready for reading", "_is_ready", "=", "GPIO", ".", "input", "(", "self", ".", "_dout", ")", "==", "0", "logging", ".", "debug", "(", "\"check data ready for reading: {result}\"", ".", "format", ...
2f3a39880cdd2d2fa8ba79a7f9245d1a35d89f1d
train
HX711._set_channel_gain
Finish data transmission from HX711 by setting next required gain and channel Only called from the _read function. :param num: how often so do the set (1...3) :type num: int :return True on success :rtype bool
hx711/__init__.py
def _set_channel_gain(self, num): """ Finish data transmission from HX711 by setting next required gain and channel Only called from the _read function. :param num: how often so do the set (1...3) :type num: int :return True on success :rtype bool ...
def _set_channel_gain(self, num): """ Finish data transmission from HX711 by setting next required gain and channel Only called from the _read function. :param num: how often so do the set (1...3) :type num: int :return True on success :rtype bool ...
[ "Finish", "data", "transmission", "from", "HX711", "by", "setting", "next", "required", "gain", "and", "channel" ]
mpibpc-mroose/hx711
python
https://github.com/mpibpc-mroose/hx711/blob/2f3a39880cdd2d2fa8ba79a7f9245d1a35d89f1d/hx711/__init__.py#L192-L227
[ "def", "_set_channel_gain", "(", "self", ",", "num", ")", ":", "if", "not", "1", "<=", "num", "<=", "3", ":", "raise", "AttributeError", "(", "\"\"\"\"num\" has to be in the range of 1 to 3\"\"\"", ")", "for", "_", "in", "range", "(", "num", ")", ":", "loggi...
2f3a39880cdd2d2fa8ba79a7f9245d1a35d89f1d
train
HX711._read
- read the bit stream from HX711 and convert to an int value. - validates the acquired data :param max_tries: how often to try to get data :type max_tries: int :return raw data :rtype: int
hx711/__init__.py
def _read(self, max_tries=40): """ - read the bit stream from HX711 and convert to an int value. - validates the acquired data :param max_tries: how often to try to get data :type max_tries: int :return raw data :rtype: int """ # start by setting t...
def _read(self, max_tries=40): """ - read the bit stream from HX711 and convert to an int value. - validates the acquired data :param max_tries: how often to try to get data :type max_tries: int :return raw data :rtype: int """ # start by setting t...
[ "-", "read", "the", "bit", "stream", "from", "HX711", "and", "convert", "to", "an", "int", "value", ".", "-", "validates", "the", "acquired", "data", ":", "param", "max_tries", ":", "how", "often", "to", "try", "to", "get", "data", ":", "type", "max_tr...
mpibpc-mroose/hx711
python
https://github.com/mpibpc-mroose/hx711/blob/2f3a39880cdd2d2fa8ba79a7f9245d1a35d89f1d/hx711/__init__.py#L229-L301
[ "def", "_read", "(", "self", ",", "max_tries", "=", "40", ")", ":", "# start by setting the pd_sck to false", "GPIO", ".", "output", "(", "self", ".", "_pd_sck", ",", "False", ")", "# init the counter", "ready_counter", "=", "0", "# loop until HX711 is ready", "# ...
2f3a39880cdd2d2fa8ba79a7f9245d1a35d89f1d
train
HX711.get_raw_data
do some readings and aggregate them using the defined statistics function :param times: how many measures to aggregate :type times: int :return: the aggregate of the measured values :rtype float
hx711/__init__.py
def get_raw_data(self, times=5): """ do some readings and aggregate them using the defined statistics function :param times: how many measures to aggregate :type times: int :return: the aggregate of the measured values :rtype float """ self._validate_mea...
def get_raw_data(self, times=5): """ do some readings and aggregate them using the defined statistics function :param times: how many measures to aggregate :type times: int :return: the aggregate of the measured values :rtype float """ self._validate_mea...
[ "do", "some", "readings", "and", "aggregate", "them", "using", "the", "defined", "statistics", "function" ]
mpibpc-mroose/hx711
python
https://github.com/mpibpc-mroose/hx711/blob/2f3a39880cdd2d2fa8ba79a7f9245d1a35d89f1d/hx711/__init__.py#L303-L321
[ "def", "get_raw_data", "(", "self", ",", "times", "=", "5", ")", ":", "self", ".", "_validate_measure_count", "(", "times", ")", "data_list", "=", "[", "]", "while", "len", "(", "data_list", ")", "<", "times", ":", "data", "=", "self", ".", "_read", ...
2f3a39880cdd2d2fa8ba79a7f9245d1a35d89f1d
train
ResourceTreeService.from_resource_deeper
This returns you subtree of ordered objects relative to the start resource_id (currently only implemented in postgresql) :param resource_id: :param limit_depth: :param db_session: :return:
ziggurat_foundations/models/services/resource_tree.py
def from_resource_deeper( self, resource_id=None, limit_depth=1000000, db_session=None, *args, **kwargs ): """ This returns you subtree of ordered objects relative to the start resource_id (currently only implemented in postgresql) :param resource_id: :param limit_de...
def from_resource_deeper( self, resource_id=None, limit_depth=1000000, db_session=None, *args, **kwargs ): """ This returns you subtree of ordered objects relative to the start resource_id (currently only implemented in postgresql) :param resource_id: :param limit_de...
[ "This", "returns", "you", "subtree", "of", "ordered", "objects", "relative", "to", "the", "start", "resource_id", "(", "currently", "only", "implemented", "in", "postgresql", ")" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource_tree.py#L16-L34
[ "def", "from_resource_deeper", "(", "self", ",", "resource_id", "=", "None", ",", "limit_depth", "=", "1000000", ",", "db_session", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "service", ".", "from_resource_deep...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceTreeService.delete_branch
This deletes whole branch with children starting from resource_id :param resource_id: :param db_session: :return:
ziggurat_foundations/models/services/resource_tree.py
def delete_branch(self, resource_id=None, db_session=None, *args, **kwargs): """ This deletes whole branch with children starting from resource_id :param resource_id: :param db_session: :return: """ return self.service.delete_branch( resource_id=resou...
def delete_branch(self, resource_id=None, db_session=None, *args, **kwargs): """ This deletes whole branch with children starting from resource_id :param resource_id: :param db_session: :return: """ return self.service.delete_branch( resource_id=resou...
[ "This", "deletes", "whole", "branch", "with", "children", "starting", "from", "resource_id" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource_tree.py#L36-L46
[ "def", "delete_branch", "(", "self", ",", "resource_id", "=", "None", ",", "db_session", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "service", ".", "delete_branch", "(", "resource_id", "=", "resource_id", ","...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceTreeService.from_parent_deeper
This returns you subtree of ordered objects relative to the start parent_id (currently only implemented in postgresql) :param resource_id: :param limit_depth: :param db_session: :return:
ziggurat_foundations/models/services/resource_tree.py
def from_parent_deeper( self, parent_id=None, limit_depth=1000000, db_session=None, *args, **kwargs ): """ This returns you subtree of ordered objects relative to the start parent_id (currently only implemented in postgresql) :param resource_id: :param limit_depth: ...
def from_parent_deeper( self, parent_id=None, limit_depth=1000000, db_session=None, *args, **kwargs ): """ This returns you subtree of ordered objects relative to the start parent_id (currently only implemented in postgresql) :param resource_id: :param limit_depth: ...
[ "This", "returns", "you", "subtree", "of", "ordered", "objects", "relative", "to", "the", "start", "parent_id", "(", "currently", "only", "implemented", "in", "postgresql", ")" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource_tree.py#L48-L66
[ "def", "from_parent_deeper", "(", "self", ",", "parent_id", "=", "None", ",", "limit_depth", "=", "1000000", ",", "db_session", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "service", ".", "from_parent_deeper", ...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceTreeService.build_subtree_strut
Returns a dictionary in form of {node:Resource, children:{node_id: Resource}} :param result: :return:
ziggurat_foundations/models/services/resource_tree.py
def build_subtree_strut(self, result, *args, **kwargs): """ Returns a dictionary in form of {node:Resource, children:{node_id: Resource}} :param result: :return: """ return self.service.build_subtree_strut(result=result, *args, **kwargs)
def build_subtree_strut(self, result, *args, **kwargs): """ Returns a dictionary in form of {node:Resource, children:{node_id: Resource}} :param result: :return: """ return self.service.build_subtree_strut(result=result, *args, **kwargs)
[ "Returns", "a", "dictionary", "in", "form", "of", "{", "node", ":", "Resource", "children", ":", "{", "node_id", ":", "Resource", "}}" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource_tree.py#L68-L76
[ "def", "build_subtree_strut", "(", "self", ",", "result", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "service", ".", "build_subtree_strut", "(", "result", "=", "result", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceTreeService.path_upper
This returns you path to root node starting from object_id currently only for postgresql :param object_id: :param limit_depth: :param db_session: :return:
ziggurat_foundations/models/services/resource_tree.py
def path_upper( self, object_id, limit_depth=1000000, db_session=None, *args, **kwargs ): """ This returns you path to root node starting from object_id currently only for postgresql :param object_id: :param limit_depth: :param db_session: :return...
def path_upper( self, object_id, limit_depth=1000000, db_session=None, *args, **kwargs ): """ This returns you path to root node starting from object_id currently only for postgresql :param object_id: :param limit_depth: :param db_session: :return...
[ "This", "returns", "you", "path", "to", "root", "node", "starting", "from", "object_id", "currently", "only", "for", "postgresql" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource_tree.py#L78-L96
[ "def", "path_upper", "(", "self", ",", "object_id", ",", "limit_depth", "=", "1000000", ",", "db_session", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "service", ".", "path_upper", "(", "object_id", "=", "ob...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceTreeService.move_to_position
Moves node to new location in the tree :param resource_id: resource to move :param to_position: new position :param new_parent_id: new parent id :param db_session: :return:
ziggurat_foundations/models/services/resource_tree.py
def move_to_position( self, resource_id, to_position, new_parent_id=noop, db_session=None, *args, **kwargs ): """ Moves node to new location in the tree :param resource_id: resource to move :param to_position: new position ...
def move_to_position( self, resource_id, to_position, new_parent_id=noop, db_session=None, *args, **kwargs ): """ Moves node to new location in the tree :param resource_id: resource to move :param to_position: new position ...
[ "Moves", "node", "to", "new", "location", "in", "the", "tree" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource_tree.py#L98-L123
[ "def", "move_to_position", "(", "self", ",", "resource_id", ",", "to_position", ",", "new_parent_id", "=", "noop", ",", "db_session", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "service", ".", "move_to_position...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceTreeService.shift_ordering_down
Shifts ordering to "close gaps" after node deletion or being moved to another branch, begins the shift from given position :param parent_id: :param position: :param db_session: :return:
ziggurat_foundations/models/services/resource_tree.py
def shift_ordering_down( self, parent_id, position, db_session=None, *args, **kwargs ): """ Shifts ordering to "close gaps" after node deletion or being moved to another branch, begins the shift from given position :param parent_id: :param position: :param db...
def shift_ordering_down( self, parent_id, position, db_session=None, *args, **kwargs ): """ Shifts ordering to "close gaps" after node deletion or being moved to another branch, begins the shift from given position :param parent_id: :param position: :param db...
[ "Shifts", "ordering", "to", "close", "gaps", "after", "node", "deletion", "or", "being", "moved", "to", "another", "branch", "begins", "the", "shift", "from", "given", "position" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource_tree.py#L125-L143
[ "def", "shift_ordering_down", "(", "self", ",", "parent_id", ",", "position", ",", "db_session", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "service", ".", "shift_ordering_down", "(", "parent_id", "=", "parent_...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceTreeService.shift_ordering_up
Shifts ordering to "open a gap" for node insertion, begins the shift from given position :param parent_id: :param position: :param db_session: :return:
ziggurat_foundations/models/services/resource_tree.py
def shift_ordering_up(self, parent_id, position, db_session=None, *args, **kwargs): """ Shifts ordering to "open a gap" for node insertion, begins the shift from given position :param parent_id: :param position: :param db_session: :return: """ ret...
def shift_ordering_up(self, parent_id, position, db_session=None, *args, **kwargs): """ Shifts ordering to "open a gap" for node insertion, begins the shift from given position :param parent_id: :param position: :param db_session: :return: """ ret...
[ "Shifts", "ordering", "to", "open", "a", "gap", "for", "node", "insertion", "begins", "the", "shift", "from", "given", "position" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource_tree.py#L145-L161
[ "def", "shift_ordering_up", "(", "self", ",", "parent_id", ",", "position", ",", "db_session", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "service", ".", "shift_ordering_up", "(", "parent_id", "=", "parent_id",...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceTreeService.set_position
Sets node position for new node in the tree :param resource_id: resource to move :param to_position: new position :param db_session: :return:def count_children(cls, resource_id, db_session=None):
ziggurat_foundations/models/services/resource_tree.py
def set_position(self, resource_id, to_position, db_session=None, *args, **kwargs): """ Sets node position for new node in the tree :param resource_id: resource to move :param to_position: new position :param db_session: :return:def count_children(cls, resource_id, db_se...
def set_position(self, resource_id, to_position, db_session=None, *args, **kwargs): """ Sets node position for new node in the tree :param resource_id: resource to move :param to_position: new position :param db_session: :return:def count_children(cls, resource_id, db_se...
[ "Sets", "node", "position", "for", "new", "node", "in", "the", "tree" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource_tree.py#L163-L178
[ "def", "set_position", "(", "self", ",", "resource_id", ",", "to_position", ",", "db_session", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "service", ".", "set_position", "(", "resource_id", "=", "resource_id", ...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceTreeService.check_node_parent
Checks if parent destination is valid for node :param resource_id: :param new_parent_id: :param db_session: :return:
ziggurat_foundations/models/services/resource_tree.py
def check_node_parent( self, resource_id, new_parent_id, db_session=None, *args, **kwargs ): """ Checks if parent destination is valid for node :param resource_id: :param new_parent_id: :param db_session: :return: """ return self.service.check...
def check_node_parent( self, resource_id, new_parent_id, db_session=None, *args, **kwargs ): """ Checks if parent destination is valid for node :param resource_id: :param new_parent_id: :param db_session: :return: """ return self.service.check...
[ "Checks", "if", "parent", "destination", "is", "valid", "for", "node" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource_tree.py#L180-L197
[ "def", "check_node_parent", "(", "self", ",", "resource_id", ",", "new_parent_id", ",", "db_session", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "service", ".", "check_node_parent", "(", "resource_id", "=", "re...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceTreeService.count_children
Counts children of resource node :param resource_id: :param db_session: :return:
ziggurat_foundations/models/services/resource_tree.py
def count_children(self, resource_id, db_session=None, *args, **kwargs): """ Counts children of resource node :param resource_id: :param db_session: :return: """ return self.service.count_children( resource_id=resource_id, db_session=db_session, *args...
def count_children(self, resource_id, db_session=None, *args, **kwargs): """ Counts children of resource node :param resource_id: :param db_session: :return: """ return self.service.count_children( resource_id=resource_id, db_session=db_session, *args...
[ "Counts", "children", "of", "resource", "node" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource_tree.py#L199-L209
[ "def", "count_children", "(", "self", ",", "resource_id", ",", "db_session", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "service", ".", "count_children", "(", "resource_id", "=", "resource_id", ",", "db_session...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceTreeService.check_node_position
Checks if node position for given parent is valid, raises exception if this is not the case :param parent_id: :param position: :param on_same_branch: indicates that we are checking same branch :param db_session: :return:
ziggurat_foundations/models/services/resource_tree.py
def check_node_position( self, parent_id, position, on_same_branch, db_session=None, *args, **kwargs ): """ Checks if node position for given parent is valid, raises exception if this is not the case :param parent_id: :param position: :param on_same_branch: i...
def check_node_position( self, parent_id, position, on_same_branch, db_session=None, *args, **kwargs ): """ Checks if node position for given parent is valid, raises exception if this is not the case :param parent_id: :param position: :param on_same_branch: i...
[ "Checks", "if", "node", "position", "for", "given", "parent", "is", "valid", "raises", "exception", "if", "this", "is", "not", "the", "case" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource_tree.py#L211-L231
[ "def", "check_node_position", "(", "self", ",", "parent_id", ",", "position", ",", "on_same_branch", ",", "db_session", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "service", ".", "check_node_position", "(", "pa...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
flatten_list
takes a list of lists, l and returns a flat list
nemreader/nem_reader.py
def flatten_list(l: List[list]) -> list: """ takes a list of lists, l and returns a flat list """ return [v for inner_l in l for v in inner_l]
def flatten_list(l: List[list]) -> list: """ takes a list of lists, l and returns a flat list """ return [v for inner_l in l for v in inner_l]
[ "takes", "a", "list", "of", "lists", "l", "and", "returns", "a", "flat", "list" ]
aguinane/nem-reader
python
https://github.com/aguinane/nem-reader/blob/5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5/nemreader/nem_reader.py#L17-L20
[ "def", "flatten_list", "(", "l", ":", "List", "[", "list", "]", ")", "->", "list", ":", "return", "[", "v", "for", "inner_l", "in", "l", "for", "v", "in", "inner_l", "]" ]
5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5
train
read_nem_file
Read in NEM file and return meter readings named tuple :param file_path: The NEM file to process :returns: The file that was created
nemreader/nem_reader.py
def read_nem_file(file_path: str) -> NEMFile: """ Read in NEM file and return meter readings named tuple :param file_path: The NEM file to process :returns: The file that was created """ _, file_extension = os.path.splitext(file_path) if file_extension.lower() == '.zip': with zipfile.Z...
def read_nem_file(file_path: str) -> NEMFile: """ Read in NEM file and return meter readings named tuple :param file_path: The NEM file to process :returns: The file that was created """ _, file_extension = os.path.splitext(file_path) if file_extension.lower() == '.zip': with zipfile.Z...
[ "Read", "in", "NEM", "file", "and", "return", "meter", "readings", "named", "tuple" ]
aguinane/nem-reader
python
https://github.com/aguinane/nem-reader/blob/5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5/nemreader/nem_reader.py#L23-L42
[ "def", "read_nem_file", "(", "file_path", ":", "str", ")", "->", "NEMFile", ":", "_", ",", "file_extension", "=", "os", ".", "path", ".", "splitext", "(", "file_path", ")", "if", "file_extension", ".", "lower", "(", ")", "==", "'.zip'", ":", "with", "z...
5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5
train
parse_nem_file
Parse NEM file and return meter readings named tuple
nemreader/nem_reader.py
def parse_nem_file(nem_file) -> NEMFile: """ Parse NEM file and return meter readings named tuple """ reader = csv.reader(nem_file, delimiter=',') return parse_nem_rows(reader, file_name=nem_file)
def parse_nem_file(nem_file) -> NEMFile: """ Parse NEM file and return meter readings named tuple """ reader = csv.reader(nem_file, delimiter=',') return parse_nem_rows(reader, file_name=nem_file)
[ "Parse", "NEM", "file", "and", "return", "meter", "readings", "named", "tuple" ]
aguinane/nem-reader
python
https://github.com/aguinane/nem-reader/blob/5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5/nemreader/nem_reader.py#L45-L48
[ "def", "parse_nem_file", "(", "nem_file", ")", "->", "NEMFile", ":", "reader", "=", "csv", ".", "reader", "(", "nem_file", ",", "delimiter", "=", "','", ")", "return", "parse_nem_rows", "(", "reader", ",", "file_name", "=", "nem_file", ")" ]
5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5
train
parse_nem_rows
Parse NEM row iterator and return meter readings named tuple
nemreader/nem_reader.py
def parse_nem_rows(nem_list: Iterable, file_name=None) -> NEMFile: """ Parse NEM row iterator and return meter readings named tuple """ header = HeaderRecord(None, None, None, None, file_name) readings = dict() # readings nested by NMI then channel trans = dict() # transactions nested by NMI then cha...
def parse_nem_rows(nem_list: Iterable, file_name=None) -> NEMFile: """ Parse NEM row iterator and return meter readings named tuple """ header = HeaderRecord(None, None, None, None, file_name) readings = dict() # readings nested by NMI then channel trans = dict() # transactions nested by NMI then cha...
[ "Parse", "NEM", "row", "iterator", "and", "return", "meter", "readings", "named", "tuple" ]
aguinane/nem-reader
python
https://github.com/aguinane/nem-reader/blob/5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5/nemreader/nem_reader.py#L51-L140
[ "def", "parse_nem_rows", "(", "nem_list", ":", "Iterable", ",", "file_name", "=", "None", ")", "->", "NEMFile", ":", "header", "=", "HeaderRecord", "(", "None", ",", "None", ",", "None", ",", "None", ",", "file_name", ")", "readings", "=", "dict", "(", ...
5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5
train
calculate_manual_reading
Calculate the interval between two manual readings
nemreader/nem_reader.py
def calculate_manual_reading(basic_data: BasicMeterData) -> Reading: """ Calculate the interval between two manual readings """ t_start = basic_data.previous_register_read_datetime t_end = basic_data.current_register_read_datetime read_start = basic_data.previous_register_read read_end = basic_data....
def calculate_manual_reading(basic_data: BasicMeterData) -> Reading: """ Calculate the interval between two manual readings """ t_start = basic_data.previous_register_read_datetime t_end = basic_data.current_register_read_datetime read_start = basic_data.previous_register_read read_end = basic_data....
[ "Calculate", "the", "interval", "between", "two", "manual", "readings" ]
aguinane/nem-reader
python
https://github.com/aguinane/nem-reader/blob/5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5/nemreader/nem_reader.py#L143-L155
[ "def", "calculate_manual_reading", "(", "basic_data", ":", "BasicMeterData", ")", "->", "Reading", ":", "t_start", "=", "basic_data", ".", "previous_register_read_datetime", "t_end", "=", "basic_data", ".", "current_register_read_datetime", "read_start", "=", "basic_data"...
5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5
train
parse_100_row
Parse header record (100)
nemreader/nem_reader.py
def parse_100_row(row: list, file_name: str) -> HeaderRecord: """ Parse header record (100) """ return HeaderRecord( row[1], parse_datetime(row[2]), row[3], row[4], file_name, )
def parse_100_row(row: list, file_name: str) -> HeaderRecord: """ Parse header record (100) """ return HeaderRecord( row[1], parse_datetime(row[2]), row[3], row[4], file_name, )
[ "Parse", "header", "record", "(", "100", ")" ]
aguinane/nem-reader
python
https://github.com/aguinane/nem-reader/blob/5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5/nemreader/nem_reader.py#L158-L166
[ "def", "parse_100_row", "(", "row", ":", "list", ",", "file_name", ":", "str", ")", "->", "HeaderRecord", ":", "return", "HeaderRecord", "(", "row", "[", "1", "]", ",", "parse_datetime", "(", "row", "[", "2", "]", ")", ",", "row", "[", "3", "]", ",...
5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5
train
parse_200_row
Parse NMI data details record (200)
nemreader/nem_reader.py
def parse_200_row(row: list) -> NmiDetails: """ Parse NMI data details record (200) """ return NmiDetails(row[1], row[2], row[3], row[4], row[5], row[6], row[7], int(row[8]), parse_datetime(row[9]))
def parse_200_row(row: list) -> NmiDetails: """ Parse NMI data details record (200) """ return NmiDetails(row[1], row[2], row[3], row[4], row[5], row[6], row[7], int(row[8]), parse_datetime(row[9]))
[ "Parse", "NMI", "data", "details", "record", "(", "200", ")" ]
aguinane/nem-reader
python
https://github.com/aguinane/nem-reader/blob/5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5/nemreader/nem_reader.py#L169-L172
[ "def", "parse_200_row", "(", "row", ":", "list", ")", "->", "NmiDetails", ":", "return", "NmiDetails", "(", "row", "[", "1", "]", ",", "row", "[", "2", "]", ",", "row", "[", "3", "]", ",", "row", "[", "4", "]", ",", "row", "[", "5", "]", ",",...
5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5
train
parse_250_row
Parse basic meter data record (250)
nemreader/nem_reader.py
def parse_250_row(row: list) -> BasicMeterData: """ Parse basic meter data record (250) """ return BasicMeterData(row[1], row[2], row[3], row[4], row[5], row[6], row[7], float(row[8]), parse_datetime(row[9]), row[10], row[11], row[12], ...
def parse_250_row(row: list) -> BasicMeterData: """ Parse basic meter data record (250) """ return BasicMeterData(row[1], row[2], row[3], row[4], row[5], row[6], row[7], float(row[8]), parse_datetime(row[9]), row[10], row[11], row[12], ...
[ "Parse", "basic", "meter", "data", "record", "(", "250", ")" ]
aguinane/nem-reader
python
https://github.com/aguinane/nem-reader/blob/5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5/nemreader/nem_reader.py#L175-L183
[ "def", "parse_250_row", "(", "row", ":", "list", ")", "->", "BasicMeterData", ":", "return", "BasicMeterData", "(", "row", "[", "1", "]", ",", "row", "[", "2", "]", ",", "row", "[", "3", "]", ",", "row", "[", "4", "]", ",", "row", "[", "5", "]"...
5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5
train
parse_300_row
Interval data record (300)
nemreader/nem_reader.py
def parse_300_row(row: list, interval: int, uom: str) -> IntervalRecord: """ Interval data record (300) """ num_intervals = int(24 * 60 / interval) interval_date = parse_datetime(row[1]) last_interval = 2 + num_intervals quality_method = row[last_interval] interval_values = parse_interval_reco...
def parse_300_row(row: list, interval: int, uom: str) -> IntervalRecord: """ Interval data record (300) """ num_intervals = int(24 * 60 / interval) interval_date = parse_datetime(row[1]) last_interval = 2 + num_intervals quality_method = row[last_interval] interval_values = parse_interval_reco...
[ "Interval", "data", "record", "(", "300", ")" ]
aguinane/nem-reader
python
https://github.com/aguinane/nem-reader/blob/5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5/nemreader/nem_reader.py#L186-L201
[ "def", "parse_300_row", "(", "row", ":", "list", ",", "interval", ":", "int", ",", "uom", ":", "str", ")", "->", "IntervalRecord", ":", "num_intervals", "=", "int", "(", "24", "*", "60", "/", "interval", ")", "interval_date", "=", "parse_datetime", "(", ...
5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5
train
parse_interval_records
Convert interval values into tuples with datetime
nemreader/nem_reader.py
def parse_interval_records(interval_record, interval_date, interval, uom, quality_method) -> List[Reading]: """ Convert interval values into tuples with datetime """ interval_delta = timedelta(minutes=interval) return [ Reading( t_start=interval_date + (i *...
def parse_interval_records(interval_record, interval_date, interval, uom, quality_method) -> List[Reading]: """ Convert interval values into tuples with datetime """ interval_delta = timedelta(minutes=interval) return [ Reading( t_start=interval_date + (i *...
[ "Convert", "interval", "values", "into", "tuples", "with", "datetime" ]
aguinane/nem-reader
python
https://github.com/aguinane/nem-reader/blob/5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5/nemreader/nem_reader.py#L204-L221
[ "def", "parse_interval_records", "(", "interval_record", ",", "interval_date", ",", "interval", ",", "uom", ",", "quality_method", ")", "->", "List", "[", "Reading", "]", ":", "interval_delta", "=", "timedelta", "(", "minutes", "=", "interval", ")", "return", ...
5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5
train
parse_reading
Convert reading value to float (if possible)
nemreader/nem_reader.py
def parse_reading(val: str) -> Optional[float]: """ Convert reading value to float (if possible) """ try: return float(val) except ValueError: logging.warning('Reading of "%s" is not a number', val) return None
def parse_reading(val: str) -> Optional[float]: """ Convert reading value to float (if possible) """ try: return float(val) except ValueError: logging.warning('Reading of "%s" is not a number', val) return None
[ "Convert", "reading", "value", "to", "float", "(", "if", "possible", ")" ]
aguinane/nem-reader
python
https://github.com/aguinane/nem-reader/blob/5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5/nemreader/nem_reader.py#L224-L230
[ "def", "parse_reading", "(", "val", ":", "str", ")", "->", "Optional", "[", "float", "]", ":", "try", ":", "return", "float", "(", "val", ")", "except", "ValueError", ":", "logging", ".", "warning", "(", "'Reading of \"%s\" is not a number'", ",", "val", "...
5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5
train
parse_400_row
Interval event record (400)
nemreader/nem_reader.py
def parse_400_row(row: list) -> tuple: """ Interval event record (400) """ return EventRecord(int(row[1]), int(row[2]), row[3], row[4], row[5])
def parse_400_row(row: list) -> tuple: """ Interval event record (400) """ return EventRecord(int(row[1]), int(row[2]), row[3], row[4], row[5])
[ "Interval", "event", "record", "(", "400", ")" ]
aguinane/nem-reader
python
https://github.com/aguinane/nem-reader/blob/5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5/nemreader/nem_reader.py#L233-L236
[ "def", "parse_400_row", "(", "row", ":", "list", ")", "->", "tuple", ":", "return", "EventRecord", "(", "int", "(", "row", "[", "1", "]", ")", ",", "int", "(", "row", "[", "2", "]", ")", ",", "row", "[", "3", "]", ",", "row", "[", "4", "]", ...
5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5
train
update_reading_events
Updates readings from a 300 row to reflect any events found in a subsequent 400 row
nemreader/nem_reader.py
def update_reading_events(readings, event_record): """ Updates readings from a 300 row to reflect any events found in a subsequent 400 row """ # event intervals are 1-indexed for i in range(event_record.start_interval - 1, event_record.end_interval): readings[i] = Reading( t_...
def update_reading_events(readings, event_record): """ Updates readings from a 300 row to reflect any events found in a subsequent 400 row """ # event intervals are 1-indexed for i in range(event_record.start_interval - 1, event_record.end_interval): readings[i] = Reading( t_...
[ "Updates", "readings", "from", "a", "300", "row", "to", "reflect", "any", "events", "found", "in", "a", "subsequent", "400", "row" ]
aguinane/nem-reader
python
https://github.com/aguinane/nem-reader/blob/5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5/nemreader/nem_reader.py#L239-L255
[ "def", "update_reading_events", "(", "readings", ",", "event_record", ")", ":", "# event intervals are 1-indexed", "for", "i", "in", "range", "(", "event_record", ".", "start_interval", "-", "1", ",", "event_record", ".", "end_interval", ")", ":", "readings", "[",...
5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5
train
parse_datetime
Parse a datetime string into a python datetime object
nemreader/nem_reader.py
def parse_datetime(record: str) -> Optional[datetime]: """ Parse a datetime string into a python datetime object """ # NEM defines Date8, DateTime12 and DateTime14 format_strings = {8: '%Y%m%d', 12: '%Y%m%d%H%M', 14: '%Y%m%d%H%M%S'} if record == '': return None return datetime.strptime(recor...
def parse_datetime(record: str) -> Optional[datetime]: """ Parse a datetime string into a python datetime object """ # NEM defines Date8, DateTime12 and DateTime14 format_strings = {8: '%Y%m%d', 12: '%Y%m%d%H%M', 14: '%Y%m%d%H%M%S'} if record == '': return None return datetime.strptime(recor...
[ "Parse", "a", "datetime", "string", "into", "a", "python", "datetime", "object" ]
aguinane/nem-reader
python
https://github.com/aguinane/nem-reader/blob/5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5/nemreader/nem_reader.py#L268-L275
[ "def", "parse_datetime", "(", "record", ":", "str", ")", "->", "Optional", "[", "datetime", "]", ":", "# NEM defines Date8, DateTime12 and DateTime14", "format_strings", "=", "{", "8", ":", "'%Y%m%d'", ",", "12", ":", "'%Y%m%d%H%M'", ",", "14", ":", "'%Y%m%d%H%M...
5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5
train
Settings.parse_args
Called from ``gnotty.server.run`` and parses any CLI args provided. Also handles loading settings from the Python module specified with the ``--conf-file`` arg. CLI args take precedence over any settings defined in the Python module defined by ``--conf-file``.
gnotty/conf.py
def parse_args(self): """ Called from ``gnotty.server.run`` and parses any CLI args provided. Also handles loading settings from the Python module specified with the ``--conf-file`` arg. CLI args take precedence over any settings defined in the Python module defined by ``...
def parse_args(self): """ Called from ``gnotty.server.run`` and parses any CLI args provided. Also handles loading settings from the Python module specified with the ``--conf-file`` arg. CLI args take precedence over any settings defined in the Python module defined by ``...
[ "Called", "from", "gnotty", ".", "server", ".", "run", "and", "parses", "any", "CLI", "args", "provided", ".", "Also", "handles", "loading", "settings", "from", "the", "Python", "module", "specified", "with", "the", "--", "conf", "-", "file", "arg", ".", ...
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/conf.py#L94-L125
[ "def", "parse_args", "(", "self", ")", ":", "options", ",", "_", "=", "parser", ".", "parse_args", "(", ")", "file_settings", "=", "{", "}", "if", "options", ".", "CONF_FILE", ":", "execfile", "(", "options", ".", "CONF_FILE", ",", "{", "}", ",", "fi...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
color
Provides a consistent color for a nickname. Uses first 6 chars of nickname's md5 hash, and then slightly darkens the rgb values for use on a light background.
gnotty/client.py
def color(nickname): """ Provides a consistent color for a nickname. Uses first 6 chars of nickname's md5 hash, and then slightly darkens the rgb values for use on a light background. """ _hex = md5(nickname).hexdigest()[:6] darken = lambda s: str(int(round(int(s, 16) * .7))) return "rgb...
def color(nickname): """ Provides a consistent color for a nickname. Uses first 6 chars of nickname's md5 hash, and then slightly darkens the rgb values for use on a light background. """ _hex = md5(nickname).hexdigest()[:6] darken = lambda s: str(int(round(int(s, 16) * .7))) return "rgb...
[ "Provides", "a", "consistent", "color", "for", "a", "nickname", ".", "Uses", "first", "6", "chars", "of", "nickname", "s", "md5", "hash", "and", "then", "slightly", "darkens", "the", "rgb", "values", "for", "use", "on", "a", "light", "background", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/client.py#L10-L18
[ "def", "color", "(", "nickname", ")", ":", "_hex", "=", "md5", "(", "nickname", ")", ".", "hexdigest", "(", ")", "[", ":", "6", "]", "darken", "=", "lambda", "s", ":", "str", "(", "int", "(", "round", "(", "int", "(", "s", ",", "16", ")", "*"...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
BaseIRCClient.on_welcome
Join the channel once connected to the IRC server.
gnotty/client.py
def on_welcome(self, connection, event): """ Join the channel once connected to the IRC server. """ connection.join(self.channel, key=settings.IRC_CHANNEL_KEY or "")
def on_welcome(self, connection, event): """ Join the channel once connected to the IRC server. """ connection.join(self.channel, key=settings.IRC_CHANNEL_KEY or "")
[ "Join", "the", "channel", "once", "connected", "to", "the", "IRC", "server", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/client.py#L64-L68
[ "def", "on_welcome", "(", "self", ",", "connection", ",", "event", ")", ":", "connection", ".", "join", "(", "self", ".", "channel", ",", "key", "=", "settings", ".", "IRC_CHANNEL_KEY", "or", "\"\"", ")" ]
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
BaseIRCClient.on_nicknameinuse
Increment a digit on the nickname if it's in use, and re-connect.
gnotty/client.py
def on_nicknameinuse(self, connection, event): """ Increment a digit on the nickname if it's in use, and re-connect. """ digits = "" while self.nickname[-1].isdigit(): digits = self.nickname[-1] + digits self.nickname = self.nickname[:-1] d...
def on_nicknameinuse(self, connection, event): """ Increment a digit on the nickname if it's in use, and re-connect. """ digits = "" while self.nickname[-1].isdigit(): digits = self.nickname[-1] + digits self.nickname = self.nickname[:-1] d...
[ "Increment", "a", "digit", "on", "the", "nickname", "if", "it", "s", "in", "use", "and", "re", "-", "connect", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/client.py#L70-L81
[ "def", "on_nicknameinuse", "(", "self", ",", "connection", ",", "event", ")", ":", "digits", "=", "\"\"", "while", "self", ".", "nickname", "[", "-", "1", "]", ".", "isdigit", "(", ")", ":", "digits", "=", "self", ".", "nickname", "[", "-", "1", "]...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
BaseIRCClient.message_channel
Nicer shortcut for sending a message to a channel. Also irclib doesn't handle unicode so we bypass its privmsg -> send_raw methods and use its socket directly.
gnotty/client.py
def message_channel(self, message): """ Nicer shortcut for sending a message to a channel. Also irclib doesn't handle unicode so we bypass its privmsg -> send_raw methods and use its socket directly. """ data = "PRIVMSG %s :%s\r\n" % (self.channel, message) self.c...
def message_channel(self, message): """ Nicer shortcut for sending a message to a channel. Also irclib doesn't handle unicode so we bypass its privmsg -> send_raw methods and use its socket directly. """ data = "PRIVMSG %s :%s\r\n" % (self.channel, message) self.c...
[ "Nicer", "shortcut", "for", "sending", "a", "message", "to", "a", "channel", ".", "Also", "irclib", "doesn", "t", "handle", "unicode", "so", "we", "bypass", "its", "privmsg", "-", ">", "send_raw", "methods", "and", "use", "its", "socket", "directly", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/client.py#L83-L90
[ "def", "message_channel", "(", "self", ",", "message", ")", ":", "data", "=", "\"PRIVMSG %s :%s\\r\\n\"", "%", "(", "self", ".", "channel", ",", "message", ")", "self", ".", "connection", ".", "socket", ".", "send", "(", "data", ".", "encode", "(", "\"ut...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
WebSocketIRCClient.emit_message
Send a message to the channel. We also emit the message back to the sender's WebSocket.
gnotty/client.py
def emit_message(self, message): """ Send a message to the channel. We also emit the message back to the sender's WebSocket. """ try: nickname_color = self.nicknames[self.nickname] except KeyError: # Only accept messages if we've joined. ...
def emit_message(self, message): """ Send a message to the channel. We also emit the message back to the sender's WebSocket. """ try: nickname_color = self.nicknames[self.nickname] except KeyError: # Only accept messages if we've joined. ...
[ "Send", "a", "message", "to", "the", "channel", ".", "We", "also", "emit", "the", "message", "back", "to", "the", "sender", "s", "WebSocket", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/client.py#L104-L120
[ "def", "emit_message", "(", "self", ",", "message", ")", ":", "try", ":", "nickname_color", "=", "self", ".", "nicknames", "[", "self", ".", "nickname", "]", "except", "KeyError", ":", "# Only accept messages if we've joined.", "return", "message", "=", "message...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
WebSocketIRCClient.emit_nicknames
Send the nickname list to the Websocket. Called whenever the nicknames list changes.
gnotty/client.py
def emit_nicknames(self): """ Send the nickname list to the Websocket. Called whenever the nicknames list changes. """ nicknames = [{"nickname": name, "color": color(name)} for name in sorted(self.nicknames.keys())] self.namespace.emit("nicknames", ni...
def emit_nicknames(self): """ Send the nickname list to the Websocket. Called whenever the nicknames list changes. """ nicknames = [{"nickname": name, "color": color(name)} for name in sorted(self.nicknames.keys())] self.namespace.emit("nicknames", ni...
[ "Send", "the", "nickname", "list", "to", "the", "Websocket", ".", "Called", "whenever", "the", "nicknames", "list", "changes", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/client.py#L122-L129
[ "def", "emit_nicknames", "(", "self", ")", ":", "nicknames", "=", "[", "{", "\"nickname\"", ":", "name", ",", "\"color\"", ":", "color", "(", "name", ")", "}", "for", "name", "in", "sorted", "(", "self", ".", "nicknames", ".", "keys", "(", ")", ")", ...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
WebSocketIRCClient.on_namreply
Initial list of nicknames received - remove op/voice prefixes, and send the list to the WebSocket.
gnotty/client.py
def on_namreply(self, connection, event): """ Initial list of nicknames received - remove op/voice prefixes, and send the list to the WebSocket. """ for nickname in event.arguments()[-1].split(): nickname = nickname.lstrip("@+") self.nicknames[nickname] = ...
def on_namreply(self, connection, event): """ Initial list of nicknames received - remove op/voice prefixes, and send the list to the WebSocket. """ for nickname in event.arguments()[-1].split(): nickname = nickname.lstrip("@+") self.nicknames[nickname] = ...
[ "Initial", "list", "of", "nicknames", "received", "-", "remove", "op", "/", "voice", "prefixes", "and", "send", "the", "list", "to", "the", "WebSocket", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/client.py#L137-L145
[ "def", "on_namreply", "(", "self", ",", "connection", ",", "event", ")", ":", "for", "nickname", "in", "event", ".", "arguments", "(", ")", "[", "-", "1", "]", ".", "split", "(", ")", ":", "nickname", "=", "nickname", ".", "lstrip", "(", "\"@+\"", ...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
WebSocketIRCClient.on_join
Someone joined the channel - send the nicknames list to the WebSocket.
gnotty/client.py
def on_join(self, connection, event): """ Someone joined the channel - send the nicknames list to the WebSocket. """ #from time import sleep; sleep(10) # Simulate a slow connection nickname = self.get_nickname(event) nickname_color = color(nickname) self....
def on_join(self, connection, event): """ Someone joined the channel - send the nicknames list to the WebSocket. """ #from time import sleep; sleep(10) # Simulate a slow connection nickname = self.get_nickname(event) nickname_color = color(nickname) self....
[ "Someone", "joined", "the", "channel", "-", "send", "the", "nicknames", "list", "to", "the", "WebSocket", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/client.py#L147-L158
[ "def", "on_join", "(", "self", ",", "connection", ",", "event", ")", ":", "#from time import sleep; sleep(10) # Simulate a slow connection", "nickname", "=", "self", ".", "get_nickname", "(", "event", ")", "nickname_color", "=", "color", "(", "nickname", ")", "self...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
WebSocketIRCClient.on_nick
Someone changed their nickname - send the nicknames list to the WebSocket.
gnotty/client.py
def on_nick(self, connection, event): """ Someone changed their nickname - send the nicknames list to the WebSocket. """ old_nickname = self.get_nickname(event) old_color = self.nicknames.pop(old_nickname) new_nickname = event.target() message = "is now kn...
def on_nick(self, connection, event): """ Someone changed their nickname - send the nicknames list to the WebSocket. """ old_nickname = self.get_nickname(event) old_color = self.nicknames.pop(old_nickname) new_nickname = event.target() message = "is now kn...
[ "Someone", "changed", "their", "nickname", "-", "send", "the", "nicknames", "list", "to", "the", "WebSocket", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/client.py#L160-L174
[ "def", "on_nick", "(", "self", ",", "connection", ",", "event", ")", ":", "old_nickname", "=", "self", ".", "get_nickname", "(", "event", ")", "old_color", "=", "self", ".", "nicknames", ".", "pop", "(", "old_nickname", ")", "new_nickname", "=", "event", ...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
WebSocketIRCClient.on_quit
Someone left the channel - send the nicknames list to the WebSocket.
gnotty/client.py
def on_quit(self, connection, event): """ Someone left the channel - send the nicknames list to the WebSocket. """ nickname = self.get_nickname(event) nickname_color = self.nicknames[nickname] del self.nicknames[nickname] self.namespace.emit("message", nic...
def on_quit(self, connection, event): """ Someone left the channel - send the nicknames list to the WebSocket. """ nickname = self.get_nickname(event) nickname_color = self.nicknames[nickname] del self.nicknames[nickname] self.namespace.emit("message", nic...
[ "Someone", "left", "the", "channel", "-", "send", "the", "nicknames", "list", "to", "the", "WebSocket", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/client.py#L176-L185
[ "def", "on_quit", "(", "self", ",", "connection", ",", "event", ")", ":", "nickname", "=", "self", ".", "get_nickname", "(", "event", ")", "nickname_color", "=", "self", ".", "nicknames", "[", "nickname", "]", "del", "self", ".", "nicknames", "[", "nickn...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
WebSocketIRCClient.on_pubmsg
Messages received in the channel - send them to the WebSocket.
gnotty/client.py
def on_pubmsg(self, connection, event): """ Messages received in the channel - send them to the WebSocket. """ for message in event.arguments(): nickname = self.get_nickname(event) nickname_color = self.nicknames[nickname] self.namespace.emit("message"...
def on_pubmsg(self, connection, event): """ Messages received in the channel - send them to the WebSocket. """ for message in event.arguments(): nickname = self.get_nickname(event) nickname_color = self.nicknames[nickname] self.namespace.emit("message"...
[ "Messages", "received", "in", "the", "channel", "-", "send", "them", "to", "the", "WebSocket", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/client.py#L187-L194
[ "def", "on_pubmsg", "(", "self", ",", "connection", ",", "event", ")", ":", "for", "message", "in", "event", ".", "arguments", "(", ")", ":", "nickname", "=", "self", ".", "get_nickname", "(", "event", ")", "nickname_color", "=", "self", ".", "nicknames"...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
ResourceService.get
Fetch row using primary key - will use existing object in session if already present :param resource_id: :param db_session: :return:
ziggurat_foundations/models/services/resource.py
def get(cls, resource_id, db_session=None): """ Fetch row using primary key - will use existing object in session if already present :param resource_id: :param db_session: :return: """ db_session = get_db_session(db_session) return db_session.quer...
def get(cls, resource_id, db_session=None): """ Fetch row using primary key - will use existing object in session if already present :param resource_id: :param db_session: :return: """ db_session = get_db_session(db_session) return db_session.quer...
[ "Fetch", "row", "using", "primary", "key", "-", "will", "use", "existing", "object", "in", "session", "if", "already", "present" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource.py#L20-L30
[ "def", "get", "(", "cls", ",", "resource_id", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "return", "db_session", ".", "query", "(", "cls", ".", "model", ")", ".", "get", "(", "resource_id", ")" ...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceService.perms_for_user
returns all permissions that given user has for this resource from groups and directly set ones too :param instance: :param user: :param db_session: :return:
ziggurat_foundations/models/services/resource.py
def perms_for_user(cls, instance, user, db_session=None): """ returns all permissions that given user has for this resource from groups and directly set ones too :param instance: :param user: :param db_session: :return: """ db_session = get_db...
def perms_for_user(cls, instance, user, db_session=None): """ returns all permissions that given user has for this resource from groups and directly set ones too :param instance: :param user: :param db_session: :return: """ db_session = get_db...
[ "returns", "all", "permissions", "that", "given", "user", "has", "for", "this", "resource", "from", "groups", "and", "directly", "set", "ones", "too" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource.py#L33-L106
[ "def", "perms_for_user", "(", "cls", ",", "instance", ",", "user", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ",", "instance", ")", "query", "=", "db_session", ".", "query", "(", "cls", ".", "models_pr...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceService.direct_perms_for_user
returns permissions that given user has for this resource without ones inherited from groups that user belongs to :param instance: :param user: :param db_session: :return:
ziggurat_foundations/models/services/resource.py
def direct_perms_for_user(cls, instance, user, db_session=None): """ returns permissions that given user has for this resource without ones inherited from groups that user belongs to :param instance: :param user: :param db_session: :return: """ ...
def direct_perms_for_user(cls, instance, user, db_session=None): """ returns permissions that given user has for this resource without ones inherited from groups that user belongs to :param instance: :param user: :param db_session: :return: """ ...
[ "returns", "permissions", "that", "given", "user", "has", "for", "this", "resource", "without", "ones", "inherited", "from", "groups", "that", "user", "belongs", "to" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource.py#L109-L139
[ "def", "direct_perms_for_user", "(", "cls", ",", "instance", ",", "user", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ",", "instance", ")", "query", "=", "db_session", ".", "query", "(", "cls", ".", "mo...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceService.group_perms_for_user
returns permissions that given user has for this resource that are inherited from groups :param instance: :param user: :param db_session: :return:
ziggurat_foundations/models/services/resource.py
def group_perms_for_user(cls, instance, user, db_session=None): """ returns permissions that given user has for this resource that are inherited from groups :param instance: :param user: :param db_session: :return: """ db_session = get_db_sess...
def group_perms_for_user(cls, instance, user, db_session=None): """ returns permissions that given user has for this resource that are inherited from groups :param instance: :param user: :param db_session: :return: """ db_session = get_db_sess...
[ "returns", "permissions", "that", "given", "user", "has", "for", "this", "resource", "that", "are", "inherited", "from", "groups" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource.py#L142-L175
[ "def", "group_perms_for_user", "(", "cls", ",", "instance", ",", "user", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ",", "instance", ")", "perms", "=", "resource_permissions_for_users", "(", "cls", ".", "m...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceService.users_for_perm
return PermissionTuples for users AND groups that have given permission for the resource, perm_name is __any_permission__ then users with any permission will be listed :param instance: :param perm_name: :param user_ids: limits the permissions to specific user ids :param ...
ziggurat_foundations/models/services/resource.py
def users_for_perm( cls, instance, perm_name, user_ids=None, group_ids=None, limit_group_permissions=False, skip_group_perms=False, db_session=None, ): """ return PermissionTuples for users AND groups that have given permission ...
def users_for_perm( cls, instance, perm_name, user_ids=None, group_ids=None, limit_group_permissions=False, skip_group_perms=False, db_session=None, ): """ return PermissionTuples for users AND groups that have given permission ...
[ "return", "PermissionTuples", "for", "users", "AND", "groups", "that", "have", "given", "permission", "for", "the", "resource", "perm_name", "is", "__any_permission__", "then", "users", "with", "any", "permission", "will", "be", "listed" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource.py#L178-L235
[ "def", "users_for_perm", "(", "cls", ",", "instance", ",", "perm_name", ",", "user_ids", "=", "None", ",", "group_ids", "=", "None", ",", "limit_group_permissions", "=", "False", ",", "skip_group_perms", "=", "False", ",", "db_session", "=", "None", ",", ")"...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceService.by_resource_id
fetch the resouce by id :param resource_id: :param db_session: :return:
ziggurat_foundations/models/services/resource.py
def by_resource_id(cls, resource_id, db_session=None): """ fetch the resouce by id :param resource_id: :param db_session: :return: """ db_session = get_db_session(db_session) query = db_session.query(cls.model).filter( cls.model.resource_id ==...
def by_resource_id(cls, resource_id, db_session=None): """ fetch the resouce by id :param resource_id: :param db_session: :return: """ db_session = get_db_session(db_session) query = db_session.query(cls.model).filter( cls.model.resource_id ==...
[ "fetch", "the", "resouce", "by", "id" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource.py#L238-L250
[ "def", "by_resource_id", "(", "cls", ",", "resource_id", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "query", "=", "db_session", ".", "query", "(", "cls", ".", "model", ")", ".", "filter", "(", "...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceService.perm_by_group_and_perm_name
fetch permissions by group and permission name :param resource_id: :param group_id: :param perm_name: :param db_session: :return:
ziggurat_foundations/models/services/resource.py
def perm_by_group_and_perm_name( cls, resource_id, group_id, perm_name, db_session=None ): """ fetch permissions by group and permission name :param resource_id: :param group_id: :param perm_name: :param db_session: :return: """ db_ses...
def perm_by_group_and_perm_name( cls, resource_id, group_id, perm_name, db_session=None ): """ fetch permissions by group and permission name :param resource_id: :param group_id: :param perm_name: :param db_session: :return: """ db_ses...
[ "fetch", "permissions", "by", "group", "and", "permission", "name" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource.py#L253-L276
[ "def", "perm_by_group_and_perm_name", "(", "cls", ",", "resource_id", ",", "group_id", ",", "perm_name", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "query", "=", "db_session", ".", "query", "(", "cls"...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceService.groups_for_perm
return PermissionTuples for groups that have given permission for the resource, perm_name is __any_permission__ then users with any permission will be listed :param instance: :param perm_name: :param group_ids: limits the permissions to specific group ids :param limit_gr...
ziggurat_foundations/models/services/resource.py
def groups_for_perm( cls, instance, perm_name, group_ids=None, limit_group_permissions=False, db_session=None, ): """ return PermissionTuples for groups that have given permission for the resource, perm_name is __any_permission__ then u...
def groups_for_perm( cls, instance, perm_name, group_ids=None, limit_group_permissions=False, db_session=None, ): """ return PermissionTuples for groups that have given permission for the resource, perm_name is __any_permission__ then u...
[ "return", "PermissionTuples", "for", "groups", "that", "have", "given", "permission", "for", "the", "resource", "perm_name", "is", "__any_permission__", "then", "users", "with", "any", "permission", "will", "be", "listed" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource.py#L279-L325
[ "def", "groups_for_perm", "(", "cls", ",", "instance", ",", "perm_name", ",", "group_ids", "=", "None", ",", "limit_group_permissions", "=", "False", ",", "db_session", "=", "None", ",", ")", ":", "# noqa", "db_session", "=", "get_db_session", "(", "db_session...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceService.lock_resource_for_update
Selects resource for update - locking access for other transactions :param resource_id: :param db_session: :return:
ziggurat_foundations/models/services/resource.py
def lock_resource_for_update(cls, resource_id, db_session): """ Selects resource for update - locking access for other transactions :param resource_id: :param db_session: :return: """ db_session = get_db_session(db_session) query = db_session.query(cls.mo...
def lock_resource_for_update(cls, resource_id, db_session): """ Selects resource for update - locking access for other transactions :param resource_id: :param db_session: :return: """ db_session = get_db_session(db_session) query = db_session.query(cls.mo...
[ "Selects", "resource", "for", "update", "-", "locking", "access", "for", "other", "transactions" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource.py#L328-L340
[ "def", "lock_resource_for_update", "(", "cls", ",", "resource_id", ",", "db_session", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "query", "=", "db_session", ".", "query", "(", "cls", ".", "model", ")", "query", "=", "query", ".", ...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
UserService.get
Fetch row using primary key - will use existing object in session if already present :param user_id: :param db_session: :return:
ziggurat_foundations/models/services/user.py
def get(cls, user_id, db_session=None): """ Fetch row using primary key - will use existing object in session if already present :param user_id: :param db_session: :return: """ db_session = get_db_session(db_session) return db_session.query(cls.mo...
def get(cls, user_id, db_session=None): """ Fetch row using primary key - will use existing object in session if already present :param user_id: :param db_session: :return: """ db_session = get_db_session(db_session) return db_session.query(cls.mo...
[ "Fetch", "row", "using", "primary", "key", "-", "will", "use", "existing", "object", "in", "session", "if", "already", "present" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/user.py#L24-L34
[ "def", "get", "(", "cls", ",", "user_id", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "return", "db_session", ".", "query", "(", "cls", ".", "model", ")", ".", "get", "(", "user_id", ")" ]
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
UserService.permissions
returns all non-resource permissions based on what groups user belongs and directly set ones for this user :param instance: :param db_session: :return:
ziggurat_foundations/models/services/user.py
def permissions(cls, instance, db_session=None): """ returns all non-resource permissions based on what groups user belongs and directly set ones for this user :param instance: :param db_session: :return: """ db_session = get_db_session(db_session, in...
def permissions(cls, instance, db_session=None): """ returns all non-resource permissions based on what groups user belongs and directly set ones for this user :param instance: :param db_session: :return: """ db_session = get_db_session(db_session, in...
[ "returns", "all", "non", "-", "resource", "permissions", "based", "on", "what", "groups", "user", "belongs", "and", "directly", "set", "ones", "for", "this", "user" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/user.py#L37-L80
[ "def", "permissions", "(", "cls", ",", "instance", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ",", "instance", ")", "query", "=", "db_session", ".", "query", "(", "cls", ".", "models_proxy", ".", "Grou...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
UserService.resources_with_perms
returns all resources that user has perms for (note that at least one perm needs to be met) :param instance: :param perms: :param resource_ids: restricts the search to specific resources :param resource_types: :param db_session: :return:
ziggurat_foundations/models/services/user.py
def resources_with_perms( cls, instance, perms, resource_ids=None, resource_types=None, db_session=None ): """ returns all resources that user has perms for (note that at least one perm needs to be met) :param instance: :param perms: :param resource_ids: ...
def resources_with_perms( cls, instance, perms, resource_ids=None, resource_types=None, db_session=None ): """ returns all resources that user has perms for (note that at least one perm needs to be met) :param instance: :param perms: :param resource_ids: ...
[ "returns", "all", "resources", "that", "user", "has", "perms", "for", "(", "note", "that", "at", "least", "one", "perm", "needs", "to", "be", "met", ")" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/user.py#L83-L157
[ "def", "resources_with_perms", "(", "cls", ",", "instance", ",", "perms", ",", "resource_ids", "=", "None", ",", "resource_types", "=", "None", ",", "db_session", "=", "None", ")", ":", "# owned entities have ALL permissions so we return those resources too", "# even wi...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
UserService.groups_with_resources
Returns a list of groups users belongs to with eager loaded resources owned by those groups :param instance: :return:
ziggurat_foundations/models/services/user.py
def groups_with_resources(cls, instance): """ Returns a list of groups users belongs to with eager loaded resources owned by those groups :param instance: :return: """ return instance.groups_dynamic.options( sa.orm.eagerload(cls.models_proxy.Group.res...
def groups_with_resources(cls, instance): """ Returns a list of groups users belongs to with eager loaded resources owned by those groups :param instance: :return: """ return instance.groups_dynamic.options( sa.orm.eagerload(cls.models_proxy.Group.res...
[ "Returns", "a", "list", "of", "groups", "users", "belongs", "to", "with", "eager", "loaded", "resources", "owned", "by", "those", "groups" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/user.py#L160-L170
[ "def", "groups_with_resources", "(", "cls", ",", "instance", ")", ":", "return", "instance", ".", "groups_dynamic", ".", "options", "(", "sa", ".", "orm", ".", "eagerload", "(", "cls", ".", "models_proxy", ".", "Group", ".", "resources", ")", ")" ]
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
UserService.resources_with_possible_perms
returns list of permissions and resources for this user :param instance: :param resource_ids: restricts the search to specific resources :param resource_types: restricts the search to specific resource types :param db_session: :return:
ziggurat_foundations/models/services/user.py
def resources_with_possible_perms( cls, instance, resource_ids=None, resource_types=None, db_session=None ): """ returns list of permissions and resources for this user :param instance: :param resource_ids: restricts the search to specific resources :param resource_t...
def resources_with_possible_perms( cls, instance, resource_ids=None, resource_types=None, db_session=None ): """ returns list of permissions and resources for this user :param instance: :param resource_ids: restricts the search to specific resources :param resource_t...
[ "returns", "list", "of", "permissions", "and", "resources", "for", "this", "user" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/user.py#L173-L207
[ "def", "resources_with_possible_perms", "(", "cls", ",", "instance", ",", "resource_ids", "=", "None", ",", "resource_types", "=", "None", ",", "db_session", "=", "None", ")", ":", "perms", "=", "resource_permissions_for_users", "(", "cls", ".", "models_proxy", ...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
UserService.gravatar_url
returns user gravatar url :param instance: :param default: :param kwargs: :return:
ziggurat_foundations/models/services/user.py
def gravatar_url(cls, instance, default="mm", **kwargs): """ returns user gravatar url :param instance: :param default: :param kwargs: :return: """ # construct the url hash = hashlib.md5(instance.email.encode("utf8").lower()).hexdigest() i...
def gravatar_url(cls, instance, default="mm", **kwargs): """ returns user gravatar url :param instance: :param default: :param kwargs: :return: """ # construct the url hash = hashlib.md5(instance.email.encode("utf8").lower()).hexdigest() i...
[ "returns", "user", "gravatar", "url" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/user.py#L210-L229
[ "def", "gravatar_url", "(", "cls", ",", "instance", ",", "default", "=", "\"mm\"", ",", "*", "*", "kwargs", ")", ":", "# construct the url", "hash", "=", "hashlib", ".", "md5", "(", "instance", ".", "email", ".", "encode", "(", "\"utf8\"", ")", ".", "l...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
UserService.set_password
sets new password on a user using password manager :param instance: :param raw_password: :return:
ziggurat_foundations/models/services/user.py
def set_password(cls, instance, raw_password): """ sets new password on a user using password manager :param instance: :param raw_password: :return: """ # support API for both passlib 1.x and 2.x hash_callable = getattr( instance.passwordmanag...
def set_password(cls, instance, raw_password): """ sets new password on a user using password manager :param instance: :param raw_password: :return: """ # support API for both passlib 1.x and 2.x hash_callable = getattr( instance.passwordmanag...
[ "sets", "new", "password", "on", "a", "user", "using", "password", "manager" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/user.py#L232-L249
[ "def", "set_password", "(", "cls", ",", "instance", ",", "raw_password", ")", ":", "# support API for both passlib 1.x and 2.x", "hash_callable", "=", "getattr", "(", "instance", ".", "passwordmanager", ",", "\"hash\"", ",", "instance", ".", "passwordmanager", ".", ...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
UserService.check_password
checks string with users password hash using password manager :param instance: :param raw_password: :param enable_hash_migration: if legacy hashes should be migrated :return:
ziggurat_foundations/models/services/user.py
def check_password(cls, instance, raw_password, enable_hash_migration=True): """ checks string with users password hash using password manager :param instance: :param raw_password: :param enable_hash_migration: if legacy hashes should be migrated :return: """ ...
def check_password(cls, instance, raw_password, enable_hash_migration=True): """ checks string with users password hash using password manager :param instance: :param raw_password: :param enable_hash_migration: if legacy hashes should be migrated :return: """ ...
[ "checks", "string", "with", "users", "password", "hash", "using", "password", "manager" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/user.py#L252-L269
[ "def", "check_password", "(", "cls", ",", "instance", ",", "raw_password", ",", "enable_hash_migration", "=", "True", ")", ":", "verified", ",", "replacement_hash", "=", "instance", ".", "passwordmanager", ".", "verify_and_update", "(", "raw_password", ",", "insta...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
UserService.by_id
fetch user by user id :param user_id: :param db_session: :return:
ziggurat_foundations/models/services/user.py
def by_id(cls, user_id, db_session=None): """ fetch user by user id :param user_id: :param db_session: :return: """ db_session = get_db_session(db_session) query = db_session.query(cls.model) query = query.filter(cls.model.id == user_id) q...
def by_id(cls, user_id, db_session=None): """ fetch user by user id :param user_id: :param db_session: :return: """ db_session = get_db_session(db_session) query = db_session.query(cls.model) query = query.filter(cls.model.id == user_id) q...
[ "fetch", "user", "by", "user", "id" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/user.py#L301-L313
[ "def", "by_id", "(", "cls", ",", "user_id", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "query", "=", "db_session", ".", "query", "(", "cls", ".", "model", ")", "query", "=", "query", ".", "fil...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
UserService.by_user_name_and_security_code
fetch user objects by user name and security code :param user_name: :param security_code: :param db_session: :return:
ziggurat_foundations/models/services/user.py
def by_user_name_and_security_code(cls, user_name, security_code, db_session=None): """ fetch user objects by user name and security code :param user_name: :param security_code: :param db_session: :return: """ db_session = get_db_session(db_session) ...
def by_user_name_and_security_code(cls, user_name, security_code, db_session=None): """ fetch user objects by user name and security code :param user_name: :param security_code: :param db_session: :return: """ db_session = get_db_session(db_session) ...
[ "fetch", "user", "objects", "by", "user", "name", "and", "security", "code" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/user.py#L333-L348
[ "def", "by_user_name_and_security_code", "(", "cls", ",", "user_name", ",", "security_code", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "query", "=", "db_session", ".", "query", "(", "cls", ".", "mode...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
UserService.by_user_names
fetch user objects by user names :param user_names: :param db_session: :return:
ziggurat_foundations/models/services/user.py
def by_user_names(cls, user_names, db_session=None): """ fetch user objects by user names :param user_names: :param db_session: :return: """ user_names = [(name or "").lower() for name in user_names] db_session = get_db_session(db_session) query =...
def by_user_names(cls, user_names, db_session=None): """ fetch user objects by user names :param user_names: :param db_session: :return: """ user_names = [(name or "").lower() for name in user_names] db_session = get_db_session(db_session) query =...
[ "fetch", "user", "objects", "by", "user", "names" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/user.py#L351-L364
[ "def", "by_user_names", "(", "cls", ",", "user_names", ",", "db_session", "=", "None", ")", ":", "user_names", "=", "[", "(", "name", "or", "\"\"", ")", ".", "lower", "(", ")", "for", "name", "in", "user_names", "]", "db_session", "=", "get_db_session", ...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
UserService.user_names_like
fetch users with similar names using LIKE clause :param user_name: :param db_session: :return:
ziggurat_foundations/models/services/user.py
def user_names_like(cls, user_name, db_session=None): """ fetch users with similar names using LIKE clause :param user_name: :param db_session: :return: """ db_session = get_db_session(db_session) query = db_session.query(cls.model) query = query....
def user_names_like(cls, user_name, db_session=None): """ fetch users with similar names using LIKE clause :param user_name: :param db_session: :return: """ db_session = get_db_session(db_session) query = db_session.query(cls.model) query = query....
[ "fetch", "users", "with", "similar", "names", "using", "LIKE", "clause" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/user.py#L367-L382
[ "def", "user_names_like", "(", "cls", ",", "user_name", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "query", "=", "db_session", ".", "query", "(", "cls", ".", "model", ")", "query", "=", "query", ...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
UserService.by_email
fetch user object by email :param email: :param db_session: :return:
ziggurat_foundations/models/services/user.py
def by_email(cls, email, db_session=None): """ fetch user object by email :param email: :param db_session: :return: """ db_session = get_db_session(db_session) query = db_session.query(cls.model).filter( sa.func.lower(cls.model.email) == (emai...
def by_email(cls, email, db_session=None): """ fetch user object by email :param email: :param db_session: :return: """ db_session = get_db_session(db_session) query = db_session.query(cls.model).filter( sa.func.lower(cls.model.email) == (emai...
[ "fetch", "user", "object", "by", "email" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/user.py#L385-L398
[ "def", "by_email", "(", "cls", ",", "email", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "query", "=", "db_session", ".", "query", "(", "cls", ".", "model", ")", ".", "filter", "(", "sa", ".", ...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
UserService.users_for_perms
return users hat have one of given permissions :param perm_names: :param db_session: :return:
ziggurat_foundations/models/services/user.py
def users_for_perms(cls, perm_names, db_session=None): """ return users hat have one of given permissions :param perm_names: :param db_session: :return: """ db_session = get_db_session(db_session) query = db_session.query(cls.model) query = query....
def users_for_perms(cls, perm_names, db_session=None): """ return users hat have one of given permissions :param perm_names: :param db_session: :return: """ db_session = get_db_session(db_session) query = db_session.query(cls.model) query = query....
[ "return", "users", "hat", "have", "one", "of", "given", "permissions" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/user.py#L419-L446
[ "def", "users_for_perms", "(", "cls", ",", "perm_names", ",", "db_session", "=", "None", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "query", "=", "db_session", ".", "query", "(", "cls", ".", "model", ")", "query", "=", "query", ...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
CommandMixin.handle_joined
Store join times for current nicknames when we first join.
gnotty/bots/commands.py
def handle_joined(self, connection, event): """ Store join times for current nicknames when we first join. """ nicknames = [s.lstrip("@+") for s in event.arguments()[-1].split()] for nickname in nicknames: self.joined[nickname] = datetime.now()
def handle_joined(self, connection, event): """ Store join times for current nicknames when we first join. """ nicknames = [s.lstrip("@+") for s in event.arguments()[-1].split()] for nickname in nicknames: self.joined[nickname] = datetime.now()
[ "Store", "join", "times", "for", "current", "nicknames", "when", "we", "first", "join", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/commands.py#L20-L26
[ "def", "handle_joined", "(", "self", ",", "connection", ",", "event", ")", ":", "nicknames", "=", "[", "s", ".", "lstrip", "(", "\"@+\"", ")", "for", "s", "in", "event", ".", "arguments", "(", ")", "[", "-", "1", "]", ".", "split", "(", ")", "]",...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
CommandMixin.handle_join
Store join time for a nickname when it joins.
gnotty/bots/commands.py
def handle_join(self, connection, event): """ Store join time for a nickname when it joins. """ nickname = self.get_nickname(event) self.joined[nickname] = datetime.now()
def handle_join(self, connection, event): """ Store join time for a nickname when it joins. """ nickname = self.get_nickname(event) self.joined[nickname] = datetime.now()
[ "Store", "join", "time", "for", "a", "nickname", "when", "it", "joins", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/commands.py#L29-L34
[ "def", "handle_join", "(", "self", ",", "connection", ",", "event", ")", ":", "nickname", "=", "self", ".", "get_nickname", "(", "event", ")", "self", ".", "joined", "[", "nickname", "]", "=", "datetime", ".", "now", "(", ")" ]
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
CommandMixin.handle_quit
Store quit time for a nickname when it quits.
gnotty/bots/commands.py
def handle_quit(self, connection, event): """ Store quit time for a nickname when it quits. """ nickname = self.get_nickname(event) self.quit[nickname] = datetime.now() del self.joined[nickname]
def handle_quit(self, connection, event): """ Store quit time for a nickname when it quits. """ nickname = self.get_nickname(event) self.quit[nickname] = datetime.now() del self.joined[nickname]
[ "Store", "quit", "time", "for", "a", "nickname", "when", "it", "quits", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/commands.py#L37-L43
[ "def", "handle_quit", "(", "self", ",", "connection", ",", "event", ")", ":", "nickname", "=", "self", ".", "get_nickname", "(", "event", ")", "self", ".", "quit", "[", "nickname", "]", "=", "datetime", ".", "now", "(", ")", "del", "self", ".", "join...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
CommandMixin.timesince
Returns human friendly version of the timespan between now and the given datetime.
gnotty/bots/commands.py
def timesince(self, when): """ Returns human friendly version of the timespan between now and the given datetime. """ units = ( ("year", 60 * 60 * 24 * 365), ("week", 60 * 60 * 24 * 7), ("day", 60 * 60 * 24), ("hour", 60 * ...
def timesince(self, when): """ Returns human friendly version of the timespan between now and the given datetime. """ units = ( ("year", 60 * 60 * 24 * 365), ("week", 60 * 60 * 24 * 7), ("day", 60 * 60 * 24), ("hour", 60 * ...
[ "Returns", "human", "friendly", "version", "of", "the", "timespan", "between", "now", "and", "the", "given", "datetime", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/commands.py#L45-L67
[ "def", "timesince", "(", "self", ",", "when", ")", ":", "units", "=", "(", "(", "\"year\"", ",", "60", "*", "60", "*", "24", "*", "365", ")", ",", "(", "\"week\"", ",", "60", "*", "60", "*", "24", "*", "7", ")", ",", "(", "\"day\"", ",", "6...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
CommandMixin.version
Shows version information.
gnotty/bots/commands.py
def version(self, event): """ Shows version information. """ name = "%s.%s" % (self.__class__.__module__, self.__class__.__name__) return "%s [%s]" % (settings.GNOTTY_VERSION_STRING, name)
def version(self, event): """ Shows version information. """ name = "%s.%s" % (self.__class__.__module__, self.__class__.__name__) return "%s [%s]" % (settings.GNOTTY_VERSION_STRING, name)
[ "Shows", "version", "information", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/commands.py#L78-L83
[ "def", "version", "(", "self", ",", "event", ")", ":", "name", "=", "\"%s.%s\"", "%", "(", "self", ".", "__class__", ".", "__module__", ",", "self", ".", "__class__", ".", "__name__", ")", "return", "\"%s [%s]\"", "%", "(", "settings", ".", "GNOTTY_VERSI...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
CommandMixin.commands
Lists all available commands.
gnotty/bots/commands.py
def commands(self, event): """ Lists all available commands. """ commands = sorted(self.commands_dict().keys()) return "Available commands: %s" % " ".join(commands)
def commands(self, event): """ Lists all available commands. """ commands = sorted(self.commands_dict().keys()) return "Available commands: %s" % " ".join(commands)
[ "Lists", "all", "available", "commands", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/commands.py#L86-L91
[ "def", "commands", "(", "self", ",", "event", ")", ":", "commands", "=", "sorted", "(", "self", ".", "commands_dict", "(", ")", ".", "keys", "(", ")", ")", "return", "\"Available commands: %s\"", "%", "\" \"", ".", "join", "(", "commands", ")" ]
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
CommandMixin.help
Shows the help message for the bot. Takes an optional command name which when given, will show help for that command.
gnotty/bots/commands.py
def help(self, event, command_name=None): """ Shows the help message for the bot. Takes an optional command name which when given, will show help for that command. """ if command_name is None: return ("Type !commands for a list of all commands. Type " ...
def help(self, event, command_name=None): """ Shows the help message for the bot. Takes an optional command name which when given, will show help for that command. """ if command_name is None: return ("Type !commands for a list of all commands. Type " ...
[ "Shows", "the", "help", "message", "for", "the", "bot", ".", "Takes", "an", "optional", "command", "name", "which", "when", "given", "will", "show", "help", "for", "that", "command", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/commands.py#L94-L114
[ "def", "help", "(", "self", ",", "event", ",", "command_name", "=", "None", ")", ":", "if", "command_name", "is", "None", ":", "return", "(", "\"Type !commands for a list of all commands. Type \"", "\"!help [command] to see help for a specific command.\"", ")", "try", "...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
CommandMixin.uptime
Shows the amount of time since the given nickname has been in the channel. If no nickname is given, I'll use my own.
gnotty/bots/commands.py
def uptime(self, event, nickname=None): """ Shows the amount of time since the given nickname has been in the channel. If no nickname is given, I'll use my own. """ if nickname and nickname != self.nickname: try: uptime = self.timesince(self.joined[nic...
def uptime(self, event, nickname=None): """ Shows the amount of time since the given nickname has been in the channel. If no nickname is given, I'll use my own. """ if nickname and nickname != self.nickname: try: uptime = self.timesince(self.joined[nic...
[ "Shows", "the", "amount", "of", "time", "since", "the", "given", "nickname", "has", "been", "in", "the", "channel", ".", "If", "no", "nickname", "is", "given", "I", "ll", "use", "my", "own", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/commands.py#L117-L134
[ "def", "uptime", "(", "self", ",", "event", ",", "nickname", "=", "None", ")", ":", "if", "nickname", "and", "nickname", "!=", "self", ".", "nickname", ":", "try", ":", "uptime", "=", "self", ".", "timesince", "(", "self", ".", "joined", "[", "nickna...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
CommandMixin.seen
Shows the amount of time since the given nickname was last seen in the channel.
gnotty/bots/commands.py
def seen(self, event, nickname): """ Shows the amount of time since the given nickname was last seen in the channel. """ try: self.joined[nickname] except KeyError: pass else: if nickname == self.get_nickname(event): ...
def seen(self, event, nickname): """ Shows the amount of time since the given nickname was last seen in the channel. """ try: self.joined[nickname] except KeyError: pass else: if nickname == self.get_nickname(event): ...
[ "Shows", "the", "amount", "of", "time", "since", "the", "given", "nickname", "was", "last", "seen", "in", "the", "channel", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/commands.py#L137-L157
[ "def", "seen", "(", "self", ",", "event", ",", "nickname", ")", ":", "try", ":", "self", ".", "joined", "[", "nickname", "]", "except", "KeyError", ":", "pass", "else", ":", "if", "nickname", "==", "self", ".", "get_nickname", "(", "event", ")", ":",...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
UserMixin.id
Unique identifier of user object
ziggurat_foundations/models/user.py
def id(self): """ Unique identifier of user object""" return sa.Column(sa.Integer, primary_key=True, autoincrement=True)
def id(self): """ Unique identifier of user object""" return sa.Column(sa.Integer, primary_key=True, autoincrement=True)
[ "Unique", "identifier", "of", "user", "object" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/user.py#L29-L31
[ "def", "id", "(", "self", ")", ":", "return", "sa", ".", "Column", "(", "sa", ".", "Integer", ",", "primary_key", "=", "True", ",", "autoincrement", "=", "True", ")" ]
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
UserMixin.last_login_date
Date of user's last login
ziggurat_foundations/models/user.py
def last_login_date(self): """ Date of user's last login """ return sa.Column( sa.TIMESTAMP(timezone=False), default=lambda x: datetime.utcnow(), server_default=sa.func.now(), )
def last_login_date(self): """ Date of user's last login """ return sa.Column( sa.TIMESTAMP(timezone=False), default=lambda x: datetime.utcnow(), server_default=sa.func.now(), )
[ "Date", "of", "user", "s", "last", "login" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/user.py#L59-L65
[ "def", "last_login_date", "(", "self", ")", ":", "return", "sa", ".", "Column", "(", "sa", ".", "TIMESTAMP", "(", "timezone", "=", "False", ")", ",", "default", "=", "lambda", "x", ":", "datetime", ".", "utcnow", "(", ")", ",", "server_default", "=", ...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
UserMixin.security_code_date
Date of user's security code update
ziggurat_foundations/models/user.py
def security_code_date(self): """ Date of user's security code update """ return sa.Column( sa.TIMESTAMP(timezone=False), default=datetime(2000, 1, 1), server_default="2000-01-01 01:01", )
def security_code_date(self): """ Date of user's security code update """ return sa.Column( sa.TIMESTAMP(timezone=False), default=datetime(2000, 1, 1), server_default="2000-01-01 01:01", )
[ "Date", "of", "user", "s", "security", "code", "update" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/user.py#L77-L83
[ "def", "security_code_date", "(", "self", ")", ":", "return", "sa", ".", "Column", "(", "sa", ".", "TIMESTAMP", "(", "timezone", "=", "False", ")", ",", "default", "=", "datetime", "(", "2000", ",", "1", ",", "1", ")", ",", "server_default", "=", "\"...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
UserMixin.groups_dynamic
returns dynamic relationship for groups - allowing for filtering of data
ziggurat_foundations/models/user.py
def groups_dynamic(self): """ returns dynamic relationship for groups - allowing for filtering of data """ return sa.orm.relationship( "Group", secondary="users_groups", lazy="dynamic", passive_deletes=True, passive_updates=True, ...
def groups_dynamic(self): """ returns dynamic relationship for groups - allowing for filtering of data """ return sa.orm.relationship( "Group", secondary="users_groups", lazy="dynamic", passive_deletes=True, passive_updates=True, ...
[ "returns", "dynamic", "relationship", "for", "groups", "-", "allowing", "for", "filtering", "of", "data" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/user.py#L89-L98
[ "def", "groups_dynamic", "(", "self", ")", ":", "return", "sa", ".", "orm", ".", "relationship", "(", "\"Group\"", ",", "secondary", "=", "\"users_groups\"", ",", "lazy", "=", "\"dynamic\"", ",", "passive_deletes", "=", "True", ",", "passive_updates", "=", "...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
UserMixin.resources
Returns all resources directly owned by user, can be used to assign ownership of new resources:: user.resources.append(resource)
ziggurat_foundations/models/user.py
def resources(self): """ Returns all resources directly owned by user, can be used to assign ownership of new resources:: user.resources.append(resource) """ return sa.orm.relationship( "Resource", cascade="all", passive_deletes=True, ...
def resources(self): """ Returns all resources directly owned by user, can be used to assign ownership of new resources:: user.resources.append(resource) """ return sa.orm.relationship( "Resource", cascade="all", passive_deletes=True, ...
[ "Returns", "all", "resources", "directly", "owned", "by", "user", "can", "be", "used", "to", "assign", "ownership", "of", "new", "resources", "::" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/user.py#L126-L138
[ "def", "resources", "(", "self", ")", ":", "return", "sa", ".", "orm", ".", "relationship", "(", "\"Resource\"", ",", "cascade", "=", "\"all\"", ",", "passive_deletes", "=", "True", ",", "passive_updates", "=", "True", ",", "backref", "=", "\"owner\"", ","...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
GroupMixin.resources_dynamic
Returns all resources directly owned by group, can be used to assign ownership of new resources:: user.resources.append(resource)
ziggurat_foundations/models/group.py
def resources_dynamic(self): """ Returns all resources directly owned by group, can be used to assign ownership of new resources:: user.resources.append(resource) """ return sa.orm.relationship( "Resource", cascade="all", passive_deletes=True, ...
def resources_dynamic(self): """ Returns all resources directly owned by group, can be used to assign ownership of new resources:: user.resources.append(resource) """ return sa.orm.relationship( "Resource", cascade="all", passive_deletes=True, ...
[ "Returns", "all", "resources", "directly", "owned", "by", "group", "can", "be", "used", "to", "assign", "ownership", "of", "new", "resources", "::" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/group.py#L99-L110
[ "def", "resources_dynamic", "(", "self", ")", ":", "return", "sa", ".", "orm", ".", "relationship", "(", "\"Resource\"", ",", "cascade", "=", "\"all\"", ",", "passive_deletes", "=", "True", ",", "passive_updates", "=", "True", ",", "lazy", "=", "\"dynamic\""...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
GroupMixin.validate_permission
validates if group can get assigned with permission
ziggurat_foundations/models/group.py
def validate_permission(self, key, permission): """ validates if group can get assigned with permission""" if permission.perm_name not in self.__possible_permissions__: raise AssertionError( "perm_name is not one of {}".format(self.__possible_permissions__) ) ...
def validate_permission(self, key, permission): """ validates if group can get assigned with permission""" if permission.perm_name not in self.__possible_permissions__: raise AssertionError( "perm_name is not one of {}".format(self.__possible_permissions__) ) ...
[ "validates", "if", "group", "can", "get", "assigned", "with", "permission" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/group.py#L113-L119
[ "def", "validate_permission", "(", "self", ",", "key", ",", "permission", ")", ":", "if", "permission", ".", "perm_name", "not", "in", "self", ".", "__possible_permissions__", ":", "raise", "AssertionError", "(", "\"perm_name is not one of {}\"", ".", "format", "(...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
RSSMixin.parse_feeds
Iterates through each of the feed URLs, parses their items, and sends any items to the channel that have not been previously been parsed.
gnotty/bots/rss.py
def parse_feeds(self, message_channel=True): """ Iterates through each of the feed URLs, parses their items, and sends any items to the channel that have not been previously been parsed. """ if parse: for feed_url in self.feeds: feed = parse(fe...
def parse_feeds(self, message_channel=True): """ Iterates through each of the feed URLs, parses their items, and sends any items to the channel that have not been previously been parsed. """ if parse: for feed_url in self.feeds: feed = parse(fe...
[ "Iterates", "through", "each", "of", "the", "feed", "URLs", "parses", "their", "items", "and", "sends", "any", "items", "to", "the", "channel", "that", "have", "not", "been", "previously", "been", "parsed", "." ]
stephenmcd/gnotty
python
https://github.com/stephenmcd/gnotty/blob/bea3762dc9cbc3cb21a5ae7224091cf027273c40/gnotty/bots/rss.py#L30-L45
[ "def", "parse_feeds", "(", "self", ",", "message_channel", "=", "True", ")", ":", "if", "parse", ":", "for", "feed_url", "in", "self", ".", "feeds", ":", "feed", "=", "parse", "(", "feed_url", ")", "for", "item", "in", "feed", ".", "entries", ":", "i...
bea3762dc9cbc3cb21a5ae7224091cf027273c40
train
ChunkBy
[ { 'self': [1, 1, 3, 3, 1, 1], 'f': lambda x: x%2, 'assert': lambda ret: ret == [[1, 1], [3, 3], [1, 1]] } ]
linq/standard/dict.py
def ChunkBy(self: dict, f=None): """ [ { 'self': [1, 1, 3, 3, 1, 1], 'f': lambda x: x%2, 'assert': lambda ret: ret == [[1, 1], [3, 3], [1, 1]] } ] """ if f is None: return _chunk(self.items()) if is_to_destruct(f): f = destruct...
def ChunkBy(self: dict, f=None): """ [ { 'self': [1, 1, 3, 3, 1, 1], 'f': lambda x: x%2, 'assert': lambda ret: ret == [[1, 1], [3, 3], [1, 1]] } ] """ if f is None: return _chunk(self.items()) if is_to_destruct(f): f = destruct...
[ "[", "{", "self", ":", "[", "1", "1", "3", "3", "1", "1", "]", "f", ":", "lambda", "x", ":", "x%2", "assert", ":", "lambda", "ret", ":", "ret", "==", "[[", "1", "1", "]", "[", "3", "3", "]", "[", "1", "1", "]]", "}", "]" ]
Xython/Linq.py
python
https://github.com/Xython/Linq.py/blob/ffb65f92f1df0d8161d5f835f5947554f6f33d72/linq/standard/dict.py#L74-L88
[ "def", "ChunkBy", "(", "self", ":", "dict", ",", "f", "=", "None", ")", ":", "if", "f", "is", "None", ":", "return", "_chunk", "(", "self", ".", "items", "(", ")", ")", "if", "is_to_destruct", "(", "f", ")", ":", "f", "=", "destruct_func", "(", ...
ffb65f92f1df0d8161d5f835f5947554f6f33d72
train
GroupBy
[ { 'self': [1, 2, 3], 'f': lambda x: x%2, 'assert': lambda ret: ret[0] == [2] and ret[1] == [1, 3] } ]
linq/standard/dict.py
def GroupBy(self: dict, f=None): """ [ { 'self': [1, 2, 3], 'f': lambda x: x%2, 'assert': lambda ret: ret[0] == [2] and ret[1] == [1, 3] } ] """ if f and is_to_destruct(f): f = destruct_func(f) return _group_by(self.items(), f)
def GroupBy(self: dict, f=None): """ [ { 'self': [1, 2, 3], 'f': lambda x: x%2, 'assert': lambda ret: ret[0] == [2] and ret[1] == [1, 3] } ] """ if f and is_to_destruct(f): f = destruct_func(f) return _group_by(self.items(), f)
[ "[", "{", "self", ":", "[", "1", "2", "3", "]", "f", ":", "lambda", "x", ":", "x%2", "assert", ":", "lambda", "ret", ":", "ret", "[", "0", "]", "==", "[", "2", "]", "and", "ret", "[", "1", "]", "==", "[", "1", "3", "]", "}", "]" ]
Xython/Linq.py
python
https://github.com/Xython/Linq.py/blob/ffb65f92f1df0d8161d5f835f5947554f6f33d72/linq/standard/dict.py#L92-L104
[ "def", "GroupBy", "(", "self", ":", "dict", ",", "f", "=", "None", ")", ":", "if", "f", "and", "is_to_destruct", "(", "f", ")", ":", "f", "=", "destruct_func", "(", "f", ")", "return", "_group_by", "(", "self", ".", "items", "(", ")", ",", "f", ...
ffb65f92f1df0d8161d5f835f5947554f6f33d72
train
Take
[ { 'self': [1, 2, 3], 'n': 2, 'assert': lambda ret: list(ret) == [1, 2] } ]
linq/standard/dict.py
def Take(self: dict, n): """ [ { 'self': [1, 2, 3], 'n': 2, 'assert': lambda ret: list(ret) == [1, 2] } ] """ for i, e in enumerate(self.items()): if i == n: break yield e
def Take(self: dict, n): """ [ { 'self': [1, 2, 3], 'n': 2, 'assert': lambda ret: list(ret) == [1, 2] } ] """ for i, e in enumerate(self.items()): if i == n: break yield e
[ "[", "{", "self", ":", "[", "1", "2", "3", "]", "n", ":", "2", "assert", ":", "lambda", "ret", ":", "list", "(", "ret", ")", "==", "[", "1", "2", "]", "}", "]" ]
Xython/Linq.py
python
https://github.com/Xython/Linq.py/blob/ffb65f92f1df0d8161d5f835f5947554f6f33d72/linq/standard/dict.py#L108-L122
[ "def", "Take", "(", "self", ":", "dict", ",", "n", ")", ":", "for", "i", ",", "e", "in", "enumerate", "(", "self", ".", "items", "(", ")", ")", ":", "if", "i", "==", "n", ":", "break", "yield", "e" ]
ffb65f92f1df0d8161d5f835f5947554f6f33d72
train
TakeIf
[ { 'self': [1, 2, 3], 'f': lambda e: e%2, 'assert': lambda ret: list(ret) == [1, 3] } ]
linq/standard/dict.py
def TakeIf(self: dict, f): """ [ { 'self': [1, 2, 3], 'f': lambda e: e%2, 'assert': lambda ret: list(ret) == [1, 3] } ] """ if is_to_destruct(f): f = destruct_func(f) return (e for e in self.items() if f(e))
def TakeIf(self: dict, f): """ [ { 'self': [1, 2, 3], 'f': lambda e: e%2, 'assert': lambda ret: list(ret) == [1, 3] } ] """ if is_to_destruct(f): f = destruct_func(f) return (e for e in self.items() if f(e))
[ "[", "{", "self", ":", "[", "1", "2", "3", "]", "f", ":", "lambda", "e", ":", "e%2", "assert", ":", "lambda", "ret", ":", "list", "(", "ret", ")", "==", "[", "1", "3", "]", "}", "]" ]
Xython/Linq.py
python
https://github.com/Xython/Linq.py/blob/ffb65f92f1df0d8161d5f835f5947554f6f33d72/linq/standard/dict.py#L126-L139
[ "def", "TakeIf", "(", "self", ":", "dict", ",", "f", ")", ":", "if", "is_to_destruct", "(", "f", ")", ":", "f", "=", "destruct_func", "(", "f", ")", "return", "(", "e", "for", "e", "in", "self", ".", "items", "(", ")", "if", "f", "(", "e", ")...
ffb65f92f1df0d8161d5f835f5947554f6f33d72
train
TakeWhile
[ { 'self': [1, 2, 3, 4, 5], 'f': lambda x: x < 4, 'assert': lambda ret: list(ret) == [1, 2, 3] } ]
linq/standard/dict.py
def TakeWhile(self: dict, f): """ [ { 'self': [1, 2, 3, 4, 5], 'f': lambda x: x < 4, 'assert': lambda ret: list(ret) == [1, 2, 3] } ] """ if is_to_destruct(f): f = destruct_func(f) for e in self.items(): if not f(e): ...
def TakeWhile(self: dict, f): """ [ { 'self': [1, 2, 3, 4, 5], 'f': lambda x: x < 4, 'assert': lambda ret: list(ret) == [1, 2, 3] } ] """ if is_to_destruct(f): f = destruct_func(f) for e in self.items(): if not f(e): ...
[ "[", "{", "self", ":", "[", "1", "2", "3", "4", "5", "]", "f", ":", "lambda", "x", ":", "x", "<", "4", "assert", ":", "lambda", "ret", ":", "list", "(", "ret", ")", "==", "[", "1", "2", "3", "]", "}", "]" ]
Xython/Linq.py
python
https://github.com/Xython/Linq.py/blob/ffb65f92f1df0d8161d5f835f5947554f6f33d72/linq/standard/dict.py#L143-L159
[ "def", "TakeWhile", "(", "self", ":", "dict", ",", "f", ")", ":", "if", "is_to_destruct", "(", "f", ")", ":", "f", "=", "destruct_func", "(", "f", ")", "for", "e", "in", "self", ".", "items", "(", ")", ":", "if", "not", "f", "(", "e", ")", ":...
ffb65f92f1df0d8161d5f835f5947554f6f33d72
train
Drop
[ { 'self': [1, 2, 3, 4, 5], 'n': 3, 'assert': lambda ret: list(ret) == [1, 2] } ]
linq/standard/dict.py
def Drop(self: dict, n): """ [ { 'self': [1, 2, 3, 4, 5], 'n': 3, 'assert': lambda ret: list(ret) == [1, 2] } ] """ n = len(self) - n if n <= 0: yield from self.items() else: for i, e in enumerate(self.items()): ...
def Drop(self: dict, n): """ [ { 'self': [1, 2, 3, 4, 5], 'n': 3, 'assert': lambda ret: list(ret) == [1, 2] } ] """ n = len(self) - n if n <= 0: yield from self.items() else: for i, e in enumerate(self.items()): ...
[ "[", "{", "self", ":", "[", "1", "2", "3", "4", "5", "]", "n", ":", "3", "assert", ":", "lambda", "ret", ":", "list", "(", "ret", ")", "==", "[", "1", "2", "]", "}", "]" ]
Xython/Linq.py
python
https://github.com/Xython/Linq.py/blob/ffb65f92f1df0d8161d5f835f5947554f6f33d72/linq/standard/dict.py#L163-L180
[ "def", "Drop", "(", "self", ":", "dict", ",", "n", ")", ":", "n", "=", "len", "(", "self", ")", "-", "n", "if", "n", "<=", "0", ":", "yield", "from", "self", ".", "items", "(", ")", "else", ":", "for", "i", ",", "e", "in", "enumerate", "(",...
ffb65f92f1df0d8161d5f835f5947554f6f33d72
train
Skip
[ { 'self': [1, 2, 3, 4, 5], 'n': 3, 'assert': lambda ret: list(ret) == [4, 5] } ]
linq/standard/dict.py
def Skip(self: dict, n): """ [ { 'self': [1, 2, 3, 4, 5], 'n': 3, 'assert': lambda ret: list(ret) == [4, 5] } ] """ con = self.items() for i, _ in enumerate(con): if i == n: break return...
def Skip(self: dict, n): """ [ { 'self': [1, 2, 3, 4, 5], 'n': 3, 'assert': lambda ret: list(ret) == [4, 5] } ] """ con = self.items() for i, _ in enumerate(con): if i == n: break return...
[ "[", "{", "self", ":", "[", "1", "2", "3", "4", "5", "]", "n", ":", "3", "assert", ":", "lambda", "ret", ":", "list", "(", "ret", ")", "==", "[", "4", "5", "]", "}", "]" ]
Xython/Linq.py
python
https://github.com/Xython/Linq.py/blob/ffb65f92f1df0d8161d5f835f5947554f6f33d72/linq/standard/dict.py#L184-L199
[ "def", "Skip", "(", "self", ":", "dict", ",", "n", ")", ":", "con", "=", "self", ".", "items", "(", ")", "for", "i", ",", "_", "in", "enumerate", "(", "con", ")", ":", "if", "i", "==", "n", ":", "break", "return", "con" ]
ffb65f92f1df0d8161d5f835f5947554f6f33d72
train
print_meter_record
Output readings for specified number of rows to console
print_examples.py
def print_meter_record(file_path, rows=5): """ Output readings for specified number of rows to console """ m = nr.read_nem_file(file_path) print('Header:', m.header) print('Transactions:', m.transactions) for nmi in m.readings: for channel in m.readings[nmi]: print(nmi, 'Channel'...
def print_meter_record(file_path, rows=5): """ Output readings for specified number of rows to console """ m = nr.read_nem_file(file_path) print('Header:', m.header) print('Transactions:', m.transactions) for nmi in m.readings: for channel in m.readings[nmi]: print(nmi, 'Channel'...
[ "Output", "readings", "for", "specified", "number", "of", "rows", "to", "console" ]
aguinane/nem-reader
python
https://github.com/aguinane/nem-reader/blob/5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5/print_examples.py#L4-L13
[ "def", "print_meter_record", "(", "file_path", ",", "rows", "=", "5", ")", ":", "m", "=", "nr", ".", "read_nem_file", "(", "file_path", ")", "print", "(", "'Header:'", ",", "m", ".", "header", ")", "print", "(", "'Transactions:'", ",", "m", ".", "trans...
5405a5cba4bb8ebdad05c28455d12bb34a6d3ce5
train
ResourceMixin.users
returns all users that have permissions for this resource
ziggurat_foundations/models/resource.py
def users(self): """ returns all users that have permissions for this resource""" return sa.orm.relationship( "User", secondary="users_resources_permissions", passive_deletes=True, passive_updates=True, )
def users(self): """ returns all users that have permissions for this resource""" return sa.orm.relationship( "User", secondary="users_resources_permissions", passive_deletes=True, passive_updates=True, )
[ "returns", "all", "users", "that", "have", "permissions", "for", "this", "resource" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/resource.py#L98-L105
[ "def", "users", "(", "self", ")", ":", "return", "sa", ".", "orm", ".", "relationship", "(", "\"User\"", ",", "secondary", "=", "\"users_resources_permissions\"", ",", "passive_deletes", "=", "True", ",", "passive_updates", "=", "True", ",", ")" ]
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceTreeServicePostgreSQL.from_resource_deeper
This returns you subtree of ordered objects relative to the start resource_id (currently only implemented in postgresql) :param resource_id: :param limit_depth: :param db_session: :return:
ziggurat_foundations/models/services/resource_tree_postgres.py
def from_resource_deeper( cls, resource_id=None, limit_depth=1000000, db_session=None, *args, **kwargs ): """ This returns you subtree of ordered objects relative to the start resource_id (currently only implemented in postgresql) :param resource_id: :param limit_dep...
def from_resource_deeper( cls, resource_id=None, limit_depth=1000000, db_session=None, *args, **kwargs ): """ This returns you subtree of ordered objects relative to the start resource_id (currently only implemented in postgresql) :param resource_id: :param limit_dep...
[ "This", "returns", "you", "subtree", "of", "ordered", "objects", "relative", "to", "the", "start", "resource_id", "(", "currently", "only", "implemented", "in", "postgresql", ")" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource_tree_postgres.py#L24-L58
[ "def", "from_resource_deeper", "(", "cls", ",", "resource_id", "=", "None", ",", "limit_depth", "=", "1000000", ",", "db_session", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "tablename", "=", "cls", ".", "model", ".", "__table__", ...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceTreeServicePostgreSQL.delete_branch
This deletes whole branch with children starting from resource_id :param resource_id: :param db_session: :return:
ziggurat_foundations/models/services/resource_tree_postgres.py
def delete_branch(cls, resource_id=None, db_session=None, *args, **kwargs): """ This deletes whole branch with children starting from resource_id :param resource_id: :param db_session: :return: """ tablename = cls.model.__table__.name # lets lock rows to...
def delete_branch(cls, resource_id=None, db_session=None, *args, **kwargs): """ This deletes whole branch with children starting from resource_id :param resource_id: :param db_session: :return: """ tablename = cls.model.__table__.name # lets lock rows to...
[ "This", "deletes", "whole", "branch", "with", "children", "starting", "from", "resource_id" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource_tree_postgres.py#L61-L94
[ "def", "delete_branch", "(", "cls", ",", "resource_id", "=", "None", ",", "db_session", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "tablename", "=", "cls", ".", "model", ".", "__table__", ".", "name", "# lets lock rows to prevent bad...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceTreeServicePostgreSQL.from_parent_deeper
This returns you subtree of ordered objects relative to the start parent_id (currently only implemented in postgresql) :param resource_id: :param limit_depth: :param db_session: :return:
ziggurat_foundations/models/services/resource_tree_postgres.py
def from_parent_deeper( cls, parent_id=None, limit_depth=1000000, db_session=None, *args, **kwargs ): """ This returns you subtree of ordered objects relative to the start parent_id (currently only implemented in postgresql) :param resource_id: :param limit_depth: ...
def from_parent_deeper( cls, parent_id=None, limit_depth=1000000, db_session=None, *args, **kwargs ): """ This returns you subtree of ordered objects relative to the start parent_id (currently only implemented in postgresql) :param resource_id: :param limit_depth: ...
[ "This", "returns", "you", "subtree", "of", "ordered", "objects", "relative", "to", "the", "start", "parent_id", "(", "currently", "only", "implemented", "in", "postgresql", ")" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource_tree_postgres.py#L97-L136
[ "def", "from_parent_deeper", "(", "cls", ",", "parent_id", "=", "None", ",", "limit_depth", "=", "1000000", ",", "db_session", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "parent_id", ":", "limiting_clause", "=", "\"res.parent_i...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceTreeServicePostgreSQL.build_subtree_strut
Returns a dictionary in form of {node:Resource, children:{node_id: Resource}} :param result: :return:
ziggurat_foundations/models/services/resource_tree_postgres.py
def build_subtree_strut(self, result, *args, **kwargs): """ Returns a dictionary in form of {node:Resource, children:{node_id: Resource}} :param result: :return: """ items = list(result) root_elem = {"node": None, "children": OrderedDict()} if len...
def build_subtree_strut(self, result, *args, **kwargs): """ Returns a dictionary in form of {node:Resource, children:{node_id: Resource}} :param result: :return: """ items = list(result) root_elem = {"node": None, "children": OrderedDict()} if len...
[ "Returns", "a", "dictionary", "in", "form", "of", "{", "node", ":", "Resource", "children", ":", "{", "node_id", ":", "Resource", "}}" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource_tree_postgres.py#L139-L160
[ "def", "build_subtree_strut", "(", "self", ",", "result", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "items", "=", "list", "(", "result", ")", "root_elem", "=", "{", "\"node\"", ":", "None", ",", "\"children\"", ":", "OrderedDict", "(", ")", ...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceTreeServicePostgreSQL.path_upper
This returns you path to root node starting from object_id currently only for postgresql :param object_id: :param limit_depth: :param db_session: :return:
ziggurat_foundations/models/services/resource_tree_postgres.py
def path_upper( cls, object_id, limit_depth=1000000, db_session=None, *args, **kwargs ): """ This returns you path to root node starting from object_id currently only for postgresql :param object_id: :param limit_depth: :param db_session: :return:...
def path_upper( cls, object_id, limit_depth=1000000, db_session=None, *args, **kwargs ): """ This returns you path to root node starting from object_id currently only for postgresql :param object_id: :param limit_depth: :param db_session: :return:...
[ "This", "returns", "you", "path", "to", "root", "node", "starting", "from", "object_id", "currently", "only", "for", "postgresql" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource_tree_postgres.py#L163-L195
[ "def", "path_upper", "(", "cls", ",", "object_id", ",", "limit_depth", "=", "1000000", ",", "db_session", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "tablename", "=", "cls", ".", "model", ".", "__table__", ".", "name", "raw_q", ...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceTreeServicePostgreSQL.move_to_position
Moves node to new location in the tree :param resource_id: resource to move :param to_position: new position :param new_parent_id: new parent id :param db_session: :return:
ziggurat_foundations/models/services/resource_tree_postgres.py
def move_to_position( cls, resource_id, to_position, new_parent_id=noop, db_session=None, *args, **kwargs ): """ Moves node to new location in the tree :param resource_id: resource to move :param to_position: new position ...
def move_to_position( cls, resource_id, to_position, new_parent_id=noop, db_session=None, *args, **kwargs ): """ Moves node to new location in the tree :param resource_id: resource to move :param to_position: new position ...
[ "Moves", "node", "to", "new", "location", "in", "the", "tree" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource_tree_postgres.py#L198-L275
[ "def", "move_to_position", "(", "cls", ",", "resource_id", ",", "to_position", ",", "new_parent_id", "=", "noop", ",", "db_session", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", "...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba
train
ResourceTreeServicePostgreSQL.shift_ordering_up
Shifts ordering to "open a gap" for node insertion, begins the shift from given position :param parent_id: :param position: :param db_session: :return:
ziggurat_foundations/models/services/resource_tree_postgres.py
def shift_ordering_up(cls, parent_id, position, db_session=None, *args, **kwargs): """ Shifts ordering to "open a gap" for node insertion, begins the shift from given position :param parent_id: :param position: :param db_session: :return: """ db_s...
def shift_ordering_up(cls, parent_id, position, db_session=None, *args, **kwargs): """ Shifts ordering to "open a gap" for node insertion, begins the shift from given position :param parent_id: :param position: :param db_session: :return: """ db_s...
[ "Shifts", "ordering", "to", "open", "a", "gap", "for", "node", "insertion", "begins", "the", "shift", "from", "given", "position" ]
ergo/ziggurat_foundations
python
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource_tree_postgres.py#L298-L315
[ "def", "shift_ordering_up", "(", "cls", ",", "parent_id", ",", "position", ",", "db_session", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "db_session", "=", "get_db_session", "(", "db_session", ")", "query", "=", "db_session", ".", ...
9eeec894d08e8d7defa60ddc04b63f69cd4cbeba