repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
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",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L241-L289 |
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",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L291-L311 |
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",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L316-L365 |
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",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L367-L408 |
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",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L410-L418 |
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"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L432-L477 |
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... | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L479-L506 |
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",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L508-L516 |
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"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L518-L535 |
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"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L538-L562 |
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"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L573-L583 |
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",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L585-L606 |
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",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L608-L643 |
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",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L645-L655 |
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",
"."
... | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L657-L690 |
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",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L692-L716 |
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",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/engine.py#L718-L725 |
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"
] | train | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/utils/rdkit.py#L23-L56 |
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"
] | train | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/utils/rdkit.py#L59-L88 |
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"
] | train | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/algorithms/strings.py#L130-L158 |
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",
"."
] | train | https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/config.py#L90-L161 |
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",
"."
] | train | https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/config.py#L40-L60 |
zetaops/zengine | zengine/views/base.py | BaseView.set_current | def set_current(self, current):
"""
Creates some aliases for attributes of ``current``.
Args:
current: :attr:`~zengine.engine.WFCurrent` object.
"""
self.current = current
self.input = current.input
# self.req = current.request
# self.resp = c... | python | def set_current(self, current):
"""
Creates some aliases for attributes of ``current``.
Args:
current: :attr:`~zengine.engine.WFCurrent` object.
"""
self.current = current
self.input = current.input
# self.req = current.request
# self.resp = c... | [
"def",
"set_current",
"(",
"self",
",",
"current",
")",
":",
"self",
".",
"current",
"=",
"current",
"self",
".",
"input",
"=",
"current",
".",
"input",
"# self.req = current.request",
"# self.resp = current.response",
"self",
".",
"output",
"=",
"current",
".",... | Creates some aliases for attributes of ``current``.
Args:
current: :attr:`~zengine.engine.WFCurrent` object. | [
"Creates",
"some",
"aliases",
"for",
"attributes",
"of",
"current",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/base.py#L35-L52 |
zetaops/zengine | zengine/views/base.py | BaseView.form_out | def form_out(self, _form=None):
"""
Renders form. Applies form modifiers, then writes
result to response payload. If supplied, given form
object instance will be used instead of view's
default ObjectForm.
Args:
_form (:py:attr:`~zengine.forms.json_form.JsonF... | python | def form_out(self, _form=None):
"""
Renders form. Applies form modifiers, then writes
result to response payload. If supplied, given form
object instance will be used instead of view's
default ObjectForm.
Args:
_form (:py:attr:`~zengine.forms.json_form.JsonF... | [
"def",
"form_out",
"(",
"self",
",",
"_form",
"=",
"None",
")",
":",
"_form",
"=",
"_form",
"or",
"self",
".",
"object_form",
"self",
".",
"output",
"[",
"'forms'",
"]",
"=",
"_form",
".",
"serialize",
"(",
")",
"self",
".",
"_add_meta_props",
"(",
"... | Renders form. Applies form modifiers, then writes
result to response payload. If supplied, given form
object instance will be used instead of view's
default ObjectForm.
Args:
_form (:py:attr:`~zengine.forms.json_form.JsonForm`):
Form object to override `self.o... | [
"Renders",
"form",
".",
"Applies",
"form",
"modifiers",
"then",
"writes",
"result",
"to",
"response",
"payload",
".",
"If",
"supplied",
"given",
"form",
"object",
"instance",
"will",
"be",
"used",
"instead",
"of",
"view",
"s",
"default",
"ObjectForm",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/base.py#L86-L103 |
zetaops/zengine | zengine/views/base.py | BaseView.set_client_cmd | def set_client_cmd(self, *args):
"""
Adds given cmd(s) to ``self.output['client_cmd']``
Args:
*args: Client commands.
"""
self.client_cmd.update(args)
self.output['client_cmd'] = list(self.client_cmd) | python | def set_client_cmd(self, *args):
"""
Adds given cmd(s) to ``self.output['client_cmd']``
Args:
*args: Client commands.
"""
self.client_cmd.update(args)
self.output['client_cmd'] = list(self.client_cmd) | [
"def",
"set_client_cmd",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"client_cmd",
".",
"update",
"(",
"args",
")",
"self",
".",
"output",
"[",
"'client_cmd'",
"]",
"=",
"list",
"(",
"self",
".",
"client_cmd",
")"
] | Adds given cmd(s) to ``self.output['client_cmd']``
Args:
*args: Client commands. | [
"Adds",
"given",
"cmd",
"(",
"s",
")",
"to",
"self",
".",
"output",
"[",
"client_cmd",
"]"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/base.py#L117-L125 |
zetaops/zengine | zengine/management_commands.py | UpdatePermissions.run | def run(self):
"""
Creates new permissions.
"""
from pyoko.lib.utils import get_object_from_path
from zengine.config import settings
model = get_object_from_path(settings.PERMISSION_MODEL)
perm_provider = get_object_from_path(settings.PERMISSION_PROVIDER)
... | python | def run(self):
"""
Creates new permissions.
"""
from pyoko.lib.utils import get_object_from_path
from zengine.config import settings
model = get_object_from_path(settings.PERMISSION_MODEL)
perm_provider = get_object_from_path(settings.PERMISSION_PROVIDER)
... | [
"def",
"run",
"(",
"self",
")",
":",
"from",
"pyoko",
".",
"lib",
".",
"utils",
"import",
"get_object_from_path",
"from",
"zengine",
".",
"config",
"import",
"settings",
"model",
"=",
"get_object_from_path",
"(",
"settings",
".",
"PERMISSION_MODEL",
")",
"perm... | Creates new permissions. | [
"Creates",
"new",
"permissions",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L44-L92 |
zetaops/zengine | zengine/management_commands.py | CreateUser.run | def run(self):
"""
Creates user, encrypts password.
"""
from zengine.models import User
user = User(username=self.manager.args.username, superuser=self.manager.args.super)
user.set_password(self.manager.args.password)
user.save()
print("New user created wi... | python | def run(self):
"""
Creates user, encrypts password.
"""
from zengine.models import User
user = User(username=self.manager.args.username, superuser=self.manager.args.super)
user.set_password(self.manager.args.password)
user.save()
print("New user created wi... | [
"def",
"run",
"(",
"self",
")",
":",
"from",
"zengine",
".",
"models",
"import",
"User",
"user",
"=",
"User",
"(",
"username",
"=",
"self",
".",
"manager",
".",
"args",
".",
"username",
",",
"superuser",
"=",
"self",
".",
"manager",
".",
"args",
".",... | Creates user, encrypts password. | [
"Creates",
"user",
"encrypts",
"password",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L110-L118 |
zetaops/zengine | zengine/management_commands.py | RunServer.run | def run(self):
"""
Starts a development server for the zengine application
"""
print("Development server started on http://%s:%s. \n\nPress Ctrl+C to stop\n" % (
self.manager.args.addr,
self.manager.args.port)
)
if self.manager.args.server_ty... | python | def run(self):
"""
Starts a development server for the zengine application
"""
print("Development server started on http://%s:%s. \n\nPress Ctrl+C to stop\n" % (
self.manager.args.addr,
self.manager.args.port)
)
if self.manager.args.server_ty... | [
"def",
"run",
"(",
"self",
")",
":",
"print",
"(",
"\"Development server started on http://%s:%s. \\n\\nPress Ctrl+C to stop\\n\"",
"%",
"(",
"self",
".",
"manager",
".",
"args",
".",
"addr",
",",
"self",
".",
"manager",
".",
"args",
".",
"port",
")",
")",
"if... | Starts a development server for the zengine application | [
"Starts",
"a",
"development",
"server",
"for",
"the",
"zengine",
"application"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L139-L150 |
zetaops/zengine | zengine/management_commands.py | RunServer.run_with_tornado | def run_with_tornado(self):
"""
runs the tornado/websockets based test server
"""
from zengine.tornado_server.server import runserver
runserver(self.manager.args.addr, int(self.manager.args.port)) | python | def run_with_tornado(self):
"""
runs the tornado/websockets based test server
"""
from zengine.tornado_server.server import runserver
runserver(self.manager.args.addr, int(self.manager.args.port)) | [
"def",
"run_with_tornado",
"(",
"self",
")",
":",
"from",
"zengine",
".",
"tornado_server",
".",
"server",
"import",
"runserver",
"runserver",
"(",
"self",
".",
"manager",
".",
"args",
".",
"addr",
",",
"int",
"(",
"self",
".",
"manager",
".",
"args",
".... | runs the tornado/websockets based test server | [
"runs",
"the",
"tornado",
"/",
"websockets",
"based",
"test",
"server"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L152-L157 |
zetaops/zengine | zengine/management_commands.py | RunServer.run_with_falcon | def run_with_falcon(self):
"""
runs the falcon/http based test server
"""
from wsgiref import simple_server
from zengine.server import app
httpd = simple_server.make_server(self.manager.args.addr, int(self.manager.args.port), app)
httpd.serve_forever() | python | def run_with_falcon(self):
"""
runs the falcon/http based test server
"""
from wsgiref import simple_server
from zengine.server import app
httpd = simple_server.make_server(self.manager.args.addr, int(self.manager.args.port), app)
httpd.serve_forever() | [
"def",
"run_with_falcon",
"(",
"self",
")",
":",
"from",
"wsgiref",
"import",
"simple_server",
"from",
"zengine",
".",
"server",
"import",
"app",
"httpd",
"=",
"simple_server",
".",
"make_server",
"(",
"self",
".",
"manager",
".",
"args",
".",
"addr",
",",
... | runs the falcon/http based test server | [
"runs",
"the",
"falcon",
"/",
"http",
"based",
"test",
"server"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L159-L166 |
zetaops/zengine | zengine/management_commands.py | RunWorker.run | def run(self):
"""
Starts a development server for the zengine application
"""
from zengine.wf_daemon import run_workers, Worker
worker_count = int(self.manager.args.workers or 1)
if not self.manager.args.daemonize:
print("Starting worker(s)")
if wor... | python | def run(self):
"""
Starts a development server for the zengine application
"""
from zengine.wf_daemon import run_workers, Worker
worker_count = int(self.manager.args.workers or 1)
if not self.manager.args.daemonize:
print("Starting worker(s)")
if wor... | [
"def",
"run",
"(",
"self",
")",
":",
"from",
"zengine",
".",
"wf_daemon",
"import",
"run_workers",
",",
"Worker",
"worker_count",
"=",
"int",
"(",
"self",
".",
"manager",
".",
"args",
".",
"workers",
"or",
"1",
")",
"if",
"not",
"self",
".",
"manager",... | Starts a development server for the zengine application | [
"Starts",
"a",
"development",
"server",
"for",
"the",
"zengine",
"application"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L187-L203 |
zetaops/zengine | zengine/management_commands.py | ExtractTranslations._prepare_domain | def _prepare_domain(mapping):
"""Prepare a helper dictionary for the domain to temporarily hold some information."""
# Parse the domain-directory mapping
try:
domain, dir = mapping.split(':')
except ValueError:
print("Please provide the sources in the form of '<do... | python | def _prepare_domain(mapping):
"""Prepare a helper dictionary for the domain to temporarily hold some information."""
# Parse the domain-directory mapping
try:
domain, dir = mapping.split(':')
except ValueError:
print("Please provide the sources in the form of '<do... | [
"def",
"_prepare_domain",
"(",
"mapping",
")",
":",
"# Parse the domain-directory mapping",
"try",
":",
"domain",
",",
"dir",
"=",
"mapping",
".",
"split",
"(",
"':'",
")",
"except",
"ValueError",
":",
"print",
"(",
"\"Please provide the sources in the form of '<domai... | Prepare a helper dictionary for the domain to temporarily hold some information. | [
"Prepare",
"a",
"helper",
"dictionary",
"for",
"the",
"domain",
"to",
"temporarily",
"hold",
"some",
"information",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L227-L248 |
zetaops/zengine | zengine/management_commands.py | ExtractTranslations._validate_domains | def _validate_domains(domains):
"""Check that all domains specified in the settings was provided in the options."""
missing = set(settings.TRANSLATION_DOMAINS.keys()) - set(domains.keys())
if missing:
print('The following domains have been set in the configuration, '
... | python | def _validate_domains(domains):
"""Check that all domains specified in the settings was provided in the options."""
missing = set(settings.TRANSLATION_DOMAINS.keys()) - set(domains.keys())
if missing:
print('The following domains have been set in the configuration, '
... | [
"def",
"_validate_domains",
"(",
"domains",
")",
":",
"missing",
"=",
"set",
"(",
"settings",
".",
"TRANSLATION_DOMAINS",
".",
"keys",
"(",
")",
")",
"-",
"set",
"(",
"domains",
".",
"keys",
"(",
")",
")",
"if",
"missing",
":",
"print",
"(",
"'The foll... | Check that all domains specified in the settings was provided in the options. | [
"Check",
"that",
"all",
"domains",
"specified",
"in",
"the",
"settings",
"was",
"provided",
"in",
"the",
"options",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L251-L258 |
zetaops/zengine | zengine/management_commands.py | ExtractTranslations._extract_translations | def _extract_translations(self, domains):
"""Extract the translations into `.pot` files"""
for domain, options in domains.items():
# Create the extractor
extractor = babel_frontend.extract_messages()
extractor.initialize_options()
# The temporary location ... | python | def _extract_translations(self, domains):
"""Extract the translations into `.pot` files"""
for domain, options in domains.items():
# Create the extractor
extractor = babel_frontend.extract_messages()
extractor.initialize_options()
# The temporary location ... | [
"def",
"_extract_translations",
"(",
"self",
",",
"domains",
")",
":",
"for",
"domain",
",",
"options",
"in",
"domains",
".",
"items",
"(",
")",
":",
"# Create the extractor",
"extractor",
"=",
"babel_frontend",
".",
"extract_messages",
"(",
")",
"extractor",
... | Extract the translations into `.pot` files | [
"Extract",
"the",
"translations",
"into",
".",
"pot",
"files"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L260-L286 |
zetaops/zengine | zengine/management_commands.py | ExtractTranslations._init_update_po_files | def _init_update_po_files(self, domains):
"""Update or initialize the `.po` translation files"""
for language in settings.TRANSLATIONS:
for domain, options in domains.items():
if language == options['default']: continue # Default language of the domain doesn't need translati... | python | def _init_update_po_files(self, domains):
"""Update or initialize the `.po` translation files"""
for language in settings.TRANSLATIONS:
for domain, options in domains.items():
if language == options['default']: continue # Default language of the domain doesn't need translati... | [
"def",
"_init_update_po_files",
"(",
"self",
",",
"domains",
")",
":",
"for",
"language",
"in",
"settings",
".",
"TRANSLATIONS",
":",
"for",
"domain",
",",
"options",
"in",
"domains",
".",
"items",
"(",
")",
":",
"if",
"language",
"==",
"options",
"[",
"... | Update or initialize the `.po` translation files | [
"Update",
"or",
"initialize",
"the",
".",
"po",
"translation",
"files"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L288-L298 |
zetaops/zengine | zengine/management_commands.py | ExtractTranslations._cleanup | def _cleanup(self, domains):
"""Remove the temporary '.pot' files that were created for the domains."""
for option in domains.values():
try:
os.remove(option['pot'])
except (IOError, OSError):
# It is not a problem if we can't actually remove the t... | python | def _cleanup(self, domains):
"""Remove the temporary '.pot' files that were created for the domains."""
for option in domains.values():
try:
os.remove(option['pot'])
except (IOError, OSError):
# It is not a problem if we can't actually remove the t... | [
"def",
"_cleanup",
"(",
"self",
",",
"domains",
")",
":",
"for",
"option",
"in",
"domains",
".",
"values",
"(",
")",
":",
"try",
":",
"os",
".",
"remove",
"(",
"option",
"[",
"'pot'",
"]",
")",
"except",
"(",
"IOError",
",",
"OSError",
")",
":",
... | Remove the temporary '.pot' files that were created for the domains. | [
"Remove",
"the",
"temporary",
".",
"pot",
"files",
"that",
"were",
"created",
"for",
"the",
"domains",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L312-L319 |
zetaops/zengine | zengine/management_commands.py | LoadDiagrams.run | def run(self):
"""
read workflows, checks if it's updated,
tries to update if there aren't any running instances of that wf
"""
from zengine.lib.cache import WFSpecNames
if self.manager.args.clear:
self._clear_models()
return
if self.mana... | python | def run(self):
"""
read workflows, checks if it's updated,
tries to update if there aren't any running instances of that wf
"""
from zengine.lib.cache import WFSpecNames
if self.manager.args.clear:
self._clear_models()
return
if self.mana... | [
"def",
"run",
"(",
"self",
")",
":",
"from",
"zengine",
".",
"lib",
".",
"cache",
"import",
"WFSpecNames",
"if",
"self",
".",
"manager",
".",
"args",
".",
"clear",
":",
"self",
".",
"_clear_models",
"(",
")",
"return",
"if",
"self",
".",
"manager",
"... | read workflows, checks if it's updated,
tries to update if there aren't any running instances of that wf | [
"read",
"workflows",
"checks",
"if",
"it",
"s",
"updated",
"tries",
"to",
"update",
"if",
"there",
"aren",
"t",
"any",
"running",
"instances",
"of",
"that",
"wf"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L450-L472 |
zetaops/zengine | zengine/management_commands.py | LoadDiagrams.get_wf_from_path | def get_wf_from_path(self, path):
"""
load xml from given path
Args:
path: diagram path
Returns:
"""
with open(path) as fp:
content = fp.read()
return [(os.path.basename(os.path.splitext(path)[0]), content), ] | python | def get_wf_from_path(self, path):
"""
load xml from given path
Args:
path: diagram path
Returns:
"""
with open(path) as fp:
content = fp.read()
return [(os.path.basename(os.path.splitext(path)[0]), content), ] | [
"def",
"get_wf_from_path",
"(",
"self",
",",
"path",
")",
":",
"with",
"open",
"(",
"path",
")",
"as",
"fp",
":",
"content",
"=",
"fp",
".",
"read",
"(",
")",
"return",
"[",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"os",
".",
"path",
".",
... | load xml from given path
Args:
path: diagram path
Returns: | [
"load",
"xml",
"from",
"given",
"path",
"Args",
":",
"path",
":",
"diagram",
"path"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L515-L526 |
zetaops/zengine | zengine/management_commands.py | LoadDiagrams.get_workflows | def get_workflows(self):
"""
Scans and loads all wf found under WORKFLOW_PACKAGES_PATHS
Yields: XML content of diagram file
"""
for pth in settings.WORKFLOW_PACKAGES_PATHS:
for f in glob.glob("%s/*.bpmn" % pth):
with open(f) as fp:
... | python | def get_workflows(self):
"""
Scans and loads all wf found under WORKFLOW_PACKAGES_PATHS
Yields: XML content of diagram file
"""
for pth in settings.WORKFLOW_PACKAGES_PATHS:
for f in glob.glob("%s/*.bpmn" % pth):
with open(f) as fp:
... | [
"def",
"get_workflows",
"(",
"self",
")",
":",
"for",
"pth",
"in",
"settings",
".",
"WORKFLOW_PACKAGES_PATHS",
":",
"for",
"f",
"in",
"glob",
".",
"glob",
"(",
"\"%s/*.bpmn\"",
"%",
"pth",
")",
":",
"with",
"open",
"(",
"f",
")",
"as",
"fp",
":",
"yi... | Scans and loads all wf found under WORKFLOW_PACKAGES_PATHS
Yields: XML content of diagram file | [
"Scans",
"and",
"loads",
"all",
"wf",
"found",
"under",
"WORKFLOW_PACKAGES_PATHS"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L528-L538 |
zetaops/zengine | zengine/management_commands.py | CheckList.check_migration_and_solr | def check_migration_and_solr(self):
"""
The model or models are checked for migrations that need to be done.
Solr is also checked.
"""
from pyoko.db.schema_update import SchemaUpdater
from socket import error as socket_error
from pyoko.conf import settings... | python | def check_migration_and_solr(self):
"""
The model or models are checked for migrations that need to be done.
Solr is also checked.
"""
from pyoko.db.schema_update import SchemaUpdater
from socket import error as socket_error
from pyoko.conf import settings... | [
"def",
"check_migration_and_solr",
"(",
"self",
")",
":",
"from",
"pyoko",
".",
"db",
".",
"schema_update",
"import",
"SchemaUpdater",
"from",
"socket",
"import",
"error",
"as",
"socket_error",
"from",
"pyoko",
".",
"conf",
"import",
"settings",
"from",
"importl... | The model or models are checked for migrations that need to be done.
Solr is also checked. | [
"The",
"model",
"or",
"models",
"are",
"checked",
"for",
"migrations",
"that",
"need",
"to",
"be",
"done",
".",
"Solr",
"is",
"also",
"checked",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L563-L583 |
zetaops/zengine | zengine/management_commands.py | CheckList.check_redis | def check_redis():
"""
Redis checks the connection
It displays on the screen whether or not you have a connection.
"""
from pyoko.db.connection import cache
from redis.exceptions import ConnectionError
try:
cache.ping()
print(Check... | python | def check_redis():
"""
Redis checks the connection
It displays on the screen whether or not you have a connection.
"""
from pyoko.db.connection import cache
from redis.exceptions import ConnectionError
try:
cache.ping()
print(Check... | [
"def",
"check_redis",
"(",
")",
":",
"from",
"pyoko",
".",
"db",
".",
"connection",
"import",
"cache",
"from",
"redis",
".",
"exceptions",
"import",
"ConnectionError",
"try",
":",
"cache",
".",
"ping",
"(",
")",
"print",
"(",
"CheckList",
".",
"OKGREEN",
... | Redis checks the connection
It displays on the screen whether or not you have a connection. | [
"Redis",
"checks",
"the",
"connection",
"It",
"displays",
"on",
"the",
"screen",
"whether",
"or",
"not",
"you",
"have",
"a",
"connection",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L586-L599 |
zetaops/zengine | zengine/management_commands.py | CheckList.check_riak | def check_riak():
"""
Riak checks the connection
It displays on the screen whether or not you have a connection.
"""
from pyoko.db.connection import client
from socket import error as socket_error
try:
if client.ping():
print(_... | python | def check_riak():
"""
Riak checks the connection
It displays on the screen whether or not you have a connection.
"""
from pyoko.db.connection import client
from socket import error as socket_error
try:
if client.ping():
print(_... | [
"def",
"check_riak",
"(",
")",
":",
"from",
"pyoko",
".",
"db",
".",
"connection",
"import",
"client",
"from",
"socket",
"import",
"error",
"as",
"socket_error",
"try",
":",
"if",
"client",
".",
"ping",
"(",
")",
":",
"print",
"(",
"__",
"(",
"u\"{0}Ri... | Riak checks the connection
It displays on the screen whether or not you have a connection. | [
"Riak",
"checks",
"the",
"connection",
"It",
"displays",
"on",
"the",
"screen",
"whether",
"or",
"not",
"you",
"have",
"a",
"connection",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L602-L617 |
zetaops/zengine | zengine/management_commands.py | CheckList.check_mq_connection | def check_mq_connection(self):
"""
RabbitMQ checks the connection
It displays on the screen whether or not you have a connection.
"""
import pika
from zengine.client_queue import BLOCKING_MQ_PARAMS
from pika.exceptions import ProbableAuthenticationError, Connectio... | python | def check_mq_connection(self):
"""
RabbitMQ checks the connection
It displays on the screen whether or not you have a connection.
"""
import pika
from zengine.client_queue import BLOCKING_MQ_PARAMS
from pika.exceptions import ProbableAuthenticationError, Connectio... | [
"def",
"check_mq_connection",
"(",
"self",
")",
":",
"import",
"pika",
"from",
"zengine",
".",
"client_queue",
"import",
"BLOCKING_MQ_PARAMS",
"from",
"pika",
".",
"exceptions",
"import",
"ProbableAuthenticationError",
",",
"ConnectionClosed",
"try",
":",
"connection"... | RabbitMQ checks the connection
It displays on the screen whether or not you have a connection. | [
"RabbitMQ",
"checks",
"the",
"connection",
"It",
"displays",
"on",
"the",
"screen",
"whether",
"or",
"not",
"you",
"have",
"a",
"connection",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L619-L639 |
zetaops/zengine | zengine/management_commands.py | CheckList.check_encoding_and_env | def check_encoding_and_env():
"""
It brings the environment variables to the screen.
The user checks to see if they are using the correct variables.
"""
import sys
import os
if sys.getfilesystemencoding() in ['utf-8', 'UTF-8']:
print(__(u"{0}File syste... | python | def check_encoding_and_env():
"""
It brings the environment variables to the screen.
The user checks to see if they are using the correct variables.
"""
import sys
import os
if sys.getfilesystemencoding() in ['utf-8', 'UTF-8']:
print(__(u"{0}File syste... | [
"def",
"check_encoding_and_env",
"(",
")",
":",
"import",
"sys",
"import",
"os",
"if",
"sys",
".",
"getfilesystemencoding",
"(",
")",
"in",
"[",
"'utf-8'",
",",
"'UTF-8'",
"]",
":",
"print",
"(",
"__",
"(",
"u\"{0}File system encoding correct{1}\"",
")",
".",
... | It brings the environment variables to the screen.
The user checks to see if they are using the correct variables. | [
"It",
"brings",
"the",
"environment",
"variables",
"to",
"the",
"screen",
".",
"The",
"user",
"checks",
"to",
"see",
"if",
"they",
"are",
"using",
"the",
"correct",
"variables",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L642-L662 |
LordDarkula/chess_py | chess_py/game/game_state.py | no_moves | def no_moves(position):
"""
Finds if the game is over.
:type: position: Board
:rtype: bool
"""
return position.no_moves(color.white) \
or position.no_moves(color.black) | python | def no_moves(position):
"""
Finds if the game is over.
:type: position: Board
:rtype: bool
"""
return position.no_moves(color.white) \
or position.no_moves(color.black) | [
"def",
"no_moves",
"(",
"position",
")",
":",
"return",
"position",
".",
"no_moves",
"(",
"color",
".",
"white",
")",
"or",
"position",
".",
"no_moves",
"(",
"color",
".",
"black",
")"
] | Finds if the game is over.
:type: position: Board
:rtype: bool | [
"Finds",
"if",
"the",
"game",
"is",
"over",
"."
] | train | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/game/game_state.py#L13-L21 |
LordDarkula/chess_py | chess_py/game/game_state.py | is_checkmate | def is_checkmate(position, input_color):
"""
Finds if particular King is checkmated.
:type: position: Board
:type: input_color: Color
:rtype: bool
"""
return position.no_moves(input_color) and \
position.get_king(input_color).in_check(position) | python | def is_checkmate(position, input_color):
"""
Finds if particular King is checkmated.
:type: position: Board
:type: input_color: Color
:rtype: bool
"""
return position.no_moves(input_color) and \
position.get_king(input_color).in_check(position) | [
"def",
"is_checkmate",
"(",
"position",
",",
"input_color",
")",
":",
"return",
"position",
".",
"no_moves",
"(",
"input_color",
")",
"and",
"position",
".",
"get_king",
"(",
"input_color",
")",
".",
"in_check",
"(",
"position",
")"
] | Finds if particular King is checkmated.
:type: position: Board
:type: input_color: Color
:rtype: bool | [
"Finds",
"if",
"particular",
"King",
"is",
"checkmated",
"."
] | train | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/game/game_state.py#L24-L33 |
zetaops/zengine | zengine/messaging/views.py | _paginate | def _paginate(self, current_page, query_set, per_page=10):
"""
Handles pagination of object listings.
Args:
current_page int:
Current page number
query_set (:class:`QuerySet<pyoko:pyoko.db.queryset.QuerySet>`):
Object listing queryset.
per_page int:
... | python | def _paginate(self, current_page, query_set, per_page=10):
"""
Handles pagination of object listings.
Args:
current_page int:
Current page number
query_set (:class:`QuerySet<pyoko:pyoko.db.queryset.QuerySet>`):
Object listing queryset.
per_page int:
... | [
"def",
"_paginate",
"(",
"self",
",",
"current_page",
",",
"query_set",
",",
"per_page",
"=",
"10",
")",
":",
"total_objects",
"=",
"query_set",
".",
"count",
"(",
")",
"total_pages",
"=",
"int",
"(",
"total_objects",
"/",
"per_page",
"or",
"1",
")",
"# ... | Handles pagination of object listings.
Args:
current_page int:
Current page number
query_set (:class:`QuerySet<pyoko:pyoko.db.queryset.QuerySet>`):
Object listing queryset.
per_page int:
Objects per page.
Returns:
QuerySet object, pagination ... | [
"Handles",
"pagination",
"of",
"object",
"listings",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L72-L97 |
zetaops/zengine | zengine/messaging/views.py | create_message | def create_message(current):
"""
Creates a message for the given channel.
.. code-block:: python
# request:
{
'view':'_zops_create_message',
'message': {
'channel': key, # of channel
'body': string, # message text.,
... | python | def create_message(current):
"""
Creates a message for the given channel.
.. code-block:: python
# request:
{
'view':'_zops_create_message',
'message': {
'channel': key, # of channel
'body': string, # message text.,
... | [
"def",
"create_message",
"(",
"current",
")",
":",
"msg",
"=",
"current",
".",
"input",
"[",
"'message'",
"]",
"msg_obj",
"=",
"Channel",
".",
"add_message",
"(",
"msg",
"[",
"'channel'",
"]",
",",
"body",
"=",
"msg",
"[",
"'body'",
"]",
",",
"typ",
... | Creates a message for the given channel.
.. code-block:: python
# request:
{
'view':'_zops_create_message',
'message': {
'channel': key, # of channel
'body': string, # message text.,
'type': int, # zengine.messa... | [
"Creates",
"a",
"message",
"for",
"the",
"given",
"channel",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L100-L139 |
zetaops/zengine | zengine/messaging/views.py | show_channel | def show_channel(current, waited=False):
"""
Initial display of channel content.
Returns channel description, members, no of members, last 20 messages etc.
.. code-block:: python
# request:
{
'view':'_zops_show_channel',
'key': key,
}
... | python | def show_channel(current, waited=False):
"""
Initial display of channel content.
Returns channel description, members, no of members, last 20 messages etc.
.. code-block:: python
# request:
{
'view':'_zops_show_channel',
'key': key,
}
... | [
"def",
"show_channel",
"(",
"current",
",",
"waited",
"=",
"False",
")",
":",
"ch",
"=",
"Channel",
"(",
"current",
")",
".",
"objects",
".",
"get",
"(",
"current",
".",
"input",
"[",
"'key'",
"]",
")",
"sbs",
"=",
"ch",
".",
"get_subscription_for_user... | Initial display of channel content.
Returns channel description, members, no of members, last 20 messages etc.
.. code-block:: python
# request:
{
'view':'_zops_show_channel',
'key': key,
}
# response:
{
'chann... | [
"Initial",
"display",
"of",
"channel",
"content",
".",
"Returns",
"channel",
"description",
"members",
"no",
"of",
"members",
"last",
"20",
"messages",
"etc",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L142-L189 |
zetaops/zengine | zengine/messaging/views.py | channel_history | def channel_history(current):
"""
Get old messages for a channel. 20 messages per request
.. code-block:: python
# request:
{
'view':'_zops_channel_history,
'channel_key': key,
'timestamp': datetime, # timestamp data of o... | python | def channel_history(current):
"""
Get old messages for a channel. 20 messages per request
.. code-block:: python
# request:
{
'view':'_zops_channel_history,
'channel_key': key,
'timestamp': datetime, # timestamp data of o... | [
"def",
"channel_history",
"(",
"current",
")",
":",
"current",
".",
"output",
"=",
"{",
"'status'",
":",
"'OK'",
",",
"'code'",
":",
"201",
",",
"'messages'",
":",
"[",
"]",
"}",
"for",
"msg",
"in",
"list",
"(",
"Message",
".",
"objects",
".",
"filte... | Get old messages for a channel. 20 messages per request
.. code-block:: python
# request:
{
'view':'_zops_channel_history,
'channel_key': key,
'timestamp': datetime, # timestamp data of oldest shown message
}
... | [
"Get",
"old",
"messages",
"for",
"a",
"channel",
".",
"20",
"messages",
"per",
"request"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L192-L224 |
zetaops/zengine | zengine/messaging/views.py | report_last_seen_message | def report_last_seen_message(current):
"""
Push timestamp of latest message of an ACTIVE channel.
This view should be called with timestamp of latest message;
- When user opens (clicks on) a channel.
- Periodically (eg: setInterval for 15secs) while user staying in a channel.
.. code-block:: ... | python | def report_last_seen_message(current):
"""
Push timestamp of latest message of an ACTIVE channel.
This view should be called with timestamp of latest message;
- When user opens (clicks on) a channel.
- Periodically (eg: setInterval for 15secs) while user staying in a channel.
.. code-block:: ... | [
"def",
"report_last_seen_message",
"(",
"current",
")",
":",
"sbs",
"=",
"Subscriber",
"(",
"current",
")",
".",
"objects",
".",
"filter",
"(",
"channel_id",
"=",
"current",
".",
"input",
"[",
"'channel_key'",
"]",
",",
"user_id",
"=",
"current",
".",
"use... | Push timestamp of latest message of an ACTIVE channel.
This view should be called with timestamp of latest message;
- When user opens (clicks on) a channel.
- Periodically (eg: setInterval for 15secs) while user staying in a channel.
.. code-block:: python
# request:
{
... | [
"Push",
"timestamp",
"of",
"latest",
"message",
"of",
"an",
"ACTIVE",
"channel",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L227-L258 |
zetaops/zengine | zengine/messaging/views.py | list_channels | def list_channels(current):
"""
List channel memberships of current user
.. code-block:: python
# request:
{
'view':'_zops_list_channels',
}
# response:
{
'channels': [
{... | python | def list_channels(current):
"""
List channel memberships of current user
.. code-block:: python
# request:
{
'view':'_zops_list_channels',
}
# response:
{
'channels': [
{... | [
"def",
"list_channels",
"(",
"current",
")",
":",
"current",
".",
"output",
"=",
"{",
"'status'",
":",
"'OK'",
",",
"'code'",
":",
"200",
",",
"'channels'",
":",
"[",
"]",
"}",
"for",
"sbs",
"in",
"current",
".",
"user",
".",
"subscriptions",
".",
"o... | List channel memberships of current user
.. code-block:: python
# request:
{
'view':'_zops_list_channels',
}
# response:
{
'channels': [
{'name': string, # name of channel
... | [
"List",
"channel",
"memberships",
"of",
"current",
"user"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L261-L302 |
zetaops/zengine | zengine/messaging/views.py | unread_count | def unread_count(current):
"""
Number of unread messages for current user
.. code-block:: python
# request:
{
'view':'_zops_unread_count',
}
# response:
{
'status': 'OK',
'co... | python | def unread_count(current):
"""
Number of unread messages for current user
.. code-block:: python
# request:
{
'view':'_zops_unread_count',
}
# response:
{
'status': 'OK',
'co... | [
"def",
"unread_count",
"(",
"current",
")",
":",
"unread_ntf",
"=",
"0",
"unread_msg",
"=",
"0",
"for",
"sbs",
"in",
"current",
".",
"user",
".",
"subscriptions",
".",
"objects",
".",
"filter",
"(",
"is_visible",
"=",
"True",
")",
":",
"try",
":",
"if"... | Number of unread messages for current user
.. code-block:: python
# request:
{
'view':'_zops_unread_count',
}
# response:
{
'status': 'OK',
'code': 200,
'notifications': ... | [
"Number",
"of",
"unread",
"messages",
"for",
"current",
"user"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L305-L342 |
zetaops/zengine | zengine/messaging/views.py | get_notifications | def get_notifications(current):
"""
Returns last N notifications for current user
.. code-block:: python
# request:
{
'view':'_zops_unread_messages',
'amount': int, # Optional, defaults to 8
}
# response:
... | python | def get_notifications(current):
"""
Returns last N notifications for current user
.. code-block:: python
# request:
{
'view':'_zops_unread_messages',
'amount': int, # Optional, defaults to 8
}
# response:
... | [
"def",
"get_notifications",
"(",
"current",
")",
":",
"current",
".",
"output",
"=",
"{",
"'status'",
":",
"'OK'",
",",
"'code'",
":",
"200",
",",
"'notifications'",
":",
"[",
"]",
",",
"}",
"amount",
"=",
"current",
".",
"input",
".",
"get",
"(",
"'... | Returns last N notifications for current user
.. code-block:: python
# request:
{
'view':'_zops_unread_messages',
'amount': int, # Optional, defaults to 8
}
# response:
{
'status': 'OK',... | [
"Returns",
"last",
"N",
"notifications",
"for",
"current",
"user"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L345-L394 |
zetaops/zengine | zengine/messaging/views.py | create_channel | def create_channel(current):
"""
Create a public channel. Can be a broadcast channel or normal chat room.
Chat room and broadcast distinction will be made at user subscription phase.
.. code-block:: python
# request:
{
'view':'_zops_create_chan... | python | def create_channel(current):
"""
Create a public channel. Can be a broadcast channel or normal chat room.
Chat room and broadcast distinction will be made at user subscription phase.
.. code-block:: python
# request:
{
'view':'_zops_create_chan... | [
"def",
"create_channel",
"(",
"current",
")",
":",
"channel",
"=",
"Channel",
"(",
"name",
"=",
"current",
".",
"input",
"[",
"'name'",
"]",
",",
"description",
"=",
"current",
".",
"input",
"[",
"'description'",
"]",
",",
"owner",
"=",
"current",
".",
... | Create a public channel. Can be a broadcast channel or normal chat room.
Chat room and broadcast distinction will be made at user subscription phase.
.. code-block:: python
# request:
{
'view':'_zops_create_channel',
'name': string,
... | [
"Create",
"a",
"public",
"channel",
".",
"Can",
"be",
"a",
"broadcast",
"channel",
"or",
"normal",
"chat",
"room",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L397-L442 |
zetaops/zengine | zengine/messaging/views.py | add_members | def add_members(current):
"""
Subscribe member(s) to a channel
.. code-block:: python
# request:
{
'view':'_zops_add_members',
'channel_key': key,
'read_only': boolean, # true if this is a Broadcast channel,
... | python | def add_members(current):
"""
Subscribe member(s) to a channel
.. code-block:: python
# request:
{
'view':'_zops_add_members',
'channel_key': key,
'read_only': boolean, # true if this is a Broadcast channel,
... | [
"def",
"add_members",
"(",
"current",
")",
":",
"newly_added",
",",
"existing",
"=",
"[",
"]",
",",
"[",
"]",
"read_only",
"=",
"current",
".",
"input",
"[",
"'read_only'",
"]",
"for",
"member_key",
"in",
"current",
".",
"input",
"[",
"'members'",
"]",
... | Subscribe member(s) to a channel
.. code-block:: python
# request:
{
'view':'_zops_add_members',
'channel_key': key,
'read_only': boolean, # true if this is a Broadcast channel,
# false if it's a... | [
"Subscribe",
"member",
"(",
"s",
")",
"to",
"a",
"channel"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L445-L484 |
zetaops/zengine | zengine/messaging/views.py | add_unit_to_channel | def add_unit_to_channel(current):
"""
Subscribe users of a given unit to given channel
JSON API:
.. code-block:: python
# request:
{
'view':'_zops_add_unit_to_channel',
'unit_key': key,
'ch... | python | def add_unit_to_channel(current):
"""
Subscribe users of a given unit to given channel
JSON API:
.. code-block:: python
# request:
{
'view':'_zops_add_unit_to_channel',
'unit_key': key,
'ch... | [
"def",
"add_unit_to_channel",
"(",
"current",
")",
":",
"read_only",
"=",
"current",
".",
"input",
"[",
"'read_only'",
"]",
"newly_added",
",",
"existing",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"member_key",
"in",
"UnitModel",
".",
"get_user_keys",
"(",
"cu... | Subscribe users of a given unit to given channel
JSON API:
.. code-block:: python
# request:
{
'view':'_zops_add_unit_to_channel',
'unit_key': key,
'channel_key': key,
'read_only': ... | [
"Subscribe",
"users",
"of",
"a",
"given",
"unit",
"to",
"given",
"channel"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L487-L528 |
zetaops/zengine | zengine/messaging/views.py | search_user | def search_user(current):
"""
Search users for adding to a public room
or creating one to one direct messaging
.. code-block:: python
# request:
{
'view':'_zops_search_user',
'query': string,
}
# res... | python | def search_user(current):
"""
Search users for adding to a public room
or creating one to one direct messaging
.. code-block:: python
# request:
{
'view':'_zops_search_user',
'query': string,
}
# res... | [
"def",
"search_user",
"(",
"current",
")",
":",
"current",
".",
"output",
"=",
"{",
"'results'",
":",
"[",
"]",
",",
"'status'",
":",
"'OK'",
",",
"'code'",
":",
"201",
"}",
"qs",
"=",
"UserModel",
"(",
"current",
")",
".",
"objects",
".",
"exclude",... | Search users for adding to a public room
or creating one to one direct messaging
.. code-block:: python
# request:
{
'view':'_zops_search_user',
'query': string,
}
# response:
{
'... | [
"Search",
"users",
"for",
"adding",
"to",
"a",
"public",
"room",
"or",
"creating",
"one",
"to",
"one",
"direct",
"messaging"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L531-L563 |
zetaops/zengine | zengine/messaging/views.py | search_unit | def search_unit(current):
"""
Search on units for subscribing it's users to a channel
.. code-block:: python
# request:
{
'view':'_zops_search_unit',
'query': string,
}
# response:
{
... | python | def search_unit(current):
"""
Search on units for subscribing it's users to a channel
.. code-block:: python
# request:
{
'view':'_zops_search_unit',
'query': string,
}
# response:
{
... | [
"def",
"search_unit",
"(",
"current",
")",
":",
"current",
".",
"output",
"=",
"{",
"'results'",
":",
"[",
"]",
",",
"'status'",
":",
"'OK'",
",",
"'code'",
":",
"201",
"}",
"for",
"user",
"in",
"UnitModel",
"(",
"current",
")",
".",
"objects",
".",
... | Search on units for subscribing it's users to a channel
.. code-block:: python
# request:
{
'view':'_zops_search_unit',
'query': string,
}
# response:
{
'results': [('name', 'key'), ],
... | [
"Search",
"on",
"units",
"for",
"subscribing",
"it",
"s",
"users",
"to",
"a",
"channel"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L566-L592 |
zetaops/zengine | zengine/messaging/views.py | create_direct_channel | def create_direct_channel(current):
"""
Create a One-To-One channel between current and selected user.
.. code-block:: python
# request:
{
'view':'_zops_create_direct_channel',
'user_key': key,
}
# response:
{
'des... | python | def create_direct_channel(current):
"""
Create a One-To-One channel between current and selected user.
.. code-block:: python
# request:
{
'view':'_zops_create_direct_channel',
'user_key': key,
}
# response:
{
'des... | [
"def",
"create_direct_channel",
"(",
"current",
")",
":",
"channel",
",",
"sub_name",
"=",
"Channel",
".",
"get_or_create_direct_channel",
"(",
"current",
".",
"user_id",
",",
"current",
".",
"input",
"[",
"'user_key'",
"]",
")",
"current",
".",
"input",
"[",
... | Create a One-To-One channel between current and selected user.
.. code-block:: python
# request:
{
'view':'_zops_create_direct_channel',
'user_key': key,
}
# response:
{
'description': string,
'no_of_members': ... | [
"Create",
"a",
"One",
"-",
"To",
"-",
"One",
"channel",
"between",
"current",
"and",
"selected",
"user",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L595-L631 |
zetaops/zengine | zengine/messaging/views.py | find_message | def find_message(current):
"""
Search in messages. If "channel_key" given, search will be limited to that channel,
otherwise search will be performed on all of user's subscribed channels.
.. code-block:: python
# request:
{
'view':'_zops_search_... | python | def find_message(current):
"""
Search in messages. If "channel_key" given, search will be limited to that channel,
otherwise search will be performed on all of user's subscribed channels.
.. code-block:: python
# request:
{
'view':'_zops_search_... | [
"def",
"find_message",
"(",
"current",
")",
":",
"current",
".",
"output",
"=",
"{",
"'results'",
":",
"[",
"]",
",",
"'status'",
":",
"'OK'",
",",
"'code'",
":",
"201",
"}",
"query_set",
"=",
"Message",
"(",
"current",
")",
".",
"objects",
".",
"sea... | Search in messages. If "channel_key" given, search will be limited to that channel,
otherwise search will be performed on all of user's subscribed channels.
.. code-block:: python
# request:
{
'view':'_zops_search_unit,
'channel_key': key,
... | [
"Search",
"in",
"messages",
".",
"If",
"channel_key",
"given",
"search",
"will",
"be",
"limited",
"to",
"that",
"channel",
"otherwise",
"search",
"will",
"be",
"performed",
"on",
"all",
"of",
"user",
"s",
"subscribed",
"channels",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L634-L679 |
zetaops/zengine | zengine/messaging/views.py | delete_channel | def delete_channel(current):
"""
Delete a channel
.. code-block:: python
# request:
{
'view':'_zops_delete_channel,
'channel_key': key,
}
# response:
{
'status': 'OK',
... | python | def delete_channel(current):
"""
Delete a channel
.. code-block:: python
# request:
{
'view':'_zops_delete_channel,
'channel_key': key,
}
# response:
{
'status': 'OK',
... | [
"def",
"delete_channel",
"(",
"current",
")",
":",
"ch_key",
"=",
"current",
".",
"input",
"[",
"'channel_key'",
"]",
"ch",
"=",
"Channel",
"(",
"current",
")",
".",
"objects",
".",
"get",
"(",
"owner_id",
"=",
"current",
".",
"user_id",
",",
"key",
"=... | Delete a channel
.. code-block:: python
# request:
{
'view':'_zops_delete_channel,
'channel_key': key,
}
# response:
{
'status': 'OK',
'code': 200
} | [
"Delete",
"a",
"channel"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L682-L706 |
zetaops/zengine | zengine/messaging/views.py | edit_channel | def edit_channel(current):
"""
Update channel name or description
.. code-block:: python
# request:
{
'view':'_zops_edit_channel,
'channel_key': key,
'name': string,
'description': string,
... | python | def edit_channel(current):
"""
Update channel name or description
.. code-block:: python
# request:
{
'view':'_zops_edit_channel,
'channel_key': key,
'name': string,
'description': string,
... | [
"def",
"edit_channel",
"(",
"current",
")",
":",
"ch",
"=",
"Channel",
"(",
"current",
")",
".",
"objects",
".",
"get",
"(",
"owner_id",
"=",
"current",
".",
"user_id",
",",
"key",
"=",
"current",
".",
"input",
"[",
"'channel_key'",
"]",
")",
"ch",
"... | Update channel name or description
.. code-block:: python
# request:
{
'view':'_zops_edit_channel,
'channel_key': key,
'name': string,
'description': string,
}
# response:
... | [
"Update",
"channel",
"name",
"or",
"description"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L709-L737 |
zetaops/zengine | zengine/messaging/views.py | pin_channel | def pin_channel(current):
"""
Pin a channel to top of channel list
.. code-block:: python
# request:
{
'view':'_zops_pin_channel,
'channel_key': key,
}
# response:
{
'status':... | python | def pin_channel(current):
"""
Pin a channel to top of channel list
.. code-block:: python
# request:
{
'view':'_zops_pin_channel,
'channel_key': key,
}
# response:
{
'status':... | [
"def",
"pin_channel",
"(",
"current",
")",
":",
"try",
":",
"Subscriber",
"(",
"current",
")",
".",
"objects",
".",
"filter",
"(",
"user_id",
"=",
"current",
".",
"user_id",
",",
"channel_id",
"=",
"current",
".",
"input",
"[",
"'channel_key'",
"]",
")",... | Pin a channel to top of channel list
.. code-block:: python
# request:
{
'view':'_zops_pin_channel,
'channel_key': key,
}
# response:
{
'status': 'OK',
'code': 200
... | [
"Pin",
"a",
"channel",
"to",
"top",
"of",
"channel",
"list"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L740-L764 |
zetaops/zengine | zengine/messaging/views.py | delete_message | def delete_message(current):
"""
Delete a message
.. code-block:: python
# request:
{
'view':'_zops_delete_message,
'message_key': key,
}
# response:
{
'key': key,
... | python | def delete_message(current):
"""
Delete a message
.. code-block:: python
# request:
{
'view':'_zops_delete_message,
'message_key': key,
}
# response:
{
'key': key,
... | [
"def",
"delete_message",
"(",
"current",
")",
":",
"try",
":",
"Message",
"(",
"current",
")",
".",
"objects",
".",
"get",
"(",
"sender_id",
"=",
"current",
".",
"user_id",
",",
"key",
"=",
"current",
".",
"input",
"[",
"'key'",
"]",
")",
".",
"delet... | Delete a message
.. code-block:: python
# request:
{
'view':'_zops_delete_message,
'message_key': key,
}
# response:
{
'key': key,
'status': 'OK',
'code': ... | [
"Delete",
"a",
"message"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L767-L791 |
zetaops/zengine | zengine/messaging/views.py | edit_message | def edit_message(current):
"""
Edit a message a user own.
.. code-block:: python
# request:
{
'view':'_zops_edit_message',
'message': {
'body': string, # message text
'key': key
}
}
# response:
... | python | def edit_message(current):
"""
Edit a message a user own.
.. code-block:: python
# request:
{
'view':'_zops_edit_message',
'message': {
'body': string, # message text
'key': key
}
}
# response:
... | [
"def",
"edit_message",
"(",
"current",
")",
":",
"current",
".",
"output",
"=",
"{",
"'status'",
":",
"'OK'",
",",
"'code'",
":",
"200",
"}",
"in_msg",
"=",
"current",
".",
"input",
"[",
"'message'",
"]",
"try",
":",
"msg",
"=",
"Message",
"(",
"curr... | Edit a message a user own.
.. code-block:: python
# request:
{
'view':'_zops_edit_message',
'message': {
'body': string, # message text
'key': key
}
}
# response:
{
'status': string,... | [
"Edit",
"a",
"message",
"a",
"user",
"own",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L794-L822 |
zetaops/zengine | zengine/messaging/views.py | flag_message | def flag_message(current):
"""
Flag inappropriate messages
.. code-block:: python
# request:
{
'view':'_zops_flag_message',
'message_key': key,
}
# response:
{
'
'status': 'Created',
'code': 201,
... | python | def flag_message(current):
"""
Flag inappropriate messages
.. code-block:: python
# request:
{
'view':'_zops_flag_message',
'message_key': key,
}
# response:
{
'
'status': 'Created',
'code': 201,
... | [
"def",
"flag_message",
"(",
"current",
")",
":",
"current",
".",
"output",
"=",
"{",
"'status'",
":",
"'Created'",
",",
"'code'",
":",
"201",
"}",
"FlaggedMessage",
".",
"objects",
".",
"get_or_create",
"(",
"user_id",
"=",
"current",
".",
"user_id",
",",
... | Flag inappropriate messages
.. code-block:: python
# request:
{
'view':'_zops_flag_message',
'message_key': key,
}
# response:
{
'
'status': 'Created',
'code': 201,
} | [
"Flag",
"inappropriate",
"messages"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L825-L846 |
zetaops/zengine | zengine/messaging/views.py | unflag_message | def unflag_message(current):
"""
remove flag of a message
.. code-block:: python
# request:
{
'view':'_zops_flag_message',
'key': key,
}
# response:
{
'
'status': 'OK',
'code': 200,
}
"... | python | def unflag_message(current):
"""
remove flag of a message
.. code-block:: python
# request:
{
'view':'_zops_flag_message',
'key': key,
}
# response:
{
'
'status': 'OK',
'code': 200,
}
"... | [
"def",
"unflag_message",
"(",
"current",
")",
":",
"current",
".",
"output",
"=",
"{",
"'status'",
":",
"'OK'",
",",
"'code'",
":",
"200",
"}",
"FlaggedMessage",
"(",
"current",
")",
".",
"objects",
".",
"filter",
"(",
"user_id",
"=",
"current",
".",
"... | remove flag of a message
.. code-block:: python
# request:
{
'view':'_zops_flag_message',
'key': key,
}
# response:
{
'
'status': 'OK',
'code': 200,
} | [
"remove",
"flag",
"of",
"a",
"message"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L849-L871 |
zetaops/zengine | zengine/messaging/views.py | get_message_actions | def get_message_actions(current):
"""
Returns applicable actions for current user for given message key
.. code-block:: python
# request:
{
'view':'_zops_get_message_actions',
'key': key,
}
# response:
{
'actions':[('name_stri... | python | def get_message_actions(current):
"""
Returns applicable actions for current user for given message key
.. code-block:: python
# request:
{
'view':'_zops_get_message_actions',
'key': key,
}
# response:
{
'actions':[('name_stri... | [
"def",
"get_message_actions",
"(",
"current",
")",
":",
"current",
".",
"output",
"=",
"{",
"'status'",
":",
"'OK'",
",",
"'code'",
":",
"200",
",",
"'actions'",
":",
"Message",
".",
"objects",
".",
"get",
"(",
"current",
".",
"input",
"[",
"'key'",
"]... | Returns applicable actions for current user for given message key
.. code-block:: python
# request:
{
'view':'_zops_get_message_actions',
'key': key,
}
# response:
{
'actions':[('name_string', 'cmd_string'),]
'status': str... | [
"Returns",
"applicable",
"actions",
"for",
"current",
"user",
"for",
"given",
"message",
"key"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L874-L896 |
zetaops/zengine | zengine/messaging/views.py | add_to_favorites | def add_to_favorites(current):
"""
Favorite a message
.. code-block:: python
# request:
{
'view':'_zops_add_to_favorites,
'key': key,
}
# response:
{
'status': 'Created',
'code': 201
'favorit... | python | def add_to_favorites(current):
"""
Favorite a message
.. code-block:: python
# request:
{
'view':'_zops_add_to_favorites,
'key': key,
}
# response:
{
'status': 'Created',
'code': 201
'favorit... | [
"def",
"add_to_favorites",
"(",
"current",
")",
":",
"msg",
"=",
"Message",
".",
"objects",
".",
"get",
"(",
"current",
".",
"input",
"[",
"'key'",
"]",
")",
"current",
".",
"output",
"=",
"{",
"'status'",
":",
"'Created'",
",",
"'code'",
":",
"201",
... | Favorite a message
.. code-block:: python
# request:
{
'view':'_zops_add_to_favorites,
'key': key,
}
# response:
{
'status': 'Created',
'code': 201
'favorite_key': key
} | [
"Favorite",
"a",
"message"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L899-L922 |
zetaops/zengine | zengine/messaging/views.py | remove_from_favorites | def remove_from_favorites(current):
"""
Remove a message from favorites
.. code-block:: python
# request:
{
'view':'_zops_remove_from_favorites,
'key': key,
}
# response:
{
'status': 'OK',
'code': 200
... | python | def remove_from_favorites(current):
"""
Remove a message from favorites
.. code-block:: python
# request:
{
'view':'_zops_remove_from_favorites,
'key': key,
}
# response:
{
'status': 'OK',
'code': 200
... | [
"def",
"remove_from_favorites",
"(",
"current",
")",
":",
"try",
":",
"current",
".",
"output",
"=",
"{",
"'status'",
":",
"'OK'",
",",
"'code'",
":",
"200",
"}",
"Favorite",
"(",
"current",
")",
".",
"objects",
".",
"get",
"(",
"user_id",
"=",
"curren... | Remove a message from favorites
.. code-block:: python
# request:
{
'view':'_zops_remove_from_favorites,
'key': key,
}
# response:
{
'status': 'OK',
'code': 200
} | [
"Remove",
"a",
"message",
"from",
"favorites"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L925-L949 |
zetaops/zengine | zengine/messaging/views.py | list_favorites | def list_favorites(current):
"""
List user's favorites. If "channel_key" given, will return favorites belong to that channel.
.. code-block:: python
# request:
{
'view':'_zops_list_favorites,
'channel_key': key,
}
# response:
{... | python | def list_favorites(current):
"""
List user's favorites. If "channel_key" given, will return favorites belong to that channel.
.. code-block:: python
# request:
{
'view':'_zops_list_favorites,
'channel_key': key,
}
# response:
{... | [
"def",
"list_favorites",
"(",
"current",
")",
":",
"current",
".",
"output",
"=",
"{",
"'status'",
":",
"'OK'",
",",
"'code'",
":",
"200",
",",
"'favorites'",
":",
"[",
"]",
"}",
"query_set",
"=",
"Favorite",
"(",
"current",
")",
".",
"objects",
".",
... | List user's favorites. If "channel_key" given, will return favorites belong to that channel.
.. code-block:: python
# request:
{
'view':'_zops_list_favorites,
'channel_key': key,
}
# response:
{
'status': 'OK',
... | [
"List",
"user",
"s",
"favorites",
".",
"If",
"channel_key",
"given",
"will",
"return",
"favorites",
"belong",
"to",
"that",
"channel",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L952-L987 |
zetaops/zengine | zengine/messaging/model.py | Channel.get_or_create_direct_channel | def get_or_create_direct_channel(cls, initiator_key, receiver_key):
"""
Creates a direct messaging channel between two user
Args:
initiator: User, who want's to make first contact
receiver: User, other party
Returns:
(Channel, receiver_name)
... | python | def get_or_create_direct_channel(cls, initiator_key, receiver_key):
"""
Creates a direct messaging channel between two user
Args:
initiator: User, who want's to make first contact
receiver: User, other party
Returns:
(Channel, receiver_name)
... | [
"def",
"get_or_create_direct_channel",
"(",
"cls",
",",
"initiator_key",
",",
"receiver_key",
")",
":",
"existing",
"=",
"cls",
".",
"objects",
".",
"OR",
"(",
")",
".",
"filter",
"(",
"code_name",
"=",
"'%s_%s'",
"%",
"(",
"initiator_key",
",",
"receiver_ke... | Creates a direct messaging channel between two user
Args:
initiator: User, who want's to make first contact
receiver: User, other party
Returns:
(Channel, receiver_name) | [
"Creates",
"a",
"direct",
"messaging",
"channel",
"between",
"two",
"user"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/model.py#L75-L102 |
zetaops/zengine | zengine/messaging/model.py | Channel.create_exchange | def create_exchange(self):
"""
Creates MQ exchange for this channel
Needs to be defined only once.
"""
mq_channel = self._connect_mq()
mq_channel.exchange_declare(exchange=self.code_name,
exchange_type='fanout',
... | python | def create_exchange(self):
"""
Creates MQ exchange for this channel
Needs to be defined only once.
"""
mq_channel = self._connect_mq()
mq_channel.exchange_declare(exchange=self.code_name,
exchange_type='fanout',
... | [
"def",
"create_exchange",
"(",
"self",
")",
":",
"mq_channel",
"=",
"self",
".",
"_connect_mq",
"(",
")",
"mq_channel",
".",
"exchange_declare",
"(",
"exchange",
"=",
"self",
".",
"code_name",
",",
"exchange_type",
"=",
"'fanout'",
",",
"durable",
"=",
"True... | Creates MQ exchange for this channel
Needs to be defined only once. | [
"Creates",
"MQ",
"exchange",
"for",
"this",
"channel",
"Needs",
"to",
"be",
"defined",
"only",
"once",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/model.py#L135-L143 |
zetaops/zengine | zengine/messaging/model.py | Channel.delete_exchange | def delete_exchange(self):
"""
Deletes MQ exchange for this channel
Needs to be defined only once.
"""
mq_channel = self._connect_mq()
mq_channel.exchange_delete(exchange=self.code_name) | python | def delete_exchange(self):
"""
Deletes MQ exchange for this channel
Needs to be defined only once.
"""
mq_channel = self._connect_mq()
mq_channel.exchange_delete(exchange=self.code_name) | [
"def",
"delete_exchange",
"(",
"self",
")",
":",
"mq_channel",
"=",
"self",
".",
"_connect_mq",
"(",
")",
"mq_channel",
".",
"exchange_delete",
"(",
"exchange",
"=",
"self",
".",
"code_name",
")"
] | Deletes MQ exchange for this channel
Needs to be defined only once. | [
"Deletes",
"MQ",
"exchange",
"for",
"this",
"channel",
"Needs",
"to",
"be",
"defined",
"only",
"once",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/model.py#L145-L151 |
zetaops/zengine | zengine/messaging/model.py | Subscriber.get_channel_listing | def get_channel_listing(self):
"""
serialized form for channel listing
"""
return {'name': self.name,
'key': self.channel.key,
'type': self.channel.typ,
'read_only': self.read_only,
'is_online': self.is_online(),
... | python | def get_channel_listing(self):
"""
serialized form for channel listing
"""
return {'name': self.name,
'key': self.channel.key,
'type': self.channel.typ,
'read_only': self.read_only,
'is_online': self.is_online(),
... | [
"def",
"get_channel_listing",
"(",
"self",
")",
":",
"return",
"{",
"'name'",
":",
"self",
".",
"name",
",",
"'key'",
":",
"self",
".",
"channel",
".",
"key",
",",
"'type'",
":",
"self",
".",
"channel",
".",
"typ",
",",
"'read_only'",
":",
"self",
".... | serialized form for channel listing | [
"serialized",
"form",
"for",
"channel",
"listing"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/model.py#L214-L225 |
zetaops/zengine | zengine/messaging/model.py | Subscriber.create_exchange | def create_exchange(self):
"""
Creates user's private exchange
Actually user's private channel needed to be defined only once,
and this should be happened when user first created.
But since this has a little performance cost,
to be safe we always call it before binding t... | python | def create_exchange(self):
"""
Creates user's private exchange
Actually user's private channel needed to be defined only once,
and this should be happened when user first created.
But since this has a little performance cost,
to be safe we always call it before binding t... | [
"def",
"create_exchange",
"(",
"self",
")",
":",
"channel",
"=",
"self",
".",
"_connect_mq",
"(",
")",
"channel",
".",
"exchange_declare",
"(",
"exchange",
"=",
"self",
".",
"user",
".",
"prv_exchange",
",",
"exchange_type",
"=",
"'fanout'",
",",
"durable",
... | Creates user's private exchange
Actually user's private channel needed to be defined only once,
and this should be happened when user first created.
But since this has a little performance cost,
to be safe we always call it before binding to the channel we currently subscribe | [
"Creates",
"user",
"s",
"private",
"exchange"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/model.py#L264-L276 |
zetaops/zengine | zengine/messaging/model.py | Subscriber.bind_to_channel | def bind_to_channel(self):
"""
Binds (subscribes) users private exchange to channel exchange
Automatically called at creation of subscription record.
"""
if self.channel.code_name != self.user.prv_exchange:
channel = self._connect_mq()
channel.exchange_bin... | python | def bind_to_channel(self):
"""
Binds (subscribes) users private exchange to channel exchange
Automatically called at creation of subscription record.
"""
if self.channel.code_name != self.user.prv_exchange:
channel = self._connect_mq()
channel.exchange_bin... | [
"def",
"bind_to_channel",
"(",
"self",
")",
":",
"if",
"self",
".",
"channel",
".",
"code_name",
"!=",
"self",
".",
"user",
".",
"prv_exchange",
":",
"channel",
"=",
"self",
".",
"_connect_mq",
"(",
")",
"channel",
".",
"exchange_bind",
"(",
"source",
"=... | Binds (subscribes) users private exchange to channel exchange
Automatically called at creation of subscription record. | [
"Binds",
"(",
"subscribes",
")",
"users",
"private",
"exchange",
"to",
"channel",
"exchange",
"Automatically",
"called",
"at",
"creation",
"of",
"subscription",
"record",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/model.py#L282-L289 |
zetaops/zengine | zengine/messaging/model.py | Message.serialize | def serialize(self, user=None):
"""
Serializes message for given user.
Note:
Should be called before first save(). Otherwise "is_update" will get wrong value.
Args:
user: User object
Returns:
Dict. JSON serialization ready dictionary object
... | python | def serialize(self, user=None):
"""
Serializes message for given user.
Note:
Should be called before first save(). Otherwise "is_update" will get wrong value.
Args:
user: User object
Returns:
Dict. JSON serialization ready dictionary object
... | [
"def",
"serialize",
"(",
"self",
",",
"user",
"=",
"None",
")",
":",
"return",
"{",
"'content'",
":",
"self",
".",
"body",
",",
"'type'",
":",
"self",
".",
"typ",
",",
"'updated_at'",
":",
"self",
".",
"updated_at",
",",
"'timestamp'",
":",
"self",
"... | Serializes message for given user.
Note:
Should be called before first save(). Otherwise "is_update" will get wrong value.
Args:
user: User object
Returns:
Dict. JSON serialization ready dictionary object | [
"Serializes",
"message",
"for",
"given",
"user",
"."
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/model.py#L370-L398 |
zetaops/zengine | zengine/messaging/model.py | Message._republish | def _republish(self):
"""
Re-publishes updated message
"""
mq_channel = self.channel._connect_mq()
mq_channel.basic_publish(exchange=self.channel.key, routing_key='',
body=json.dumps(self.serialize())) | python | def _republish(self):
"""
Re-publishes updated message
"""
mq_channel = self.channel._connect_mq()
mq_channel.basic_publish(exchange=self.channel.key, routing_key='',
body=json.dumps(self.serialize())) | [
"def",
"_republish",
"(",
"self",
")",
":",
"mq_channel",
"=",
"self",
".",
"channel",
".",
"_connect_mq",
"(",
")",
"mq_channel",
".",
"basic_publish",
"(",
"exchange",
"=",
"self",
".",
"channel",
".",
"key",
",",
"routing_key",
"=",
"''",
",",
"body",... | Re-publishes updated message | [
"Re",
"-",
"publishes",
"updated",
"message"
] | train | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/model.py#L404-L410 |
chrismattmann/nutch-python | nutch/nutch.py | defaultCrawlId | def defaultCrawlId():
"""
Provide a reasonable default crawl name using the user name and date
"""
timestamp = datetime.now().isoformat().replace(':', '_')
user = getuser()
return '_'.join(('crawl', user, timestamp)) | python | def defaultCrawlId():
"""
Provide a reasonable default crawl name using the user name and date
"""
timestamp = datetime.now().isoformat().replace(':', '_')
user = getuser()
return '_'.join(('crawl', user, timestamp)) | [
"def",
"defaultCrawlId",
"(",
")",
":",
"timestamp",
"=",
"datetime",
".",
"now",
"(",
")",
".",
"isoformat",
"(",
")",
".",
"replace",
"(",
"':'",
",",
"'_'",
")",
"user",
"=",
"getuser",
"(",
")",
"return",
"'_'",
".",
"join",
"(",
"(",
"'crawl'"... | Provide a reasonable default crawl name using the user name and date | [
"Provide",
"a",
"reasonable",
"default",
"crawl",
"name",
"using",
"the",
"user",
"name",
"and",
"date"
] | train | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L91-L98 |
chrismattmann/nutch-python | nutch/nutch.py | main | def main(argv=None):
"""Run Nutch command using REST API."""
global Verbose, Mock
if argv is None:
argv = sys.argv
if len(argv) < 5: die('Bad args')
try:
opts, argv = getopt.getopt(argv[1:], 'hs:p:mv',
['help', 'server=', 'port=', 'mock', 'verbose'])
except getopt.Geto... | python | def main(argv=None):
"""Run Nutch command using REST API."""
global Verbose, Mock
if argv is None:
argv = sys.argv
if len(argv) < 5: die('Bad args')
try:
opts, argv = getopt.getopt(argv[1:], 'hs:p:mv',
['help', 'server=', 'port=', 'mock', 'verbose'])
except getopt.Geto... | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"global",
"Verbose",
",",
"Mock",
"if",
"argv",
"is",
"None",
":",
"argv",
"=",
"sys",
".",
"argv",
"if",
"len",
"(",
"argv",
")",
"<",
"5",
":",
"die",
"(",
"'Bad args'",
")",
"try",
":",
"opt... | Run Nutch command using REST API. | [
"Run",
"Nutch",
"command",
"using",
"REST",
"API",
"."
] | train | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L716-L749 |
chrismattmann/nutch-python | nutch/nutch.py | Server.call | def call(self, verb, servicePath, data=None, headers=None, forceText=False, sendJson=True):
"""Call the Nutch Server, do some error checking, and return the response.
:param verb: One of nutch.RequestVerbs
:param servicePath: path component of URL to append to endpoint, e.g. '/config'
:... | python | def call(self, verb, servicePath, data=None, headers=None, forceText=False, sendJson=True):
"""Call the Nutch Server, do some error checking, and return the response.
:param verb: One of nutch.RequestVerbs
:param servicePath: path component of URL to append to endpoint, e.g. '/config'
:... | [
"def",
"call",
"(",
"self",
",",
"verb",
",",
"servicePath",
",",
"data",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"forceText",
"=",
"False",
",",
"sendJson",
"=",
"True",
")",
":",
"default_data",
"=",
"{",
"}",
"if",
"sendJson",
"else",
"\"\"... | Call the Nutch Server, do some error checking, and return the response.
:param verb: One of nutch.RequestVerbs
:param servicePath: path component of URL to append to endpoint, e.g. '/config'
:param data: Data to attach to this request
:param headers: headers to attach to this request, d... | [
"Call",
"the",
"Nutch",
"Server",
"do",
"some",
"error",
"checking",
"and",
"return",
"the",
"response",
"."
] | train | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L117-L170 |
chrismattmann/nutch-python | nutch/nutch.py | ConfigClient.create | def create(self, cid, configData):
"""
Create a new named (cid) configuration from a parameter dictionary (config_data).
"""
configArgs = {'configId': cid, 'params': configData, 'force': True}
cid = self.server.call('post', "/config/create", configArgs, forceText=True, headers=Te... | python | def create(self, cid, configData):
"""
Create a new named (cid) configuration from a parameter dictionary (config_data).
"""
configArgs = {'configId': cid, 'params': configData, 'force': True}
cid = self.server.call('post', "/config/create", configArgs, forceText=True, headers=Te... | [
"def",
"create",
"(",
"self",
",",
"cid",
",",
"configData",
")",
":",
"configArgs",
"=",
"{",
"'configId'",
":",
"cid",
",",
"'params'",
":",
"configData",
",",
"'force'",
":",
"True",
"}",
"cid",
"=",
"self",
".",
"server",
".",
"call",
"(",
"'post... | Create a new named (cid) configuration from a parameter dictionary (config_data). | [
"Create",
"a",
"new",
"named",
"(",
"cid",
")",
"configuration",
"from",
"a",
"parameter",
"dictionary",
"(",
"config_data",
")",
"."
] | train | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L278-L285 |
chrismattmann/nutch-python | nutch/nutch.py | JobClient.list | def list(self, allJobs=False):
"""
Return list of jobs at this endpoint.
Call get(allJobs=True) to see all jobs, not just the ones managed by this Client
"""
jobs = self.server.call('get', '/job')
return [Job(job['id'], self.server) for job in jobs if allJobs or self._... | python | def list(self, allJobs=False):
"""
Return list of jobs at this endpoint.
Call get(allJobs=True) to see all jobs, not just the ones managed by this Client
"""
jobs = self.server.call('get', '/job')
return [Job(job['id'], self.server) for job in jobs if allJobs or self._... | [
"def",
"list",
"(",
"self",
",",
"allJobs",
"=",
"False",
")",
":",
"jobs",
"=",
"self",
".",
"server",
".",
"call",
"(",
"'get'",
",",
"'/job'",
")",
"return",
"[",
"Job",
"(",
"job",
"[",
"'id'",
"]",
",",
"self",
".",
"server",
")",
"for",
"... | Return list of jobs at this endpoint.
Call get(allJobs=True) to see all jobs, not just the ones managed by this Client | [
"Return",
"list",
"of",
"jobs",
"at",
"this",
"endpoint",
"."
] | train | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L337-L346 |
chrismattmann/nutch-python | nutch/nutch.py | JobClient.create | def create(self, command, **args):
"""
Create a job given a command
:param command: Nutch command, one of nutch.LegalJobs
:param args: Additional arguments to pass to the job
:return: The created Job
"""
command = command.upper()
if command not in LegalJo... | python | def create(self, command, **args):
"""
Create a job given a command
:param command: Nutch command, one of nutch.LegalJobs
:param args: Additional arguments to pass to the job
:return: The created Job
"""
command = command.upper()
if command not in LegalJo... | [
"def",
"create",
"(",
"self",
",",
"command",
",",
"*",
"*",
"args",
")",
":",
"command",
"=",
"command",
".",
"upper",
"(",
")",
"if",
"command",
"not",
"in",
"LegalJobs",
":",
"warn",
"(",
"'Nutch command must be one of: %s'",
"%",
"', '",
".",
"join",... | Create a job given a command
:param command: Nutch command, one of nutch.LegalJobs
:param args: Additional arguments to pass to the job
:return: The created Job | [
"Create",
"a",
"job",
"given",
"a",
"command",
":",
"param",
"command",
":",
"Nutch",
"command",
"one",
"of",
"nutch",
".",
"LegalJobs",
":",
"param",
"args",
":",
"Additional",
"arguments",
"to",
"pass",
"to",
"the",
"job",
":",
"return",
":",
"The",
... | train | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L348-L370 |
chrismattmann/nutch-python | nutch/nutch.py | JobClient.inject | def inject(self, seed=None, urlDir=None, **args):
"""
:param seed: A Seed object (this or urlDir must be specified)
:param urlDir: The directory on the server containing the seed list (this or urlDir must be specified)
:param args: Extra arguments for the job
:return: a created J... | python | def inject(self, seed=None, urlDir=None, **args):
"""
:param seed: A Seed object (this or urlDir must be specified)
:param urlDir: The directory on the server containing the seed list (this or urlDir must be specified)
:param args: Extra arguments for the job
:return: a created J... | [
"def",
"inject",
"(",
"self",
",",
"seed",
"=",
"None",
",",
"urlDir",
"=",
"None",
",",
"*",
"*",
"args",
")",
":",
"if",
"seed",
":",
"if",
"urlDir",
"and",
"urlDir",
"!=",
"seed",
".",
"seedPath",
":",
"raise",
"NutchException",
"(",
"\"Can't spec... | :param seed: A Seed object (this or urlDir must be specified)
:param urlDir: The directory on the server containing the seed list (this or urlDir must be specified)
:param args: Extra arguments for the job
:return: a created Job object | [
":",
"param",
"seed",
":",
"A",
"Seed",
"object",
"(",
"this",
"or",
"urlDir",
"must",
"be",
"specified",
")",
":",
"param",
"urlDir",
":",
"The",
"directory",
"on",
"the",
"server",
"containing",
"the",
"seed",
"list",
"(",
"this",
"or",
"urlDir",
"mu... | train | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L374-L391 |
chrismattmann/nutch-python | nutch/nutch.py | SeedClient.create | def create(self, sid, seedList):
"""
Create a new named (sid) Seed from a list of seed URLs
:param sid: the name to assign to the new seed list
:param seedList: the list of seeds to use
:return: the created Seed object
"""
seedUrl = lambda uid, url: {"id": uid, ... | python | def create(self, sid, seedList):
"""
Create a new named (sid) Seed from a list of seed URLs
:param sid: the name to assign to the new seed list
:param seedList: the list of seeds to use
:return: the created Seed object
"""
seedUrl = lambda uid, url: {"id": uid, ... | [
"def",
"create",
"(",
"self",
",",
"sid",
",",
"seedList",
")",
":",
"seedUrl",
"=",
"lambda",
"uid",
",",
"url",
":",
"{",
"\"id\"",
":",
"uid",
",",
"\"url\"",
":",
"url",
"}",
"if",
"not",
"isinstance",
"(",
"seedList",
",",
"tuple",
")",
":",
... | Create a new named (sid) Seed from a list of seed URLs
:param sid: the name to assign to the new seed list
:param seedList: the list of seeds to use
:return: the created Seed object | [
"Create",
"a",
"new",
"named",
"(",
"sid",
")",
"Seed",
"from",
"a",
"list",
"of",
"seed",
"URLs"
] | train | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L419-L442 |
chrismattmann/nutch-python | nutch/nutch.py | SeedClient.createFromFile | def createFromFile(self, sid, filename):
"""
Create a new named (sid) Seed from a file containing URLs
It's assumed URLs are whitespace seperated.
:param sid: the name to assign to the new seed list
:param filename: the name of the file that contains URLs
:return: the cr... | python | def createFromFile(self, sid, filename):
"""
Create a new named (sid) Seed from a file containing URLs
It's assumed URLs are whitespace seperated.
:param sid: the name to assign to the new seed list
:param filename: the name of the file that contains URLs
:return: the cr... | [
"def",
"createFromFile",
"(",
"self",
",",
"sid",
",",
"filename",
")",
":",
"urls",
"=",
"[",
"]",
"with",
"open",
"(",
"filename",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"for",
"url",
"in",
"line",
".",
"split",
"(",
")",
":",
"u... | Create a new named (sid) Seed from a file containing URLs
It's assumed URLs are whitespace seperated.
:param sid: the name to assign to the new seed list
:param filename: the name of the file that contains URLs
:return: the created Seed object | [
"Create",
"a",
"new",
"named",
"(",
"sid",
")",
"Seed",
"from",
"a",
"file",
"containing",
"URLs",
"It",
"s",
"assumed",
"URLs",
"are",
"whitespace",
"seperated",
"."
] | train | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L444-L460 |
chrismattmann/nutch-python | nutch/nutch.py | CrawlClient._nextJob | def _nextJob(self, job, nextRound=True):
"""
Given a completed job, start the next job in the round, or return None
:param nextRound: whether to start jobs from the next round if the current round is completed.
:return: the newly started Job, or None if no job was started
"""
... | python | def _nextJob(self, job, nextRound=True):
"""
Given a completed job, start the next job in the round, or return None
:param nextRound: whether to start jobs from the next round if the current round is completed.
:return: the newly started Job, or None if no job was started
"""
... | [
"def",
"_nextJob",
"(",
"self",
",",
"job",
",",
"nextRound",
"=",
"True",
")",
":",
"jobInfo",
"=",
"job",
".",
"info",
"(",
")",
"assert",
"jobInfo",
"[",
"'state'",
"]",
"==",
"'FINISHED'",
"roundEnd",
"=",
"False",
"if",
"jobInfo",
"[",
"'type'",
... | Given a completed job, start the next job in the round, or return None
:param nextRound: whether to start jobs from the next round if the current round is completed.
:return: the newly started Job, or None if no job was started | [
"Given",
"a",
"completed",
"job",
"start",
"the",
"next",
"job",
"in",
"the",
"round",
"or",
"return",
"None"
] | train | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L492-L533 |
chrismattmann/nutch-python | nutch/nutch.py | CrawlClient.progress | def progress(self, nextRound=True):
"""
Check the status of the current job, activate the next job if it's finished, and return the active job
If the current job has failed, a NutchCrawlException will be raised with no jobs attached.
:param nextRound: whether to start jobs from the nex... | python | def progress(self, nextRound=True):
"""
Check the status of the current job, activate the next job if it's finished, and return the active job
If the current job has failed, a NutchCrawlException will be raised with no jobs attached.
:param nextRound: whether to start jobs from the nex... | [
"def",
"progress",
"(",
"self",
",",
"nextRound",
"=",
"True",
")",
":",
"currentJob",
"=",
"self",
".",
"currentJob",
"if",
"currentJob",
"is",
"None",
":",
"return",
"currentJob",
"jobInfo",
"=",
"currentJob",
".",
"info",
"(",
")",
"if",
"jobInfo",
"[... | Check the status of the current job, activate the next job if it's finished, and return the active job
If the current job has failed, a NutchCrawlException will be raised with no jobs attached.
:param nextRound: whether to start jobs from the next round if the current job/round is completed.
:... | [
"Check",
"the",
"status",
"of",
"the",
"current",
"job",
"activate",
"the",
"next",
"job",
"if",
"it",
"s",
"finished",
"and",
"return",
"the",
"active",
"job"
] | train | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L535-L560 |
chrismattmann/nutch-python | nutch/nutch.py | CrawlClient.nextRound | def nextRound(self):
"""
Execute all jobs in the current round and return when they have finished.
If a job fails, a NutchCrawlException will be raised, with all completed jobs from this round attached
to the exception.
:return: a list of all completed Jobs
"""
... | python | def nextRound(self):
"""
Execute all jobs in the current round and return when they have finished.
If a job fails, a NutchCrawlException will be raised, with all completed jobs from this round attached
to the exception.
:return: a list of all completed Jobs
"""
... | [
"def",
"nextRound",
"(",
"self",
")",
":",
"finishedJobs",
"=",
"[",
"]",
"if",
"self",
".",
"currentJob",
"is",
"None",
":",
"self",
".",
"currentJob",
"=",
"self",
".",
"jobClient",
".",
"create",
"(",
"'GENERATE'",
")",
"activeJob",
"=",
"self",
"."... | Execute all jobs in the current round and return when they have finished.
If a job fails, a NutchCrawlException will be raised, with all completed jobs from this round attached
to the exception.
:return: a list of all completed Jobs | [
"Execute",
"all",
"jobs",
"in",
"the",
"current",
"round",
"and",
"return",
"when",
"they",
"have",
"finished",
"."
] | train | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L573-L595 |
chrismattmann/nutch-python | nutch/nutch.py | CrawlClient.waitAll | def waitAll(self):
"""
Execute all queued rounds and return when they have finished.
If a job fails, a NutchCrawlException will be raised, with all completed jobs attached
to the exception
:return: a list of jobs completed for each round, organized by round (list-of-lists)
... | python | def waitAll(self):
"""
Execute all queued rounds and return when they have finished.
If a job fails, a NutchCrawlException will be raised, with all completed jobs attached
to the exception
:return: a list of jobs completed for each round, organized by round (list-of-lists)
... | [
"def",
"waitAll",
"(",
"self",
")",
":",
"finishedRounds",
"=",
"[",
"self",
".",
"nextRound",
"(",
")",
"]",
"while",
"self",
".",
"currentRound",
"<",
"self",
".",
"totalRounds",
":",
"finishedRounds",
".",
"append",
"(",
"self",
".",
"nextRound",
"(",... | Execute all queued rounds and return when they have finished.
If a job fails, a NutchCrawlException will be raised, with all completed jobs attached
to the exception
:return: a list of jobs completed for each round, organized by round (list-of-lists) | [
"Execute",
"all",
"queued",
"rounds",
"and",
"return",
"when",
"they",
"have",
"finished",
"."
] | train | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L597-L612 |
chrismattmann/nutch-python | nutch/nutch.py | Nutch.Jobs | def Jobs(self, crawlId=None):
"""
Create a JobClient for listing and creating jobs.
The JobClient inherits the confId from the Nutch client.
:param crawlId: crawlIds to use for this client. If not provided, will be generated
by nutch.defaultCrawlId()
:return: a JobClie... | python | def Jobs(self, crawlId=None):
"""
Create a JobClient for listing and creating jobs.
The JobClient inherits the confId from the Nutch client.
:param crawlId: crawlIds to use for this client. If not provided, will be generated
by nutch.defaultCrawlId()
:return: a JobClie... | [
"def",
"Jobs",
"(",
"self",
",",
"crawlId",
"=",
"None",
")",
":",
"crawlId",
"=",
"crawlId",
"if",
"crawlId",
"else",
"defaultCrawlId",
"(",
")",
"return",
"JobClient",
"(",
"self",
".",
"server",
",",
"crawlId",
",",
"self",
".",
"confId",
")"
] | Create a JobClient for listing and creating jobs.
The JobClient inherits the confId from the Nutch client.
:param crawlId: crawlIds to use for this client. If not provided, will be generated
by nutch.defaultCrawlId()
:return: a JobClient | [
"Create",
"a",
"JobClient",
"for",
"listing",
"and",
"creating",
"jobs",
".",
"The",
"JobClient",
"inherits",
"the",
"confId",
"from",
"the",
"Nutch",
"client",
"."
] | train | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L656-L666 |
chrismattmann/nutch-python | nutch/nutch.py | Nutch.Crawl | def Crawl(self, seed, seedClient=None, jobClient=None, rounds=1, index=True):
"""
Launch a crawl using the given seed
:param seed: Type (Seed or SeedList) - used for crawl
:param seedClient: if a SeedList is given, the SeedClient to upload, if None a default will be created
:para... | python | def Crawl(self, seed, seedClient=None, jobClient=None, rounds=1, index=True):
"""
Launch a crawl using the given seed
:param seed: Type (Seed or SeedList) - used for crawl
:param seedClient: if a SeedList is given, the SeedClient to upload, if None a default will be created
:para... | [
"def",
"Crawl",
"(",
"self",
",",
"seed",
",",
"seedClient",
"=",
"None",
",",
"jobClient",
"=",
"None",
",",
"rounds",
"=",
"1",
",",
"index",
"=",
"True",
")",
":",
"if",
"seedClient",
"is",
"None",
":",
"seedClient",
"=",
"self",
".",
"Seeds",
"... | Launch a crawl using the given seed
:param seed: Type (Seed or SeedList) - used for crawl
:param seedClient: if a SeedList is given, the SeedClient to upload, if None a default will be created
:param jobClient: the JobClient to be used, if None a default will be created
:param rounds: th... | [
"Launch",
"a",
"crawl",
"using",
"the",
"given",
"seed",
":",
"param",
"seed",
":",
"Type",
"(",
"Seed",
"or",
"SeedList",
")",
"-",
"used",
"for",
"crawl",
":",
"param",
"seedClient",
":",
"if",
"a",
"SeedList",
"is",
"given",
"the",
"SeedClient",
"to... | train | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L677-L693 |
deep-compute/logagg | logagg/formatters.py | haproxy | def haproxy(line):
#TODO Handle all message formats
'''
>>> import pprint
>>> input_line1 = 'Apr 24 00:00:02 node haproxy[12298]: 1.1.1.1:48660 [24/Apr/2019:00:00:02.358] pre-staging~ pre-staging_doc/pre-staging_active 261/0/2/8/271 200 2406 - - ---- 4/4/0/1/0 0/0 {AAAAAA:AAAAA_AAAAA:AAAAA_AAAAA_AAAAA:3... | python | def haproxy(line):
#TODO Handle all message formats
'''
>>> import pprint
>>> input_line1 = 'Apr 24 00:00:02 node haproxy[12298]: 1.1.1.1:48660 [24/Apr/2019:00:00:02.358] pre-staging~ pre-staging_doc/pre-staging_active 261/0/2/8/271 200 2406 - - ---- 4/4/0/1/0 0/0 {AAAAAA:AAAAA_AAAAA:AAAAA_AAAAA_AAAAA:3... | [
"def",
"haproxy",
"(",
"line",
")",
":",
"#TODO Handle all message formats",
"_line",
"=",
"line",
".",
"strip",
"(",
")",
".",
"split",
"(",
")",
"log",
"=",
"{",
"}",
"log",
"[",
"'client_server'",
"]",
"=",
"_line",
"[",
"5",
"]",
".",
"split",
"(... | >>> import pprint
>>> input_line1 = 'Apr 24 00:00:02 node haproxy[12298]: 1.1.1.1:48660 [24/Apr/2019:00:00:02.358] pre-staging~ pre-staging_doc/pre-staging_active 261/0/2/8/271 200 2406 - - ---- 4/4/0/1/0 0/0 {AAAAAA:AAAAA_AAAAA:AAAAA_AAAAA_AAAAA:300A||| user@mail.net:sdasdasdasdsdasAHDivsjd=|user@mail.net|2018} "G... | [
">>>",
"import",
"pprint",
">>>",
"input_line1",
"=",
"Apr",
"24",
"00",
":",
"00",
":",
"02",
"node",
"haproxy",
"[",
"12298",
"]",
":",
"1",
".",
"1",
".",
"1",
".",
"1",
":",
"48660",
"[",
"24",
"/",
"Apr",
"/",
"2019",
":",
"00",
":",
"00... | train | https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/formatters.py#L19-L94 |
deep-compute/logagg | logagg/formatters.py | nginx_access | def nginx_access(line):
'''
>>> import pprint
>>> input_line1 = '{ \
"remote_addr": "127.0.0.1","remote_user": "-","timestamp": "1515144699.201", \
"request": "GET / HTTP/1.1","status": "200","request_time": "0.000", \
"body_bytes_sent": "396","htt... | python | def nginx_access(line):
'''
>>> import pprint
>>> input_line1 = '{ \
"remote_addr": "127.0.0.1","remote_user": "-","timestamp": "1515144699.201", \
"request": "GET / HTTP/1.1","status": "200","request_time": "0.000", \
"body_bytes_sent": "396","htt... | [
"def",
"nginx_access",
"(",
"line",
")",
":",
"#TODO Handle nginx error logs",
"log",
"=",
"json",
".",
"loads",
"(",
"line",
")",
"timestamp_iso",
"=",
"datetime",
".",
"datetime",
".",
"utcfromtimestamp",
"(",
"float",
"(",
"log",
"[",
"'timestamp'",
"]",
... | >>> import pprint
>>> input_line1 = '{ \
"remote_addr": "127.0.0.1","remote_user": "-","timestamp": "1515144699.201", \
"request": "GET / HTTP/1.1","status": "200","request_time": "0.000", \
"body_bytes_sent": "396","http_referer": "-","http_user_agent": "... | [
">>>",
"import",
"pprint",
">>>",
"input_line1",
"=",
"{",
"\\",
"remote_addr",
":",
"127",
".",
"0",
".",
"0",
".",
"1",
"remote_user",
":",
"-",
"timestamp",
":",
"1515144699",
".",
"201",
"\\",
"request",
":",
"GET",
"/",
"HTTP",
"/",
"1",
".",
... | train | https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/formatters.py#L96-L160 |
deep-compute/logagg | logagg/formatters.py | mongodb | def mongodb(line):
'''
>>> import pprint
>>> input_line1 = '2017-08-17T07:56:33.489+0200 I REPL [signalProcessingThread] shutting down replication subsystems'
>>> output_line1 = mongodb(input_line1)
>>> pprint.pprint(output_line1)
{'data': {'component': 'REPL',
'context': '[sig... | python | def mongodb(line):
'''
>>> import pprint
>>> input_line1 = '2017-08-17T07:56:33.489+0200 I REPL [signalProcessingThread] shutting down replication subsystems'
>>> output_line1 = mongodb(input_line1)
>>> pprint.pprint(output_line1)
{'data': {'component': 'REPL',
'context': '[sig... | [
"def",
"mongodb",
"(",
"line",
")",
":",
"keys",
"=",
"[",
"'timestamp'",
",",
"'severity'",
",",
"'component'",
",",
"'context'",
",",
"'message'",
"]",
"values",
"=",
"re",
".",
"split",
"(",
"r'\\s+'",
",",
"line",
",",
"maxsplit",
"=",
"4",
")",
... | >>> import pprint
>>> input_line1 = '2017-08-17T07:56:33.489+0200 I REPL [signalProcessingThread] shutting down replication subsystems'
>>> output_line1 = mongodb(input_line1)
>>> pprint.pprint(output_line1)
{'data': {'component': 'REPL',
'context': '[signalProcessingThread]',
... | [
">>>",
"import",
"pprint",
">>>",
"input_line1",
"=",
"2017",
"-",
"08",
"-",
"17T07",
":",
"56",
":",
"33",
".",
"489",
"+",
"0200",
"I",
"REPL",
"[",
"signalProcessingThread",
"]",
"shutting",
"down",
"replication",
"subsystems",
">>>",
"output_line1",
"... | train | https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/formatters.py#L162-L196 |
deep-compute/logagg | logagg/formatters.py | django | def django(line):
'''
>>> import pprint
>>> input_line1 = '[23/Aug/2017 11:35:25] INFO [app.middleware_log_req:50]View func called:{"exception": null,"processing_time": 0.00011801719665527344, "url": "<url>",host": "localhost", "user": "testing", "post_contents": "", "method": "POST" }'
>>> output_line1... | python | def django(line):
'''
>>> import pprint
>>> input_line1 = '[23/Aug/2017 11:35:25] INFO [app.middleware_log_req:50]View func called:{"exception": null,"processing_time": 0.00011801719665527344, "url": "<url>",host": "localhost", "user": "testing", "post_contents": "", "method": "POST" }'
>>> output_line1... | [
"def",
"django",
"(",
"line",
")",
":",
"#TODO we need to handle case2 logs",
"data",
"=",
"{",
"}",
"log",
"=",
"re",
".",
"findall",
"(",
"r'^(\\[\\d+/\\w+/\\d+ \\d+:\\d+:\\d+\\].*)'",
",",
"line",
")",
"if",
"len",
"(",
"log",
")",
"==",
"1",
":",
"data",... | >>> import pprint
>>> input_line1 = '[23/Aug/2017 11:35:25] INFO [app.middleware_log_req:50]View func called:{"exception": null,"processing_time": 0.00011801719665527344, "url": "<url>",host": "localhost", "user": "testing", "post_contents": "", "method": "POST" }'
>>> output_line1 = django(input_line1)
>>>... | [
">>>",
"import",
"pprint",
">>>",
"input_line1",
"=",
"[",
"23",
"/",
"Aug",
"/",
"2017",
"11",
":",
"35",
":",
"25",
"]",
"INFO",
"[",
"app",
".",
"middleware_log_req",
":",
"50",
"]",
"View",
"func",
"called",
":",
"{",
"exception",
":",
"null",
... | train | https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/formatters.py#L199-L271 |
deep-compute/logagg | logagg/formatters.py | basescript | def basescript(line):
'''
>>> import pprint
>>> input_line = '{"level": "warning", "timestamp": "2018-02-07T06:37:00.297610Z", "event": "exited via keyboard interrupt", "type": "log", "id": "20180207T063700_4d03fe800bd111e89ecb96000007bc65", "_": {"ln": 58, "file": "/usr/local/lib/python2.7/dist-packages/ba... | python | def basescript(line):
'''
>>> import pprint
>>> input_line = '{"level": "warning", "timestamp": "2018-02-07T06:37:00.297610Z", "event": "exited via keyboard interrupt", "type": "log", "id": "20180207T063700_4d03fe800bd111e89ecb96000007bc65", "_": {"ln": 58, "file": "/usr/local/lib/python2.7/dist-packages/ba... | [
"def",
"basescript",
"(",
"line",
")",
":",
"log",
"=",
"json",
".",
"loads",
"(",
"line",
")",
"return",
"dict",
"(",
"timestamp",
"=",
"log",
"[",
"'timestamp'",
"]",
",",
"data",
"=",
"log",
",",
"id",
"=",
"log",
"[",
"'id'",
"]",
",",
"type"... | >>> import pprint
>>> input_line = '{"level": "warning", "timestamp": "2018-02-07T06:37:00.297610Z", "event": "exited via keyboard interrupt", "type": "log", "id": "20180207T063700_4d03fe800bd111e89ecb96000007bc65", "_": {"ln": 58, "file": "/usr/local/lib/python2.7/dist-packages/basescript/basescript.py", "name": "... | [
">>>",
"import",
"pprint",
">>>",
"input_line",
"=",
"{",
"level",
":",
"warning",
"timestamp",
":",
"2018",
"-",
"02",
"-",
"07T06",
":",
"37",
":",
"00",
".",
"297610Z",
"event",
":",
"exited",
"via",
"keyboard",
"interrupt",
"type",
":",
"log",
"id"... | train | https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/formatters.py#L273-L304 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.