repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
cimm-kzn/CGRtools | CGRtools/reactor.py | Reactor.__get_mapping | def __get_mapping(self, structures):
"""
match each pattern to each molecule.
if all patterns matches with all molecules
return generator of all possible mapping.
:param structures: disjoint molecules
:return: mapping generator
"""
for c in permutations(s... | python | def __get_mapping(self, structures):
"""
match each pattern to each molecule.
if all patterns matches with all molecules
return generator of all possible mapping.
:param structures: disjoint molecules
:return: mapping generator
"""
for c in permutations(s... | [
"def",
"__get_mapping",
"(",
"self",
",",
"structures",
")",
":",
"for",
"c",
"in",
"permutations",
"(",
"structures",
",",
"len",
"(",
"self",
".",
"__patterns",
")",
")",
":",
"for",
"m",
"in",
"product",
"(",
"*",
"(",
"x",
".",
"get_substructure_ma... | match each pattern to each molecule.
if all patterns matches with all molecules
return generator of all possible mapping.
:param structures: disjoint molecules
:return: mapping generator | [
"match",
"each",
"pattern",
"to",
"each",
"molecule",
".",
"if",
"all",
"patterns",
"matches",
"with",
"all",
"molecules",
"return",
"generator",
"of",
"all",
"possible",
"mapping",
"."
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/reactor.py#L300-L315 | train |
zetaops/zengine | zengine/lib/cache.py | Cache.get | def get(self, default=None):
"""
return the cached value or default if it can't be found
:param default: default value
:return: cached value
"""
d = cache.get(self.key)
return ((json.loads(d.decode('utf-8')) if self.serialize else d)
if d is not N... | python | def get(self, default=None):
"""
return the cached value or default if it can't be found
:param default: default value
:return: cached value
"""
d = cache.get(self.key)
return ((json.loads(d.decode('utf-8')) if self.serialize else d)
if d is not N... | [
"def",
"get",
"(",
"self",
",",
"default",
"=",
"None",
")",
":",
"d",
"=",
"cache",
".",
"get",
"(",
"self",
".",
"key",
")",
"return",
"(",
"(",
"json",
".",
"loads",
"(",
"d",
".",
"decode",
"(",
"'utf-8'",
")",
")",
"if",
"self",
".",
"se... | return the cached value or default if it can't be found
:param default: default value
:return: cached value | [
"return",
"the",
"cached",
"value",
"or",
"default",
"if",
"it",
"can",
"t",
"be",
"found"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/cache.py#L79-L89 | train |
zetaops/zengine | zengine/lib/cache.py | Cache.set | def set(self, val, lifetime=None):
"""
set cache value
:param val: any picklable object
:param lifetime: exprition time in sec
:return: val
"""
cache.set(self.key,
(json.dumps(val) if self.serialize else val),
lifetime or setti... | python | def set(self, val, lifetime=None):
"""
set cache value
:param val: any picklable object
:param lifetime: exprition time in sec
:return: val
"""
cache.set(self.key,
(json.dumps(val) if self.serialize else val),
lifetime or setti... | [
"def",
"set",
"(",
"self",
",",
"val",
",",
"lifetime",
"=",
"None",
")",
":",
"cache",
".",
"set",
"(",
"self",
".",
"key",
",",
"(",
"json",
".",
"dumps",
"(",
"val",
")",
"if",
"self",
".",
"serialize",
"else",
"val",
")",
",",
"lifetime",
"... | set cache value
:param val: any picklable object
:param lifetime: exprition time in sec
:return: val | [
"set",
"cache",
"value"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/cache.py#L91-L102 | train |
zetaops/zengine | zengine/lib/cache.py | Cache.add | def add(self, val):
"""
Add given value to item (list)
Args:
val: A JSON serializable object.
Returns:
Cache backend response.
"""
return cache.lpush(self.key, json.dumps(val) if self.serialize else val) | python | def add(self, val):
"""
Add given value to item (list)
Args:
val: A JSON serializable object.
Returns:
Cache backend response.
"""
return cache.lpush(self.key, json.dumps(val) if self.serialize else val) | [
"def",
"add",
"(",
"self",
",",
"val",
")",
":",
"return",
"cache",
".",
"lpush",
"(",
"self",
".",
"key",
",",
"json",
".",
"dumps",
"(",
"val",
")",
"if",
"self",
".",
"serialize",
"else",
"val",
")"
] | Add given value to item (list)
Args:
val: A JSON serializable object.
Returns:
Cache backend response. | [
"Add",
"given",
"value",
"to",
"item",
"(",
"list",
")"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/cache.py#L143-L153 | train |
zetaops/zengine | zengine/lib/cache.py | Cache.get_all | def get_all(self):
"""
Get all list items.
Returns:
Cache backend response.
"""
result = cache.lrange(self.key, 0, -1)
return (json.loads(item.decode('utf-8')) for item in result if
item) if self.serialize else result | python | def get_all(self):
"""
Get all list items.
Returns:
Cache backend response.
"""
result = cache.lrange(self.key, 0, -1)
return (json.loads(item.decode('utf-8')) for item in result if
item) if self.serialize else result | [
"def",
"get_all",
"(",
"self",
")",
":",
"result",
"=",
"cache",
".",
"lrange",
"(",
"self",
".",
"key",
",",
"0",
",",
"-",
"1",
")",
"return",
"(",
"json",
".",
"loads",
"(",
"item",
".",
"decode",
"(",
"'utf-8'",
")",
")",
"for",
"item",
"in... | Get all list items.
Returns:
Cache backend response. | [
"Get",
"all",
"list",
"items",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/cache.py#L155-L164 | train |
zetaops/zengine | zengine/lib/cache.py | Cache.remove_item | def remove_item(self, val):
"""
Removes given item from the list.
Args:
val: Item
Returns:
Cache backend response.
"""
return cache.lrem(self.key, json.dumps(val)) | python | def remove_item(self, val):
"""
Removes given item from the list.
Args:
val: Item
Returns:
Cache backend response.
"""
return cache.lrem(self.key, json.dumps(val)) | [
"def",
"remove_item",
"(",
"self",
",",
"val",
")",
":",
"return",
"cache",
".",
"lrem",
"(",
"self",
".",
"key",
",",
"json",
".",
"dumps",
"(",
"val",
")",
")"
] | Removes given item from the list.
Args:
val: Item
Returns:
Cache backend response. | [
"Removes",
"given",
"item",
"from",
"the",
"list",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/cache.py#L175-L185 | train |
zetaops/zengine | zengine/lib/cache.py | Cache.flush | def flush(cls, *args):
"""
Removes all keys of this namespace
Without args, clears all keys starting with cls.PREFIX
if called with args, clears keys starting with given cls.PREFIX + args
Args:
*args: Arbitrary number of arguments.
Returns:
List ... | python | def flush(cls, *args):
"""
Removes all keys of this namespace
Without args, clears all keys starting with cls.PREFIX
if called with args, clears keys starting with given cls.PREFIX + args
Args:
*args: Arbitrary number of arguments.
Returns:
List ... | [
"def",
"flush",
"(",
"cls",
",",
"*",
"args",
")",
":",
"return",
"_remove_keys",
"(",
"[",
"]",
",",
"[",
"(",
"cls",
".",
"_make_key",
"(",
"args",
")",
"if",
"args",
"else",
"cls",
".",
"PREFIX",
")",
"+",
"'*'",
"]",
")"
] | Removes all keys of this namespace
Without args, clears all keys starting with cls.PREFIX
if called with args, clears keys starting with given cls.PREFIX + args
Args:
*args: Arbitrary number of arguments.
Returns:
List of removed keys. | [
"Removes",
"all",
"keys",
"of",
"this",
"namespace",
"Without",
"args",
"clears",
"all",
"keys",
"starting",
"with",
"cls",
".",
"PREFIX",
"if",
"called",
"with",
"args",
"clears",
"keys",
"starting",
"with",
"given",
"cls",
".",
"PREFIX",
"+",
"args"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/cache.py#L188-L200 | train |
zetaops/zengine | zengine/lib/cache.py | KeepAlive.update_or_expire_session | def update_or_expire_session(self):
"""
Deletes session if keepalive request expired
otherwise updates the keepalive timestamp value
"""
if not hasattr(self, 'key'):
return
now = time.time()
timestamp = float(self.get() or 0) or now
sess_id = s... | python | def update_or_expire_session(self):
"""
Deletes session if keepalive request expired
otherwise updates the keepalive timestamp value
"""
if not hasattr(self, 'key'):
return
now = time.time()
timestamp = float(self.get() or 0) or now
sess_id = s... | [
"def",
"update_or_expire_session",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'key'",
")",
":",
"return",
"now",
"=",
"time",
".",
"time",
"(",
")",
"timestamp",
"=",
"float",
"(",
"self",
".",
"get",
"(",
")",
"or",
"0",
")"... | Deletes session if keepalive request expired
otherwise updates the keepalive timestamp value | [
"Deletes",
"session",
"if",
"keepalive",
"request",
"expired",
"otherwise",
"updates",
"the",
"keepalive",
"timestamp",
"value"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/cache.py#L250-L265 | train |
zetaops/zengine | zengine/receivers.py | send_message_for_lane_change | def send_message_for_lane_change(sender, **kwargs):
"""
Sends a message to possible owners of the current workflows
next lane.
Args:
**kwargs: ``current`` and ``possible_owners`` are required.
sender (User): User object
"""
current = kwargs['current']
owners = kwargs['possi... | python | def send_message_for_lane_change(sender, **kwargs):
"""
Sends a message to possible owners of the current workflows
next lane.
Args:
**kwargs: ``current`` and ``possible_owners`` are required.
sender (User): User object
"""
current = kwargs['current']
owners = kwargs['possi... | [
"def",
"send_message_for_lane_change",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"current",
"=",
"kwargs",
"[",
"'current'",
"]",
"owners",
"=",
"kwargs",
"[",
"'possible_owners'",
"]",
"if",
"'lane_change_invite'",
"in",
"current",
".",
"task_data",
"... | Sends a message to possible owners of the current workflows
next lane.
Args:
**kwargs: ``current`` and ``possible_owners`` are required.
sender (User): User object | [
"Sends",
"a",
"message",
"to",
"possible",
"owners",
"of",
"the",
"current",
"workflows",
"next",
"lane",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/receivers.py#L29-L73 | train |
zetaops/zengine | zengine/receivers.py | set_password | def set_password(sender, **kwargs):
"""
Encrypts password of the user.
"""
if sender.model_class.__name__ == 'User':
usr = kwargs['object']
if not usr.password.startswith('$pbkdf2'):
usr.set_password(usr.password)
usr.save() | python | def set_password(sender, **kwargs):
"""
Encrypts password of the user.
"""
if sender.model_class.__name__ == 'User':
usr = kwargs['object']
if not usr.password.startswith('$pbkdf2'):
usr.set_password(usr.password)
usr.save() | [
"def",
"set_password",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"sender",
".",
"model_class",
".",
"__name__",
"==",
"'User'",
":",
"usr",
"=",
"kwargs",
"[",
"'object'",
"]",
"if",
"not",
"usr",
".",
"password",
".",
"startswith",
"(",
... | Encrypts password of the user. | [
"Encrypts",
"password",
"of",
"the",
"user",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/receivers.py#L78-L86 | train |
zetaops/zengine | zengine/views/channel_management.py | ChannelManagement.channel_list | def channel_list(self):
"""
Main screen for channel management.
Channels listed and operations can be chosen on the screen.
If there is an error message like non-choice,
it is shown here.
"""
if self.current.task_data.get('msg', False):
if self.curre... | python | def channel_list(self):
"""
Main screen for channel management.
Channels listed and operations can be chosen on the screen.
If there is an error message like non-choice,
it is shown here.
"""
if self.current.task_data.get('msg', False):
if self.curre... | [
"def",
"channel_list",
"(",
"self",
")",
":",
"if",
"self",
".",
"current",
".",
"task_data",
".",
"get",
"(",
"'msg'",
",",
"False",
")",
":",
"if",
"self",
".",
"current",
".",
"task_data",
".",
"get",
"(",
"'target_channel_key'",
",",
"False",
")",
... | Main screen for channel management.
Channels listed and operations can be chosen on the screen.
If there is an error message like non-choice,
it is shown here. | [
"Main",
"screen",
"for",
"channel",
"management",
".",
"Channels",
"listed",
"and",
"operations",
"can",
"be",
"chosen",
"on",
"the",
"screen",
".",
"If",
"there",
"is",
"an",
"error",
"message",
"like",
"non",
"-",
"choice",
"it",
"is",
"shown",
"here",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L57-L86 | train |
zetaops/zengine | zengine/views/channel_management.py | ChannelManagement.channel_choice_control | def channel_choice_control(self):
"""
It controls errors. If there is an error,
returns channel list screen with error message.
"""
self.current.task_data['control'], self.current.task_data['msg'] \
= self.selection_error_control(self.input['form'])
if self.cu... | python | def channel_choice_control(self):
"""
It controls errors. If there is an error,
returns channel list screen with error message.
"""
self.current.task_data['control'], self.current.task_data['msg'] \
= self.selection_error_control(self.input['form'])
if self.cu... | [
"def",
"channel_choice_control",
"(",
"self",
")",
":",
"self",
".",
"current",
".",
"task_data",
"[",
"'control'",
"]",
",",
"self",
".",
"current",
".",
"task_data",
"[",
"'msg'",
"]",
"=",
"self",
".",
"selection_error_control",
"(",
"self",
".",
"input... | It controls errors. If there is an error,
returns channel list screen with error message. | [
"It",
"controls",
"errors",
".",
"If",
"there",
"is",
"an",
"error",
"returns",
"channel",
"list",
"screen",
"with",
"error",
"message",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L88-L100 | train |
zetaops/zengine | zengine/views/channel_management.py | ChannelManagement.create_new_channel | def create_new_channel(self):
"""
Features of new channel are specified like channel's name, owner etc.
"""
self.current.task_data['new_channel'] = True
_form = NewChannelForm(Channel(), current=self.current)
_form.title = _(u"Specify Features of New Channel to Create")
... | python | def create_new_channel(self):
"""
Features of new channel are specified like channel's name, owner etc.
"""
self.current.task_data['new_channel'] = True
_form = NewChannelForm(Channel(), current=self.current)
_form.title = _(u"Specify Features of New Channel to Create")
... | [
"def",
"create_new_channel",
"(",
"self",
")",
":",
"self",
".",
"current",
".",
"task_data",
"[",
"'new_channel'",
"]",
"=",
"True",
"_form",
"=",
"NewChannelForm",
"(",
"Channel",
"(",
")",
",",
"current",
"=",
"self",
".",
"current",
")",
"_form",
"."... | Features of new channel are specified like channel's name, owner etc. | [
"Features",
"of",
"new",
"channel",
"are",
"specified",
"like",
"channel",
"s",
"name",
"owner",
"etc",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L102-L111 | train |
zetaops/zengine | zengine/views/channel_management.py | ChannelManagement.save_new_channel | def save_new_channel(self):
"""
It saves new channel according to specified channel features.
"""
form_info = self.input['form']
channel = Channel(typ=15, name=form_info['name'],
description=form_info['description'],
owner_id=f... | python | def save_new_channel(self):
"""
It saves new channel according to specified channel features.
"""
form_info = self.input['form']
channel = Channel(typ=15, name=form_info['name'],
description=form_info['description'],
owner_id=f... | [
"def",
"save_new_channel",
"(",
"self",
")",
":",
"form_info",
"=",
"self",
".",
"input",
"[",
"'form'",
"]",
"channel",
"=",
"Channel",
"(",
"typ",
"=",
"15",
",",
"name",
"=",
"form_info",
"[",
"'name'",
"]",
",",
"description",
"=",
"form_info",
"["... | It saves new channel according to specified channel features. | [
"It",
"saves",
"new",
"channel",
"according",
"to",
"specified",
"channel",
"features",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L113-L123 | train |
zetaops/zengine | zengine/views/channel_management.py | ChannelManagement.choose_existing_channel | def choose_existing_channel(self):
"""
It is a channel choice list and chosen channels
at previous step shouldn't be on the screen.
"""
if self.current.task_data.get('msg', False):
self.show_warning_messages()
_form = ChannelListForm()
_form.title = ... | python | def choose_existing_channel(self):
"""
It is a channel choice list and chosen channels
at previous step shouldn't be on the screen.
"""
if self.current.task_data.get('msg', False):
self.show_warning_messages()
_form = ChannelListForm()
_form.title = ... | [
"def",
"choose_existing_channel",
"(",
"self",
")",
":",
"if",
"self",
".",
"current",
".",
"task_data",
".",
"get",
"(",
"'msg'",
",",
"False",
")",
":",
"self",
".",
"show_warning_messages",
"(",
")",
"_form",
"=",
"ChannelListForm",
"(",
")",
"_form",
... | It is a channel choice list and chosen channels
at previous step shouldn't be on the screen. | [
"It",
"is",
"a",
"channel",
"choice",
"list",
"and",
"chosen",
"channels",
"at",
"previous",
"step",
"shouldn",
"t",
"be",
"on",
"the",
"screen",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L125-L144 | train |
zetaops/zengine | zengine/views/channel_management.py | ChannelManagement.existing_choice_control | def existing_choice_control(self):
"""
It controls errors. It generates an error message
if zero or more than one channels are selected.
"""
self.current.task_data['existing'] = False
self.current.task_data['msg'] = _(u"You should choose just one channel to do operation."... | python | def existing_choice_control(self):
"""
It controls errors. It generates an error message
if zero or more than one channels are selected.
"""
self.current.task_data['existing'] = False
self.current.task_data['msg'] = _(u"You should choose just one channel to do operation."... | [
"def",
"existing_choice_control",
"(",
"self",
")",
":",
"self",
".",
"current",
".",
"task_data",
"[",
"'existing'",
"]",
"=",
"False",
"self",
".",
"current",
".",
"task_data",
"[",
"'msg'",
"]",
"=",
"_",
"(",
"u\"You should choose just one channel to do oper... | It controls errors. It generates an error message
if zero or more than one channels are selected. | [
"It",
"controls",
"errors",
".",
"It",
"generates",
"an",
"error",
"message",
"if",
"zero",
"or",
"more",
"than",
"one",
"channels",
"are",
"selected",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L146-L156 | train |
zetaops/zengine | zengine/views/channel_management.py | ChannelManagement.split_channel | def split_channel(self):
"""
A channel can be splitted to new channel or other existing channel.
It creates subscribers list as selectable to moved.
"""
if self.current.task_data.get('msg', False):
self.show_warning_messages()
self.current.task_data['split_o... | python | def split_channel(self):
"""
A channel can be splitted to new channel or other existing channel.
It creates subscribers list as selectable to moved.
"""
if self.current.task_data.get('msg', False):
self.show_warning_messages()
self.current.task_data['split_o... | [
"def",
"split_channel",
"(",
"self",
")",
":",
"if",
"self",
".",
"current",
".",
"task_data",
".",
"get",
"(",
"'msg'",
",",
"False",
")",
":",
"self",
".",
"show_warning_messages",
"(",
")",
"self",
".",
"current",
".",
"task_data",
"[",
"'split_operat... | A channel can be splitted to new channel or other existing channel.
It creates subscribers list as selectable to moved. | [
"A",
"channel",
"can",
"be",
"splitted",
"to",
"new",
"channel",
"or",
"other",
"existing",
"channel",
".",
"It",
"creates",
"subscribers",
"list",
"as",
"selectable",
"to",
"moved",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L158-L179 | train |
zetaops/zengine | zengine/views/channel_management.py | ChannelManagement.subscriber_choice_control | def subscriber_choice_control(self):
"""
It controls subscribers choice and generates
error message if there is a non-choice.
"""
self.current.task_data['option'] = None
self.current.task_data['chosen_subscribers'], names = self.return_selected_form_items(
sel... | python | def subscriber_choice_control(self):
"""
It controls subscribers choice and generates
error message if there is a non-choice.
"""
self.current.task_data['option'] = None
self.current.task_data['chosen_subscribers'], names = self.return_selected_form_items(
sel... | [
"def",
"subscriber_choice_control",
"(",
"self",
")",
":",
"self",
".",
"current",
".",
"task_data",
"[",
"'option'",
"]",
"=",
"None",
"self",
".",
"current",
".",
"task_data",
"[",
"'chosen_subscribers'",
"]",
",",
"names",
"=",
"self",
".",
"return_select... | It controls subscribers choice and generates
error message if there is a non-choice. | [
"It",
"controls",
"subscribers",
"choice",
"and",
"generates",
"error",
"message",
"if",
"there",
"is",
"a",
"non",
"-",
"choice",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L181-L193 | train |
zetaops/zengine | zengine/views/channel_management.py | ChannelManagement.move_complete_channel | def move_complete_channel(self):
"""
Channels and theirs subscribers are moved
completely to new channel or existing channel.
"""
to_channel = Channel.objects.get(self.current.task_data['target_channel_key'])
chosen_channels = self.current.task_data['chosen_channels']
... | python | def move_complete_channel(self):
"""
Channels and theirs subscribers are moved
completely to new channel or existing channel.
"""
to_channel = Channel.objects.get(self.current.task_data['target_channel_key'])
chosen_channels = self.current.task_data['chosen_channels']
... | [
"def",
"move_complete_channel",
"(",
"self",
")",
":",
"to_channel",
"=",
"Channel",
".",
"objects",
".",
"get",
"(",
"self",
".",
"current",
".",
"task_data",
"[",
"'target_channel_key'",
"]",
")",
"chosen_channels",
"=",
"self",
".",
"current",
".",
"task_... | Channels and theirs subscribers are moved
completely to new channel or existing channel. | [
"Channels",
"and",
"theirs",
"subscribers",
"are",
"moved",
"completely",
"to",
"new",
"channel",
"or",
"existing",
"channel",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L195-L218 | train |
zetaops/zengine | zengine/views/channel_management.py | ChannelManagement.move_chosen_subscribers | def move_chosen_subscribers(self):
"""
After splitting operation, only chosen subscribers
are moved to new channel or existing channel.
"""
from_channel = Channel.objects.get(self.current.task_data['chosen_channels'][0])
to_channel = Channel.objects.get(self.current.task_... | python | def move_chosen_subscribers(self):
"""
After splitting operation, only chosen subscribers
are moved to new channel or existing channel.
"""
from_channel = Channel.objects.get(self.current.task_data['chosen_channels'][0])
to_channel = Channel.objects.get(self.current.task_... | [
"def",
"move_chosen_subscribers",
"(",
"self",
")",
":",
"from_channel",
"=",
"Channel",
".",
"objects",
".",
"get",
"(",
"self",
".",
"current",
".",
"task_data",
"[",
"'chosen_channels'",
"]",
"[",
"0",
"]",
")",
"to_channel",
"=",
"Channel",
".",
"objec... | After splitting operation, only chosen subscribers
are moved to new channel or existing channel. | [
"After",
"splitting",
"operation",
"only",
"chosen",
"subscribers",
"are",
"moved",
"to",
"new",
"channel",
"or",
"existing",
"channel",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L220-L239 | train |
zetaops/zengine | zengine/views/channel_management.py | ChannelManagement.copy_and_move_messages | def copy_and_move_messages(from_channel, to_channel):
"""
While splitting channel and moving chosen subscribers to new channel,
old channel's messages are copied and moved to new channel.
Args:
from_channel (Channel object): move messages from channel
to_chann... | python | def copy_and_move_messages(from_channel, to_channel):
"""
While splitting channel and moving chosen subscribers to new channel,
old channel's messages are copied and moved to new channel.
Args:
from_channel (Channel object): move messages from channel
to_chann... | [
"def",
"copy_and_move_messages",
"(",
"from_channel",
",",
"to_channel",
")",
":",
"with",
"BlockSave",
"(",
"Message",
",",
"query_dict",
"=",
"{",
"'channel_id'",
":",
"to_channel",
".",
"key",
"}",
")",
":",
"for",
"message",
"in",
"Message",
".",
"object... | While splitting channel and moving chosen subscribers to new channel,
old channel's messages are copied and moved to new channel.
Args:
from_channel (Channel object): move messages from channel
to_channel (Channel object): move messages to channel | [
"While",
"splitting",
"channel",
"and",
"moving",
"chosen",
"subscribers",
"to",
"new",
"channel",
"old",
"channel",
"s",
"messages",
"are",
"copied",
"and",
"moved",
"to",
"new",
"channel",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L242-L255 | train |
zetaops/zengine | zengine/views/channel_management.py | ChannelManagement.show_warning_messages | def show_warning_messages(self, title=_(u"Incorrect Operation"), box_type='warning'):
"""
It shows incorrect operations or successful operation messages.
Args:
title (string): title of message box
box_type (string): type of message box (warning, info)
"""
... | python | def show_warning_messages(self, title=_(u"Incorrect Operation"), box_type='warning'):
"""
It shows incorrect operations or successful operation messages.
Args:
title (string): title of message box
box_type (string): type of message box (warning, info)
"""
... | [
"def",
"show_warning_messages",
"(",
"self",
",",
"title",
"=",
"_",
"(",
"u\"Incorrect Operation\"",
")",
",",
"box_type",
"=",
"'warning'",
")",
":",
"msg",
"=",
"self",
".",
"current",
".",
"task_data",
"[",
"'msg'",
"]",
"self",
".",
"current",
".",
... | It shows incorrect operations or successful operation messages.
Args:
title (string): title of message box
box_type (string): type of message box (warning, info) | [
"It",
"shows",
"incorrect",
"operations",
"or",
"successful",
"operation",
"messages",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L257-L267 | train |
zetaops/zengine | zengine/views/channel_management.py | ChannelManagement.return_selected_form_items | def return_selected_form_items(form_info):
"""
It returns chosen keys list from a given form.
Args:
form_info: serialized list of dict form data
Returns:
selected_keys(list): Chosen keys list
selected_names(list): Chosen channels' or subscribers' name... | python | def return_selected_form_items(form_info):
"""
It returns chosen keys list from a given form.
Args:
form_info: serialized list of dict form data
Returns:
selected_keys(list): Chosen keys list
selected_names(list): Chosen channels' or subscribers' name... | [
"def",
"return_selected_form_items",
"(",
"form_info",
")",
":",
"selected_keys",
"=",
"[",
"]",
"selected_names",
"=",
"[",
"]",
"for",
"chosen",
"in",
"form_info",
":",
"if",
"chosen",
"[",
"'choice'",
"]",
":",
"selected_keys",
".",
"append",
"(",
"chosen... | It returns chosen keys list from a given form.
Args:
form_info: serialized list of dict form data
Returns:
selected_keys(list): Chosen keys list
selected_names(list): Chosen channels' or subscribers' names. | [
"It",
"returns",
"chosen",
"keys",
"list",
"from",
"a",
"given",
"form",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L270-L287 | train |
zetaops/zengine | zengine/views/channel_management.py | ChannelManagement.selection_error_control | def selection_error_control(self, form_info):
"""
It controls the selection from the form according
to the operations, and returns an error message
if it does not comply with the rules.
Args:
form_info: Channel or subscriber form from the user
Returns: True ... | python | def selection_error_control(self, form_info):
"""
It controls the selection from the form according
to the operations, and returns an error message
if it does not comply with the rules.
Args:
form_info: Channel or subscriber form from the user
Returns: True ... | [
"def",
"selection_error_control",
"(",
"self",
",",
"form_info",
")",
":",
"keys",
",",
"names",
"=",
"self",
".",
"return_selected_form_items",
"(",
"form_info",
"[",
"'ChannelList'",
"]",
")",
"chosen_channels_number",
"=",
"len",
"(",
"keys",
")",
"if",
"fo... | It controls the selection from the form according
to the operations, and returns an error message
if it does not comply with the rules.
Args:
form_info: Channel or subscriber form from the user
Returns: True or False
error message | [
"It",
"controls",
"the",
"selection",
"from",
"the",
"form",
"according",
"to",
"the",
"operations",
"and",
"returns",
"an",
"error",
"message",
"if",
"it",
"does",
"not",
"comply",
"with",
"the",
"rules",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/channel_management.py#L289-L314 | train |
cimm-kzn/CGRtools | CGRtools/algorithms/morgan.py | _eratosthenes | def _eratosthenes():
"""Yields the sequence of prime numbers via the Sieve of Eratosthenes."""
d = {} # map each composite integer to its first-found prime factor
for q in count(2): # q gets 2, 3, 4, 5, ... ad infinitum
p = d.pop(q, None)
if p is None:
# q not a key in D, so q ... | python | def _eratosthenes():
"""Yields the sequence of prime numbers via the Sieve of Eratosthenes."""
d = {} # map each composite integer to its first-found prime factor
for q in count(2): # q gets 2, 3, 4, 5, ... ad infinitum
p = d.pop(q, None)
if p is None:
# q not a key in D, so q ... | [
"def",
"_eratosthenes",
"(",
")",
":",
"d",
"=",
"{",
"}",
"# map each composite integer to its first-found prime factor",
"for",
"q",
"in",
"count",
"(",
"2",
")",
":",
"# q gets 2, 3, 4, 5, ... ad infinitum",
"p",
"=",
"d",
".",
"pop",
"(",
"q",
",",
"None",
... | Yields the sequence of prime numbers via the Sieve of Eratosthenes. | [
"Yields",
"the",
"sequence",
"of",
"prime",
"numbers",
"via",
"the",
"Sieve",
"of",
"Eratosthenes",
"."
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/morgan.py#L88-L105 | train |
cimm-kzn/CGRtools | CGRtools/algorithms/morgan.py | Morgan.atoms_order | def atoms_order(self):
"""
Morgan like algorithm for graph nodes ordering
:return: dict of atom-weight pairs
"""
if not len(self): # for empty containers
return {}
elif len(self) == 1: # optimize single atom containers
return dict.fromkeys(self,... | python | def atoms_order(self):
"""
Morgan like algorithm for graph nodes ordering
:return: dict of atom-weight pairs
"""
if not len(self): # for empty containers
return {}
elif len(self) == 1: # optimize single atom containers
return dict.fromkeys(self,... | [
"def",
"atoms_order",
"(",
"self",
")",
":",
"if",
"not",
"len",
"(",
"self",
")",
":",
"# for empty containers",
"return",
"{",
"}",
"elif",
"len",
"(",
"self",
")",
"==",
"1",
":",
"# optimize single atom containers",
"return",
"dict",
".",
"fromkeys",
"... | Morgan like algorithm for graph nodes ordering
:return: dict of atom-weight pairs | [
"Morgan",
"like",
"algorithm",
"for",
"graph",
"nodes",
"ordering"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/morgan.py#L29-L85 | train |
LordDarkula/chess_py | chess_py/pieces/piece_const.py | PieceValues.init_manual | def init_manual(cls, pawn_value, knight_value, bishop_value, rook_value, queen_value, king_value):
"""
Manual init method for external piece values
:type: PAWN_VALUE: int
:type: KNIGHT_VALUE: int
:type: BISHOP_VALUE: int
:type: ROOK_VALUE: int
:type: QUEEN_VALUE:... | python | def init_manual(cls, pawn_value, knight_value, bishop_value, rook_value, queen_value, king_value):
"""
Manual init method for external piece values
:type: PAWN_VALUE: int
:type: KNIGHT_VALUE: int
:type: BISHOP_VALUE: int
:type: ROOK_VALUE: int
:type: QUEEN_VALUE:... | [
"def",
"init_manual",
"(",
"cls",
",",
"pawn_value",
",",
"knight_value",
",",
"bishop_value",
",",
"rook_value",
",",
"queen_value",
",",
"king_value",
")",
":",
"piece_values",
"=",
"cls",
"(",
")",
"piece_values",
".",
"PAWN_VALUE",
"=",
"pawn_value",
"piec... | Manual init method for external piece values
:type: PAWN_VALUE: int
:type: KNIGHT_VALUE: int
:type: BISHOP_VALUE: int
:type: ROOK_VALUE: int
:type: QUEEN_VALUE: int | [
"Manual",
"init",
"method",
"for",
"external",
"piece",
"values"
] | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/piece_const.py#L27-L44 | train |
LordDarkula/chess_py | chess_py/pieces/piece_const.py | PieceValues.val | def val(self, piece, ref_color):
"""
Finds value of ``Piece``
:type: piece: Piece
:type: ref_color: Color
:rtype: int
"""
if piece is None:
return 0
if ref_color == piece.color:
const = 1
else:
const = -1
... | python | def val(self, piece, ref_color):
"""
Finds value of ``Piece``
:type: piece: Piece
:type: ref_color: Color
:rtype: int
"""
if piece is None:
return 0
if ref_color == piece.color:
const = 1
else:
const = -1
... | [
"def",
"val",
"(",
"self",
",",
"piece",
",",
"ref_color",
")",
":",
"if",
"piece",
"is",
"None",
":",
"return",
"0",
"if",
"ref_color",
"==",
"piece",
".",
"color",
":",
"const",
"=",
"1",
"else",
":",
"const",
"=",
"-",
"1",
"if",
"isinstance",
... | Finds value of ``Piece``
:type: piece: Piece
:type: ref_color: Color
:rtype: int | [
"Finds",
"value",
"of",
"Piece"
] | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/piece_const.py#L46-L74 | train |
LordDarkula/chess_py | chess_py/game/game.py | Game.play | def play(self):
"""
Starts game and returns one of 3 results .
Iterates between methods ``white_move()`` and
``black_move()`` until game ends. Each
method calls the respective player's ``generate_move()``
method.
:rtype: int
"""
colors = [lambda:... | python | def play(self):
"""
Starts game and returns one of 3 results .
Iterates between methods ``white_move()`` and
``black_move()`` until game ends. Each
method calls the respective player's ``generate_move()``
method.
:rtype: int
"""
colors = [lambda:... | [
"def",
"play",
"(",
"self",
")",
":",
"colors",
"=",
"[",
"lambda",
":",
"self",
".",
"white_move",
"(",
")",
",",
"lambda",
":",
"self",
".",
"black_move",
"(",
")",
"]",
"colors",
"=",
"itertools",
".",
"cycle",
"(",
"colors",
")",
"while",
"True... | Starts game and returns one of 3 results .
Iterates between methods ``white_move()`` and
``black_move()`` until game ends. Each
method calls the respective player's ``generate_move()``
method.
:rtype: int | [
"Starts",
"game",
"and",
"returns",
"one",
"of",
"3",
"results",
".",
"Iterates",
"between",
"methods",
"white_move",
"()",
"and",
"black_move",
"()",
"until",
"game",
"ends",
".",
"Each",
"method",
"calls",
"the",
"respective",
"player",
"s",
"generate_move",... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/game/game.py#L39-L64 | train |
LordDarkula/chess_py | chess_py/game/game.py | Game.white_move | def white_move(self):
"""
Calls the white player's ``generate_move()``
method and updates the board with the move returned.
"""
move = self.player_white.generate_move(self.position)
move = make_legal(move, self.position)
self.position.update(move) | python | def white_move(self):
"""
Calls the white player's ``generate_move()``
method and updates the board with the move returned.
"""
move = self.player_white.generate_move(self.position)
move = make_legal(move, self.position)
self.position.update(move) | [
"def",
"white_move",
"(",
"self",
")",
":",
"move",
"=",
"self",
".",
"player_white",
".",
"generate_move",
"(",
"self",
".",
"position",
")",
"move",
"=",
"make_legal",
"(",
"move",
",",
"self",
".",
"position",
")",
"self",
".",
"position",
".",
"upd... | Calls the white player's ``generate_move()``
method and updates the board with the move returned. | [
"Calls",
"the",
"white",
"player",
"s",
"generate_move",
"()",
"method",
"and",
"updates",
"the",
"board",
"with",
"the",
"move",
"returned",
"."
] | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/game/game.py#L66-L73 | train |
LordDarkula/chess_py | chess_py/game/game.py | Game.black_move | def black_move(self):
"""
Calls the black player's ``generate_move()``
method and updates the board with the move returned.
"""
move = self.player_black.generate_move(self.position)
move = make_legal(move, self.position)
self.position.update(move) | python | def black_move(self):
"""
Calls the black player's ``generate_move()``
method and updates the board with the move returned.
"""
move = self.player_black.generate_move(self.position)
move = make_legal(move, self.position)
self.position.update(move) | [
"def",
"black_move",
"(",
"self",
")",
":",
"move",
"=",
"self",
".",
"player_black",
".",
"generate_move",
"(",
"self",
".",
"position",
")",
"move",
"=",
"make_legal",
"(",
"move",
",",
"self",
".",
"position",
")",
"self",
".",
"position",
".",
"upd... | Calls the black player's ``generate_move()``
method and updates the board with the move returned. | [
"Calls",
"the",
"black",
"player",
"s",
"generate_move",
"()",
"method",
"and",
"updates",
"the",
"board",
"with",
"the",
"move",
"returned",
"."
] | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/game/game.py#L75-L82 | train |
rfarley3/Kibana | kibana/mapping.py | KibanaMapping.get_field_cache | def get_field_cache(self, cache_type='es'):
"""Return a list of fields' mappings"""
if cache_type == 'kibana':
try:
search_results = urlopen(self.get_url).read().decode('utf-8')
except HTTPError: # as e:
# self.pr_err("get_field_cache(kibana), HTT... | python | def get_field_cache(self, cache_type='es'):
"""Return a list of fields' mappings"""
if cache_type == 'kibana':
try:
search_results = urlopen(self.get_url).read().decode('utf-8')
except HTTPError: # as e:
# self.pr_err("get_field_cache(kibana), HTT... | [
"def",
"get_field_cache",
"(",
"self",
",",
"cache_type",
"=",
"'es'",
")",
":",
"if",
"cache_type",
"==",
"'kibana'",
":",
"try",
":",
"search_results",
"=",
"urlopen",
"(",
"self",
".",
"get_url",
")",
".",
"read",
"(",
")",
".",
"decode",
"(",
"'utf... | Return a list of fields' mappings | [
"Return",
"a",
"list",
"of",
"fields",
"mappings"
] | 3df1e13be18edfb39ec173d8d2bbe9e90be61022 | https://github.com/rfarley3/Kibana/blob/3df1e13be18edfb39ec173d8d2bbe9e90be61022/kibana/mapping.py#L96-L125 | train |
rfarley3/Kibana | kibana/mapping.py | KibanaMapping.post_field_cache | def post_field_cache(self, field_cache):
"""Where field_cache is a list of fields' mappings"""
index_pattern = self.field_cache_to_index_pattern(field_cache)
# self.pr_dbg("request/post: %s" % index_pattern)
resp = requests.post(self.post_url, data=index_pattern).text
# resp = {"... | python | def post_field_cache(self, field_cache):
"""Where field_cache is a list of fields' mappings"""
index_pattern = self.field_cache_to_index_pattern(field_cache)
# self.pr_dbg("request/post: %s" % index_pattern)
resp = requests.post(self.post_url, data=index_pattern).text
# resp = {"... | [
"def",
"post_field_cache",
"(",
"self",
",",
"field_cache",
")",
":",
"index_pattern",
"=",
"self",
".",
"field_cache_to_index_pattern",
"(",
"field_cache",
")",
"# self.pr_dbg(\"request/post: %s\" % index_pattern)",
"resp",
"=",
"requests",
".",
"post",
"(",
"self",
... | Where field_cache is a list of fields' mappings | [
"Where",
"field_cache",
"is",
"a",
"list",
"of",
"fields",
"mappings"
] | 3df1e13be18edfb39ec173d8d2bbe9e90be61022 | https://github.com/rfarley3/Kibana/blob/3df1e13be18edfb39ec173d8d2bbe9e90be61022/kibana/mapping.py#L142-L149 | train |
rfarley3/Kibana | kibana/mapping.py | KibanaMapping.field_cache_to_index_pattern | def field_cache_to_index_pattern(self, field_cache):
"""Return a .kibana index-pattern doc_type"""
mapping_dict = {}
mapping_dict['customFormats'] = "{}"
mapping_dict['title'] = self.index_pattern
# now post the data into .kibana
mapping_dict['fields'] = json.dumps(field_... | python | def field_cache_to_index_pattern(self, field_cache):
"""Return a .kibana index-pattern doc_type"""
mapping_dict = {}
mapping_dict['customFormats'] = "{}"
mapping_dict['title'] = self.index_pattern
# now post the data into .kibana
mapping_dict['fields'] = json.dumps(field_... | [
"def",
"field_cache_to_index_pattern",
"(",
"self",
",",
"field_cache",
")",
":",
"mapping_dict",
"=",
"{",
"}",
"mapping_dict",
"[",
"'customFormats'",
"]",
"=",
"\"{}\"",
"mapping_dict",
"[",
"'title'",
"]",
"=",
"self",
".",
"index_pattern",
"# now post the dat... | Return a .kibana index-pattern doc_type | [
"Return",
"a",
".",
"kibana",
"index",
"-",
"pattern",
"doc_type"
] | 3df1e13be18edfb39ec173d8d2bbe9e90be61022 | https://github.com/rfarley3/Kibana/blob/3df1e13be18edfb39ec173d8d2bbe9e90be61022/kibana/mapping.py#L152-L161 | train |
rfarley3/Kibana | kibana/mapping.py | KibanaMapping.check_mapping | def check_mapping(self, m):
"""Assert minimum set of fields in cache, does not validate contents"""
if 'name' not in m:
self.pr_dbg("Missing %s" % "name")
return False
# self.pr_dbg("Checking %s" % m['name'])
for x in ['analyzed', 'indexed', 'type', 'scripted', 'c... | python | def check_mapping(self, m):
"""Assert minimum set of fields in cache, does not validate contents"""
if 'name' not in m:
self.pr_dbg("Missing %s" % "name")
return False
# self.pr_dbg("Checking %s" % m['name'])
for x in ['analyzed', 'indexed', 'type', 'scripted', 'c... | [
"def",
"check_mapping",
"(",
"self",
",",
"m",
")",
":",
"if",
"'name'",
"not",
"in",
"m",
":",
"self",
".",
"pr_dbg",
"(",
"\"Missing %s\"",
"%",
"\"name\"",
")",
"return",
"False",
"# self.pr_dbg(\"Checking %s\" % m['name'])",
"for",
"x",
"in",
"[",
"'anal... | Assert minimum set of fields in cache, does not validate contents | [
"Assert",
"minimum",
"set",
"of",
"fields",
"in",
"cache",
"does",
"not",
"validate",
"contents"
] | 3df1e13be18edfb39ec173d8d2bbe9e90be61022 | https://github.com/rfarley3/Kibana/blob/3df1e13be18edfb39ec173d8d2bbe9e90be61022/kibana/mapping.py#L163-L179 | train |
rfarley3/Kibana | kibana/mapping.py | KibanaMapping.get_index_mappings | def get_index_mappings(self, index):
"""Converts all index's doc_types to .kibana"""
fields_arr = []
for (key, val) in iteritems(index):
# self.pr_dbg("\tdoc_type: %s" % key)
doc_mapping = self.get_doc_type_mappings(index[key])
# self.pr_dbg("\tdoc_mapping: %s... | python | def get_index_mappings(self, index):
"""Converts all index's doc_types to .kibana"""
fields_arr = []
for (key, val) in iteritems(index):
# self.pr_dbg("\tdoc_type: %s" % key)
doc_mapping = self.get_doc_type_mappings(index[key])
# self.pr_dbg("\tdoc_mapping: %s... | [
"def",
"get_index_mappings",
"(",
"self",
",",
"index",
")",
":",
"fields_arr",
"=",
"[",
"]",
"for",
"(",
"key",
",",
"val",
")",
"in",
"iteritems",
"(",
"index",
")",
":",
"# self.pr_dbg(\"\\tdoc_type: %s\" % key)",
"doc_mapping",
"=",
"self",
".",
"get_do... | Converts all index's doc_types to .kibana | [
"Converts",
"all",
"index",
"s",
"doc_types",
"to",
".",
"kibana"
] | 3df1e13be18edfb39ec173d8d2bbe9e90be61022 | https://github.com/rfarley3/Kibana/blob/3df1e13be18edfb39ec173d8d2bbe9e90be61022/kibana/mapping.py#L181-L192 | train |
rfarley3/Kibana | kibana/mapping.py | KibanaMapping.get_doc_type_mappings | def get_doc_type_mappings(self, doc_type):
"""Converts all doc_types' fields to .kibana"""
doc_fields_arr = []
found_score = False
for (key, val) in iteritems(doc_type):
# self.pr_dbg("\t\tfield: %s" % key)
# self.pr_dbg("\tval: %s" % val)
add_it = Fal... | python | def get_doc_type_mappings(self, doc_type):
"""Converts all doc_types' fields to .kibana"""
doc_fields_arr = []
found_score = False
for (key, val) in iteritems(doc_type):
# self.pr_dbg("\t\tfield: %s" % key)
# self.pr_dbg("\tval: %s" % val)
add_it = Fal... | [
"def",
"get_doc_type_mappings",
"(",
"self",
",",
"doc_type",
")",
":",
"doc_fields_arr",
"=",
"[",
"]",
"found_score",
"=",
"False",
"for",
"(",
"key",
",",
"val",
")",
"in",
"iteritems",
"(",
"doc_type",
")",
":",
"# self.pr_dbg(\"\\t\\tfield: %s\" % key)",
... | Converts all doc_types' fields to .kibana | [
"Converts",
"all",
"doc_types",
"fields",
"to",
".",
"kibana"
] | 3df1e13be18edfb39ec173d8d2bbe9e90be61022 | https://github.com/rfarley3/Kibana/blob/3df1e13be18edfb39ec173d8d2bbe9e90be61022/kibana/mapping.py#L194-L254 | train |
rfarley3/Kibana | kibana/mapping.py | KibanaMapping.get_field_mappings | def get_field_mappings(self, field):
"""Converts ES field mappings to .kibana field mappings"""
retdict = {}
retdict['indexed'] = False
retdict['analyzed'] = False
for (key, val) in iteritems(field):
if key in self.mappings:
if (key == 'type' and
... | python | def get_field_mappings(self, field):
"""Converts ES field mappings to .kibana field mappings"""
retdict = {}
retdict['indexed'] = False
retdict['analyzed'] = False
for (key, val) in iteritems(field):
if key in self.mappings:
if (key == 'type' and
... | [
"def",
"get_field_mappings",
"(",
"self",
",",
"field",
")",
":",
"retdict",
"=",
"{",
"}",
"retdict",
"[",
"'indexed'",
"]",
"=",
"False",
"retdict",
"[",
"'analyzed'",
"]",
"=",
"False",
"for",
"(",
"key",
",",
"val",
")",
"in",
"iteritems",
"(",
"... | Converts ES field mappings to .kibana field mappings | [
"Converts",
"ES",
"field",
"mappings",
"to",
".",
"kibana",
"field",
"mappings"
] | 3df1e13be18edfb39ec173d8d2bbe9e90be61022 | https://github.com/rfarley3/Kibana/blob/3df1e13be18edfb39ec173d8d2bbe9e90be61022/kibana/mapping.py#L256-L278 | train |
rfarley3/Kibana | kibana/mapping.py | KibanaMapping.is_kibana_cache_incomplete | def is_kibana_cache_incomplete(self, es_cache, k_cache):
"""Test if k_cache is incomplete
Assume k_cache is always correct, but could be missing new
fields that es_cache has
"""
# convert list into dict, with each item's ['name'] as key
k_dict = {}
for field in k... | python | def is_kibana_cache_incomplete(self, es_cache, k_cache):
"""Test if k_cache is incomplete
Assume k_cache is always correct, but could be missing new
fields that es_cache has
"""
# convert list into dict, with each item's ['name'] as key
k_dict = {}
for field in k... | [
"def",
"is_kibana_cache_incomplete",
"(",
"self",
",",
"es_cache",
",",
"k_cache",
")",
":",
"# convert list into dict, with each item's ['name'] as key",
"k_dict",
"=",
"{",
"}",
"for",
"field",
"in",
"k_cache",
":",
"# self.pr_dbg(\"field: %s\" % field)",
"k_dict",
"[",... | Test if k_cache is incomplete
Assume k_cache is always correct, but could be missing new
fields that es_cache has | [
"Test",
"if",
"k_cache",
"is",
"incomplete"
] | 3df1e13be18edfb39ec173d8d2bbe9e90be61022 | https://github.com/rfarley3/Kibana/blob/3df1e13be18edfb39ec173d8d2bbe9e90be61022/kibana/mapping.py#L310-L339 | train |
rfarley3/Kibana | kibana/mapping.py | KibanaMapping.list_to_compare_dict | def list_to_compare_dict(self, list_form):
"""Convert list into a data structure we can query easier"""
compare_dict = {}
for field in list_form:
if field['name'] in compare_dict:
self.pr_dbg("List has duplicate field %s:\n%s" %
(field['nam... | python | def list_to_compare_dict(self, list_form):
"""Convert list into a data structure we can query easier"""
compare_dict = {}
for field in list_form:
if field['name'] in compare_dict:
self.pr_dbg("List has duplicate field %s:\n%s" %
(field['nam... | [
"def",
"list_to_compare_dict",
"(",
"self",
",",
"list_form",
")",
":",
"compare_dict",
"=",
"{",
"}",
"for",
"field",
"in",
"list_form",
":",
"if",
"field",
"[",
"'name'",
"]",
"in",
"compare_dict",
":",
"self",
".",
"pr_dbg",
"(",
"\"List has duplicate fie... | Convert list into a data structure we can query easier | [
"Convert",
"list",
"into",
"a",
"data",
"structure",
"we",
"can",
"query",
"easier"
] | 3df1e13be18edfb39ec173d8d2bbe9e90be61022 | https://github.com/rfarley3/Kibana/blob/3df1e13be18edfb39ec173d8d2bbe9e90be61022/kibana/mapping.py#L341-L354 | train |
rfarley3/Kibana | kibana/mapping.py | KibanaMapping.compare_field_caches | def compare_field_caches(self, replica, original):
"""Verify original is subset of replica"""
if original is None:
original = []
if replica is None:
replica = []
self.pr_dbg("Comparing orig with %s fields to replica with %s fields" %
(len(origi... | python | def compare_field_caches(self, replica, original):
"""Verify original is subset of replica"""
if original is None:
original = []
if replica is None:
replica = []
self.pr_dbg("Comparing orig with %s fields to replica with %s fields" %
(len(origi... | [
"def",
"compare_field_caches",
"(",
"self",
",",
"replica",
",",
"original",
")",
":",
"if",
"original",
"is",
"None",
":",
"original",
"=",
"[",
"]",
"if",
"replica",
"is",
"None",
":",
"replica",
"=",
"[",
"]",
"self",
".",
"pr_dbg",
"(",
"\"Comparin... | Verify original is subset of replica | [
"Verify",
"original",
"is",
"subset",
"of",
"replica"
] | 3df1e13be18edfb39ec173d8d2bbe9e90be61022 | https://github.com/rfarley3/Kibana/blob/3df1e13be18edfb39ec173d8d2bbe9e90be61022/kibana/mapping.py#L356-L400 | train |
deep-compute/logagg | logagg/util.py | start_daemon_thread | def start_daemon_thread(target, args=()):
"""starts a deamon thread for a given target function and arguments."""
th = Thread(target=target, args=args)
th.daemon = True
th.start()
return th | python | def start_daemon_thread(target, args=()):
"""starts a deamon thread for a given target function and arguments."""
th = Thread(target=target, args=args)
th.daemon = True
th.start()
return th | [
"def",
"start_daemon_thread",
"(",
"target",
",",
"args",
"=",
"(",
")",
")",
":",
"th",
"=",
"Thread",
"(",
"target",
"=",
"target",
",",
"args",
"=",
"args",
")",
"th",
".",
"daemon",
"=",
"True",
"th",
".",
"start",
"(",
")",
"return",
"th"
] | starts a deamon thread for a given target function and arguments. | [
"starts",
"a",
"deamon",
"thread",
"for",
"a",
"given",
"target",
"function",
"and",
"arguments",
"."
] | 7863bc1b5ddf3e67c4d4b55746799304180589a0 | https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/util.py#L45-L50 | train |
deep-compute/logagg | logagg/util.py | serialize_dict_keys | def serialize_dict_keys(d, prefix=""):
"""returns all the keys in a dictionary.
>>> serialize_dict_keys({"a": {"b": {"c": 1, "b": 2} } })
['a', 'a.b', 'a.b.c', 'a.b.b']
"""
keys = []
for k, v in d.iteritems():
fqk = '%s%s' % (prefix, k)
keys.append(fqk)
if isinstance(v, ... | python | def serialize_dict_keys(d, prefix=""):
"""returns all the keys in a dictionary.
>>> serialize_dict_keys({"a": {"b": {"c": 1, "b": 2} } })
['a', 'a.b', 'a.b.c', 'a.b.b']
"""
keys = []
for k, v in d.iteritems():
fqk = '%s%s' % (prefix, k)
keys.append(fqk)
if isinstance(v, ... | [
"def",
"serialize_dict_keys",
"(",
"d",
",",
"prefix",
"=",
"\"\"",
")",
":",
"keys",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"d",
".",
"iteritems",
"(",
")",
":",
"fqk",
"=",
"'%s%s'",
"%",
"(",
"prefix",
",",
"k",
")",
"keys",
".",
"append... | returns all the keys in a dictionary.
>>> serialize_dict_keys({"a": {"b": {"c": 1, "b": 2} } })
['a', 'a.b', 'a.b.c', 'a.b.b'] | [
"returns",
"all",
"the",
"keys",
"in",
"a",
"dictionary",
"."
] | 7863bc1b5ddf3e67c4d4b55746799304180589a0 | https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/util.py#L53-L66 | train |
zetaops/zengine | zengine/auth/auth_backend.py | AuthBackend.set_user | def set_user(self, user):
"""
Writes user data to session.
Args:
user: User object
"""
self.session['user_id'] = user.key
self.session['user_data'] = user.clean_value()
role = self.get_role()
# TODO: this should be remembered from previous lo... | python | def set_user(self, user):
"""
Writes user data to session.
Args:
user: User object
"""
self.session['user_id'] = user.key
self.session['user_data'] = user.clean_value()
role = self.get_role()
# TODO: this should be remembered from previous lo... | [
"def",
"set_user",
"(",
"self",
",",
"user",
")",
":",
"self",
".",
"session",
"[",
"'user_id'",
"]",
"=",
"user",
".",
"key",
"self",
".",
"session",
"[",
"'user_data'",
"]",
"=",
"user",
".",
"clean_value",
"(",
")",
"role",
"=",
"self",
".",
"ge... | Writes user data to session.
Args:
user: User object | [
"Writes",
"user",
"data",
"to",
"session",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/auth/auth_backend.py#L33-L50 | train |
LordDarkula/chess_py | chess_py/pieces/piece.py | Piece.contains_opposite_color_piece | def contains_opposite_color_piece(self, square, position):
"""
Finds if square on the board is occupied by a ``Piece``
belonging to the opponent.
:type: square: Location
:type: position: Board
:rtype: bool
"""
return not position.is_square_empty(square) a... | python | def contains_opposite_color_piece(self, square, position):
"""
Finds if square on the board is occupied by a ``Piece``
belonging to the opponent.
:type: square: Location
:type: position: Board
:rtype: bool
"""
return not position.is_square_empty(square) a... | [
"def",
"contains_opposite_color_piece",
"(",
"self",
",",
"square",
",",
"position",
")",
":",
"return",
"not",
"position",
".",
"is_square_empty",
"(",
"square",
")",
"and",
"position",
".",
"piece_at_square",
"(",
"square",
")",
".",
"color",
"!=",
"self",
... | Finds if square on the board is occupied by a ``Piece``
belonging to the opponent.
:type: square: Location
:type: position: Board
:rtype: bool | [
"Finds",
"if",
"square",
"on",
"the",
"board",
"is",
"occupied",
"by",
"a",
"Piece",
"belonging",
"to",
"the",
"opponent",
"."
] | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/piece.py#L79-L89 | train |
zetaops/zengine | zengine/lib/translation.py | gettext | def gettext(message, domain=DEFAULT_DOMAIN):
"""Mark a message as translateable, and translate it.
All messages in the application that are translateable should be wrapped with this function.
When importing this function, it should be renamed to '_'. For example:
.. code-block:: python
from z... | python | def gettext(message, domain=DEFAULT_DOMAIN):
"""Mark a message as translateable, and translate it.
All messages in the application that are translateable should be wrapped with this function.
When importing this function, it should be renamed to '_'. For example:
.. code-block:: python
from z... | [
"def",
"gettext",
"(",
"message",
",",
"domain",
"=",
"DEFAULT_DOMAIN",
")",
":",
"if",
"six",
".",
"PY2",
":",
"return",
"InstalledLocale",
".",
"_active_catalogs",
"[",
"domain",
"]",
".",
"ugettext",
"(",
"message",
")",
"else",
":",
"return",
"Installe... | Mark a message as translateable, and translate it.
All messages in the application that are translateable should be wrapped with this function.
When importing this function, it should be renamed to '_'. For example:
.. code-block:: python
from zengine.lib.translation import gettext as _
p... | [
"Mark",
"a",
"message",
"as",
"translateable",
"and",
"translate",
"it",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/translation.py#L133-L184 | train |
zetaops/zengine | zengine/lib/translation.py | gettext_lazy | def gettext_lazy(message, domain=DEFAULT_DOMAIN):
"""Mark a message as translatable, but delay the translation until the message is used.
Sometimes, there are some messages that need to be translated, but the translation
can't be done at the point the message itself is written. For example, the names of
... | python | def gettext_lazy(message, domain=DEFAULT_DOMAIN):
"""Mark a message as translatable, but delay the translation until the message is used.
Sometimes, there are some messages that need to be translated, but the translation
can't be done at the point the message itself is written. For example, the names of
... | [
"def",
"gettext_lazy",
"(",
"message",
",",
"domain",
"=",
"DEFAULT_DOMAIN",
")",
":",
"return",
"LazyProxy",
"(",
"gettext",
",",
"message",
",",
"domain",
"=",
"domain",
",",
"enable_cache",
"=",
"False",
")"
] | Mark a message as translatable, but delay the translation until the message is used.
Sometimes, there are some messages that need to be translated, but the translation
can't be done at the point the message itself is written. For example, the names of
the fields in a Model can't be translated at the point ... | [
"Mark",
"a",
"message",
"as",
"translatable",
"but",
"delay",
"the",
"translation",
"until",
"the",
"message",
"is",
"used",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/translation.py#L187-L219 | train |
zetaops/zengine | zengine/lib/translation.py | ngettext | def ngettext(singular, plural, n, domain=DEFAULT_DOMAIN):
"""Mark a message as translateable, and translate it considering plural forms.
Some messages may need to change based on a number. For example, consider a message
like the following:
.. code-block:: python
def alert_msg(msg_count): pri... | python | def ngettext(singular, plural, n, domain=DEFAULT_DOMAIN):
"""Mark a message as translateable, and translate it considering plural forms.
Some messages may need to change based on a number. For example, consider a message
like the following:
.. code-block:: python
def alert_msg(msg_count): pri... | [
"def",
"ngettext",
"(",
"singular",
",",
"plural",
",",
"n",
",",
"domain",
"=",
"DEFAULT_DOMAIN",
")",
":",
"if",
"six",
".",
"PY2",
":",
"return",
"InstalledLocale",
".",
"_active_catalogs",
"[",
"domain",
"]",
".",
"ungettext",
"(",
"singular",
",",
"... | Mark a message as translateable, and translate it considering plural forms.
Some messages may need to change based on a number. For example, consider a message
like the following:
.. code-block:: python
def alert_msg(msg_count): print(
'You have %d %s' % (msg_count, 'message' if msg_count... | [
"Mark",
"a",
"message",
"as",
"translateable",
"and",
"translate",
"it",
"considering",
"plural",
"forms",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/translation.py#L222-L269 | train |
zetaops/zengine | zengine/lib/translation.py | ngettext_lazy | def ngettext_lazy(singular, plural, n, domain=DEFAULT_DOMAIN):
"""Mark a message with plural forms translateable, and delay the translation
until the message is used.
Works the same was a `ngettext`, with a delaying functionality similiar to `gettext_lazy`.
Args:
singular (unicode): The singul... | python | def ngettext_lazy(singular, plural, n, domain=DEFAULT_DOMAIN):
"""Mark a message with plural forms translateable, and delay the translation
until the message is used.
Works the same was a `ngettext`, with a delaying functionality similiar to `gettext_lazy`.
Args:
singular (unicode): The singul... | [
"def",
"ngettext_lazy",
"(",
"singular",
",",
"plural",
",",
"n",
",",
"domain",
"=",
"DEFAULT_DOMAIN",
")",
":",
"return",
"LazyProxy",
"(",
"ngettext",
",",
"singular",
",",
"plural",
",",
"n",
",",
"domain",
"=",
"domain",
",",
"enable_cache",
"=",
"F... | Mark a message with plural forms translateable, and delay the translation
until the message is used.
Works the same was a `ngettext`, with a delaying functionality similiar to `gettext_lazy`.
Args:
singular (unicode): The singular form of the message.
plural (unicode): The plural form of t... | [
"Mark",
"a",
"message",
"with",
"plural",
"forms",
"translateable",
"and",
"delay",
"the",
"translation",
"until",
"the",
"message",
"is",
"used",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/translation.py#L272-L288 | train |
zetaops/zengine | zengine/lib/translation.py | _wrap_locale_formatter | def _wrap_locale_formatter(fn, locale_type):
"""Wrap a Babel data formatting function to automatically format
for currently installed locale."""
def wrapped_locale_formatter(*args, **kwargs):
"""A Babel formatting function, wrapped to automatically use the
currently installed language.
... | python | def _wrap_locale_formatter(fn, locale_type):
"""Wrap a Babel data formatting function to automatically format
for currently installed locale."""
def wrapped_locale_formatter(*args, **kwargs):
"""A Babel formatting function, wrapped to automatically use the
currently installed language.
... | [
"def",
"_wrap_locale_formatter",
"(",
"fn",
",",
"locale_type",
")",
":",
"def",
"wrapped_locale_formatter",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"A Babel formatting function, wrapped to automatically use the\n currently installed language.\n\n ... | Wrap a Babel data formatting function to automatically format
for currently installed locale. | [
"Wrap",
"a",
"Babel",
"data",
"formatting",
"function",
"to",
"automatically",
"format",
"for",
"currently",
"installed",
"locale",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/translation.py#L328-L361 | train |
zetaops/zengine | zengine/lib/translation.py | InstalledLocale.install_language | def install_language(cls, language_code):
"""Install the translations for language specified by `language_code`.
If we don't have translations for this language, then the default language will be used.
If the language specified is already installed, then this is a no-op.
"""
# ... | python | def install_language(cls, language_code):
"""Install the translations for language specified by `language_code`.
If we don't have translations for this language, then the default language will be used.
If the language specified is already installed, then this is a no-op.
"""
# ... | [
"def",
"install_language",
"(",
"cls",
",",
"language_code",
")",
":",
"# Skip if the language is already installed",
"if",
"language_code",
"==",
"cls",
".",
"language",
":",
"return",
"try",
":",
"cls",
".",
"_active_catalogs",
"=",
"cls",
".",
"_translation_catal... | Install the translations for language specified by `language_code`.
If we don't have translations for this language, then the default language will be used.
If the language specified is already installed, then this is a no-op. | [
"Install",
"the",
"translations",
"for",
"language",
"specified",
"by",
"language_code",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/translation.py#L89-L107 | train |
zetaops/zengine | zengine/lib/translation.py | InstalledLocale.install_locale | def install_locale(cls, locale_code, locale_type):
"""Install the locale specified by `language_code`, for localizations of type `locale_type`.
If we can't perform localized formatting for the specified locale,
then the default localization format will be used.
If the locale specified ... | python | def install_locale(cls, locale_code, locale_type):
"""Install the locale specified by `language_code`, for localizations of type `locale_type`.
If we can't perform localized formatting for the specified locale,
then the default localization format will be used.
If the locale specified ... | [
"def",
"install_locale",
"(",
"cls",
",",
"locale_code",
",",
"locale_type",
")",
":",
"# Skip if the locale is already installed",
"if",
"locale_code",
"==",
"getattr",
"(",
"cls",
",",
"locale_type",
")",
":",
"return",
"try",
":",
"# We create a Locale instance to ... | Install the locale specified by `language_code`, for localizations of type `locale_type`.
If we can't perform localized formatting for the specified locale,
then the default localization format will be used.
If the locale specified is already installed for the selected type, then this is a no-... | [
"Install",
"the",
"locale",
"specified",
"by",
"language_code",
"for",
"localizations",
"of",
"type",
"locale_type",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/translation.py#L110-L130 | train |
cimm-kzn/CGRtools | CGRtools/algorithms/depict.py | Depict._rotate_vector | def _rotate_vector(x, y, x2, y2, x1, y1):
"""
rotate x,y vector over x2-x1, y2-y1 angle
"""
angle = atan2(y2 - y1, x2 - x1)
cos_rad = cos(angle)
sin_rad = sin(angle)
return cos_rad * x + sin_rad * y, -sin_rad * x + cos_rad * y | python | def _rotate_vector(x, y, x2, y2, x1, y1):
"""
rotate x,y vector over x2-x1, y2-y1 angle
"""
angle = atan2(y2 - y1, x2 - x1)
cos_rad = cos(angle)
sin_rad = sin(angle)
return cos_rad * x + sin_rad * y, -sin_rad * x + cos_rad * y | [
"def",
"_rotate_vector",
"(",
"x",
",",
"y",
",",
"x2",
",",
"y2",
",",
"x1",
",",
"y1",
")",
":",
"angle",
"=",
"atan2",
"(",
"y2",
"-",
"y1",
",",
"x2",
"-",
"x1",
")",
"cos_rad",
"=",
"cos",
"(",
"angle",
")",
"sin_rad",
"=",
"sin",
"(",
... | rotate x,y vector over x2-x1, y2-y1 angle | [
"rotate",
"x",
"y",
"vector",
"over",
"x2",
"-",
"x1",
"y2",
"-",
"y1",
"angle"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/depict.py#L86-L93 | train |
cocaine/cocaine-framework-python | cocaine/detail/headers.py | _build_static_table_mapping | def _build_static_table_mapping():
"""
Build static table mapping from header name to tuple with next structure:
(<minimal index of header>, <mapping from header value to it index>).
static_table_mapping used for hash searching.
"""
static_table_mapping = {}
for index, (name, value) in enum... | python | def _build_static_table_mapping():
"""
Build static table mapping from header name to tuple with next structure:
(<minimal index of header>, <mapping from header value to it index>).
static_table_mapping used for hash searching.
"""
static_table_mapping = {}
for index, (name, value) in enum... | [
"def",
"_build_static_table_mapping",
"(",
")",
":",
"static_table_mapping",
"=",
"{",
"}",
"for",
"index",
",",
"(",
"name",
",",
"value",
")",
"in",
"enumerate",
"(",
"CocaineHeaders",
".",
"STATIC_TABLE",
",",
"1",
")",
":",
"header_name_search_result",
"="... | Build static table mapping from header name to tuple with next structure:
(<minimal index of header>, <mapping from header value to it index>).
static_table_mapping used for hash searching. | [
"Build",
"static",
"table",
"mapping",
"from",
"header",
"name",
"to",
"tuple",
"with",
"next",
"structure",
":",
"(",
"<minimal",
"index",
"of",
"header",
">",
"<mapping",
"from",
"header",
"value",
"to",
"it",
"index",
">",
")",
"."
] | d8a30074b6338bac4389eb996e00d404338115e4 | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/headers.py#L268-L279 | train |
cocaine/cocaine-framework-python | cocaine/detail/headers.py | CocaineHeaders.get_by_index | def get_by_index(self, index):
"""
Returns the entry specified by index
Note that the table is 1-based ie an index of 0 is
invalid. This is due to the fact that a zero value
index signals that a completely unindexed header
follows.
The entry will either be from... | python | def get_by_index(self, index):
"""
Returns the entry specified by index
Note that the table is 1-based ie an index of 0 is
invalid. This is due to the fact that a zero value
index signals that a completely unindexed header
follows.
The entry will either be from... | [
"def",
"get_by_index",
"(",
"self",
",",
"index",
")",
":",
"index",
"-=",
"1",
"if",
"0",
"<=",
"index",
"<",
"len",
"(",
"CocaineHeaders",
".",
"STATIC_TABLE",
")",
":",
"return",
"CocaineHeaders",
".",
"STATIC_TABLE",
"[",
"index",
"]",
"index",
"-=",... | Returns the entry specified by index
Note that the table is 1-based ie an index of 0 is
invalid. This is due to the fact that a zero value
index signals that a completely unindexed header
follows.
The entry will either be from the static table or
the dynamic table depe... | [
"Returns",
"the",
"entry",
"specified",
"by",
"index"
] | d8a30074b6338bac4389eb996e00d404338115e4 | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/headers.py#L145-L163 | train |
cocaine/cocaine-framework-python | cocaine/detail/headers.py | CocaineHeaders.add | def add(self, name, value):
"""
Adds a new entry to the table
We reduce the table size if the entry will make the
table size greater than maxsize.
"""
# We just clear the table if the entry is too big
size = table_entry_size(name, value)
if size > self._m... | python | def add(self, name, value):
"""
Adds a new entry to the table
We reduce the table size if the entry will make the
table size greater than maxsize.
"""
# We just clear the table if the entry is too big
size = table_entry_size(name, value)
if size > self._m... | [
"def",
"add",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"# We just clear the table if the entry is too big",
"size",
"=",
"table_entry_size",
"(",
"name",
",",
"value",
")",
"if",
"size",
">",
"self",
".",
"_maxsize",
":",
"self",
".",
"dynamic_entries... | Adds a new entry to the table
We reduce the table size if the entry will make the
table size greater than maxsize. | [
"Adds",
"a",
"new",
"entry",
"to",
"the",
"table"
] | d8a30074b6338bac4389eb996e00d404338115e4 | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/headers.py#L172-L189 | train |
cocaine/cocaine-framework-python | cocaine/detail/headers.py | CocaineHeaders.search | def search(self, name, value):
"""
Searches the table for the entry specified by name
and value
Returns one of the following:
- ``None``, no match at all
- ``(index, name, None)`` for partial matches on name only.
- ``(index, name, value)`` for perfec... | python | def search(self, name, value):
"""
Searches the table for the entry specified by name
and value
Returns one of the following:
- ``None``, no match at all
- ``(index, name, None)`` for partial matches on name only.
- ``(index, name, value)`` for perfec... | [
"def",
"search",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"partial",
"=",
"None",
"header_name_search_result",
"=",
"CocaineHeaders",
".",
"STATIC_TABLE_MAPPING",
".",
"get",
"(",
"name",
")",
"if",
"header_name_search_result",
":",
"index",
"=",
"hea... | Searches the table for the entry specified by name
and value
Returns one of the following:
- ``None``, no match at all
- ``(index, name, None)`` for partial matches on name only.
- ``(index, name, value)`` for perfect matches. | [
"Searches",
"the",
"table",
"for",
"the",
"entry",
"specified",
"by",
"name",
"and",
"value"
] | d8a30074b6338bac4389eb996e00d404338115e4 | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/headers.py#L191-L217 | train |
cocaine/cocaine-framework-python | cocaine/detail/headers.py | CocaineHeaders._shrink | def _shrink(self):
"""
Shrinks the dynamic table to be at or below maxsize
"""
cursize = self._current_size
while cursize > self._maxsize:
name, value = self.dynamic_entries.pop()
cursize -= table_entry_size(name, value)
self._current_size = cursiz... | python | def _shrink(self):
"""
Shrinks the dynamic table to be at or below maxsize
"""
cursize = self._current_size
while cursize > self._maxsize:
name, value = self.dynamic_entries.pop()
cursize -= table_entry_size(name, value)
self._current_size = cursiz... | [
"def",
"_shrink",
"(",
"self",
")",
":",
"cursize",
"=",
"self",
".",
"_current_size",
"while",
"cursize",
">",
"self",
".",
"_maxsize",
":",
"name",
",",
"value",
"=",
"self",
".",
"dynamic_entries",
".",
"pop",
"(",
")",
"cursize",
"-=",
"table_entry_s... | Shrinks the dynamic table to be at or below maxsize | [
"Shrinks",
"the",
"dynamic",
"table",
"to",
"be",
"at",
"or",
"below",
"maxsize"
] | d8a30074b6338bac4389eb996e00d404338115e4 | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/headers.py#L235-L243 | train |
cocaine/cocaine-framework-python | cocaine/detail/headers.py | Headers.add | def add(self, name, value):
# type: (str, str) -> None
"""Adds a new value for the given key."""
self._last_key = name
if name in self:
self._dict[name] = value
self._as_list[name].append(value)
else:
self[name] = value | python | def add(self, name, value):
# type: (str, str) -> None
"""Adds a new value for the given key."""
self._last_key = name
if name in self:
self._dict[name] = value
self._as_list[name].append(value)
else:
self[name] = value | [
"def",
"add",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"# type: (str, str) -> None",
"self",
".",
"_last_key",
"=",
"name",
"if",
"name",
"in",
"self",
":",
"self",
".",
"_dict",
"[",
"name",
"]",
"=",
"value",
"self",
".",
"_as_list",
"[",
... | Adds a new value for the given key. | [
"Adds",
"a",
"new",
"value",
"for",
"the",
"given",
"key",
"."
] | d8a30074b6338bac4389eb996e00d404338115e4 | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/headers.py#L314-L322 | train |
cocaine/cocaine-framework-python | cocaine/detail/headers.py | Headers.get_all | def get_all(self):
# type: () -> typing.Iterable[typing.Tuple[str, str]]
"""Returns an iterable of all (name, value) pairs.
If a header has multiple values, multiple pairs will be
returned with the same name.
"""
for name, values in six.iteritems(self._as_list):
... | python | def get_all(self):
# type: () -> typing.Iterable[typing.Tuple[str, str]]
"""Returns an iterable of all (name, value) pairs.
If a header has multiple values, multiple pairs will be
returned with the same name.
"""
for name, values in six.iteritems(self._as_list):
... | [
"def",
"get_all",
"(",
"self",
")",
":",
"# type: () -> typing.Iterable[typing.Tuple[str, str]]",
"for",
"name",
",",
"values",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"_as_list",
")",
":",
"for",
"value",
"in",
"values",
":",
"yield",
"(",
"name",
... | Returns an iterable of all (name, value) pairs.
If a header has multiple values, multiple pairs will be
returned with the same name. | [
"Returns",
"an",
"iterable",
"of",
"all",
"(",
"name",
"value",
")",
"pairs",
"."
] | d8a30074b6338bac4389eb996e00d404338115e4 | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/headers.py#L328-L337 | train |
camptocamp/marabunta | marabunta/output.py | safe_print | def safe_print(ustring, errors='replace', **kwargs):
""" Safely print a unicode string """
encoding = sys.stdout.encoding or 'utf-8'
if sys.version_info[0] == 3:
print(ustring, **kwargs)
else:
bytestr = ustring.encode(encoding, errors=errors)
print(bytestr, **kwargs) | python | def safe_print(ustring, errors='replace', **kwargs):
""" Safely print a unicode string """
encoding = sys.stdout.encoding or 'utf-8'
if sys.version_info[0] == 3:
print(ustring, **kwargs)
else:
bytestr = ustring.encode(encoding, errors=errors)
print(bytestr, **kwargs) | [
"def",
"safe_print",
"(",
"ustring",
",",
"errors",
"=",
"'replace'",
",",
"*",
"*",
"kwargs",
")",
":",
"encoding",
"=",
"sys",
".",
"stdout",
".",
"encoding",
"or",
"'utf-8'",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
"==",
"3",
":",
"print"... | Safely print a unicode string | [
"Safely",
"print",
"a",
"unicode",
"string"
] | ec3a7a725c7426d6ed642e0a80119b37880eb91e | https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/output.py#L26-L33 | train |
zetaops/zengine | zengine/views/permissions.py | Permissions.edit_permissions | def edit_permissions(self):
"""Creates the view used to edit permissions.
To create the view, data in the following format is passed to the UI
in the objects field:
.. code-block:: python
{
"type": "tree-toggle",
"action": "set_permission",
... | python | def edit_permissions(self):
"""Creates the view used to edit permissions.
To create the view, data in the following format is passed to the UI
in the objects field:
.. code-block:: python
{
"type": "tree-toggle",
"action": "set_permission",
... | [
"def",
"edit_permissions",
"(",
"self",
")",
":",
"# Get the role that was selected in the CRUD view",
"key",
"=",
"self",
".",
"current",
".",
"input",
"[",
"'object_id'",
"]",
"self",
".",
"current",
".",
"task_data",
"[",
"'role_id'",
"]",
"=",
"key",
"role",... | Creates the view used to edit permissions.
To create the view, data in the following format is passed to the UI
in the objects field:
.. code-block:: python
{
"type": "tree-toggle",
"action": "set_permission",
"tree": [
... | [
"Creates",
"the",
"view",
"used",
"to",
"edit",
"permissions",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/permissions.py#L110-L196 | train |
zetaops/zengine | zengine/views/permissions.py | Permissions._permission_trees | def _permission_trees(permissions):
"""Get the cached permission tree, or build a new one if necessary."""
treecache = PermissionTreeCache()
cached = treecache.get()
if not cached:
tree = PermissionTreeBuilder()
for permission in permissions:
tree.... | python | def _permission_trees(permissions):
"""Get the cached permission tree, or build a new one if necessary."""
treecache = PermissionTreeCache()
cached = treecache.get()
if not cached:
tree = PermissionTreeBuilder()
for permission in permissions:
tree.... | [
"def",
"_permission_trees",
"(",
"permissions",
")",
":",
"treecache",
"=",
"PermissionTreeCache",
"(",
")",
"cached",
"=",
"treecache",
".",
"get",
"(",
")",
"if",
"not",
"cached",
":",
"tree",
"=",
"PermissionTreeBuilder",
"(",
")",
"for",
"permission",
"i... | Get the cached permission tree, or build a new one if necessary. | [
"Get",
"the",
"cached",
"permission",
"tree",
"or",
"build",
"a",
"new",
"one",
"if",
"necessary",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/permissions.py#L199-L210 | train |
zetaops/zengine | zengine/views/permissions.py | Permissions._apply_role_tree | def _apply_role_tree(self, perm_tree, role):
"""In permission tree, sets `'checked': True` for the permissions that the role has."""
role_permissions = role.get_permissions()
for perm in role_permissions:
self._traverse_tree(perm_tree, perm)['checked'] = True
return perm_tree | python | def _apply_role_tree(self, perm_tree, role):
"""In permission tree, sets `'checked': True` for the permissions that the role has."""
role_permissions = role.get_permissions()
for perm in role_permissions:
self._traverse_tree(perm_tree, perm)['checked'] = True
return perm_tree | [
"def",
"_apply_role_tree",
"(",
"self",
",",
"perm_tree",
",",
"role",
")",
":",
"role_permissions",
"=",
"role",
".",
"get_permissions",
"(",
")",
"for",
"perm",
"in",
"role_permissions",
":",
"self",
".",
"_traverse_tree",
"(",
"perm_tree",
",",
"perm",
")... | In permission tree, sets `'checked': True` for the permissions that the role has. | [
"In",
"permission",
"tree",
"sets",
"checked",
":",
"True",
"for",
"the",
"permissions",
"that",
"the",
"role",
"has",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/permissions.py#L212-L217 | train |
zetaops/zengine | zengine/views/permissions.py | Permissions._traverse_tree | def _traverse_tree(tree, path):
"""Traverses the permission tree, returning the permission at given permission path."""
path_steps = (step for step in path.split('.') if step != '')
# Special handling for first step, because the first step isn't under 'objects'
first_step = path_steps.ne... | python | def _traverse_tree(tree, path):
"""Traverses the permission tree, returning the permission at given permission path."""
path_steps = (step for step in path.split('.') if step != '')
# Special handling for first step, because the first step isn't under 'objects'
first_step = path_steps.ne... | [
"def",
"_traverse_tree",
"(",
"tree",
",",
"path",
")",
":",
"path_steps",
"=",
"(",
"step",
"for",
"step",
"in",
"path",
".",
"split",
"(",
"'.'",
")",
"if",
"step",
"!=",
"''",
")",
"# Special handling for first step, because the first step isn't under 'objects'... | Traverses the permission tree, returning the permission at given permission path. | [
"Traverses",
"the",
"permission",
"tree",
"returning",
"the",
"permission",
"at",
"given",
"permission",
"path",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/permissions.py#L220-L229 | train |
zetaops/zengine | zengine/views/permissions.py | Permissions._format_subtree | def _format_subtree(self, subtree):
"""Recursively format all subtrees."""
subtree['children'] = list(subtree['children'].values())
for child in subtree['children']:
self._format_subtree(child)
return subtree | python | def _format_subtree(self, subtree):
"""Recursively format all subtrees."""
subtree['children'] = list(subtree['children'].values())
for child in subtree['children']:
self._format_subtree(child)
return subtree | [
"def",
"_format_subtree",
"(",
"self",
",",
"subtree",
")",
":",
"subtree",
"[",
"'children'",
"]",
"=",
"list",
"(",
"subtree",
"[",
"'children'",
"]",
".",
"values",
"(",
")",
")",
"for",
"child",
"in",
"subtree",
"[",
"'children'",
"]",
":",
"self",... | Recursively format all subtrees. | [
"Recursively",
"format",
"all",
"subtrees",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/permissions.py#L241-L246 | train |
zetaops/zengine | zengine/views/permissions.py | Permissions.apply_change | def apply_change(self):
"""Applies changes to the permissions of the role.
To make a change to the permission of the role, a request
in the following format should be sent:
.. code-block:: python
{
'change':
{
'id'... | python | def apply_change(self):
"""Applies changes to the permissions of the role.
To make a change to the permission of the role, a request
in the following format should be sent:
.. code-block:: python
{
'change':
{
'id'... | [
"def",
"apply_change",
"(",
"self",
")",
":",
"changes",
"=",
"self",
".",
"input",
"[",
"'change'",
"]",
"key",
"=",
"self",
".",
"current",
".",
"task_data",
"[",
"'role_id'",
"]",
"role",
"=",
"RoleModel",
".",
"objects",
".",
"get",
"(",
"key",
"... | Applies changes to the permissions of the role.
To make a change to the permission of the role, a request
in the following format should be sent:
.. code-block:: python
{
'change':
{
'id': 'workflow2.lane1.task1',
... | [
"Applies",
"changes",
"to",
"the",
"permissions",
"of",
"the",
"role",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/permissions.py#L248-L276 | train |
cimm-kzn/CGRtools | CGRtools/files/SDFrw.py | SDFread.seek | def seek(self, offset):
"""
shifts on a given number of record in the original file
:param offset: number of record
"""
if self._shifts:
if 0 <= offset < len(self._shifts):
current_pos = self._file.tell()
new_pos = self._shifts[offset]
... | python | def seek(self, offset):
"""
shifts on a given number of record in the original file
:param offset: number of record
"""
if self._shifts:
if 0 <= offset < len(self._shifts):
current_pos = self._file.tell()
new_pos = self._shifts[offset]
... | [
"def",
"seek",
"(",
"self",
",",
"offset",
")",
":",
"if",
"self",
".",
"_shifts",
":",
"if",
"0",
"<=",
"offset",
"<",
"len",
"(",
"self",
".",
"_shifts",
")",
":",
"current_pos",
"=",
"self",
".",
"_file",
".",
"tell",
"(",
")",
"new_pos",
"=",... | shifts on a given number of record in the original file
:param offset: number of record | [
"shifts",
"on",
"a",
"given",
"number",
"of",
"record",
"in",
"the",
"original",
"file",
":",
"param",
"offset",
":",
"number",
"of",
"record"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/files/SDFrw.py#L62-L79 | train |
cimm-kzn/CGRtools | CGRtools/files/SDFrw.py | SDFread.tell | def tell(self):
"""
:return: number of records processed from the original file
"""
if self._shifts:
t = self._file.tell()
return bisect_left(self._shifts, t)
raise self._implement_error | python | def tell(self):
"""
:return: number of records processed from the original file
"""
if self._shifts:
t = self._file.tell()
return bisect_left(self._shifts, t)
raise self._implement_error | [
"def",
"tell",
"(",
"self",
")",
":",
"if",
"self",
".",
"_shifts",
":",
"t",
"=",
"self",
".",
"_file",
".",
"tell",
"(",
")",
"return",
"bisect_left",
"(",
"self",
".",
"_shifts",
",",
"t",
")",
"raise",
"self",
".",
"_implement_error"
] | :return: number of records processed from the original file | [
":",
"return",
":",
"number",
"of",
"records",
"processed",
"from",
"the",
"original",
"file"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/files/SDFrw.py#L81-L88 | train |
cimm-kzn/CGRtools | CGRtools/files/SDFrw.py | SDFwrite.write | def write(self, data):
"""
write single molecule into file
"""
m = self._convert_structure(data)
self._file.write(self._format_mol(*m))
self._file.write('M END\n')
for k, v in data.meta.items():
self._file.write(f'> <{k}>\n{v}\n')
self._file... | python | def write(self, data):
"""
write single molecule into file
"""
m = self._convert_structure(data)
self._file.write(self._format_mol(*m))
self._file.write('M END\n')
for k, v in data.meta.items():
self._file.write(f'> <{k}>\n{v}\n')
self._file... | [
"def",
"write",
"(",
"self",
",",
"data",
")",
":",
"m",
"=",
"self",
".",
"_convert_structure",
"(",
"data",
")",
"self",
".",
"_file",
".",
"write",
"(",
"self",
".",
"_format_mol",
"(",
"*",
"m",
")",
")",
"self",
".",
"_file",
".",
"write",
"... | write single molecule into file | [
"write",
"single",
"molecule",
"into",
"file"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/files/SDFrw.py#L166-L176 | train |
zetaops/zengine | zengine/engine.py | ZEngine.save_workflow_to_cache | def save_workflow_to_cache(self, serialized_wf_instance):
"""
If we aren't come to the end of the wf,
saves the wf state and task_data to cache
Task_data items that starts with underscore "_" are treated as
local and does not passed to subsequent task steps.
"""
... | python | def save_workflow_to_cache(self, serialized_wf_instance):
"""
If we aren't come to the end of the wf,
saves the wf state and task_data to cache
Task_data items that starts with underscore "_" are treated as
local and does not passed to subsequent task steps.
"""
... | [
"def",
"save_workflow_to_cache",
"(",
"self",
",",
"serialized_wf_instance",
")",
":",
"# self.current.task_data['flow'] = None",
"task_data",
"=",
"self",
".",
"current",
".",
"task_data",
".",
"copy",
"(",
")",
"for",
"k",
",",
"v",
"in",
"list",
"(",
"task_da... | If we aren't come to the end of the wf,
saves the wf state and task_data to cache
Task_data items that starts with underscore "_" are treated as
local and does not passed to subsequent task steps. | [
"If",
"we",
"aren",
"t",
"come",
"to",
"the",
"end",
"of",
"the",
"wf",
"saves",
"the",
"wf",
"state",
"and",
"task_data",
"to",
"cache"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L76-L102 | train |
zetaops/zengine | zengine/engine.py | ZEngine.get_pool_context | def get_pool_context(self):
# TODO: Add in-process caching
"""
Builds context for the WF pool.
Returns:
Context dict.
"""
context = {self.current.lane_id: self.current.role, 'self': self.current.role}
for lane_id, role_id in self.current.pool.items():... | python | def get_pool_context(self):
# TODO: Add in-process caching
"""
Builds context for the WF pool.
Returns:
Context dict.
"""
context = {self.current.lane_id: self.current.role, 'self': self.current.role}
for lane_id, role_id in self.current.pool.items():... | [
"def",
"get_pool_context",
"(",
"self",
")",
":",
"# TODO: Add in-process caching",
"context",
"=",
"{",
"self",
".",
"current",
".",
"lane_id",
":",
"self",
".",
"current",
".",
"role",
",",
"'self'",
":",
"self",
".",
"current",
".",
"role",
"}",
"for",
... | Builds context for the WF pool.
Returns:
Context dict. | [
"Builds",
"context",
"for",
"the",
"WF",
"pool",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L104-L117 | train |
zetaops/zengine | zengine/engine.py | ZEngine.load_workflow_from_cache | def load_workflow_from_cache(self):
"""
loads the serialized wf state and data from cache
updates the self.current.task_data
"""
if not self.current.new_token:
self.wf_state = self.current.wf_cache.get(self.wf_state)
self.current.task_data = self.wf_state[... | python | def load_workflow_from_cache(self):
"""
loads the serialized wf state and data from cache
updates the self.current.task_data
"""
if not self.current.new_token:
self.wf_state = self.current.wf_cache.get(self.wf_state)
self.current.task_data = self.wf_state[... | [
"def",
"load_workflow_from_cache",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"current",
".",
"new_token",
":",
"self",
".",
"wf_state",
"=",
"self",
".",
"current",
".",
"wf_cache",
".",
"get",
"(",
"self",
".",
"wf_state",
")",
"self",
".",
"cu... | loads the serialized wf state and data from cache
updates the self.current.task_data | [
"loads",
"the",
"serialized",
"wf",
"state",
"and",
"data",
"from",
"cache",
"updates",
"the",
"self",
".",
"current",
".",
"task_data"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L119-L129 | train |
zetaops/zengine | zengine/engine.py | ZEngine.serialize_workflow | def serialize_workflow(self):
"""
Serializes the current WF.
Returns:
WF state data.
"""
self.workflow.refresh_waiting_tasks()
return CompactWorkflowSerializer().serialize_workflow(self.workflow,
i... | python | def serialize_workflow(self):
"""
Serializes the current WF.
Returns:
WF state data.
"""
self.workflow.refresh_waiting_tasks()
return CompactWorkflowSerializer().serialize_workflow(self.workflow,
i... | [
"def",
"serialize_workflow",
"(",
"self",
")",
":",
"self",
".",
"workflow",
".",
"refresh_waiting_tasks",
"(",
")",
"return",
"CompactWorkflowSerializer",
"(",
")",
".",
"serialize_workflow",
"(",
"self",
".",
"workflow",
",",
"include_spec",
"=",
"False",
")"
... | Serializes the current WF.
Returns:
WF state data. | [
"Serializes",
"the",
"current",
"WF",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L150-L159 | train |
zetaops/zengine | zengine/engine.py | ZEngine.load_or_create_workflow | def load_or_create_workflow(self):
"""
Tries to load the previously serialized (and saved) workflow
Creates a new one if it can't
"""
self.workflow_spec = self.get_worfklow_spec()
return self._load_workflow() or self.create_workflow() | python | def load_or_create_workflow(self):
"""
Tries to load the previously serialized (and saved) workflow
Creates a new one if it can't
"""
self.workflow_spec = self.get_worfklow_spec()
return self._load_workflow() or self.create_workflow() | [
"def",
"load_or_create_workflow",
"(",
"self",
")",
":",
"self",
".",
"workflow_spec",
"=",
"self",
".",
"get_worfklow_spec",
"(",
")",
"return",
"self",
".",
"_load_workflow",
"(",
")",
"or",
"self",
".",
"create_workflow",
"(",
")"
] | Tries to load the previously serialized (and saved) workflow
Creates a new one if it can't | [
"Tries",
"to",
"load",
"the",
"previously",
"serialized",
"(",
"and",
"saved",
")",
"workflow",
"Creates",
"a",
"new",
"one",
"if",
"it",
"can",
"t"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L169-L175 | train |
zetaops/zengine | zengine/engine.py | ZEngine.find_workflow_path | def find_workflow_path(self):
"""
Tries to find the path of the workflow diagram file
in `WORKFLOW_PACKAGES_PATHS`.
Returns:
Path of the workflow spec file (BPMN diagram)
"""
for pth in settings.WORKFLOW_PACKAGES_PATHS:
path = "%s/%s.bpmn" % (pth,... | python | def find_workflow_path(self):
"""
Tries to find the path of the workflow diagram file
in `WORKFLOW_PACKAGES_PATHS`.
Returns:
Path of the workflow spec file (BPMN diagram)
"""
for pth in settings.WORKFLOW_PACKAGES_PATHS:
path = "%s/%s.bpmn" % (pth,... | [
"def",
"find_workflow_path",
"(",
"self",
")",
":",
"for",
"pth",
"in",
"settings",
".",
"WORKFLOW_PACKAGES_PATHS",
":",
"path",
"=",
"\"%s/%s.bpmn\"",
"%",
"(",
"pth",
",",
"self",
".",
"current",
".",
"workflow_name",
")",
"if",
"os",
".",
"path",
".",
... | Tries to find the path of the workflow diagram file
in `WORKFLOW_PACKAGES_PATHS`.
Returns:
Path of the workflow spec file (BPMN diagram) | [
"Tries",
"to",
"find",
"the",
"path",
"of",
"the",
"workflow",
"diagram",
"file",
"in",
"WORKFLOW_PACKAGES_PATHS",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L178-L192 | train |
zetaops/zengine | zengine/engine.py | ZEngine.get_worfklow_spec | def get_worfklow_spec(self):
"""
Generates and caches the workflow spec package from
BPMN diagrams that read from disk
Returns:
SpiffWorkflow Spec object.
"""
# TODO: convert from in-process to redis based caching
if self.current.workflow_name not in ... | python | def get_worfklow_spec(self):
"""
Generates and caches the workflow spec package from
BPMN diagrams that read from disk
Returns:
SpiffWorkflow Spec object.
"""
# TODO: convert from in-process to redis based caching
if self.current.workflow_name not in ... | [
"def",
"get_worfklow_spec",
"(",
"self",
")",
":",
"# TODO: convert from in-process to redis based caching",
"if",
"self",
".",
"current",
".",
"workflow_name",
"not",
"in",
"self",
".",
"workflow_spec_cache",
":",
"# path = self.find_workflow_path()",
"# spec_package = InMem... | Generates and caches the workflow spec package from
BPMN diagrams that read from disk
Returns:
SpiffWorkflow Spec object. | [
"Generates",
"and",
"caches",
"the",
"workflow",
"spec",
"package",
"from",
"BPMN",
"diagrams",
"that",
"read",
"from",
"disk"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L194-L219 | train |
zetaops/zengine | zengine/engine.py | ZEngine._save_or_delete_workflow | def _save_or_delete_workflow(self):
"""
Calls the real save method if we pass the beggining of the wf
"""
if not self.current.task_type.startswith('Start'):
if self.current.task_name.startswith('End') and not self.are_we_in_subprocess():
self.wf_state['finishe... | python | def _save_or_delete_workflow(self):
"""
Calls the real save method if we pass the beggining of the wf
"""
if not self.current.task_type.startswith('Start'):
if self.current.task_name.startswith('End') and not self.are_we_in_subprocess():
self.wf_state['finishe... | [
"def",
"_save_or_delete_workflow",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"current",
".",
"task_type",
".",
"startswith",
"(",
"'Start'",
")",
":",
"if",
"self",
".",
"current",
".",
"task_name",
".",
"startswith",
"(",
"'End'",
")",
"and",
"no... | Calls the real save method if we pass the beggining of the wf | [
"Calls",
"the",
"real",
"save",
"method",
"if",
"we",
"pass",
"the",
"beggining",
"of",
"the",
"wf"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L221-L239 | train |
zetaops/zengine | zengine/engine.py | ZEngine.start_engine | def start_engine(self, **kwargs):
"""
Initializes the workflow with given request, response objects and diagram name.
Args:
session:
input:
workflow_name (str): Name of workflow diagram without ".bpmn" suffix.
File must be placed under one of con... | python | def start_engine(self, **kwargs):
"""
Initializes the workflow with given request, response objects and diagram name.
Args:
session:
input:
workflow_name (str): Name of workflow diagram without ".bpmn" suffix.
File must be placed under one of con... | [
"def",
"start_engine",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"current",
"=",
"WFCurrent",
"(",
"*",
"*",
"kwargs",
")",
"self",
".",
"wf_state",
"=",
"{",
"'in_external'",
":",
"False",
",",
"'finished'",
":",
"False",
"}",
"if... | Initializes the workflow with given request, response objects and diagram name.
Args:
session:
input:
workflow_name (str): Name of workflow diagram without ".bpmn" suffix.
File must be placed under one of configured :py:attr:`~zengine.settings.WORKFLOW_PACKAGES_... | [
"Initializes",
"the",
"workflow",
"with",
"given",
"request",
"response",
"objects",
"and",
"diagram",
"name",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L241-L289 | train |
zetaops/zengine | zengine/engine.py | ZEngine.generate_wf_state_log | def generate_wf_state_log(self):
"""
Logs the state of workflow and content of task_data.
"""
output = '\n- - - - - -\n'
output += "WORKFLOW: %s ( %s )" % (self.current.workflow_name.upper(),
self.current.workflow.name)
output +... | python | def generate_wf_state_log(self):
"""
Logs the state of workflow and content of task_data.
"""
output = '\n- - - - - -\n'
output += "WORKFLOW: %s ( %s )" % (self.current.workflow_name.upper(),
self.current.workflow.name)
output +... | [
"def",
"generate_wf_state_log",
"(",
"self",
")",
":",
"output",
"=",
"'\\n- - - - - -\\n'",
"output",
"+=",
"\"WORKFLOW: %s ( %s )\"",
"%",
"(",
"self",
".",
"current",
".",
"workflow_name",
".",
"upper",
"(",
")",
",",
"self",
".",
"current",
".",
"workflow"... | Logs the state of workflow and content of task_data. | [
"Logs",
"the",
"state",
"of",
"workflow",
"and",
"content",
"of",
"task_data",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L291-L311 | train |
zetaops/zengine | zengine/engine.py | ZEngine.switch_from_external_to_main_wf | def switch_from_external_to_main_wf(self):
"""
Main workflow switcher.
This method recreates main workflow from `main wf` dict which
was set by external workflow swicther previously.
"""
# in external assigned as True in switch_to_external_wf.
# external_wf sh... | python | def switch_from_external_to_main_wf(self):
"""
Main workflow switcher.
This method recreates main workflow from `main wf` dict which
was set by external workflow swicther previously.
"""
# in external assigned as True in switch_to_external_wf.
# external_wf sh... | [
"def",
"switch_from_external_to_main_wf",
"(",
"self",
")",
":",
"# in external assigned as True in switch_to_external_wf.",
"# external_wf should finish EndEvent and it's name should be",
"# also EndEvent for switching again to main wf.",
"if",
"self",
".",
"wf_state",
"[",
"'in_externa... | Main workflow switcher.
This method recreates main workflow from `main wf` dict which
was set by external workflow swicther previously. | [
"Main",
"workflow",
"switcher",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L316-L365 | train |
zetaops/zengine | zengine/engine.py | ZEngine.switch_to_external_wf | def switch_to_external_wf(self):
"""
External workflow switcher.
This method copies main workflow information into
a temporary dict `main_wf` and makes external workflow
acting as main workflow.
"""
# External WF name should be stated at main wf diagram and typ... | python | def switch_to_external_wf(self):
"""
External workflow switcher.
This method copies main workflow information into
a temporary dict `main_wf` and makes external workflow
acting as main workflow.
"""
# External WF name should be stated at main wf diagram and typ... | [
"def",
"switch_to_external_wf",
"(",
"self",
")",
":",
"# External WF name should be stated at main wf diagram and type should be service task.",
"if",
"(",
"self",
".",
"current",
".",
"task_type",
"==",
"'ServiceTask'",
"and",
"self",
".",
"current",
".",
"task",
".",
... | External workflow switcher.
This method copies main workflow information into
a temporary dict `main_wf` and makes external workflow
acting as main workflow. | [
"External",
"workflow",
"switcher",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L367-L408 | train |
zetaops/zengine | zengine/engine.py | ZEngine._clear_current_task | def _clear_current_task(self):
"""
Clear tasks related attributes, checks permissions
While switching WF to WF, authentication and permissions are checked for new WF.
"""
self.current.task_name = None
self.current.task_type = None
self.current.task = None | python | def _clear_current_task(self):
"""
Clear tasks related attributes, checks permissions
While switching WF to WF, authentication and permissions are checked for new WF.
"""
self.current.task_name = None
self.current.task_type = None
self.current.task = None | [
"def",
"_clear_current_task",
"(",
"self",
")",
":",
"self",
".",
"current",
".",
"task_name",
"=",
"None",
"self",
".",
"current",
".",
"task_type",
"=",
"None",
"self",
".",
"current",
".",
"task",
"=",
"None"
] | Clear tasks related attributes, checks permissions
While switching WF to WF, authentication and permissions are checked for new WF. | [
"Clear",
"tasks",
"related",
"attributes",
"checks",
"permissions",
"While",
"switching",
"WF",
"to",
"WF",
"authentication",
"and",
"permissions",
"are",
"checked",
"for",
"new",
"WF",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L410-L418 | train |
zetaops/zengine | zengine/engine.py | ZEngine.run | def run(self):
"""
Main loop of the workflow engine
- Updates ::class:`~WFCurrent` object.
- Checks for Permissions.
- Activates all READY tasks.
- Runs referenced activities (method calls).
- Saves WF states.
- Stops if current task is a UserTask or EndT... | python | def run(self):
"""
Main loop of the workflow engine
- Updates ::class:`~WFCurrent` object.
- Checks for Permissions.
- Activates all READY tasks.
- Runs referenced activities (method calls).
- Saves WF states.
- Stops if current task is a UserTask or EndT... | [
"def",
"run",
"(",
"self",
")",
":",
"# FIXME: raise if first task after line change isn't a UserTask",
"# FIXME: raise if last task of a workflow is a UserTask",
"# actually this check should be done at parser",
"is_lane_changed",
"=",
"False",
"while",
"self",
".",
"_should_we_run",
... | Main loop of the workflow engine
- Updates ::class:`~WFCurrent` object.
- Checks for Permissions.
- Activates all READY tasks.
- Runs referenced activities (method calls).
- Saves WF states.
- Stops if current task is a UserTask or EndTask.
- Deletes state object... | [
"Main",
"loop",
"of",
"the",
"workflow",
"engine"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L432-L477 | train |
zetaops/zengine | zengine/engine.py | ZEngine.check_for_rerun_user_task | def check_for_rerun_user_task(self):
"""
Checks that the user task needs to re-run.
If necessary, current task and pre task's states are changed and re-run.
If wf_meta not in data(there is no user interaction from pre-task) and last completed task
type is user task and current st... | python | def check_for_rerun_user_task(self):
"""
Checks that the user task needs to re-run.
If necessary, current task and pre task's states are changed and re-run.
If wf_meta not in data(there is no user interaction from pre-task) and last completed task
type is user task and current st... | [
"def",
"check_for_rerun_user_task",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"current",
".",
"input",
"if",
"'wf_meta'",
"in",
"data",
":",
"return",
"current_task",
"=",
"self",
".",
"workflow",
".",
"get_tasks",
"(",
"Task",
".",
"READY",
")",
... | Checks that the user task needs to re-run.
If necessary, current task and pre task's states are changed and re-run.
If wf_meta not in data(there is no user interaction from pre-task) and last completed task
type is user task and current step is not EndEvent and there is no lane change,
t... | [
"Checks",
"that",
"the",
"user",
"task",
"needs",
"to",
"re",
"-",
"run",
".",
"If",
"necessary",
"current",
"task",
"and",
"pre",
"task",
"s",
"states",
"are",
"changed",
"and",
"re",
"-",
"run",
".",
"If",
"wf_meta",
"not",
"in",
"data",
"(",
"ther... | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L479-L506 | train |
zetaops/zengine | zengine/engine.py | ZEngine.switch_lang | def switch_lang(self):
"""Switch to the language of the current user.
If the current language is already the specified one, nothing will be done.
"""
locale = self.current.locale
translation.InstalledLocale.install_language(locale['locale_language'])
translation.Installe... | python | def switch_lang(self):
"""Switch to the language of the current user.
If the current language is already the specified one, nothing will be done.
"""
locale = self.current.locale
translation.InstalledLocale.install_language(locale['locale_language'])
translation.Installe... | [
"def",
"switch_lang",
"(",
"self",
")",
":",
"locale",
"=",
"self",
".",
"current",
".",
"locale",
"translation",
".",
"InstalledLocale",
".",
"install_language",
"(",
"locale",
"[",
"'locale_language'",
"]",
")",
"translation",
".",
"InstalledLocale",
".",
"i... | Switch to the language of the current user.
If the current language is already the specified one, nothing will be done. | [
"Switch",
"to",
"the",
"language",
"of",
"the",
"current",
"user",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L508-L516 | train |
zetaops/zengine | zengine/engine.py | ZEngine.catch_lane_change | def catch_lane_change(self):
"""
trigger a lane_user_change signal if we switched to a new lane
and new lane's user is different from current one
"""
if self.current.lane_name:
if self.current.old_lane and self.current.lane_name != self.current.old_lane:
... | python | def catch_lane_change(self):
"""
trigger a lane_user_change signal if we switched to a new lane
and new lane's user is different from current one
"""
if self.current.lane_name:
if self.current.old_lane and self.current.lane_name != self.current.old_lane:
... | [
"def",
"catch_lane_change",
"(",
"self",
")",
":",
"if",
"self",
".",
"current",
".",
"lane_name",
":",
"if",
"self",
".",
"current",
".",
"old_lane",
"and",
"self",
".",
"current",
".",
"lane_name",
"!=",
"self",
".",
"current",
".",
"old_lane",
":",
... | trigger a lane_user_change signal if we switched to a new lane
and new lane's user is different from current one | [
"trigger",
"a",
"lane_user_change",
"signal",
"if",
"we",
"switched",
"to",
"a",
"new",
"lane",
"and",
"new",
"lane",
"s",
"user",
"is",
"different",
"from",
"current",
"one"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L518-L535 | train |
zetaops/zengine | zengine/engine.py | ZEngine.parse_workflow_messages | def parse_workflow_messages(self):
"""
Transmits client message that defined in
a workflow task's inputOutput extension
.. code-block:: xml
<bpmn2:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="client_message">
<cam... | python | def parse_workflow_messages(self):
"""
Transmits client message that defined in
a workflow task's inputOutput extension
.. code-block:: xml
<bpmn2:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="client_message">
<cam... | [
"def",
"parse_workflow_messages",
"(",
"self",
")",
":",
"if",
"'client_message'",
"in",
"self",
".",
"current",
".",
"spec",
".",
"data",
":",
"m",
"=",
"self",
".",
"current",
".",
"spec",
".",
"data",
"[",
"'client_message'",
"]",
"self",
".",
"curren... | Transmits client message that defined in
a workflow task's inputOutput extension
.. code-block:: xml
<bpmn2:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="client_message">
<camunda:map>
<camunda:entry key="title">Teşe... | [
"Transmits",
"client",
"message",
"that",
"defined",
"in",
"a",
"workflow",
"task",
"s",
"inputOutput",
"extension"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L538-L562 | train |
zetaops/zengine | zengine/engine.py | ZEngine.run_activity | def run_activity(self):
"""
runs the method that referenced from current task
"""
activity = self.current.activity
if activity:
if activity not in self.wf_activities:
self._load_activity(activity)
self.current.log.debug(
"Ca... | python | def run_activity(self):
"""
runs the method that referenced from current task
"""
activity = self.current.activity
if activity:
if activity not in self.wf_activities:
self._load_activity(activity)
self.current.log.debug(
"Ca... | [
"def",
"run_activity",
"(",
"self",
")",
":",
"activity",
"=",
"self",
".",
"current",
".",
"activity",
"if",
"activity",
":",
"if",
"activity",
"not",
"in",
"self",
".",
"wf_activities",
":",
"self",
".",
"_load_activity",
"(",
"activity",
")",
"self",
... | runs the method that referenced from current task | [
"runs",
"the",
"method",
"that",
"referenced",
"from",
"current",
"task"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L573-L583 | train |
zetaops/zengine | zengine/engine.py | ZEngine._import_object | def _import_object(self, path, look_for_cls_method):
"""
Imports the module that contains the referenced method.
Args:
path: python path of class/function
look_for_cls_method (bool): If True, treat the last part of path as class method.
Returns:
Tupl... | python | def _import_object(self, path, look_for_cls_method):
"""
Imports the module that contains the referenced method.
Args:
path: python path of class/function
look_for_cls_method (bool): If True, treat the last part of path as class method.
Returns:
Tupl... | [
"def",
"_import_object",
"(",
"self",
",",
"path",
",",
"look_for_cls_method",
")",
":",
"last_nth",
"=",
"2",
"if",
"look_for_cls_method",
"else",
"1",
"path",
"=",
"path",
".",
"split",
"(",
"'.'",
")",
"module_path",
"=",
"'.'",
".",
"join",
"(",
"pat... | Imports the module that contains the referenced method.
Args:
path: python path of class/function
look_for_cls_method (bool): If True, treat the last part of path as class method.
Returns:
Tuple. (class object, class name, method to be called) | [
"Imports",
"the",
"module",
"that",
"contains",
"the",
"referenced",
"method",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L585-L606 | train |
zetaops/zengine | zengine/engine.py | ZEngine._load_activity | def _load_activity(self, activity):
"""
Iterates trough the all enabled `~zengine.settings.ACTIVITY_MODULES_IMPORT_PATHS` to find the given path.
"""
fpths = []
full_path = ''
errors = []
paths = settings.ACTIVITY_MODULES_IMPORT_PATHS
number_of_paths = len... | python | def _load_activity(self, activity):
"""
Iterates trough the all enabled `~zengine.settings.ACTIVITY_MODULES_IMPORT_PATHS` to find the given path.
"""
fpths = []
full_path = ''
errors = []
paths = settings.ACTIVITY_MODULES_IMPORT_PATHS
number_of_paths = len... | [
"def",
"_load_activity",
"(",
"self",
",",
"activity",
")",
":",
"fpths",
"=",
"[",
"]",
"full_path",
"=",
"''",
"errors",
"=",
"[",
"]",
"paths",
"=",
"settings",
".",
"ACTIVITY_MODULES_IMPORT_PATHS",
"number_of_paths",
"=",
"len",
"(",
"paths",
")",
"for... | Iterates trough the all enabled `~zengine.settings.ACTIVITY_MODULES_IMPORT_PATHS` to find the given path. | [
"Iterates",
"trough",
"the",
"all",
"enabled",
"~zengine",
".",
"settings",
".",
"ACTIVITY_MODULES_IMPORT_PATHS",
"to",
"find",
"the",
"given",
"path",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L608-L643 | train |
zetaops/zengine | zengine/engine.py | ZEngine.check_for_authentication | def check_for_authentication(self):
"""
Checks current workflow against :py:data:`~zengine.settings.ANONYMOUS_WORKFLOWS` list.
Raises:
HTTPUnauthorized: if WF needs an authenticated user and current user isn't.
"""
auth_required = self.current.workflow_name not in se... | python | def check_for_authentication(self):
"""
Checks current workflow against :py:data:`~zengine.settings.ANONYMOUS_WORKFLOWS` list.
Raises:
HTTPUnauthorized: if WF needs an authenticated user and current user isn't.
"""
auth_required = self.current.workflow_name not in se... | [
"def",
"check_for_authentication",
"(",
"self",
")",
":",
"auth_required",
"=",
"self",
".",
"current",
".",
"workflow_name",
"not",
"in",
"settings",
".",
"ANONYMOUS_WORKFLOWS",
"if",
"auth_required",
"and",
"not",
"self",
".",
"current",
".",
"is_auth",
":",
... | Checks current workflow against :py:data:`~zengine.settings.ANONYMOUS_WORKFLOWS` list.
Raises:
HTTPUnauthorized: if WF needs an authenticated user and current user isn't. | [
"Checks",
"current",
"workflow",
"against",
":",
"py",
":",
"data",
":",
"~zengine",
".",
"settings",
".",
"ANONYMOUS_WORKFLOWS",
"list",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L645-L655 | train |
zetaops/zengine | zengine/engine.py | ZEngine.check_for_lane_permission | def check_for_lane_permission(self):
"""
One or more permissions can be associated with a lane
of a workflow. In a similar way, a lane can be
restricted with relation to other lanes of the workflow.
This method called on lane changes and checks user has
required permissi... | python | def check_for_lane_permission(self):
"""
One or more permissions can be associated with a lane
of a workflow. In a similar way, a lane can be
restricted with relation to other lanes of the workflow.
This method called on lane changes and checks user has
required permissi... | [
"def",
"check_for_lane_permission",
"(",
"self",
")",
":",
"# TODO: Cache lane_data in app memory",
"if",
"self",
".",
"current",
".",
"lane_permission",
":",
"log",
".",
"debug",
"(",
"\"HAS LANE PERM: %s\"",
"%",
"self",
".",
"current",
".",
"lane_permission",
")"... | One or more permissions can be associated with a lane
of a workflow. In a similar way, a lane can be
restricted with relation to other lanes of the workflow.
This method called on lane changes and checks user has
required permissions and relations.
Raises:
HTTPForb... | [
"One",
"or",
"more",
"permissions",
"can",
"be",
"associated",
"with",
"a",
"lane",
"of",
"a",
"workflow",
".",
"In",
"a",
"similar",
"way",
"a",
"lane",
"can",
"be",
"restricted",
"with",
"relation",
"to",
"other",
"lanes",
"of",
"the",
"workflow",
"."
... | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L657-L690 | train |
zetaops/zengine | zengine/engine.py | ZEngine.check_for_permission | def check_for_permission(self):
# TODO: Works but not beautiful, needs review!
"""
Checks if current user (or role) has the required permission
for current workflow step.
Raises:
HTTPError: if user doesn't have required permissions.
"""
if self.curren... | python | def check_for_permission(self):
# TODO: Works but not beautiful, needs review!
"""
Checks if current user (or role) has the required permission
for current workflow step.
Raises:
HTTPError: if user doesn't have required permissions.
"""
if self.curren... | [
"def",
"check_for_permission",
"(",
"self",
")",
":",
"# TODO: Works but not beautiful, needs review!",
"if",
"self",
".",
"current",
".",
"task",
":",
"lane",
"=",
"self",
".",
"current",
".",
"lane_id",
"permission",
"=",
"\"%s.%s.%s\"",
"%",
"(",
"self",
".",... | Checks if current user (or role) has the required permission
for current workflow step.
Raises:
HTTPError: if user doesn't have required permissions. | [
"Checks",
"if",
"current",
"user",
"(",
"or",
"role",
")",
"has",
"the",
"required",
"permission",
"for",
"current",
"workflow",
"step",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L692-L716 | train |
zetaops/zengine | zengine/engine.py | ZEngine.handle_wf_finalization | def handle_wf_finalization(self):
"""
Removes the ``token`` key from ``current.output`` if WF is over.
"""
if ((not self.current.flow_enabled or (
self.current.task_type.startswith('End') and not self.are_we_in_subprocess())) and
'token' in self.current.ou... | python | def handle_wf_finalization(self):
"""
Removes the ``token`` key from ``current.output`` if WF is over.
"""
if ((not self.current.flow_enabled or (
self.current.task_type.startswith('End') and not self.are_we_in_subprocess())) and
'token' in self.current.ou... | [
"def",
"handle_wf_finalization",
"(",
"self",
")",
":",
"if",
"(",
"(",
"not",
"self",
".",
"current",
".",
"flow_enabled",
"or",
"(",
"self",
".",
"current",
".",
"task_type",
".",
"startswith",
"(",
"'End'",
")",
"and",
"not",
"self",
".",
"are_we_in_s... | Removes the ``token`` key from ``current.output`` if WF is over. | [
"Removes",
"the",
"token",
"key",
"from",
"current",
".",
"output",
"if",
"WF",
"is",
"over",
"."
] | b5bc32d3b37bca799f8985be916f04528ac79e4a | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L718-L725 | train |
cimm-kzn/CGRtools | CGRtools/utils/rdkit.py | from_rdkit_molecule | def from_rdkit_molecule(data):
"""
RDKit molecule object to MoleculeContainer converter
"""
m = MoleculeContainer()
atoms, mapping = [], []
for a in data.GetAtoms():
atom = {'element': a.GetSymbol(), 'charge': a.GetFormalCharge()}
atoms.append(atom)
mapping.append(a.GetAt... | python | def from_rdkit_molecule(data):
"""
RDKit molecule object to MoleculeContainer converter
"""
m = MoleculeContainer()
atoms, mapping = [], []
for a in data.GetAtoms():
atom = {'element': a.GetSymbol(), 'charge': a.GetFormalCharge()}
atoms.append(atom)
mapping.append(a.GetAt... | [
"def",
"from_rdkit_molecule",
"(",
"data",
")",
":",
"m",
"=",
"MoleculeContainer",
"(",
")",
"atoms",
",",
"mapping",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"a",
"in",
"data",
".",
"GetAtoms",
"(",
")",
":",
"atom",
"=",
"{",
"'element'",
":",
"a",
... | RDKit molecule object to MoleculeContainer converter | [
"RDKit",
"molecule",
"object",
"to",
"MoleculeContainer",
"converter"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/utils/rdkit.py#L23-L56 | train |
cimm-kzn/CGRtools | CGRtools/utils/rdkit.py | to_rdkit_molecule | def to_rdkit_molecule(data):
"""
MoleculeContainer to RDKit molecule object converter
"""
mol = RWMol()
conf = Conformer()
mapping = {}
is_3d = False
for n, a in data.atoms():
ra = Atom(a.number)
ra.SetAtomMapNum(n)
if a.charge:
ra.SetFormalCharge(a.ch... | python | def to_rdkit_molecule(data):
"""
MoleculeContainer to RDKit molecule object converter
"""
mol = RWMol()
conf = Conformer()
mapping = {}
is_3d = False
for n, a in data.atoms():
ra = Atom(a.number)
ra.SetAtomMapNum(n)
if a.charge:
ra.SetFormalCharge(a.ch... | [
"def",
"to_rdkit_molecule",
"(",
"data",
")",
":",
"mol",
"=",
"RWMol",
"(",
")",
"conf",
"=",
"Conformer",
"(",
")",
"mapping",
"=",
"{",
"}",
"is_3d",
"=",
"False",
"for",
"n",
",",
"a",
"in",
"data",
".",
"atoms",
"(",
")",
":",
"ra",
"=",
"... | MoleculeContainer to RDKit molecule object converter | [
"MoleculeContainer",
"to",
"RDKit",
"molecule",
"object",
"converter"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/utils/rdkit.py#L59-L88 | train |
cimm-kzn/CGRtools | CGRtools/algorithms/strings.py | StringCommon.__dfs | def __dfs(self, start, weights, depth_limit):
"""
modified NX dfs
"""
adj = self._adj
stack = [(start, depth_limit, iter(sorted(adj[start], key=weights)))]
visited = {start}
disconnected = defaultdict(list)
edges = defaultdict(list)
while stack:
... | python | def __dfs(self, start, weights, depth_limit):
"""
modified NX dfs
"""
adj = self._adj
stack = [(start, depth_limit, iter(sorted(adj[start], key=weights)))]
visited = {start}
disconnected = defaultdict(list)
edges = defaultdict(list)
while stack:
... | [
"def",
"__dfs",
"(",
"self",
",",
"start",
",",
"weights",
",",
"depth_limit",
")",
":",
"adj",
"=",
"self",
".",
"_adj",
"stack",
"=",
"[",
"(",
"start",
",",
"depth_limit",
",",
"iter",
"(",
"sorted",
"(",
"adj",
"[",
"start",
"]",
",",
"key",
... | modified NX dfs | [
"modified",
"NX",
"dfs"
] | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/strings.py#L130-L158 | train |
camptocamp/marabunta | marabunta/config.py | get_args_parser | def get_args_parser():
"""Return a parser for command line options."""
parser = argparse.ArgumentParser(
description='Marabunta: Migrating ants for Odoo')
parser.add_argument('--migration-file', '-f',
action=EnvDefault,
envvar='MARABUNTA_MIGRATION_FILE... | python | def get_args_parser():
"""Return a parser for command line options."""
parser = argparse.ArgumentParser(
description='Marabunta: Migrating ants for Odoo')
parser.add_argument('--migration-file', '-f',
action=EnvDefault,
envvar='MARABUNTA_MIGRATION_FILE... | [
"def",
"get_args_parser",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Marabunta: Migrating ants for Odoo'",
")",
"parser",
".",
"add_argument",
"(",
"'--migration-file'",
",",
"'-f'",
",",
"action",
"=",
"EnvDefault",
... | Return a parser for command line options. | [
"Return",
"a",
"parser",
"for",
"command",
"line",
"options",
"."
] | ec3a7a725c7426d6ed642e0a80119b37880eb91e | https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/config.py#L90-L161 | train |
camptocamp/marabunta | marabunta/config.py | Config.from_parse_args | def from_parse_args(cls, args):
"""Constructor from command line args.
:param args: parse command line arguments
:type args: argparse.ArgumentParser
"""
return cls(args.migration_file,
args.database,
db_user=args.db_user,
... | python | def from_parse_args(cls, args):
"""Constructor from command line args.
:param args: parse command line arguments
:type args: argparse.ArgumentParser
"""
return cls(args.migration_file,
args.database,
db_user=args.db_user,
... | [
"def",
"from_parse_args",
"(",
"cls",
",",
"args",
")",
":",
"return",
"cls",
"(",
"args",
".",
"migration_file",
",",
"args",
".",
"database",
",",
"db_user",
"=",
"args",
".",
"db_user",
",",
"db_password",
"=",
"args",
".",
"db_password",
",",
"db_por... | Constructor from command line args.
:param args: parse command line arguments
:type args: argparse.ArgumentParser | [
"Constructor",
"from",
"command",
"line",
"args",
"."
] | ec3a7a725c7426d6ed642e0a80119b37880eb91e | https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/config.py#L40-L60 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.