sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
def delete(self, *, if_unused=True): """ Delete the exchange. This method is a :ref:`coroutine <coroutine>`. :keyword bool if_unused: If true, the exchange will only be deleted if it has no queues bound to it. """ self.sender.send_ExchangeDelete(self.name, i...
Delete the exchange. This method is a :ref:`coroutine <coroutine>`. :keyword bool if_unused: If true, the exchange will only be deleted if it has no queues bound to it.
entailment
def reject(self, *, requeue=True): """ Reject the message. :keyword bool requeue: if true, the broker will attempt to requeue the message and deliver it to an alternate consumer. """ self.sender.send_BasicReject(self.delivery_tag, requeue)
Reject the message. :keyword bool requeue: if true, the broker will attempt to requeue the message and deliver it to an alternate consumer.
entailment
def declare_exchange(self, name, type, *, durable=True, auto_delete=False, passive=False, internal=False, nowait=False, arguments=None): """ Declare an :class:`Exchange` on the broker. If the exchange does not exist, it will be created. This met...
Declare an :class:`Exchange` on the broker. If the exchange does not exist, it will be created. This method is a :ref:`coroutine <coroutine>`. :param str name: the name of the exchange. :param str type: the type of the exchange (usually one of ``'fanout'``, ``'direct'``, ``'topic'`...
entailment
def declare_queue(self, name='', *, durable=True, exclusive=False, auto_delete=False, passive=False, nowait=False, arguments=None): """ Declare a queue on the broker. If the queue does not exist, it will be created. This method is a :ref:`coroutine <c...
Declare a queue on the broker. If the queue does not exist, it will be created. This method is a :ref:`coroutine <coroutine>`. :param str name: the name of the queue. Supplying a name of '' will create a queue with a unique name of the server's choosing. :keyword bool durable: If t...
entailment
def set_qos(self, prefetch_size=0, prefetch_count=0, apply_globally=False): """ Specify quality of service by requesting that messages be pre-fetched from the server. Pre-fetching means that the server will deliver messages to the client while the client is still processing unacknowledge...
Specify quality of service by requesting that messages be pre-fetched from the server. Pre-fetching means that the server will deliver messages to the client while the client is still processing unacknowledged messages. This method is a :ref:`coroutine <coroutine>`. :param int prefetch...
entailment
def close(self): """ Close the channel by handshaking with the server. This method is a :ref:`coroutine <coroutine>`. """ # If we aren't already closed ask for server to close if not self.is_closed(): self._closing = True # Let the ChannelActor do...
Close the channel by handshaking with the server. This method is a :ref:`coroutine <coroutine>`.
entailment
def handle_ChannelClose(self, frame): """ AMQP server closed the channel with an error """ # By docs: # The response to receiving a Close after sending Close must be to # send Close-Ok. # # No need for additional checks self.sender.send_CloseOK() exc = ex...
AMQP server closed the channel with an error
entailment
def handle_ChannelCloseOK(self, frame): """ AMQP server closed channel as per our request """ assert self.channel._closing, "received a not expected CloseOk" # Release the `close` method's future self.synchroniser.notify(spec.ChannelCloseOK) exc = ChannelClosed() self._c...
AMQP server closed channel as per our request
entailment
def bind(self, exchange, routing_key, *, arguments=None): """ Bind a queue to an exchange, with the supplied routing key. This action 'subscribes' the queue to the routing key; the precise meaning of this varies with the exchange type. This method is a :ref:`coroutine <coroutin...
Bind a queue to an exchange, with the supplied routing key. This action 'subscribes' the queue to the routing key; the precise meaning of this varies with the exchange type. This method is a :ref:`coroutine <coroutine>`. :param asynqp.Exchange exchange: the :class:`Exchange` to bind t...
entailment
def consume(self, callback, *, no_local=False, no_ack=False, exclusive=False, arguments=None): """ Start a consumer on the queue. Messages will be delivered asynchronously to the consumer. The callback function will be called whenever a new message arrives on the queue. Advanced usage: ...
Start a consumer on the queue. Messages will be delivered asynchronously to the consumer. The callback function will be called whenever a new message arrives on the queue. Advanced usage: the callback object must be callable (it must be a function or define a ``__call__`` method), but m...
entailment
def get(self, *, no_ack=False): """ Synchronously get a message from the queue. This method is a :ref:`coroutine <coroutine>`. :keyword bool no_ack: if true, the broker does not require acknowledgement of receipt of the message. :return: an :class:`~asynqp.message.IncomingMess...
Synchronously get a message from the queue. This method is a :ref:`coroutine <coroutine>`. :keyword bool no_ack: if true, the broker does not require acknowledgement of receipt of the message. :return: an :class:`~asynqp.message.IncomingMessage`, or ``None`` if there were no messa...
entailment
def purge(self): """ Purge all undelivered messages from the queue. This method is a :ref:`coroutine <coroutine>`. """ self.sender.send_QueuePurge(self.name) yield from self.synchroniser.wait(spec.QueuePurgeOK) self.reader.ready()
Purge all undelivered messages from the queue. This method is a :ref:`coroutine <coroutine>`.
entailment
def delete(self, *, if_unused=True, if_empty=True): """ Delete the queue. This method is a :ref:`coroutine <coroutine>`. :keyword bool if_unused: If true, the queue will only be deleted if it has no consumers. :keyword bool if_empty: If true, the queue will only be ...
Delete the queue. This method is a :ref:`coroutine <coroutine>`. :keyword bool if_unused: If true, the queue will only be deleted if it has no consumers. :keyword bool if_empty: If true, the queue will only be deleted if it has no unacknowledged messages.
entailment
def unbind(self, arguments=None): """ Unbind the queue from the exchange. This method is a :ref:`coroutine <coroutine>`. """ if self.deleted: raise Deleted("Queue {} was already unbound from exchange {}".format(self.queue.name, self.exchange.name)) self.send...
Unbind the queue from the exchange. This method is a :ref:`coroutine <coroutine>`.
entailment
def cancel(self): """ Cancel the consumer and stop recieving messages. This method is a :ref:`coroutine <coroutine>`. """ self.sender.send_BasicCancel(self.tag) try: yield from self.synchroniser.wait(spec.BasicCancelOK) except AMQPError: p...
Cancel the consumer and stop recieving messages. This method is a :ref:`coroutine <coroutine>`.
entailment
def hello_world(): """ Sends a 'hello world' message and then reads it from the queue. """ # connect to the RabbitMQ broker connection = yield from asynqp.connect('localhost', 5672, username='guest', password='guest') # Open a communications channel channel = yield from connection.open_chan...
Sends a 'hello world' message and then reads it from the queue.
entailment
def killall(self, exc): """ Connection/Channel was closed. All subsequent and ongoing requests should raise an error """ self.connection_exc = exc # Set an exception for all others for method, futs in self._futures.items(): for fut in futs: ...
Connection/Channel was closed. All subsequent and ongoing requests should raise an error
entailment
def connect(host='localhost', port=5672, username='guest', password='guest', virtual_host='/', on_connection_close=None, *, loop=None, sock=None, **kwargs): """ Connect to an AMQP server on the given host and port. Log in to the given virtual host...
Connect to an AMQP server on the given host and port. Log in to the given virtual host using the supplied credentials. This function is a :ref:`coroutine <coroutine>`. :param str host: the host server to connect to. :param int port: the port which the AMQP server is listening on. :param str userna...
entailment
def connect_and_open_channel(host='localhost', port=5672, username='guest', password='guest', virtual_host='/', on_connection_close=None, *, loop=None, **kwargs): """ ...
Connect to an AMQP server and open a channel on the connection. This function is a :ref:`coroutine <coroutine>`. Parameters of this function are the same as :func:`connect`. :return: a tuple of ``(connection, channel)``. Equivalent to:: connection = yield from connect(host, port, username, p...
entailment
def heartbeat_timeout(self): """ Called by heartbeat_monitor on timeout """ assert not self._closed, "Did we not stop heartbeat_monitor on close?" log.error("Heartbeat time out") poison_exc = ConnectionLostError('Heartbeat timed out') poison_frame = frames.PoisonPillFrame(poison_...
Called by heartbeat_monitor on timeout
entailment
def convert_general(value): """Take a python object and convert it to the format Imgur expects.""" if isinstance(value, bool): return "true" if value else "false" elif isinstance(value, list): value = [convert_general(item) for item in value] value = convert_to_imgur_list(value) ...
Take a python object and convert it to the format Imgur expects.
entailment
def to_imgur_format(params): """Convert the parameters to the format Imgur expects.""" if params is None: return None return dict((k, convert_general(val)) for (k, val) in params.items())
Convert the parameters to the format Imgur expects.
entailment
def render(self, name, value, attrs=None, *args, **kwargs): """Handle a few expected values for rendering the current choice. Extracts the state name from StateWrapper and State object. """ if isinstance(value, base.StateWrapper): state_name = value.state.name elif i...
Handle a few expected values for rendering the current choice. Extracts the state name from StateWrapper and State object.
entailment
def contribute_to_class(self, cls, name): """Contribute the state to a Model. Attaches a StateFieldProperty to wrap the attribute. """ super(StateField, self).contribute_to_class(cls, name) parent_property = getattr(cls, self.name, None) setattr(cls, self.name, StateFie...
Contribute the state to a Model. Attaches a StateFieldProperty to wrap the attribute.
entailment
def to_python(self, value): """Converts the DB-stored value into a Python value.""" if isinstance(value, base.StateWrapper): res = value else: if isinstance(value, base.State): state = value elif value is None: state = self.work...
Converts the DB-stored value into a Python value.
entailment
def get_db_prep_value(self, value, connection, prepared=False): """Convert a value to DB storage. Returns the state name. """ if not prepared: value = self.get_prep_value(value) return value.state.name
Convert a value to DB storage. Returns the state name.
entailment
def value_to_string(self, obj): """Convert a field value to a string. Returns the state name. """ statefield = self.to_python(self.value_from_object(obj)) return statefield.state.name
Convert a field value to a string. Returns the state name.
entailment
def validate(self, value, model_instance): """Validate that a given value is a valid option for a given model instance. Args: value (xworkflows.base.StateWrapper): The base.StateWrapper returned by to_python. model_instance: A WorkflowEnabled instance """ if not ...
Validate that a given value is a valid option for a given model instance. Args: value (xworkflows.base.StateWrapper): The base.StateWrapper returned by to_python. model_instance: A WorkflowEnabled instance
entailment
def deconstruct(self): """Deconstruction for migrations. Return a simpler object (_SerializedWorkflow), since our Workflows are rather hard to serialize: Django doesn't like deconstructing metaclass-built classes. """ name, path, args, kwargs = super(StateField, self).de...
Deconstruction for migrations. Return a simpler object (_SerializedWorkflow), since our Workflows are rather hard to serialize: Django doesn't like deconstructing metaclass-built classes.
entailment
def _find_workflows(mcs, attrs): """Find workflow definition(s) in a WorkflowEnabled definition. This method overrides the default behavior from xworkflows in order to use our custom StateField objects. """ workflows = {} for k, v in attrs.items(): if isinsta...
Find workflow definition(s) in a WorkflowEnabled definition. This method overrides the default behavior from xworkflows in order to use our custom StateField objects.
entailment
def _get_log_model_class(self): """Cache for fetching the actual log model object once django is loaded. Otherwise, import conflict occur: WorkflowEnabled imports <log_model> which tries to import all models to retrieve the proper model class. """ if self.log_model_class is not ...
Cache for fetching the actual log model object once django is loaded. Otherwise, import conflict occur: WorkflowEnabled imports <log_model> which tries to import all models to retrieve the proper model class.
entailment
def db_log(self, transition, from_state, instance, *args, **kwargs): """Logs the transition into the database.""" if self.log_model: model_class = self._get_log_model_class() extras = {} for db_field, transition_arg, default in model_class.EXTRA_LOG_ATTRIBUTES: ...
Logs the transition into the database.
entailment
def log_transition(self, transition, from_state, instance, *args, **kwargs): """Generic transition logging.""" save = kwargs.pop('save', True) log = kwargs.pop('log', True) super(Workflow, self).log_transition( transition, from_state, instance, *args, **kwargs) if sav...
Generic transition logging.
entailment
def clean_readme(fname): """Cleanup README.rst for proper PyPI formatting.""" with codecs.open(fname, 'r', 'utf-8') as f: return ''.join( re.sub(r':\w+:`([^`]+?)( <[^<>]+>)?`', r'``\1``', line) for line in f if not (line.startswith('.. currentmodule') or line.startswi...
Cleanup README.rst for proper PyPI formatting.
entailment
def _get_album_or_image(json, imgur): """Return a gallery image/album depending on what the json represent.""" if json['is_album']: return Gallery_album(json, imgur, has_fetched=False) return Gallery_image(json, imgur)
Return a gallery image/album depending on what the json represent.
entailment
def refresh(self): """ Refresh this objects attributes to the newest values. Attributes that weren't added to the object before, due to lazy loading, will be added by calling refresh. """ resp = self._imgur._send_request(self._INFO_URL) self._populate(resp) ...
Refresh this objects attributes to the newest values. Attributes that weren't added to the object before, due to lazy loading, will be added by calling refresh.
entailment
def add_images(self, images): """ Add images to the album. :param images: A list of the images we want to add to the album. Can be Image objects, ids or a combination of the two. Images that you cannot add (non-existing or not owned by you) will not cause ex...
Add images to the album. :param images: A list of the images we want to add to the album. Can be Image objects, ids or a combination of the two. Images that you cannot add (non-existing or not owned by you) will not cause exceptions, but fail silently.
entailment
def remove_images(self, images): """ Remove images from the album. :param images: A list of the images we want to remove from the album. Can be Image objects, ids or a combination of the two. Images that you cannot remove (non-existing, not owned by you or not part of ...
Remove images from the album. :param images: A list of the images we want to remove from the album. Can be Image objects, ids or a combination of the two. Images that you cannot remove (non-existing, not owned by you or not part of album) will not cause exceptions, but fail ...
entailment
def set_images(self, images): """ Set the images in this album. :param images: A list of the images we want the album to contain. Can be Image objects, ids or a combination of the two. Images that images that you cannot set (non-existing or not owned by you) will ...
Set the images in this album. :param images: A list of the images we want the album to contain. Can be Image objects, ids or a combination of the two. Images that images that you cannot set (non-existing or not owned by you) will not cause exceptions, but fail silently.
entailment
def submit_to_gallery(self, title, bypass_terms=False): """ Add this to the gallery. Require that the authenticated user has accepted gallery terms and verified their email. :param title: The title of the new gallery item. :param bypass_terms: If the user has not accept...
Add this to the gallery. Require that the authenticated user has accepted gallery terms and verified their email. :param title: The title of the new gallery item. :param bypass_terms: If the user has not accepted Imgur's terms yet, this method will return an error. Set this...
entailment
def update(self, title=None, description=None, images=None, cover=None, layout=None, privacy=None): """ Update the album's information. Arguments with the value None will retain their old values. :param title: The title of the album. :param description: A descrip...
Update the album's information. Arguments with the value None will retain their old values. :param title: The title of the album. :param description: A description of the album. :param images: A list of the images we want the album to contain. Can be Image objects, ids or a...
entailment
def get_replies(self): """Get the replies to this comment.""" url = self._imgur._base_url + "/3/comment/{0}/replies".format(self.id) json = self._imgur._send_request(url) child_comments = json['children'] return [Comment(com, self._imgur) for com in child_comments]
Get the replies to this comment.
entailment
def comment(self, text): """ Make a top-level comment to this. :param text: The comment text. """ url = self._imgur._base_url + "/3/comment" payload = {'image_id': self.id, 'comment': text} resp = self._imgur._send_request(url, params=payload, needs_auth=True, ...
Make a top-level comment to this. :param text: The comment text.
entailment
def downvote(self): """ Dislike this. A downvote will replace a neutral vote or an upvote. Downvoting something the authenticated user has already downvoted will set the vote to neutral. """ url = self._imgur._base_url + "/3/gallery/{0}/vote/down".format(self.id)...
Dislike this. A downvote will replace a neutral vote or an upvote. Downvoting something the authenticated user has already downvoted will set the vote to neutral.
entailment
def get_comments(self): """Get a list of the top-level comments.""" url = self._imgur._base_url + "/3/gallery/{0}/comments".format(self.id) resp = self._imgur._send_request(url) return [Comment(com, self._imgur) for com in resp]
Get a list of the top-level comments.
entailment
def remove_from_gallery(self): """Remove this image from the gallery.""" url = self._imgur._base_url + "/3/gallery/{0}".format(self.id) self._imgur._send_request(url, needs_auth=True, method='DELETE') if isinstance(self, Image): item = self._imgur.get_image(self.id) e...
Remove this image from the gallery.
entailment
def download(self, path='', name=None, overwrite=False, size=None): """ Download the image. :param path: The image will be downloaded to the folder specified at path, if path is None (default) then the current working directory will be used. :param name: The name...
Download the image. :param path: The image will be downloaded to the folder specified at path, if path is None (default) then the current working directory will be used. :param name: The name the image will be stored as (not including file extension). If name is None...
entailment
def update(self, title=None, description=None): """Update the image with a new title and/or description.""" url = (self._imgur._base_url + "/3/image/" "{0}".format(self._delete_or_id_hash)) is_updated = self._imgur._send_request(url, params=locals(), ...
Update the image with a new title and/or description.
entailment
def _send_request(self, url, needs_auth=False, **kwargs): """ Handles top level functionality for sending requests to Imgur. This mean - Raising client-side error if insufficient authentication. - Adding authentication information to the request. - Split the ...
Handles top level functionality for sending requests to Imgur. This mean - Raising client-side error if insufficient authentication. - Adding authentication information to the request. - Split the request into multiple request for pagination. - Retry calls for ce...
entailment
def authorization_url(self, response, state=""): """ Return the authorization url that's needed to authorize as a user. :param response: Can be either code or pin. If it's code the user will be redirected to your redirect url with the code as a get parameter after author...
Return the authorization url that's needed to authorize as a user. :param response: Can be either code or pin. If it's code the user will be redirected to your redirect url with the code as a get parameter after authorizing your application. If it's pin then after authorizin...
entailment
def change_authentication(self, client_id=None, client_secret=None, access_token=None, refresh_token=None): """Change the current authentication.""" # TODO: Add error checking so you cannot change client_id and retain # access_token. Because that doesn't make sense....
Change the current authentication.
entailment
def create_album(self, title=None, description=None, images=None, cover=None): """ Create a new Album. :param title: The title of the album. :param description: The albums description. :param images: A list of the images that will be added to the album ...
Create a new Album. :param title: The title of the album. :param description: The albums description. :param images: A list of the images that will be added to the album after it's created. Can be Image objects, ids or a combination of the two. Images that you cannot a...
entailment
def exchange_code(self, code): """Exchange one-use code for an access_token and request_token.""" params = {'client_id': self.client_id, 'client_secret': self.client_secret, 'grant_type': 'authorization_code', 'code': code} result = self._sen...
Exchange one-use code for an access_token and request_token.
entailment
def exchange_pin(self, pin): """Exchange one-use pin for an access_token and request_token.""" params = {'client_id': self.client_id, 'client_secret': self.client_secret, 'grant_type': 'pin', 'pin': pin} result = self._send_request(EXCHANGE_U...
Exchange one-use pin for an access_token and request_token.
entailment
def get_album(self, id): """Return information about this album.""" url = self._base_url + "/3/album/{0}".format(id) json = self._send_request(url) return Album(json, self)
Return information about this album.
entailment
def get_at_url(self, url): """ Return a object representing the content at url. Returns None if no object could be matched with the id. Works for Album, Comment, Gallery_album, Gallery_image, Image and User. NOTE: Imgur's documentation does not cover what urls are available. ...
Return a object representing the content at url. Returns None if no object could be matched with the id. Works for Album, Comment, Gallery_album, Gallery_image, Image and User. NOTE: Imgur's documentation does not cover what urls are available. Some urls, such as imgur.com/<ID> can be...
entailment
def get_comment(self, id): """Return information about this comment.""" url = self._base_url + "/3/comment/{0}".format(id) json = self._send_request(url) return Comment(json, self)
Return information about this comment.
entailment
def get_gallery(self, section='hot', sort='viral', window='day', show_viral=True, limit=None): """ Return a list of gallery albums and gallery images. :param section: hot | top | user - defaults to hot. :param sort: viral | time - defaults to viral. :param wi...
Return a list of gallery albums and gallery images. :param section: hot | top | user - defaults to hot. :param sort: viral | time - defaults to viral. :param window: Change the date range of the request if the section is "top", day | week | month | year | all, defaults to day. ...
entailment
def get_gallery_album(self, id): """ Return the gallery album matching the id. Note that an album's id is different from it's id as a gallery album. This makes it possible to remove an album from the gallery and setting it's privacy setting as secret, without compromising it's s...
Return the gallery album matching the id. Note that an album's id is different from it's id as a gallery album. This makes it possible to remove an album from the gallery and setting it's privacy setting as secret, without compromising it's secrecy.
entailment
def get_gallery_image(self, id): """ Return the gallery image matching the id. Note that an image's id is different from it's id as a gallery image. This makes it possible to remove an image from the gallery and setting it's privacy setting as secret, without compromising it's s...
Return the gallery image matching the id. Note that an image's id is different from it's id as a gallery image. This makes it possible to remove an image from the gallery and setting it's privacy setting as secret, without compromising it's secrecy.
entailment
def get_image(self, id): """Return a Image object representing the image with the given id.""" url = self._base_url + "/3/image/{0}".format(id) resp = self._send_request(url) return Image(resp, self)
Return a Image object representing the image with the given id.
entailment
def get_message(self, id): """ Return a Message object for given id. :param id: The id of the message object to return. """ url = self._base_url + "/3/message/{0}".format(id) resp = self._send_request(url) return Message(resp, self)
Return a Message object for given id. :param id: The id of the message object to return.
entailment
def get_notification(self, id): """ Return a Notification object. :param id: The id of the notification object to return. """ url = self._base_url + "/3/notification/{0}".format(id) resp = self._send_request(url) return Notification(resp, self)
Return a Notification object. :param id: The id of the notification object to return.
entailment
def get_memes_gallery(self, sort='viral', window='week', limit=None): """ Return a list of gallery albums/images submitted to the memes gallery The url for the memes gallery is: http://imgur.com/g/memes :param sort: viral | time | top - defaults to viral :param window: Change t...
Return a list of gallery albums/images submitted to the memes gallery The url for the memes gallery is: http://imgur.com/g/memes :param sort: viral | time | top - defaults to viral :param window: Change the date range of the request if the section is "top", day | week | month | yea...
entailment
def get_subreddit_gallery(self, subreddit, sort='time', window='top', limit=None): """ Return a list of gallery albums/images submitted to a subreddit. A subreddit is a subsection of the website www.reddit.com, where users can, among other things, post imag...
Return a list of gallery albums/images submitted to a subreddit. A subreddit is a subsection of the website www.reddit.com, where users can, among other things, post images. :param subreddit: A valid subreddit name. :param sort: time | top - defaults to top. :param window: Chan...
entailment
def get_subreddit_image(self, subreddit, id): """ Return the Gallery_image with the id submitted to subreddit gallery :param subreddit: The subreddit the image has been submitted to. :param id: The id of the image we want. """ url = self._base_url + "/3/gallery/r/{0}/{1}...
Return the Gallery_image with the id submitted to subreddit gallery :param subreddit: The subreddit the image has been submitted to. :param id: The id of the image we want.
entailment
def get_user(self, username): """ Return a User object for this username. :param username: The name of the user we want more information about. """ url = self._base_url + "/3/account/{0}".format(username) json = self._send_request(url) return User(json, self)
Return a User object for this username. :param username: The name of the user we want more information about.
entailment
def refresh_access_token(self): """ Refresh the access_token. The self.access_token attribute will be updated with the value of the new access_token which will also be returned. """ if self.client_secret is None: raise Exception("client_secret must be set to ...
Refresh the access_token. The self.access_token attribute will be updated with the value of the new access_token which will also be returned.
entailment
def search_gallery(self, q): """Search the gallery with the given query string.""" url = self._base_url + "/3/gallery/search?q={0}".format(q) resp = self._send_request(url) return [_get_album_or_image(thing, self) for thing in resp]
Search the gallery with the given query string.
entailment
def upload_image(self, path=None, url=None, title=None, description=None, album=None): """ Upload the image at either path or url. :param path: The path to the image you want to upload. :param url: The url to the image you want to upload. :param title: The t...
Upload the image at either path or url. :param path: The path to the image you want to upload. :param url: The url to the image you want to upload. :param title: The title the image will have when uploaded. :param description: The description the image will have when uploaded. :...
entailment
def delete(self): """Delete the message.""" url = self._imgur._base_url + "/3/message/{0}".format(self.id) return self._imgur._send_request(url, method='DELETE')
Delete the message.
entailment
def get_thread(self): """Return the message thread this Message is in.""" url = (self._imgur._base_url + "/3/message/{0}/thread".format( self.first_message.id)) resp = self._imgur._send_request(url) return [Message(msg, self._imgur) for msg in resp]
Return the message thread this Message is in.
entailment
def reply(self, body): """ Reply to this message. This is a convenience method calling User.send_message. See it for more information on usage. Note that both recipient and reply_to are given by using this convenience method. :param body: The body of the message. ...
Reply to this message. This is a convenience method calling User.send_message. See it for more information on usage. Note that both recipient and reply_to are given by using this convenience method. :param body: The body of the message.
entailment
def change_settings(self, bio=None, public_images=None, messaging_enabled=None, album_privacy=None, accepted_gallery_terms=None): """ Update the settings for the user. :param bio: A basic description filled out by the user, is displayed in ...
Update the settings for the user. :param bio: A basic description filled out by the user, is displayed in the gallery profile page. :param public_images: Set the default privacy setting of the users images. If True images are public, if False private. :param messaging_en...
entailment
def get_albums(self, limit=None): """ Return a list of the user's albums. Secret and hidden albums are only returned if this is the logged-in user. """ url = (self._imgur._base_url + "/3/account/{0}/albums/{1}".format(self.name, ...
Return a list of the user's albums. Secret and hidden albums are only returned if this is the logged-in user.
entailment
def get_favorites(self): """Return the users favorited images.""" url = self._imgur._base_url + "/3/account/{0}/favorites".format(self.name) resp = self._imgur._send_request(url, needs_auth=True) return [_get_album_or_image(thing, self._imgur) for thing in resp]
Return the users favorited images.
entailment
def get_gallery_favorites(self): """Get a list of the images in the gallery this user has favorited.""" url = (self._imgur._base_url + "/3/account/{0}/gallery_favorites".format( self.name)) resp = self._imgur._send_request(url) return [Image(img, self._imgur) for img in re...
Get a list of the images in the gallery this user has favorited.
entailment
def get_gallery_profile(self): """Return the users gallery profile.""" url = (self._imgur._base_url + "/3/account/{0}/" "gallery_profile".format(self.name)) return self._imgur._send_request(url)
Return the users gallery profile.
entailment
def has_verified_email(self): """ Has the user verified that the email he has given is legit? Verified e-mail is required to the gallery. Confirmation happens by sending an email to the user and the owner of the email user verifying that he is the same as the Imgur user. ...
Has the user verified that the email he has given is legit? Verified e-mail is required to the gallery. Confirmation happens by sending an email to the user and the owner of the email user verifying that he is the same as the Imgur user.
entailment
def get_images(self, limit=None): """Return all of the images associated with the user.""" url = (self._imgur._base_url + "/3/account/{0}/" "images/{1}".format(self.name, '{}')) resp = self._imgur._send_request(url, limit=limit) return [Image(img, self._imgur) for img in r...
Return all of the images associated with the user.
entailment
def get_messages(self, new=True): """ Return all messages sent to this user, formatted as a notification. :param new: False for all notifications, True for only non-viewed notifications. """ url = (self._imgur._base_url + "/3/account/{0}/notifications/" ...
Return all messages sent to this user, formatted as a notification. :param new: False for all notifications, True for only non-viewed notifications.
entailment
def get_notifications(self, new=True): """Return all the notifications for this user.""" url = (self._imgur._base_url + "/3/account/{0}/" "notifications".format(self.name)) resp = self._imgur._send_request(url, params=locals(), needs_auth=True) msgs = [Message(msg_dict, se...
Return all the notifications for this user.
entailment
def get_replies(self, new=True): """ Return all reply notifications for this user. :param new: False for all notifications, True for only non-viewed notifications. """ url = (self._imgur._base_url + "/3/account/{0}/" "notifications/replies".format(self...
Return all reply notifications for this user. :param new: False for all notifications, True for only non-viewed notifications.
entailment
def get_settings(self): """ Returns current settings. Only accessible if authenticated as the user. """ url = self._imgur._base_url + "/3/account/{0}/settings".format(self.name) return self._imgur._send_request(url)
Returns current settings. Only accessible if authenticated as the user.
entailment
def get_submissions(self, limit=None): """Return a list of the images a user has submitted to the gallery.""" url = (self._imgur._base_url + "/3/account/{0}/submissions/" "{1}".format(self.name, '{}')) resp = self._imgur._send_request(url, limit=limit) return [_get_album_o...
Return a list of the images a user has submitted to the gallery.
entailment
def send_message(self, body, subject=None, reply_to=None): """ Send a message to this user from the logged in user. :param body: The body of the message. :param subject: The subject of the message. Note that if the this message is a reply, then the subject of the first messa...
Send a message to this user from the logged in user. :param body: The body of the message. :param subject: The subject of the message. Note that if the this message is a reply, then the subject of the first message will be used instead. :param reply_to: Messages can eith...
entailment
def send_verification_email(self): """ Send verification email to this users email address. Remember that the verification email may end up in the users spam folder. """ url = (self._imgur._base_url + "/3/account/{0}" "/verifyemail".format(self.name)) ...
Send verification email to this users email address. Remember that the verification email may end up in the users spam folder.
entailment
def hook(reverse=False, align=False, strip_path=False, enable_on_envvar_only=False, on_tty=False, conservative=False, styles=None, tb=None, tpe=None, value=None): """Hook the current excepthook to the backtrace. If `align` is True...
Hook the current excepthook to the backtrace. If `align` is True, all parts (line numbers, file names, etc..) will be aligned to the left according to the longest entry. If `strip_path` is True, only the file name will be shown, not its full path. If `enable_on_envvar_only` is True, only if the e...
entailment
def _extract_traceback(text): """Receive a list of strings representing the input from stdin and return the restructured backtrace. This iterates over the output and once it identifies a hopefully genuine identifier, it will start parsing output. In the case the input includes a reraise (a Python 3...
Receive a list of strings representing the input from stdin and return the restructured backtrace. This iterates over the output and once it identifies a hopefully genuine identifier, it will start parsing output. In the case the input includes a reraise (a Python 3 case), the primary traceback isn...
entailment
def generate_backtrace(self, styles): """Return the (potentially) aligned, rebuit traceback Yes, we iterate over the entries thrice. We sacrifice performance for code readability. I mean.. come on, how long can your traceback be that it matters? """ backtrace = [] ...
Return the (potentially) aligned, rebuit traceback Yes, we iterate over the entries thrice. We sacrifice performance for code readability. I mean.. come on, how long can your traceback be that it matters?
entailment
def classify_catalog(catalog): """ Look at a list of sources and split them according to their class. Parameters ---------- catalog : iterable A list or iterable object of {SimpleSource, IslandSource, OutputSource} objects, possibly mixed. Any other objects will be silently ignored....
Look at a list of sources and split them according to their class. Parameters ---------- catalog : iterable A list or iterable object of {SimpleSource, IslandSource, OutputSource} objects, possibly mixed. Any other objects will be silently ignored. Returns ------- components : ...
entailment
def island_itergen(catalog): """ Iterate over a catalog of sources, and return an island worth of sources at a time. Yields a list of components, one island at a time Parameters ---------- catalog : iterable A list or iterable of :class:`AegeanTools.models.OutputSource` objects. Yi...
Iterate over a catalog of sources, and return an island worth of sources at a time. Yields a list of components, one island at a time Parameters ---------- catalog : iterable A list or iterable of :class:`AegeanTools.models.OutputSource` objects. Yields ------ group : list ...
entailment
def _sanitise(self): """ Convert attributes of type npumpy.float32 to numpy.float64 so that they will print properly. """ for k in self.__dict__: if isinstance(self.__dict__[k], np.float32): # np.float32 has a broken __str__ method self.__dict__[k] = np.float...
Convert attributes of type npumpy.float32 to numpy.float64 so that they will print properly.
entailment
def as_list(self): """ Return an *ordered* list of the source attributes """ self._sanitise() l = [] for name in self.names: l.append(getattr(self, name)) return l
Return an *ordered* list of the source attributes
entailment
def add_circles(self, ra_cen, dec_cen, radius, depth=None): """ Add one or more circles to this region Parameters ---------- ra_cen, dec_cen, radius : float or list The center and radius of the circle or circles to add to this region. depth : int ...
Add one or more circles to this region Parameters ---------- ra_cen, dec_cen, radius : float or list The center and radius of the circle or circles to add to this region. depth : int The depth at which the given circles will be inserted.
entailment
def add_poly(self, positions, depth=None): """ Add a single polygon to this region. Parameters ---------- positions : [[ra, dec], ...] Positions for the vertices of the polygon. The polygon needs to be convex and non-intersecting. depth : int The...
Add a single polygon to this region. Parameters ---------- positions : [[ra, dec], ...] Positions for the vertices of the polygon. The polygon needs to be convex and non-intersecting. depth : int The deepth at which the polygon will be inserted.
entailment
def add_pixels(self, pix, depth): """ Add one or more HEALPix pixels to this region. Parameters ---------- pix : int or iterable The pixels to be added depth : int The depth at which the pixels are added. """ if depth not in self....
Add one or more HEALPix pixels to this region. Parameters ---------- pix : int or iterable The pixels to be added depth : int The depth at which the pixels are added.
entailment
def get_area(self, degrees=True): """ Calculate the total area represented by this region. Parameters ---------- degrees : bool If True then return the area in square degrees, otherwise use steradians. Default = True. Returns ------- ...
Calculate the total area represented by this region. Parameters ---------- degrees : bool If True then return the area in square degrees, otherwise use steradians. Default = True. Returns ------- area : float The area of the region.
entailment
def _demote_all(self): """ Convert the multi-depth pixeldict into a single set of pixels at the deepest layer. The result is cached, and reset when any changes are made to this region. """ # only do the calculations if the demoted list is empty if len(self.demoted) == 0:...
Convert the multi-depth pixeldict into a single set of pixels at the deepest layer. The result is cached, and reset when any changes are made to this region.
entailment
def _renorm(self): """ Remake the pixel dictionary, merging groups of pixels at level N into a single pixel at level N-1 """ self.demoted = set() # convert all to lowest level self._demote_all() # now promote as needed for d in range(self.maxdepth,...
Remake the pixel dictionary, merging groups of pixels at level N into a single pixel at level N-1
entailment