repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
rhgrant10/Groupy
groupy/pagers.py
MessageList.set_next_page_params
def set_next_page_params(self): """Set the params so that the next page is fetched.""" if self.items: index = self.get_last_item_index() self.params[self.mode] = self.get_next_page_param(self.items[index])
python
def set_next_page_params(self): """Set the params so that the next page is fetched.""" if self.items: index = self.get_last_item_index() self.params[self.mode] = self.get_next_page_param(self.items[index])
[ "def", "set_next_page_params", "(", "self", ")", ":", "if", "self", ".", "items", ":", "index", "=", "self", ".", "get_last_item_index", "(", ")", "self", ".", "params", "[", "self", ".", "mode", "]", "=", "self", ".", "get_next_page_param", "(", "self",...
Set the params so that the next page is fetched.
[ "Set", "the", "params", "so", "that", "the", "next", "page", "is", "fetched", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/pagers.py#L114-L118
train
rhgrant10/Groupy
groupy/api/blocks.py
Blocks.list
def list(self): """List the users you have blocked. :return: a list of :class:`~groupy.api.blocks.Block`'s :rtype: :class:`list` """ params = {'user': self.user_id} response = self.session.get(self.url, params=params) blocks = response.data['blocks'] retu...
python
def list(self): """List the users you have blocked. :return: a list of :class:`~groupy.api.blocks.Block`'s :rtype: :class:`list` """ params = {'user': self.user_id} response = self.session.get(self.url, params=params) blocks = response.data['blocks'] retu...
[ "def", "list", "(", "self", ")", ":", "params", "=", "{", "'user'", ":", "self", ".", "user_id", "}", "response", "=", "self", ".", "session", ".", "get", "(", "self", ".", "url", ",", "params", "=", "params", ")", "blocks", "=", "response", ".", ...
List the users you have blocked. :return: a list of :class:`~groupy.api.blocks.Block`'s :rtype: :class:`list`
[ "List", "the", "users", "you", "have", "blocked", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/blocks.py#L16-L25
train
rhgrant10/Groupy
groupy/api/blocks.py
Blocks.between
def between(self, other_user_id): """Check if there is a block between you and the given user. :return: ``True`` if the given user has been blocked :rtype: bool """ params = {'user': self.user_id, 'otherUser': other_user_id} response = self.session.get(self.url, params=p...
python
def between(self, other_user_id): """Check if there is a block between you and the given user. :return: ``True`` if the given user has been blocked :rtype: bool """ params = {'user': self.user_id, 'otherUser': other_user_id} response = self.session.get(self.url, params=p...
[ "def", "between", "(", "self", ",", "other_user_id", ")", ":", "params", "=", "{", "'user'", ":", "self", ".", "user_id", ",", "'otherUser'", ":", "other_user_id", "}", "response", "=", "self", ".", "session", ".", "get", "(", "self", ".", "url", ",", ...
Check if there is a block between you and the given user. :return: ``True`` if the given user has been blocked :rtype: bool
[ "Check", "if", "there", "is", "a", "block", "between", "you", "and", "the", "given", "user", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/blocks.py#L27-L35
train
rhgrant10/Groupy
groupy/api/blocks.py
Blocks.block
def block(self, other_user_id): """Block the given user. :param str other_user_id: the ID of the user to block :return: the block created :rtype: :class:`~groupy.api.blocks.Block` """ params = {'user': self.user_id, 'otherUser': other_user_id} response = self.ses...
python
def block(self, other_user_id): """Block the given user. :param str other_user_id: the ID of the user to block :return: the block created :rtype: :class:`~groupy.api.blocks.Block` """ params = {'user': self.user_id, 'otherUser': other_user_id} response = self.ses...
[ "def", "block", "(", "self", ",", "other_user_id", ")", ":", "params", "=", "{", "'user'", ":", "self", ".", "user_id", ",", "'otherUser'", ":", "other_user_id", "}", "response", "=", "self", ".", "session", ".", "post", "(", "self", ".", "url", ",", ...
Block the given user. :param str other_user_id: the ID of the user to block :return: the block created :rtype: :class:`~groupy.api.blocks.Block`
[ "Block", "the", "given", "user", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/blocks.py#L37-L47
train
rhgrant10/Groupy
groupy/api/blocks.py
Blocks.unblock
def unblock(self, other_user_id): """Unblock the given user. :param str other_user_id: the ID of the user to unblock :return: ``True`` if successful :rtype: bool """ params = {'user': self.user_id, 'otherUser': other_user_id} response = self.session.delete(self.u...
python
def unblock(self, other_user_id): """Unblock the given user. :param str other_user_id: the ID of the user to unblock :return: ``True`` if successful :rtype: bool """ params = {'user': self.user_id, 'otherUser': other_user_id} response = self.session.delete(self.u...
[ "def", "unblock", "(", "self", ",", "other_user_id", ")", ":", "params", "=", "{", "'user'", ":", "self", ".", "user_id", ",", "'otherUser'", ":", "other_user_id", "}", "response", "=", "self", ".", "session", ".", "delete", "(", "self", ".", "url", ",...
Unblock the given user. :param str other_user_id: the ID of the user to unblock :return: ``True`` if successful :rtype: bool
[ "Unblock", "the", "given", "user", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/blocks.py#L49-L58
train
rhgrant10/Groupy
groupy/api/chats.py
Chats.list
def list(self, page=1, per_page=10): """List a page of chats. :param int page: which page :param int per_page: how many chats per page :return: chats with other users :rtype: :class:`~groupy.pagers.ChatList` """ return pagers.ChatList(self, self._raw_list, per_pa...
python
def list(self, page=1, per_page=10): """List a page of chats. :param int page: which page :param int per_page: how many chats per page :return: chats with other users :rtype: :class:`~groupy.pagers.ChatList` """ return pagers.ChatList(self, self._raw_list, per_pa...
[ "def", "list", "(", "self", ",", "page", "=", "1", ",", "per_page", "=", "10", ")", ":", "return", "pagers", ".", "ChatList", "(", "self", ",", "self", ".", "_raw_list", ",", "per_page", "=", "per_page", ",", "page", "=", "page", ")" ]
List a page of chats. :param int page: which page :param int per_page: how many chats per page :return: chats with other users :rtype: :class:`~groupy.pagers.ChatList`
[ "List", "a", "page", "of", "chats", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/chats.py#L17-L26
train
rhgrant10/Groupy
groupy/api/messages.py
Messages.list
def list(self, before_id=None, since_id=None, after_id=None, limit=20): """Return a page of group messages. The messages come in reversed order (newest first). Note you can only provide _one_ of ``before_id``, ``since_id``, or ``after_id``. :param str before_id: message ID for paging b...
python
def list(self, before_id=None, since_id=None, after_id=None, limit=20): """Return a page of group messages. The messages come in reversed order (newest first). Note you can only provide _one_ of ``before_id``, ``since_id``, or ``after_id``. :param str before_id: message ID for paging b...
[ "def", "list", "(", "self", ",", "before_id", "=", "None", ",", "since_id", "=", "None", ",", "after_id", "=", "None", ",", "limit", "=", "20", ")", ":", "return", "pagers", ".", "MessageList", "(", "self", ",", "self", ".", "_raw_list", ",", "before...
Return a page of group messages. The messages come in reversed order (newest first). Note you can only provide _one_ of ``before_id``, ``since_id``, or ``after_id``. :param str before_id: message ID for paging backwards :param str after_id: message ID for paging forwards :param...
[ "Return", "a", "page", "of", "group", "messages", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/messages.py#L28-L43
train
rhgrant10/Groupy
groupy/api/messages.py
Messages.list_since
def list_since(self, message_id, limit=None): """Return a page of group messages created since a message. This is used to fetch the most recent messages after another. There may exist messages between the one given and the ones returned. Use :func:`list_after` to retrieve newer messages...
python
def list_since(self, message_id, limit=None): """Return a page of group messages created since a message. This is used to fetch the most recent messages after another. There may exist messages between the one given and the ones returned. Use :func:`list_after` to retrieve newer messages...
[ "def", "list_since", "(", "self", ",", "message_id", ",", "limit", "=", "None", ")", ":", "return", "self", ".", "list", "(", "since_id", "=", "message_id", ",", "limit", "=", "limit", ")" ]
Return a page of group messages created since a message. This is used to fetch the most recent messages after another. There may exist messages between the one given and the ones returned. Use :func:`list_after` to retrieve newer messages without skipping any. :param str message_id: th...
[ "Return", "a", "page", "of", "group", "messages", "created", "since", "a", "message", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/messages.py#L57-L69
train
rhgrant10/Groupy
groupy/api/messages.py
Messages.list_after
def list_after(self, message_id, limit=None): """Return a page of group messages created after a message. This is used to page forwards through messages. :param str message_id: the ID of a message :param int limit: maximum number of messages per page :return: group messages ...
python
def list_after(self, message_id, limit=None): """Return a page of group messages created after a message. This is used to page forwards through messages. :param str message_id: the ID of a message :param int limit: maximum number of messages per page :return: group messages ...
[ "def", "list_after", "(", "self", ",", "message_id", ",", "limit", "=", "None", ")", ":", "return", "self", ".", "list", "(", "after_id", "=", "message_id", ",", "limit", "=", "limit", ")" ]
Return a page of group messages created after a message. This is used to page forwards through messages. :param str message_id: the ID of a message :param int limit: maximum number of messages per page :return: group messages :rtype: :class:`~groupy.pagers.MessageList`
[ "Return", "a", "page", "of", "group", "messages", "created", "after", "a", "message", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/messages.py#L71-L81
train
rhgrant10/Groupy
groupy/api/messages.py
Messages.list_all_before
def list_all_before(self, message_id, limit=None): """Return all group messages created before a message. :param str message_id: the ID of a message :param int limit: maximum number of messages per page :return: group messages :rtype: generator """ return self.li...
python
def list_all_before(self, message_id, limit=None): """Return all group messages created before a message. :param str message_id: the ID of a message :param int limit: maximum number of messages per page :return: group messages :rtype: generator """ return self.li...
[ "def", "list_all_before", "(", "self", ",", "message_id", ",", "limit", "=", "None", ")", ":", "return", "self", ".", "list_before", "(", "message_id", ",", "limit", "=", "limit", ")", ".", "autopage", "(", ")" ]
Return all group messages created before a message. :param str message_id: the ID of a message :param int limit: maximum number of messages per page :return: group messages :rtype: generator
[ "Return", "all", "group", "messages", "created", "before", "a", "message", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/messages.py#L92-L100
train
rhgrant10/Groupy
groupy/api/messages.py
Messages.list_all_after
def list_all_after(self, message_id, limit=None): """Return all group messages created after a message. :param str message_id: the ID of a message :param int limit: maximum number of messages per page :return: group messages :rtype: generator """ return self.list...
python
def list_all_after(self, message_id, limit=None): """Return all group messages created after a message. :param str message_id: the ID of a message :param int limit: maximum number of messages per page :return: group messages :rtype: generator """ return self.list...
[ "def", "list_all_after", "(", "self", ",", "message_id", ",", "limit", "=", "None", ")", ":", "return", "self", ".", "list_after", "(", "message_id", ",", "limit", "=", "limit", ")", ".", "autopage", "(", ")" ]
Return all group messages created after a message. :param str message_id: the ID of a message :param int limit: maximum number of messages per page :return: group messages :rtype: generator
[ "Return", "all", "group", "messages", "created", "after", "a", "message", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/messages.py#L102-L110
train
rhgrant10/Groupy
groupy/api/messages.py
Messages.create
def create(self, text=None, attachments=None, source_guid=None): """Create a new message in the group. :param str text: the text of the message :param attachments: a list of attachments :type attachments: :class:`list` :param str source_guid: a unique identifier for the message ...
python
def create(self, text=None, attachments=None, source_guid=None): """Create a new message in the group. :param str text: the text of the message :param attachments: a list of attachments :type attachments: :class:`list` :param str source_guid: a unique identifier for the message ...
[ "def", "create", "(", "self", ",", "text", "=", "None", ",", "attachments", "=", "None", ",", "source_guid", "=", "None", ")", ":", "message", "=", "{", "'source_guid'", ":", "source_guid", "or", "str", "(", "time", ".", "time", "(", ")", ")", ",", ...
Create a new message in the group. :param str text: the text of the message :param attachments: a list of attachments :type attachments: :class:`list` :param str source_guid: a unique identifier for the message :return: the created message :rtype: :class:`~groupy.api.mes...
[ "Create", "a", "new", "message", "in", "the", "group", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/messages.py#L112-L135
train
rhgrant10/Groupy
groupy/api/messages.py
DirectMessages.list
def list(self, before_id=None, since_id=None, **kwargs): """Return a page of direct messages. The messages come in reversed order (newest first). Note you can only provide _one_ of ``before_id``, ``since_id``. :param str before_id: message ID for paging backwards :param str sin...
python
def list(self, before_id=None, since_id=None, **kwargs): """Return a page of direct messages. The messages come in reversed order (newest first). Note you can only provide _one_ of ``before_id``, ``since_id``. :param str before_id: message ID for paging backwards :param str sin...
[ "def", "list", "(", "self", ",", "before_id", "=", "None", ",", "since_id", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "pagers", ".", "MessageList", "(", "self", ",", "self", ".", "_raw_list", ",", "before_id", "=", "before_id", ",", "...
Return a page of direct messages. The messages come in reversed order (newest first). Note you can only provide _one_ of ``before_id``, ``since_id``. :param str before_id: message ID for paging backwards :param str since_id: message ID for most recent messages since :return: di...
[ "Return", "a", "page", "of", "direct", "messages", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/messages.py#L157-L169
train
rhgrant10/Groupy
groupy/api/messages.py
DirectMessages.list_all
def list_all(self, before_id=None, since_id=None, **kwargs): """Return all direct messages. The messages come in reversed order (newest first). Note you can only provide _one_ of ``before_id``, ``since_id``. :param str before_id: message ID for paging backwards :param str since...
python
def list_all(self, before_id=None, since_id=None, **kwargs): """Return all direct messages. The messages come in reversed order (newest first). Note you can only provide _one_ of ``before_id``, ``since_id``. :param str before_id: message ID for paging backwards :param str since...
[ "def", "list_all", "(", "self", ",", "before_id", "=", "None", ",", "since_id", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "list", "(", "before_id", "=", "before_id", ",", "since_id", "=", "since_id", ",", "*", "*", "kwarg...
Return all direct messages. The messages come in reversed order (newest first). Note you can only provide _one_ of ``before_id``, ``since_id``. :param str before_id: message ID for paging backwards :param str since_id: message ID for most recent messages since :return: direct m...
[ "Return", "all", "direct", "messages", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/messages.py#L194-L205
train
rhgrant10/Groupy
groupy/api/memberships.py
Memberships.add
def add(self, nickname, email=None, phone_number=None, user_id=None): """Add a user to the group. You must provide either the email, phone number, or user_id that uniquely identifies a user. :param str nickname: new name for the user in the group :param str email: email address...
python
def add(self, nickname, email=None, phone_number=None, user_id=None): """Add a user to the group. You must provide either the email, phone number, or user_id that uniquely identifies a user. :param str nickname: new name for the user in the group :param str email: email address...
[ "def", "add", "(", "self", ",", "nickname", ",", "email", "=", "None", ",", "phone_number", "=", "None", ",", "user_id", "=", "None", ")", ":", "member", "=", "{", "'nickname'", ":", "nickname", ",", "'email'", ":", "email", ",", "'phone_number'", ":",...
Add a user to the group. You must provide either the email, phone number, or user_id that uniquely identifies a user. :param str nickname: new name for the user in the group :param str email: email address of the user :param str phone_number: phone number of the user :p...
[ "Add", "a", "user", "to", "the", "group", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/memberships.py#L25-L44
train
rhgrant10/Groupy
groupy/api/memberships.py
Memberships.add_multiple
def add_multiple(self, *users): """Add multiple users to the group at once. Each given user must be a dictionary containing a nickname and either an email, phone number, or user_id. :param args users: the users to add :return: a membership request :rtype: :class:`Member...
python
def add_multiple(self, *users): """Add multiple users to the group at once. Each given user must be a dictionary containing a nickname and either an email, phone number, or user_id. :param args users: the users to add :return: a membership request :rtype: :class:`Member...
[ "def", "add_multiple", "(", "self", ",", "*", "users", ")", ":", "guid", "=", "uuid", ".", "uuid4", "(", ")", "for", "i", ",", "user_", "in", "enumerate", "(", "users", ")", ":", "user_", "[", "'guid'", "]", "=", "'{}-{}'", ".", "format", "(", "g...
Add multiple users to the group at once. Each given user must be a dictionary containing a nickname and either an email, phone number, or user_id. :param args users: the users to add :return: a membership request :rtype: :class:`MembershipRequest`
[ "Add", "multiple", "users", "to", "the", "group", "at", "once", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/memberships.py#L46-L64
train
rhgrant10/Groupy
groupy/api/memberships.py
Memberships.check
def check(self, results_id): """Check for results of a membership request. :param str results_id: the ID of a membership request :return: successfully created memberships :rtype: :class:`list` :raises groupy.exceptions.ResultsNotReady: if the results are not ready :raise...
python
def check(self, results_id): """Check for results of a membership request. :param str results_id: the ID of a membership request :return: successfully created memberships :rtype: :class:`list` :raises groupy.exceptions.ResultsNotReady: if the results are not ready :raise...
[ "def", "check", "(", "self", ",", "results_id", ")", ":", "path", "=", "'results/{}'", ".", "format", "(", "results_id", ")", "url", "=", "utils", ".", "urljoin", "(", "self", ".", "url", ",", "path", ")", "response", "=", "self", ".", "session", "."...
Check for results of a membership request. :param str results_id: the ID of a membership request :return: successfully created memberships :rtype: :class:`list` :raises groupy.exceptions.ResultsNotReady: if the results are not ready :raises groupy.exceptions.ResultsExpired: if t...
[ "Check", "for", "results", "of", "a", "membership", "request", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/memberships.py#L66-L82
train
rhgrant10/Groupy
groupy/api/memberships.py
Memberships.update
def update(self, nickname=None, **kwargs): """Update your own membership. Note that this fails on former groups. :param str nickname: new nickname :return: updated membership :rtype: :class:`~groupy.api.memberships.Member` """ url = self.url + 'hips/update' ...
python
def update(self, nickname=None, **kwargs): """Update your own membership. Note that this fails on former groups. :param str nickname: new nickname :return: updated membership :rtype: :class:`~groupy.api.memberships.Member` """ url = self.url + 'hips/update' ...
[ "def", "update", "(", "self", ",", "nickname", "=", "None", ",", "*", "*", "kwargs", ")", ":", "url", "=", "self", ".", "url", "+", "'hips/update'", "payload", "=", "{", "'membership'", ":", "{", "'nickname'", ":", "nickname", ",", "}", ",", "}", "...
Update your own membership. Note that this fails on former groups. :param str nickname: new nickname :return: updated membership :rtype: :class:`~groupy.api.memberships.Member`
[ "Update", "your", "own", "membership", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/memberships.py#L84-L101
train
rhgrant10/Groupy
groupy/api/memberships.py
Memberships.remove
def remove(self, membership_id): """Remove a member from the group. :param str membership_id: the ID of a member in this group :return: ``True`` if the member was successfully removed :rtype: bool """ path = '{}/remove'.format(membership_id) url = utils.urljoin(s...
python
def remove(self, membership_id): """Remove a member from the group. :param str membership_id: the ID of a member in this group :return: ``True`` if the member was successfully removed :rtype: bool """ path = '{}/remove'.format(membership_id) url = utils.urljoin(s...
[ "def", "remove", "(", "self", ",", "membership_id", ")", ":", "path", "=", "'{}/remove'", ".", "format", "(", "membership_id", ")", "url", "=", "utils", ".", "urljoin", "(", "self", ".", "url", ",", "path", ")", "payload", "=", "{", "'membership_id'", ...
Remove a member from the group. :param str membership_id: the ID of a member in this group :return: ``True`` if the member was successfully removed :rtype: bool
[ "Remove", "a", "member", "from", "the", "group", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/memberships.py#L103-L114
train
rhgrant10/Groupy
groupy/api/memberships.py
Member.post
def post(self, text=None, attachments=None, source_guid=None): """Post a direct message to the user. :param str text: the message content :param attachments: message attachments :param str source_guid: a client-side unique ID for the message :return: the message sent :rt...
python
def post(self, text=None, attachments=None, source_guid=None): """Post a direct message to the user. :param str text: the message content :param attachments: message attachments :param str source_guid: a client-side unique ID for the message :return: the message sent :rt...
[ "def", "post", "(", "self", ",", "text", "=", "None", ",", "attachments", "=", "None", ",", "source_guid", "=", "None", ")", ":", "return", "self", ".", "messages", ".", "create", "(", "text", "=", "text", ",", "attachments", "=", "attachments", ",", ...
Post a direct message to the user. :param str text: the message content :param attachments: message attachments :param str source_guid: a client-side unique ID for the message :return: the message sent :rtype: :class:`~groupy.api.messages.DirectMessage`
[ "Post", "a", "direct", "message", "to", "the", "user", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/memberships.py#L151-L161
train
rhgrant10/Groupy
groupy/api/memberships.py
Member.add_to_group
def add_to_group(self, group_id, nickname=None): """Add the member to another group. If a nickname is not provided the member's current nickname is used. :param str group_id: the group_id of a group :param str nickname: a new nickname :return: a membership request :rtyp...
python
def add_to_group(self, group_id, nickname=None): """Add the member to another group. If a nickname is not provided the member's current nickname is used. :param str group_id: the group_id of a group :param str nickname: a new nickname :return: a membership request :rtyp...
[ "def", "add_to_group", "(", "self", ",", "group_id", ",", "nickname", "=", "None", ")", ":", "if", "nickname", "is", "None", ":", "nickname", "=", "self", ".", "nickname", "memberships", "=", "Memberships", "(", "self", ".", "manager", ".", "session", ",...
Add the member to another group. If a nickname is not provided the member's current nickname is used. :param str group_id: the group_id of a group :param str nickname: a new nickname :return: a membership request :rtype: :class:`MembershipRequest`
[ "Add", "the", "member", "to", "another", "group", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/memberships.py#L195-L208
train
rhgrant10/Groupy
groupy/api/memberships.py
MembershipRequest.check_if_ready
def check_if_ready(self): """Check for and fetch the results if ready.""" try: results = self.manager.check(self.results_id) except exceptions.ResultsNotReady as e: self._is_ready = False self._not_ready_exception = e except exceptions.ResultsExpired a...
python
def check_if_ready(self): """Check for and fetch the results if ready.""" try: results = self.manager.check(self.results_id) except exceptions.ResultsNotReady as e: self._is_ready = False self._not_ready_exception = e except exceptions.ResultsExpired a...
[ "def", "check_if_ready", "(", "self", ")", ":", "try", ":", "results", "=", "self", ".", "manager", ".", "check", "(", "self", ".", "results_id", ")", "except", "exceptions", ".", "ResultsNotReady", "as", "e", ":", "self", ".", "_is_ready", "=", "False",...
Check for and fetch the results if ready.
[ "Check", "for", "and", "fetch", "the", "results", "if", "ready", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/memberships.py#L231-L246
train
rhgrant10/Groupy
groupy/api/memberships.py
MembershipRequest.get_failed_requests
def get_failed_requests(self, results): """Return the requests that failed. :param results: the results of a membership request check :type results: :class:`list` :return: the failed requests :rtype: generator """ data = {member['guid']: member for member in resu...
python
def get_failed_requests(self, results): """Return the requests that failed. :param results: the results of a membership request check :type results: :class:`list` :return: the failed requests :rtype: generator """ data = {member['guid']: member for member in resu...
[ "def", "get_failed_requests", "(", "self", ",", "results", ")", ":", "data", "=", "{", "member", "[", "'guid'", "]", ":", "member", "for", "member", "in", "results", "}", "for", "request", "in", "self", ".", "requests", ":", "if", "request", "[", "'gui...
Return the requests that failed. :param results: the results of a membership request check :type results: :class:`list` :return: the failed requests :rtype: generator
[ "Return", "the", "requests", "that", "failed", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/memberships.py#L248-L259
train
rhgrant10/Groupy
groupy/api/memberships.py
MembershipRequest.get_new_members
def get_new_members(self, results): """Return the newly added members. :param results: the results of a membership request check :type results: :class:`list` :return: the successful requests, as :class:`~groupy.api.memberships.Members` :rtype: generator """ for m...
python
def get_new_members(self, results): """Return the newly added members. :param results: the results of a membership request check :type results: :class:`list` :return: the successful requests, as :class:`~groupy.api.memberships.Members` :rtype: generator """ for m...
[ "def", "get_new_members", "(", "self", ",", "results", ")", ":", "for", "member", "in", "results", ":", "guid", "=", "member", ".", "pop", "(", "'guid'", ")", "yield", "Member", "(", "self", ".", "manager", ",", "self", ".", "group_id", ",", "*", "*"...
Return the newly added members. :param results: the results of a membership request check :type results: :class:`list` :return: the successful requests, as :class:`~groupy.api.memberships.Members` :rtype: generator
[ "Return", "the", "newly", "added", "members", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/memberships.py#L261-L272
train
rhgrant10/Groupy
groupy/api/memberships.py
MembershipRequest.is_ready
def is_ready(self, check=True): """Return ``True`` if the results are ready. If you pass ``check=False``, no attempt is made to check again for results. :param bool check: whether to query for the results :return: ``True`` if the results are ready :rtype: bool "...
python
def is_ready(self, check=True): """Return ``True`` if the results are ready. If you pass ``check=False``, no attempt is made to check again for results. :param bool check: whether to query for the results :return: ``True`` if the results are ready :rtype: bool "...
[ "def", "is_ready", "(", "self", ",", "check", "=", "True", ")", ":", "if", "not", "self", ".", "_is_ready", "and", "check", ":", "self", ".", "check_if_ready", "(", ")", "return", "self", ".", "_is_ready" ]
Return ``True`` if the results are ready. If you pass ``check=False``, no attempt is made to check again for results. :param bool check: whether to query for the results :return: ``True`` if the results are ready :rtype: bool
[ "Return", "True", "if", "the", "results", "are", "ready", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/memberships.py#L274-L286
train
rhgrant10/Groupy
groupy/api/memberships.py
MembershipRequest.poll
def poll(self, timeout=30, interval=2): """Return the results when they become ready. :param int timeout: the maximum time to wait for the results :param float interval: the number of seconds between checks :return: the membership request result :rtype: :class:`~groupy.api.membe...
python
def poll(self, timeout=30, interval=2): """Return the results when they become ready. :param int timeout: the maximum time to wait for the results :param float interval: the number of seconds between checks :return: the membership request result :rtype: :class:`~groupy.api.membe...
[ "def", "poll", "(", "self", ",", "timeout", "=", "30", ",", "interval", "=", "2", ")", ":", "time", ".", "sleep", "(", "interval", ")", "start", "=", "time", ".", "time", "(", ")", "while", "time", ".", "time", "(", ")", "-", "start", "<", "tim...
Return the results when they become ready. :param int timeout: the maximum time to wait for the results :param float interval: the number of seconds between checks :return: the membership request result :rtype: :class:`~groupy.api.memberships.MembershipResult.Results`
[ "Return", "the", "results", "when", "they", "become", "ready", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/memberships.py#L288-L300
train
rhgrant10/Groupy
groupy/api/memberships.py
MembershipRequest.get
def get(self): """Return the results now. :return: the membership request results :rtype: :class:`~groupy.api.memberships.MembershipResult.Results` :raises groupy.exceptions.ResultsNotReady: if the results are not ready :raises groupy.exceptions.ResultsExpired: if the results ha...
python
def get(self): """Return the results now. :return: the membership request results :rtype: :class:`~groupy.api.memberships.MembershipResult.Results` :raises groupy.exceptions.ResultsNotReady: if the results are not ready :raises groupy.exceptions.ResultsExpired: if the results ha...
[ "def", "get", "(", "self", ")", ":", "if", "self", ".", "_expired_exception", ":", "raise", "self", ".", "_expired_exception", "if", "self", ".", "_not_ready_exception", ":", "raise", "self", ".", "_not_ready_exception", "return", "self", ".", "results" ]
Return the results now. :return: the membership request results :rtype: :class:`~groupy.api.memberships.MembershipResult.Results` :raises groupy.exceptions.ResultsNotReady: if the results are not ready :raises groupy.exceptions.ResultsExpired: if the results have expired
[ "Return", "the", "results", "now", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/memberships.py#L302-L314
train
rhgrant10/Groupy
groupy/api/groups.py
Groups.list
def list(self, page=1, per_page=10, omit=None): """List groups by page. The API allows certain fields to be excluded from the results so that very large groups can be fetched without exceeding the maximum response size. At the time of this writing, only 'memberships' is supporte...
python
def list(self, page=1, per_page=10, omit=None): """List groups by page. The API allows certain fields to be excluded from the results so that very large groups can be fetched without exceeding the maximum response size. At the time of this writing, only 'memberships' is supporte...
[ "def", "list", "(", "self", ",", "page", "=", "1", ",", "per_page", "=", "10", ",", "omit", "=", "None", ")", ":", "return", "pagers", ".", "GroupList", "(", "self", ",", "self", ".", "_raw_list", ",", "page", "=", "page", ",", "per_page", "=", "...
List groups by page. The API allows certain fields to be excluded from the results so that very large groups can be fetched without exceeding the maximum response size. At the time of this writing, only 'memberships' is supported. :param int page: page number :param int...
[ "List", "groups", "by", "page", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L23-L38
train
rhgrant10/Groupy
groupy/api/groups.py
Groups.list_all
def list_all(self, per_page=10, omit=None): """List all groups. Since the order of groups is determined by recent activity, this is the recommended way to obtain a list of all groups. See :func:`~groupy.api.groups.Groups.list` for details about ``omit``. :param int per_page: nu...
python
def list_all(self, per_page=10, omit=None): """List all groups. Since the order of groups is determined by recent activity, this is the recommended way to obtain a list of all groups. See :func:`~groupy.api.groups.Groups.list` for details about ``omit``. :param int per_page: nu...
[ "def", "list_all", "(", "self", ",", "per_page", "=", "10", ",", "omit", "=", "None", ")", ":", "return", "self", ".", "list", "(", "per_page", "=", "per_page", ",", "omit", "=", "omit", ")", ".", "autopage", "(", ")" ]
List all groups. Since the order of groups is determined by recent activity, this is the recommended way to obtain a list of all groups. See :func:`~groupy.api.groups.Groups.list` for details about ``omit``. :param int per_page: number of groups per page :param int omit: a comm...
[ "List", "all", "groups", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L40-L52
train
rhgrant10/Groupy
groupy/api/groups.py
Groups.list_former
def list_former(self): """List all former groups. :return: a list of groups :rtype: :class:`list` """ url = utils.urljoin(self.url, 'former') response = self.session.get(url) return [Group(self, **group) for group in response.data]
python
def list_former(self): """List all former groups. :return: a list of groups :rtype: :class:`list` """ url = utils.urljoin(self.url, 'former') response = self.session.get(url) return [Group(self, **group) for group in response.data]
[ "def", "list_former", "(", "self", ")", ":", "url", "=", "utils", ".", "urljoin", "(", "self", ".", "url", ",", "'former'", ")", "response", "=", "self", ".", "session", ".", "get", "(", "url", ")", "return", "[", "Group", "(", "self", ",", "*", ...
List all former groups. :return: a list of groups :rtype: :class:`list`
[ "List", "all", "former", "groups", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L54-L62
train
rhgrant10/Groupy
groupy/api/groups.py
Groups.get
def get(self, id): """Get a single group by ID. :param str id: a group ID :return: a group :rtype: :class:`~groupy.api.groups.Group` """ url = utils.urljoin(self.url, id) response = self.session.get(url) return Group(self, **response.data)
python
def get(self, id): """Get a single group by ID. :param str id: a group ID :return: a group :rtype: :class:`~groupy.api.groups.Group` """ url = utils.urljoin(self.url, id) response = self.session.get(url) return Group(self, **response.data)
[ "def", "get", "(", "self", ",", "id", ")", ":", "url", "=", "utils", ".", "urljoin", "(", "self", ".", "url", ",", "id", ")", "response", "=", "self", ".", "session", ".", "get", "(", "url", ")", "return", "Group", "(", "self", ",", "*", "*", ...
Get a single group by ID. :param str id: a group ID :return: a group :rtype: :class:`~groupy.api.groups.Group`
[ "Get", "a", "single", "group", "by", "ID", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L64-L73
train
rhgrant10/Groupy
groupy/api/groups.py
Groups.create
def create(self, name, description=None, image_url=None, share=None, **kwargs): """Create a new group. Note that, although possible, there may be issues when not using an image URL from GroupMe's image service. :param str name: group name (140 characters maximum) :param str des...
python
def create(self, name, description=None, image_url=None, share=None, **kwargs): """Create a new group. Note that, although possible, there may be issues when not using an image URL from GroupMe's image service. :param str name: group name (140 characters maximum) :param str des...
[ "def", "create", "(", "self", ",", "name", ",", "description", "=", "None", ",", "image_url", "=", "None", ",", "share", "=", "None", ",", "*", "*", "kwargs", ")", ":", "payload", "=", "{", "'name'", ":", "name", ",", "'description'", ":", "descripti...
Create a new group. Note that, although possible, there may be issues when not using an image URL from GroupMe's image service. :param str name: group name (140 characters maximum) :param str description: short description (255 characters maximum) :param str image_url: GroupMe ...
[ "Create", "a", "new", "group", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L75-L96
train
rhgrant10/Groupy
groupy/api/groups.py
Groups.update
def update(self, id, name=None, description=None, image_url=None, office_mode=None, share=None, **kwargs): """Update the details of a group. .. note:: There are significant bugs in this endpoint! 1. not providing ``name`` produces 400: "Topic can't be blank" ...
python
def update(self, id, name=None, description=None, image_url=None, office_mode=None, share=None, **kwargs): """Update the details of a group. .. note:: There are significant bugs in this endpoint! 1. not providing ``name`` produces 400: "Topic can't be blank" ...
[ "def", "update", "(", "self", ",", "id", ",", "name", "=", "None", ",", "description", "=", "None", ",", "image_url", "=", "None", ",", "office_mode", "=", "None", ",", "share", "=", "None", ",", "*", "*", "kwargs", ")", ":", "path", "=", "'{}/upda...
Update the details of a group. .. note:: There are significant bugs in this endpoint! 1. not providing ``name`` produces 400: "Topic can't be blank" 2. not providing ``office_mode`` produces 500: "sql: Scan error on column index 14: sql/driver: couldn't convert ...
[ "Update", "the", "details", "of", "a", "group", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L98-L133
train
rhgrant10/Groupy
groupy/api/groups.py
Groups.destroy
def destroy(self, id): """Destroy a group. :param str id: a group ID :return: ``True`` if successful :rtype: bool """ path = '{}/destroy'.format(id) url = utils.urljoin(self.url, path) response = self.session.post(url) return response.ok
python
def destroy(self, id): """Destroy a group. :param str id: a group ID :return: ``True`` if successful :rtype: bool """ path = '{}/destroy'.format(id) url = utils.urljoin(self.url, path) response = self.session.post(url) return response.ok
[ "def", "destroy", "(", "self", ",", "id", ")", ":", "path", "=", "'{}/destroy'", ".", "format", "(", "id", ")", "url", "=", "utils", ".", "urljoin", "(", "self", ".", "url", ",", "path", ")", "response", "=", "self", ".", "session", ".", "post", ...
Destroy a group. :param str id: a group ID :return: ``True`` if successful :rtype: bool
[ "Destroy", "a", "group", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L135-L145
train
rhgrant10/Groupy
groupy/api/groups.py
Groups.join
def join(self, group_id, share_token): """Join a group using a share token. :param str group_id: the group_id of a group :param str share_token: the share token :return: the group :rtype: :class:`~groupy.api.groups.Group` """ path = '{}/join/{}'.format(group_id, ...
python
def join(self, group_id, share_token): """Join a group using a share token. :param str group_id: the group_id of a group :param str share_token: the share token :return: the group :rtype: :class:`~groupy.api.groups.Group` """ path = '{}/join/{}'.format(group_id, ...
[ "def", "join", "(", "self", ",", "group_id", ",", "share_token", ")", ":", "path", "=", "'{}/join/{}'", ".", "format", "(", "group_id", ",", "share_token", ")", "url", "=", "utils", ".", "urljoin", "(", "self", ".", "url", ",", "path", ")", "response",...
Join a group using a share token. :param str group_id: the group_id of a group :param str share_token: the share token :return: the group :rtype: :class:`~groupy.api.groups.Group`
[ "Join", "a", "group", "using", "a", "share", "token", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L147-L159
train
rhgrant10/Groupy
groupy/api/groups.py
Groups.rejoin
def rejoin(self, group_id): """Rejoin a former group. :param str group_id: the group_id of a group :return: the group :rtype: :class:`~groupy.api.groups.Group` """ url = utils.urljoin(self.url, 'join') payload = {'group_id': group_id} response = self.sess...
python
def rejoin(self, group_id): """Rejoin a former group. :param str group_id: the group_id of a group :return: the group :rtype: :class:`~groupy.api.groups.Group` """ url = utils.urljoin(self.url, 'join') payload = {'group_id': group_id} response = self.sess...
[ "def", "rejoin", "(", "self", ",", "group_id", ")", ":", "url", "=", "utils", ".", "urljoin", "(", "self", ".", "url", ",", "'join'", ")", "payload", "=", "{", "'group_id'", ":", "group_id", "}", "response", "=", "self", ".", "session", ".", "post", ...
Rejoin a former group. :param str group_id: the group_id of a group :return: the group :rtype: :class:`~groupy.api.groups.Group`
[ "Rejoin", "a", "former", "group", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L161-L171
train
rhgrant10/Groupy
groupy/api/groups.py
Groups.change_owners
def change_owners(self, group_id, owner_id): """Change the owner of a group. .. note:: you must be the owner to change owners :param str group_id: the group_id of a group :param str owner_id: the ID of the new owner :return: the result :rtype: :class:`~groupy.api.groups...
python
def change_owners(self, group_id, owner_id): """Change the owner of a group. .. note:: you must be the owner to change owners :param str group_id: the group_id of a group :param str owner_id: the ID of the new owner :return: the result :rtype: :class:`~groupy.api.groups...
[ "def", "change_owners", "(", "self", ",", "group_id", ",", "owner_id", ")", ":", "url", "=", "utils", ".", "urljoin", "(", "self", ".", "url", ",", "'change_owners'", ")", "payload", "=", "{", "'requests'", ":", "[", "{", "'group_id'", ":", "group_id", ...
Change the owner of a group. .. note:: you must be the owner to change owners :param str group_id: the group_id of a group :param str owner_id: the ID of the new owner :return: the result :rtype: :class:`~groupy.api.groups.ChangeOwnersResult`
[ "Change", "the", "owner", "of", "a", "group", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L173-L192
train
rhgrant10/Groupy
groupy/api/groups.py
Group.update
def update(self, name=None, description=None, image_url=None, office_mode=None, share=None, **kwargs): """Update the details of the group. :param str name: group name (140 characters maximum) :param str description: short description (255 characters maximum) :param str im...
python
def update(self, name=None, description=None, image_url=None, office_mode=None, share=None, **kwargs): """Update the details of the group. :param str name: group name (140 characters maximum) :param str description: short description (255 characters maximum) :param str im...
[ "def", "update", "(", "self", ",", "name", "=", "None", ",", "description", "=", "None", ",", "image_url", "=", "None", ",", "office_mode", "=", "None", ",", "share", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# note we default to the current values ...
Update the details of the group. :param str name: group name (140 characters maximum) :param str description: short description (255 characters maximum) :param str image_url: GroupMe image service URL :param bool office_mode: (undocumented) :param bool share: whether to generate...
[ "Update", "the", "details", "of", "the", "group", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L272-L292
train
rhgrant10/Groupy
groupy/api/groups.py
Group.refresh_from_server
def refresh_from_server(self): """Refresh the group from the server in place.""" group = self.manager.get(id=self.id) self.__init__(self.manager, **group.data)
python
def refresh_from_server(self): """Refresh the group from the server in place.""" group = self.manager.get(id=self.id) self.__init__(self.manager, **group.data)
[ "def", "refresh_from_server", "(", "self", ")", ":", "group", "=", "self", ".", "manager", ".", "get", "(", "id", "=", "self", ".", "id", ")", "self", ".", "__init__", "(", "self", ".", "manager", ",", "*", "*", "group", ".", "data", ")" ]
Refresh the group from the server in place.
[ "Refresh", "the", "group", "from", "the", "server", "in", "place", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L314-L317
train
rhgrant10/Groupy
groupy/api/groups.py
Group.create_bot
def create_bot(self, name, avatar_url=None, callback_url=None, dm_notification=None, **kwargs): """Create a new bot in a particular group. :param str name: bot name :param str avatar_url: the URL of an image to use as an avatar :param str callback_url: a POST-back URL...
python
def create_bot(self, name, avatar_url=None, callback_url=None, dm_notification=None, **kwargs): """Create a new bot in a particular group. :param str name: bot name :param str avatar_url: the URL of an image to use as an avatar :param str callback_url: a POST-back URL...
[ "def", "create_bot", "(", "self", ",", "name", ",", "avatar_url", "=", "None", ",", "callback_url", "=", "None", ",", "dm_notification", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_bots", ".", "create", "(", "name", "=", ...
Create a new bot in a particular group. :param str name: bot name :param str avatar_url: the URL of an image to use as an avatar :param str callback_url: a POST-back URL for each new message :param bool dm_notification: whether to POST-back for direct messages? :return: the new ...
[ "Create", "a", "new", "bot", "in", "a", "particular", "group", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L319-L332
train
rhgrant10/Groupy
groupy/api/groups.py
Group.get_membership
def get_membership(self): """Get your membership. Note that your membership may not exist. For example, you do not have a membership in a former group. Also, the group returned by the API when rejoining a former group does not contain your membership. You must call :func:`refres...
python
def get_membership(self): """Get your membership. Note that your membership may not exist. For example, you do not have a membership in a former group. Also, the group returned by the API when rejoining a former group does not contain your membership. You must call :func:`refres...
[ "def", "get_membership", "(", "self", ")", ":", "user_id", "=", "self", ".", "_user", ".", "me", "[", "'user_id'", "]", "for", "member", "in", "self", ".", "members", ":", "if", "member", ".", "user_id", "==", "user_id", ":", "return", "member", "raise...
Get your membership. Note that your membership may not exist. For example, you do not have a membership in a former group. Also, the group returned by the API when rejoining a former group does not contain your membership. You must call :func:`refresh_from_server` to update the list of ...
[ "Get", "your", "membership", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L345-L362
train
rhgrant10/Groupy
groupy/api/groups.py
Group.update_membership
def update_membership(self, nickname=None, **kwargs): """Update your own membership. Note that this fails on former groups. :param str nickname: new nickname :return: updated membership :rtype: :class:`~groupy.api.members.Member` """ return self.memberships.upda...
python
def update_membership(self, nickname=None, **kwargs): """Update your own membership. Note that this fails on former groups. :param str nickname: new nickname :return: updated membership :rtype: :class:`~groupy.api.members.Member` """ return self.memberships.upda...
[ "def", "update_membership", "(", "self", ",", "nickname", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "memberships", ".", "update", "(", "nickname", "=", "nickname", ",", "*", "*", "kwargs", ")" ]
Update your own membership. Note that this fails on former groups. :param str nickname: new nickname :return: updated membership :rtype: :class:`~groupy.api.members.Member`
[ "Update", "your", "own", "membership", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L364-L373
train
rhgrant10/Groupy
groupy/utils.py
urljoin
def urljoin(base, path=None): """Join a base url with a relative path.""" # /foo/bar + baz makes /foo/bar/baz instead of /foo/baz if path is None: url = base else: if not base.endswith('/'): base += '/' url = urllib.parse.urljoin(base, str(path)) return url
python
def urljoin(base, path=None): """Join a base url with a relative path.""" # /foo/bar + baz makes /foo/bar/baz instead of /foo/baz if path is None: url = base else: if not base.endswith('/'): base += '/' url = urllib.parse.urljoin(base, str(path)) return url
[ "def", "urljoin", "(", "base", ",", "path", "=", "None", ")", ":", "# /foo/bar + baz makes /foo/bar/baz instead of /foo/baz", "if", "path", "is", "None", ":", "url", "=", "base", "else", ":", "if", "not", "base", ".", "endswith", "(", "'/'", ")", ":", "bas...
Join a base url with a relative path.
[ "Join", "a", "base", "url", "with", "a", "relative", "path", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/utils.py#L8-L17
train
rhgrant10/Groupy
groupy/utils.py
parse_share_url
def parse_share_url(share_url): """Return the group_id and share_token in a group's share url. :param str share_url: the share url of a group """ *__, group_id, share_token = share_url.rstrip('/').split('/') return group_id, share_token
python
def parse_share_url(share_url): """Return the group_id and share_token in a group's share url. :param str share_url: the share url of a group """ *__, group_id, share_token = share_url.rstrip('/').split('/') return group_id, share_token
[ "def", "parse_share_url", "(", "share_url", ")", ":", "*", "__", ",", "group_id", ",", "share_token", "=", "share_url", ".", "rstrip", "(", "'/'", ")", ".", "split", "(", "'/'", ")", "return", "group_id", ",", "share_token" ]
Return the group_id and share_token in a group's share url. :param str share_url: the share url of a group
[ "Return", "the", "group_id", "and", "share_token", "in", "a", "group", "s", "share", "url", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/utils.py#L20-L26
train
rhgrant10/Groupy
groupy/utils.py
get_rfc3339
def get_rfc3339(when): """Return an RFC 3339 timestamp. :param datetime.datetime when: a datetime in UTC :return: RFC 3339 timestamp :rtype: str """ microseconds = format(when.microsecond, '04d')[:4] rfc3339 = '%Y-%m-%dT%H:%M:%S.{}Z' return when.strftime(rfc3339.format(microseconds))
python
def get_rfc3339(when): """Return an RFC 3339 timestamp. :param datetime.datetime when: a datetime in UTC :return: RFC 3339 timestamp :rtype: str """ microseconds = format(when.microsecond, '04d')[:4] rfc3339 = '%Y-%m-%dT%H:%M:%S.{}Z' return when.strftime(rfc3339.format(microseconds))
[ "def", "get_rfc3339", "(", "when", ")", ":", "microseconds", "=", "format", "(", "when", ".", "microsecond", ",", "'04d'", ")", "[", ":", "4", "]", "rfc3339", "=", "'%Y-%m-%dT%H:%M:%S.{}Z'", "return", "when", ".", "strftime", "(", "rfc3339", ".", "format",...
Return an RFC 3339 timestamp. :param datetime.datetime when: a datetime in UTC :return: RFC 3339 timestamp :rtype: str
[ "Return", "an", "RFC", "3339", "timestamp", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/utils.py#L29-L38
train
rhgrant10/Groupy
groupy/utils.py
make_filter
def make_filter(**tests): """Create a filter from keyword arguments.""" tests = [AttrTest(k, v) for k, v in tests.items()] return Filter(tests)
python
def make_filter(**tests): """Create a filter from keyword arguments.""" tests = [AttrTest(k, v) for k, v in tests.items()] return Filter(tests)
[ "def", "make_filter", "(", "*", "*", "tests", ")", ":", "tests", "=", "[", "AttrTest", "(", "k", ",", "v", ")", "for", "k", ",", "v", "in", "tests", ".", "items", "(", ")", "]", "return", "Filter", "(", "tests", ")" ]
Create a filter from keyword arguments.
[ "Create", "a", "filter", "from", "keyword", "arguments", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/utils.py#L116-L119
train
rhgrant10/Groupy
groupy/utils.py
Filter.find
def find(self, objects): """Find exactly one match in the list of objects. :param objects: objects to filter :type objects: :class:`list` :return: the one matching object :raises groupy.exceptions.NoMatchesError: if no objects match :raises groupy.exceptions.MultipleMatc...
python
def find(self, objects): """Find exactly one match in the list of objects. :param objects: objects to filter :type objects: :class:`list` :return: the one matching object :raises groupy.exceptions.NoMatchesError: if no objects match :raises groupy.exceptions.MultipleMatc...
[ "def", "find", "(", "self", ",", "objects", ")", ":", "matches", "=", "list", "(", "self", ".", "__call__", "(", "objects", ")", ")", "if", "not", "matches", ":", "raise", "exceptions", ".", "NoMatchesError", "(", "objects", ",", "self", ".", "tests", ...
Find exactly one match in the list of objects. :param objects: objects to filter :type objects: :class:`list` :return: the one matching object :raises groupy.exceptions.NoMatchesError: if no objects match :raises groupy.exceptions.MultipleMatchesError: if multiple objects match
[ "Find", "exactly", "one", "match", "in", "the", "list", "of", "objects", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/utils.py#L89-L104
train
rhgrant10/Groupy
groupy/api/bots.py
Bots.list
def list(self): """Return a list of bots. :return: all of your bots :rtype: :class:`list` """ response = self.session.get(self.url) return [Bot(self, **bot) for bot in response.data]
python
def list(self): """Return a list of bots. :return: all of your bots :rtype: :class:`list` """ response = self.session.get(self.url) return [Bot(self, **bot) for bot in response.data]
[ "def", "list", "(", "self", ")", ":", "response", "=", "self", ".", "session", ".", "get", "(", "self", ".", "url", ")", "return", "[", "Bot", "(", "self", ",", "*", "*", "bot", ")", "for", "bot", "in", "response", ".", "data", "]" ]
Return a list of bots. :return: all of your bots :rtype: :class:`list`
[ "Return", "a", "list", "of", "bots", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/bots.py#L11-L18
train
rhgrant10/Groupy
groupy/api/bots.py
Bots.create
def create(self, name, group_id, avatar_url=None, callback_url=None, dm_notification=None, **kwargs): """Create a new bot in a particular group. :param str name: bot name :param str group_id: the group_id of a group :param str avatar_url: the URL of an image to use as an ...
python
def create(self, name, group_id, avatar_url=None, callback_url=None, dm_notification=None, **kwargs): """Create a new bot in a particular group. :param str name: bot name :param str group_id: the group_id of a group :param str avatar_url: the URL of an image to use as an ...
[ "def", "create", "(", "self", ",", "name", ",", "group_id", ",", "avatar_url", "=", "None", ",", "callback_url", "=", "None", ",", "dm_notification", "=", "None", ",", "*", "*", "kwargs", ")", ":", "payload", "=", "{", "'bot'", ":", "{", "'name'", ":...
Create a new bot in a particular group. :param str name: bot name :param str group_id: the group_id of a group :param str avatar_url: the URL of an image to use as an avatar :param str callback_url: a POST-back URL for each new message :param bool dm_notification: whether to POS...
[ "Create", "a", "new", "bot", "in", "a", "particular", "group", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/bots.py#L20-L44
train
rhgrant10/Groupy
groupy/api/bots.py
Bots.post
def post(self, bot_id, text, attachments=None): """Post a new message as a bot to its room. :param str bot_id: the ID of the bot :param str text: the text of the message :param attachments: a list of attachments :type attachments: :class:`list` :return: ``True`` if succe...
python
def post(self, bot_id, text, attachments=None): """Post a new message as a bot to its room. :param str bot_id: the ID of the bot :param str text: the text of the message :param attachments: a list of attachments :type attachments: :class:`list` :return: ``True`` if succe...
[ "def", "post", "(", "self", ",", "bot_id", ",", "text", ",", "attachments", "=", "None", ")", ":", "url", "=", "utils", ".", "urljoin", "(", "self", ".", "url", ",", "'post'", ")", "payload", "=", "dict", "(", "bot_id", "=", "bot_id", ",", "text", ...
Post a new message as a bot to its room. :param str bot_id: the ID of the bot :param str text: the text of the message :param attachments: a list of attachments :type attachments: :class:`list` :return: ``True`` if successful :rtype: bool
[ "Post", "a", "new", "message", "as", "a", "bot", "to", "its", "room", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/bots.py#L46-L63
train
rhgrant10/Groupy
groupy/api/bots.py
Bots.destroy
def destroy(self, bot_id): """Destroy a bot. :param str bot_id: the ID of the bot to destroy :return: ``True`` if successful :rtype: bool """ url = utils.urljoin(self.url, 'destroy') payload = {'bot_id': bot_id} response = self.session.post(url, json=payl...
python
def destroy(self, bot_id): """Destroy a bot. :param str bot_id: the ID of the bot to destroy :return: ``True`` if successful :rtype: bool """ url = utils.urljoin(self.url, 'destroy') payload = {'bot_id': bot_id} response = self.session.post(url, json=payl...
[ "def", "destroy", "(", "self", ",", "bot_id", ")", ":", "url", "=", "utils", ".", "urljoin", "(", "self", ".", "url", ",", "'destroy'", ")", "payload", "=", "{", "'bot_id'", ":", "bot_id", "}", "response", "=", "self", ".", "session", ".", "post", ...
Destroy a bot. :param str bot_id: the ID of the bot to destroy :return: ``True`` if successful :rtype: bool
[ "Destroy", "a", "bot", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/bots.py#L65-L75
train
rhgrant10/Groupy
groupy/api/bots.py
Bot.post
def post(self, text, attachments=None): """Post a message as the bot. :param str text: the text of the message :param attachments: a list of attachments :type attachments: :class:`list` :return: ``True`` if successful :rtype: bool """ return self.manager....
python
def post(self, text, attachments=None): """Post a message as the bot. :param str text: the text of the message :param attachments: a list of attachments :type attachments: :class:`list` :return: ``True`` if successful :rtype: bool """ return self.manager....
[ "def", "post", "(", "self", ",", "text", ",", "attachments", "=", "None", ")", ":", "return", "self", ".", "manager", ".", "post", "(", "self", ".", "bot_id", ",", "text", ",", "attachments", ")" ]
Post a message as the bot. :param str text: the text of the message :param attachments: a list of attachments :type attachments: :class:`list` :return: ``True`` if successful :rtype: bool
[ "Post", "a", "message", "as", "the", "bot", "." ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/bots.py#L88-L97
train
jackfirth/pyramda
pyramda/iterable/flatten.py
flatten_until
def flatten_until(is_leaf, xs): """ Flatten a nested sequence. A sequence could be a nested list of lists or tuples or a combination of both :param is_leaf: Predicate. Predicate to determine whether an item in the iterable `xs` is a leaf node or not. :param xs: Iterable. Neste...
python
def flatten_until(is_leaf, xs): """ Flatten a nested sequence. A sequence could be a nested list of lists or tuples or a combination of both :param is_leaf: Predicate. Predicate to determine whether an item in the iterable `xs` is a leaf node or not. :param xs: Iterable. Neste...
[ "def", "flatten_until", "(", "is_leaf", ",", "xs", ")", ":", "def", "_flatten_until", "(", "items", ")", ":", "if", "isinstance", "(", "Iterable", ",", "items", ")", "and", "not", "is_leaf", "(", "items", ")", ":", "for", "item", "in", "items", ":", ...
Flatten a nested sequence. A sequence could be a nested list of lists or tuples or a combination of both :param is_leaf: Predicate. Predicate to determine whether an item in the iterable `xs` is a leaf node or not. :param xs: Iterable. Nested lists or tuples :return: list.
[ "Flatten", "a", "nested", "sequence", ".", "A", "sequence", "could", "be", "a", "nested", "list", "of", "lists", "or", "tuples", "or", "a", "combination", "of", "both" ]
85ab1c2f456085c9e31e3831459ee1a850ab559c
https://github.com/jackfirth/pyramda/blob/85ab1c2f456085c9e31e3831459ee1a850ab559c/pyramda/iterable/flatten.py#L9-L28
train
jackfirth/pyramda
pyramda/function/flip.py
flip
def flip(f): """ Calls the function f by flipping the first two positional arguments """ def wrapped(*args, **kwargs): return f(*flip_first_two(args), **kwargs) f_spec = make_func_curry_spec(f) return curry_by_spec(f_spec, wrapped)
python
def flip(f): """ Calls the function f by flipping the first two positional arguments """ def wrapped(*args, **kwargs): return f(*flip_first_two(args), **kwargs) f_spec = make_func_curry_spec(f) return curry_by_spec(f_spec, wrapped)
[ "def", "flip", "(", "f", ")", ":", "def", "wrapped", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "f", "(", "*", "flip_first_two", "(", "args", ")", ",", "*", "*", "kwargs", ")", "f_spec", "=", "make_func_curry_spec", "(", "f", ...
Calls the function f by flipping the first two positional arguments
[ "Calls", "the", "function", "f", "by", "flipping", "the", "first", "two", "positional", "arguments" ]
85ab1c2f456085c9e31e3831459ee1a850ab559c
https://github.com/jackfirth/pyramda/blob/85ab1c2f456085c9e31e3831459ee1a850ab559c/pyramda/function/flip.py#L10-L21
train
shaypal5/cachier
cachier/core.py
cachier
def cachier(stale_after=None, next_time=False, pickle_reload=True, mongetter=None): """A persistent, stale-free memoization decorator. The positional and keyword arguments to the wrapped function must be hashable (i.e. Python's immutable built-in objects, not mutable containers). Also, noti...
python
def cachier(stale_after=None, next_time=False, pickle_reload=True, mongetter=None): """A persistent, stale-free memoization decorator. The positional and keyword arguments to the wrapped function must be hashable (i.e. Python's immutable built-in objects, not mutable containers). Also, noti...
[ "def", "cachier", "(", "stale_after", "=", "None", ",", "next_time", "=", "False", ",", "pickle_reload", "=", "True", ",", "mongetter", "=", "None", ")", ":", "# print('Inside the wrapper maker')", "# print('mongetter={}'.format(mongetter))", "# print('stale_after={}'.for...
A persistent, stale-free memoization decorator. The positional and keyword arguments to the wrapped function must be hashable (i.e. Python's immutable built-in objects, not mutable containers). Also, notice that since objects which are instances of user-defined classes are hashable but all compare uneq...
[ "A", "persistent", "stale", "-", "free", "memoization", "decorator", "." ]
998233b97b9d905292e9d33413677f98d131f17d
https://github.com/shaypal5/cachier/blob/998233b97b9d905292e9d33413677f98d131f17d/cachier/core.py#L74-L185
train
bocong/urbandictionary-py
urbandictionary.py
defineID
def defineID(defid): """Search for UD's definition ID and return list of UrbanDefinition objects. Keyword arguments: defid -- definition ID to search for (int or str) """ json = _get_urban_json(UD_DEFID_URL + urlquote(str(defid))) return _parse_urban_json(json)
python
def defineID(defid): """Search for UD's definition ID and return list of UrbanDefinition objects. Keyword arguments: defid -- definition ID to search for (int or str) """ json = _get_urban_json(UD_DEFID_URL + urlquote(str(defid))) return _parse_urban_json(json)
[ "def", "defineID", "(", "defid", ")", ":", "json", "=", "_get_urban_json", "(", "UD_DEFID_URL", "+", "urlquote", "(", "str", "(", "defid", ")", ")", ")", "return", "_parse_urban_json", "(", "json", ")" ]
Search for UD's definition ID and return list of UrbanDefinition objects. Keyword arguments: defid -- definition ID to search for (int or str)
[ "Search", "for", "UD", "s", "definition", "ID", "and", "return", "list", "of", "UrbanDefinition", "objects", "." ]
aa919cd2c28563ca7f09ff80a3125de2dc7576ba
https://github.com/bocong/urbandictionary-py/blob/aa919cd2c28563ca7f09ff80a3125de2dc7576ba/urbandictionary.py#L63-L70
train
scraperwiki/scraperwiki-python
setup.py
has_external_dependency
def has_external_dependency(name): 'Check that a non-Python dependency is installed.' for directory in os.environ['PATH'].split(':'): if os.path.exists(os.path.join(directory, name)): return True return False
python
def has_external_dependency(name): 'Check that a non-Python dependency is installed.' for directory in os.environ['PATH'].split(':'): if os.path.exists(os.path.join(directory, name)): return True return False
[ "def", "has_external_dependency", "(", "name", ")", ":", "for", "directory", "in", "os", ".", "environ", "[", "'PATH'", "]", ".", "split", "(", "':'", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "os", ".", "path", ".", "join", "(", "dire...
Check that a non-Python dependency is installed.
[ "Check", "that", "a", "non", "-", "Python", "dependency", "is", "installed", "." ]
75f77e27071ba667df93e740b61bbb0383ba0843
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/setup.py#L11-L16
train
akaszynski/pymeshfix
pymeshfix/examples/fix.py
with_vtk
def with_vtk(plot=True): """ Tests VTK interface and mesh repair of Stanford Bunny Mesh """ mesh = vtki.PolyData(bunny_scan) meshfix = pymeshfix.MeshFix(mesh) if plot: print('Plotting input mesh') meshfix.plot() meshfix.repair() if plot: print('Plotting repaired mesh') ...
python
def with_vtk(plot=True): """ Tests VTK interface and mesh repair of Stanford Bunny Mesh """ mesh = vtki.PolyData(bunny_scan) meshfix = pymeshfix.MeshFix(mesh) if plot: print('Plotting input mesh') meshfix.plot() meshfix.repair() if plot: print('Plotting repaired mesh') ...
[ "def", "with_vtk", "(", "plot", "=", "True", ")", ":", "mesh", "=", "vtki", ".", "PolyData", "(", "bunny_scan", ")", "meshfix", "=", "pymeshfix", ".", "MeshFix", "(", "mesh", ")", "if", "plot", ":", "print", "(", "'Plotting input mesh'", ")", "meshfix", ...
Tests VTK interface and mesh repair of Stanford Bunny Mesh
[ "Tests", "VTK", "interface", "and", "mesh", "repair", "of", "Stanford", "Bunny", "Mesh" ]
51873b25d8d46168479989a528db8456af6748f4
https://github.com/akaszynski/pymeshfix/blob/51873b25d8d46168479989a528db8456af6748f4/pymeshfix/examples/fix.py#L15-L27
train
akaszynski/pymeshfix
pymeshfix/meshfix.py
MeshFix.load_arrays
def load_arrays(self, v, f): """Loads triangular mesh from vertex and face numpy arrays. Both vertex and face arrays should be 2D arrays with each vertex containing XYZ data and each face containing three points. Parameters ---------- v : np.ndarray ...
python
def load_arrays(self, v, f): """Loads triangular mesh from vertex and face numpy arrays. Both vertex and face arrays should be 2D arrays with each vertex containing XYZ data and each face containing three points. Parameters ---------- v : np.ndarray ...
[ "def", "load_arrays", "(", "self", ",", "v", ",", "f", ")", ":", "# Check inputs", "if", "not", "isinstance", "(", "v", ",", "np", ".", "ndarray", ")", ":", "try", ":", "v", "=", "np", ".", "asarray", "(", "v", ",", "np", ".", "float", ")", "if...
Loads triangular mesh from vertex and face numpy arrays. Both vertex and face arrays should be 2D arrays with each vertex containing XYZ data and each face containing three points. Parameters ---------- v : np.ndarray n x 3 vertex array. f : np.ndar...
[ "Loads", "triangular", "mesh", "from", "vertex", "and", "face", "numpy", "arrays", "." ]
51873b25d8d46168479989a528db8456af6748f4
https://github.com/akaszynski/pymeshfix/blob/51873b25d8d46168479989a528db8456af6748f4/pymeshfix/meshfix.py#L37-L74
train
akaszynski/pymeshfix
pymeshfix/meshfix.py
MeshFix.mesh
def mesh(self): """Return the surface mesh""" triangles = np.empty((self.f.shape[0], 4)) triangles[:, -3:] = self.f triangles[:, 0] = 3 return vtki.PolyData(self.v, triangles, deep=False)
python
def mesh(self): """Return the surface mesh""" triangles = np.empty((self.f.shape[0], 4)) triangles[:, -3:] = self.f triangles[:, 0] = 3 return vtki.PolyData(self.v, triangles, deep=False)
[ "def", "mesh", "(", "self", ")", ":", "triangles", "=", "np", ".", "empty", "(", "(", "self", ".", "f", ".", "shape", "[", "0", "]", ",", "4", ")", ")", "triangles", "[", ":", ",", "-", "3", ":", "]", "=", "self", ".", "f", "triangles", "["...
Return the surface mesh
[ "Return", "the", "surface", "mesh" ]
51873b25d8d46168479989a528db8456af6748f4
https://github.com/akaszynski/pymeshfix/blob/51873b25d8d46168479989a528db8456af6748f4/pymeshfix/meshfix.py#L77-L82
train
akaszynski/pymeshfix
pymeshfix/meshfix.py
MeshFix.plot
def plot(self, show_holes=True): """ Plot the mesh. Parameters ---------- show_holes : bool, optional Shows boundaries. Default True """ if show_holes: edges = self.mesh.extract_edges(boundary_edges=True, ...
python
def plot(self, show_holes=True): """ Plot the mesh. Parameters ---------- show_holes : bool, optional Shows boundaries. Default True """ if show_holes: edges = self.mesh.extract_edges(boundary_edges=True, ...
[ "def", "plot", "(", "self", ",", "show_holes", "=", "True", ")", ":", "if", "show_holes", ":", "edges", "=", "self", ".", "mesh", ".", "extract_edges", "(", "boundary_edges", "=", "True", ",", "feature_edges", "=", "False", ",", "manifold_edges", "=", "F...
Plot the mesh. Parameters ---------- show_holes : bool, optional Shows boundaries. Default True
[ "Plot", "the", "mesh", "." ]
51873b25d8d46168479989a528db8456af6748f4
https://github.com/akaszynski/pymeshfix/blob/51873b25d8d46168479989a528db8456af6748f4/pymeshfix/meshfix.py#L84-L104
train
akaszynski/pymeshfix
pymeshfix/meshfix.py
MeshFix.repair
def repair(self, verbose=False, joincomp=False, remove_smallest_components=True): """Performs mesh repair using MeshFix's default repair process. Parameters ---------- verbose : bool, optional Enables or disables debug printing. Disabled by default. ...
python
def repair(self, verbose=False, joincomp=False, remove_smallest_components=True): """Performs mesh repair using MeshFix's default repair process. Parameters ---------- verbose : bool, optional Enables or disables debug printing. Disabled by default. ...
[ "def", "repair", "(", "self", ",", "verbose", "=", "False", ",", "joincomp", "=", "False", ",", "remove_smallest_components", "=", "True", ")", ":", "assert", "self", ".", "f", ".", "shape", "[", "1", "]", "==", "3", ",", "'Face array must contain three co...
Performs mesh repair using MeshFix's default repair process. Parameters ---------- verbose : bool, optional Enables or disables debug printing. Disabled by default. joincomp : bool, optional Attempts to join nearby open components. remove_small...
[ "Performs", "mesh", "repair", "using", "MeshFix", "s", "default", "repair", "process", "." ]
51873b25d8d46168479989a528db8456af6748f4
https://github.com/akaszynski/pymeshfix/blob/51873b25d8d46168479989a528db8456af6748f4/pymeshfix/meshfix.py#L106-L133
train
akaszynski/pymeshfix
pymeshfix/meshfix.py
MeshFix.write
def write(self, filename, binary=True): """Writes a surface mesh to disk. Written file may be an ASCII or binary ply, stl, or vtk mesh file. Parameters ---------- filename : str Filename of mesh to be written. Filetype is inferred from the exten...
python
def write(self, filename, binary=True): """Writes a surface mesh to disk. Written file may be an ASCII or binary ply, stl, or vtk mesh file. Parameters ---------- filename : str Filename of mesh to be written. Filetype is inferred from the exten...
[ "def", "write", "(", "self", ",", "filename", ",", "binary", "=", "True", ")", ":", "self", ".", "mesh", ".", "write", "(", "filename", ",", "binary", ")" ]
Writes a surface mesh to disk. Written file may be an ASCII or binary ply, stl, or vtk mesh file. Parameters ---------- filename : str Filename of mesh to be written. Filetype is inferred from the extension of the filename unless overridden with ...
[ "Writes", "a", "surface", "mesh", "to", "disk", "." ]
51873b25d8d46168479989a528db8456af6748f4
https://github.com/akaszynski/pymeshfix/blob/51873b25d8d46168479989a528db8456af6748f4/pymeshfix/meshfix.py#L135-L158
train
scraperwiki/scraperwiki-python
scraperwiki/utils.py
scrape
def scrape(url, params=None, user_agent=None): ''' Scrape a URL optionally with parameters. This is effectively a wrapper around urllib2.urlopen. ''' headers = {} if user_agent: headers['User-Agent'] = user_agent data = params and six.moves.urllib.parse.urlencode(params) or None ...
python
def scrape(url, params=None, user_agent=None): ''' Scrape a URL optionally with parameters. This is effectively a wrapper around urllib2.urlopen. ''' headers = {} if user_agent: headers['User-Agent'] = user_agent data = params and six.moves.urllib.parse.urlencode(params) or None ...
[ "def", "scrape", "(", "url", ",", "params", "=", "None", ",", "user_agent", "=", "None", ")", ":", "headers", "=", "{", "}", "if", "user_agent", ":", "headers", "[", "'User-Agent'", "]", "=", "user_agent", "data", "=", "params", "and", "six", ".", "m...
Scrape a URL optionally with parameters. This is effectively a wrapper around urllib2.urlopen.
[ "Scrape", "a", "URL", "optionally", "with", "parameters", ".", "This", "is", "effectively", "a", "wrapper", "around", "urllib2", ".", "urlopen", "." ]
75f77e27071ba667df93e740b61bbb0383ba0843
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/utils.py#L21-L39
train
scraperwiki/scraperwiki-python
scraperwiki/utils.py
pdftoxml
def pdftoxml(pdfdata, options=""): """converts pdf file to xml file""" pdffout = tempfile.NamedTemporaryFile(suffix='.pdf') pdffout.write(pdfdata) pdffout.flush() xmlin = tempfile.NamedTemporaryFile(mode='r', suffix='.xml') tmpxml = xmlin.name # "temph.xml" cmd = 'pdftohtml -xml -nodrm -zo...
python
def pdftoxml(pdfdata, options=""): """converts pdf file to xml file""" pdffout = tempfile.NamedTemporaryFile(suffix='.pdf') pdffout.write(pdfdata) pdffout.flush() xmlin = tempfile.NamedTemporaryFile(mode='r', suffix='.xml') tmpxml = xmlin.name # "temph.xml" cmd = 'pdftohtml -xml -nodrm -zo...
[ "def", "pdftoxml", "(", "pdfdata", ",", "options", "=", "\"\"", ")", ":", "pdffout", "=", "tempfile", ".", "NamedTemporaryFile", "(", "suffix", "=", "'.pdf'", ")", "pdffout", ".", "write", "(", "pdfdata", ")", "pdffout", ".", "flush", "(", ")", "xmlin", ...
converts pdf file to xml file
[ "converts", "pdf", "file", "to", "xml", "file" ]
75f77e27071ba667df93e740b61bbb0383ba0843
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/utils.py#L42-L60
train
scraperwiki/scraperwiki-python
scraperwiki/sql.py
execute
def execute(query, data=None): """ Execute an arbitrary SQL query given by query, returning any results as a list of OrderedDicts. A list of values can be supplied as an, additional argument, which will be substituted into question marks in the query. """ connection = _State.connection() ...
python
def execute(query, data=None): """ Execute an arbitrary SQL query given by query, returning any results as a list of OrderedDicts. A list of values can be supplied as an, additional argument, which will be substituted into question marks in the query. """ connection = _State.connection() ...
[ "def", "execute", "(", "query", ",", "data", "=", "None", ")", ":", "connection", "=", "_State", ".", "connection", "(", ")", "_State", ".", "new_transaction", "(", ")", "if", "data", "is", "None", ":", "data", "=", "[", "]", "result", "=", "connecti...
Execute an arbitrary SQL query given by query, returning any results as a list of OrderedDicts. A list of values can be supplied as an, additional argument, which will be substituted into question marks in the query.
[ "Execute", "an", "arbitrary", "SQL", "query", "given", "by", "query", "returning", "any", "results", "as", "a", "list", "of", "OrderedDicts", ".", "A", "list", "of", "values", "can", "be", "supplied", "as", "an", "additional", "argument", "which", "will", ...
75f77e27071ba667df93e740b61bbb0383ba0843
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L134-L159
train
scraperwiki/scraperwiki-python
scraperwiki/sql.py
select
def select(query, data=None): """ Perform a sql select statement with the given query (without 'select') and return any results as a list of OrderedDicts. """ connection = _State.connection() _State.new_transaction() if data is None: data = [] result = connection.execute('select...
python
def select(query, data=None): """ Perform a sql select statement with the given query (without 'select') and return any results as a list of OrderedDicts. """ connection = _State.connection() _State.new_transaction() if data is None: data = [] result = connection.execute('select...
[ "def", "select", "(", "query", ",", "data", "=", "None", ")", ":", "connection", "=", "_State", ".", "connection", "(", ")", "_State", ".", "new_transaction", "(", ")", "if", "data", "is", "None", ":", "data", "=", "[", "]", "result", "=", "connectio...
Perform a sql select statement with the given query (without 'select') and return any results as a list of OrderedDicts.
[ "Perform", "a", "sql", "select", "statement", "with", "the", "given", "query", "(", "without", "select", ")", "and", "return", "any", "results", "as", "a", "list", "of", "OrderedDicts", "." ]
75f77e27071ba667df93e740b61bbb0383ba0843
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L162-L178
train
scraperwiki/scraperwiki-python
scraperwiki/sql.py
save
def save(unique_keys, data, table_name='swdata'): """ Save the given data to the table specified by `table_name` (which defaults to 'swdata'). The data must be a mapping or an iterable of mappings. Unique keys is a list of keys that exist for all rows and for which a unique index will be created. ...
python
def save(unique_keys, data, table_name='swdata'): """ Save the given data to the table specified by `table_name` (which defaults to 'swdata'). The data must be a mapping or an iterable of mappings. Unique keys is a list of keys that exist for all rows and for which a unique index will be created. ...
[ "def", "save", "(", "unique_keys", ",", "data", ",", "table_name", "=", "'swdata'", ")", ":", "_set_table", "(", "table_name", ")", "connection", "=", "_State", ".", "connection", "(", ")", "if", "isinstance", "(", "data", ",", "Mapping", ")", ":", "# Is...
Save the given data to the table specified by `table_name` (which defaults to 'swdata'). The data must be a mapping or an iterable of mappings. Unique keys is a list of keys that exist for all rows and for which a unique index will be created.
[ "Save", "the", "given", "data", "to", "the", "table", "specified", "by", "table_name", "(", "which", "defaults", "to", "swdata", ")", ".", "The", "data", "must", "be", "a", "mapping", "or", "an", "iterable", "of", "mappings", ".", "Unique", "keys", "is",...
75f77e27071ba667df93e740b61bbb0383ba0843
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L181-L207
train
scraperwiki/scraperwiki-python
scraperwiki/sql.py
_set_table
def _set_table(table_name): """ Specify the table to work on. """ _State.connection() _State.reflect_metadata() _State.table = sqlalchemy.Table(table_name, _State.metadata, extend_existing=True) if list(_State.table.columns.keys()) == []: _State.t...
python
def _set_table(table_name): """ Specify the table to work on. """ _State.connection() _State.reflect_metadata() _State.table = sqlalchemy.Table(table_name, _State.metadata, extend_existing=True) if list(_State.table.columns.keys()) == []: _State.t...
[ "def", "_set_table", "(", "table_name", ")", ":", "_State", ".", "connection", "(", ")", "_State", ".", "reflect_metadata", "(", ")", "_State", ".", "table", "=", "sqlalchemy", ".", "Table", "(", "table_name", ",", "_State", ".", "metadata", ",", "extend_e...
Specify the table to work on.
[ "Specify", "the", "table", "to", "work", "on", "." ]
75f77e27071ba667df93e740b61bbb0383ba0843
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L210-L222
train
scraperwiki/scraperwiki-python
scraperwiki/sql.py
show_tables
def show_tables(): """ Return the names of the tables currently in the database. """ _State.connection() _State.reflect_metadata() metadata = _State.metadata response = select('name, sql from sqlite_master where type="table"') return {row['name']: row['sql'] for row in response}
python
def show_tables(): """ Return the names of the tables currently in the database. """ _State.connection() _State.reflect_metadata() metadata = _State.metadata response = select('name, sql from sqlite_master where type="table"') return {row['name']: row['sql'] for row in response}
[ "def", "show_tables", "(", ")", ":", "_State", ".", "connection", "(", ")", "_State", ".", "reflect_metadata", "(", ")", "metadata", "=", "_State", ".", "metadata", "response", "=", "select", "(", "'name, sql from sqlite_master where type=\"table\"'", ")", "return...
Return the names of the tables currently in the database.
[ "Return", "the", "names", "of", "the", "tables", "currently", "in", "the", "database", "." ]
75f77e27071ba667df93e740b61bbb0383ba0843
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L225-L235
train
scraperwiki/scraperwiki-python
scraperwiki/sql.py
save_var
def save_var(name, value): """ Save a variable to the table specified by _State.vars_table_name. Key is the name of the variable, and value is the value. """ connection = _State.connection() _State.reflect_metadata() vars_table = sqlalchemy.Table( _State.vars_table_name, _State.meta...
python
def save_var(name, value): """ Save a variable to the table specified by _State.vars_table_name. Key is the name of the variable, and value is the value. """ connection = _State.connection() _State.reflect_metadata() vars_table = sqlalchemy.Table( _State.vars_table_name, _State.meta...
[ "def", "save_var", "(", "name", ",", "value", ")", ":", "connection", "=", "_State", ".", "connection", "(", ")", "_State", ".", "reflect_metadata", "(", ")", "vars_table", "=", "sqlalchemy", ".", "Table", "(", "_State", ".", "vars_table_name", ",", "_Stat...
Save a variable to the table specified by _State.vars_table_name. Key is the name of the variable, and value is the value.
[ "Save", "a", "variable", "to", "the", "table", "specified", "by", "_State", ".", "vars_table_name", ".", "Key", "is", "the", "name", "of", "the", "variable", "and", "value", "is", "the", "value", "." ]
75f77e27071ba667df93e740b61bbb0383ba0843
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L238-L268
train
scraperwiki/scraperwiki-python
scraperwiki/sql.py
get_var
def get_var(name, default=None): """ Returns the variable with the provided key from the table specified by _State.vars_table_name. """ alchemytypes = {"text": lambda x: x.decode('utf-8'), "big_integer": lambda x: int(x), "date": lambda x: x.decode('utf-8'), ...
python
def get_var(name, default=None): """ Returns the variable with the provided key from the table specified by _State.vars_table_name. """ alchemytypes = {"text": lambda x: x.decode('utf-8'), "big_integer": lambda x: int(x), "date": lambda x: x.decode('utf-8'), ...
[ "def", "get_var", "(", "name", ",", "default", "=", "None", ")", ":", "alchemytypes", "=", "{", "\"text\"", ":", "lambda", "x", ":", "x", ".", "decode", "(", "'utf-8'", ")", ",", "\"big_integer\"", ":", "lambda", "x", ":", "int", "(", "x", ")", ","...
Returns the variable with the provided key from the table specified by _State.vars_table_name.
[ "Returns", "the", "variable", "with", "the", "provided", "key", "from", "the", "table", "specified", "by", "_State", ".", "vars_table_name", "." ]
75f77e27071ba667df93e740b61bbb0383ba0843
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L271-L306
train
scraperwiki/scraperwiki-python
scraperwiki/sql.py
create_index
def create_index(column_names, unique=False): """ Create a new index of the columns in column_names, where column_names is a list of strings. If unique is True, it will be a unique index. """ connection = _State.connection() _State.reflect_metadata() table_name = _State.table.name t...
python
def create_index(column_names, unique=False): """ Create a new index of the columns in column_names, where column_names is a list of strings. If unique is True, it will be a unique index. """ connection = _State.connection() _State.reflect_metadata() table_name = _State.table.name t...
[ "def", "create_index", "(", "column_names", ",", "unique", "=", "False", ")", ":", "connection", "=", "_State", ".", "connection", "(", ")", "_State", ".", "reflect_metadata", "(", ")", "table_name", "=", "_State", ".", "table", ".", "name", "table", "=", ...
Create a new index of the columns in column_names, where column_names is a list of strings. If unique is True, it will be a unique index.
[ "Create", "a", "new", "index", "of", "the", "columns", "in", "column_names", "where", "column_names", "is", "a", "list", "of", "strings", ".", "If", "unique", "is", "True", "it", "will", "be", "a", "unique", "index", "." ]
75f77e27071ba667df93e740b61bbb0383ba0843
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L309-L335
train
scraperwiki/scraperwiki-python
scraperwiki/sql.py
fit_row
def fit_row(connection, row, unique_keys): """ Takes a row and checks to make sure it fits in the columns of the current table. If it does not fit, adds the required columns. """ new_columns = [] for column_name, column_value in list(row.items()): new_column = sqlalchemy.Column(column_na...
python
def fit_row(connection, row, unique_keys): """ Takes a row and checks to make sure it fits in the columns of the current table. If it does not fit, adds the required columns. """ new_columns = [] for column_name, column_value in list(row.items()): new_column = sqlalchemy.Column(column_na...
[ "def", "fit_row", "(", "connection", ",", "row", ",", "unique_keys", ")", ":", "new_columns", "=", "[", "]", "for", "column_name", ",", "column_value", "in", "list", "(", "row", ".", "items", "(", ")", ")", ":", "new_column", "=", "sqlalchemy", ".", "C...
Takes a row and checks to make sure it fits in the columns of the current table. If it does not fit, adds the required columns.
[ "Takes", "a", "row", "and", "checks", "to", "make", "sure", "it", "fits", "in", "the", "columns", "of", "the", "current", "table", ".", "If", "it", "does", "not", "fit", "adds", "the", "required", "columns", "." ]
75f77e27071ba667df93e740b61bbb0383ba0843
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L338-L357
train
scraperwiki/scraperwiki-python
scraperwiki/sql.py
create_table
def create_table(unique_keys): """ Save the table currently waiting to be created. """ _State.new_transaction() _State.table.create(bind=_State.engine, checkfirst=True) if unique_keys != []: create_index(unique_keys, unique=True) _State.table_pending = False _State.reflect_metada...
python
def create_table(unique_keys): """ Save the table currently waiting to be created. """ _State.new_transaction() _State.table.create(bind=_State.engine, checkfirst=True) if unique_keys != []: create_index(unique_keys, unique=True) _State.table_pending = False _State.reflect_metada...
[ "def", "create_table", "(", "unique_keys", ")", ":", "_State", ".", "new_transaction", "(", ")", "_State", ".", "table", ".", "create", "(", "bind", "=", "_State", ".", "engine", ",", "checkfirst", "=", "True", ")", "if", "unique_keys", "!=", "[", "]", ...
Save the table currently waiting to be created.
[ "Save", "the", "table", "currently", "waiting", "to", "be", "created", "." ]
75f77e27071ba667df93e740b61bbb0383ba0843
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L360-L369
train
scraperwiki/scraperwiki-python
scraperwiki/sql.py
add_column
def add_column(connection, column): """ Add a column to the current table. """ stmt = alembic.ddl.base.AddColumn(_State.table.name, column) connection.execute(stmt) _State.reflect_metadata()
python
def add_column(connection, column): """ Add a column to the current table. """ stmt = alembic.ddl.base.AddColumn(_State.table.name, column) connection.execute(stmt) _State.reflect_metadata()
[ "def", "add_column", "(", "connection", ",", "column", ")", ":", "stmt", "=", "alembic", ".", "ddl", ".", "base", ".", "AddColumn", "(", "_State", ".", "table", ".", "name", ",", "column", ")", "connection", ".", "execute", "(", "stmt", ")", "_State", ...
Add a column to the current table.
[ "Add", "a", "column", "to", "the", "current", "table", "." ]
75f77e27071ba667df93e740b61bbb0383ba0843
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L372-L378
train
scraperwiki/scraperwiki-python
scraperwiki/sql.py
drop
def drop(): """ Drop the current table if it exists """ # Ensure the connection is up _State.connection() _State.table.drop(checkfirst=True) _State.metadata.remove(_State.table) _State.table = None _State.new_transaction()
python
def drop(): """ Drop the current table if it exists """ # Ensure the connection is up _State.connection() _State.table.drop(checkfirst=True) _State.metadata.remove(_State.table) _State.table = None _State.new_transaction()
[ "def", "drop", "(", ")", ":", "# Ensure the connection is up", "_State", ".", "connection", "(", ")", "_State", ".", "table", ".", "drop", "(", "checkfirst", "=", "True", ")", "_State", ".", "metadata", ".", "remove", "(", "_State", ".", "table", ")", "_...
Drop the current table if it exists
[ "Drop", "the", "current", "table", "if", "it", "exists" ]
75f77e27071ba667df93e740b61bbb0383ba0843
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L394-L403
train
tomduck/pandoc-tablenos
pandoc_tablenos.py
attach_attrs_table
def attach_attrs_table(key, value, fmt, meta): """Extracts attributes and attaches them to element.""" # We can't use attach_attrs_factory() because Table is a block-level element if key in ['Table']: assert len(value) == 5 caption = value[0] # caption, align, x, head, body # Set ...
python
def attach_attrs_table(key, value, fmt, meta): """Extracts attributes and attaches them to element.""" # We can't use attach_attrs_factory() because Table is a block-level element if key in ['Table']: assert len(value) == 5 caption = value[0] # caption, align, x, head, body # Set ...
[ "def", "attach_attrs_table", "(", "key", ",", "value", ",", "fmt", ",", "meta", ")", ":", "# We can't use attach_attrs_factory() because Table is a block-level element", "if", "key", "in", "[", "'Table'", "]", ":", "assert", "len", "(", "value", ")", "==", "5", ...
Extracts attributes and attaches them to element.
[ "Extracts", "attributes", "and", "attaches", "them", "to", "element", "." ]
b3c7b6a259eec5fb7c8420033d05b32640f1f266
https://github.com/tomduck/pandoc-tablenos/blob/b3c7b6a259eec5fb7c8420033d05b32640f1f266/pandoc_tablenos.py#L89-L107
train
tomduck/pandoc-tablenos
pandoc_tablenos.py
process_tables
def process_tables(key, value, fmt, meta): """Processes the attributed tables.""" global has_unnumbered_tables # pylint: disable=global-statement # Process block-level Table elements if key == 'Table': # Inspect the table if len(value) == 5: # Unattributed, bail out has_...
python
def process_tables(key, value, fmt, meta): """Processes the attributed tables.""" global has_unnumbered_tables # pylint: disable=global-statement # Process block-level Table elements if key == 'Table': # Inspect the table if len(value) == 5: # Unattributed, bail out has_...
[ "def", "process_tables", "(", "key", ",", "value", ",", "fmt", ",", "meta", ")", ":", "global", "has_unnumbered_tables", "# pylint: disable=global-statement", "# Process block-level Table elements", "if", "key", "==", "'Table'", ":", "# Inspect the table", "if", "len", ...
Processes the attributed tables.
[ "Processes", "the", "attributed", "tables", "." ]
b3c7b6a259eec5fb7c8420033d05b32640f1f266
https://github.com/tomduck/pandoc-tablenos/blob/b3c7b6a259eec5fb7c8420033d05b32640f1f266/pandoc_tablenos.py#L195-L249
train
tomduck/pandoc-tablenos
pandoc_tablenos.py
main
def main(): """Filters the document AST.""" # pylint: disable=global-statement global PANDOCVERSION global AttrTable # Get the output format and document fmt = args.fmt doc = json.loads(STDIN.read()) # Initialize pandocxnos # pylint: disable=too-many-function-args PANDOCVERSIO...
python
def main(): """Filters the document AST.""" # pylint: disable=global-statement global PANDOCVERSION global AttrTable # Get the output format and document fmt = args.fmt doc = json.loads(STDIN.read()) # Initialize pandocxnos # pylint: disable=too-many-function-args PANDOCVERSIO...
[ "def", "main", "(", ")", ":", "# pylint: disable=global-statement", "global", "PANDOCVERSION", "global", "AttrTable", "# Get the output format and document", "fmt", "=", "args", ".", "fmt", "doc", "=", "json", ".", "loads", "(", "STDIN", ".", "read", "(", ")", "...
Filters the document AST.
[ "Filters", "the", "document", "AST", "." ]
b3c7b6a259eec5fb7c8420033d05b32640f1f266
https://github.com/tomduck/pandoc-tablenos/blob/b3c7b6a259eec5fb7c8420033d05b32640f1f266/pandoc_tablenos.py#L368-L441
train
mediaburst/clockwork-python
clockwork/clockwork_http.py
request
def request(url, xml): """Make a http request to clockwork, using the XML provided Sets sensible headers for the request. If there is a problem with the http connection a clockwork_exceptions.HttpException is raised """ r = _urllib.Request(url, xml) r.add_header('Content-Type'...
python
def request(url, xml): """Make a http request to clockwork, using the XML provided Sets sensible headers for the request. If there is a problem with the http connection a clockwork_exceptions.HttpException is raised """ r = _urllib.Request(url, xml) r.add_header('Content-Type'...
[ "def", "request", "(", "url", ",", "xml", ")", ":", "r", "=", "_urllib", ".", "Request", "(", "url", ",", "xml", ")", "r", ".", "add_header", "(", "'Content-Type'", ",", "'application/xml'", ")", "r", ".", "add_header", "(", "'User-Agent'", ",", "'Cloc...
Make a http request to clockwork, using the XML provided Sets sensible headers for the request. If there is a problem with the http connection a clockwork_exceptions.HttpException is raised
[ "Make", "a", "http", "request", "to", "clockwork", "using", "the", "XML", "provided", "Sets", "sensible", "headers", "for", "the", "request", ".", "If", "there", "is", "a", "problem", "with", "the", "http", "connection", "a", "clockwork_exceptions", ".", "Ht...
7f8368bbed1fcb5218584fbc5094d93c6aa365d1
https://github.com/mediaburst/clockwork-python/blob/7f8368bbed1fcb5218584fbc5094d93c6aa365d1/clockwork/clockwork_http.py#L11-L44
train
mediaburst/clockwork-python
clockwork/clockwork.py
API.get_balance
def get_balance(self): """Check the balance fot this account. Returns a dictionary containing: account_type: The account type balance: The balance remaining on the account currency: The currency used for the account balance. Assume GBP in not set""" xml_root ...
python
def get_balance(self): """Check the balance fot this account. Returns a dictionary containing: account_type: The account type balance: The balance remaining on the account currency: The currency used for the account balance. Assume GBP in not set""" xml_root ...
[ "def", "get_balance", "(", "self", ")", ":", "xml_root", "=", "self", ".", "__init_xml", "(", "'Balance'", ")", "response", "=", "clockwork_http", ".", "request", "(", "BALANCE_URL", ",", "etree", ".", "tostring", "(", "xml_root", ",", "encoding", "=", "'u...
Check the balance fot this account. Returns a dictionary containing: account_type: The account type balance: The balance remaining on the account currency: The currency used for the account balance. Assume GBP in not set
[ "Check", "the", "balance", "fot", "this", "account", ".", "Returns", "a", "dictionary", "containing", ":", "account_type", ":", "The", "account", "type", "balance", ":", "The", "balance", "remaining", "on", "the", "account", "currency", ":", "The", "currency",...
7f8368bbed1fcb5218584fbc5094d93c6aa365d1
https://github.com/mediaburst/clockwork-python/blob/7f8368bbed1fcb5218584fbc5094d93c6aa365d1/clockwork/clockwork.py#L47-L67
train
mediaburst/clockwork-python
clockwork/clockwork.py
API.send
def send(self, messages): """Send a SMS message, or an array of SMS messages""" tmpSms = SMS(to='', message='') if str(type(messages)) == str(type(tmpSms)): messages = [messages] xml_root = self.__init_xml('Message') wrapper_id = 0 for m in messages: ...
python
def send(self, messages): """Send a SMS message, or an array of SMS messages""" tmpSms = SMS(to='', message='') if str(type(messages)) == str(type(tmpSms)): messages = [messages] xml_root = self.__init_xml('Message') wrapper_id = 0 for m in messages: ...
[ "def", "send", "(", "self", ",", "messages", ")", ":", "tmpSms", "=", "SMS", "(", "to", "=", "''", ",", "message", "=", "''", ")", "if", "str", "(", "type", "(", "messages", ")", ")", "==", "str", "(", "type", "(", "tmpSms", ")", ")", ":", "m...
Send a SMS message, or an array of SMS messages
[ "Send", "a", "SMS", "message", "or", "an", "array", "of", "SMS", "messages" ]
7f8368bbed1fcb5218584fbc5094d93c6aa365d1
https://github.com/mediaburst/clockwork-python/blob/7f8368bbed1fcb5218584fbc5094d93c6aa365d1/clockwork/clockwork.py#L69-L115
train
mediaburst/clockwork-python
clockwork/clockwork.py
API.__init_xml
def __init_xml(self, rootElementTag): """Init a etree element and pop a key in there""" xml_root = etree.Element(rootElementTag) key = etree.SubElement(xml_root, "Key") key.text = self.apikey return xml_root
python
def __init_xml(self, rootElementTag): """Init a etree element and pop a key in there""" xml_root = etree.Element(rootElementTag) key = etree.SubElement(xml_root, "Key") key.text = self.apikey return xml_root
[ "def", "__init_xml", "(", "self", ",", "rootElementTag", ")", ":", "xml_root", "=", "etree", ".", "Element", "(", "rootElementTag", ")", "key", "=", "etree", ".", "SubElement", "(", "xml_root", ",", "\"Key\"", ")", "key", ".", "text", "=", "self", ".", ...
Init a etree element and pop a key in there
[ "Init", "a", "etree", "element", "and", "pop", "a", "key", "in", "there" ]
7f8368bbed1fcb5218584fbc5094d93c6aa365d1
https://github.com/mediaburst/clockwork-python/blob/7f8368bbed1fcb5218584fbc5094d93c6aa365d1/clockwork/clockwork.py#L117-L122
train
mediaburst/clockwork-python
clockwork/clockwork.py
API.__build_sms_data
def __build_sms_data(self, message): """Build a dictionary of SMS message elements""" attributes = {} attributes_to_translate = { 'to' : 'To', 'message' : 'Content', 'client_id' : 'ClientID', 'concat' : 'Concat', 'from_name': 'From', ...
python
def __build_sms_data(self, message): """Build a dictionary of SMS message elements""" attributes = {} attributes_to_translate = { 'to' : 'To', 'message' : 'Content', 'client_id' : 'ClientID', 'concat' : 'Concat', 'from_name': 'From', ...
[ "def", "__build_sms_data", "(", "self", ",", "message", ")", ":", "attributes", "=", "{", "}", "attributes_to_translate", "=", "{", "'to'", ":", "'To'", ",", "'message'", ":", "'Content'", ",", "'client_id'", ":", "'ClientID'", ",", "'concat'", ":", "'Concat...
Build a dictionary of SMS message elements
[ "Build", "a", "dictionary", "of", "SMS", "message", "elements" ]
7f8368bbed1fcb5218584fbc5094d93c6aa365d1
https://github.com/mediaburst/clockwork-python/blob/7f8368bbed1fcb5218584fbc5094d93c6aa365d1/clockwork/clockwork.py#L125-L150
train
pwaller/pyprof2calltree
pyprof2calltree.py
pstats2entries
def pstats2entries(data): """Helper to convert serialized pstats back to a list of raw entries. Converse operation of cProfile.Profile.snapshot_stats() """ # Each entry's key is a tuple of (filename, line number, function name) entries = {} allcallers = {} # first pass over stats to build ...
python
def pstats2entries(data): """Helper to convert serialized pstats back to a list of raw entries. Converse operation of cProfile.Profile.snapshot_stats() """ # Each entry's key is a tuple of (filename, line number, function name) entries = {} allcallers = {} # first pass over stats to build ...
[ "def", "pstats2entries", "(", "data", ")", ":", "# Each entry's key is a tuple of (filename, line number, function name)", "entries", "=", "{", "}", "allcallers", "=", "{", "}", "# first pass over stats to build the list of entry instances", "for", "code_info", ",", "call_info"...
Helper to convert serialized pstats back to a list of raw entries. Converse operation of cProfile.Profile.snapshot_stats()
[ "Helper", "to", "convert", "serialized", "pstats", "back", "to", "a", "list", "of", "raw", "entries", "." ]
62b99c7b366ad317d3d5e21fb73466c8baea670e
https://github.com/pwaller/pyprof2calltree/blob/62b99c7b366ad317d3d5e21fb73466c8baea670e/pyprof2calltree.py#L106-L141
train
pwaller/pyprof2calltree
pyprof2calltree.py
is_installed
def is_installed(prog): """Return whether or not a given executable is installed on the machine.""" with open(os.devnull, 'w') as devnull: try: if os.name == 'nt': retcode = subprocess.call(['where', prog], stdout=devnull) else: retcode = subproces...
python
def is_installed(prog): """Return whether or not a given executable is installed on the machine.""" with open(os.devnull, 'w') as devnull: try: if os.name == 'nt': retcode = subprocess.call(['where', prog], stdout=devnull) else: retcode = subproces...
[ "def", "is_installed", "(", "prog", ")", ":", "with", "open", "(", "os", ".", "devnull", ",", "'w'", ")", "as", "devnull", ":", "try", ":", "if", "os", ".", "name", "==", "'nt'", ":", "retcode", "=", "subprocess", ".", "call", "(", "[", "'where'", ...
Return whether or not a given executable is installed on the machine.
[ "Return", "whether", "or", "not", "a", "given", "executable", "is", "installed", "on", "the", "machine", "." ]
62b99c7b366ad317d3d5e21fb73466c8baea670e
https://github.com/pwaller/pyprof2calltree/blob/62b99c7b366ad317d3d5e21fb73466c8baea670e/pyprof2calltree.py#L144-L159
train
pwaller/pyprof2calltree
pyprof2calltree.py
main
def main(): """Execute the converter using parameters provided on the command line""" parser = argparse.ArgumentParser() parser.add_argument('-o', '--outfile', metavar='output_file_path', help="Save calltree stats to <outfile>") parser.add_argument('-i', '--infile', metavar='inp...
python
def main(): """Execute the converter using parameters provided on the command line""" parser = argparse.ArgumentParser() parser.add_argument('-o', '--outfile', metavar='output_file_path', help="Save calltree stats to <outfile>") parser.add_argument('-i', '--infile', metavar='inp...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'-o'", ",", "'--outfile'", ",", "metavar", "=", "'output_file_path'", ",", "help", "=", "\"Save calltree stats to <outfile>\"", ")", ...
Execute the converter using parameters provided on the command line
[ "Execute", "the", "converter", "using", "parameters", "provided", "on", "the", "command", "line" ]
62b99c7b366ad317d3d5e21fb73466c8baea670e
https://github.com/pwaller/pyprof2calltree/blob/62b99c7b366ad317d3d5e21fb73466c8baea670e/pyprof2calltree.py#L289-L355
train
pwaller/pyprof2calltree
pyprof2calltree.py
convert
def convert(profiling_data, outputfile): """convert `profiling_data` to calltree format and dump it to `outputfile` `profiling_data` can either be: - a pstats.Stats instance - the filename of a pstats.Stats dump - the result of a call to cProfile.Profile.getstats() `outputfile` can...
python
def convert(profiling_data, outputfile): """convert `profiling_data` to calltree format and dump it to `outputfile` `profiling_data` can either be: - a pstats.Stats instance - the filename of a pstats.Stats dump - the result of a call to cProfile.Profile.getstats() `outputfile` can...
[ "def", "convert", "(", "profiling_data", ",", "outputfile", ")", ":", "converter", "=", "CalltreeConverter", "(", "profiling_data", ")", "if", "is_basestring", "(", "outputfile", ")", ":", "with", "open", "(", "outputfile", ",", "\"w\"", ")", "as", "f", ":",...
convert `profiling_data` to calltree format and dump it to `outputfile` `profiling_data` can either be: - a pstats.Stats instance - the filename of a pstats.Stats dump - the result of a call to cProfile.Profile.getstats() `outputfile` can either be: - a file() instance open in ...
[ "convert", "profiling_data", "to", "calltree", "format", "and", "dump", "it", "to", "outputfile" ]
62b99c7b366ad317d3d5e21fb73466c8baea670e
https://github.com/pwaller/pyprof2calltree/blob/62b99c7b366ad317d3d5e21fb73466c8baea670e/pyprof2calltree.py#L370-L387
train
pwaller/pyprof2calltree
pyprof2calltree.py
CalltreeConverter.output
def output(self, out_file): """Write the converted entries to out_file""" self.out_file = out_file out_file.write('event: ns : Nanoseconds\n') out_file.write('events: ns\n') self._output_summary() for entry in sorted(self.entries, key=_entry_sort_key): self._o...
python
def output(self, out_file): """Write the converted entries to out_file""" self.out_file = out_file out_file.write('event: ns : Nanoseconds\n') out_file.write('events: ns\n') self._output_summary() for entry in sorted(self.entries, key=_entry_sort_key): self._o...
[ "def", "output", "(", "self", ",", "out_file", ")", ":", "self", ".", "out_file", "=", "out_file", "out_file", ".", "write", "(", "'event: ns : Nanoseconds\\n'", ")", "out_file", ".", "write", "(", "'events: ns\\n'", ")", "self", ".", "_output_summary", "(", ...
Write the converted entries to out_file
[ "Write", "the", "converted", "entries", "to", "out_file" ]
62b99c7b366ad317d3d5e21fb73466c8baea670e
https://github.com/pwaller/pyprof2calltree/blob/62b99c7b366ad317d3d5e21fb73466c8baea670e/pyprof2calltree.py#L204-L211
train
pwaller/pyprof2calltree
pyprof2calltree.py
CalltreeConverter.visualize
def visualize(self): """Launch kcachegrind on the converted entries. One of the executables listed in KCACHEGRIND_EXECUTABLES must be present in the system path. """ available_cmd = None for cmd in KCACHEGRIND_EXECUTABLES: if is_installed(cmd): ...
python
def visualize(self): """Launch kcachegrind on the converted entries. One of the executables listed in KCACHEGRIND_EXECUTABLES must be present in the system path. """ available_cmd = None for cmd in KCACHEGRIND_EXECUTABLES: if is_installed(cmd): ...
[ "def", "visualize", "(", "self", ")", ":", "available_cmd", "=", "None", "for", "cmd", "in", "KCACHEGRIND_EXECUTABLES", ":", "if", "is_installed", "(", "cmd", ")", ":", "available_cmd", "=", "cmd", "break", "if", "available_cmd", "is", "None", ":", "sys", ...
Launch kcachegrind on the converted entries. One of the executables listed in KCACHEGRIND_EXECUTABLES must be present in the system path.
[ "Launch", "kcachegrind", "on", "the", "converted", "entries", "." ]
62b99c7b366ad317d3d5e21fb73466c8baea670e
https://github.com/pwaller/pyprof2calltree/blob/62b99c7b366ad317d3d5e21fb73466c8baea670e/pyprof2calltree.py#L213-L247
train
bouncer-app/flask-bouncer
flask_bouncer.py
Bouncer.get_app
def get_app(self, reference_app=None): """Helper method that implements the logic to look up an application.""" if reference_app is not None: return reference_app if self.app is not None: return self.app ctx = stack.top if ctx is not None: ...
python
def get_app(self, reference_app=None): """Helper method that implements the logic to look up an application.""" if reference_app is not None: return reference_app if self.app is not None: return self.app ctx = stack.top if ctx is not None: ...
[ "def", "get_app", "(", "self", ",", "reference_app", "=", "None", ")", ":", "if", "reference_app", "is", "not", "None", ":", "return", "reference_app", "if", "self", ".", "app", "is", "not", "None", ":", "return", "self", ".", "app", "ctx", "=", "stack...
Helper method that implements the logic to look up an application.
[ "Helper", "method", "that", "implements", "the", "logic", "to", "look", "up", "an", "application", "." ]
41a8763520cca7d7ff1b247ab6eb3383281f5ab7
https://github.com/bouncer-app/flask-bouncer/blob/41a8763520cca7d7ff1b247ab6eb3383281f5ab7/flask_bouncer.py#L80-L96
train
bouncer-app/flask-bouncer
flask_bouncer.py
Bouncer.init_app
def init_app(self, app, **kwargs): """ Initializes the Flask-Bouncer extension for the specified application. :param app: The application. """ self.app = app self._init_extension() self.app.before_request(self.check_implicit_rules) if kwargs.get('ensure_author...
python
def init_app(self, app, **kwargs): """ Initializes the Flask-Bouncer extension for the specified application. :param app: The application. """ self.app = app self._init_extension() self.app.before_request(self.check_implicit_rules) if kwargs.get('ensure_author...
[ "def", "init_app", "(", "self", ",", "app", ",", "*", "*", "kwargs", ")", ":", "self", ".", "app", "=", "app", "self", ".", "_init_extension", "(", ")", "self", ".", "app", ".", "before_request", "(", "self", ".", "check_implicit_rules", ")", "if", "...
Initializes the Flask-Bouncer extension for the specified application. :param app: The application.
[ "Initializes", "the", "Flask", "-", "Bouncer", "extension", "for", "the", "specified", "application", "." ]
41a8763520cca7d7ff1b247ab6eb3383281f5ab7
https://github.com/bouncer-app/flask-bouncer/blob/41a8763520cca7d7ff1b247ab6eb3383281f5ab7/flask_bouncer.py#L98-L110
train
bouncer-app/flask-bouncer
flask_bouncer.py
Bouncer.check_authorization
def check_authorization(self, response): """checks that an authorization call has been made during the request""" if not hasattr(request, '_authorized'): raise Unauthorized elif not request._authorized: raise Unauthorized return response
python
def check_authorization(self, response): """checks that an authorization call has been made during the request""" if not hasattr(request, '_authorized'): raise Unauthorized elif not request._authorized: raise Unauthorized return response
[ "def", "check_authorization", "(", "self", ",", "response", ")", ":", "if", "not", "hasattr", "(", "request", ",", "'_authorized'", ")", ":", "raise", "Unauthorized", "elif", "not", "request", ".", "_authorized", ":", "raise", "Unauthorized", "return", "respon...
checks that an authorization call has been made during the request
[ "checks", "that", "an", "authorization", "call", "has", "been", "made", "during", "the", "request" ]
41a8763520cca7d7ff1b247ab6eb3383281f5ab7
https://github.com/bouncer-app/flask-bouncer/blob/41a8763520cca7d7ff1b247ab6eb3383281f5ab7/flask_bouncer.py#L118-L124
train
bouncer-app/flask-bouncer
flask_bouncer.py
Bouncer.check_implicit_rules
def check_implicit_rules(self): """ if you are using flask classy are using the standard index,new,put,post, etc ... type routes, we will automatically check the permissions for you """ if not self.request_is_managed_by_flask_classy(): return if self.method_is_ex...
python
def check_implicit_rules(self): """ if you are using flask classy are using the standard index,new,put,post, etc ... type routes, we will automatically check the permissions for you """ if not self.request_is_managed_by_flask_classy(): return if self.method_is_ex...
[ "def", "check_implicit_rules", "(", "self", ")", ":", "if", "not", "self", ".", "request_is_managed_by_flask_classy", "(", ")", ":", "return", "if", "self", ".", "method_is_explictly_overwritten", "(", ")", ":", "return", "class_name", ",", "action", "=", "reque...
if you are using flask classy are using the standard index,new,put,post, etc ... type routes, we will automatically check the permissions for you
[ "if", "you", "are", "using", "flask", "classy", "are", "using", "the", "standard", "index", "new", "put", "post", "etc", "...", "type", "routes", "we", "will", "automatically", "check", "the", "permissions", "for", "you" ]
41a8763520cca7d7ff1b247ab6eb3383281f5ab7
https://github.com/bouncer-app/flask-bouncer/blob/41a8763520cca7d7ff1b247ab6eb3383281f5ab7/flask_bouncer.py#L126-L138
train
paulgb/penkit
penkit/textures/util.py
rotate_texture
def rotate_texture(texture, rotation, x_offset=0.5, y_offset=0.5): """Rotates the given texture by a given angle. Args: texture (texture): the texture to rotate rotation (float): the angle of rotation in degrees x_offset (float): the x component of the center of rotation (optional) ...
python
def rotate_texture(texture, rotation, x_offset=0.5, y_offset=0.5): """Rotates the given texture by a given angle. Args: texture (texture): the texture to rotate rotation (float): the angle of rotation in degrees x_offset (float): the x component of the center of rotation (optional) ...
[ "def", "rotate_texture", "(", "texture", ",", "rotation", ",", "x_offset", "=", "0.5", ",", "y_offset", "=", "0.5", ")", ":", "x", ",", "y", "=", "texture", "x", "=", "x", ".", "copy", "(", ")", "-", "x_offset", "y", "=", "y", ".", "copy", "(", ...
Rotates the given texture by a given angle. Args: texture (texture): the texture to rotate rotation (float): the angle of rotation in degrees x_offset (float): the x component of the center of rotation (optional) y_offset (float): the y component of the center of rotation (optional)...
[ "Rotates", "the", "given", "texture", "by", "a", "given", "angle", "." ]
da451a30f62cfefbab285b9d6979b8dec3ac4957
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/textures/util.py#L6-L24
train
paulgb/penkit
penkit/textures/util.py
fit_texture
def fit_texture(layer): """Fits a layer into a texture by scaling each axis to (0, 1). Does not preserve aspect ratio (TODO: make this an option). Args: layer (layer): the layer to scale Returns: texture: A texture. """ x, y = layer x = (x - np.nanmin(x)) / (np.nanmax(x) -...
python
def fit_texture(layer): """Fits a layer into a texture by scaling each axis to (0, 1). Does not preserve aspect ratio (TODO: make this an option). Args: layer (layer): the layer to scale Returns: texture: A texture. """ x, y = layer x = (x - np.nanmin(x)) / (np.nanmax(x) -...
[ "def", "fit_texture", "(", "layer", ")", ":", "x", ",", "y", "=", "layer", "x", "=", "(", "x", "-", "np", ".", "nanmin", "(", "x", ")", ")", "/", "(", "np", ".", "nanmax", "(", "x", ")", "-", "np", ".", "nanmin", "(", "x", ")", ")", "y", ...
Fits a layer into a texture by scaling each axis to (0, 1). Does not preserve aspect ratio (TODO: make this an option). Args: layer (layer): the layer to scale Returns: texture: A texture.
[ "Fits", "a", "layer", "into", "a", "texture", "by", "scaling", "each", "axis", "to", "(", "0", "1", ")", "." ]
da451a30f62cfefbab285b9d6979b8dec3ac4957
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/textures/util.py#L27-L41
train
paulgb/penkit
optimizer/penkit_optimize/route_util.py
check_valid_solution
def check_valid_solution(solution, graph): """Check that the solution is valid: every path is visited exactly once.""" expected = Counter( i for (i, _) in graph.iter_starts_with_index() if i < graph.get_disjoint(i) ) actual = Counter( min(i, graph.get_disjoint(i)) for i i...
python
def check_valid_solution(solution, graph): """Check that the solution is valid: every path is visited exactly once.""" expected = Counter( i for (i, _) in graph.iter_starts_with_index() if i < graph.get_disjoint(i) ) actual = Counter( min(i, graph.get_disjoint(i)) for i i...
[ "def", "check_valid_solution", "(", "solution", ",", "graph", ")", ":", "expected", "=", "Counter", "(", "i", "for", "(", "i", ",", "_", ")", "in", "graph", ".", "iter_starts_with_index", "(", ")", "if", "i", "<", "graph", ".", "get_disjoint", "(", "i"...
Check that the solution is valid: every path is visited exactly once.
[ "Check", "that", "the", "solution", "is", "valid", ":", "every", "path", "is", "visited", "exactly", "once", "." ]
da451a30f62cfefbab285b9d6979b8dec3ac4957
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/optimizer/penkit_optimize/route_util.py#L5-L23
train
paulgb/penkit
optimizer/penkit_optimize/route_util.py
get_route_from_solution
def get_route_from_solution(solution, graph): """Converts a solution (a list of node indices) into a list of paths suitable for rendering.""" # As a guard against comparing invalid "solutions", # ensure that this solution is valid. assert check_valid_solution(solution, graph) return [graph.get...
python
def get_route_from_solution(solution, graph): """Converts a solution (a list of node indices) into a list of paths suitable for rendering.""" # As a guard against comparing invalid "solutions", # ensure that this solution is valid. assert check_valid_solution(solution, graph) return [graph.get...
[ "def", "get_route_from_solution", "(", "solution", ",", "graph", ")", ":", "# As a guard against comparing invalid \"solutions\",", "# ensure that this solution is valid.", "assert", "check_valid_solution", "(", "solution", ",", "graph", ")", "return", "[", "graph", ".", "g...
Converts a solution (a list of node indices) into a list of paths suitable for rendering.
[ "Converts", "a", "solution", "(", "a", "list", "of", "node", "indices", ")", "into", "a", "list", "of", "paths", "suitable", "for", "rendering", "." ]
da451a30f62cfefbab285b9d6979b8dec3ac4957
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/optimizer/penkit_optimize/route_util.py#L26-L34
train
paulgb/penkit
penkit/turtle.py
branching_turtle_generator
def branching_turtle_generator(turtle_program, turn_amount=DEFAULT_TURN, initial_angle=DEFAULT_INITIAL_ANGLE, resolution=1): """Given a turtle program, creates a generator of turtle positions. The state of the turtle consists of its position and angle. The turtle starts a...
python
def branching_turtle_generator(turtle_program, turn_amount=DEFAULT_TURN, initial_angle=DEFAULT_INITIAL_ANGLE, resolution=1): """Given a turtle program, creates a generator of turtle positions. The state of the turtle consists of its position and angle. The turtle starts a...
[ "def", "branching_turtle_generator", "(", "turtle_program", ",", "turn_amount", "=", "DEFAULT_TURN", ",", "initial_angle", "=", "DEFAULT_INITIAL_ANGLE", ",", "resolution", "=", "1", ")", ":", "saved_states", "=", "list", "(", ")", "state", "=", "(", "0", ",", ...
Given a turtle program, creates a generator of turtle positions. The state of the turtle consists of its position and angle. The turtle starts at the position ``(0, 0)`` facing up. Each character in the turtle program is processed in order and causes an update to the state. The position component o...
[ "Given", "a", "turtle", "program", "creates", "a", "generator", "of", "turtle", "positions", ".", "The", "state", "of", "the", "turtle", "consists", "of", "its", "position", "and", "angle", ".", "The", "turtle", "starts", "at", "the", "position", "(", "0",...
da451a30f62cfefbab285b9d6979b8dec3ac4957
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/turtle.py#L23-L89
train