partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | _paginate | 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 ... | zengine/messaging/views.py | 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):
"""
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:
... | [
"Handles",
"pagination",
"of",
"object",
"listings",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L72-L97 | [
"def",
"_paginate",
"(",
"self",
",",
"current_page",
",",
"query_set",
",",
"per_page",
"=",
"10",
")",
":",
"total_objects",
"=",
"query_set",
".",
"count",
"(",
")",
"total_pages",
"=",
"int",
"(",
"total_objects",
"/",
"per_page",
"or",
"1",
")",
"# ... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | create_message | 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... | zengine/messaging/views.py | 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):
"""
Creates a message for the given channel.
.. code-block:: python
# request:
{
'view':'_zops_create_message',
'message': {
'channel': key, # of channel
'body': string, # message text.,
... | [
"Creates",
"a",
"message",
"for",
"the",
"given",
"channel",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L100-L139 | [
"def",
"create_message",
"(",
"current",
")",
":",
"msg",
"=",
"current",
".",
"input",
"[",
"'message'",
"]",
"msg_obj",
"=",
"Channel",
".",
"add_message",
"(",
"msg",
"[",
"'channel'",
"]",
",",
"body",
"=",
"msg",
"[",
"'body'",
"]",
",",
"typ",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | show_channel | 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... | zengine/messaging/views.py | 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):
"""
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,
}
... | [
"Initial",
"display",
"of",
"channel",
"content",
".",
"Returns",
"channel",
"description",
"members",
"no",
"of",
"members",
"last",
"20",
"messages",
"etc",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L142-L189 | [
"def",
"show_channel",
"(",
"current",
",",
"waited",
"=",
"False",
")",
":",
"ch",
"=",
"Channel",
"(",
"current",
")",
".",
"objects",
".",
"get",
"(",
"current",
".",
"input",
"[",
"'key'",
"]",
")",
"sbs",
"=",
"ch",
".",
"get_subscription_for_user... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | channel_history | 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
}
... | zengine/messaging/views.py | 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):
"""
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... | [
"Get",
"old",
"messages",
"for",
"a",
"channel",
".",
"20",
"messages",
"per",
"request"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L192-L224 | [
"def",
"channel_history",
"(",
"current",
")",
":",
"current",
".",
"output",
"=",
"{",
"'status'",
":",
"'OK'",
",",
"'code'",
":",
"201",
",",
"'messages'",
":",
"[",
"]",
"}",
"for",
"msg",
"in",
"list",
"(",
"Message",
".",
"objects",
".",
"filte... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | report_last_seen_message | 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:
{
... | zengine/messaging/views.py | 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):
"""
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:: ... | [
"Push",
"timestamp",
"of",
"latest",
"message",
"of",
"an",
"ACTIVE",
"channel",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L227-L258 | [
"def",
"report_last_seen_message",
"(",
"current",
")",
":",
"sbs",
"=",
"Subscriber",
"(",
"current",
")",
".",
"objects",
".",
"filter",
"(",
"channel_id",
"=",
"current",
".",
"input",
"[",
"'channel_key'",
"]",
",",
"user_id",
"=",
"current",
".",
"use... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | list_channels | List channel memberships of current user
.. code-block:: python
# request:
{
'view':'_zops_list_channels',
}
# response:
{
'channels': [
{'name': string, # name of channel
... | zengine/messaging/views.py | def list_channels(current):
"""
List channel memberships of current user
.. code-block:: python
# request:
{
'view':'_zops_list_channels',
}
# response:
{
'channels': [
{... | def list_channels(current):
"""
List channel memberships of current user
.. code-block:: python
# request:
{
'view':'_zops_list_channels',
}
# response:
{
'channels': [
{... | [
"List",
"channel",
"memberships",
"of",
"current",
"user"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L261-L302 | [
"def",
"list_channels",
"(",
"current",
")",
":",
"current",
".",
"output",
"=",
"{",
"'status'",
":",
"'OK'",
",",
"'code'",
":",
"200",
",",
"'channels'",
":",
"[",
"]",
"}",
"for",
"sbs",
"in",
"current",
".",
"user",
".",
"subscriptions",
".",
"o... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | unread_count | Number of unread messages for current user
.. code-block:: python
# request:
{
'view':'_zops_unread_count',
}
# response:
{
'status': 'OK',
'code': 200,
'notifications': ... | zengine/messaging/views.py | 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):
"""
Number of unread messages for current user
.. code-block:: python
# request:
{
'view':'_zops_unread_count',
}
# response:
{
'status': 'OK',
'co... | [
"Number",
"of",
"unread",
"messages",
"for",
"current",
"user"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L305-L342 | [
"def",
"unread_count",
"(",
"current",
")",
":",
"unread_ntf",
"=",
"0",
"unread_msg",
"=",
"0",
"for",
"sbs",
"in",
"current",
".",
"user",
".",
"subscriptions",
".",
"objects",
".",
"filter",
"(",
"is_visible",
"=",
"True",
")",
":",
"try",
":",
"if"... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | get_notifications | Returns last N notifications for current user
.. code-block:: python
# request:
{
'view':'_zops_unread_messages',
'amount': int, # Optional, defaults to 8
}
# response:
{
'status': 'OK',... | zengine/messaging/views.py | 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):
"""
Returns last N notifications for current user
.. code-block:: python
# request:
{
'view':'_zops_unread_messages',
'amount': int, # Optional, defaults to 8
}
# response:
... | [
"Returns",
"last",
"N",
"notifications",
"for",
"current",
"user"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L345-L394 | [
"def",
"get_notifications",
"(",
"current",
")",
":",
"current",
".",
"output",
"=",
"{",
"'status'",
":",
"'OK'",
",",
"'code'",
":",
"200",
",",
"'notifications'",
":",
"[",
"]",
",",
"}",
"amount",
"=",
"current",
".",
"input",
".",
"get",
"(",
"'... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | create_channel | 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,
... | zengine/messaging/views.py | 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):
"""
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... | [
"Create",
"a",
"public",
"channel",
".",
"Can",
"be",
"a",
"broadcast",
"channel",
"or",
"normal",
"chat",
"room",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L397-L442 | [
"def",
"create_channel",
"(",
"current",
")",
":",
"channel",
"=",
"Channel",
"(",
"name",
"=",
"current",
".",
"input",
"[",
"'name'",
"]",
",",
"description",
"=",
"current",
".",
"input",
"[",
"'description'",
"]",
",",
"owner",
"=",
"current",
".",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | add_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... | zengine/messaging/views.py | 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):
"""
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,
... | [
"Subscribe",
"member",
"(",
"s",
")",
"to",
"a",
"channel"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L445-L484 | [
"def",
"add_members",
"(",
"current",
")",
":",
"newly_added",
",",
"existing",
"=",
"[",
"]",
",",
"[",
"]",
"read_only",
"=",
"current",
".",
"input",
"[",
"'read_only'",
"]",
"for",
"member_key",
"in",
"current",
".",
"input",
"[",
"'members'",
"]",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | add_unit_to_channel | 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': ... | zengine/messaging/views.py | 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):
"""
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... | [
"Subscribe",
"users",
"of",
"a",
"given",
"unit",
"to",
"given",
"channel"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L487-L528 | [
"def",
"add_unit_to_channel",
"(",
"current",
")",
":",
"read_only",
"=",
"current",
".",
"input",
"[",
"'read_only'",
"]",
"newly_added",
",",
"existing",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"member_key",
"in",
"UnitModel",
".",
"get_user_keys",
"(",
"cu... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | search_user | 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:
{
'... | zengine/messaging/views.py | 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):
"""
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... | [
"Search",
"users",
"for",
"adding",
"to",
"a",
"public",
"room",
"or",
"creating",
"one",
"to",
"one",
"direct",
"messaging"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L531-L563 | [
"def",
"search_user",
"(",
"current",
")",
":",
"current",
".",
"output",
"=",
"{",
"'results'",
":",
"[",
"]",
",",
"'status'",
":",
"'OK'",
",",
"'code'",
":",
"201",
"}",
"qs",
"=",
"UserModel",
"(",
"current",
")",
".",
"objects",
".",
"exclude",... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | search_unit | 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'), ],
... | zengine/messaging/views.py | 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):
"""
Search on units for subscribing it's users to a channel
.. code-block:: python
# request:
{
'view':'_zops_search_unit',
'query': string,
}
# response:
{
... | [
"Search",
"on",
"units",
"for",
"subscribing",
"it",
"s",
"users",
"to",
"a",
"channel"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L566-L592 | [
"def",
"search_unit",
"(",
"current",
")",
":",
"current",
".",
"output",
"=",
"{",
"'results'",
":",
"[",
"]",
",",
"'status'",
":",
"'OK'",
",",
"'code'",
":",
"201",
"}",
"for",
"user",
"in",
"UnitModel",
"(",
"current",
")",
".",
"objects",
".",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | create_direct_channel | 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': ... | zengine/messaging/views.py | 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):
"""
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... | [
"Create",
"a",
"One",
"-",
"To",
"-",
"One",
"channel",
"between",
"current",
"and",
"selected",
"user",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L595-L631 | [
"def",
"create_direct_channel",
"(",
"current",
")",
":",
"channel",
",",
"sub_name",
"=",
"Channel",
".",
"get_or_create_direct_channel",
"(",
"current",
".",
"user_id",
",",
"current",
".",
"input",
"[",
"'user_key'",
"]",
")",
"current",
".",
"input",
"[",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | find_message | 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,
... | zengine/messaging/views.py | 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):
"""
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_... | [
"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",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L634-L679 | [
"def",
"find_message",
"(",
"current",
")",
":",
"current",
".",
"output",
"=",
"{",
"'results'",
":",
"[",
"]",
",",
"'status'",
":",
"'OK'",
",",
"'code'",
":",
"201",
"}",
"query_set",
"=",
"Message",
"(",
"current",
")",
".",
"objects",
".",
"sea... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | delete_channel | Delete a channel
.. code-block:: python
# request:
{
'view':'_zops_delete_channel,
'channel_key': key,
}
# response:
{
'status': 'OK',
'code': 200
} | zengine/messaging/views.py | 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):
"""
Delete a channel
.. code-block:: python
# request:
{
'view':'_zops_delete_channel,
'channel_key': key,
}
# response:
{
'status': 'OK',
... | [
"Delete",
"a",
"channel"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L682-L706 | [
"def",
"delete_channel",
"(",
"current",
")",
":",
"ch_key",
"=",
"current",
".",
"input",
"[",
"'channel_key'",
"]",
"ch",
"=",
"Channel",
"(",
"current",
")",
".",
"objects",
".",
"get",
"(",
"owner_id",
"=",
"current",
".",
"user_id",
",",
"key",
"=... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | edit_channel | Update channel name or description
.. code-block:: python
# request:
{
'view':'_zops_edit_channel,
'channel_key': key,
'name': string,
'description': string,
}
# response:
... | zengine/messaging/views.py | 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):
"""
Update channel name or description
.. code-block:: python
# request:
{
'view':'_zops_edit_channel,
'channel_key': key,
'name': string,
'description': string,
... | [
"Update",
"channel",
"name",
"or",
"description"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L709-L737 | [
"def",
"edit_channel",
"(",
"current",
")",
":",
"ch",
"=",
"Channel",
"(",
"current",
")",
".",
"objects",
".",
"get",
"(",
"owner_id",
"=",
"current",
".",
"user_id",
",",
"key",
"=",
"current",
".",
"input",
"[",
"'channel_key'",
"]",
")",
"ch",
"... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | pin_channel | Pin a channel to top of channel list
.. code-block:: python
# request:
{
'view':'_zops_pin_channel,
'channel_key': key,
}
# response:
{
'status': 'OK',
'code': 200
... | zengine/messaging/views.py | 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):
"""
Pin a channel to top of channel list
.. code-block:: python
# request:
{
'view':'_zops_pin_channel,
'channel_key': key,
}
# response:
{
'status':... | [
"Pin",
"a",
"channel",
"to",
"top",
"of",
"channel",
"list"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L740-L764 | [
"def",
"pin_channel",
"(",
"current",
")",
":",
"try",
":",
"Subscriber",
"(",
"current",
")",
".",
"objects",
".",
"filter",
"(",
"user_id",
"=",
"current",
".",
"user_id",
",",
"channel_id",
"=",
"current",
".",
"input",
"[",
"'channel_key'",
"]",
")",... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | delete_message | Delete a message
.. code-block:: python
# request:
{
'view':'_zops_delete_message,
'message_key': key,
}
# response:
{
'key': key,
'status': 'OK',
'code': ... | zengine/messaging/views.py | 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):
"""
Delete a message
.. code-block:: python
# request:
{
'view':'_zops_delete_message,
'message_key': key,
}
# response:
{
'key': key,
... | [
"Delete",
"a",
"message"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L767-L791 | [
"def",
"delete_message",
"(",
"current",
")",
":",
"try",
":",
"Message",
"(",
"current",
")",
".",
"objects",
".",
"get",
"(",
"sender_id",
"=",
"current",
".",
"user_id",
",",
"key",
"=",
"current",
".",
"input",
"[",
"'key'",
"]",
")",
".",
"delet... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | edit_message | Edit a message a user own.
.. code-block:: python
# request:
{
'view':'_zops_edit_message',
'message': {
'body': string, # message text
'key': key
}
}
# response:
{
'status': string,... | zengine/messaging/views.py | 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):
"""
Edit a message a user own.
.. code-block:: python
# request:
{
'view':'_zops_edit_message',
'message': {
'body': string, # message text
'key': key
}
}
# response:
... | [
"Edit",
"a",
"message",
"a",
"user",
"own",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L794-L822 | [
"def",
"edit_message",
"(",
"current",
")",
":",
"current",
".",
"output",
"=",
"{",
"'status'",
":",
"'OK'",
",",
"'code'",
":",
"200",
"}",
"in_msg",
"=",
"current",
".",
"input",
"[",
"'message'",
"]",
"try",
":",
"msg",
"=",
"Message",
"(",
"curr... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | flag_message | Flag inappropriate messages
.. code-block:: python
# request:
{
'view':'_zops_flag_message',
'message_key': key,
}
# response:
{
'
'status': 'Created',
'code': 201,
} | zengine/messaging/views.py | 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):
"""
Flag inappropriate messages
.. code-block:: python
# request:
{
'view':'_zops_flag_message',
'message_key': key,
}
# response:
{
'
'status': 'Created',
'code': 201,
... | [
"Flag",
"inappropriate",
"messages"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L825-L846 | [
"def",
"flag_message",
"(",
"current",
")",
":",
"current",
".",
"output",
"=",
"{",
"'status'",
":",
"'Created'",
",",
"'code'",
":",
"201",
"}",
"FlaggedMessage",
".",
"objects",
".",
"get_or_create",
"(",
"user_id",
"=",
"current",
".",
"user_id",
",",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | unflag_message | remove flag of a message
.. code-block:: python
# request:
{
'view':'_zops_flag_message',
'key': key,
}
# response:
{
'
'status': 'OK',
'code': 200,
} | zengine/messaging/views.py | 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):
"""
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"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L849-L871 | [
"def",
"unflag_message",
"(",
"current",
")",
":",
"current",
".",
"output",
"=",
"{",
"'status'",
":",
"'OK'",
",",
"'code'",
":",
"200",
"}",
"FlaggedMessage",
"(",
"current",
")",
".",
"objects",
".",
"filter",
"(",
"user_id",
"=",
"current",
".",
"... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | get_message_actions | 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... | zengine/messaging/views.py | 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):
"""
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... | [
"Returns",
"applicable",
"actions",
"for",
"current",
"user",
"for",
"given",
"message",
"key"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L874-L896 | [
"def",
"get_message_actions",
"(",
"current",
")",
":",
"current",
".",
"output",
"=",
"{",
"'status'",
":",
"'OK'",
",",
"'code'",
":",
"200",
",",
"'actions'",
":",
"Message",
".",
"objects",
".",
"get",
"(",
"current",
".",
"input",
"[",
"'key'",
"]... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | add_to_favorites | Favorite a message
.. code-block:: python
# request:
{
'view':'_zops_add_to_favorites,
'key': key,
}
# response:
{
'status': 'Created',
'code': 201
'favorite_key': key
} | zengine/messaging/views.py | 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):
"""
Favorite a message
.. code-block:: python
# request:
{
'view':'_zops_add_to_favorites,
'key': key,
}
# response:
{
'status': 'Created',
'code': 201
'favorit... | [
"Favorite",
"a",
"message"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L899-L922 | [
"def",
"add_to_favorites",
"(",
"current",
")",
":",
"msg",
"=",
"Message",
".",
"objects",
".",
"get",
"(",
"current",
".",
"input",
"[",
"'key'",
"]",
")",
"current",
".",
"output",
"=",
"{",
"'status'",
":",
"'Created'",
",",
"'code'",
":",
"201",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | remove_from_favorites | Remove a message from favorites
.. code-block:: python
# request:
{
'view':'_zops_remove_from_favorites,
'key': key,
}
# response:
{
'status': 'OK',
'code': 200
} | zengine/messaging/views.py | 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):
"""
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"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L925-L949 | [
"def",
"remove_from_favorites",
"(",
"current",
")",
":",
"try",
":",
"current",
".",
"output",
"=",
"{",
"'status'",
":",
"'OK'",
",",
"'code'",
":",
"200",
"}",
"Favorite",
"(",
"current",
")",
".",
"objects",
".",
"get",
"(",
"user_id",
"=",
"curren... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | list_favorites | 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',
... | zengine/messaging/views.py | 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):
"""
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:
{... | [
"List",
"user",
"s",
"favorites",
".",
"If",
"channel_key",
"given",
"will",
"return",
"favorites",
"belong",
"to",
"that",
"channel",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/views.py#L952-L987 | [
"def",
"list_favorites",
"(",
"current",
")",
":",
"current",
".",
"output",
"=",
"{",
"'status'",
":",
"'OK'",
",",
"'code'",
":",
"200",
",",
"'favorites'",
":",
"[",
"]",
"}",
"query_set",
"=",
"Favorite",
"(",
"current",
")",
".",
"objects",
".",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Channel.get_or_create_direct_channel | 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) | zengine/messaging/model.py | 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):
"""
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"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/model.py#L75-L102 | [
"def",
"get_or_create_direct_channel",
"(",
"cls",
",",
"initiator_key",
",",
"receiver_key",
")",
":",
"existing",
"=",
"cls",
".",
"objects",
".",
"OR",
"(",
")",
".",
"filter",
"(",
"code_name",
"=",
"'%s_%s'",
"%",
"(",
"initiator_key",
",",
"receiver_ke... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Channel.create_exchange | Creates MQ exchange for this channel
Needs to be defined only once. | zengine/messaging/model.py | 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):
"""
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',
... | [
"Creates",
"MQ",
"exchange",
"for",
"this",
"channel",
"Needs",
"to",
"be",
"defined",
"only",
"once",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/model.py#L135-L143 | [
"def",
"create_exchange",
"(",
"self",
")",
":",
"mq_channel",
"=",
"self",
".",
"_connect_mq",
"(",
")",
"mq_channel",
".",
"exchange_declare",
"(",
"exchange",
"=",
"self",
".",
"code_name",
",",
"exchange_type",
"=",
"'fanout'",
",",
"durable",
"=",
"True... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Channel.delete_exchange | Deletes MQ exchange for this channel
Needs to be defined only once. | zengine/messaging/model.py | 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):
"""
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) | [
"Deletes",
"MQ",
"exchange",
"for",
"this",
"channel",
"Needs",
"to",
"be",
"defined",
"only",
"once",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/model.py#L145-L151 | [
"def",
"delete_exchange",
"(",
"self",
")",
":",
"mq_channel",
"=",
"self",
".",
"_connect_mq",
"(",
")",
"mq_channel",
".",
"exchange_delete",
"(",
"exchange",
"=",
"self",
".",
"code_name",
")"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Subscriber.get_channel_listing | serialized form for channel listing | zengine/messaging/model.py | 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):
"""
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(),
... | [
"serialized",
"form",
"for",
"channel",
"listing"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/model.py#L214-L225 | [
"def",
"get_channel_listing",
"(",
"self",
")",
":",
"return",
"{",
"'name'",
":",
"self",
".",
"name",
",",
"'key'",
":",
"self",
".",
"channel",
".",
"key",
",",
"'type'",
":",
"self",
".",
"channel",
".",
"typ",
",",
"'read_only'",
":",
"self",
".... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Subscriber.create_exchange | 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 | zengine/messaging/model.py | 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):
"""
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... | [
"Creates",
"user",
"s",
"private",
"exchange"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/model.py#L264-L276 | [
"def",
"create_exchange",
"(",
"self",
")",
":",
"channel",
"=",
"self",
".",
"_connect_mq",
"(",
")",
"channel",
".",
"exchange_declare",
"(",
"exchange",
"=",
"self",
".",
"user",
".",
"prv_exchange",
",",
"exchange_type",
"=",
"'fanout'",
",",
"durable",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Subscriber.bind_to_channel | Binds (subscribes) users private exchange to channel exchange
Automatically called at creation of subscription record. | zengine/messaging/model.py | 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):
"""
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... | [
"Binds",
"(",
"subscribes",
")",
"users",
"private",
"exchange",
"to",
"channel",
"exchange",
"Automatically",
"called",
"at",
"creation",
"of",
"subscription",
"record",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/model.py#L282-L289 | [
"def",
"bind_to_channel",
"(",
"self",
")",
":",
"if",
"self",
".",
"channel",
".",
"code_name",
"!=",
"self",
".",
"user",
".",
"prv_exchange",
":",
"channel",
"=",
"self",
".",
"_connect_mq",
"(",
")",
"channel",
".",
"exchange_bind",
"(",
"source",
"=... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Message.serialize | 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 | zengine/messaging/model.py | 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):
"""
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",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/model.py#L370-L398 | [
"def",
"serialize",
"(",
"self",
",",
"user",
"=",
"None",
")",
":",
"return",
"{",
"'content'",
":",
"self",
".",
"body",
",",
"'type'",
":",
"self",
".",
"typ",
",",
"'updated_at'",
":",
"self",
".",
"updated_at",
",",
"'timestamp'",
":",
"self",
"... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Message._republish | Re-publishes updated message | zengine/messaging/model.py | 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):
"""
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())) | [
"Re",
"-",
"publishes",
"updated",
"message"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/model.py#L404-L410 | [
"def",
"_republish",
"(",
"self",
")",
":",
"mq_channel",
"=",
"self",
".",
"channel",
".",
"_connect_mq",
"(",
")",
"mq_channel",
".",
"basic_publish",
"(",
"exchange",
"=",
"self",
".",
"channel",
".",
"key",
",",
"routing_key",
"=",
"''",
",",
"body",... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | defaultCrawlId | Provide a reasonable default crawl name using the user name and date | nutch/nutch.py | 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():
"""
Provide a reasonable default crawl name using the user name and date
"""
timestamp = datetime.now().isoformat().replace(':', '_')
user = getuser()
return '_'.join(('crawl', user, timestamp)) | [
"Provide",
"a",
"reasonable",
"default",
"crawl",
"name",
"using",
"the",
"user",
"name",
"and",
"date"
] | chrismattmann/nutch-python | python | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L91-L98 | [
"def",
"defaultCrawlId",
"(",
")",
":",
"timestamp",
"=",
"datetime",
".",
"now",
"(",
")",
".",
"isoformat",
"(",
")",
".",
"replace",
"(",
"':'",
",",
"'_'",
")",
"user",
"=",
"getuser",
"(",
")",
"return",
"'_'",
".",
"join",
"(",
"(",
"'crawl'"... | 07ae182e283b2f74ef062ddfa20a690a59ab6f5a |
train | main | Run Nutch command using REST API. | nutch/nutch.py | 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):
"""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... | [
"Run",
"Nutch",
"command",
"using",
"REST",
"API",
"."
] | chrismattmann/nutch-python | python | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L716-L749 | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"global",
"Verbose",
",",
"Mock",
"if",
"argv",
"is",
"None",
":",
"argv",
"=",
"sys",
".",
"argv",
"if",
"len",
"(",
"argv",
")",
"<",
"5",
":",
"die",
"(",
"'Bad args'",
")",
"try",
":",
"opt... | 07ae182e283b2f74ef062ddfa20a690a59ab6f5a |
train | Server.call | 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... | nutch/nutch.py | 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):
"""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'
:... | [
"Call",
"the",
"Nutch",
"Server",
"do",
"some",
"error",
"checking",
"and",
"return",
"the",
"response",
"."
] | chrismattmann/nutch-python | python | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L117-L170 | [
"def",
"call",
"(",
"self",
",",
"verb",
",",
"servicePath",
",",
"data",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"forceText",
"=",
"False",
",",
"sendJson",
"=",
"True",
")",
":",
"default_data",
"=",
"{",
"}",
"if",
"sendJson",
"else",
"\"\"... | 07ae182e283b2f74ef062ddfa20a690a59ab6f5a |
train | ConfigClient.create | Create a new named (cid) configuration from a parameter dictionary (config_data). | nutch/nutch.py | 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):
"""
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... | [
"Create",
"a",
"new",
"named",
"(",
"cid",
")",
"configuration",
"from",
"a",
"parameter",
"dictionary",
"(",
"config_data",
")",
"."
] | chrismattmann/nutch-python | python | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L278-L285 | [
"def",
"create",
"(",
"self",
",",
"cid",
",",
"configData",
")",
":",
"configArgs",
"=",
"{",
"'configId'",
":",
"cid",
",",
"'params'",
":",
"configData",
",",
"'force'",
":",
"True",
"}",
"cid",
"=",
"self",
".",
"server",
".",
"call",
"(",
"'post... | 07ae182e283b2f74ef062ddfa20a690a59ab6f5a |
train | JobClient.list | Return list of jobs at this endpoint.
Call get(allJobs=True) to see all jobs, not just the ones managed by this Client | nutch/nutch.py | 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):
"""
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._... | [
"Return",
"list",
"of",
"jobs",
"at",
"this",
"endpoint",
"."
] | chrismattmann/nutch-python | python | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L337-L346 | [
"def",
"list",
"(",
"self",
",",
"allJobs",
"=",
"False",
")",
":",
"jobs",
"=",
"self",
".",
"server",
".",
"call",
"(",
"'get'",
",",
"'/job'",
")",
"return",
"[",
"Job",
"(",
"job",
"[",
"'id'",
"]",
",",
"self",
".",
"server",
")",
"for",
"... | 07ae182e283b2f74ef062ddfa20a690a59ab6f5a |
train | JobClient.create | 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 | nutch/nutch.py | 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):
"""
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... | [
"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",
... | chrismattmann/nutch-python | python | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L348-L370 | [
"def",
"create",
"(",
"self",
",",
"command",
",",
"*",
"*",
"args",
")",
":",
"command",
"=",
"command",
".",
"upper",
"(",
")",
"if",
"command",
"not",
"in",
"LegalJobs",
":",
"warn",
"(",
"'Nutch command must be one of: %s'",
"%",
"', '",
".",
"join",... | 07ae182e283b2f74ef062ddfa20a690a59ab6f5a |
train | JobClient.inject | :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 | nutch/nutch.py | 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):
"""
: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... | [
":",
"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... | chrismattmann/nutch-python | python | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L374-L391 | [
"def",
"inject",
"(",
"self",
",",
"seed",
"=",
"None",
",",
"urlDir",
"=",
"None",
",",
"*",
"*",
"args",
")",
":",
"if",
"seed",
":",
"if",
"urlDir",
"and",
"urlDir",
"!=",
"seed",
".",
"seedPath",
":",
"raise",
"NutchException",
"(",
"\"Can't spec... | 07ae182e283b2f74ef062ddfa20a690a59ab6f5a |
train | SeedClient.create | 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 | nutch/nutch.py | 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):
"""
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, ... | [
"Create",
"a",
"new",
"named",
"(",
"sid",
")",
"Seed",
"from",
"a",
"list",
"of",
"seed",
"URLs"
] | chrismattmann/nutch-python | python | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L419-L442 | [
"def",
"create",
"(",
"self",
",",
"sid",
",",
"seedList",
")",
":",
"seedUrl",
"=",
"lambda",
"uid",
",",
"url",
":",
"{",
"\"id\"",
":",
"uid",
",",
"\"url\"",
":",
"url",
"}",
"if",
"not",
"isinstance",
"(",
"seedList",
",",
"tuple",
")",
":",
... | 07ae182e283b2f74ef062ddfa20a690a59ab6f5a |
train | SeedClient.createFromFile | 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 | nutch/nutch.py | 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):
"""
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... | [
"Create",
"a",
"new",
"named",
"(",
"sid",
")",
"Seed",
"from",
"a",
"file",
"containing",
"URLs",
"It",
"s",
"assumed",
"URLs",
"are",
"whitespace",
"seperated",
"."
] | chrismattmann/nutch-python | python | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L444-L460 | [
"def",
"createFromFile",
"(",
"self",
",",
"sid",
",",
"filename",
")",
":",
"urls",
"=",
"[",
"]",
"with",
"open",
"(",
"filename",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"for",
"url",
"in",
"line",
".",
"split",
"(",
")",
":",
"u... | 07ae182e283b2f74ef062ddfa20a690a59ab6f5a |
train | CrawlClient._nextJob | 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 | nutch/nutch.py | 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):
"""
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"
] | chrismattmann/nutch-python | python | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L492-L533 | [
"def",
"_nextJob",
"(",
"self",
",",
"job",
",",
"nextRound",
"=",
"True",
")",
":",
"jobInfo",
"=",
"job",
".",
"info",
"(",
")",
"assert",
"jobInfo",
"[",
"'state'",
"]",
"==",
"'FINISHED'",
"roundEnd",
"=",
"False",
"if",
"jobInfo",
"[",
"'type'",
... | 07ae182e283b2f74ef062ddfa20a690a59ab6f5a |
train | CrawlClient.progress | 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.
:... | nutch/nutch.py | 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):
"""
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... | [
"Check",
"the",
"status",
"of",
"the",
"current",
"job",
"activate",
"the",
"next",
"job",
"if",
"it",
"s",
"finished",
"and",
"return",
"the",
"active",
"job"
] | chrismattmann/nutch-python | python | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L535-L560 | [
"def",
"progress",
"(",
"self",
",",
"nextRound",
"=",
"True",
")",
":",
"currentJob",
"=",
"self",
".",
"currentJob",
"if",
"currentJob",
"is",
"None",
":",
"return",
"currentJob",
"jobInfo",
"=",
"currentJob",
".",
"info",
"(",
")",
"if",
"jobInfo",
"[... | 07ae182e283b2f74ef062ddfa20a690a59ab6f5a |
train | CrawlClient.nextRound | 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 | nutch/nutch.py | 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):
"""
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",
"."
] | chrismattmann/nutch-python | python | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L573-L595 | [
"def",
"nextRound",
"(",
"self",
")",
":",
"finishedJobs",
"=",
"[",
"]",
"if",
"self",
".",
"currentJob",
"is",
"None",
":",
"self",
".",
"currentJob",
"=",
"self",
".",
"jobClient",
".",
"create",
"(",
"'GENERATE'",
")",
"activeJob",
"=",
"self",
"."... | 07ae182e283b2f74ef062ddfa20a690a59ab6f5a |
train | CrawlClient.waitAll | 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) | nutch/nutch.py | 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):
"""
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",
"."
] | chrismattmann/nutch-python | python | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L597-L612 | [
"def",
"waitAll",
"(",
"self",
")",
":",
"finishedRounds",
"=",
"[",
"self",
".",
"nextRound",
"(",
")",
"]",
"while",
"self",
".",
"currentRound",
"<",
"self",
".",
"totalRounds",
":",
"finishedRounds",
".",
"append",
"(",
"self",
".",
"nextRound",
"(",... | 07ae182e283b2f74ef062ddfa20a690a59ab6f5a |
train | Nutch.Jobs | 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 | nutch/nutch.py | 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):
"""
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... | [
"Create",
"a",
"JobClient",
"for",
"listing",
"and",
"creating",
"jobs",
".",
"The",
"JobClient",
"inherits",
"the",
"confId",
"from",
"the",
"Nutch",
"client",
"."
] | chrismattmann/nutch-python | python | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L656-L666 | [
"def",
"Jobs",
"(",
"self",
",",
"crawlId",
"=",
"None",
")",
":",
"crawlId",
"=",
"crawlId",
"if",
"crawlId",
"else",
"defaultCrawlId",
"(",
")",
"return",
"JobClient",
"(",
"self",
".",
"server",
",",
"crawlId",
",",
"self",
".",
"confId",
")"
] | 07ae182e283b2f74ef062ddfa20a690a59ab6f5a |
train | Nutch.Crawl | 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... | nutch/nutch.py | 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):
"""
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... | [
"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... | chrismattmann/nutch-python | python | https://github.com/chrismattmann/nutch-python/blob/07ae182e283b2f74ef062ddfa20a690a59ab6f5a/nutch/nutch.py#L677-L693 | [
"def",
"Crawl",
"(",
"self",
",",
"seed",
",",
"seedClient",
"=",
"None",
",",
"jobClient",
"=",
"None",
",",
"rounds",
"=",
"1",
",",
"index",
"=",
"True",
")",
":",
"if",
"seedClient",
"is",
"None",
":",
"seedClient",
"=",
"self",
".",
"Seeds",
"... | 07ae182e283b2f74ef062ddfa20a690a59ab6f5a |
train | haproxy | >>> 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... | logagg/formatters.py | 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
'''
>>> 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... | [
">>>",
"import",
"pprint",
">>>",
"input_line1",
"=",
"Apr",
"24",
"00",
":",
"00",
":",
"02",
"node",
"haproxy",
"[",
"12298",
"]",
":",
"1",
".",
"1",
".",
"1",
".",
"1",
":",
"48660",
"[",
"24",
"/",
"Apr",
"/",
"2019",
":",
"00",
":",
"00... | deep-compute/logagg | python | https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/formatters.py#L19-L94 | [
"def",
"haproxy",
"(",
"line",
")",
":",
"#TODO Handle all message formats",
"_line",
"=",
"line",
".",
"strip",
"(",
")",
".",
"split",
"(",
")",
"log",
"=",
"{",
"}",
"log",
"[",
"'client_server'",
"]",
"=",
"_line",
"[",
"5",
"]",
".",
"split",
"(... | 7863bc1b5ddf3e67c4d4b55746799304180589a0 |
train | nginx_access | >>> 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": "... | logagg/formatters.py | 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):
'''
>>> 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... | [
">>>",
"import",
"pprint",
">>>",
"input_line1",
"=",
"{",
"\\",
"remote_addr",
":",
"127",
".",
"0",
".",
"0",
".",
"1",
"remote_user",
":",
"-",
"timestamp",
":",
"1515144699",
".",
"201",
"\\",
"request",
":",
"GET",
"/",
"HTTP",
"/",
"1",
".",
... | deep-compute/logagg | python | https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/formatters.py#L96-L160 | [
"def",
"nginx_access",
"(",
"line",
")",
":",
"#TODO Handle nginx error logs",
"log",
"=",
"json",
".",
"loads",
"(",
"line",
")",
"timestamp_iso",
"=",
"datetime",
".",
"datetime",
".",
"utcfromtimestamp",
"(",
"float",
"(",
"log",
"[",
"'timestamp'",
"]",
... | 7863bc1b5ddf3e67c4d4b55746799304180589a0 |
train | mongodb | >>> 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]',
... | logagg/formatters.py | 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):
'''
>>> 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... | [
">>>",
"import",
"pprint",
">>>",
"input_line1",
"=",
"2017",
"-",
"08",
"-",
"17T07",
":",
"56",
":",
"33",
".",
"489",
"+",
"0200",
"I",
"REPL",
"[",
"signalProcessingThread",
"]",
"shutting",
"down",
"replication",
"subsystems",
">>>",
"output_line1",
"... | deep-compute/logagg | python | https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/formatters.py#L162-L196 | [
"def",
"mongodb",
"(",
"line",
")",
":",
"keys",
"=",
"[",
"'timestamp'",
",",
"'severity'",
",",
"'component'",
",",
"'context'",
",",
"'message'",
"]",
"values",
"=",
"re",
".",
"split",
"(",
"r'\\s+'",
",",
"line",
",",
"maxsplit",
"=",
"4",
")",
... | 7863bc1b5ddf3e67c4d4b55746799304180589a0 |
train | django | >>> 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)
>>>... | logagg/formatters.py | 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):
'''
>>> 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... | [
">>>",
"import",
"pprint",
">>>",
"input_line1",
"=",
"[",
"23",
"/",
"Aug",
"/",
"2017",
"11",
":",
"35",
":",
"25",
"]",
"INFO",
"[",
"app",
".",
"middleware_log_req",
":",
"50",
"]",
"View",
"func",
"called",
":",
"{",
"exception",
":",
"null",
... | deep-compute/logagg | python | https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/formatters.py#L199-L271 | [
"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",... | 7863bc1b5ddf3e67c4d4b55746799304180589a0 |
train | basescript | >>> 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": "... | logagg/formatters.py | 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):
'''
>>> 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... | [
">>>",
"import",
"pprint",
">>>",
"input_line",
"=",
"{",
"level",
":",
"warning",
"timestamp",
":",
"2018",
"-",
"02",
"-",
"07T06",
":",
"37",
":",
"00",
".",
"297610Z",
"event",
":",
"exited",
"via",
"keyboard",
"interrupt",
"type",
":",
"log",
"id"... | deep-compute/logagg | python | https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/formatters.py#L273-L304 | [
"def",
"basescript",
"(",
"line",
")",
":",
"log",
"=",
"json",
".",
"loads",
"(",
"line",
")",
"return",
"dict",
"(",
"timestamp",
"=",
"log",
"[",
"'timestamp'",
"]",
",",
"data",
"=",
"log",
",",
"id",
"=",
"log",
"[",
"'id'",
"]",
",",
"type"... | 7863bc1b5ddf3e67c4d4b55746799304180589a0 |
train | elasticsearch | >>> import pprint
>>> input_line = '[2017-08-30T06:27:19,158] [WARN ][o.e.m.j.JvmGcMonitorService] [Glsuj_2] [gc][296816] overhead, spent [1.2s] collecting in the last [1.3s]'
>>> output_line = elasticsearch(input_line)
>>> pprint.pprint(output_line)
{'data': {'garbage_collector': 'gc',
'g... | logagg/formatters.py | def elasticsearch(line):
'''
>>> import pprint
>>> input_line = '[2017-08-30T06:27:19,158] [WARN ][o.e.m.j.JvmGcMonitorService] [Glsuj_2] [gc][296816] overhead, spent [1.2s] collecting in the last [1.3s]'
>>> output_line = elasticsearch(input_line)
>>> pprint.pprint(output_line)
{'data': {'garba... | def elasticsearch(line):
'''
>>> import pprint
>>> input_line = '[2017-08-30T06:27:19,158] [WARN ][o.e.m.j.JvmGcMonitorService] [Glsuj_2] [gc][296816] overhead, spent [1.2s] collecting in the last [1.3s]'
>>> output_line = elasticsearch(input_line)
>>> pprint.pprint(output_line)
{'data': {'garba... | [
">>>",
"import",
"pprint",
">>>",
"input_line",
"=",
"[",
"2017",
"-",
"08",
"-",
"30T06",
":",
"27",
":",
"19",
"158",
"]",
"[",
"WARN",
"]",
"[",
"o",
".",
"e",
".",
"m",
".",
"j",
".",
"JvmGcMonitorService",
"]",
"[",
"Glsuj_2",
"]",
"[",
"g... | deep-compute/logagg | python | https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/formatters.py#L306-L370 | [
"def",
"elasticsearch",
"(",
"line",
")",
":",
"# TODO we need to handle case2 logs",
"elasticsearch_log",
"=",
"line",
"actuallog",
"=",
"re",
".",
"findall",
"(",
"r'(\\[\\d+\\-+\\d+\\d+\\-+\\d+\\w+\\d+:\\d+:\\d+,+\\d\\d\\d+\\].*)'",
",",
"elasticsearch_log",
")",
"if",
"... | 7863bc1b5ddf3e67c4d4b55746799304180589a0 |
train | elasticsearch_ispartial_log | >>> line1 = ' [2018-04-03T00:22:38,048][DEBUG][o.e.c.u.c.QueueResizingEsThreadPoolExecutor] [search17/search]: there were [2000] tasks in [809ms], avg task time [28.4micros], EWMA task execution [790nanos], [35165.36 tasks/s], optimal queue is [35165], current capacity [1000]'
>>> line2 = ' org.elasticsearch.Reso... | logagg/formatters.py | def elasticsearch_ispartial_log(line):
'''
>>> line1 = ' [2018-04-03T00:22:38,048][DEBUG][o.e.c.u.c.QueueResizingEsThreadPoolExecutor] [search17/search]: there were [2000] tasks in [809ms], avg task time [28.4micros], EWMA task execution [790nanos], [35165.36 tasks/s], optimal queue is [35165], current capacit... | def elasticsearch_ispartial_log(line):
'''
>>> line1 = ' [2018-04-03T00:22:38,048][DEBUG][o.e.c.u.c.QueueResizingEsThreadPoolExecutor] [search17/search]: there were [2000] tasks in [809ms], avg task time [28.4micros], EWMA task execution [790nanos], [35165.36 tasks/s], optimal queue is [35165], current capacit... | [
">>>",
"line1",
"=",
"[",
"2018",
"-",
"04",
"-",
"03T00",
":",
"22",
":",
"38",
"048",
"]",
"[",
"DEBUG",
"]",
"[",
"o",
".",
"e",
".",
"c",
".",
"u",
".",
"c",
".",
"QueueResizingEsThreadPoolExecutor",
"]",
"[",
"search17",
"/",
"search",
"]",
... | deep-compute/logagg | python | https://github.com/deep-compute/logagg/blob/7863bc1b5ddf3e67c4d4b55746799304180589a0/logagg/formatters.py#L374-L391 | [
"def",
"elasticsearch_ispartial_log",
"(",
"line",
")",
":",
"match_result",
"=",
"[",
"]",
"for",
"p",
"in",
"LOG_BEGIN_PATTERN",
":",
"if",
"re",
".",
"match",
"(",
"p",
",",
"line",
")",
"!=",
"None",
":",
"return",
"False",
"return",
"True"
] | 7863bc1b5ddf3e67c4d4b55746799304180589a0 |
train | Session.get | Get an attribute defined by this session | alexandra/session.py | def get(self, attr, default=None):
"""Get an attribute defined by this session"""
attrs = self.body.get('attributes') or {}
return attrs.get(attr, default) | def get(self, attr, default=None):
"""Get an attribute defined by this session"""
attrs = self.body.get('attributes') or {}
return attrs.get(attr, default) | [
"Get",
"an",
"attribute",
"defined",
"by",
"this",
"session"
] | erik/alexandra | python | https://github.com/erik/alexandra/blob/8bea94efa1af465254a553dc4dfea3fa552b18da/alexandra/session.py#L38-L42 | [
"def",
"get",
"(",
"self",
",",
"attr",
",",
"default",
"=",
"None",
")",
":",
"attrs",
"=",
"self",
".",
"body",
".",
"get",
"(",
"'attributes'",
")",
"or",
"{",
"}",
"return",
"attrs",
".",
"get",
"(",
"attr",
",",
"default",
")"
] | 8bea94efa1af465254a553dc4dfea3fa552b18da |
train | CatalogData.get_all | if data can't found in cache then it will be fetched from db,
parsed and stored to cache for each lang_code.
:param cat: cat of catalog data
:return: | zengine/lib/catalog_data.py | def get_all(self, cat):
"""
if data can't found in cache then it will be fetched from db,
parsed and stored to cache for each lang_code.
:param cat: cat of catalog data
:return:
"""
return self._get_from_local_cache(cat) or self._get_from_cache(cat) or self._get... | def get_all(self, cat):
"""
if data can't found in cache then it will be fetched from db,
parsed and stored to cache for each lang_code.
:param cat: cat of catalog data
:return:
"""
return self._get_from_local_cache(cat) or self._get_from_cache(cat) or self._get... | [
"if",
"data",
"can",
"t",
"found",
"in",
"cache",
"then",
"it",
"will",
"be",
"fetched",
"from",
"db",
"parsed",
"and",
"stored",
"to",
"cache",
"for",
"each",
"lang_code",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/catalog_data.py#L58-L66 | [
"def",
"get_all",
"(",
"self",
",",
"cat",
")",
":",
"return",
"self",
".",
"_get_from_local_cache",
"(",
"cat",
")",
"or",
"self",
".",
"_get_from_cache",
"(",
"cat",
")",
"or",
"self",
".",
"_get_from_db",
"(",
"cat",
")"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | CatalogData._fill_get_item_cache | get from redis, cache locally then return
:param catalog: catalog name
:param key:
:return: | zengine/lib/catalog_data.py | def _fill_get_item_cache(self, catalog, key):
"""
get from redis, cache locally then return
:param catalog: catalog name
:param key:
:return:
"""
lang = self._get_lang()
keylist = self.get_all(catalog)
self.ITEM_CACHE[lang][catalog] = dict([(i['va... | def _fill_get_item_cache(self, catalog, key):
"""
get from redis, cache locally then return
:param catalog: catalog name
:param key:
:return:
"""
lang = self._get_lang()
keylist = self.get_all(catalog)
self.ITEM_CACHE[lang][catalog] = dict([(i['va... | [
"get",
"from",
"redis",
"cache",
"locally",
"then",
"return"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/lib/catalog_data.py#L88-L99 | [
"def",
"_fill_get_item_cache",
"(",
"self",
",",
"catalog",
",",
"key",
")",
":",
"lang",
"=",
"self",
".",
"_get_lang",
"(",
")",
"keylist",
"=",
"self",
".",
"get_all",
"(",
"catalog",
")",
"self",
".",
"ITEM_CACHE",
"[",
"lang",
"]",
"[",
"catalog",... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Application.run | Utility method to quickly get a server up and running.
:param debug: turns on Werkzeug debugger, code reloading, and full
logging.
:param validate_requests: whether or not to ensure that requests are
sent by Amazon. This can be usefulfor manually testing the server. | alexandra/app.py | def run(self, host, port, debug=True, validate_requests=True):
"""Utility method to quickly get a server up and running.
:param debug: turns on Werkzeug debugger, code reloading, and full
logging.
:param validate_requests: whether or not to ensure that requests are
sent ... | def run(self, host, port, debug=True, validate_requests=True):
"""Utility method to quickly get a server up and running.
:param debug: turns on Werkzeug debugger, code reloading, and full
logging.
:param validate_requests: whether or not to ensure that requests are
sent ... | [
"Utility",
"method",
"to",
"quickly",
"get",
"a",
"server",
"up",
"and",
"running",
"."
] | erik/alexandra | python | https://github.com/erik/alexandra/blob/8bea94efa1af465254a553dc4dfea3fa552b18da/alexandra/app.py#L26-L40 | [
"def",
"run",
"(",
"self",
",",
"host",
",",
"port",
",",
"debug",
"=",
"True",
",",
"validate_requests",
"=",
"True",
")",
":",
"if",
"debug",
":",
"# Turn on all alexandra log output",
"logging",
".",
"basicConfig",
"(",
"level",
"=",
"logging",
".",
"DE... | 8bea94efa1af465254a553dc4dfea3fa552b18da |
train | Application.dispatch_request | Given a parsed JSON request object, call the correct Intent, Launch,
or SessionEnded function.
This function is called after request parsing and validaion and will
raise a `ValueError` if an unknown request type comes in.
:param body: JSON object loaded from incoming request's POST dat... | alexandra/app.py | def dispatch_request(self, body):
"""Given a parsed JSON request object, call the correct Intent, Launch,
or SessionEnded function.
This function is called after request parsing and validaion and will
raise a `ValueError` if an unknown request type comes in.
:param body: JSON o... | def dispatch_request(self, body):
"""Given a parsed JSON request object, call the correct Intent, Launch,
or SessionEnded function.
This function is called after request parsing and validaion and will
raise a `ValueError` if an unknown request type comes in.
:param body: JSON o... | [
"Given",
"a",
"parsed",
"JSON",
"request",
"object",
"call",
"the",
"correct",
"Intent",
"Launch",
"or",
"SessionEnded",
"function",
"."
] | erik/alexandra | python | https://github.com/erik/alexandra/blob/8bea94efa1af465254a553dc4dfea3fa552b18da/alexandra/app.py#L42-L81 | [
"def",
"dispatch_request",
"(",
"self",
",",
"body",
")",
":",
"req_type",
"=",
"body",
".",
"get",
"(",
"'request'",
",",
"{",
"}",
")",
".",
"get",
"(",
"'type'",
")",
"session_obj",
"=",
"body",
".",
"get",
"(",
"'session'",
")",
"session",
"=",
... | 8bea94efa1af465254a553dc4dfea3fa552b18da |
train | Application.intent | Decorator to register a handler for the given intent.
The decorated function can either take 0 or 2 arguments. If two are
specified, it will be provided a dictionary of `{slot_name: value}` and
a :py:class:`alexandra.session.Session` instance.
If no session was provided in the request,... | alexandra/app.py | def intent(self, intent_name):
"""Decorator to register a handler for the given intent.
The decorated function can either take 0 or 2 arguments. If two are
specified, it will be provided a dictionary of `{slot_name: value}` and
a :py:class:`alexandra.session.Session` instance.
... | def intent(self, intent_name):
"""Decorator to register a handler for the given intent.
The decorated function can either take 0 or 2 arguments. If two are
specified, it will be provided a dictionary of `{slot_name: value}` and
a :py:class:`alexandra.session.Session` instance.
... | [
"Decorator",
"to",
"register",
"a",
"handler",
"for",
"the",
"given",
"intent",
"."
] | erik/alexandra | python | https://github.com/erik/alexandra/blob/8bea94efa1af465254a553dc4dfea3fa552b18da/alexandra/app.py#L96-L125 | [
"def",
"intent",
"(",
"self",
",",
"intent_name",
")",
":",
"# nested decorator so we can have params.",
"def",
"_decorator",
"(",
"func",
")",
":",
"arity",
"=",
"func",
".",
"__code__",
".",
"co_argcount",
"if",
"arity",
"not",
"in",
"[",
"0",
",",
"2",
... | 8bea94efa1af465254a553dc4dfea3fa552b18da |
train | BaseUser.set_password | Kullanıcı şifresini encrypt ederek set eder.
Args:
raw_password (str) | zengine/messaging/lib.py | def set_password(self, raw_password):
"""
Kullanıcı şifresini encrypt ederek set eder.
Args:
raw_password (str)
"""
self.password = pbkdf2_sha512.encrypt(raw_password, rounds=10000,
salt_size=10) | def set_password(self, raw_password):
"""
Kullanıcı şifresini encrypt ederek set eder.
Args:
raw_password (str)
"""
self.password = pbkdf2_sha512.encrypt(raw_password, rounds=10000,
salt_size=10) | [
"Kullanıcı",
"şifresini",
"encrypt",
"ederek",
"set",
"eder",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/lib.py#L56-L64 | [
"def",
"set_password",
"(",
"self",
",",
"raw_password",
")",
":",
"self",
".",
"password",
"=",
"pbkdf2_sha512",
".",
"encrypt",
"(",
"raw_password",
",",
"rounds",
"=",
"10000",
",",
"salt_size",
"=",
"10",
")"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | BaseUser.encrypt_password | encrypt password if not already encrypted | zengine/messaging/lib.py | def encrypt_password(self):
""" encrypt password if not already encrypted """
if self.password and not self.password.startswith('$pbkdf2'):
self.set_password(self.password) | def encrypt_password(self):
""" encrypt password if not already encrypted """
if self.password and not self.password.startswith('$pbkdf2'):
self.set_password(self.password) | [
"encrypt",
"password",
"if",
"not",
"already",
"encrypted"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/lib.py#L89-L92 | [
"def",
"encrypt_password",
"(",
"self",
")",
":",
"if",
"self",
".",
"password",
"and",
"not",
"self",
".",
"password",
".",
"startswith",
"(",
"'$pbkdf2'",
")",
":",
"self",
".",
"set_password",
"(",
"self",
".",
"password",
")"
] | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | BaseUser.send_notification | sends message to users private mq exchange
Args:
title:
message:
sender:
url:
typ: | zengine/messaging/lib.py | def send_notification(self, title, message, typ=1, url=None, sender=None):
"""
sends message to users private mq exchange
Args:
title:
message:
sender:
url:
typ:
"""
self.created_channels.channel.add_message(
... | def send_notification(self, title, message, typ=1, url=None, sender=None):
"""
sends message to users private mq exchange
Args:
title:
message:
sender:
url:
typ:
"""
self.created_channels.channel.add_message(
... | [
"sends",
"message",
"to",
"users",
"private",
"mq",
"exchange",
"Args",
":",
"title",
":",
"message",
":",
"sender",
":",
"url",
":",
"typ",
":"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/lib.py#L161-L179 | [
"def",
"send_notification",
"(",
"self",
",",
"title",
",",
"message",
",",
"typ",
"=",
"1",
",",
"url",
"=",
"None",
",",
"sender",
"=",
"None",
")",
":",
"self",
".",
"created_channels",
".",
"channel",
".",
"add_message",
"(",
"channel_key",
"=",
"s... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | BaseUser.send_client_cmd | Send arbitrary cmd and data to client
if queue name passed by "via_queue" parameter,
that queue will be used instead of users private exchange.
Args:
data: dict
cmd: string
via_queue: queue name, | zengine/messaging/lib.py | def send_client_cmd(self, data, cmd=None, via_queue=None):
"""
Send arbitrary cmd and data to client
if queue name passed by "via_queue" parameter,
that queue will be used instead of users private exchange.
Args:
data: dict
cmd: string
via_que... | def send_client_cmd(self, data, cmd=None, via_queue=None):
"""
Send arbitrary cmd and data to client
if queue name passed by "via_queue" parameter,
that queue will be used instead of users private exchange.
Args:
data: dict
cmd: string
via_que... | [
"Send",
"arbitrary",
"cmd",
"and",
"data",
"to",
"client"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/messaging/lib.py#L181-L202 | [
"def",
"send_client_cmd",
"(",
"self",
",",
"data",
",",
"cmd",
"=",
"None",
",",
"via_queue",
"=",
"None",
")",
":",
"mq_channel",
"=",
"self",
".",
"_connect_mq",
"(",
")",
"if",
"cmd",
":",
"data",
"[",
"'cmd'",
"]",
"=",
"cmd",
"if",
"via_queue",... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | RDFread.seek | shifts on a given number of record in the original file
:param offset: number of record | CGRtools/files/RDFrw.py | def seek(self, offset):
"""
shifts on a given number of record in the original file
:param offset: number of record
"""
if self._shifts:
if 0 <= offset < len(self._shifts):
current_pos = self._file.tell()
new_pos = self._shifts[offset]
... | def seek(self, offset):
"""
shifts on a given number of record in the original file
:param offset: number of record
"""
if self._shifts:
if 0 <= offset < len(self._shifts):
current_pos = self._file.tell()
new_pos = self._shifts[offset]
... | [
"shifts",
"on",
"a",
"given",
"number",
"of",
"record",
"in",
"the",
"original",
"file",
":",
"param",
"offset",
":",
"number",
"of",
"record"
] | cimm-kzn/CGRtools | python | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/files/RDFrw.py#L68-L94 | [
"def",
"seek",
"(",
"self",
",",
"offset",
")",
":",
"if",
"self",
".",
"_shifts",
":",
"if",
"0",
"<=",
"offset",
"<",
"len",
"(",
"self",
".",
"_shifts",
")",
":",
"current_pos",
"=",
"self",
".",
"_file",
".",
"tell",
"(",
")",
"new_pos",
"=",... | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 |
train | RDFread.tell | :return: number of records processed from the original file | CGRtools/files/RDFrw.py | def tell(self):
"""
:return: number of records processed from the original file
"""
if self._shifts:
t = self._file.tell()
if t == self._shifts[0]:
return 0
elif t == self._shifts[-1]:
return len(self._shifts) - 1
... | def tell(self):
"""
:return: number of records processed from the original file
"""
if self._shifts:
t = self._file.tell()
if t == self._shifts[0]:
return 0
elif t == self._shifts[-1]:
return len(self._shifts) - 1
... | [
":",
"return",
":",
"number",
"of",
"records",
"processed",
"from",
"the",
"original",
"file"
] | cimm-kzn/CGRtools | python | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/files/RDFrw.py#L96-L110 | [
"def",
"tell",
"(",
"self",
")",
":",
"if",
"self",
".",
"_shifts",
":",
"t",
"=",
"self",
".",
"_file",
".",
"tell",
"(",
")",
"if",
"t",
"==",
"self",
".",
"_shifts",
"[",
"0",
"]",
":",
"return",
"0",
"elif",
"t",
"==",
"self",
".",
"_shif... | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 |
train | TaskManagerActionsView.assign_yourself | Assigning the workflow to itself.
The selected job is checked to see if there is an assigned role.
If it does not have a role assigned to it, it takes the job to itself
and displays a message that the process is successful.
If there is a role assigned to it, it does not d... | zengine/views/task_manager_actions.py | def assign_yourself(self):
"""
Assigning the workflow to itself.
The selected job is checked to see if there is an assigned role.
If it does not have a role assigned to it, it takes the job to itself
and displays a message that the process is successful.
... | def assign_yourself(self):
"""
Assigning the workflow to itself.
The selected job is checked to see if there is an assigned role.
If it does not have a role assigned to it, it takes the job to itself
and displays a message that the process is successful.
... | [
"Assigning",
"the",
"workflow",
"to",
"itself",
".",
"The",
"selected",
"job",
"is",
"checked",
"to",
"see",
"if",
"there",
"is",
"an",
"assigned",
"role",
".",
"If",
"it",
"does",
"not",
"have",
"a",
"role",
"assigned",
"to",
"it",
"it",
"takes",
"the... | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/task_manager_actions.py#L29-L60 | [
"def",
"assign_yourself",
"(",
"self",
")",
":",
"task_invitation",
"=",
"TaskInvitation",
".",
"objects",
".",
"get",
"(",
"self",
".",
"task_invitation_key",
")",
"wfi",
"=",
"task_invitation",
".",
"instance",
"if",
"not",
"wfi",
".",
"current_actor",
".",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | TaskManagerActionsView.select_role | The workflow method to be assigned to the person with the same role and unit as the user.
.. code-block:: python
# request:
{
'task_inv_key': string,
} | zengine/views/task_manager_actions.py | def select_role(self):
"""
The workflow method to be assigned to the person with the same role and unit as the user.
.. code-block:: python
# request:
{
'task_inv_key': string,
}
"""
roles = [(m.key,... | def select_role(self):
"""
The workflow method to be assigned to the person with the same role and unit as the user.
.. code-block:: python
# request:
{
'task_inv_key': string,
}
"""
roles = [(m.key,... | [
"The",
"workflow",
"method",
"to",
"be",
"assigned",
"to",
"the",
"person",
"with",
"the",
"same",
"role",
"and",
"unit",
"as",
"the",
"user",
".",
"..",
"code",
"-",
"block",
"::",
"python"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/task_manager_actions.py#L65-L90 | [
"def",
"select_role",
"(",
"self",
")",
":",
"roles",
"=",
"[",
"(",
"m",
".",
"key",
",",
"m",
".",
"__unicode__",
"(",
")",
")",
"for",
"m",
"in",
"RoleModel",
".",
"objects",
".",
"filter",
"(",
"abstract_role",
"=",
"self",
".",
"current",
".",... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | TaskManagerActionsView.send_workflow | With the workflow instance and the task invitation is assigned a role. | zengine/views/task_manager_actions.py | def send_workflow(self):
"""
With the workflow instance and the task invitation is assigned a role.
"""
task_invitation = TaskInvitation.objects.get(self.task_invitation_key)
wfi = task_invitation.instance
select_role = self.input['form']['select_role']
if wfi.cur... | def send_workflow(self):
"""
With the workflow instance and the task invitation is assigned a role.
"""
task_invitation = TaskInvitation.objects.get(self.task_invitation_key)
wfi = task_invitation.instance
select_role = self.input['form']['select_role']
if wfi.cur... | [
"With",
"the",
"workflow",
"instance",
"and",
"the",
"task",
"invitation",
"is",
"assigned",
"a",
"role",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/task_manager_actions.py#L92-L112 | [
"def",
"send_workflow",
"(",
"self",
")",
":",
"task_invitation",
"=",
"TaskInvitation",
".",
"objects",
".",
"get",
"(",
"self",
".",
"task_invitation_key",
")",
"wfi",
"=",
"task_invitation",
".",
"instance",
"select_role",
"=",
"self",
".",
"input",
"[",
... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | TaskManagerActionsView.select_postponed_date | The time intervals at which the workflow is to be extended are determined.
.. code-block:: python
# request:
{
'task_inv_key': string,
} | zengine/views/task_manager_actions.py | def select_postponed_date(self):
"""
The time intervals at which the workflow is to be extended are determined.
.. code-block:: python
# request:
{
'task_inv_key': string,
}
"""
_form = forms.Jso... | def select_postponed_date(self):
"""
The time intervals at which the workflow is to be extended are determined.
.. code-block:: python
# request:
{
'task_inv_key': string,
}
"""
_form = forms.Jso... | [
"The",
"time",
"intervals",
"at",
"which",
"the",
"workflow",
"is",
"to",
"be",
"extended",
"are",
"determined",
".",
"..",
"code",
"-",
"block",
"::",
"python"
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/task_manager_actions.py#L117-L133 | [
"def",
"select_postponed_date",
"(",
"self",
")",
":",
"_form",
"=",
"forms",
".",
"JsonForm",
"(",
"title",
"=",
"\"Postponed Workflow\"",
")",
"_form",
".",
"start_date",
"=",
"fields",
".",
"DateTime",
"(",
"\"Start Date\"",
")",
"_form",
".",
"finish_date"... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | TaskManagerActionsView.save_date | Invitations with the same workflow status are deleted.
Workflow instance and invitation roles change. | zengine/views/task_manager_actions.py | def save_date(self):
"""
Invitations with the same workflow status are deleted.
Workflow instance and invitation roles change.
"""
task_invitation = TaskInvitation.objects.get(self.task_invitation_key)
wfi = task_invitation.instance
if wfi.current_actor.e... | def save_date(self):
"""
Invitations with the same workflow status are deleted.
Workflow instance and invitation roles change.
"""
task_invitation = TaskInvitation.objects.get(self.task_invitation_key)
wfi = task_invitation.instance
if wfi.current_actor.e... | [
"Invitations",
"with",
"the",
"same",
"workflow",
"status",
"are",
"deleted",
".",
"Workflow",
"instance",
"and",
"invitation",
"roles",
"change",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/task_manager_actions.py#L135-L162 | [
"def",
"save_date",
"(",
"self",
")",
":",
"task_invitation",
"=",
"TaskInvitation",
".",
"objects",
".",
"get",
"(",
"self",
".",
"task_invitation_key",
")",
"wfi",
"=",
"task_invitation",
".",
"instance",
"if",
"wfi",
".",
"current_actor",
".",
"exist",
"a... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | TaskManagerActionsView.suspend | If there is a role assigned to the workflow and
it is the same as the user, it can drop the workflow.
If it does not exist, it can not do anything.
.. code-block:: python
# request:
{
'task_inv_key': string,
} | zengine/views/task_manager_actions.py | def suspend(self):
"""
If there is a role assigned to the workflow and
it is the same as the user, it can drop the workflow.
If it does not exist, it can not do anything.
.. code-block:: python
# request:
{
'task_inv_ke... | def suspend(self):
"""
If there is a role assigned to the workflow and
it is the same as the user, it can drop the workflow.
If it does not exist, it can not do anything.
.. code-block:: python
# request:
{
'task_inv_ke... | [
"If",
"there",
"is",
"a",
"role",
"assigned",
"to",
"the",
"workflow",
"and",
"it",
"is",
"the",
"same",
"as",
"the",
"user",
"it",
"can",
"drop",
"the",
"workflow",
".",
"If",
"it",
"does",
"not",
"exist",
"it",
"can",
"not",
"do",
"anything",
"."
] | zetaops/zengine | python | https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/views/task_manager_actions.py#L167-L200 | [
"def",
"suspend",
"(",
"self",
")",
":",
"task_invitation",
"=",
"TaskInvitation",
".",
"objects",
".",
"get",
"(",
"self",
".",
"task_invitation_key",
")",
"wfi",
"=",
"task_invitation",
".",
"instance",
"if",
"wfi",
".",
"current_actor",
".",
"exist",
"and... | b5bc32d3b37bca799f8985be916f04528ac79e4a |
train | Pawn.on_home_row | Finds out if the piece is on the home row.
:return: bool for whether piece is on home row or not | chess_py/pieces/pawn.py | def on_home_row(self, location=None):
"""
Finds out if the piece is on the home row.
:return: bool for whether piece is on home row or not
"""
location = location or self.location
return (self.color == color.white and location.rank == 1) or \
(self.color =... | def on_home_row(self, location=None):
"""
Finds out if the piece is on the home row.
:return: bool for whether piece is on home row or not
"""
location = location or self.location
return (self.color == color.white and location.rank == 1) or \
(self.color =... | [
"Finds",
"out",
"if",
"the",
"piece",
"is",
"on",
"the",
"home",
"row",
"."
] | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/pawn.py#L51-L59 | [
"def",
"on_home_row",
"(",
"self",
",",
"location",
"=",
"None",
")",
":",
"location",
"=",
"location",
"or",
"self",
".",
"location",
"return",
"(",
"self",
".",
"color",
"==",
"color",
".",
"white",
"and",
"location",
".",
"rank",
"==",
"1",
")",
"... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | Pawn.would_move_be_promotion | Finds if move from current get_location would result in promotion
:type: location: Location
:rtype: bool | chess_py/pieces/pawn.py | def would_move_be_promotion(self, location=None):
"""
Finds if move from current get_location would result in promotion
:type: location: Location
:rtype: bool
"""
location = location or self.location
return (location.rank == 1 and self.color == color.black) or \
... | def would_move_be_promotion(self, location=None):
"""
Finds if move from current get_location would result in promotion
:type: location: Location
:rtype: bool
"""
location = location or self.location
return (location.rank == 1 and self.color == color.black) or \
... | [
"Finds",
"if",
"move",
"from",
"current",
"get_location",
"would",
"result",
"in",
"promotion"
] | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/pawn.py#L61-L70 | [
"def",
"would_move_be_promotion",
"(",
"self",
",",
"location",
"=",
"None",
")",
":",
"location",
"=",
"location",
"or",
"self",
".",
"location",
"return",
"(",
"location",
".",
"rank",
"==",
"1",
"and",
"self",
".",
"color",
"==",
"color",
".",
"black"... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | Pawn.square_in_front | Finds square directly in front of Pawn
:type: location: Location
:rtype: Location | chess_py/pieces/pawn.py | def square_in_front(self, location=None):
"""
Finds square directly in front of Pawn
:type: location: Location
:rtype: Location
"""
location = location or self.location
return location.shift_up() if self.color == color.white else location.shift_down() | def square_in_front(self, location=None):
"""
Finds square directly in front of Pawn
:type: location: Location
:rtype: Location
"""
location = location or self.location
return location.shift_up() if self.color == color.white else location.shift_down() | [
"Finds",
"square",
"directly",
"in",
"front",
"of",
"Pawn"
] | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/pawn.py#L72-L80 | [
"def",
"square_in_front",
"(",
"self",
",",
"location",
"=",
"None",
")",
":",
"location",
"=",
"location",
"or",
"self",
".",
"location",
"return",
"location",
".",
"shift_up",
"(",
")",
"if",
"self",
".",
"color",
"==",
"color",
".",
"white",
"else",
... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | Pawn.forward_moves | Finds possible moves one step and two steps in front
of Pawn.
:type: position: Board
:rtype: list | chess_py/pieces/pawn.py | def forward_moves(self, position):
"""
Finds possible moves one step and two steps in front
of Pawn.
:type: position: Board
:rtype: list
"""
if position.is_square_empty(self.square_in_front(self.location)):
"""
If square in front is empty ... | def forward_moves(self, position):
"""
Finds possible moves one step and two steps in front
of Pawn.
:type: position: Board
:rtype: list
"""
if position.is_square_empty(self.square_in_front(self.location)):
"""
If square in front is empty ... | [
"Finds",
"possible",
"moves",
"one",
"step",
"and",
"two",
"steps",
"in",
"front",
"of",
"Pawn",
"."
] | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/pawn.py#L105-L133 | [
"def",
"forward_moves",
"(",
"self",
",",
"position",
")",
":",
"if",
"position",
".",
"is_square_empty",
"(",
"self",
".",
"square_in_front",
"(",
"self",
".",
"location",
")",
")",
":",
"\"\"\"\n If square in front is empty add the move\n \"\"\""... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | Pawn._one_diagonal_capture_square | Adds specified diagonal as a capture move if it is one | chess_py/pieces/pawn.py | def _one_diagonal_capture_square(self, capture_square, position):
"""
Adds specified diagonal as a capture move if it is one
"""
if self.contains_opposite_color_piece(capture_square, position):
if self.would_move_be_promotion():
for move in self.create_promot... | def _one_diagonal_capture_square(self, capture_square, position):
"""
Adds specified diagonal as a capture move if it is one
"""
if self.contains_opposite_color_piece(capture_square, position):
if self.would_move_be_promotion():
for move in self.create_promot... | [
"Adds",
"specified",
"diagonal",
"as",
"a",
"capture",
"move",
"if",
"it",
"is",
"one"
] | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/pawn.py#L135-L148 | [
"def",
"_one_diagonal_capture_square",
"(",
"self",
",",
"capture_square",
",",
"position",
")",
":",
"if",
"self",
".",
"contains_opposite_color_piece",
"(",
"capture_square",
",",
"position",
")",
":",
"if",
"self",
".",
"would_move_be_promotion",
"(",
")",
":",... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | Pawn.capture_moves | Finds out all possible capture moves
:rtype: list | chess_py/pieces/pawn.py | def capture_moves(self, position):
"""
Finds out all possible capture moves
:rtype: list
"""
try:
right_diagonal = self.square_in_front(self.location.shift_right())
for move in self._one_diagonal_capture_square(right_diagonal, position):
y... | def capture_moves(self, position):
"""
Finds out all possible capture moves
:rtype: list
"""
try:
right_diagonal = self.square_in_front(self.location.shift_right())
for move in self._one_diagonal_capture_square(right_diagonal, position):
y... | [
"Finds",
"out",
"all",
"possible",
"capture",
"moves"
] | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/pawn.py#L150-L168 | [
"def",
"capture_moves",
"(",
"self",
",",
"position",
")",
":",
"try",
":",
"right_diagonal",
"=",
"self",
".",
"square_in_front",
"(",
"self",
".",
"location",
".",
"shift_right",
"(",
")",
")",
"for",
"move",
"in",
"self",
".",
"_one_diagonal_capture_squar... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | Pawn.on_en_passant_valid_location | Finds out if pawn is on enemy center rank.
:rtype: bool | chess_py/pieces/pawn.py | def on_en_passant_valid_location(self):
"""
Finds out if pawn is on enemy center rank.
:rtype: bool
"""
return (self.color == color.white and self.location.rank == 4) or \
(self.color == color.black and self.location.rank == 3) | def on_en_passant_valid_location(self):
"""
Finds out if pawn is on enemy center rank.
:rtype: bool
"""
return (self.color == color.white and self.location.rank == 4) or \
(self.color == color.black and self.location.rank == 3) | [
"Finds",
"out",
"if",
"pawn",
"is",
"on",
"enemy",
"center",
"rank",
"."
] | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/pawn.py#L170-L177 | [
"def",
"on_en_passant_valid_location",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"color",
"==",
"color",
".",
"white",
"and",
"self",
".",
"location",
".",
"rank",
"==",
"4",
")",
"or",
"(",
"self",
".",
"color",
"==",
"color",
".",
"black",
... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | Pawn._is_en_passant_valid | Finds if their opponent's pawn is next to this pawn
:rtype: bool | chess_py/pieces/pawn.py | def _is_en_passant_valid(self, opponent_pawn_location, position):
"""
Finds if their opponent's pawn is next to this pawn
:rtype: bool
"""
try:
pawn = position.piece_at_square(opponent_pawn_location)
return pawn is not None and \
isinstanc... | def _is_en_passant_valid(self, opponent_pawn_location, position):
"""
Finds if their opponent's pawn is next to this pawn
:rtype: bool
"""
try:
pawn = position.piece_at_square(opponent_pawn_location)
return pawn is not None and \
isinstanc... | [
"Finds",
"if",
"their",
"opponent",
"s",
"pawn",
"is",
"next",
"to",
"this",
"pawn"
] | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/pawn.py#L179-L192 | [
"def",
"_is_en_passant_valid",
"(",
"self",
",",
"opponent_pawn_location",
",",
"position",
")",
":",
"try",
":",
"pawn",
"=",
"position",
".",
"piece_at_square",
"(",
"opponent_pawn_location",
")",
"return",
"pawn",
"is",
"not",
"None",
"and",
"isinstance",
"("... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | Pawn.add_one_en_passant_move | Yields en_passant moves in given direction if it is legal.
:type: direction: function
:type: position: Board
:rtype: gen | chess_py/pieces/pawn.py | def add_one_en_passant_move(self, direction, position):
"""
Yields en_passant moves in given direction if it is legal.
:type: direction: function
:type: position: Board
:rtype: gen
"""
try:
if self._is_en_passant_valid(direction(self.location), positi... | def add_one_en_passant_move(self, direction, position):
"""
Yields en_passant moves in given direction if it is legal.
:type: direction: function
:type: position: Board
:rtype: gen
"""
try:
if self._is_en_passant_valid(direction(self.location), positi... | [
"Yields",
"en_passant",
"moves",
"in",
"given",
"direction",
"if",
"it",
"is",
"legal",
"."
] | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/pawn.py#L194-L209 | [
"def",
"add_one_en_passant_move",
"(",
"self",
",",
"direction",
",",
"position",
")",
":",
"try",
":",
"if",
"self",
".",
"_is_en_passant_valid",
"(",
"direction",
"(",
"self",
".",
"location",
")",
",",
"position",
")",
":",
"yield",
"self",
".",
"create... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | Pawn.en_passant_moves | Finds possible en passant moves.
:rtype: list | chess_py/pieces/pawn.py | def en_passant_moves(self, position):
"""
Finds possible en passant moves.
:rtype: list
"""
# if pawn is not on a valid en passant get_location then return None
if self.on_en_passant_valid_location():
for move in itertools.chain(self.add_one_en_passant_move(... | def en_passant_moves(self, position):
"""
Finds possible en passant moves.
:rtype: list
"""
# if pawn is not on a valid en passant get_location then return None
if self.on_en_passant_valid_location():
for move in itertools.chain(self.add_one_en_passant_move(... | [
"Finds",
"possible",
"en",
"passant",
"moves",
"."
] | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/pawn.py#L211-L222 | [
"def",
"en_passant_moves",
"(",
"self",
",",
"position",
")",
":",
"# if pawn is not on a valid en passant get_location then return None",
"if",
"self",
".",
"on_en_passant_valid_location",
"(",
")",
":",
"for",
"move",
"in",
"itertools",
".",
"chain",
"(",
"self",
".... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | Pawn.possible_moves | Finds out the locations of possible moves given board.Board position.
:pre get_location is on board and piece at specified get_location on position
:type: position: Board
:rtype: list | chess_py/pieces/pawn.py | def possible_moves(self, position):
"""
Finds out the locations of possible moves given board.Board position.
:pre get_location is on board and piece at specified get_location on position
:type: position: Board
:rtype: list
"""
for move in itertools.chain(self.fo... | def possible_moves(self, position):
"""
Finds out the locations of possible moves given board.Board position.
:pre get_location is on board and piece at specified get_location on position
:type: position: Board
:rtype: list
"""
for move in itertools.chain(self.fo... | [
"Finds",
"out",
"the",
"locations",
"of",
"possible",
"moves",
"given",
"board",
".",
"Board",
"position",
".",
":",
"pre",
"get_location",
"is",
"on",
"board",
"and",
"piece",
"at",
"specified",
"get_location",
"on",
"position"
] | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/pieces/pawn.py#L224-L235 | [
"def",
"possible_moves",
"(",
"self",
",",
"position",
")",
":",
"for",
"move",
"in",
"itertools",
".",
"chain",
"(",
"self",
".",
"forward_moves",
"(",
"position",
")",
",",
"self",
".",
"capture_moves",
"(",
"position",
")",
",",
"self",
".",
"en_passa... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | main | Main method | main.py | def main():
"""
Main method
"""
print("Creating a new game...")
new_game = Game(Human(color.white), Human(color.black))
result = new_game.play()
print("Result is ", result) | def main():
"""
Main method
"""
print("Creating a new game...")
new_game = Game(Human(color.white), Human(color.black))
result = new_game.play()
print("Result is ", result) | [
"Main",
"method"
] | LordDarkula/chess_py | python | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/main.py#L25-L34 | [
"def",
"main",
"(",
")",
":",
"print",
"(",
"\"Creating a new game...\"",
")",
"new_game",
"=",
"Game",
"(",
"Human",
"(",
"color",
".",
"white",
")",
",",
"Human",
"(",
"color",
".",
"black",
")",
")",
"result",
"=",
"new_game",
".",
"play",
"(",
")... | 14bebc2f8c49ae25c59375cc83d0b38d8ff7281d |
train | respond | Build a dict containing a valid response to an Alexa request.
If speech output is desired, either of `text` or `ssml` should
be specified.
:param text: Plain text speech output to be said by Alexa device.
:param ssml: Speech output in SSML form.
:param attributes: Dictionary of attributes to store... | alexandra/util.py | def respond(text=None, ssml=None, attributes=None, reprompt_text=None,
reprompt_ssml=None, end_session=True):
""" Build a dict containing a valid response to an Alexa request.
If speech output is desired, either of `text` or `ssml` should
be specified.
:param text: Plain text speech output... | def respond(text=None, ssml=None, attributes=None, reprompt_text=None,
reprompt_ssml=None, end_session=True):
""" Build a dict containing a valid response to an Alexa request.
If speech output is desired, either of `text` or `ssml` should
be specified.
:param text: Plain text speech output... | [
"Build",
"a",
"dict",
"containing",
"a",
"valid",
"response",
"to",
"an",
"Alexa",
"request",
"."
] | erik/alexandra | python | https://github.com/erik/alexandra/blob/8bea94efa1af465254a553dc4dfea3fa552b18da/alexandra/util.py#L25-L63 | [
"def",
"respond",
"(",
"text",
"=",
"None",
",",
"ssml",
"=",
"None",
",",
"attributes",
"=",
"None",
",",
"reprompt_text",
"=",
"None",
",",
"reprompt_ssml",
"=",
"None",
",",
"end_session",
"=",
"True",
")",
":",
"obj",
"=",
"{",
"'version'",
":",
... | 8bea94efa1af465254a553dc4dfea3fa552b18da |
train | reprompt | Convenience method to save a little bit of typing for the common case of
reprompting the user. Simply calls :py:func:`alexandra.util.respond` with
the given arguments and holds the session open.
One of either the `text` or `ssml` should be provided if any
speech output is desired.
:param text: Pla... | alexandra/util.py | def reprompt(text=None, ssml=None, attributes=None):
"""Convenience method to save a little bit of typing for the common case of
reprompting the user. Simply calls :py:func:`alexandra.util.respond` with
the given arguments and holds the session open.
One of either the `text` or `ssml` should be provide... | def reprompt(text=None, ssml=None, attributes=None):
"""Convenience method to save a little bit of typing for the common case of
reprompting the user. Simply calls :py:func:`alexandra.util.respond` with
the given arguments and holds the session open.
One of either the `text` or `ssml` should be provide... | [
"Convenience",
"method",
"to",
"save",
"a",
"little",
"bit",
"of",
"typing",
"for",
"the",
"common",
"case",
"of",
"reprompting",
"the",
"user",
".",
"Simply",
"calls",
":",
"py",
":",
"func",
":",
"alexandra",
".",
"util",
".",
"respond",
"with",
"the",... | erik/alexandra | python | https://github.com/erik/alexandra/blob/8bea94efa1af465254a553dc4dfea3fa552b18da/alexandra/util.py#L66-L84 | [
"def",
"reprompt",
"(",
"text",
"=",
"None",
",",
"ssml",
"=",
"None",
",",
"attributes",
"=",
"None",
")",
":",
"return",
"respond",
"(",
"reprompt_text",
"=",
"text",
",",
"reprompt_ssml",
"=",
"ssml",
",",
"attributes",
"=",
"attributes",
",",
"end_se... | 8bea94efa1af465254a553dc4dfea3fa552b18da |
train | validate_request_timestamp | Ensure the request's timestamp doesn't fall outside of the
app's specified tolerance.
Returns True if this request is valid, False otherwise.
:param req_body: JSON object parsed out of the raw POST data of a request.
:param max_diff: Maximum allowable difference in seconds between request
time... | alexandra/util.py | def validate_request_timestamp(req_body, max_diff=150):
"""Ensure the request's timestamp doesn't fall outside of the
app's specified tolerance.
Returns True if this request is valid, False otherwise.
:param req_body: JSON object parsed out of the raw POST data of a request.
:param max_diff: Maxim... | def validate_request_timestamp(req_body, max_diff=150):
"""Ensure the request's timestamp doesn't fall outside of the
app's specified tolerance.
Returns True if this request is valid, False otherwise.
:param req_body: JSON object parsed out of the raw POST data of a request.
:param max_diff: Maxim... | [
"Ensure",
"the",
"request",
"s",
"timestamp",
"doesn",
"t",
"fall",
"outside",
"of",
"the",
"app",
"s",
"specified",
"tolerance",
"."
] | erik/alexandra | python | https://github.com/erik/alexandra/blob/8bea94efa1af465254a553dc4dfea3fa552b18da/alexandra/util.py#L87-L112 | [
"def",
"validate_request_timestamp",
"(",
"req_body",
",",
"max_diff",
"=",
"150",
")",
":",
"time_str",
"=",
"req_body",
".",
"get",
"(",
"'request'",
",",
"{",
"}",
")",
".",
"get",
"(",
"'timestamp'",
")",
"if",
"not",
"time_str",
":",
"log",
".",
"... | 8bea94efa1af465254a553dc4dfea3fa552b18da |
train | validate_request_certificate | Ensure that the certificate and signature specified in the
request headers are truely from Amazon and correctly verify.
Returns True if certificate verification succeeds, False otherwise.
:param headers: Dictionary (or sufficiently dictionary-like) map of request
headers.
:param data: Raw POST... | alexandra/util.py | def validate_request_certificate(headers, data):
"""Ensure that the certificate and signature specified in the
request headers are truely from Amazon and correctly verify.
Returns True if certificate verification succeeds, False otherwise.
:param headers: Dictionary (or sufficiently dictionary-like) m... | def validate_request_certificate(headers, data):
"""Ensure that the certificate and signature specified in the
request headers are truely from Amazon and correctly verify.
Returns True if certificate verification succeeds, False otherwise.
:param headers: Dictionary (or sufficiently dictionary-like) m... | [
"Ensure",
"that",
"the",
"certificate",
"and",
"signature",
"specified",
"in",
"the",
"request",
"headers",
"are",
"truely",
"from",
"Amazon",
"and",
"correctly",
"verify",
"."
] | erik/alexandra | python | https://github.com/erik/alexandra/blob/8bea94efa1af465254a553dc4dfea3fa552b18da/alexandra/util.py#L115-L146 | [
"def",
"validate_request_certificate",
"(",
"headers",
",",
"data",
")",
":",
"# Make sure we have the appropriate headers.",
"if",
"'SignatureCertChainUrl'",
"not",
"in",
"headers",
"or",
"'Signature'",
"not",
"in",
"headers",
":",
"log",
".",
"error",
"(",
"'invalid... | 8bea94efa1af465254a553dc4dfea3fa552b18da |
train | _get_certificate | Download and validate a specified Amazon PEM file. | alexandra/util.py | def _get_certificate(cert_url):
"""Download and validate a specified Amazon PEM file."""
global _cache
if cert_url in _cache:
cert = _cache[cert_url]
if cert.has_expired():
_cache = {}
else:
return cert
url = urlparse(cert_url)
host = url.netloc.lowe... | def _get_certificate(cert_url):
"""Download and validate a specified Amazon PEM file."""
global _cache
if cert_url in _cache:
cert = _cache[cert_url]
if cert.has_expired():
_cache = {}
else:
return cert
url = urlparse(cert_url)
host = url.netloc.lowe... | [
"Download",
"and",
"validate",
"a",
"specified",
"Amazon",
"PEM",
"file",
"."
] | erik/alexandra | python | https://github.com/erik/alexandra/blob/8bea94efa1af465254a553dc4dfea3fa552b18da/alexandra/util.py#L149-L183 | [
"def",
"_get_certificate",
"(",
"cert_url",
")",
":",
"global",
"_cache",
"if",
"cert_url",
"in",
"_cache",
":",
"cert",
"=",
"_cache",
"[",
"cert_url",
"]",
"if",
"cert",
".",
"has_expired",
"(",
")",
":",
"_cache",
"=",
"{",
"}",
"else",
":",
"return... | 8bea94efa1af465254a553dc4dfea3fa552b18da |
train | Version.is_processed | Check if version is already applied in the database.
:param db_versions: | marabunta/model.py | def is_processed(self, db_versions):
"""Check if version is already applied in the database.
:param db_versions:
"""
return self.number in (v.number for v in db_versions if v.date_done) | def is_processed(self, db_versions):
"""Check if version is already applied in the database.
:param db_versions:
"""
return self.number in (v.number for v in db_versions if v.date_done) | [
"Check",
"if",
"version",
"is",
"already",
"applied",
"in",
"the",
"database",
"."
] | camptocamp/marabunta | python | https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/model.py#L123-L128 | [
"def",
"is_processed",
"(",
"self",
",",
"db_versions",
")",
":",
"return",
"self",
".",
"number",
"in",
"(",
"v",
".",
"number",
"for",
"v",
"in",
"db_versions",
"if",
"v",
".",
"date_done",
")"
] | ec3a7a725c7426d6ed642e0a80119b37880eb91e |
train | Version.is_noop | Check if version is a no operation version. | marabunta/model.py | def is_noop(self):
"""Check if version is a no operation version.
"""
has_operations = [mode.pre_operations or mode.post_operations
for mode in self._version_modes.values()]
has_upgrade_addons = [mode.upgrade_addons or mode.remove_addons
... | def is_noop(self):
"""Check if version is a no operation version.
"""
has_operations = [mode.pre_operations or mode.post_operations
for mode in self._version_modes.values()]
has_upgrade_addons = [mode.upgrade_addons or mode.remove_addons
... | [
"Check",
"if",
"version",
"is",
"a",
"no",
"operation",
"version",
"."
] | camptocamp/marabunta | python | https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/model.py#L130-L138 | [
"def",
"is_noop",
"(",
"self",
")",
":",
"has_operations",
"=",
"[",
"mode",
".",
"pre_operations",
"or",
"mode",
".",
"post_operations",
"for",
"mode",
"in",
"self",
".",
"_version_modes",
".",
"values",
"(",
")",
"]",
"has_upgrade_addons",
"=",
"[",
"mod... | ec3a7a725c7426d6ed642e0a80119b37880eb91e |
train | Version._get_version_mode | Return a VersionMode for a mode name.
When the mode is None, we are working with the 'base' mode. | marabunta/model.py | def _get_version_mode(self, mode=None):
"""Return a VersionMode for a mode name.
When the mode is None, we are working with the 'base' mode.
"""
version_mode = self._version_modes.get(mode)
if not version_mode:
version_mode = self._version_modes[mode] = VersionMode(n... | def _get_version_mode(self, mode=None):
"""Return a VersionMode for a mode name.
When the mode is None, we are working with the 'base' mode.
"""
version_mode = self._version_modes.get(mode)
if not version_mode:
version_mode = self._version_modes[mode] = VersionMode(n... | [
"Return",
"a",
"VersionMode",
"for",
"a",
"mode",
"name",
"."
] | camptocamp/marabunta | python | https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/model.py#L145-L153 | [
"def",
"_get_version_mode",
"(",
"self",
",",
"mode",
"=",
"None",
")",
":",
"version_mode",
"=",
"self",
".",
"_version_modes",
".",
"get",
"(",
"mode",
")",
"if",
"not",
"version_mode",
":",
"version_mode",
"=",
"self",
".",
"_version_modes",
"[",
"mode"... | ec3a7a725c7426d6ed642e0a80119b37880eb91e |
train | Version.add_operation | Add an operation to the version
:param mode: Name of the mode in which the operation is executed
:type mode: str
:param operation_type: one of 'pre', 'post'
:type operation_type: str
:param operation: the operation to add
:type operation: :class:`marabunta.model.Operatio... | marabunta/model.py | def add_operation(self, operation_type, operation, mode=None):
"""Add an operation to the version
:param mode: Name of the mode in which the operation is executed
:type mode: str
:param operation_type: one of 'pre', 'post'
:type operation_type: str
:param operation: the ... | def add_operation(self, operation_type, operation, mode=None):
"""Add an operation to the version
:param mode: Name of the mode in which the operation is executed
:type mode: str
:param operation_type: one of 'pre', 'post'
:type operation_type: str
:param operation: the ... | [
"Add",
"an",
"operation",
"to",
"the",
"version"
] | camptocamp/marabunta | python | https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/model.py#L155-L174 | [
"def",
"add_operation",
"(",
"self",
",",
"operation_type",
",",
"operation",
",",
"mode",
"=",
"None",
")",
":",
"version_mode",
"=",
"self",
".",
"_get_version_mode",
"(",
"mode",
"=",
"mode",
")",
"if",
"operation_type",
"==",
"'pre'",
":",
"version_mode"... | ec3a7a725c7426d6ed642e0a80119b37880eb91e |
train | Version.add_backup_operation | Add a backup operation to the version.
:param backup: To either add or skip the backup
:type backup: Boolean
:param mode: Name of the mode in which the operation is executed
For now, backups are mode-independent
:type mode: String | marabunta/model.py | def add_backup_operation(self, backup, mode=None):
"""Add a backup operation to the version.
:param backup: To either add or skip the backup
:type backup: Boolean
:param mode: Name of the mode in which the operation is executed
For now, backups are mode-independent
... | def add_backup_operation(self, backup, mode=None):
"""Add a backup operation to the version.
:param backup: To either add or skip the backup
:type backup: Boolean
:param mode: Name of the mode in which the operation is executed
For now, backups are mode-independent
... | [
"Add",
"a",
"backup",
"operation",
"to",
"the",
"version",
"."
] | camptocamp/marabunta | python | https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/model.py#L176-L189 | [
"def",
"add_backup_operation",
"(",
"self",
",",
"backup",
",",
"mode",
"=",
"None",
")",
":",
"try",
":",
"if",
"self",
".",
"options",
".",
"backup",
":",
"self",
".",
"options",
".",
"backup",
".",
"ignore_if_operation",
"(",
")",
".",
"execute",
"(... | ec3a7a725c7426d6ed642e0a80119b37880eb91e |
train | Version.pre_operations | Return pre-operations only for the mode asked | marabunta/model.py | def pre_operations(self, mode=None):
""" Return pre-operations only for the mode asked """
version_mode = self._get_version_mode(mode=mode)
return version_mode.pre_operations | def pre_operations(self, mode=None):
""" Return pre-operations only for the mode asked """
version_mode = self._get_version_mode(mode=mode)
return version_mode.pre_operations | [
"Return",
"pre",
"-",
"operations",
"only",
"for",
"the",
"mode",
"asked"
] | camptocamp/marabunta | python | https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/model.py#L204-L207 | [
"def",
"pre_operations",
"(",
"self",
",",
"mode",
"=",
"None",
")",
":",
"version_mode",
"=",
"self",
".",
"_get_version_mode",
"(",
"mode",
"=",
"mode",
")",
"return",
"version_mode",
".",
"pre_operations"
] | ec3a7a725c7426d6ed642e0a80119b37880eb91e |
train | Version.post_operations | Return post-operations only for the mode asked | marabunta/model.py | def post_operations(self, mode=None):
""" Return post-operations only for the mode asked """
version_mode = self._get_version_mode(mode=mode)
return version_mode.post_operations | def post_operations(self, mode=None):
""" Return post-operations only for the mode asked """
version_mode = self._get_version_mode(mode=mode)
return version_mode.post_operations | [
"Return",
"post",
"-",
"operations",
"only",
"for",
"the",
"mode",
"asked"
] | camptocamp/marabunta | python | https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/model.py#L209-L212 | [
"def",
"post_operations",
"(",
"self",
",",
"mode",
"=",
"None",
")",
":",
"version_mode",
"=",
"self",
".",
"_get_version_mode",
"(",
"mode",
"=",
"mode",
")",
"return",
"version_mode",
".",
"post_operations"
] | ec3a7a725c7426d6ed642e0a80119b37880eb91e |
train | Version.upgrade_addons_operation | Return merged set of main addons and mode's addons | marabunta/model.py | def upgrade_addons_operation(self, addons_state, mode=None):
""" Return merged set of main addons and mode's addons """
installed = set(a.name for a in addons_state
if a.state in ('installed', 'to upgrade'))
base_mode = self._get_version_mode()
addons_list = base... | def upgrade_addons_operation(self, addons_state, mode=None):
""" Return merged set of main addons and mode's addons """
installed = set(a.name for a in addons_state
if a.state in ('installed', 'to upgrade'))
base_mode = self._get_version_mode()
addons_list = base... | [
"Return",
"merged",
"set",
"of",
"main",
"addons",
"and",
"mode",
"s",
"addons"
] | camptocamp/marabunta | python | https://github.com/camptocamp/marabunta/blob/ec3a7a725c7426d6ed642e0a80119b37880eb91e/marabunta/model.py#L214-L228 | [
"def",
"upgrade_addons_operation",
"(",
"self",
",",
"addons_state",
",",
"mode",
"=",
"None",
")",
":",
"installed",
"=",
"set",
"(",
"a",
".",
"name",
"for",
"a",
"in",
"addons_state",
"if",
"a",
".",
"state",
"in",
"(",
"'installed'",
",",
"'to upgrad... | ec3a7a725c7426d6ed642e0a80119b37880eb91e |
train | ReactionContainer.copy | get copy of object
:return: ReactionContainer | CGRtools/containers/reaction.py | def copy(self):
"""
get copy of object
:return: ReactionContainer
"""
return type(self)(reagents=[x.copy() for x in self.__reagents], meta=self.__meta.copy(),
products=[x.copy() for x in self.__products],
reactants=[x.copy() fo... | def copy(self):
"""
get copy of object
:return: ReactionContainer
"""
return type(self)(reagents=[x.copy() for x in self.__reagents], meta=self.__meta.copy(),
products=[x.copy() for x in self.__products],
reactants=[x.copy() fo... | [
"get",
"copy",
"of",
"object"
] | cimm-kzn/CGRtools | python | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/reaction.py#L135-L143 | [
"def",
"copy",
"(",
"self",
")",
":",
"return",
"type",
"(",
"self",
")",
"(",
"reagents",
"=",
"[",
"x",
".",
"copy",
"(",
")",
"for",
"x",
"in",
"self",
".",
"__reagents",
"]",
",",
"meta",
"=",
"self",
".",
"__meta",
".",
"copy",
"(",
")",
... | 15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.