repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
LordDarkula/chess_py
chess_py/pieces/pawn.py
Pawn.square_in_front
def square_in_front(self, location=None): """ Finds square directly in front of Pawn :type: location: Location :rtype: Location """ location = location or self.location return location.shift_up() if self.color == color.white else location.shift_down()
python
def square_in_front(self, location=None): """ Finds square directly in front of Pawn :type: location: Location :rtype: Location """ location = location or self.location return location.shift_up() if self.color == color.white else location.shift_down()
[ "def", "square_in_front", "(", "self", ",", "location", "=", "None", ")", ":", "location", "=", "location", "or", "self", ".", "location", "return", "location", ".", "shift_up", "(", ")", "if", "self", ".", "color", "==", "color", ".", "white", "else", ...
Finds square directly in front of Pawn :type: location: Location :rtype: Location
[ "Finds", "square", "directly", "in", "front", "of", "Pawn" ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/pawn.py#L72-L80
train
LordDarkula/chess_py
chess_py/pieces/pawn.py
Pawn.forward_moves
def forward_moves(self, position): """ Finds possible moves one step and two steps in front of Pawn. :type: position: Board :rtype: list """ if position.is_square_empty(self.square_in_front(self.location)): """ If square in front is empty ...
python
def forward_moves(self, position): """ Finds possible moves one step and two steps in front of Pawn. :type: position: Board :rtype: list """ if position.is_square_empty(self.square_in_front(self.location)): """ If square in front is empty ...
[ "def", "forward_moves", "(", "self", ",", "position", ")", ":", "if", "position", ".", "is_square_empty", "(", "self", ".", "square_in_front", "(", "self", ".", "location", ")", ")", ":", "\"\"\"\n If square in front is empty add the move\n \"\"\""...
Finds possible moves one step and two steps in front of Pawn. :type: position: Board :rtype: list
[ "Finds", "possible", "moves", "one", "step", "and", "two", "steps", "in", "front", "of", "Pawn", "." ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/pawn.py#L105-L133
train
LordDarkula/chess_py
chess_py/pieces/pawn.py
Pawn._one_diagonal_capture_square
def _one_diagonal_capture_square(self, capture_square, position): """ Adds specified diagonal as a capture move if it is one """ if self.contains_opposite_color_piece(capture_square, position): if self.would_move_be_promotion(): for move in self.create_promot...
python
def _one_diagonal_capture_square(self, capture_square, position): """ Adds specified diagonal as a capture move if it is one """ if self.contains_opposite_color_piece(capture_square, position): if self.would_move_be_promotion(): for move in self.create_promot...
[ "def", "_one_diagonal_capture_square", "(", "self", ",", "capture_square", ",", "position", ")", ":", "if", "self", ".", "contains_opposite_color_piece", "(", "capture_square", ",", "position", ")", ":", "if", "self", ".", "would_move_be_promotion", "(", ")", ":",...
Adds specified diagonal as a capture move if it is one
[ "Adds", "specified", "diagonal", "as", "a", "capture", "move", "if", "it", "is", "one" ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/pawn.py#L135-L148
train
LordDarkula/chess_py
chess_py/pieces/pawn.py
Pawn.capture_moves
def capture_moves(self, position): """ Finds out all possible capture moves :rtype: list """ try: right_diagonal = self.square_in_front(self.location.shift_right()) for move in self._one_diagonal_capture_square(right_diagonal, position): y...
python
def capture_moves(self, position): """ Finds out all possible capture moves :rtype: list """ try: right_diagonal = self.square_in_front(self.location.shift_right()) for move in self._one_diagonal_capture_square(right_diagonal, position): y...
[ "def", "capture_moves", "(", "self", ",", "position", ")", ":", "try", ":", "right_diagonal", "=", "self", ".", "square_in_front", "(", "self", ".", "location", ".", "shift_right", "(", ")", ")", "for", "move", "in", "self", ".", "_one_diagonal_capture_squar...
Finds out all possible capture moves :rtype: list
[ "Finds", "out", "all", "possible", "capture", "moves" ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/pawn.py#L150-L168
train
LordDarkula/chess_py
chess_py/pieces/pawn.py
Pawn.on_en_passant_valid_location
def on_en_passant_valid_location(self): """ Finds out if pawn is on enemy center rank. :rtype: bool """ return (self.color == color.white and self.location.rank == 4) or \ (self.color == color.black and self.location.rank == 3)
python
def on_en_passant_valid_location(self): """ Finds out if pawn is on enemy center rank. :rtype: bool """ return (self.color == color.white and self.location.rank == 4) or \ (self.color == color.black and self.location.rank == 3)
[ "def", "on_en_passant_valid_location", "(", "self", ")", ":", "return", "(", "self", ".", "color", "==", "color", ".", "white", "and", "self", ".", "location", ".", "rank", "==", "4", ")", "or", "(", "self", ".", "color", "==", "color", ".", "black", ...
Finds out if pawn is on enemy center rank. :rtype: bool
[ "Finds", "out", "if", "pawn", "is", "on", "enemy", "center", "rank", "." ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/pawn.py#L170-L177
train
LordDarkula/chess_py
chess_py/pieces/pawn.py
Pawn._is_en_passant_valid
def _is_en_passant_valid(self, opponent_pawn_location, position): """ Finds if their opponent's pawn is next to this pawn :rtype: bool """ try: pawn = position.piece_at_square(opponent_pawn_location) return pawn is not None and \ isinstanc...
python
def _is_en_passant_valid(self, opponent_pawn_location, position): """ Finds if their opponent's pawn is next to this pawn :rtype: bool """ try: pawn = position.piece_at_square(opponent_pawn_location) return pawn is not None and \ isinstanc...
[ "def", "_is_en_passant_valid", "(", "self", ",", "opponent_pawn_location", ",", "position", ")", ":", "try", ":", "pawn", "=", "position", ".", "piece_at_square", "(", "opponent_pawn_location", ")", "return", "pawn", "is", "not", "None", "and", "isinstance", "("...
Finds if their opponent's pawn is next to this pawn :rtype: bool
[ "Finds", "if", "their", "opponent", "s", "pawn", "is", "next", "to", "this", "pawn" ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/pawn.py#L179-L192
train
LordDarkula/chess_py
chess_py/pieces/pawn.py
Pawn.add_one_en_passant_move
def add_one_en_passant_move(self, direction, position): """ Yields en_passant moves in given direction if it is legal. :type: direction: function :type: position: Board :rtype: gen """ try: if self._is_en_passant_valid(direction(self.location), positi...
python
def add_one_en_passant_move(self, direction, position): """ Yields en_passant moves in given direction if it is legal. :type: direction: function :type: position: Board :rtype: gen """ try: if self._is_en_passant_valid(direction(self.location), positi...
[ "def", "add_one_en_passant_move", "(", "self", ",", "direction", ",", "position", ")", ":", "try", ":", "if", "self", ".", "_is_en_passant_valid", "(", "direction", "(", "self", ".", "location", ")", ",", "position", ")", ":", "yield", "self", ".", "create...
Yields en_passant moves in given direction if it is legal. :type: direction: function :type: position: Board :rtype: gen
[ "Yields", "en_passant", "moves", "in", "given", "direction", "if", "it", "is", "legal", "." ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/pawn.py#L194-L209
train
LordDarkula/chess_py
chess_py/pieces/pawn.py
Pawn.en_passant_moves
def en_passant_moves(self, position): """ Finds possible en passant moves. :rtype: list """ # if pawn is not on a valid en passant get_location then return None if self.on_en_passant_valid_location(): for move in itertools.chain(self.add_one_en_passant_move(...
python
def en_passant_moves(self, position): """ Finds possible en passant moves. :rtype: list """ # if pawn is not on a valid en passant get_location then return None if self.on_en_passant_valid_location(): for move in itertools.chain(self.add_one_en_passant_move(...
[ "def", "en_passant_moves", "(", "self", ",", "position", ")", ":", "# if pawn is not on a valid en passant get_location then return None", "if", "self", ".", "on_en_passant_valid_location", "(", ")", ":", "for", "move", "in", "itertools", ".", "chain", "(", "self", "....
Finds possible en passant moves. :rtype: list
[ "Finds", "possible", "en", "passant", "moves", "." ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/pawn.py#L211-L222
train
LordDarkula/chess_py
chess_py/pieces/pawn.py
Pawn.possible_moves
def possible_moves(self, position): """ Finds out the locations of possible moves given board.Board position. :pre get_location is on board and piece at specified get_location on position :type: position: Board :rtype: list """ for move in itertools.chain(self.fo...
python
def possible_moves(self, position): """ Finds out the locations of possible moves given board.Board position. :pre get_location is on board and piece at specified get_location on position :type: position: Board :rtype: list """ for move in itertools.chain(self.fo...
[ "def", "possible_moves", "(", "self", ",", "position", ")", ":", "for", "move", "in", "itertools", ".", "chain", "(", "self", ".", "forward_moves", "(", "position", ")", ",", "self", ".", "capture_moves", "(", "position", ")", ",", "self", ".", "en_passa...
Finds out the locations of possible moves given board.Board position. :pre get_location is on board and piece at specified get_location on position :type: position: Board :rtype: list
[ "Finds", "out", "the", "locations", "of", "possible", "moves", "given", "board", ".", "Board", "position", ".", ":", "pre", "get_location", "is", "on", "board", "and", "piece", "at", "specified", "get_location", "on", "position" ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/pawn.py#L224-L235
train
LordDarkula/chess_py
main.py
main
def main(): """ Main method """ print("Creating a new game...") new_game = Game(Human(color.white), Human(color.black)) result = new_game.play() print("Result is ", result)
python
def main(): """ Main method """ print("Creating a new game...") new_game = Game(Human(color.white), Human(color.black)) result = new_game.play() print("Result is ", result)
[ "def", "main", "(", ")", ":", "print", "(", "\"Creating a new game...\"", ")", "new_game", "=", "Game", "(", "Human", "(", "color", ".", "white", ")", ",", "Human", "(", "color", ".", "black", ")", ")", "result", "=", "new_game", ".", "play", "(", ")...
Main method
[ "Main", "method" ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/main.py#L25-L34
train
erik/alexandra
alexandra/util.py
respond
def respond(text=None, ssml=None, attributes=None, reprompt_text=None, reprompt_ssml=None, end_session=True): """ Build a dict containing a valid response to an Alexa request. If speech output is desired, either of `text` or `ssml` should be specified. :param text: Plain text speech output...
python
def respond(text=None, ssml=None, attributes=None, reprompt_text=None, reprompt_ssml=None, end_session=True): """ Build a dict containing a valid response to an Alexa request. If speech output is desired, either of `text` or `ssml` should be specified. :param text: Plain text speech output...
[ "def", "respond", "(", "text", "=", "None", ",", "ssml", "=", "None", ",", "attributes", "=", "None", ",", "reprompt_text", "=", "None", ",", "reprompt_ssml", "=", "None", ",", "end_session", "=", "True", ")", ":", "obj", "=", "{", "'version'", ":", ...
Build a dict containing a valid response to an Alexa request. If speech output is desired, either of `text` or `ssml` should be specified. :param text: Plain text speech output to be said by Alexa device. :param ssml: Speech output in SSML form. :param attributes: Dictionary of attributes to store...
[ "Build", "a", "dict", "containing", "a", "valid", "response", "to", "an", "Alexa", "request", "." ]
8bea94efa1af465254a553dc4dfea3fa552b18da
https://github.com/erik/alexandra/blob/8bea94efa1af465254a553dc4dfea3fa552b18da/alexandra/util.py#L25-L63
train
erik/alexandra
alexandra/util.py
reprompt
def reprompt(text=None, ssml=None, attributes=None): """Convenience method to save a little bit of typing for the common case of reprompting the user. Simply calls :py:func:`alexandra.util.respond` with the given arguments and holds the session open. One of either the `text` or `ssml` should be provide...
python
def reprompt(text=None, ssml=None, attributes=None): """Convenience method to save a little bit of typing for the common case of reprompting the user. Simply calls :py:func:`alexandra.util.respond` with the given arguments and holds the session open. One of either the `text` or `ssml` should be provide...
[ "def", "reprompt", "(", "text", "=", "None", ",", "ssml", "=", "None", ",", "attributes", "=", "None", ")", ":", "return", "respond", "(", "reprompt_text", "=", "text", ",", "reprompt_ssml", "=", "ssml", ",", "attributes", "=", "attributes", ",", "end_se...
Convenience method to save a little bit of typing for the common case of reprompting the user. Simply calls :py:func:`alexandra.util.respond` with the given arguments and holds the session open. One of either the `text` or `ssml` should be provided if any speech output is desired. :param text: Pla...
[ "Convenience", "method", "to", "save", "a", "little", "bit", "of", "typing", "for", "the", "common", "case", "of", "reprompting", "the", "user", ".", "Simply", "calls", ":", "py", ":", "func", ":", "alexandra", ".", "util", ".", "respond", "with", "the",...
8bea94efa1af465254a553dc4dfea3fa552b18da
https://github.com/erik/alexandra/blob/8bea94efa1af465254a553dc4dfea3fa552b18da/alexandra/util.py#L66-L84
train
erik/alexandra
alexandra/util.py
validate_request_timestamp
def validate_request_timestamp(req_body, max_diff=150): """Ensure the request's timestamp doesn't fall outside of the app's specified tolerance. Returns True if this request is valid, False otherwise. :param req_body: JSON object parsed out of the raw POST data of a request. :param max_diff: Maxim...
python
def validate_request_timestamp(req_body, max_diff=150): """Ensure the request's timestamp doesn't fall outside of the app's specified tolerance. Returns True if this request is valid, False otherwise. :param req_body: JSON object parsed out of the raw POST data of a request. :param max_diff: Maxim...
[ "def", "validate_request_timestamp", "(", "req_body", ",", "max_diff", "=", "150", ")", ":", "time_str", "=", "req_body", ".", "get", "(", "'request'", ",", "{", "}", ")", ".", "get", "(", "'timestamp'", ")", "if", "not", "time_str", ":", "log", ".", "...
Ensure the request's timestamp doesn't fall outside of the app's specified tolerance. Returns True if this request is valid, False otherwise. :param req_body: JSON object parsed out of the raw POST data of a request. :param max_diff: Maximum allowable difference in seconds between request time...
[ "Ensure", "the", "request", "s", "timestamp", "doesn", "t", "fall", "outside", "of", "the", "app", "s", "specified", "tolerance", "." ]
8bea94efa1af465254a553dc4dfea3fa552b18da
https://github.com/erik/alexandra/blob/8bea94efa1af465254a553dc4dfea3fa552b18da/alexandra/util.py#L87-L112
train
erik/alexandra
alexandra/util.py
validate_request_certificate
def validate_request_certificate(headers, data): """Ensure that the certificate and signature specified in the request headers are truely from Amazon and correctly verify. Returns True if certificate verification succeeds, False otherwise. :param headers: Dictionary (or sufficiently dictionary-like) m...
python
def validate_request_certificate(headers, data): """Ensure that the certificate and signature specified in the request headers are truely from Amazon and correctly verify. Returns True if certificate verification succeeds, False otherwise. :param headers: Dictionary (or sufficiently dictionary-like) m...
[ "def", "validate_request_certificate", "(", "headers", ",", "data", ")", ":", "# Make sure we have the appropriate headers.", "if", "'SignatureCertChainUrl'", "not", "in", "headers", "or", "'Signature'", "not", "in", "headers", ":", "log", ".", "error", "(", "'invalid...
Ensure that the certificate and signature specified in the request headers are truely from Amazon and correctly verify. Returns True if certificate verification succeeds, False otherwise. :param headers: Dictionary (or sufficiently dictionary-like) map of request headers. :param data: Raw POST...
[ "Ensure", "that", "the", "certificate", "and", "signature", "specified", "in", "the", "request", "headers", "are", "truely", "from", "Amazon", "and", "correctly", "verify", "." ]
8bea94efa1af465254a553dc4dfea3fa552b18da
https://github.com/erik/alexandra/blob/8bea94efa1af465254a553dc4dfea3fa552b18da/alexandra/util.py#L115-L146
train
erik/alexandra
alexandra/util.py
_get_certificate
def _get_certificate(cert_url): """Download and validate a specified Amazon PEM file.""" global _cache if cert_url in _cache: cert = _cache[cert_url] if cert.has_expired(): _cache = {} else: return cert url = urlparse(cert_url) host = url.netloc.lowe...
python
def _get_certificate(cert_url): """Download and validate a specified Amazon PEM file.""" global _cache if cert_url in _cache: cert = _cache[cert_url] if cert.has_expired(): _cache = {} else: return cert url = urlparse(cert_url) host = url.netloc.lowe...
[ "def", "_get_certificate", "(", "cert_url", ")", ":", "global", "_cache", "if", "cert_url", "in", "_cache", ":", "cert", "=", "_cache", "[", "cert_url", "]", "if", "cert", ".", "has_expired", "(", ")", ":", "_cache", "=", "{", "}", "else", ":", "return...
Download and validate a specified Amazon PEM file.
[ "Download", "and", "validate", "a", "specified", "Amazon", "PEM", "file", "." ]
8bea94efa1af465254a553dc4dfea3fa552b18da
https://github.com/erik/alexandra/blob/8bea94efa1af465254a553dc4dfea3fa552b18da/alexandra/util.py#L149-L183
train
camptocamp/marabunta
marabunta/model.py
Version.is_processed
def is_processed(self, db_versions): """Check if version is already applied in the database. :param db_versions: """ return self.number in (v.number for v in db_versions if v.date_done)
python
def is_processed(self, db_versions): """Check if version is already applied in the database. :param db_versions: """ return self.number in (v.number for v in db_versions if v.date_done)
[ "def", "is_processed", "(", "self", ",", "db_versions", ")", ":", "return", "self", ".", "number", "in", "(", "v", ".", "number", "for", "v", "in", "db_versions", "if", "v", ".", "date_done", ")" ]
Check if version is already applied in the database. :param db_versions:
[ "Check", "if", "version", "is", "already", "applied", "in", "the", "database", "." ]
ec3a7a725c7426d6ed642e0a80119b37880eb91e
https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/model.py#L123-L128
train
camptocamp/marabunta
marabunta/model.py
Version.is_noop
def is_noop(self): """Check if version is a no operation version. """ has_operations = [mode.pre_operations or mode.post_operations for mode in self._version_modes.values()] has_upgrade_addons = [mode.upgrade_addons or mode.remove_addons ...
python
def is_noop(self): """Check if version is a no operation version. """ has_operations = [mode.pre_operations or mode.post_operations for mode in self._version_modes.values()] has_upgrade_addons = [mode.upgrade_addons or mode.remove_addons ...
[ "def", "is_noop", "(", "self", ")", ":", "has_operations", "=", "[", "mode", ".", "pre_operations", "or", "mode", ".", "post_operations", "for", "mode", "in", "self", ".", "_version_modes", ".", "values", "(", ")", "]", "has_upgrade_addons", "=", "[", "mod...
Check if version is a no operation version.
[ "Check", "if", "version", "is", "a", "no", "operation", "version", "." ]
ec3a7a725c7426d6ed642e0a80119b37880eb91e
https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/model.py#L130-L138
train
camptocamp/marabunta
marabunta/model.py
Version._get_version_mode
def _get_version_mode(self, mode=None): """Return a VersionMode for a mode name. When the mode is None, we are working with the 'base' mode. """ version_mode = self._version_modes.get(mode) if not version_mode: version_mode = self._version_modes[mode] = VersionMode(n...
python
def _get_version_mode(self, mode=None): """Return a VersionMode for a mode name. When the mode is None, we are working with the 'base' mode. """ version_mode = self._version_modes.get(mode) if not version_mode: version_mode = self._version_modes[mode] = VersionMode(n...
[ "def", "_get_version_mode", "(", "self", ",", "mode", "=", "None", ")", ":", "version_mode", "=", "self", ".", "_version_modes", ".", "get", "(", "mode", ")", "if", "not", "version_mode", ":", "version_mode", "=", "self", ".", "_version_modes", "[", "mode"...
Return a VersionMode for a mode name. When the mode is None, we are working with the 'base' mode.
[ "Return", "a", "VersionMode", "for", "a", "mode", "name", "." ]
ec3a7a725c7426d6ed642e0a80119b37880eb91e
https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/model.py#L145-L153
train
camptocamp/marabunta
marabunta/model.py
Version.add_operation
def add_operation(self, operation_type, operation, mode=None): """Add an operation to the version :param mode: Name of the mode in which the operation is executed :type mode: str :param operation_type: one of 'pre', 'post' :type operation_type: str :param operation: the ...
python
def add_operation(self, operation_type, operation, mode=None): """Add an operation to the version :param mode: Name of the mode in which the operation is executed :type mode: str :param operation_type: one of 'pre', 'post' :type operation_type: str :param operation: the ...
[ "def", "add_operation", "(", "self", ",", "operation_type", ",", "operation", ",", "mode", "=", "None", ")", ":", "version_mode", "=", "self", ".", "_get_version_mode", "(", "mode", "=", "mode", ")", "if", "operation_type", "==", "'pre'", ":", "version_mode"...
Add an operation to the version :param mode: Name of the mode in which the operation is executed :type mode: str :param operation_type: one of 'pre', 'post' :type operation_type: str :param operation: the operation to add :type operation: :class:`marabunta.model.Operatio...
[ "Add", "an", "operation", "to", "the", "version" ]
ec3a7a725c7426d6ed642e0a80119b37880eb91e
https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/model.py#L155-L174
train
camptocamp/marabunta
marabunta/model.py
Version.add_backup_operation
def add_backup_operation(self, backup, mode=None): """Add a backup operation to the version. :param backup: To either add or skip the backup :type backup: Boolean :param mode: Name of the mode in which the operation is executed For now, backups are mode-independent ...
python
def add_backup_operation(self, backup, mode=None): """Add a backup operation to the version. :param backup: To either add or skip the backup :type backup: Boolean :param mode: Name of the mode in which the operation is executed For now, backups are mode-independent ...
[ "def", "add_backup_operation", "(", "self", ",", "backup", ",", "mode", "=", "None", ")", ":", "try", ":", "if", "self", ".", "options", ".", "backup", ":", "self", ".", "options", ".", "backup", ".", "ignore_if_operation", "(", ")", ".", "execute", "(...
Add a backup operation to the version. :param backup: To either add or skip the backup :type backup: Boolean :param mode: Name of the mode in which the operation is executed For now, backups are mode-independent :type mode: String
[ "Add", "a", "backup", "operation", "to", "the", "version", "." ]
ec3a7a725c7426d6ed642e0a80119b37880eb91e
https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/model.py#L176-L189
train
camptocamp/marabunta
marabunta/model.py
Version.pre_operations
def pre_operations(self, mode=None): """ Return pre-operations only for the mode asked """ version_mode = self._get_version_mode(mode=mode) return version_mode.pre_operations
python
def pre_operations(self, mode=None): """ Return pre-operations only for the mode asked """ version_mode = self._get_version_mode(mode=mode) return version_mode.pre_operations
[ "def", "pre_operations", "(", "self", ",", "mode", "=", "None", ")", ":", "version_mode", "=", "self", ".", "_get_version_mode", "(", "mode", "=", "mode", ")", "return", "version_mode", ".", "pre_operations" ]
Return pre-operations only for the mode asked
[ "Return", "pre", "-", "operations", "only", "for", "the", "mode", "asked" ]
ec3a7a725c7426d6ed642e0a80119b37880eb91e
https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/model.py#L204-L207
train
camptocamp/marabunta
marabunta/model.py
Version.post_operations
def post_operations(self, mode=None): """ Return post-operations only for the mode asked """ version_mode = self._get_version_mode(mode=mode) return version_mode.post_operations
python
def post_operations(self, mode=None): """ Return post-operations only for the mode asked """ version_mode = self._get_version_mode(mode=mode) return version_mode.post_operations
[ "def", "post_operations", "(", "self", ",", "mode", "=", "None", ")", ":", "version_mode", "=", "self", ".", "_get_version_mode", "(", "mode", "=", "mode", ")", "return", "version_mode", ".", "post_operations" ]
Return post-operations only for the mode asked
[ "Return", "post", "-", "operations", "only", "for", "the", "mode", "asked" ]
ec3a7a725c7426d6ed642e0a80119b37880eb91e
https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/model.py#L209-L212
train
camptocamp/marabunta
marabunta/model.py
Version.upgrade_addons_operation
def upgrade_addons_operation(self, addons_state, mode=None): """ Return merged set of main addons and mode's addons """ installed = set(a.name for a in addons_state if a.state in ('installed', 'to upgrade')) base_mode = self._get_version_mode() addons_list = base...
python
def upgrade_addons_operation(self, addons_state, mode=None): """ Return merged set of main addons and mode's addons """ installed = set(a.name for a in addons_state if a.state in ('installed', 'to upgrade')) base_mode = self._get_version_mode() addons_list = base...
[ "def", "upgrade_addons_operation", "(", "self", ",", "addons_state", ",", "mode", "=", "None", ")", ":", "installed", "=", "set", "(", "a", ".", "name", "for", "a", "in", "addons_state", "if", "a", ".", "state", "in", "(", "'installed'", ",", "'to upgrad...
Return merged set of main addons and mode's addons
[ "Return", "merged", "set", "of", "main", "addons", "and", "mode", "s", "addons" ]
ec3a7a725c7426d6ed642e0a80119b37880eb91e
https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/model.py#L214-L228
train
cimm-kzn/CGRtools
CGRtools/containers/reaction.py
ReactionContainer.copy
def copy(self): """ get copy of object :return: ReactionContainer """ return type(self)(reagents=[x.copy() for x in self.__reagents], meta=self.__meta.copy(), products=[x.copy() for x in self.__products], reactants=[x.copy() fo...
python
def copy(self): """ get copy of object :return: ReactionContainer """ return type(self)(reagents=[x.copy() for x in self.__reagents], meta=self.__meta.copy(), products=[x.copy() for x in self.__products], reactants=[x.copy() fo...
[ "def", "copy", "(", "self", ")", ":", "return", "type", "(", "self", ")", "(", "reagents", "=", "[", "x", ".", "copy", "(", ")", "for", "x", "in", "self", ".", "__reagents", "]", ",", "meta", "=", "self", ".", "__meta", ".", "copy", "(", ")", ...
get copy of object :return: ReactionContainer
[ "get", "copy", "of", "object" ]
15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34
https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/reaction.py#L135-L143
train
cimm-kzn/CGRtools
CGRtools/containers/reaction.py
ReactionContainer.implicify_hydrogens
def implicify_hydrogens(self): """ remove explicit hydrogens if possible :return: number of removed hydrogens """ total = 0 for ml in (self.__reagents, self.__reactants, self.__products): for m in ml: if hasattr(m, 'implicify_hydrogens'): ...
python
def implicify_hydrogens(self): """ remove explicit hydrogens if possible :return: number of removed hydrogens """ total = 0 for ml in (self.__reagents, self.__reactants, self.__products): for m in ml: if hasattr(m, 'implicify_hydrogens'): ...
[ "def", "implicify_hydrogens", "(", "self", ")", ":", "total", "=", "0", "for", "ml", "in", "(", "self", ".", "__reagents", ",", "self", ".", "__reactants", ",", "self", ".", "__products", ")", ":", "for", "m", "in", "ml", ":", "if", "hasattr", "(", ...
remove explicit hydrogens if possible :return: number of removed hydrogens
[ "remove", "explicit", "hydrogens", "if", "possible" ]
15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34
https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/reaction.py#L145-L158
train
cimm-kzn/CGRtools
CGRtools/containers/reaction.py
ReactionContainer.reset_query_marks
def reset_query_marks(self): """ set or reset hyb and neighbors marks to atoms. """ for ml in (self.__reagents, self.__reactants, self.__products): for m in ml: if hasattr(m, 'reset_query_marks'): m.reset_query_marks() self.flush_ca...
python
def reset_query_marks(self): """ set or reset hyb and neighbors marks to atoms. """ for ml in (self.__reagents, self.__reactants, self.__products): for m in ml: if hasattr(m, 'reset_query_marks'): m.reset_query_marks() self.flush_ca...
[ "def", "reset_query_marks", "(", "self", ")", ":", "for", "ml", "in", "(", "self", ".", "__reagents", ",", "self", ".", "__reactants", ",", "self", ".", "__products", ")", ":", "for", "m", "in", "ml", ":", "if", "hasattr", "(", "m", ",", "'reset_quer...
set or reset hyb and neighbors marks to atoms.
[ "set", "or", "reset", "hyb", "and", "neighbors", "marks", "to", "atoms", "." ]
15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34
https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/reaction.py#L207-L215
train
cimm-kzn/CGRtools
CGRtools/containers/reaction.py
ReactionContainer.compose
def compose(self): """ get CGR of reaction reagents will be presented as unchanged molecules :return: CGRContainer """ rr = self.__reagents + self.__reactants if rr: if not all(isinstance(x, (MoleculeContainer, CGRContainer)) for x in rr): ...
python
def compose(self): """ get CGR of reaction reagents will be presented as unchanged molecules :return: CGRContainer """ rr = self.__reagents + self.__reactants if rr: if not all(isinstance(x, (MoleculeContainer, CGRContainer)) for x in rr): ...
[ "def", "compose", "(", "self", ")", ":", "rr", "=", "self", ".", "__reagents", "+", "self", ".", "__reactants", "if", "rr", ":", "if", "not", "all", "(", "isinstance", "(", "x", ",", "(", "MoleculeContainer", ",", "CGRContainer", ")", ")", "for", "x"...
get CGR of reaction reagents will be presented as unchanged molecules :return: CGRContainer
[ "get", "CGR", "of", "reaction" ]
15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34
https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/reaction.py#L218-L238
train
cimm-kzn/CGRtools
CGRtools/containers/reaction.py
ReactionContainer.calculate2d
def calculate2d(self, force=True): """ recalculate 2d coordinates. currently rings can be calculated badly. :param force: ignore existing coordinates of atoms """ for ml in (self.__reagents, self.__reactants, self.__products): for m in ml: m.calculate...
python
def calculate2d(self, force=True): """ recalculate 2d coordinates. currently rings can be calculated badly. :param force: ignore existing coordinates of atoms """ for ml in (self.__reagents, self.__reactants, self.__products): for m in ml: m.calculate...
[ "def", "calculate2d", "(", "self", ",", "force", "=", "True", ")", ":", "for", "ml", "in", "(", "self", ".", "__reagents", ",", "self", ".", "__reactants", ",", "self", ".", "__products", ")", ":", "for", "m", "in", "ml", ":", "m", ".", "calculate2...
recalculate 2d coordinates. currently rings can be calculated badly. :param force: ignore existing coordinates of atoms
[ "recalculate", "2d", "coordinates", ".", "currently", "rings", "can", "be", "calculated", "badly", "." ]
15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34
https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/reaction.py#L246-L255
train
cimm-kzn/CGRtools
CGRtools/containers/reaction.py
ReactionContainer.fix_positions
def fix_positions(self): """ fix coordinates of molecules in reaction """ shift_x = 0 for m in self.__reactants: max_x = self.__fix_positions(m, shift_x, 0) shift_x = max_x + 1 arrow_min = shift_x if self.__reagents: for m in s...
python
def fix_positions(self): """ fix coordinates of molecules in reaction """ shift_x = 0 for m in self.__reactants: max_x = self.__fix_positions(m, shift_x, 0) shift_x = max_x + 1 arrow_min = shift_x if self.__reagents: for m in s...
[ "def", "fix_positions", "(", "self", ")", ":", "shift_x", "=", "0", "for", "m", "in", "self", ".", "__reactants", ":", "max_x", "=", "self", ".", "__fix_positions", "(", "m", ",", "shift_x", ",", "0", ")", "shift_x", "=", "max_x", "+", "1", "arrow_mi...
fix coordinates of molecules in reaction
[ "fix", "coordinates", "of", "molecules", "in", "reaction" ]
15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34
https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/reaction.py#L257-L279
train
zetaops/zengine
zengine/models/auth.py
Unit.get_role_keys
def get_role_keys(cls, unit_key): """ :param unit_key: Parent unit key :return: role keys of subunits """ stack = Role.objects.filter(unit_id=unit_key).values_list('key', flatten=True) for unit_key in cls.objects.filter(parent_id=unit_key).values_list('key', flatten=True)...
python
def get_role_keys(cls, unit_key): """ :param unit_key: Parent unit key :return: role keys of subunits """ stack = Role.objects.filter(unit_id=unit_key).values_list('key', flatten=True) for unit_key in cls.objects.filter(parent_id=unit_key).values_list('key', flatten=True)...
[ "def", "get_role_keys", "(", "cls", ",", "unit_key", ")", ":", "stack", "=", "Role", ".", "objects", ".", "filter", "(", "unit_id", "=", "unit_key", ")", ".", "values_list", "(", "'key'", ",", "flatten", "=", "True", ")", "for", "unit_key", "in", "cls"...
:param unit_key: Parent unit key :return: role keys of subunits
[ ":", "param", "unit_key", ":", "Parent", "unit", "key", ":", "return", ":", "role", "keys", "of", "subunits" ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/auth.py#L44-L52
train
zetaops/zengine
zengine/models/auth.py
User.get_permissions
def get_permissions(self): """ Permissions of the user. Returns: List of Permission objects. """ user_role = self.last_login_role() if self.last_login_role_key else self.role_set[0].role return user_role.get_permissions()
python
def get_permissions(self): """ Permissions of the user. Returns: List of Permission objects. """ user_role = self.last_login_role() if self.last_login_role_key else self.role_set[0].role return user_role.get_permissions()
[ "def", "get_permissions", "(", "self", ")", ":", "user_role", "=", "self", ".", "last_login_role", "(", ")", "if", "self", ".", "last_login_role_key", "else", "self", ".", "role_set", "[", "0", "]", ".", "role", "return", "user_role", ".", "get_permissions",...
Permissions of the user. Returns: List of Permission objects.
[ "Permissions", "of", "the", "user", "." ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/auth.py#L119-L127
train
zetaops/zengine
zengine/models/auth.py
AbstractRole.get_permissions
def get_permissions(self): """ Soyut role ait Permission nesnelerini bulur ve code değerlerini döner. Returns: list: Permission code değerleri """ return [p.permission.code for p in self.Permissions if p.permission.code]
python
def get_permissions(self): """ Soyut role ait Permission nesnelerini bulur ve code değerlerini döner. Returns: list: Permission code değerleri """ return [p.permission.code for p in self.Permissions if p.permission.code]
[ "def", "get_permissions", "(", "self", ")", ":", "return", "[", "p", ".", "permission", ".", "code", "for", "p", "in", "self", ".", "Permissions", "if", "p", ".", "permission", ".", "code", "]" ]
Soyut role ait Permission nesnelerini bulur ve code değerlerini döner. Returns: list: Permission code değerleri
[ "Soyut", "role", "ait", "Permission", "nesnelerini", "bulur", "ve", "code", "değerlerini", "döner", "." ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/auth.py#L156-L165
train
zetaops/zengine
zengine/models/auth.py
AbstractRole.add_permission
def add_permission(self, perm): """ Soyut Role Permission nesnesi tanımlamayı sağlar. Args: perm (object): """ self.Permissions(permission=perm) PermissionCache.flush() self.save()
python
def add_permission(self, perm): """ Soyut Role Permission nesnesi tanımlamayı sağlar. Args: perm (object): """ self.Permissions(permission=perm) PermissionCache.flush() self.save()
[ "def", "add_permission", "(", "self", ",", "perm", ")", ":", "self", ".", "Permissions", "(", "permission", "=", "perm", ")", "PermissionCache", ".", "flush", "(", ")", "self", ".", "save", "(", ")" ]
Soyut Role Permission nesnesi tanımlamayı sağlar. Args: perm (object):
[ "Soyut", "Role", "Permission", "nesnesi", "tanımlamayı", "sağlar", "." ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/auth.py#L167-L177
train
zetaops/zengine
zengine/models/auth.py
Role.add_permission_by_name
def add_permission_by_name(self, code, save=False): """ Adds a permission with given name. Args: code (str): Code name of the permission. save (bool): If False, does nothing. """ if not save: return ["%s | %s" % (p.name, p.code) for p in ...
python
def add_permission_by_name(self, code, save=False): """ Adds a permission with given name. Args: code (str): Code name of the permission. save (bool): If False, does nothing. """ if not save: return ["%s | %s" % (p.name, p.code) for p in ...
[ "def", "add_permission_by_name", "(", "self", ",", "code", ",", "save", "=", "False", ")", ":", "if", "not", "save", ":", "return", "[", "\"%s | %s\"", "%", "(", "p", ".", "name", ",", "p", ".", "code", ")", "for", "p", "in", "Permission", ".", "ob...
Adds a permission with given name. Args: code (str): Code name of the permission. save (bool): If False, does nothing.
[ "Adds", "a", "permission", "with", "given", "name", "." ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/auth.py#L267-L282
train
zetaops/zengine
zengine/models/auth.py
Role.send_notification
def send_notification(self, title, message, typ=1, url=None, sender=None): """ sends a message to user of this role's private mq exchange """ self.user.send_notification(title=title, message=message, typ=typ, url=url, sender=sender)
python
def send_notification(self, title, message, typ=1, url=None, sender=None): """ sends a message to user of this role's private mq exchange """ self.user.send_notification(title=title, message=message, typ=typ, url=url, sender=sender)
[ "def", "send_notification", "(", "self", ",", "title", ",", "message", ",", "typ", "=", "1", ",", "url", "=", "None", ",", "sender", "=", "None", ")", ":", "self", ".", "user", ".", "send_notification", "(", "title", "=", "title", ",", "message", "="...
sends a message to user of this role's private mq exchange
[ "sends", "a", "message", "to", "user", "of", "this", "role", "s", "private", "mq", "exchange" ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/auth.py#L284-L290
train
LordDarkula/chess_py
chess_py/core/algebraic/move.py
Move.would_move_be_promotion
def would_move_be_promotion(self): """ Finds if move from current location would be a promotion """ return (self._end_loc.rank == 0 and not self.color) or \ (self._end_loc.rank == 7 and self.color)
python
def would_move_be_promotion(self): """ Finds if move from current location would be a promotion """ return (self._end_loc.rank == 0 and not self.color) or \ (self._end_loc.rank == 7 and self.color)
[ "def", "would_move_be_promotion", "(", "self", ")", ":", "return", "(", "self", ".", "_end_loc", ".", "rank", "==", "0", "and", "not", "self", ".", "color", ")", "or", "(", "self", ".", "_end_loc", ".", "rank", "==", "7", "and", "self", ".", "color",...
Finds if move from current location would be a promotion
[ "Finds", "if", "move", "from", "current", "location", "would", "be", "a", "promotion" ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/move.py#L120-L125
train
zetaops/zengine
zengine/dispatch/dispatcher.py
Signal.connect
def connect(self, receiver, sender=None, weak=True, dispatch_uid=None): """ Connect receiver to sender for signal. Arguments: receiver A function or an instance method which is to receive signals. Receivers must be hashable objects. ...
python
def connect(self, receiver, sender=None, weak=True, dispatch_uid=None): """ Connect receiver to sender for signal. Arguments: receiver A function or an instance method which is to receive signals. Receivers must be hashable objects. ...
[ "def", "connect", "(", "self", ",", "receiver", ",", "sender", "=", "None", ",", "weak", "=", "True", ",", "dispatch_uid", "=", "None", ")", ":", "if", "dispatch_uid", ":", "lookup_key", "=", "(", "dispatch_uid", ",", "_make_id", "(", "sender", ")", ")...
Connect receiver to sender for signal. Arguments: receiver A function or an instance method which is to receive signals. Receivers must be hashable objects. If weak is True, then receiver must be weak referenceable. Receivers must b...
[ "Connect", "receiver", "to", "sender", "for", "signal", "." ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/dispatch/dispatcher.py#L56-L114
train
zetaops/zengine
zengine/dispatch/dispatcher.py
Signal.disconnect
def disconnect(self, receiver=None, sender=None, dispatch_uid=None): """ Disconnect receiver from sender for signal. If weak references are used, disconnect need not be called. The receiver will be remove from dispatch automatically. Arguments: receiver ...
python
def disconnect(self, receiver=None, sender=None, dispatch_uid=None): """ Disconnect receiver from sender for signal. If weak references are used, disconnect need not be called. The receiver will be remove from dispatch automatically. Arguments: receiver ...
[ "def", "disconnect", "(", "self", ",", "receiver", "=", "None", ",", "sender", "=", "None", ",", "dispatch_uid", "=", "None", ")", ":", "if", "dispatch_uid", ":", "lookup_key", "=", "(", "dispatch_uid", ",", "_make_id", "(", "sender", ")", ")", "else", ...
Disconnect receiver from sender for signal. If weak references are used, disconnect need not be called. The receiver will be remove from dispatch automatically. Arguments: receiver The registered receiver to disconnect. May be none if dispatch_uid i...
[ "Disconnect", "receiver", "from", "sender", "for", "signal", "." ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/dispatch/dispatcher.py#L116-L151
train
camptocamp/marabunta
marabunta/core.py
migrate
def migrate(config): """Perform a migration according to config. :param config: The configuration to be applied :type config: Config """ webapp = WebApp(config.web_host, config.web_port, custom_maintenance_file=config.web_custom_html) webserver = WebServer(webapp) webse...
python
def migrate(config): """Perform a migration according to config. :param config: The configuration to be applied :type config: Config """ webapp = WebApp(config.web_host, config.web_port, custom_maintenance_file=config.web_custom_html) webserver = WebServer(webapp) webse...
[ "def", "migrate", "(", "config", ")", ":", "webapp", "=", "WebApp", "(", "config", ".", "web_host", ",", "config", ".", "web_port", ",", "custom_maintenance_file", "=", "config", ".", "web_custom_html", ")", "webserver", "=", "WebServer", "(", "webapp", ")",...
Perform a migration according to config. :param config: The configuration to be applied :type config: Config
[ "Perform", "a", "migration", "according", "to", "config", "." ]
ec3a7a725c7426d6ed642e0a80119b37880eb91e
https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/core.py#L103-L146
train
camptocamp/marabunta
marabunta/core.py
main
def main(): """Parse the command line and run :func:`migrate`.""" parser = get_args_parser() args = parser.parse_args() config = Config.from_parse_args(args) migrate(config)
python
def main(): """Parse the command line and run :func:`migrate`.""" parser = get_args_parser() args = parser.parse_args() config = Config.from_parse_args(args) migrate(config)
[ "def", "main", "(", ")", ":", "parser", "=", "get_args_parser", "(", ")", "args", "=", "parser", ".", "parse_args", "(", ")", "config", "=", "Config", ".", "from_parse_args", "(", "args", ")", "migrate", "(", "config", ")" ]
Parse the command line and run :func:`migrate`.
[ "Parse", "the", "command", "line", "and", "run", ":", "func", ":", "migrate", "." ]
ec3a7a725c7426d6ed642e0a80119b37880eb91e
https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/core.py#L149-L154
train
zetaops/zengine
zengine/views/crud.py
CrudMeta.get_permissions
def get_permissions(cls): """ Generates permissions for all CrudView based class methods. Returns: List of Permission objects. """ perms = [] for kls_name, kls in cls.registry.items(): for method_name in cls.__dict__.keys(): if met...
python
def get_permissions(cls): """ Generates permissions for all CrudView based class methods. Returns: List of Permission objects. """ perms = [] for kls_name, kls in cls.registry.items(): for method_name in cls.__dict__.keys(): if met...
[ "def", "get_permissions", "(", "cls", ")", ":", "perms", "=", "[", "]", "for", "kls_name", ",", "kls", "in", "cls", ".", "registry", ".", "items", "(", ")", ":", "for", "method_name", "in", "cls", ".", "__dict__", ".", "keys", "(", ")", ":", "if", ...
Generates permissions for all CrudView based class methods. Returns: List of Permission objects.
[ "Generates", "permissions", "for", "all", "CrudView", "based", "class", "methods", "." ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/crud.py#L93-L105
train
zetaops/zengine
zengine/auth/permissions.py
_get_object_menu_models
def _get_object_menu_models(): """ we need to create basic permissions for only CRUD enabled models """ from pyoko.conf import settings enabled_models = [] for entry in settings.OBJECT_MENU.values(): for mdl in entry: if 'wf' not in mdl: enabled_models.app...
python
def _get_object_menu_models(): """ we need to create basic permissions for only CRUD enabled models """ from pyoko.conf import settings enabled_models = [] for entry in settings.OBJECT_MENU.values(): for mdl in entry: if 'wf' not in mdl: enabled_models.app...
[ "def", "_get_object_menu_models", "(", ")", ":", "from", "pyoko", ".", "conf", "import", "settings", "enabled_models", "=", "[", "]", "for", "entry", "in", "settings", ".", "OBJECT_MENU", ".", "values", "(", ")", ":", "for", "mdl", "in", "entry", ":", "i...
we need to create basic permissions for only CRUD enabled models
[ "we", "need", "to", "create", "basic", "permissions", "for", "only", "CRUD", "enabled", "models" ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/auth/permissions.py#L95-L106
train
zetaops/zengine
zengine/auth/permissions.py
CustomPermission.add
def add(cls, code_name, name='', description=''): """ create a custom permission """ if code_name not in cls.registry: cls.registry[code_name] = (code_name, name or code_name, description) return code_name
python
def add(cls, code_name, name='', description=''): """ create a custom permission """ if code_name not in cls.registry: cls.registry[code_name] = (code_name, name or code_name, description) return code_name
[ "def", "add", "(", "cls", ",", "code_name", ",", "name", "=", "''", ",", "description", "=", "''", ")", ":", "if", "code_name", "not", "in", "cls", ".", "registry", ":", "cls", ".", "registry", "[", "code_name", "]", "=", "(", "code_name", ",", "na...
create a custom permission
[ "create", "a", "custom", "permission" ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/auth/permissions.py#L27-L33
train
cimm-kzn/CGRtools
CGRtools/algorithms/isomorphism.py
Isomorphism.get_mapping
def get_mapping(self, other): """ get self to other mapping """ m = next(self._matcher(other).isomorphisms_iter(), None) if m: return {v: k for k, v in m.items()}
python
def get_mapping(self, other): """ get self to other mapping """ m = next(self._matcher(other).isomorphisms_iter(), None) if m: return {v: k for k, v in m.items()}
[ "def", "get_mapping", "(", "self", ",", "other", ")", ":", "m", "=", "next", "(", "self", ".", "_matcher", "(", "other", ")", ".", "isomorphisms_iter", "(", ")", ",", "None", ")", "if", "m", ":", "return", "{", "v", ":", "k", "for", "k", ",", "...
get self to other mapping
[ "get", "self", "to", "other", "mapping" ]
15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34
https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/isomorphism.py#L56-L62
train
cimm-kzn/CGRtools
CGRtools/algorithms/isomorphism.py
Isomorphism.get_substructure_mapping
def get_substructure_mapping(self, other, limit=1): """ get self to other substructure mapping :param limit: number of matches. if 0 return iterator for all possible; if 1 return dict or None; if > 1 return list of dicts """ i = self._matcher(other).subgraph_isomorph...
python
def get_substructure_mapping(self, other, limit=1): """ get self to other substructure mapping :param limit: number of matches. if 0 return iterator for all possible; if 1 return dict or None; if > 1 return list of dicts """ i = self._matcher(other).subgraph_isomorph...
[ "def", "get_substructure_mapping", "(", "self", ",", "other", ",", "limit", "=", "1", ")", ":", "i", "=", "self", ".", "_matcher", "(", "other", ")", ".", "subgraph_isomorphisms_iter", "(", ")", "if", "limit", "==", "1", ":", "m", "=", "next", "(", "...
get self to other substructure mapping :param limit: number of matches. if 0 return iterator for all possible; if 1 return dict or None; if > 1 return list of dicts
[ "get", "self", "to", "other", "substructure", "mapping" ]
15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34
https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/isomorphism.py#L64-L79
train
LordDarkula/chess_py
chess_py/core/algebraic/location.py
Location.from_string
def from_string(cls, alg_str): """ Creates a location from a two character string consisting of the file then rank written in algebraic notation. Examples: e4, b5, a7 :type: alg_str: str :rtype: Location """ try: return cls(int(alg_s...
python
def from_string(cls, alg_str): """ Creates a location from a two character string consisting of the file then rank written in algebraic notation. Examples: e4, b5, a7 :type: alg_str: str :rtype: Location """ try: return cls(int(alg_s...
[ "def", "from_string", "(", "cls", ",", "alg_str", ")", ":", "try", ":", "return", "cls", "(", "int", "(", "alg_str", "[", "1", "]", ")", "-", "1", ",", "ord", "(", "alg_str", "[", "0", "]", ")", "-", "97", ")", "except", "ValueError", "as", "e"...
Creates a location from a two character string consisting of the file then rank written in algebraic notation. Examples: e4, b5, a7 :type: alg_str: str :rtype: Location
[ "Creates", "a", "location", "from", "a", "two", "character", "string", "consisting", "of", "the", "file", "then", "rank", "written", "in", "algebraic", "notation", ".", "Examples", ":", "e4", "b5", "a7" ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/location.py#L63-L76
train
LordDarkula/chess_py
chess_py/core/algebraic/location.py
Location.shift
def shift(self, direction): """ Shifts in direction provided by ``Direction`` enum. :type: direction: Direction :rtype: Location """ try: if direction == Direction.UP: return self.shift_up() elif direction == Direction.DOWN: ...
python
def shift(self, direction): """ Shifts in direction provided by ``Direction`` enum. :type: direction: Direction :rtype: Location """ try: if direction == Direction.UP: return self.shift_up() elif direction == Direction.DOWN: ...
[ "def", "shift", "(", "self", ",", "direction", ")", ":", "try", ":", "if", "direction", "==", "Direction", ".", "UP", ":", "return", "self", ".", "shift_up", "(", ")", "elif", "direction", "==", "Direction", ".", "DOWN", ":", "return", "self", ".", "...
Shifts in direction provided by ``Direction`` enum. :type: direction: Direction :rtype: Location
[ "Shifts", "in", "direction", "provided", "by", "Direction", "enum", "." ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/location.py#L144-L163
train
LordDarkula/chess_py
chess_py/core/algebraic/location.py
Location.shift_up
def shift_up(self, times=1): """ Finds Location shifted up by 1 :rtype: Location """ try: return Location(self._rank + times, self._file) except IndexError as e: raise IndexError(e)
python
def shift_up(self, times=1): """ Finds Location shifted up by 1 :rtype: Location """ try: return Location(self._rank + times, self._file) except IndexError as e: raise IndexError(e)
[ "def", "shift_up", "(", "self", ",", "times", "=", "1", ")", ":", "try", ":", "return", "Location", "(", "self", ".", "_rank", "+", "times", ",", "self", ".", "_file", ")", "except", "IndexError", "as", "e", ":", "raise", "IndexError", "(", "e", ")...
Finds Location shifted up by 1 :rtype: Location
[ "Finds", "Location", "shifted", "up", "by", "1" ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/location.py#L165-L174
train
LordDarkula/chess_py
chess_py/core/algebraic/location.py
Location.shift_down
def shift_down(self, times=1): """ Finds Location shifted down by 1 :rtype: Location """ try: return Location(self._rank - times, self._file) except IndexError as e: raise IndexError(e)
python
def shift_down(self, times=1): """ Finds Location shifted down by 1 :rtype: Location """ try: return Location(self._rank - times, self._file) except IndexError as e: raise IndexError(e)
[ "def", "shift_down", "(", "self", ",", "times", "=", "1", ")", ":", "try", ":", "return", "Location", "(", "self", ".", "_rank", "-", "times", ",", "self", ".", "_file", ")", "except", "IndexError", "as", "e", ":", "raise", "IndexError", "(", "e", ...
Finds Location shifted down by 1 :rtype: Location
[ "Finds", "Location", "shifted", "down", "by", "1" ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/location.py#L176-L185
train
LordDarkula/chess_py
chess_py/core/algebraic/location.py
Location.shift_right
def shift_right(self, times=1): """ Finds Location shifted right by 1 :rtype: Location """ try: return Location(self._rank, self._file + times) except IndexError as e: raise IndexError(e)
python
def shift_right(self, times=1): """ Finds Location shifted right by 1 :rtype: Location """ try: return Location(self._rank, self._file + times) except IndexError as e: raise IndexError(e)
[ "def", "shift_right", "(", "self", ",", "times", "=", "1", ")", ":", "try", ":", "return", "Location", "(", "self", ".", "_rank", ",", "self", ".", "_file", "+", "times", ")", "except", "IndexError", "as", "e", ":", "raise", "IndexError", "(", "e", ...
Finds Location shifted right by 1 :rtype: Location
[ "Finds", "Location", "shifted", "right", "by", "1" ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/location.py#L201-L210
train
LordDarkula/chess_py
chess_py/core/algebraic/location.py
Location.shift_left
def shift_left(self, times=1): """ Finds Location shifted left by 1 :rtype: Location """ try: return Location(self._rank, self._file - times) except IndexError as e: raise IndexError(e)
python
def shift_left(self, times=1): """ Finds Location shifted left by 1 :rtype: Location """ try: return Location(self._rank, self._file - times) except IndexError as e: raise IndexError(e)
[ "def", "shift_left", "(", "self", ",", "times", "=", "1", ")", ":", "try", ":", "return", "Location", "(", "self", ".", "_rank", ",", "self", ".", "_file", "-", "times", ")", "except", "IndexError", "as", "e", ":", "raise", "IndexError", "(", "e", ...
Finds Location shifted left by 1 :rtype: Location
[ "Finds", "Location", "shifted", "left", "by", "1" ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/location.py#L212-L221
train
LordDarkula/chess_py
chess_py/core/algebraic/location.py
Location.shift_up_right
def shift_up_right(self, times=1): """ Finds Location shifted up right by 1 :rtype: Location """ try: return Location(self._rank + times, self._file + times) except IndexError as e: raise IndexError(e)
python
def shift_up_right(self, times=1): """ Finds Location shifted up right by 1 :rtype: Location """ try: return Location(self._rank + times, self._file + times) except IndexError as e: raise IndexError(e)
[ "def", "shift_up_right", "(", "self", ",", "times", "=", "1", ")", ":", "try", ":", "return", "Location", "(", "self", ".", "_rank", "+", "times", ",", "self", ".", "_file", "+", "times", ")", "except", "IndexError", "as", "e", ":", "raise", "IndexEr...
Finds Location shifted up right by 1 :rtype: Location
[ "Finds", "Location", "shifted", "up", "right", "by", "1" ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/location.py#L223-L232
train
LordDarkula/chess_py
chess_py/core/algebraic/location.py
Location.shift_up_left
def shift_up_left(self, times=1): """ Finds Location shifted up left by 1 :rtype: Location """ try: return Location(self._rank + times, self._file - times) except IndexError as e: raise IndexError(e)
python
def shift_up_left(self, times=1): """ Finds Location shifted up left by 1 :rtype: Location """ try: return Location(self._rank + times, self._file - times) except IndexError as e: raise IndexError(e)
[ "def", "shift_up_left", "(", "self", ",", "times", "=", "1", ")", ":", "try", ":", "return", "Location", "(", "self", ".", "_rank", "+", "times", ",", "self", ".", "_file", "-", "times", ")", "except", "IndexError", "as", "e", ":", "raise", "IndexErr...
Finds Location shifted up left by 1 :rtype: Location
[ "Finds", "Location", "shifted", "up", "left", "by", "1" ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/location.py#L234-L243
train
LordDarkula/chess_py
chess_py/core/algebraic/location.py
Location.shift_down_right
def shift_down_right(self, times=1): """ Finds Location shifted down right by 1 :rtype: Location """ try: return Location(self._rank - times, self._file + times) except IndexError as e: raise IndexError(e)
python
def shift_down_right(self, times=1): """ Finds Location shifted down right by 1 :rtype: Location """ try: return Location(self._rank - times, self._file + times) except IndexError as e: raise IndexError(e)
[ "def", "shift_down_right", "(", "self", ",", "times", "=", "1", ")", ":", "try", ":", "return", "Location", "(", "self", ".", "_rank", "-", "times", ",", "self", ".", "_file", "+", "times", ")", "except", "IndexError", "as", "e", ":", "raise", "Index...
Finds Location shifted down right by 1 :rtype: Location
[ "Finds", "Location", "shifted", "down", "right", "by", "1" ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/location.py#L245-L254
train
LordDarkula/chess_py
chess_py/core/algebraic/location.py
Location.shift_down_left
def shift_down_left(self, times=1): """ Finds Location shifted down left by 1 :rtype: Location """ try: return Location(self._rank - times, self._file - times) except IndexError as e: raise IndexError(e)
python
def shift_down_left(self, times=1): """ Finds Location shifted down left by 1 :rtype: Location """ try: return Location(self._rank - times, self._file - times) except IndexError as e: raise IndexError(e)
[ "def", "shift_down_left", "(", "self", ",", "times", "=", "1", ")", ":", "try", ":", "return", "Location", "(", "self", ".", "_rank", "-", "times", ",", "self", ".", "_file", "-", "times", ")", "except", "IndexError", "as", "e", ":", "raise", "IndexE...
Finds Location shifted down left by 1 :rtype: Location
[ "Finds", "Location", "shifted", "down", "left", "by", "1" ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/location.py#L256-L265
train
cimm-kzn/CGRtools
CGRtools/algorithms/standardize.py
Standardize.standardize
def standardize(self): """ standardize functional groups :return: number of found groups """ self.reset_query_marks() seen = set() total = 0 for n, atom in self.atoms(): if n in seen: continue for k, center in centr...
python
def standardize(self): """ standardize functional groups :return: number of found groups """ self.reset_query_marks() seen = set() total = 0 for n, atom in self.atoms(): if n in seen: continue for k, center in centr...
[ "def", "standardize", "(", "self", ")", ":", "self", ".", "reset_query_marks", "(", ")", "seen", "=", "set", "(", ")", "total", "=", "0", "for", "n", ",", "atom", "in", "self", ".", "atoms", "(", ")", ":", "if", "n", "in", "seen", ":", "continue"...
standardize functional groups :return: number of found groups
[ "standardize", "functional", "groups" ]
15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34
https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/standardize.py#L26-L60
train
zetaops/zengine
git-hooks/pre-commit.py
get_staged_files
def get_staged_files(): """Get all files staged for the current commit. """ proc = subprocess.Popen(('git', 'status', '--porcelain'), stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, _ = proc.communicate() staged_files = modified_re.findall...
python
def get_staged_files(): """Get all files staged for the current commit. """ proc = subprocess.Popen(('git', 'status', '--porcelain'), stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, _ = proc.communicate() staged_files = modified_re.findall...
[ "def", "get_staged_files", "(", ")", ":", "proc", "=", "subprocess", ".", "Popen", "(", "(", "'git'", ",", "'status'", ",", "'--porcelain'", ")", ",", "stdout", "=", "subprocess", ".", "PIPE", ",", "stderr", "=", "subprocess", ".", "PIPE", ")", "out", ...
Get all files staged for the current commit.
[ "Get", "all", "files", "staged", "for", "the", "current", "commit", "." ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/git-hooks/pre-commit.py#L23-L31
train
zetaops/zengine
zengine/tornado_server/server.py
runserver
def runserver(host=None, port=None): """ Run Tornado server """ host = host or os.getenv('HTTP_HOST', '0.0.0.0') port = port or os.getenv('HTTP_PORT', '9001') zioloop = ioloop.IOLoop.instance() # setup pika client: pc = QueueManager(zioloop) app.pc = pc pc.connect() app.list...
python
def runserver(host=None, port=None): """ Run Tornado server """ host = host or os.getenv('HTTP_HOST', '0.0.0.0') port = port or os.getenv('HTTP_PORT', '9001') zioloop = ioloop.IOLoop.instance() # setup pika client: pc = QueueManager(zioloop) app.pc = pc pc.connect() app.list...
[ "def", "runserver", "(", "host", "=", "None", ",", "port", "=", "None", ")", ":", "host", "=", "host", "or", "os", ".", "getenv", "(", "'HTTP_HOST'", ",", "'0.0.0.0'", ")", "port", "=", "port", "or", "os", ".", "getenv", "(", "'HTTP_PORT'", ",", "'...
Run Tornado server
[ "Run", "Tornado", "server" ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/tornado_server/server.py#L160-L173
train
zetaops/zengine
zengine/tornado_server/server.py
SocketHandler.open
def open(self): """ Called on new websocket connection. """ sess_id = self._get_sess_id() if sess_id: self.application.pc.websockets[self._get_sess_id()] = self self.write_message(json.dumps({"cmd": "status", "status": "open"})) else: s...
python
def open(self): """ Called on new websocket connection. """ sess_id = self._get_sess_id() if sess_id: self.application.pc.websockets[self._get_sess_id()] = self self.write_message(json.dumps({"cmd": "status", "status": "open"})) else: s...
[ "def", "open", "(", "self", ")", ":", "sess_id", "=", "self", ".", "_get_sess_id", "(", ")", "if", "sess_id", ":", "self", ".", "application", ".", "pc", ".", "websockets", "[", "self", ".", "_get_sess_id", "(", ")", "]", "=", "self", "self", ".", ...
Called on new websocket connection.
[ "Called", "on", "new", "websocket", "connection", "." ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/tornado_server/server.py#L48-L57
train
zetaops/zengine
zengine/tornado_server/server.py
SocketHandler.on_message
def on_message(self, message): """ called on new websocket message, """ log.debug("WS MSG for %s: %s" % (self._get_sess_id(), message)) self.application.pc.redirect_incoming_message(self._get_sess_id(), message, self.request)
python
def on_message(self, message): """ called on new websocket message, """ log.debug("WS MSG for %s: %s" % (self._get_sess_id(), message)) self.application.pc.redirect_incoming_message(self._get_sess_id(), message, self.request)
[ "def", "on_message", "(", "self", ",", "message", ")", ":", "log", ".", "debug", "(", "\"WS MSG for %s: %s\"", "%", "(", "self", ".", "_get_sess_id", "(", ")", ",", "message", ")", ")", "self", ".", "application", ".", "pc", ".", "redirect_incoming_message...
called on new websocket message,
[ "called", "on", "new", "websocket", "message" ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/tornado_server/server.py#L59-L64
train
zetaops/zengine
zengine/tornado_server/server.py
HttpHandler._handle_headers
def _handle_headers(self): """ Do response processing """ origin = self.request.headers.get('Origin') if not settings.DEBUG: if origin in settings.ALLOWED_ORIGINS or not origin: self.set_header('Access-Control-Allow-Origin', origin) else: ...
python
def _handle_headers(self): """ Do response processing """ origin = self.request.headers.get('Origin') if not settings.DEBUG: if origin in settings.ALLOWED_ORIGINS or not origin: self.set_header('Access-Control-Allow-Origin', origin) else: ...
[ "def", "_handle_headers", "(", "self", ")", ":", "origin", "=", "self", ".", "request", ".", "headers", ".", "get", "(", "'Origin'", ")", "if", "not", "settings", ".", "DEBUG", ":", "if", "origin", "in", "settings", ".", "ALLOWED_ORIGINS", "or", "not", ...
Do response processing
[ "Do", "response", "processing" ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/tornado_server/server.py#L79-L96
train
zetaops/zengine
zengine/tornado_server/server.py
HttpHandler.post
def post(self, view_name): """ login handler """ sess_id = None input_data = {} # try: self._handle_headers() # handle input input_data = json_decode(self.request.body) if self.request.body else {} input_data['path'] = view_name #...
python
def post(self, view_name): """ login handler """ sess_id = None input_data = {} # try: self._handle_headers() # handle input input_data = json_decode(self.request.body) if self.request.body else {} input_data['path'] = view_name #...
[ "def", "post", "(", "self", ",", "view_name", ")", ":", "sess_id", "=", "None", "input_data", "=", "{", "}", "# try:", "self", ".", "_handle_headers", "(", ")", "# handle input", "input_data", "=", "json_decode", "(", "self", ".", "request", ".", "body", ...
login handler
[ "login", "handler" ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/tornado_server/server.py#L110-L137
train
deep-compute/logagg
logagg/collector.py
load_formatter_fn
def load_formatter_fn(formatter): ''' >>> load_formatter_fn('logagg.formatters.basescript') #doctest: +ELLIPSIS <function basescript at 0x...> ''' obj = util.load_object(formatter) if not hasattr(obj, 'ispartial'): obj.ispartial = util.ispartial return obj
python
def load_formatter_fn(formatter): ''' >>> load_formatter_fn('logagg.formatters.basescript') #doctest: +ELLIPSIS <function basescript at 0x...> ''' obj = util.load_object(formatter) if not hasattr(obj, 'ispartial'): obj.ispartial = util.ispartial return obj
[ "def", "load_formatter_fn", "(", "formatter", ")", ":", "obj", "=", "util", ".", "load_object", "(", "formatter", ")", "if", "not", "hasattr", "(", "obj", ",", "'ispartial'", ")", ":", "obj", ".", "ispartial", "=", "util", ".", "ispartial", "return", "ob...
>>> load_formatter_fn('logagg.formatters.basescript') #doctest: +ELLIPSIS <function basescript at 0x...>
[ ">>>", "load_formatter_fn", "(", "logagg", ".", "formatters", ".", "basescript", ")", "#doctest", ":", "+", "ELLIPSIS", "<function", "basescript", "at", "0x", "...", ">" ]
7863bc1b5ddf3e67c4d4b55746799304180589a0
https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/collector.py#L23-L31
train
deep-compute/logagg
logagg/collector.py
LogCollector._remove_redundancy
def _remove_redundancy(self, log): """Removes duplicate data from 'data' inside log dict and brings it out. >>> lc = LogCollector('file=/path/to/log_file.log:formatter=logagg.formatters.basescript', 30) >>> log = {'id' : 46846876, 'type' : 'log', ... 'data' : {'a' : 1, ...
python
def _remove_redundancy(self, log): """Removes duplicate data from 'data' inside log dict and brings it out. >>> lc = LogCollector('file=/path/to/log_file.log:formatter=logagg.formatters.basescript', 30) >>> log = {'id' : 46846876, 'type' : 'log', ... 'data' : {'a' : 1, ...
[ "def", "_remove_redundancy", "(", "self", ",", "log", ")", ":", "for", "key", "in", "log", ":", "if", "key", "in", "log", "and", "key", "in", "log", "[", "'data'", "]", ":", "log", "[", "key", "]", "=", "log", "[", "'data'", "]", ".", "pop", "(...
Removes duplicate data from 'data' inside log dict and brings it out. >>> lc = LogCollector('file=/path/to/log_file.log:formatter=logagg.formatters.basescript', 30) >>> log = {'id' : 46846876, 'type' : 'log', ... 'data' : {'a' : 1, 'b' : 2, 'type' : 'metric'}} >>> lc._r...
[ "Removes", "duplicate", "data", "from", "data", "inside", "log", "dict", "and", "brings", "it", "out", "." ]
7863bc1b5ddf3e67c4d4b55746799304180589a0
https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/collector.py#L78-L92
train
deep-compute/logagg
logagg/collector.py
LogCollector.validate_log_format
def validate_log_format(self, log): ''' >>> lc = LogCollector('file=/path/to/file.log:formatter=logagg.formatters.basescript', 30) >>> incomplete_log = {'data' : {'x' : 1, 'y' : 2}, ... 'raw' : 'Not all keys present'} >>> lc.validate_log_format(incomplete_log...
python
def validate_log_format(self, log): ''' >>> lc = LogCollector('file=/path/to/file.log:formatter=logagg.formatters.basescript', 30) >>> incomplete_log = {'data' : {'x' : 1, 'y' : 2}, ... 'raw' : 'Not all keys present'} >>> lc.validate_log_format(incomplete_log...
[ "def", "validate_log_format", "(", "self", ",", "log", ")", ":", "keys_in_log", "=", "set", "(", "log", ")", "keys_in_log_structure", "=", "set", "(", "self", ".", "LOG_STRUCTURE", ")", "try", ":", "assert", "(", "keys_in_log", "==", "keys_in_log_structure", ...
>>> lc = LogCollector('file=/path/to/file.log:formatter=logagg.formatters.basescript', 30) >>> incomplete_log = {'data' : {'x' : 1, 'y' : 2}, ... 'raw' : 'Not all keys present'} >>> lc.validate_log_format(incomplete_log) 'failed' >>> redundant_log = {'one_in...
[ ">>>", "lc", "=", "LogCollector", "(", "file", "=", "/", "path", "/", "to", "/", "file", ".", "log", ":", "formatter", "=", "logagg", ".", "formatters", ".", "basescript", "30", ")" ]
7863bc1b5ddf3e67c4d4b55746799304180589a0
https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/collector.py#L94-L159
train
deep-compute/logagg
logagg/collector.py
LogCollector.assign_default_log_values
def assign_default_log_values(self, fpath, line, formatter): ''' >>> lc = LogCollector('file=/path/to/log_file.log:formatter=logagg.formatters.basescript', 30) >>> from pprint import pprint >>> formatter = 'logagg.formatters.mongodb' >>> fpath = '/var/log/mongodb/mongodb.log' ...
python
def assign_default_log_values(self, fpath, line, formatter): ''' >>> lc = LogCollector('file=/path/to/log_file.log:formatter=logagg.formatters.basescript', 30) >>> from pprint import pprint >>> formatter = 'logagg.formatters.mongodb' >>> fpath = '/var/log/mongodb/mongodb.log' ...
[ "def", "assign_default_log_values", "(", "self", ",", "fpath", ",", "line", ",", "formatter", ")", ":", "return", "dict", "(", "id", "=", "None", ",", "file", "=", "fpath", ",", "host", "=", "self", ".", "HOST", ",", "formatter", "=", "formatter", ",",...
>>> lc = LogCollector('file=/path/to/log_file.log:formatter=logagg.formatters.basescript', 30) >>> from pprint import pprint >>> formatter = 'logagg.formatters.mongodb' >>> fpath = '/var/log/mongodb/mongodb.log' >>> line = 'some log line here' >>> default_log = lc.assign_defaul...
[ ">>>", "lc", "=", "LogCollector", "(", "file", "=", "/", "path", "/", "to", "/", "log_file", ".", "log", ":", "formatter", "=", "logagg", ".", "formatters", ".", "basescript", "30", ")", ">>>", "from", "pprint", "import", "pprint" ]
7863bc1b5ddf3e67c4d4b55746799304180589a0
https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/collector.py#L184-L221
train
deep-compute/logagg
logagg/collector.py
LogCollector._scan_fpatterns
def _scan_fpatterns(self, state): ''' For a list of given fpatterns, this starts a thread collecting log lines from file >>> os.path.isfile = lambda path: path == '/path/to/log_file.log' >>> lc = LogCollector('file=/path/to/log_file.log:formatter=logagg.formatters.basescript', 3...
python
def _scan_fpatterns(self, state): ''' For a list of given fpatterns, this starts a thread collecting log lines from file >>> os.path.isfile = lambda path: path == '/path/to/log_file.log' >>> lc = LogCollector('file=/path/to/log_file.log:formatter=logagg.formatters.basescript', 3...
[ "def", "_scan_fpatterns", "(", "self", ",", "state", ")", ":", "for", "f", "in", "self", ".", "fpaths", ":", "fpattern", ",", "formatter", "=", "(", "a", ".", "split", "(", "'='", ")", "[", "1", "]", "for", "a", "in", "f", ".", "split", "(", "'...
For a list of given fpatterns, this starts a thread collecting log lines from file >>> os.path.isfile = lambda path: path == '/path/to/log_file.log' >>> lc = LogCollector('file=/path/to/log_file.log:formatter=logagg.formatters.basescript', 30) >>> print(lc.fpaths) file=/path/to...
[ "For", "a", "list", "of", "given", "fpatterns", "this", "starts", "a", "thread", "collecting", "log", "lines", "from", "file" ]
7863bc1b5ddf3e67c4d4b55746799304180589a0
https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/collector.py#L356-L412
train
zetaops/zengine
zengine/forms/json_form.py
JsonForm.get_links
def get_links(self, **kw): """ Prepare links of form by mimicing pyoko's get_links method's result Args: **kw: Returns: list of link dicts """ links = [a for a in dir(self) if isinstance(getattr(self, a), Model) and not a.startswith('_mode...
python
def get_links(self, **kw): """ Prepare links of form by mimicing pyoko's get_links method's result Args: **kw: Returns: list of link dicts """ links = [a for a in dir(self) if isinstance(getattr(self, a), Model) and not a.startswith('_mode...
[ "def", "get_links", "(", "self", ",", "*", "*", "kw", ")", ":", "links", "=", "[", "a", "for", "a", "in", "dir", "(", "self", ")", "if", "isinstance", "(", "getattr", "(", "self", ",", "a", ")", ",", "Model", ")", "and", "not", "a", ".", "sta...
Prepare links of form by mimicing pyoko's get_links method's result Args: **kw: Returns: list of link dicts
[ "Prepare", "links", "of", "form", "by", "mimicing", "pyoko", "s", "get_links", "method", "s", "result" ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/forms/json_form.py#L94-L113
train
zetaops/zengine
zengine/forms/json_form.py
JsonForm.set_data
def set_data(self, data): """ Fills form with data Args: data (dict): Data to assign form fields. Returns: Self. Form object. """ for name in self._fields: setattr(self, name, data.get(name)) return self
python
def set_data(self, data): """ Fills form with data Args: data (dict): Data to assign form fields. Returns: Self. Form object. """ for name in self._fields: setattr(self, name, data.get(name)) return self
[ "def", "set_data", "(", "self", ",", "data", ")", ":", "for", "name", "in", "self", ".", "_fields", ":", "setattr", "(", "self", ",", "name", ",", "data", ".", "get", "(", "name", ")", ")", "return", "self" ]
Fills form with data Args: data (dict): Data to assign form fields. Returns: Self. Form object.
[ "Fills", "form", "with", "data" ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/forms/json_form.py#L158-L171
train
zetaops/zengine
zengine/forms/json_form.py
JsonForm.serialize
def serialize(self): """ Converts the form/model into JSON ready dicts/lists compatible with `Ulakbus-UI API`_. Example: .. code-block:: json { "forms": { "constraints": {}, "model": { ...
python
def serialize(self): """ Converts the form/model into JSON ready dicts/lists compatible with `Ulakbus-UI API`_. Example: .. code-block:: json { "forms": { "constraints": {}, "model": { ...
[ "def", "serialize", "(", "self", ")", ":", "result", "=", "{", "\"schema\"", ":", "{", "\"title\"", ":", "self", ".", "title", ",", "\"type\"", ":", "\"object\"", ",", "\"properties\"", ":", "{", "}", ",", "\"required\"", ":", "[", "]", "}", ",", "\"...
Converts the form/model into JSON ready dicts/lists compatible with `Ulakbus-UI API`_. Example: .. code-block:: json { "forms": { "constraints": {}, "model": { "code": null, ...
[ "Converts", "the", "form", "/", "model", "into", "JSON", "ready", "dicts", "/", "lists", "compatible", "with", "Ulakbus", "-", "UI", "API", "_", "." ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/forms/json_form.py#L173-L336
train
zetaops/zengine
zengine/forms/json_form.py
JsonForm._cache_form_details
def _cache_form_details(self, form): """ Caches some form details to lates process and validate incoming (response) form data Args: form: form dict """ cache = FormCache() form['model']['form_key'] = cache.form_id form['model']['form_name'] = self.__c...
python
def _cache_form_details(self, form): """ Caches some form details to lates process and validate incoming (response) form data Args: form: form dict """ cache = FormCache() form['model']['form_key'] = cache.form_id form['model']['form_name'] = self.__c...
[ "def", "_cache_form_details", "(", "self", ",", "form", ")", ":", "cache", "=", "FormCache", "(", ")", "form", "[", "'model'", "]", "[", "'form_key'", "]", "=", "cache", ".", "form_id", "form", "[", "'model'", "]", "[", "'form_name'", "]", "=", "self",...
Caches some form details to lates process and validate incoming (response) form data Args: form: form dict
[ "Caches", "some", "form", "details", "to", "lates", "process", "and", "validate", "incoming", "(", "response", ")", "form", "data" ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/forms/json_form.py#L350-L365
train
deep-compute/logagg
logagg/forwarders.py
MongoDBForwarder._parse_msg_for_mongodb
def _parse_msg_for_mongodb(self, msgs): ''' >>> mdbf = MongoDBForwarder('no_host', '27017', 'deadpool', ... 'chimichanga', 'logs', 'collection') >>> log = [{u'data': {u'_': {u'file': u'log.py', ... u'fn': u'start', ... ...
python
def _parse_msg_for_mongodb(self, msgs): ''' >>> mdbf = MongoDBForwarder('no_host', '27017', 'deadpool', ... 'chimichanga', 'logs', 'collection') >>> log = [{u'data': {u'_': {u'file': u'log.py', ... u'fn': u'start', ... ...
[ "def", "_parse_msg_for_mongodb", "(", "self", ",", "msgs", ")", ":", "msgs_list", "=", "[", "]", "for", "msg", "in", "msgs", ":", "try", ":", "msg", "[", "'_id'", "]", "=", "msg", ".", "pop", "(", "'id'", ")", "except", "KeyError", ":", "self", "."...
>>> mdbf = MongoDBForwarder('no_host', '27017', 'deadpool', ... 'chimichanga', 'logs', 'collection') >>> log = [{u'data': {u'_': {u'file': u'log.py', ... u'fn': u'start', ... u'ln': 8, ... u'name...
[ ">>>", "mdbf", "=", "MongoDBForwarder", "(", "no_host", "27017", "deadpool", "...", "chimichanga", "logs", "collection", ")", ">>>", "log", "=", "[", "{", "u", "data", ":", "{", "u", "_", ":", "{", "u", "file", ":", "u", "log", ".", "py", "...", "u...
7863bc1b5ddf3e67c4d4b55746799304180589a0
https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/forwarders.py#L64-L116
train
deep-compute/logagg
logagg/forwarders.py
InfluxDBForwarder._tag_and_field_maker
def _tag_and_field_maker(self, event): ''' >>> idbf = InfluxDBForwarder('no_host', '8086', 'deadpool', ... 'chimichanga', 'logs', 'collection') >>> log = {u'data': {u'_': {u'file': u'log.py', ... u'fn': u'start', ... ...
python
def _tag_and_field_maker(self, event): ''' >>> idbf = InfluxDBForwarder('no_host', '8086', 'deadpool', ... 'chimichanga', 'logs', 'collection') >>> log = {u'data': {u'_': {u'file': u'log.py', ... u'fn': u'start', ... ...
[ "def", "_tag_and_field_maker", "(", "self", ",", "event", ")", ":", "data", "=", "event", ".", "pop", "(", "'data'", ")", "data", "=", "flatten_dict", "(", "{", "'data'", ":", "data", "}", ")", "t", "=", "dict", "(", "(", "k", ",", "event", "[", ...
>>> idbf = InfluxDBForwarder('no_host', '8086', 'deadpool', ... 'chimichanga', 'logs', 'collection') >>> log = {u'data': {u'_': {u'file': u'log.py', ... u'fn': u'start', ... u'ln': 8, ... ...
[ ">>>", "idbf", "=", "InfluxDBForwarder", "(", "no_host", "8086", "deadpool", "...", "chimichanga", "logs", "collection", ")", ">>>", "log", "=", "{", "u", "data", ":", "{", "u", "_", ":", "{", "u", "file", ":", "u", "log", ".", "py", "...", "u", "f...
7863bc1b5ddf3e67c4d4b55746799304180589a0
https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/forwarders.py#L167-L221
train
deep-compute/logagg
logagg/forwarders.py
InfluxDBForwarder._parse_msg_for_influxdb
def _parse_msg_for_influxdb(self, msgs): ''' >>> from logagg.forwarders import InfluxDBForwarder >>> idbf = InfluxDBForwarder('no_host', '8086', 'deadpool', ... 'chimichanga', 'logs', 'collection') >>> valid_log = [{u'data': {u'_force_this_as_field': ...
python
def _parse_msg_for_influxdb(self, msgs): ''' >>> from logagg.forwarders import InfluxDBForwarder >>> idbf = InfluxDBForwarder('no_host', '8086', 'deadpool', ... 'chimichanga', 'logs', 'collection') >>> valid_log = [{u'data': {u'_force_this_as_field': ...
[ "def", "_parse_msg_for_influxdb", "(", "self", ",", "msgs", ")", ":", "series", "=", "[", "]", "for", "msg", "in", "msgs", ":", "if", "msg", ".", "get", "(", "'error'", ")", ":", "continue", "if", "msg", ".", "get", "(", "'type'", ")", ".", "lower"...
>>> from logagg.forwarders import InfluxDBForwarder >>> idbf = InfluxDBForwarder('no_host', '8086', 'deadpool', ... 'chimichanga', 'logs', 'collection') >>> valid_log = [{u'data': {u'_force_this_as_field': 'CXNS CNS nbkbsd', ... u'a': 1, ....
[ ">>>", "from", "logagg", ".", "forwarders", "import", "InfluxDBForwarder", ">>>", "idbf", "=", "InfluxDBForwarder", "(", "no_host", "8086", "deadpool", "...", "chimichanga", "logs", "collection", ")" ]
7863bc1b5ddf3e67c4d4b55746799304180589a0
https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/forwarders.py#L223-L290
train
wdecoster/nanoget
nanoget/nanoget.py
get_input
def get_input(source, files, threads=4, readtype="1D", combine="simple", names=None, barcoded=False): """Get input and process accordingly. Data can be: - a uncompressed, bgzip, bzip2 or gzip compressed fastq file - a uncompressed, bgzip, bzip2 or gzip compressed fasta file - a rich f...
python
def get_input(source, files, threads=4, readtype="1D", combine="simple", names=None, barcoded=False): """Get input and process accordingly. Data can be: - a uncompressed, bgzip, bzip2 or gzip compressed fastq file - a uncompressed, bgzip, bzip2 or gzip compressed fasta file - a rich f...
[ "def", "get_input", "(", "source", ",", "files", ",", "threads", "=", "4", ",", "readtype", "=", "\"1D\"", ",", "combine", "=", "\"simple\"", ",", "names", "=", "None", ",", "barcoded", "=", "False", ")", ":", "proc_functions", "=", "{", "'fastq'", ":"...
Get input and process accordingly. Data can be: - a uncompressed, bgzip, bzip2 or gzip compressed fastq file - a uncompressed, bgzip, bzip2 or gzip compressed fasta file - a rich fastq containing additional key=value information in the description, as produced by MinKNOW and albacore with the sam...
[ "Get", "input", "and", "process", "accordingly", "." ]
fb7306220e261849b96785fab02dd2f35a0e3b60
https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/nanoget.py#L29-L82
train
wdecoster/nanoget
nanoget/nanoget.py
combine_dfs
def combine_dfs(dfs, names, method): """Combine dataframes. Combination is either done simple by just concatenating the DataFrames or performs tracking by adding the name of the dataset as a column.""" if method == "track": res = list() for df, identifier in zip(dfs, names): ...
python
def combine_dfs(dfs, names, method): """Combine dataframes. Combination is either done simple by just concatenating the DataFrames or performs tracking by adding the name of the dataset as a column.""" if method == "track": res = list() for df, identifier in zip(dfs, names): ...
[ "def", "combine_dfs", "(", "dfs", ",", "names", ",", "method", ")", ":", "if", "method", "==", "\"track\"", ":", "res", "=", "list", "(", ")", "for", "df", ",", "identifier", "in", "zip", "(", "dfs", ",", "names", ")", ":", "df", "[", "\"dataset\""...
Combine dataframes. Combination is either done simple by just concatenating the DataFrames or performs tracking by adding the name of the dataset as a column.
[ "Combine", "dataframes", "." ]
fb7306220e261849b96785fab02dd2f35a0e3b60
https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/nanoget.py#L85-L97
train
wdecoster/nanoget
nanoget/nanoget.py
calculate_start_time
def calculate_start_time(df): """Calculate the star_time per read. Time data is either a "time" (in seconds, derived from summary files) or a "timestamp" (in UTC, derived from fastq_rich format) and has to be converted appropriately in a datetime format time_arr For both the time_zero is the m...
python
def calculate_start_time(df): """Calculate the star_time per read. Time data is either a "time" (in seconds, derived from summary files) or a "timestamp" (in UTC, derived from fastq_rich format) and has to be converted appropriately in a datetime format time_arr For both the time_zero is the m...
[ "def", "calculate_start_time", "(", "df", ")", ":", "if", "\"time\"", "in", "df", ":", "df", "[", "\"time_arr\"", "]", "=", "pd", ".", "Series", "(", "df", "[", "\"time\"", "]", ",", "dtype", "=", "'datetime64[s]'", ")", "elif", "\"timestamp\"", "in", ...
Calculate the star_time per read. Time data is either a "time" (in seconds, derived from summary files) or a "timestamp" (in UTC, derived from fastq_rich format) and has to be converted appropriately in a datetime format time_arr For both the time_zero is the minimal value of the time_arr, whi...
[ "Calculate", "the", "star_time", "per", "read", "." ]
fb7306220e261849b96785fab02dd2f35a0e3b60
https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/nanoget.py#L100-L127
train
camptocamp/marabunta
marabunta/parser.py
YamlParser.parser_from_buffer
def parser_from_buffer(cls, fp): """Construct YamlParser from a file pointer.""" yaml = YAML(typ="safe") return cls(yaml.load(fp))
python
def parser_from_buffer(cls, fp): """Construct YamlParser from a file pointer.""" yaml = YAML(typ="safe") return cls(yaml.load(fp))
[ "def", "parser_from_buffer", "(", "cls", ",", "fp", ")", ":", "yaml", "=", "YAML", "(", "typ", "=", "\"safe\"", ")", "return", "cls", "(", "yaml", ".", "load", "(", "fp", ")", ")" ]
Construct YamlParser from a file pointer.
[ "Construct", "YamlParser", "from", "a", "file", "pointer", "." ]
ec3a7a725c7426d6ed642e0a80119b37880eb91e
https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/parser.py#L87-L90
train
camptocamp/marabunta
marabunta/parser.py
YamlParser.check_dict_expected_keys
def check_dict_expected_keys(self, expected_keys, current, dict_name): """ Check that we don't have unknown keys in a dictionary. It does not raise an error if we have less keys than expected. """ if not isinstance(current, dict): raise ParseError(u"'{}' key must be a dict"....
python
def check_dict_expected_keys(self, expected_keys, current, dict_name): """ Check that we don't have unknown keys in a dictionary. It does not raise an error if we have less keys than expected. """ if not isinstance(current, dict): raise ParseError(u"'{}' key must be a dict"....
[ "def", "check_dict_expected_keys", "(", "self", ",", "expected_keys", ",", "current", ",", "dict_name", ")", ":", "if", "not", "isinstance", "(", "current", ",", "dict", ")", ":", "raise", "ParseError", "(", "u\"'{}' key must be a dict\"", ".", "format", "(", ...
Check that we don't have unknown keys in a dictionary. It does not raise an error if we have less keys than expected.
[ "Check", "that", "we", "don", "t", "have", "unknown", "keys", "in", "a", "dictionary", "." ]
ec3a7a725c7426d6ed642e0a80119b37880eb91e
https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/parser.py#L98-L118
train
camptocamp/marabunta
marabunta/parser.py
YamlParser.parse
def parse(self): """Check input and return a :class:`Migration` instance.""" if not self.parsed.get('migration'): raise ParseError(u"'migration' key is missing", YAML_EXAMPLE) self.check_dict_expected_keys( {'options', 'versions'}, self.parsed['migration'], 'migration', ...
python
def parse(self): """Check input and return a :class:`Migration` instance.""" if not self.parsed.get('migration'): raise ParseError(u"'migration' key is missing", YAML_EXAMPLE) self.check_dict_expected_keys( {'options', 'versions'}, self.parsed['migration'], 'migration', ...
[ "def", "parse", "(", "self", ")", ":", "if", "not", "self", ".", "parsed", ".", "get", "(", "'migration'", ")", ":", "raise", "ParseError", "(", "u\"'migration' key is missing\"", ",", "YAML_EXAMPLE", ")", "self", ".", "check_dict_expected_keys", "(", "{", "...
Check input and return a :class:`Migration` instance.
[ "Check", "input", "and", "return", "a", ":", "class", ":", "Migration", "instance", "." ]
ec3a7a725c7426d6ed642e0a80119b37880eb91e
https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/parser.py#L120-L127
train
camptocamp/marabunta
marabunta/parser.py
YamlParser._parse_migrations
def _parse_migrations(self): """Build a :class:`Migration` instance.""" migration = self.parsed['migration'] options = self._parse_options(migration) versions = self._parse_versions(migration, options) return Migration(versions, options)
python
def _parse_migrations(self): """Build a :class:`Migration` instance.""" migration = self.parsed['migration'] options = self._parse_options(migration) versions = self._parse_versions(migration, options) return Migration(versions, options)
[ "def", "_parse_migrations", "(", "self", ")", ":", "migration", "=", "self", ".", "parsed", "[", "'migration'", "]", "options", "=", "self", ".", "_parse_options", "(", "migration", ")", "versions", "=", "self", ".", "_parse_versions", "(", "migration", ",",...
Build a :class:`Migration` instance.
[ "Build", "a", ":", "class", ":", "Migration", "instance", "." ]
ec3a7a725c7426d6ed642e0a80119b37880eb91e
https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/parser.py#L129-L134
train
camptocamp/marabunta
marabunta/parser.py
YamlParser._parse_options
def _parse_options(self, migration): """Build :class:`MigrationOption` and :class:`MigrationBackupOption` instances.""" options = migration.get('options', {}) install_command = options.get('install_command') backup = options.get('backup') if backup: self.check...
python
def _parse_options(self, migration): """Build :class:`MigrationOption` and :class:`MigrationBackupOption` instances.""" options = migration.get('options', {}) install_command = options.get('install_command') backup = options.get('backup') if backup: self.check...
[ "def", "_parse_options", "(", "self", ",", "migration", ")", ":", "options", "=", "migration", ".", "get", "(", "'options'", ",", "{", "}", ")", "install_command", "=", "options", ".", "get", "(", "'install_command'", ")", "backup", "=", "options", ".", ...
Build :class:`MigrationOption` and :class:`MigrationBackupOption` instances.
[ "Build", ":", "class", ":", "MigrationOption", "and", ":", "class", ":", "MigrationBackupOption", "instances", "." ]
ec3a7a725c7426d6ed642e0a80119b37880eb91e
https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/parser.py#L136-L155
train
zetaops/zengine
zengine/current.py
Current.set_message
def set_message(self, title, msg, typ, url=None): """ Sets user notification message. Args: title: Msg. title msg: Msg. text typ: Msg. type url: Additional URL (if exists) Returns: Message ID. """ return self....
python
def set_message(self, title, msg, typ, url=None): """ Sets user notification message. Args: title: Msg. title msg: Msg. text typ: Msg. type url: Additional URL (if exists) Returns: Message ID. """ return self....
[ "def", "set_message", "(", "self", ",", "title", ",", "msg", ",", "typ", ",", "url", "=", "None", ")", ":", "return", "self", ".", "user", ".", "send_notification", "(", "title", "=", "title", ",", "message", "=", "msg", ",", "typ", "=", "typ", ","...
Sets user notification message. Args: title: Msg. title msg: Msg. text typ: Msg. type url: Additional URL (if exists) Returns: Message ID.
[ "Sets", "user", "notification", "message", "." ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/current.py#L116-L132
train
zetaops/zengine
zengine/current.py
Current.is_auth
def is_auth(self): """ A property that indicates if current user is logged in or not. Returns: Boolean. """ if self.user_id is None: self.user_id = self.session.get('user_id') return bool(self.user_id)
python
def is_auth(self): """ A property that indicates if current user is logged in or not. Returns: Boolean. """ if self.user_id is None: self.user_id = self.session.get('user_id') return bool(self.user_id)
[ "def", "is_auth", "(", "self", ")", ":", "if", "self", ".", "user_id", "is", "None", ":", "self", ".", "user_id", "=", "self", ".", "session", ".", "get", "(", "'user_id'", ")", "return", "bool", "(", "self", ".", "user_id", ")" ]
A property that indicates if current user is logged in or not. Returns: Boolean.
[ "A", "property", "that", "indicates", "if", "current", "user", "is", "logged", "in", "or", "not", "." ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/current.py#L135-L144
train
zetaops/zengine
zengine/current.py
Current.has_permission
def has_permission(self, perm): """ Checks if current user (or role) has the given permission. Args: perm: Permmission code or object. Depends on the :attr:`~zengine.auth.auth_backend.AuthBackend` implementation. Returns: Boolean. """ ...
python
def has_permission(self, perm): """ Checks if current user (or role) has the given permission. Args: perm: Permmission code or object. Depends on the :attr:`~zengine.auth.auth_backend.AuthBackend` implementation. Returns: Boolean. """ ...
[ "def", "has_permission", "(", "self", ",", "perm", ")", ":", "return", "self", ".", "user", ".", "superuser", "or", "self", ".", "auth", ".", "has_permission", "(", "perm", ")" ]
Checks if current user (or role) has the given permission. Args: perm: Permmission code or object. Depends on the :attr:`~zengine.auth.auth_backend.AuthBackend` implementation. Returns: Boolean.
[ "Checks", "if", "current", "user", "(", "or", "role", ")", "has", "the", "given", "permission", "." ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/current.py#L146-L157
train
zetaops/zengine
zengine/current.py
Current.msg_box
def msg_box(self, msg, title=None, typ='info'): """ Create a message box :param str msg: :param str title: :param str typ: 'info', 'error', 'warning' """ self.output['msgbox'] = {'type': typ, "title": title or msg[:20], "msg": msg}
python
def msg_box(self, msg, title=None, typ='info'): """ Create a message box :param str msg: :param str title: :param str typ: 'info', 'error', 'warning' """ self.output['msgbox'] = {'type': typ, "title": title or msg[:20], "msg": msg}
[ "def", "msg_box", "(", "self", ",", "msg", ",", "title", "=", "None", ",", "typ", "=", "'info'", ")", ":", "self", ".", "output", "[", "'msgbox'", "]", "=", "{", "'type'", ":", "typ", ",", "\"title\"", ":", "title", "or", "msg", "[", ":", "20", ...
Create a message box :param str msg: :param str title: :param str typ: 'info', 'error', 'warning'
[ "Create", "a", "message", "box" ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/current.py#L169-L177
train
zetaops/zengine
zengine/current.py
WFCurrent.sendoff_current_user
def sendoff_current_user(self): """ Tell current user that s/he finished it's job for now. We'll notify if workflow arrives again to his/her WF Lane. """ msgs = self.task_data.get('LANE_CHANGE_MSG', DEFAULT_LANE_CHANGE_MSG) self.msg_box(title=msgs['title'], msg=msgs['body...
python
def sendoff_current_user(self): """ Tell current user that s/he finished it's job for now. We'll notify if workflow arrives again to his/her WF Lane. """ msgs = self.task_data.get('LANE_CHANGE_MSG', DEFAULT_LANE_CHANGE_MSG) self.msg_box(title=msgs['title'], msg=msgs['body...
[ "def", "sendoff_current_user", "(", "self", ")", ":", "msgs", "=", "self", ".", "task_data", ".", "get", "(", "'LANE_CHANGE_MSG'", ",", "DEFAULT_LANE_CHANGE_MSG", ")", "self", ".", "msg_box", "(", "title", "=", "msgs", "[", "'title'", "]", ",", "msg", "=",...
Tell current user that s/he finished it's job for now. We'll notify if workflow arrives again to his/her WF Lane.
[ "Tell", "current", "user", "that", "s", "/", "he", "finished", "it", "s", "job", "for", "now", ".", "We", "ll", "notify", "if", "workflow", "arrives", "again", "to", "his", "/", "her", "WF", "Lane", "." ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/current.py#L224-L230
train
zetaops/zengine
zengine/current.py
WFCurrent.invite_other_parties
def invite_other_parties(self, possible_owners): """ Invites the next lane's (possible) owner(s) to participate """ signals.lane_user_change.send(sender=self.user, current=self, old_lane=self.old_lane, ...
python
def invite_other_parties(self, possible_owners): """ Invites the next lane's (possible) owner(s) to participate """ signals.lane_user_change.send(sender=self.user, current=self, old_lane=self.old_lane, ...
[ "def", "invite_other_parties", "(", "self", ",", "possible_owners", ")", ":", "signals", ".", "lane_user_change", ".", "send", "(", "sender", "=", "self", ".", "user", ",", "current", "=", "self", ",", "old_lane", "=", "self", ".", "old_lane", ",", "possib...
Invites the next lane's (possible) owner(s) to participate
[ "Invites", "the", "next", "lane", "s", "(", "possible", ")", "owner", "(", "s", ")", "to", "participate" ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/current.py#L232-L240
train
zetaops/zengine
zengine/current.py
WFCurrent._update_task
def _update_task(self, task): """ Assigns current task step to self.task then updates the task's data with self.task_data Args: task: Task object. """ self.task = task self.task.data.update(self.task_data) self.task_type = task.task_spec.__cla...
python
def _update_task(self, task): """ Assigns current task step to self.task then updates the task's data with self.task_data Args: task: Task object. """ self.task = task self.task.data.update(self.task_data) self.task_type = task.task_spec.__cla...
[ "def", "_update_task", "(", "self", ",", "task", ")", ":", "self", ".", "task", "=", "task", "self", ".", "task", ".", "data", ".", "update", "(", "self", ".", "task_data", ")", "self", ".", "task_type", "=", "task", ".", "task_spec", ".", "__class__...
Assigns current task step to self.task then updates the task's data with self.task_data Args: task: Task object.
[ "Assigns", "current", "task", "step", "to", "self", ".", "task", "then", "updates", "the", "task", "s", "data", "with", "self", ".", "task_data" ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/current.py#L258-L272
train
zetaops/zengine
zengine/current.py
WFCurrent.set_client_cmds
def set_client_cmds(self): """ This is method automatically called on each request and updates "object_id", "cmd" and "flow" client variables from current.input. "flow" and "object_id" variables will always exists in the task_data so app developers can safely check for ...
python
def set_client_cmds(self): """ This is method automatically called on each request and updates "object_id", "cmd" and "flow" client variables from current.input. "flow" and "object_id" variables will always exists in the task_data so app developers can safely check for ...
[ "def", "set_client_cmds", "(", "self", ")", ":", "self", ".", "task_data", "[", "'cmd'", "]", "=", "self", ".", "input", ".", "get", "(", "'cmd'", ")", "self", ".", "task_data", "[", "'flow'", "]", "=", "self", ".", "input", ".", "get", "(", "'flow...
This is method automatically called on each request and updates "object_id", "cmd" and "flow" client variables from current.input. "flow" and "object_id" variables will always exists in the task_data so app developers can safely check for their values in workflows. Thei...
[ "This", "is", "method", "automatically", "called", "on", "each", "request", "and", "updates", "object_id", "cmd", "and", "flow", "client", "variables", "from", "current", ".", "input", "." ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/current.py#L274-L304
train
LordDarkula/chess_py
chess_py/players/human.py
Human.generate_move
def generate_move(self, position): """ Returns valid and legal move given position :type: position: Board :rtype: Move """ while True: print(position) raw = input(str(self.color) + "\'s move \n") move = converter.short_alg(raw, self.co...
python
def generate_move(self, position): """ Returns valid and legal move given position :type: position: Board :rtype: Move """ while True: print(position) raw = input(str(self.color) + "\'s move \n") move = converter.short_alg(raw, self.co...
[ "def", "generate_move", "(", "self", ",", "position", ")", ":", "while", "True", ":", "print", "(", "position", ")", "raw", "=", "input", "(", "str", "(", "self", ".", "color", ")", "+", "\"\\'s move \\n\"", ")", "move", "=", "converter", ".", "short_a...
Returns valid and legal move given position :type: position: Board :rtype: Move
[ "Returns", "valid", "and", "legal", "move", "given", "position" ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/players/human.py#L28-L43
train
LordDarkula/chess_py
chess_py/pieces/king.py
King.in_check_as_result
def in_check_as_result(self, pos, move): """ Finds if playing my move would make both kings meet. :type: pos: Board :type: move: Move :rtype: bool """ test = cp(pos) test.update(move) test_king = test.get_king(move.color) return self.loc_...
python
def in_check_as_result(self, pos, move): """ Finds if playing my move would make both kings meet. :type: pos: Board :type: move: Move :rtype: bool """ test = cp(pos) test.update(move) test_king = test.get_king(move.color) return self.loc_...
[ "def", "in_check_as_result", "(", "self", ",", "pos", ",", "move", ")", ":", "test", "=", "cp", "(", "pos", ")", "test", ".", "update", "(", "move", ")", "test_king", "=", "test", ".", "get_king", "(", "move", ".", "color", ")", "return", "self", "...
Finds if playing my move would make both kings meet. :type: pos: Board :type: move: Move :rtype: bool
[ "Finds", "if", "playing", "my", "move", "would", "make", "both", "kings", "meet", "." ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/king.py#L51-L63
train
LordDarkula/chess_py
chess_py/pieces/king.py
King.loc_adjacent_to_opponent_king
def loc_adjacent_to_opponent_king(self, location, position): """ Finds if 2 kings are touching given the position of one of the kings. :type: location: Location :type: position: Board :rtype: bool """ for fn in self.cardinal_directions: try: ...
python
def loc_adjacent_to_opponent_king(self, location, position): """ Finds if 2 kings are touching given the position of one of the kings. :type: location: Location :type: position: Board :rtype: bool """ for fn in self.cardinal_directions: try: ...
[ "def", "loc_adjacent_to_opponent_king", "(", "self", ",", "location", ",", "position", ")", ":", "for", "fn", "in", "self", ".", "cardinal_directions", ":", "try", ":", "if", "isinstance", "(", "position", ".", "piece_at_square", "(", "fn", "(", "location", ...
Finds if 2 kings are touching given the position of one of the kings. :type: location: Location :type: position: Board :rtype: bool
[ "Finds", "if", "2", "kings", "are", "touching", "given", "the", "position", "of", "one", "of", "the", "kings", "." ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/king.py#L65-L82
train
LordDarkula/chess_py
chess_py/pieces/king.py
King.add
def add(self, func, position): """ Adds all 8 cardinal directions as moves for the King if legal. :type: function: function :type: position: Board :rtype: gen """ try: if self.loc_adjacent_to_opponent_king(func(self.location), position): ...
python
def add(self, func, position): """ Adds all 8 cardinal directions as moves for the King if legal. :type: function: function :type: position: Board :rtype: gen """ try: if self.loc_adjacent_to_opponent_king(func(self.location), position): ...
[ "def", "add", "(", "self", ",", "func", ",", "position", ")", ":", "try", ":", "if", "self", ".", "loc_adjacent_to_opponent_king", "(", "func", "(", "self", ".", "location", ")", ",", "position", ")", ":", "return", "except", "IndexError", ":", "return",...
Adds all 8 cardinal directions as moves for the King if legal. :type: function: function :type: position: Board :rtype: gen
[ "Adds", "all", "8", "cardinal", "directions", "as", "moves", "for", "the", "King", "if", "legal", "." ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/king.py#L84-L102
train
LordDarkula/chess_py
chess_py/pieces/king.py
King._rook_legal_for_castle
def _rook_legal_for_castle(self, rook): """ Decides if given rook exists, is of this color, and has not moved so it is eligible to castle. :type: rook: Rook :rtype: bool """ return rook is not None and \ type(rook) is Rook and \ rook.color...
python
def _rook_legal_for_castle(self, rook): """ Decides if given rook exists, is of this color, and has not moved so it is eligible to castle. :type: rook: Rook :rtype: bool """ return rook is not None and \ type(rook) is Rook and \ rook.color...
[ "def", "_rook_legal_for_castle", "(", "self", ",", "rook", ")", ":", "return", "rook", "is", "not", "None", "and", "type", "(", "rook", ")", "is", "Rook", "and", "rook", ".", "color", "==", "self", ".", "color", "and", "not", "rook", ".", "has_moved" ]
Decides if given rook exists, is of this color, and has not moved so it is eligible to castle. :type: rook: Rook :rtype: bool
[ "Decides", "if", "given", "rook", "exists", "is", "of", "this", "color", "and", "has", "not", "moved", "so", "it", "is", "eligible", "to", "castle", "." ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/king.py#L104-L115
train
LordDarkula/chess_py
chess_py/pieces/king.py
King._empty_not_in_check
def _empty_not_in_check(self, position, direction): """ Checks if set of squares in between ``King`` and ``Rook`` are empty and safe for the king to castle. :type: position: Position :type: direction: function :type: times: int :rtype: bool """ de...
python
def _empty_not_in_check(self, position, direction): """ Checks if set of squares in between ``King`` and ``Rook`` are empty and safe for the king to castle. :type: position: Position :type: direction: function :type: times: int :rtype: bool """ de...
[ "def", "_empty_not_in_check", "(", "self", ",", "position", ",", "direction", ")", ":", "def", "valid_square", "(", "square", ")", ":", "return", "position", ".", "is_square_empty", "(", "square", ")", "and", "not", "self", ".", "in_check", "(", "position", ...
Checks if set of squares in between ``King`` and ``Rook`` are empty and safe for the king to castle. :type: position: Position :type: direction: function :type: times: int :rtype: bool
[ "Checks", "if", "set", "of", "squares", "in", "between", "King", "and", "Rook", "are", "empty", "and", "safe", "for", "the", "king", "to", "castle", "." ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/king.py#L117-L132
train
LordDarkula/chess_py
chess_py/pieces/king.py
King.add_castle
def add_castle(self, position): """ Adds kingside and queenside castling moves if legal :type: position: Board """ if self.has_moved or self.in_check(position): return if self.color == color.white: rook_rank = 0 else: rook_ran...
python
def add_castle(self, position): """ Adds kingside and queenside castling moves if legal :type: position: Board """ if self.has_moved or self.in_check(position): return if self.color == color.white: rook_rank = 0 else: rook_ran...
[ "def", "add_castle", "(", "self", ",", "position", ")", ":", "if", "self", ".", "has_moved", "or", "self", ".", "in_check", "(", "position", ")", ":", "return", "if", "self", ".", "color", "==", "color", ".", "white", ":", "rook_rank", "=", "0", "els...
Adds kingside and queenside castling moves if legal :type: position: Board
[ "Adds", "kingside", "and", "queenside", "castling", "moves", "if", "legal" ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/king.py#L134-L163
train
LordDarkula/chess_py
chess_py/pieces/king.py
King.possible_moves
def possible_moves(self, position): """ Generates list of possible moves :type: position: Board :rtype: list """ # Chain used to combine multiple generators for move in itertools.chain(*[self.add(fn, position) for fn in self.cardinal_directions]): yie...
python
def possible_moves(self, position): """ Generates list of possible moves :type: position: Board :rtype: list """ # Chain used to combine multiple generators for move in itertools.chain(*[self.add(fn, position) for fn in self.cardinal_directions]): yie...
[ "def", "possible_moves", "(", "self", ",", "position", ")", ":", "# Chain used to combine multiple generators", "for", "move", "in", "itertools", ".", "chain", "(", "*", "[", "self", ".", "add", "(", "fn", ",", "position", ")", "for", "fn", "in", "self", "...
Generates list of possible moves :type: position: Board :rtype: list
[ "Generates", "list", "of", "possible", "moves" ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/king.py#L165-L177
train
LordDarkula/chess_py
chess_py/pieces/king.py
King.in_check
def in_check(self, position, location=None): """ Finds if the king is in check or if both kings are touching. :type: position: Board :return: bool """ location = location or self.location for piece in position: if piece is not None and piece.color !=...
python
def in_check(self, position, location=None): """ Finds if the king is in check or if both kings are touching. :type: position: Board :return: bool """ location = location or self.location for piece in position: if piece is not None and piece.color !=...
[ "def", "in_check", "(", "self", ",", "position", ",", "location", "=", "None", ")", ":", "location", "=", "location", "or", "self", ".", "location", "for", "piece", "in", "position", ":", "if", "piece", "is", "not", "None", "and", "piece", ".", "color"...
Finds if the king is in check or if both kings are touching. :type: position: Board :return: bool
[ "Finds", "if", "the", "king", "is", "in", "check", "or", "if", "both", "kings", "are", "touching", "." ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/king.py#L179-L199
train
cocaine/cocaine-framework-python
cocaine/detail/baseservice.py
set_keep_alive
def set_keep_alive(sock, idle=10, interval=5, fails=5): """Sets the keep-alive setting for the peer socket. :param sock: Socket to be configured. :param idle: Interval in seconds after which for an idle connection a keep-alive probes is start being sent. :param interval: Interval in seconds betwe...
python
def set_keep_alive(sock, idle=10, interval=5, fails=5): """Sets the keep-alive setting for the peer socket. :param sock: Socket to be configured. :param idle: Interval in seconds after which for an idle connection a keep-alive probes is start being sent. :param interval: Interval in seconds betwe...
[ "def", "set_keep_alive", "(", "sock", ",", "idle", "=", "10", ",", "interval", "=", "5", ",", "fails", "=", "5", ")", ":", "import", "sys", "sock", ".", "setsockopt", "(", "socket", ".", "SOL_SOCKET", ",", "socket", ".", "SO_KEEPALIVE", ",", "1", ")"...
Sets the keep-alive setting for the peer socket. :param sock: Socket to be configured. :param idle: Interval in seconds after which for an idle connection a keep-alive probes is start being sent. :param interval: Interval in seconds between probes. :param fails: Maximum number of failed probes.
[ "Sets", "the", "keep", "-", "alive", "setting", "for", "the", "peer", "socket", "." ]
d8a30074b6338bac4389eb996e00d404338115e4
https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/baseservice.py#L55-L75
train