partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
ReactionContainer.implicify_hydrogens
remove explicit hydrogens if possible :return: number of removed hydrogens
CGRtools/containers/reaction.py
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): """ 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'): ...
[ "remove", "explicit", "hydrogens", "if", "possible" ]
cimm-kzn/CGRtools
python
https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/reaction.py#L145-L158
[ "def", "implicify_hydrogens", "(", "self", ")", ":", "total", "=", "0", "for", "ml", "in", "(", "self", ".", "__reagents", ",", "self", ".", "__reactants", ",", "self", ".", "__products", ")", ":", "for", "m", "in", "ml", ":", "if", "hasattr", "(", ...
15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34
train
ReactionContainer.reset_query_marks
set or reset hyb and neighbors marks to atoms.
CGRtools/containers/reaction.py
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): """ 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...
[ "set", "or", "reset", "hyb", "and", "neighbors", "marks", "to", "atoms", "." ]
cimm-kzn/CGRtools
python
https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/reaction.py#L207-L215
[ "def", "reset_query_marks", "(", "self", ")", ":", "for", "ml", "in", "(", "self", ".", "__reagents", ",", "self", ".", "__reactants", ",", "self", ".", "__products", ")", ":", "for", "m", "in", "ml", ":", "if", "hasattr", "(", "m", ",", "'reset_quer...
15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34
train
ReactionContainer.compose
get CGR of reaction reagents will be presented as unchanged molecules :return: CGRContainer
CGRtools/containers/reaction.py
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): """ 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): ...
[ "get", "CGR", "of", "reaction" ]
cimm-kzn/CGRtools
python
https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/reaction.py#L218-L238
[ "def", "compose", "(", "self", ")", ":", "rr", "=", "self", ".", "__reagents", "+", "self", ".", "__reactants", "if", "rr", ":", "if", "not", "all", "(", "isinstance", "(", "x", ",", "(", "MoleculeContainer", ",", "CGRContainer", ")", ")", "for", "x"...
15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34
train
ReactionContainer.calculate2d
recalculate 2d coordinates. currently rings can be calculated badly. :param force: ignore existing coordinates of atoms
CGRtools/containers/reaction.py
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): """ 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...
[ "recalculate", "2d", "coordinates", ".", "currently", "rings", "can", "be", "calculated", "badly", "." ]
cimm-kzn/CGRtools
python
https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/reaction.py#L246-L255
[ "def", "calculate2d", "(", "self", ",", "force", "=", "True", ")", ":", "for", "ml", "in", "(", "self", ".", "__reagents", ",", "self", ".", "__reactants", ",", "self", ".", "__products", ")", ":", "for", "m", "in", "ml", ":", "m", ".", "calculate2...
15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34
train
ReactionContainer.fix_positions
fix coordinates of molecules in reaction
CGRtools/containers/reaction.py
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): """ 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...
[ "fix", "coordinates", "of", "molecules", "in", "reaction" ]
cimm-kzn/CGRtools
python
https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/reaction.py#L257-L279
[ "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...
15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34
train
Unit.get_role_keys
:param unit_key: Parent unit key :return: role keys of subunits
zengine/models/auth.py
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): """ :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)...
[ ":", "param", "unit_key", ":", "Parent", "unit", "key", ":", "return", ":", "role", "keys", "of", "subunits" ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/auth.py#L44-L52
[ "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"...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
User.get_permissions
Permissions of the user. Returns: List of Permission objects.
zengine/models/auth.py
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): """ 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()
[ "Permissions", "of", "the", "user", "." ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/auth.py#L119-L127
[ "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",...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
AbstractRole.get_permissions
Soyut role ait Permission nesnelerini bulur ve code değerlerini döner. Returns: list: Permission code değerleri
zengine/models/auth.py
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): """ 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]
[ "Soyut", "role", "ait", "Permission", "nesnelerini", "bulur", "ve", "code", "değerlerini", "döner", "." ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/auth.py#L156-L165
[ "def", "get_permissions", "(", "self", ")", ":", "return", "[", "p", ".", "permission", ".", "code", "for", "p", "in", "self", ".", "Permissions", "if", "p", ".", "permission", ".", "code", "]" ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
AbstractRole.add_permission
Soyut Role Permission nesnesi tanımlamayı sağlar. Args: perm (object):
zengine/models/auth.py
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): """ Soyut Role Permission nesnesi tanımlamayı sağlar. Args: perm (object): """ self.Permissions(permission=perm) PermissionCache.flush() self.save()
[ "Soyut", "Role", "Permission", "nesnesi", "tanımlamayı", "sağlar", "." ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/auth.py#L167-L177
[ "def", "add_permission", "(", "self", ",", "perm", ")", ":", "self", ".", "Permissions", "(", "permission", "=", "perm", ")", "PermissionCache", ".", "flush", "(", ")", "self", ".", "save", "(", ")" ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
Role.add_permission_by_name
Adds a permission with given name. Args: code (str): Code name of the permission. save (bool): If False, does nothing.
zengine/models/auth.py
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): """ 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 ...
[ "Adds", "a", "permission", "with", "given", "name", "." ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/auth.py#L267-L282
[ "def", "add_permission_by_name", "(", "self", ",", "code", ",", "save", "=", "False", ")", ":", "if", "not", "save", ":", "return", "[", "\"%s | %s\"", "%", "(", "p", ".", "name", ",", "p", ".", "code", ")", "for", "p", "in", "Permission", ".", "ob...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
Role.send_notification
sends a message to user of this role's private mq exchange
zengine/models/auth.py
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): """ 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)
[ "sends", "a", "message", "to", "user", "of", "this", "role", "s", "private", "mq", "exchange" ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/models/auth.py#L284-L290
[ "def", "send_notification", "(", "self", ",", "title", ",", "message", ",", "typ", "=", "1", ",", "url", "=", "None", ",", "sender", "=", "None", ")", ":", "self", ".", "user", ".", "send_notification", "(", "title", "=", "title", ",", "message", "="...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
Move.would_move_be_promotion
Finds if move from current location would be a promotion
chess_py/core/algebraic/move.py
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): """ 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)
[ "Finds", "if", "move", "from", "current", "location", "would", "be", "a", "promotion" ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/move.py#L120-L125
[ "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",...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
Signal.connect
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...
zengine/dispatch/dispatcher.py
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): """ Connect receiver to sender for signal. Arguments: receiver A function or an instance method which is to receive signals. Receivers must be hashable objects. ...
[ "Connect", "receiver", "to", "sender", "for", "signal", "." ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/dispatch/dispatcher.py#L56-L114
[ "def", "connect", "(", "self", ",", "receiver", ",", "sender", "=", "None", ",", "weak", "=", "True", ",", "dispatch_uid", "=", "None", ")", ":", "if", "dispatch_uid", ":", "lookup_key", "=", "(", "dispatch_uid", ",", "_make_id", "(", "sender", ")", ")...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
Signal.disconnect
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...
zengine/dispatch/dispatcher.py
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): """ 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 ...
[ "Disconnect", "receiver", "from", "sender", "for", "signal", "." ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/dispatch/dispatcher.py#L116-L151
[ "def", "disconnect", "(", "self", ",", "receiver", "=", "None", ",", "sender", "=", "None", ",", "dispatch_uid", "=", "None", ")", ":", "if", "dispatch_uid", ":", "lookup_key", "=", "(", "dispatch_uid", ",", "_make_id", "(", "sender", ")", ")", "else", ...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
migrate
Perform a migration according to config. :param config: The configuration to be applied :type config: Config
marabunta/core.py
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): """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...
[ "Perform", "a", "migration", "according", "to", "config", "." ]
camptocamp/marabunta
python
https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/core.py#L103-L146
[ "def", "migrate", "(", "config", ")", ":", "webapp", "=", "WebApp", "(", "config", ".", "web_host", ",", "config", ".", "web_port", ",", "custom_maintenance_file", "=", "config", ".", "web_custom_html", ")", "webserver", "=", "WebServer", "(", "webapp", ")",...
ec3a7a725c7426d6ed642e0a80119b37880eb91e
train
main
Parse the command line and run :func:`migrate`.
marabunta/core.py
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(): """Parse the command line and run :func:`migrate`.""" parser = get_args_parser() args = parser.parse_args() config = Config.from_parse_args(args) migrate(config)
[ "Parse", "the", "command", "line", "and", "run", ":", "func", ":", "migrate", "." ]
camptocamp/marabunta
python
https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/core.py#L149-L154
[ "def", "main", "(", ")", ":", "parser", "=", "get_args_parser", "(", ")", "args", "=", "parser", ".", "parse_args", "(", ")", "config", "=", "Config", ".", "from_parse_args", "(", "args", ")", "migrate", "(", "config", ")" ]
ec3a7a725c7426d6ed642e0a80119b37880eb91e
train
CrudMeta.get_permissions
Generates permissions for all CrudView based class methods. Returns: List of Permission objects.
zengine/views/crud.py
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): """ 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...
[ "Generates", "permissions", "for", "all", "CrudView", "based", "class", "methods", "." ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/crud.py#L93-L105
[ "def", "get_permissions", "(", "cls", ")", ":", "perms", "=", "[", "]", "for", "kls_name", ",", "kls", "in", "cls", ".", "registry", ".", "items", "(", ")", ":", "for", "method_name", "in", "cls", ".", "__dict__", ".", "keys", "(", ")", ":", "if", ...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
_get_object_menu_models
we need to create basic permissions for only CRUD enabled models
zengine/auth/permissions.py
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(): """ 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...
[ "we", "need", "to", "create", "basic", "permissions", "for", "only", "CRUD", "enabled", "models" ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/auth/permissions.py#L95-L106
[ "def", "_get_object_menu_models", "(", ")", ":", "from", "pyoko", ".", "conf", "import", "settings", "enabled_models", "=", "[", "]", "for", "entry", "in", "settings", ".", "OBJECT_MENU", ".", "values", "(", ")", ":", "for", "mdl", "in", "entry", ":", "i...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
CustomPermission.add
create a custom permission
zengine/auth/permissions.py
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=''): """ 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
[ "create", "a", "custom", "permission" ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/auth/permissions.py#L27-L33
[ "def", "add", "(", "cls", ",", "code_name", ",", "name", "=", "''", ",", "description", "=", "''", ")", ":", "if", "code_name", "not", "in", "cls", ".", "registry", ":", "cls", ".", "registry", "[", "code_name", "]", "=", "(", "code_name", ",", "na...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
Isomorphism.get_mapping
get self to other mapping
CGRtools/algorithms/isomorphism.py
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): """ get self to other mapping """ m = next(self._matcher(other).isomorphisms_iter(), None) if m: return {v: k for k, v in m.items()}
[ "get", "self", "to", "other", "mapping" ]
cimm-kzn/CGRtools
python
https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/isomorphism.py#L56-L62
[ "def", "get_mapping", "(", "self", ",", "other", ")", ":", "m", "=", "next", "(", "self", ".", "_matcher", "(", "other", ")", ".", "isomorphisms_iter", "(", ")", ",", "None", ")", "if", "m", ":", "return", "{", "v", ":", "k", "for", "k", ",", "...
15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34
train
Isomorphism.get_substructure_mapping
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
CGRtools/algorithms/isomorphism.py
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): """ 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...
[ "get", "self", "to", "other", "substructure", "mapping" ]
cimm-kzn/CGRtools
python
https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/isomorphism.py#L64-L79
[ "def", "get_substructure_mapping", "(", "self", ",", "other", ",", "limit", "=", "1", ")", ":", "i", "=", "self", ".", "_matcher", "(", "other", ")", ".", "subgraph_isomorphisms_iter", "(", ")", "if", "limit", "==", "1", ":", "m", "=", "next", "(", "...
15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34
train
Location.from_string
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
chess_py/core/algebraic/location.py
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): """ 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...
[ "Creates", "a", "location", "from", "a", "two", "character", "string", "consisting", "of", "the", "file", "then", "rank", "written", "in", "algebraic", "notation", ".", "Examples", ":", "e4", "b5", "a7" ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/location.py#L63-L76
[ "def", "from_string", "(", "cls", ",", "alg_str", ")", ":", "try", ":", "return", "cls", "(", "int", "(", "alg_str", "[", "1", "]", ")", "-", "1", ",", "ord", "(", "alg_str", "[", "0", "]", ")", "-", "97", ")", "except", "ValueError", "as", "e"...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
Location.shift
Shifts in direction provided by ``Direction`` enum. :type: direction: Direction :rtype: Location
chess_py/core/algebraic/location.py
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): """ 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: ...
[ "Shifts", "in", "direction", "provided", "by", "Direction", "enum", "." ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/location.py#L144-L163
[ "def", "shift", "(", "self", ",", "direction", ")", ":", "try", ":", "if", "direction", "==", "Direction", ".", "UP", ":", "return", "self", ".", "shift_up", "(", ")", "elif", "direction", "==", "Direction", ".", "DOWN", ":", "return", "self", ".", "...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
Location.shift_up
Finds Location shifted up by 1 :rtype: Location
chess_py/core/algebraic/location.py
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): """ Finds Location shifted up by 1 :rtype: Location """ try: return Location(self._rank + times, self._file) except IndexError as e: raise IndexError(e)
[ "Finds", "Location", "shifted", "up", "by", "1" ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/location.py#L165-L174
[ "def", "shift_up", "(", "self", ",", "times", "=", "1", ")", ":", "try", ":", "return", "Location", "(", "self", ".", "_rank", "+", "times", ",", "self", ".", "_file", ")", "except", "IndexError", "as", "e", ":", "raise", "IndexError", "(", "e", ")...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
Location.shift_down
Finds Location shifted down by 1 :rtype: Location
chess_py/core/algebraic/location.py
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): """ Finds Location shifted down by 1 :rtype: Location """ try: return Location(self._rank - times, self._file) except IndexError as e: raise IndexError(e)
[ "Finds", "Location", "shifted", "down", "by", "1" ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/location.py#L176-L185
[ "def", "shift_down", "(", "self", ",", "times", "=", "1", ")", ":", "try", ":", "return", "Location", "(", "self", ".", "_rank", "-", "times", ",", "self", ".", "_file", ")", "except", "IndexError", "as", "e", ":", "raise", "IndexError", "(", "e", ...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
Location.shift_right
Finds Location shifted right by 1 :rtype: Location
chess_py/core/algebraic/location.py
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): """ Finds Location shifted right by 1 :rtype: Location """ try: return Location(self._rank, self._file + times) except IndexError as e: raise IndexError(e)
[ "Finds", "Location", "shifted", "right", "by", "1" ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/location.py#L201-L210
[ "def", "shift_right", "(", "self", ",", "times", "=", "1", ")", ":", "try", ":", "return", "Location", "(", "self", ".", "_rank", ",", "self", ".", "_file", "+", "times", ")", "except", "IndexError", "as", "e", ":", "raise", "IndexError", "(", "e", ...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
Location.shift_left
Finds Location shifted left by 1 :rtype: Location
chess_py/core/algebraic/location.py
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): """ Finds Location shifted left by 1 :rtype: Location """ try: return Location(self._rank, self._file - times) except IndexError as e: raise IndexError(e)
[ "Finds", "Location", "shifted", "left", "by", "1" ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/location.py#L212-L221
[ "def", "shift_left", "(", "self", ",", "times", "=", "1", ")", ":", "try", ":", "return", "Location", "(", "self", ".", "_rank", ",", "self", ".", "_file", "-", "times", ")", "except", "IndexError", "as", "e", ":", "raise", "IndexError", "(", "e", ...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
Location.shift_up_right
Finds Location shifted up right by 1 :rtype: Location
chess_py/core/algebraic/location.py
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): """ 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)
[ "Finds", "Location", "shifted", "up", "right", "by", "1" ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/location.py#L223-L232
[ "def", "shift_up_right", "(", "self", ",", "times", "=", "1", ")", ":", "try", ":", "return", "Location", "(", "self", ".", "_rank", "+", "times", ",", "self", ".", "_file", "+", "times", ")", "except", "IndexError", "as", "e", ":", "raise", "IndexEr...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
Location.shift_up_left
Finds Location shifted up left by 1 :rtype: Location
chess_py/core/algebraic/location.py
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): """ 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)
[ "Finds", "Location", "shifted", "up", "left", "by", "1" ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/location.py#L234-L243
[ "def", "shift_up_left", "(", "self", ",", "times", "=", "1", ")", ":", "try", ":", "return", "Location", "(", "self", ".", "_rank", "+", "times", ",", "self", ".", "_file", "-", "times", ")", "except", "IndexError", "as", "e", ":", "raise", "IndexErr...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
Location.shift_down_right
Finds Location shifted down right by 1 :rtype: Location
chess_py/core/algebraic/location.py
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): """ 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)
[ "Finds", "Location", "shifted", "down", "right", "by", "1" ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/location.py#L245-L254
[ "def", "shift_down_right", "(", "self", ",", "times", "=", "1", ")", ":", "try", ":", "return", "Location", "(", "self", ".", "_rank", "-", "times", ",", "self", ".", "_file", "+", "times", ")", "except", "IndexError", "as", "e", ":", "raise", "Index...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
Location.shift_down_left
Finds Location shifted down left by 1 :rtype: Location
chess_py/core/algebraic/location.py
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): """ 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)
[ "Finds", "Location", "shifted", "down", "left", "by", "1" ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/location.py#L256-L265
[ "def", "shift_down_left", "(", "self", ",", "times", "=", "1", ")", ":", "try", ":", "return", "Location", "(", "self", ".", "_rank", "-", "times", ",", "self", ".", "_file", "-", "times", ")", "except", "IndexError", "as", "e", ":", "raise", "IndexE...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
Standardize.standardize
standardize functional groups :return: number of found groups
CGRtools/algorithms/standardize.py
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): """ 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...
[ "standardize", "functional", "groups" ]
cimm-kzn/CGRtools
python
https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/standardize.py#L26-L60
[ "def", "standardize", "(", "self", ")", ":", "self", ".", "reset_query_marks", "(", ")", "seen", "=", "set", "(", ")", "total", "=", "0", "for", "n", ",", "atom", "in", "self", ".", "atoms", "(", ")", ":", "if", "n", "in", "seen", ":", "continue"...
15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34
train
get_staged_files
Get all files staged for the current commit.
git-hooks/pre-commit.py
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(): """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...
[ "Get", "all", "files", "staged", "for", "the", "current", "commit", "." ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/git-hooks/pre-commit.py#L23-L31
[ "def", "get_staged_files", "(", ")", ":", "proc", "=", "subprocess", ".", "Popen", "(", "(", "'git'", ",", "'status'", ",", "'--porcelain'", ")", ",", "stdout", "=", "subprocess", ".", "PIPE", ",", "stderr", "=", "subprocess", ".", "PIPE", ")", "out", ...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
runserver
Run Tornado server
zengine/tornado_server/server.py
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): """ 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...
[ "Run", "Tornado", "server" ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/tornado_server/server.py#L160-L173
[ "def", "runserver", "(", "host", "=", "None", ",", "port", "=", "None", ")", ":", "host", "=", "host", "or", "os", ".", "getenv", "(", "'HTTP_HOST'", ",", "'0.0.0.0'", ")", "port", "=", "port", "or", "os", ".", "getenv", "(", "'HTTP_PORT'", ",", "'...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
SocketHandler.open
Called on new websocket connection.
zengine/tornado_server/server.py
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): """ 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...
[ "Called", "on", "new", "websocket", "connection", "." ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/tornado_server/server.py#L48-L57
[ "def", "open", "(", "self", ")", ":", "sess_id", "=", "self", ".", "_get_sess_id", "(", ")", "if", "sess_id", ":", "self", ".", "application", ".", "pc", ".", "websockets", "[", "self", ".", "_get_sess_id", "(", ")", "]", "=", "self", "self", ".", ...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
SocketHandler.on_message
called on new websocket message,
zengine/tornado_server/server.py
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): """ 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)
[ "called", "on", "new", "websocket", "message" ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/tornado_server/server.py#L59-L64
[ "def", "on_message", "(", "self", ",", "message", ")", ":", "log", ".", "debug", "(", "\"WS MSG for %s: %s\"", "%", "(", "self", ".", "_get_sess_id", "(", ")", ",", "message", ")", ")", "self", ".", "application", ".", "pc", ".", "redirect_incoming_message...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
HttpHandler._handle_headers
Do response processing
zengine/tornado_server/server.py
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): """ 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: ...
[ "Do", "response", "processing" ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/tornado_server/server.py#L79-L96
[ "def", "_handle_headers", "(", "self", ")", ":", "origin", "=", "self", ".", "request", ".", "headers", ".", "get", "(", "'Origin'", ")", "if", "not", "settings", ".", "DEBUG", ":", "if", "origin", "in", "settings", ".", "ALLOWED_ORIGINS", "or", "not", ...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
HttpHandler.post
login handler
zengine/tornado_server/server.py
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): """ 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 #...
[ "login", "handler" ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/tornado_server/server.py#L110-L137
[ "def", "post", "(", "self", ",", "view_name", ")", ":", "sess_id", "=", "None", "input_data", "=", "{", "}", "# try:", "self", ".", "_handle_headers", "(", ")", "# handle input", "input_data", "=", "json_decode", "(", "self", ".", "request", ".", "body", ...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
load_formatter_fn
>>> load_formatter_fn('logagg.formatters.basescript') #doctest: +ELLIPSIS <function basescript at 0x...>
logagg/collector.py
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): ''' >>> 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
[ ">>>", "load_formatter_fn", "(", "logagg", ".", "formatters", ".", "basescript", ")", "#doctest", ":", "+", "ELLIPSIS", "<function", "basescript", "at", "0x", "...", ">" ]
deep-compute/logagg
python
https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/collector.py#L23-L31
[ "def", "load_formatter_fn", "(", "formatter", ")", ":", "obj", "=", "util", ".", "load_object", "(", "formatter", ")", "if", "not", "hasattr", "(", "obj", ",", "'ispartial'", ")", ":", "obj", ".", "ispartial", "=", "util", ".", "ispartial", "return", "ob...
7863bc1b5ddf3e67c4d4b55746799304180589a0
train
LogCollector._remove_redundancy
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...
logagg/collector.py
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): """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, ...
[ "Removes", "duplicate", "data", "from", "data", "inside", "log", "dict", "and", "brings", "it", "out", "." ]
deep-compute/logagg
python
https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/collector.py#L78-L92
[ "def", "_remove_redundancy", "(", "self", ",", "log", ")", ":", "for", "key", "in", "log", ":", "if", "key", "in", "log", "and", "key", "in", "log", "[", "'data'", "]", ":", "log", "[", "key", "]", "=", "log", "[", "'data'", "]", ".", "pop", "(...
7863bc1b5ddf3e67c4d4b55746799304180589a0
train
LogCollector.validate_log_format
>>> 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...
logagg/collector.py
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): ''' >>> 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...
[ ">>>", "lc", "=", "LogCollector", "(", "file", "=", "/", "path", "/", "to", "/", "file", ".", "log", ":", "formatter", "=", "logagg", ".", "formatters", ".", "basescript", "30", ")" ]
deep-compute/logagg
python
https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/collector.py#L94-L159
[ "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", ...
7863bc1b5ddf3e67c4d4b55746799304180589a0
train
LogCollector.assign_default_log_values
>>> 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...
logagg/collector.py
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): ''' >>> 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' ...
[ ">>>", "lc", "=", "LogCollector", "(", "file", "=", "/", "path", "/", "to", "/", "log_file", ".", "log", ":", "formatter", "=", "logagg", ".", "formatters", ".", "basescript", "30", ")", ">>>", "from", "pprint", "import", "pprint" ]
deep-compute/logagg
python
https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/collector.py#L184-L221
[ "def", "assign_default_log_values", "(", "self", ",", "fpath", ",", "line", ",", "formatter", ")", ":", "return", "dict", "(", "id", "=", "None", ",", "file", "=", "fpath", ",", "host", "=", "self", ".", "HOST", ",", "formatter", "=", "formatter", ",",...
7863bc1b5ddf3e67c4d4b55746799304180589a0
train
LogCollector._scan_fpatterns
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...
logagg/collector.py
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 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...
[ "For", "a", "list", "of", "given", "fpatterns", "this", "starts", "a", "thread", "collecting", "log", "lines", "from", "file" ]
deep-compute/logagg
python
https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/collector.py#L356-L412
[ "def", "_scan_fpatterns", "(", "self", ",", "state", ")", ":", "for", "f", "in", "self", ".", "fpaths", ":", "fpattern", ",", "formatter", "=", "(", "a", ".", "split", "(", "'='", ")", "[", "1", "]", "for", "a", "in", "f", ".", "split", "(", "'...
7863bc1b5ddf3e67c4d4b55746799304180589a0
train
JsonForm.get_links
Prepare links of form by mimicing pyoko's get_links method's result Args: **kw: Returns: list of link dicts
zengine/forms/json_form.py
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): """ 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...
[ "Prepare", "links", "of", "form", "by", "mimicing", "pyoko", "s", "get_links", "method", "s", "result" ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/forms/json_form.py#L94-L113
[ "def", "get_links", "(", "self", ",", "*", "*", "kw", ")", ":", "links", "=", "[", "a", "for", "a", "in", "dir", "(", "self", ")", "if", "isinstance", "(", "getattr", "(", "self", ",", "a", ")", ",", "Model", ")", "and", "not", "a", ".", "sta...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
JsonForm.set_data
Fills form with data Args: data (dict): Data to assign form fields. Returns: Self. Form object.
zengine/forms/json_form.py
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): """ 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
[ "Fills", "form", "with", "data" ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/forms/json_form.py#L158-L171
[ "def", "set_data", "(", "self", ",", "data", ")", ":", "for", "name", "in", "self", ".", "_fields", ":", "setattr", "(", "self", ",", "name", ",", "data", ".", "get", "(", "name", ")", ")", "return", "self" ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
JsonForm.serialize
Converts the form/model into JSON ready dicts/lists compatible with `Ulakbus-UI API`_. Example: .. code-block:: json { "forms": { "constraints": {}, "model": { "code": null, ...
zengine/forms/json_form.py
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): """ Converts the form/model into JSON ready dicts/lists compatible with `Ulakbus-UI API`_. Example: .. code-block:: json { "forms": { "constraints": {}, "model": { ...
[ "Converts", "the", "form", "/", "model", "into", "JSON", "ready", "dicts", "/", "lists", "compatible", "with", "Ulakbus", "-", "UI", "API", "_", "." ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/forms/json_form.py#L173-L336
[ "def", "serialize", "(", "self", ")", ":", "result", "=", "{", "\"schema\"", ":", "{", "\"title\"", ":", "self", ".", "title", ",", "\"type\"", ":", "\"object\"", ",", "\"properties\"", ":", "{", "}", ",", "\"required\"", ":", "[", "]", "}", ",", "\"...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
JsonForm._cache_form_details
Caches some form details to lates process and validate incoming (response) form data Args: form: form dict
zengine/forms/json_form.py
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): """ 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...
[ "Caches", "some", "form", "details", "to", "lates", "process", "and", "validate", "incoming", "(", "response", ")", "form", "data" ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/forms/json_form.py#L350-L365
[ "def", "_cache_form_details", "(", "self", ",", "form", ")", ":", "cache", "=", "FormCache", "(", ")", "form", "[", "'model'", "]", "[", "'form_key'", "]", "=", "cache", ".", "form_id", "form", "[", "'model'", "]", "[", "'form_name'", "]", "=", "self",...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
MongoDBForwarder._parse_msg_for_mongodb
>>> 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...
logagg/forwarders.py
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): ''' >>> mdbf = MongoDBForwarder('no_host', '27017', 'deadpool', ... 'chimichanga', 'logs', 'collection') >>> log = [{u'data': {u'_': {u'file': u'log.py', ... u'fn': u'start', ... ...
[ ">>>", "mdbf", "=", "MongoDBForwarder", "(", "no_host", "27017", "deadpool", "...", "chimichanga", "logs", "collection", ")", ">>>", "log", "=", "[", "{", "u", "data", ":", "{", "u", "_", ":", "{", "u", "file", ":", "u", "log", ".", "py", "...", "u...
deep-compute/logagg
python
https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/forwarders.py#L64-L116
[ "def", "_parse_msg_for_mongodb", "(", "self", ",", "msgs", ")", ":", "msgs_list", "=", "[", "]", "for", "msg", "in", "msgs", ":", "try", ":", "msg", "[", "'_id'", "]", "=", "msg", ".", "pop", "(", "'id'", ")", "except", "KeyError", ":", "self", "."...
7863bc1b5ddf3e67c4d4b55746799304180589a0
train
InfluxDBForwarder._tag_and_field_maker
>>> 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, ... ...
logagg/forwarders.py
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): ''' >>> idbf = InfluxDBForwarder('no_host', '8086', 'deadpool', ... 'chimichanga', 'logs', 'collection') >>> log = {u'data': {u'_': {u'file': u'log.py', ... u'fn': u'start', ... ...
[ ">>>", "idbf", "=", "InfluxDBForwarder", "(", "no_host", "8086", "deadpool", "...", "chimichanga", "logs", "collection", ")", ">>>", "log", "=", "{", "u", "data", ":", "{", "u", "_", ":", "{", "u", "file", ":", "u", "log", ".", "py", "...", "u", "f...
deep-compute/logagg
python
https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/forwarders.py#L167-L221
[ "def", "_tag_and_field_maker", "(", "self", ",", "event", ")", ":", "data", "=", "event", ".", "pop", "(", "'data'", ")", "data", "=", "flatten_dict", "(", "{", "'data'", ":", "data", "}", ")", "t", "=", "dict", "(", "(", "k", ",", "event", "[", ...
7863bc1b5ddf3e67c4d4b55746799304180589a0
train
InfluxDBForwarder._parse_msg_for_influxdb
>>> 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, ....
logagg/forwarders.py
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): ''' >>> from logagg.forwarders import InfluxDBForwarder >>> idbf = InfluxDBForwarder('no_host', '8086', 'deadpool', ... 'chimichanga', 'logs', 'collection') >>> valid_log = [{u'data': {u'_force_this_as_field': ...
[ ">>>", "from", "logagg", ".", "forwarders", "import", "InfluxDBForwarder", ">>>", "idbf", "=", "InfluxDBForwarder", "(", "no_host", "8086", "deadpool", "...", "chimichanga", "logs", "collection", ")" ]
deep-compute/logagg
python
https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/forwarders.py#L223-L290
[ "def", "_parse_msg_for_influxdb", "(", "self", ",", "msgs", ")", ":", "series", "=", "[", "]", "for", "msg", "in", "msgs", ":", "if", "msg", ".", "get", "(", "'error'", ")", ":", "continue", "if", "msg", ".", "get", "(", "'type'", ")", ".", "lower"...
7863bc1b5ddf3e67c4d4b55746799304180589a0
train
get_input
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...
nanoget/nanoget.py
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): """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...
[ "Get", "input", "and", "process", "accordingly", "." ]
wdecoster/nanoget
python
https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/nanoget.py#L29-L82
[ "def", "get_input", "(", "source", ",", "files", ",", "threads", "=", "4", ",", "readtype", "=", "\"1D\"", ",", "combine", "=", "\"simple\"", ",", "names", "=", "None", ",", "barcoded", "=", "False", ")", ":", "proc_functions", "=", "{", "'fastq'", ":"...
fb7306220e261849b96785fab02dd2f35a0e3b60
train
combine_dfs
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.
nanoget/nanoget.py
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): """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): ...
[ "Combine", "dataframes", "." ]
wdecoster/nanoget
python
https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/nanoget.py#L85-L97
[ "def", "combine_dfs", "(", "dfs", ",", "names", ",", "method", ")", ":", "if", "method", "==", "\"track\"", ":", "res", "=", "list", "(", ")", "for", "df", ",", "identifier", "in", "zip", "(", "dfs", ",", "names", ")", ":", "df", "[", "\"dataset\""...
fb7306220e261849b96785fab02dd2f35a0e3b60
train
calculate_start_time
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...
nanoget/nanoget.py
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): """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...
[ "Calculate", "the", "star_time", "per", "read", "." ]
wdecoster/nanoget
python
https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/nanoget.py#L100-L127
[ "def", "calculate_start_time", "(", "df", ")", ":", "if", "\"time\"", "in", "df", ":", "df", "[", "\"time_arr\"", "]", "=", "pd", ".", "Series", "(", "df", "[", "\"time\"", "]", ",", "dtype", "=", "'datetime64[s]'", ")", "elif", "\"timestamp\"", "in", ...
fb7306220e261849b96785fab02dd2f35a0e3b60
train
YamlParser.parser_from_buffer
Construct YamlParser from a file pointer.
marabunta/parser.py
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): """Construct YamlParser from a file pointer.""" yaml = YAML(typ="safe") return cls(yaml.load(fp))
[ "Construct", "YamlParser", "from", "a", "file", "pointer", "." ]
camptocamp/marabunta
python
https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/parser.py#L87-L90
[ "def", "parser_from_buffer", "(", "cls", ",", "fp", ")", ":", "yaml", "=", "YAML", "(", "typ", "=", "\"safe\"", ")", "return", "cls", "(", "yaml", ".", "load", "(", "fp", ")", ")" ]
ec3a7a725c7426d6ed642e0a80119b37880eb91e
train
YamlParser.check_dict_expected_keys
Check that we don't have unknown keys in a dictionary. It does not raise an error if we have less keys than expected.
marabunta/parser.py
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): """ 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"....
[ "Check", "that", "we", "don", "t", "have", "unknown", "keys", "in", "a", "dictionary", "." ]
camptocamp/marabunta
python
https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/parser.py#L98-L118
[ "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", "(", ...
ec3a7a725c7426d6ed642e0a80119b37880eb91e
train
YamlParser.parse
Check input and return a :class:`Migration` instance.
marabunta/parser.py
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): """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', ...
[ "Check", "input", "and", "return", "a", ":", "class", ":", "Migration", "instance", "." ]
camptocamp/marabunta
python
https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/parser.py#L120-L127
[ "def", "parse", "(", "self", ")", ":", "if", "not", "self", ".", "parsed", ".", "get", "(", "'migration'", ")", ":", "raise", "ParseError", "(", "u\"'migration' key is missing\"", ",", "YAML_EXAMPLE", ")", "self", ".", "check_dict_expected_keys", "(", "{", "...
ec3a7a725c7426d6ed642e0a80119b37880eb91e
train
YamlParser._parse_migrations
Build a :class:`Migration` instance.
marabunta/parser.py
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): """Build a :class:`Migration` instance.""" migration = self.parsed['migration'] options = self._parse_options(migration) versions = self._parse_versions(migration, options) return Migration(versions, options)
[ "Build", "a", ":", "class", ":", "Migration", "instance", "." ]
camptocamp/marabunta
python
https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/parser.py#L129-L134
[ "def", "_parse_migrations", "(", "self", ")", ":", "migration", "=", "self", ".", "parsed", "[", "'migration'", "]", "options", "=", "self", ".", "_parse_options", "(", "migration", ")", "versions", "=", "self", ".", "_parse_versions", "(", "migration", ",",...
ec3a7a725c7426d6ed642e0a80119b37880eb91e
train
YamlParser._parse_options
Build :class:`MigrationOption` and :class:`MigrationBackupOption` instances.
marabunta/parser.py
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): """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...
[ "Build", ":", "class", ":", "MigrationOption", "and", ":", "class", ":", "MigrationBackupOption", "instances", "." ]
camptocamp/marabunta
python
https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/parser.py#L136-L155
[ "def", "_parse_options", "(", "self", ",", "migration", ")", ":", "options", "=", "migration", ".", "get", "(", "'options'", ",", "{", "}", ")", "install_command", "=", "options", ".", "get", "(", "'install_command'", ")", "backup", "=", "options", ".", ...
ec3a7a725c7426d6ed642e0a80119b37880eb91e
train
Current.set_message
Sets user notification message. Args: title: Msg. title msg: Msg. text typ: Msg. type url: Additional URL (if exists) Returns: Message ID.
zengine/current.py
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): """ Sets user notification message. Args: title: Msg. title msg: Msg. text typ: Msg. type url: Additional URL (if exists) Returns: Message ID. """ return self....
[ "Sets", "user", "notification", "message", "." ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/current.py#L116-L132
[ "def", "set_message", "(", "self", ",", "title", ",", "msg", ",", "typ", ",", "url", "=", "None", ")", ":", "return", "self", ".", "user", ".", "send_notification", "(", "title", "=", "title", ",", "message", "=", "msg", ",", "typ", "=", "typ", ","...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
Current.is_auth
A property that indicates if current user is logged in or not. Returns: Boolean.
zengine/current.py
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): """ 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)
[ "A", "property", "that", "indicates", "if", "current", "user", "is", "logged", "in", "or", "not", "." ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/current.py#L135-L144
[ "def", "is_auth", "(", "self", ")", ":", "if", "self", ".", "user_id", "is", "None", ":", "self", ".", "user_id", "=", "self", ".", "session", ".", "get", "(", "'user_id'", ")", "return", "bool", "(", "self", ".", "user_id", ")" ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
Current.has_permission
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.
zengine/current.py
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): """ 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", "." ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/current.py#L146-L157
[ "def", "has_permission", "(", "self", ",", "perm", ")", ":", "return", "self", ".", "user", ".", "superuser", "or", "self", ".", "auth", ".", "has_permission", "(", "perm", ")" ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
Current.msg_box
Create a message box :param str msg: :param str title: :param str typ: 'info', 'error', 'warning'
zengine/current.py
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'): """ 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}
[ "Create", "a", "message", "box" ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/current.py#L169-L177
[ "def", "msg_box", "(", "self", ",", "msg", ",", "title", "=", "None", ",", "typ", "=", "'info'", ")", ":", "self", ".", "output", "[", "'msgbox'", "]", "=", "{", "'type'", ":", "typ", ",", "\"title\"", ":", "title", "or", "msg", "[", ":", "20", ...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
WFCurrent.sendoff_current_user
Tell current user that s/he finished it's job for now. We'll notify if workflow arrives again to his/her WF Lane.
zengine/current.py
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): """ 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...
[ "Tell", "current", "user", "that", "s", "/", "he", "finished", "it", "s", "job", "for", "now", ".", "We", "ll", "notify", "if", "workflow", "arrives", "again", "to", "his", "/", "her", "WF", "Lane", "." ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/current.py#L224-L230
[ "def", "sendoff_current_user", "(", "self", ")", ":", "msgs", "=", "self", ".", "task_data", ".", "get", "(", "'LANE_CHANGE_MSG'", ",", "DEFAULT_LANE_CHANGE_MSG", ")", "self", ".", "msg_box", "(", "title", "=", "msgs", "[", "'title'", "]", ",", "msg", "=",...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
WFCurrent.invite_other_parties
Invites the next lane's (possible) owner(s) to participate
zengine/current.py
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): """ 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, ...
[ "Invites", "the", "next", "lane", "s", "(", "possible", ")", "owner", "(", "s", ")", "to", "participate" ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/current.py#L232-L240
[ "def", "invite_other_parties", "(", "self", ",", "possible_owners", ")", ":", "signals", ".", "lane_user_change", ".", "send", "(", "sender", "=", "self", ".", "user", ",", "current", "=", "self", ",", "old_lane", "=", "self", ".", "old_lane", ",", "possib...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
WFCurrent._update_task
Assigns current task step to self.task then updates the task's data with self.task_data Args: task: Task object.
zengine/current.py
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): """ 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...
[ "Assigns", "current", "task", "step", "to", "self", ".", "task", "then", "updates", "the", "task", "s", "data", "with", "self", ".", "task_data" ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/current.py#L258-L272
[ "def", "_update_task", "(", "self", ",", "task", ")", ":", "self", ".", "task", "=", "task", "self", ".", "task", ".", "data", ".", "update", "(", "self", ".", "task_data", ")", "self", ".", "task_type", "=", "task", ".", "task_spec", ".", "__class__...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
WFCurrent.set_client_cmds
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...
zengine/current.py
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): """ 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 ...
[ "This", "is", "method", "automatically", "called", "on", "each", "request", "and", "updates", "object_id", "cmd", "and", "flow", "client", "variables", "from", "current", ".", "input", "." ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/current.py#L274-L304
[ "def", "set_client_cmds", "(", "self", ")", ":", "self", ".", "task_data", "[", "'cmd'", "]", "=", "self", ".", "input", ".", "get", "(", "'cmd'", ")", "self", ".", "task_data", "[", "'flow'", "]", "=", "self", ".", "input", ".", "get", "(", "'flow...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
Human.generate_move
Returns valid and legal move given position :type: position: Board :rtype: Move
chess_py/players/human.py
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): """ 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...
[ "Returns", "valid", "and", "legal", "move", "given", "position" ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/players/human.py#L28-L43
[ "def", "generate_move", "(", "self", ",", "position", ")", ":", "while", "True", ":", "print", "(", "position", ")", "raw", "=", "input", "(", "str", "(", "self", ".", "color", ")", "+", "\"\\'s move \\n\"", ")", "move", "=", "converter", ".", "short_a...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
King.in_check_as_result
Finds if playing my move would make both kings meet. :type: pos: Board :type: move: Move :rtype: bool
chess_py/pieces/king.py
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): """ 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_...
[ "Finds", "if", "playing", "my", "move", "would", "make", "both", "kings", "meet", "." ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/king.py#L51-L63
[ "def", "in_check_as_result", "(", "self", ",", "pos", ",", "move", ")", ":", "test", "=", "cp", "(", "pos", ")", "test", ".", "update", "(", "move", ")", "test_king", "=", "test", ".", "get_king", "(", "move", ".", "color", ")", "return", "self", "...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
King.loc_adjacent_to_opponent_king
Finds if 2 kings are touching given the position of one of the kings. :type: location: Location :type: position: Board :rtype: bool
chess_py/pieces/king.py
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): """ 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: ...
[ "Finds", "if", "2", "kings", "are", "touching", "given", "the", "position", "of", "one", "of", "the", "kings", "." ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/king.py#L65-L82
[ "def", "loc_adjacent_to_opponent_king", "(", "self", ",", "location", ",", "position", ")", ":", "for", "fn", "in", "self", ".", "cardinal_directions", ":", "try", ":", "if", "isinstance", "(", "position", ".", "piece_at_square", "(", "fn", "(", "location", ...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
King.add
Adds all 8 cardinal directions as moves for the King if legal. :type: function: function :type: position: Board :rtype: gen
chess_py/pieces/king.py
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): """ 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): ...
[ "Adds", "all", "8", "cardinal", "directions", "as", "moves", "for", "the", "King", "if", "legal", "." ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/king.py#L84-L102
[ "def", "add", "(", "self", ",", "func", ",", "position", ")", ":", "try", ":", "if", "self", ".", "loc_adjacent_to_opponent_king", "(", "func", "(", "self", ".", "location", ")", ",", "position", ")", ":", "return", "except", "IndexError", ":", "return",...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
King._rook_legal_for_castle
Decides if given rook exists, is of this color, and has not moved so it is eligible to castle. :type: rook: Rook :rtype: bool
chess_py/pieces/king.py
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): """ 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...
[ "Decides", "if", "given", "rook", "exists", "is", "of", "this", "color", "and", "has", "not", "moved", "so", "it", "is", "eligible", "to", "castle", "." ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/king.py#L104-L115
[ "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" ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
King._empty_not_in_check
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
chess_py/pieces/king.py
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): """ 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...
[ "Checks", "if", "set", "of", "squares", "in", "between", "King", "and", "Rook", "are", "empty", "and", "safe", "for", "the", "king", "to", "castle", "." ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/king.py#L117-L132
[ "def", "_empty_not_in_check", "(", "self", ",", "position", ",", "direction", ")", ":", "def", "valid_square", "(", "square", ")", ":", "return", "position", ".", "is_square_empty", "(", "square", ")", "and", "not", "self", ".", "in_check", "(", "position", ...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
King.add_castle
Adds kingside and queenside castling moves if legal :type: position: Board
chess_py/pieces/king.py
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): """ 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...
[ "Adds", "kingside", "and", "queenside", "castling", "moves", "if", "legal" ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/king.py#L134-L163
[ "def", "add_castle", "(", "self", ",", "position", ")", ":", "if", "self", ".", "has_moved", "or", "self", ".", "in_check", "(", "position", ")", ":", "return", "if", "self", ".", "color", "==", "color", ".", "white", ":", "rook_rank", "=", "0", "els...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
King.possible_moves
Generates list of possible moves :type: position: Board :rtype: list
chess_py/pieces/king.py
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): """ 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...
[ "Generates", "list", "of", "possible", "moves" ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/king.py#L165-L177
[ "def", "possible_moves", "(", "self", ",", "position", ")", ":", "# Chain used to combine multiple generators", "for", "move", "in", "itertools", ".", "chain", "(", "*", "[", "self", ".", "add", "(", "fn", ",", "position", ")", "for", "fn", "in", "self", "...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
King.in_check
Finds if the king is in check or if both kings are touching. :type: position: Board :return: bool
chess_py/pieces/king.py
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): """ 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 !=...
[ "Finds", "if", "the", "king", "is", "in", "check", "or", "if", "both", "kings", "are", "touching", "." ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/king.py#L179-L199
[ "def", "in_check", "(", "self", ",", "position", ",", "location", "=", "None", ")", ":", "location", "=", "location", "or", "self", ".", "location", "for", "piece", "in", "position", ":", "if", "piece", "is", "not", "None", "and", "piece", ".", "color"...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
set_keep_alive
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.
cocaine/detail/baseservice.py
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): """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...
[ "Sets", "the", "keep", "-", "alive", "setting", "for", "the", "peer", "socket", "." ]
cocaine/cocaine-framework-python
python
https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/baseservice.py#L55-L75
[ "def", "set_keep_alive", "(", "sock", ",", "idle", "=", "10", ",", "interval", "=", "5", ",", "fails", "=", "5", ")", ":", "import", "sys", "sock", ".", "setsockopt", "(", "socket", ".", "SOL_SOCKET", ",", "socket", ".", "SO_KEEPALIVE", ",", "1", ")"...
d8a30074b6338bac4389eb996e00d404338115e4
train
Board.init_default
Creates a ``Board`` with the standard chess starting position. :rtype: Board
chess_py/core/board.py
def init_default(cls): """ Creates a ``Board`` with the standard chess starting position. :rtype: Board """ return cls([ # First rank [Rook(white, Location(0, 0)), Knight(white, Location(0, 1)), Bishop(white, Location(0, 2)), Queen(white, Lo...
def init_default(cls): """ Creates a ``Board`` with the standard chess starting position. :rtype: Board """ return cls([ # First rank [Rook(white, Location(0, 0)), Knight(white, Location(0, 1)), Bishop(white, Location(0, 2)), Queen(white, Lo...
[ "Creates", "a", "Board", "with", "the", "standard", "chess", "starting", "position", "." ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/board.py#L73-L108
[ "def", "init_default", "(", "cls", ")", ":", "return", "cls", "(", "[", "# First rank", "[", "Rook", "(", "white", ",", "Location", "(", "0", ",", "0", ")", ")", ",", "Knight", "(", "white", ",", "Location", "(", "0", ",", "1", ")", ")", ",", "...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
Board.material_advantage
Finds the advantage a particular side possesses given a value scheme. :type: input_color: Color :type: val_scheme: PieceValues :rtype: double
chess_py/core/board.py
def material_advantage(self, input_color, val_scheme): """ Finds the advantage a particular side possesses given a value scheme. :type: input_color: Color :type: val_scheme: PieceValues :rtype: double """ if self.get_king(input_color).in_check(self) and self.no_...
def material_advantage(self, input_color, val_scheme): """ Finds the advantage a particular side possesses given a value scheme. :type: input_color: Color :type: val_scheme: PieceValues :rtype: double """ if self.get_king(input_color).in_check(self) and self.no_...
[ "Finds", "the", "advantage", "a", "particular", "side", "possesses", "given", "a", "value", "scheme", "." ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/board.py#L185-L200
[ "def", "material_advantage", "(", "self", ",", "input_color", ",", "val_scheme", ")", ":", "if", "self", ".", "get_king", "(", "input_color", ")", ".", "in_check", "(", "self", ")", "and", "self", ".", "no_moves", "(", "input_color", ")", ":", "return", ...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
Board.advantage_as_result
Calculates advantage after move is played :type: move: Move :type: val_scheme: PieceValues :rtype: double
chess_py/core/board.py
def advantage_as_result(self, move, val_scheme): """ Calculates advantage after move is played :type: move: Move :type: val_scheme: PieceValues :rtype: double """ test_board = cp(self) test_board.update(move) return test_board.material_advantage(m...
def advantage_as_result(self, move, val_scheme): """ Calculates advantage after move is played :type: move: Move :type: val_scheme: PieceValues :rtype: double """ test_board = cp(self) test_board.update(move) return test_board.material_advantage(m...
[ "Calculates", "advantage", "after", "move", "is", "played" ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/board.py#L202-L212
[ "def", "advantage_as_result", "(", "self", ",", "move", ",", "val_scheme", ")", ":", "test_board", "=", "cp", "(", "self", ")", "test_board", ".", "update", "(", "move", ")", "return", "test_board", ".", "material_advantage", "(", "move", ".", "color", ","...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
Board.all_possible_moves
Checks if all the possible moves has already been calculated and is stored in `possible_moves` dictionary. If not, it is calculated with `_calc_all_possible_moves`. :type: input_color: Color :rtype: list
chess_py/core/board.py
def all_possible_moves(self, input_color): """ Checks if all the possible moves has already been calculated and is stored in `possible_moves` dictionary. If not, it is calculated with `_calc_all_possible_moves`. :type: input_color: Color :rtype: list """ ...
def all_possible_moves(self, input_color): """ Checks if all the possible moves has already been calculated and is stored in `possible_moves` dictionary. If not, it is calculated with `_calc_all_possible_moves`. :type: input_color: Color :rtype: list """ ...
[ "Checks", "if", "all", "the", "possible", "moves", "has", "already", "been", "calculated", "and", "is", "stored", "in", "possible_moves", "dictionary", ".", "If", "not", "it", "is", "calculated", "with", "_calc_all_possible_moves", ".", ":", "type", ":", "inpu...
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/board.py#L214-L227
[ "def", "all_possible_moves", "(", "self", ",", "input_color", ")", ":", "position_tuple", "=", "self", ".", "position_tuple", "if", "position_tuple", "not", "in", "self", ".", "possible_moves", ":", "self", ".", "possible_moves", "[", "position_tuple", "]", "=",...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
Board._calc_all_possible_moves
Returns list of all possible moves :type: input_color: Color :rtype: list
chess_py/core/board.py
def _calc_all_possible_moves(self, input_color): """ Returns list of all possible moves :type: input_color: Color :rtype: list """ for piece in self: # Tests if square on the board is not empty if piece is not None and piece.color == input_color:...
def _calc_all_possible_moves(self, input_color): """ Returns list of all possible moves :type: input_color: Color :rtype: list """ for piece in self: # Tests if square on the board is not empty if piece is not None and piece.color == input_color:...
[ "Returns", "list", "of", "all", "possible", "moves" ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/board.py#L229-L264
[ "def", "_calc_all_possible_moves", "(", "self", ",", "input_color", ")", ":", "for", "piece", "in", "self", ":", "# Tests if square on the board is not empty", "if", "piece", "is", "not", "None", "and", "piece", ".", "color", "==", "input_color", ":", "for", "mo...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
Board.runInParallel
Runs multiple processes in parallel. :type: fns: def
chess_py/core/board.py
def runInParallel(*fns): """ Runs multiple processes in parallel. :type: fns: def """ proc = [] for fn in fns: p = Process(target=fn) p.start() proc.append(p) for p in proc: p.join()
def runInParallel(*fns): """ Runs multiple processes in parallel. :type: fns: def """ proc = [] for fn in fns: p = Process(target=fn) p.start() proc.append(p) for p in proc: p.join()
[ "Runs", "multiple", "processes", "in", "parallel", "." ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/board.py#L266-L278
[ "def", "runInParallel", "(", "*", "fns", ")", ":", "proc", "=", "[", "]", "for", "fn", "in", "fns", ":", "p", "=", "Process", "(", "target", "=", "fn", ")", "p", ".", "start", "(", ")", "proc", ".", "append", "(", "p", ")", "for", "p", "in", ...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
Board.find_piece
Finds Location of the first piece that matches piece. If none is found, Exception is raised. :type: piece: Piece :rtype: Location
chess_py/core/board.py
def find_piece(self, piece): """ Finds Location of the first piece that matches piece. If none is found, Exception is raised. :type: piece: Piece :rtype: Location """ for i, _ in enumerate(self.position): for j, _ in enumerate(self.position): ...
def find_piece(self, piece): """ Finds Location of the first piece that matches piece. If none is found, Exception is raised. :type: piece: Piece :rtype: Location """ for i, _ in enumerate(self.position): for j, _ in enumerate(self.position): ...
[ "Finds", "Location", "of", "the", "first", "piece", "that", "matches", "piece", ".", "If", "none", "is", "found", "Exception", "is", "raised", "." ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/board.py#L298-L314
[ "def", "find_piece", "(", "self", ",", "piece", ")", ":", "for", "i", ",", "_", "in", "enumerate", "(", "self", ".", "position", ")", ":", "for", "j", ",", "_", "in", "enumerate", "(", "self", ".", "position", ")", ":", "loc", "=", "Location", "(...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
Board.get_piece
Gets location of a piece on the board given the type and color. :type: piece_type: Piece :type: input_color: Color :rtype: Location
chess_py/core/board.py
def get_piece(self, piece_type, input_color): """ Gets location of a piece on the board given the type and color. :type: piece_type: Piece :type: input_color: Color :rtype: Location """ for loc in self: piece = self.piece_at_square(loc) ...
def get_piece(self, piece_type, input_color): """ Gets location of a piece on the board given the type and color. :type: piece_type: Piece :type: input_color: Color :rtype: Location """ for loc in self: piece = self.piece_at_square(loc) ...
[ "Gets", "location", "of", "a", "piece", "on", "the", "board", "given", "the", "type", "and", "color", ".", ":", "type", ":", "piece_type", ":", "Piece", ":", "type", ":", "input_color", ":", "Color", ":", "rtype", ":", "Location" ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/board.py#L316-L332
[ "def", "get_piece", "(", "self", ",", "piece_type", ",", "input_color", ")", ":", "for", "loc", "in", "self", ":", "piece", "=", "self", ".", "piece_at_square", "(", "loc", ")", "if", "not", "self", ".", "is_square_empty", "(", "loc", ")", "and", "isin...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
Board.place_piece_at_square
Places piece at given get_location :type: piece: Piece :type: location: Location
chess_py/core/board.py
def place_piece_at_square(self, piece, location): """ Places piece at given get_location :type: piece: Piece :type: location: Location """ self.position[location.rank][location.file] = piece piece.location = location
def place_piece_at_square(self, piece, location): """ Places piece at given get_location :type: piece: Piece :type: location: Location """ self.position[location.rank][location.file] = piece piece.location = location
[ "Places", "piece", "at", "given", "get_location" ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/board.py#L360-L368
[ "def", "place_piece_at_square", "(", "self", ",", "piece", ",", "location", ")", ":", "self", ".", "position", "[", "location", ".", "rank", "]", "[", "location", ".", "file", "]", "=", "piece", "piece", ".", "location", "=", "location" ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
Board.move_piece
Moves piece from one location to another :type: initial: Location :type: final: Location
chess_py/core/board.py
def move_piece(self, initial, final): """ Moves piece from one location to another :type: initial: Location :type: final: Location """ self.place_piece_at_square(self.piece_at_square(initial), final) self.remove_piece_at_square(initial)
def move_piece(self, initial, final): """ Moves piece from one location to another :type: initial: Location :type: final: Location """ self.place_piece_at_square(self.piece_at_square(initial), final) self.remove_piece_at_square(initial)
[ "Moves", "piece", "from", "one", "location", "to", "another" ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/board.py#L370-L378
[ "def", "move_piece", "(", "self", ",", "initial", ",", "final", ")", ":", "self", ".", "place_piece_at_square", "(", "self", ".", "piece_at_square", "(", "initial", ")", ",", "final", ")", "self", ".", "remove_piece_at_square", "(", "initial", ")" ]
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
Board.update
Updates position by applying selected move :type: move: Move
chess_py/core/board.py
def update(self, move): """ Updates position by applying selected move :type: move: Move """ if move is None: raise TypeError("Move cannot be type None") if self.king_loc_dict is not None and isinstance(move.piece, King): self.king_loc_dict[move....
def update(self, move): """ Updates position by applying selected move :type: move: Move """ if move is None: raise TypeError("Move cannot be type None") if self.king_loc_dict is not None and isinstance(move.piece, King): self.king_loc_dict[move....
[ "Updates", "position", "by", "applying", "selected", "move" ]
LordDarkula/chess_py
python
https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/board.py#L380-L427
[ "def", "update", "(", "self", ",", "move", ")", ":", "if", "move", "is", "None", ":", "raise", "TypeError", "(", "\"Move cannot be type None\"", ")", "if", "self", ".", "king_loc_dict", "is", "not", "None", "and", "isinstance", "(", "move", ".", "piece", ...
14bebc2f8c49ae25c59375cc83d0b38d8ff7281d
train
Balance._balance
calc unbalanced charges and radicals for skin atoms
CGRtools/algorithms/balance.py
def _balance(self, ): """ calc unbalanced charges and radicals for skin atoms """ meta = h.meta for n in (skin_reagent.keys() | skin_product.keys()): lost = skin_reagent[n] cycle_lost = cycle(lost) new = skin_product[n] cycle_new = cycle(ne...
def _balance(self, ): """ calc unbalanced charges and radicals for skin atoms """ meta = h.meta for n in (skin_reagent.keys() | skin_product.keys()): lost = skin_reagent[n] cycle_lost = cycle(lost) new = skin_product[n] cycle_new = cycle(ne...
[ "calc", "unbalanced", "charges", "and", "radicals", "for", "skin", "atoms" ]
cimm-kzn/CGRtools
python
https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/balance.py#L25-L206
[ "def", "_balance", "(", "self", ",", ")", ":", "meta", "=", "h", ".", "meta", "for", "n", "in", "(", "skin_reagent", ".", "keys", "(", ")", "|", "skin_product", ".", "keys", "(", ")", ")", ":", "lost", "=", "skin_reagent", "[", "n", "]", "cycle_l...
15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34
train
Balance.clone_subgraphs
search bond breaks and creations
CGRtools/algorithms/balance.py
def clone_subgraphs(self, g): if not isinstance(g, CGRContainer): raise InvalidData('only CGRContainer acceptable') r_group = [] x_group = {} r_group_clones = [] newcomponents = [] ''' search bond breaks and creations ''' components, lost_bon...
def clone_subgraphs(self, g): if not isinstance(g, CGRContainer): raise InvalidData('only CGRContainer acceptable') r_group = [] x_group = {} r_group_clones = [] newcomponents = [] ''' search bond breaks and creations ''' components, lost_bon...
[ "search", "bond", "breaks", "and", "creations" ]
cimm-kzn/CGRtools
python
https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/balance.py#L208-L266
[ "def", "clone_subgraphs", "(", "self", ",", "g", ")", ":", "if", "not", "isinstance", "(", "g", ",", "CGRContainer", ")", ":", "raise", "InvalidData", "(", "'only CGRContainer acceptable'", ")", "r_group", "=", "[", "]", "x_group", "=", "{", "}", "r_group_...
15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34
train
Balance.__get_substitution_paths
get atoms paths from detached atom to attached :param g: CGRContainer :return: tuple of atoms numbers
CGRtools/algorithms/balance.py
def __get_substitution_paths(g): """ get atoms paths from detached atom to attached :param g: CGRContainer :return: tuple of atoms numbers """ for n, nbrdict in g.adjacency(): for m, l in combinations(nbrdict, 2): nms = nbrdict[m]['sp_bond'] ...
def __get_substitution_paths(g): """ get atoms paths from detached atom to attached :param g: CGRContainer :return: tuple of atoms numbers """ for n, nbrdict in g.adjacency(): for m, l in combinations(nbrdict, 2): nms = nbrdict[m]['sp_bond'] ...
[ "get", "atoms", "paths", "from", "detached", "atom", "to", "attached" ]
cimm-kzn/CGRtools
python
https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/balance.py#L292-L306
[ "def", "__get_substitution_paths", "(", "g", ")", ":", "for", "n", ",", "nbrdict", "in", "g", ".", "adjacency", "(", ")", ":", "for", "m", ",", "l", "in", "combinations", "(", "nbrdict", ",", "2", ")", ":", "nms", "=", "nbrdict", "[", "m", "]", "...
15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34
train
MigrationTable.versions
Read versions from the table The versions are kept in cache for the next reads.
marabunta/database.py
def versions(self): """ Read versions from the table The versions are kept in cache for the next reads. """ if self._versions is None: with self.database.cursor_autocommit() as cursor: query = """ SELECT number, date_sta...
def versions(self): """ Read versions from the table The versions are kept in cache for the next reads. """ if self._versions is None: with self.database.cursor_autocommit() as cursor: query = """ SELECT number, date_sta...
[ "Read", "versions", "from", "the", "table" ]
camptocamp/marabunta
python
https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/database.py#L77-L103
[ "def", "versions", "(", "self", ")", ":", "if", "self", ".", "_versions", "is", "None", ":", "with", "self", ".", "database", ".", "cursor_autocommit", "(", ")", "as", "cursor", ":", "query", "=", "\"\"\"\n SELECT number,\n dat...
ec3a7a725c7426d6ed642e0a80119b37880eb91e
train
Menu.simple_crud
Prepares menu entries for auto-generated model CRUD views. This is simple version of :attr:`get_crud_menus()` without Category support and permission control. Just for development purposes. Returns: Dict of list of dicts (``{'':[{}],}``). Menu entries.
zengine/views/menu.py
def simple_crud(): """ Prepares menu entries for auto-generated model CRUD views. This is simple version of :attr:`get_crud_menus()` without Category support and permission control. Just for development purposes. Returns: Dict of list of dicts (``{'':[{}],}``...
def simple_crud(): """ Prepares menu entries for auto-generated model CRUD views. This is simple version of :attr:`get_crud_menus()` without Category support and permission control. Just for development purposes. Returns: Dict of list of dicts (``{'':[{}],}``...
[ "Prepares", "menu", "entries", "for", "auto", "-", "generated", "model", "CRUD", "views", ".", "This", "is", "simple", "version", "of", ":", "attr", ":", "get_crud_menus", "()", "without", "Category", "support", "and", "permission", "control", ".", "Just", "...
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/menu.py#L43-L60
[ "def", "simple_crud", "(", ")", ":", "results", "=", "defaultdict", "(", "list", ")", "for", "mdl", "in", "model_registry", ".", "get_base_models", "(", ")", ":", "results", "[", "'other'", "]", ".", "append", "(", "{", "\"text\"", ":", "mdl", ".", "Me...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
Menu.get_crud_menus
Generates menu entries according to :attr:`zengine.settings.OBJECT_MENU` and permissions of current user. Returns: Dict of list of dicts (``{'':[{}],}``). Menu entries.
zengine/views/menu.py
def get_crud_menus(self): """ Generates menu entries according to :attr:`zengine.settings.OBJECT_MENU` and permissions of current user. Returns: Dict of list of dicts (``{'':[{}],}``). Menu entries. """ results = defaultdict(list) for object_t...
def get_crud_menus(self): """ Generates menu entries according to :attr:`zengine.settings.OBJECT_MENU` and permissions of current user. Returns: Dict of list of dicts (``{'':[{}],}``). Menu entries. """ results = defaultdict(list) for object_t...
[ "Generates", "menu", "entries", "according", "to", ":", "attr", ":", "zengine", ".", "settings", ".", "OBJECT_MENU", "and", "permissions", "of", "current", "user", "." ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/menu.py#L62-L76
[ "def", "get_crud_menus", "(", "self", ")", ":", "results", "=", "defaultdict", "(", "list", ")", "for", "object_type", "in", "settings", ".", "OBJECT_MENU", ":", "for", "model_data", "in", "settings", ".", "OBJECT_MENU", "[", "object_type", "]", ":", "if", ...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
Menu._add_crud
Creates a menu entry for given model data. Updates results in place. Args: model_data: Model data. object_type: Relation name. results: Results dict.
zengine/views/menu.py
def _add_crud(self, model_data, object_type, results): """ Creates a menu entry for given model data. Updates results in place. Args: model_data: Model data. object_type: Relation name. results: Results dict. """ model = model_registry...
def _add_crud(self, model_data, object_type, results): """ Creates a menu entry for given model data. Updates results in place. Args: model_data: Model data. object_type: Relation name. results: Results dict. """ model = model_registry...
[ "Creates", "a", "menu", "entry", "for", "given", "model", "data", ".", "Updates", "results", "in", "place", "." ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/menu.py#L78-L99
[ "def", "_add_crud", "(", "self", ",", "model_data", ",", "object_type", ",", "results", ")", ":", "model", "=", "model_registry", ".", "get_model", "(", "model_data", "[", "'name'", "]", ")", "field_name", "=", "model_data", ".", "get", "(", "'field'", ")"...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
Menu._add_to_quick_menu
Appends menu entries to dashboard quickmenu according to :attr:`zengine.settings.QUICK_MENU` Args: key: workflow name wf: workflow menu entry
zengine/views/menu.py
def _add_to_quick_menu(self, key, wf): """ Appends menu entries to dashboard quickmenu according to :attr:`zengine.settings.QUICK_MENU` Args: key: workflow name wf: workflow menu entry """ if key in settings.QUICK_MENU: self.output['qu...
def _add_to_quick_menu(self, key, wf): """ Appends menu entries to dashboard quickmenu according to :attr:`zengine.settings.QUICK_MENU` Args: key: workflow name wf: workflow menu entry """ if key in settings.QUICK_MENU: self.output['qu...
[ "Appends", "menu", "entries", "to", "dashboard", "quickmenu", "according", "to", ":", "attr", ":", "zengine", ".", "settings", ".", "QUICK_MENU" ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/menu.py#L101-L111
[ "def", "_add_to_quick_menu", "(", "self", ",", "key", ",", "wf", ")", ":", "if", "key", "in", "settings", ".", "QUICK_MENU", ":", "self", ".", "output", "[", "'quick_menu'", "]", ".", "append", "(", "wf", ")" ]
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
Menu._get_workflow_menus
Creates menu entries for custom workflows. Returns: Dict of list of dicts (``{'':[{}],}``). Menu entries.
zengine/views/menu.py
def _get_workflow_menus(self): """ Creates menu entries for custom workflows. Returns: Dict of list of dicts (``{'':[{}],}``). Menu entries. """ results = defaultdict(list) from zengine.lib.cache import WFSpecNames for name, title, category in WFSpecN...
def _get_workflow_menus(self): """ Creates menu entries for custom workflows. Returns: Dict of list of dicts (``{'':[{}],}``). Menu entries. """ results = defaultdict(list) from zengine.lib.cache import WFSpecNames for name, title, category in WFSpecN...
[ "Creates", "menu", "entries", "for", "custom", "workflows", "." ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/menu.py#L113-L132
[ "def", "_get_workflow_menus", "(", "self", ")", ":", "results", "=", "defaultdict", "(", "list", ")", "from", "zengine", ".", "lib", ".", "cache", "import", "WFSpecNames", "for", "name", ",", "title", ",", "category", "in", "WFSpecNames", "(", ")", ".", ...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
CORS.process_response
Do response processing
zengine/middlewares.py
def process_response(self, request, response, resource): """ Do response processing """ origin = request.get_header('Origin') if not settings.DEBUG: if origin in settings.ALLOWED_ORIGINS or not origin: response.set_header('Access-Control-Allow-Origin',...
def process_response(self, request, response, resource): """ Do response processing """ origin = request.get_header('Origin') if not settings.DEBUG: if origin in settings.ALLOWED_ORIGINS or not origin: response.set_header('Access-Control-Allow-Origin',...
[ "Do", "response", "processing" ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/middlewares.py#L26-L45
[ "def", "process_response", "(", "self", ",", "request", ",", "response", ",", "resource", ")", ":", "origin", "=", "request", ".", "get_header", "(", "'Origin'", ")", "if", "not", "settings", ".", "DEBUG", ":", "if", "origin", "in", "settings", ".", "ALL...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
RequireJSON.process_request
Do response processing
zengine/middlewares.py
def process_request(self, req, resp): """ Do response processing """ if not req.client_accepts_json: raise falcon.HTTPNotAcceptable( 'This API only supports responses encoded as JSON.', href='http://docs.examples.com/api/json') if req.m...
def process_request(self, req, resp): """ Do response processing """ if not req.client_accepts_json: raise falcon.HTTPNotAcceptable( 'This API only supports responses encoded as JSON.', href='http://docs.examples.com/api/json') if req.m...
[ "Do", "response", "processing" ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/middlewares.py#L52-L66
[ "def", "process_request", "(", "self", ",", "req", ",", "resp", ")", ":", "if", "not", "req", ".", "client_accepts_json", ":", "raise", "falcon", ".", "HTTPNotAcceptable", "(", "'This API only supports responses encoded as JSON.'", ",", "href", "=", "'http://docs.ex...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
JSONTranslator.process_request
Do response processing
zengine/middlewares.py
def process_request(self, req, resp): """ Do response processing """ # req.stream corresponds to the WSGI wsgi.input environ variable, # and allows you to read bytes from the request body. # # See also: PEP 3333 if req.content_length in (None, 0): ...
def process_request(self, req, resp): """ Do response processing """ # req.stream corresponds to the WSGI wsgi.input environ variable, # and allows you to read bytes from the request body. # # See also: PEP 3333 if req.content_length in (None, 0): ...
[ "Do", "response", "processing" ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/middlewares.py#L73-L106
[ "def", "process_request", "(", "self", ",", "req", ",", "resp", ")", ":", "# req.stream corresponds to the WSGI wsgi.input environ variable,", "# and allows you to read bytes from the request body.", "#", "# See also: PEP 3333", "if", "req", ".", "content_length", "in", "(", ...
b5bc32d3b37bca799f8985be916f04528ac79e4a
train
JSONTranslator.process_response
Serializes ``req.context['result']`` to resp.body as JSON. If :attr:`~zengine.settings.DEBUG` is True, ``sys._debug_db_queries`` (set by pyoko) added to response.
zengine/middlewares.py
def process_response(self, req, resp, resource): """ Serializes ``req.context['result']`` to resp.body as JSON. If :attr:`~zengine.settings.DEBUG` is True, ``sys._debug_db_queries`` (set by pyoko) added to response. """ if 'result' not in req.context: return...
def process_response(self, req, resp, resource): """ Serializes ``req.context['result']`` to resp.body as JSON. If :attr:`~zengine.settings.DEBUG` is True, ``sys._debug_db_queries`` (set by pyoko) added to response. """ if 'result' not in req.context: return...
[ "Serializes", "req", ".", "context", "[", "result", "]", "to", "resp", ".", "body", "as", "JSON", "." ]
zetaops/zengine
python
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/middlewares.py#L108-L128
[ "def", "process_response", "(", "self", ",", "req", ",", "resp", ",", "resource", ")", ":", "if", "'result'", "not", "in", "req", ".", "context", ":", "return", "req", ".", "context", "[", "'result'", "]", "[", "'is_login'", "]", "=", "'user_id'", "in"...
b5bc32d3b37bca799f8985be916f04528ac79e4a