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 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
benjamin-hodgson/asynqp | src/asynqp/channel.py | Channel.close | 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... | python | 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... | [
"def",
"close",
"(",
"self",
")",
":",
"# If we aren't already closed ask for server to close",
"if",
"not",
"self",
".",
"is_closed",
"(",
")",
":",
"self",
".",
"_closing",
"=",
"True",
"# Let the ChannelActor do the actual close operations.",
"# It will do the work on Cl... | Close the channel by handshaking with the server.
This method is a :ref:`coroutine <coroutine>`. | [
"Close",
"the",
"channel",
"by",
"handshaking",
"with",
"the",
"server",
"."
] | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/channel.py#L173-L194 | train | Close the channel by handshaking with the server. |
benjamin-hodgson/asynqp | src/asynqp/channel.py | ChannelActor.handle_ChannelClose | 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... | python | 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... | [
"def",
"handle_ChannelClose",
"(",
"self",
",",
"frame",
")",
":",
"# 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",
"=... | AMQP server closed the channel with an error | [
"AMQP",
"server",
"closed",
"the",
"channel",
"with",
"an",
"error"
] | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/channel.py#L345-L355 | train | Handle a channel close. |
benjamin-hodgson/asynqp | src/asynqp/channel.py | ChannelActor.handle_ChannelCloseOK | 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... | python | 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... | [
"def",
"handle_ChannelCloseOK",
"(",
"self",
",",
"frame",
")",
":",
"assert",
"self",
".",
"channel",
".",
"_closing",
",",
"\"received a not expected CloseOk\"",
"# Release the `close` method's future",
"self",
".",
"synchroniser",
".",
"notify",
"(",
"spec",
".",
... | AMQP server closed channel as per our request | [
"AMQP",
"server",
"closed",
"channel",
"as",
"per",
"our",
"request"
] | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/channel.py#L357-L364 | train | Handle a ChannelCloseOK frame. |
benjamin-hodgson/asynqp | src/asynqp/queue.py | Queue.bind | 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... | python | 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... | [
"def",
"bind",
"(",
"self",
",",
"exchange",
",",
"routing_key",
",",
"*",
",",
"arguments",
"=",
"None",
")",
":",
"if",
"self",
".",
"deleted",
":",
"raise",
"Deleted",
"(",
"\"Queue {} was deleted\"",
".",
"format",
"(",
"self",
".",
"name",
")",
")... | 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... | [
"Bind",
"a",
"queue",
"to",
"an",
"exchange",
"with",
"the",
"supplied",
"routing",
"key",
"."
] | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/queue.py#L54-L78 | train | Bind a queue to an exchange with the supplied routing key. |
benjamin-hodgson/asynqp | src/asynqp/queue.py | Queue.consume | 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: ... | python | 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: ... | [
"def",
"consume",
"(",
"self",
",",
"callback",
",",
"*",
",",
"no_local",
"=",
"False",
",",
"no_ack",
"=",
"False",
",",
"exclusive",
"=",
"False",
",",
"arguments",
"=",
"None",
")",
":",
"if",
"self",
".",
"deleted",
":",
"raise",
"Deleted",
"(",... | 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... | [
"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",
"que... | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/queue.py#L81-L116 | train | Start a consumer on the queue. Messages will be delivered asynchronously to the consumer. |
benjamin-hodgson/asynqp | src/asynqp/queue.py | Queue.get | 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... | python | 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... | [
"def",
"get",
"(",
"self",
",",
"*",
",",
"no_ack",
"=",
"False",
")",
":",
"if",
"self",
".",
"deleted",
":",
"raise",
"Deleted",
"(",
"\"Queue {} was deleted\"",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"self",
".",
"sender",
".",
"send_B... | 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... | [
"Synchronously",
"get",
"a",
"message",
"from",
"the",
"queue",
"."
] | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/queue.py#L119-L142 | train | Synchronously get a message from the queue. |
benjamin-hodgson/asynqp | src/asynqp/queue.py | Queue.purge | 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() | python | 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() | [
"def",
"purge",
"(",
"self",
")",
":",
"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>`. | [
"Purge",
"all",
"undelivered",
"messages",
"from",
"the",
"queue",
"."
] | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/queue.py#L145-L153 | train | Purge all undelivered messages from the queue. |
benjamin-hodgson/asynqp | src/asynqp/queue.py | Queue.delete | 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 ... | python | 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 ... | [
"def",
"delete",
"(",
"self",
",",
"*",
",",
"if_unused",
"=",
"True",
",",
"if_empty",
"=",
"True",
")",
":",
"if",
"self",
".",
"deleted",
":",
"raise",
"Deleted",
"(",
"\"Queue {} was already deleted\"",
".",
"format",
"(",
"self",
".",
"name",
")",
... | 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. | [
"Delete",
"the",
"queue",
"."
] | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/queue.py#L156-L173 | train | Delete the queue. |
benjamin-hodgson/asynqp | src/asynqp/queue.py | QueueBinding.unbind | 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... | python | 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... | [
"def",
"unbind",
"(",
"self",
",",
"arguments",
"=",
"None",
")",
":",
"if",
"self",
".",
"deleted",
":",
"raise",
"Deleted",
"(",
"\"Queue {} was already unbound from exchange {}\"",
".",
"format",
"(",
"self",
".",
"queue",
".",
"name",
",",
"self",
".",
... | Unbind the queue from the exchange.
This method is a :ref:`coroutine <coroutine>`. | [
"Unbind",
"the",
"queue",
"from",
"the",
"exchange",
"."
] | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/queue.py#L209-L221 | train | Unbind the queue from the exchange. |
benjamin-hodgson/asynqp | src/asynqp/queue.py | Consumer.cancel | 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... | python | 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... | [
"def",
"cancel",
"(",
"self",
")",
":",
"self",
".",
"sender",
".",
"send_BasicCancel",
"(",
"self",
".",
"tag",
")",
"try",
":",
"yield",
"from",
"self",
".",
"synchroniser",
".",
"wait",
"(",
"spec",
".",
"BasicCancelOK",
")",
"except",
"AMQPError",
... | Cancel the consumer and stop recieving messages.
This method is a :ref:`coroutine <coroutine>`. | [
"Cancel",
"the",
"consumer",
"and",
"stop",
"recieving",
"messages",
"."
] | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/queue.py#L255-L272 | train | Cancel the consumer and stop recieving messages. |
benjamin-hodgson/asynqp | doc/examples/helloworld.py | hello_world | 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... | python | 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... | [
"def",
"hello_world",
"(",
")",
":",
"# connect to the RabbitMQ broker",
"connection",
"=",
"yield",
"from",
"asynqp",
".",
"connect",
"(",
"'localhost'",
",",
"5672",
",",
"username",
"=",
"'guest'",
",",
"password",
"=",
"'guest'",
")",
"# Open a communications ... | Sends a 'hello world' message and then reads it from the queue. | [
"Sends",
"a",
"hello",
"world",
"message",
"and",
"then",
"reads",
"it",
"from",
"the",
"queue",
"."
] | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/doc/examples/helloworld.py#L6-L35 | train | Send a hello world message and then reads it from the queue. |
benjamin-hodgson/asynqp | src/asynqp/routing.py | Synchroniser.killall | 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:
... | python | 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:
... | [
"def",
"killall",
"(",
"self",
",",
"exc",
")",
":",
"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 | [
"Connection",
"/",
"Channel",
"was",
"closed",
".",
"All",
"subsequent",
"and",
"ongoing",
"requests",
"should",
"raise",
"an",
"error"
] | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/routing.py#L85-L96 | train | Kill all ongoing requests and clear the internal state. |
benjamin-hodgson/asynqp | src/asynqp/__init__.py | connect | 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... | python | 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... | [
"def",
"connect",
"(",
"host",
"=",
"'localhost'",
",",
"port",
"=",
"5672",
",",
"username",
"=",
"'guest'",
",",
"password",
"=",
"'guest'",
",",
"virtual_host",
"=",
"'/'",
",",
"on_connection_close",
"=",
"None",
",",
"*",
",",
"loop",
"=",
"None",
... | 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... | [
"Connect",
"to",
"an",
"AMQP",
"server",
"on",
"the",
"given",
"host",
"and",
"port",
"."
] | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/__init__.py#L22-L86 | train | Connect to an AMQP server. |
benjamin-hodgson/asynqp | src/asynqp/__init__.py | connect_and_open_channel | def connect_and_open_channel(host='localhost',
port=5672,
username='guest', password='guest',
virtual_host='/',
on_connection_close=None, *,
loop=None, **kwargs):
"""
... | python | def connect_and_open_channel(host='localhost',
port=5672,
username='guest', password='guest',
virtual_host='/',
on_connection_close=None, *,
loop=None, **kwargs):
"""
... | [
"def",
"connect_and_open_channel",
"(",
"host",
"=",
"'localhost'",
",",
"port",
"=",
"5672",
",",
"username",
"=",
"'guest'",
",",
"password",
"=",
"'guest'",
",",
"virtual_host",
"=",
"'/'",
",",
"on_connection_close",
"=",
"None",
",",
"*",
",",
"loop",
... | 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... | [
"Connect",
"to",
"an",
"AMQP",
"server",
"and",
"open",
"a",
"channel",
"on",
"the",
"connection",
".",
"This",
"function",
"is",
"a",
":",
"ref",
":",
"coroutine",
"<coroutine",
">",
"."
] | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/__init__.py#L90-L112 | train | Connect to an AMQP server and open a channel on the connection. |
benjamin-hodgson/asynqp | src/asynqp/protocol.py | AMQP.heartbeat_timeout | 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_... | python | 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_... | [
"def",
"heartbeat_timeout",
"(",
"self",
")",
":",
"assert",
"not",
"self",
".",
"_closed",
",",
"\"Did we not stop heartbeat_monitor on close?\"",
"log",
".",
"error",
"(",
"\"Heartbeat time out\"",
")",
"poison_exc",
"=",
"ConnectionLostError",
"(",
"'Heartbeat timed ... | Called by heartbeat_monitor on timeout | [
"Called",
"by",
"heartbeat_monitor",
"on",
"timeout"
] | ea8630d1803d10d4fd64b1a0e50f3097710b34d1 | https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/protocol.py#L66-L74 | train | Called by heartbeat_monitor when heartbeat_timeout expires. |
Damgaard/PyImgur | pyimgur/request.py | convert_general | 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)
... | python | 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)
... | [
"def",
"convert_general",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"bool",
")",
":",
"return",
"\"true\"",
"if",
"value",
"else",
"\"false\"",
"elif",
"isinstance",
"(",
"value",
",",
"list",
")",
":",
"value",
"=",
"[",
"convert_ge... | Take a python object and convert it to the format Imgur expects. | [
"Take",
"a",
"python",
"object",
"and",
"convert",
"it",
"to",
"the",
"format",
"Imgur",
"expects",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/request.py#L32-L43 | train | Take a python object and convert it to the format Imgur expects. |
Damgaard/PyImgur | pyimgur/request.py | to_imgur_format | 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()) | python | 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()) | [
"def",
"to_imgur_format",
"(",
"params",
")",
":",
"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. | [
"Convert",
"the",
"parameters",
"to",
"the",
"format",
"Imgur",
"expects",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/request.py#L53-L57 | train | Convert the parameters to the format Imgur expects. |
rbarrois/django_xworkflows | django_xworkflows/models.py | StateSelect.render | 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... | python | 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... | [
"def",
"render",
"(",
"self",
",",
"name",
",",
"value",
",",
"attrs",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"base",
".",
"StateWrapper",
")",
":",
"state_name",
"=",
"value",
".",
... | Handle a few expected values for rendering the current choice.
Extracts the state name from StateWrapper and State object. | [
"Handle",
"a",
"few",
"expected",
"values",
"for",
"rendering",
"the",
"current",
"choice",
"."
] | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/django_xworkflows/models.py#L38-L49 | train | Handle a few expected values for rendering the current choice. |
rbarrois/django_xworkflows | django_xworkflows/models.py | StateField.contribute_to_class | 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... | python | 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... | [
"def",
"contribute_to_class",
"(",
"self",
",",
"cls",
",",
"name",
")",
":",
"super",
"(",
"StateField",
",",
"self",
")",
".",
"contribute_to_class",
"(",
"cls",
",",
"name",
")",
"parent_property",
"=",
"getattr",
"(",
"cls",
",",
"self",
".",
"name",... | Contribute the state to a Model.
Attaches a StateFieldProperty to wrap the attribute. | [
"Contribute",
"the",
"state",
"to",
"a",
"Model",
"."
] | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/django_xworkflows/models.py#L115-L123 | train | Contributes the state to a Model. |
rbarrois/django_xworkflows | django_xworkflows/models.py | StateField.to_python | 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... | python | 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... | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"base",
".",
"StateWrapper",
")",
":",
"res",
"=",
"value",
"else",
":",
"if",
"isinstance",
"(",
"value",
",",
"base",
".",
"State",
")",
":",
"state",
... | Converts the DB-stored value into a Python value. | [
"Converts",
"the",
"DB",
"-",
"stored",
"value",
"into",
"a",
"Python",
"value",
"."
] | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/django_xworkflows/models.py#L125-L144 | train | Converts the DB - stored value into a Python value. |
rbarrois/django_xworkflows | django_xworkflows/models.py | StateField.get_db_prep_value | 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 | python | 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 | [
"def",
"get_db_prep_value",
"(",
"self",
",",
"value",
",",
"connection",
",",
"prepared",
"=",
"False",
")",
":",
"if",
"not",
"prepared",
":",
"value",
"=",
"self",
".",
"get_prep_value",
"(",
"value",
")",
"return",
"value",
".",
"state",
".",
"name"
... | Convert a value to DB storage.
Returns the state name. | [
"Convert",
"a",
"value",
"to",
"DB",
"storage",
"."
] | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/django_xworkflows/models.py#L153-L160 | train | Convert a value to DB storage. |
rbarrois/django_xworkflows | django_xworkflows/models.py | StateField.value_to_string | 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 | python | 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 | [
"def",
"value_to_string",
"(",
"self",
",",
"obj",
")",
":",
"statefield",
"=",
"self",
".",
"to_python",
"(",
"self",
".",
"value_from_object",
"(",
"obj",
")",
")",
"return",
"statefield",
".",
"state",
".",
"name"
] | Convert a field value to a string.
Returns the state name. | [
"Convert",
"a",
"field",
"value",
"to",
"a",
"string",
"."
] | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/django_xworkflows/models.py#L162-L168 | train | Convert a field value to a string. |
rbarrois/django_xworkflows | django_xworkflows/models.py | StateField.validate | 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 ... | python | 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 ... | [
"def",
"validate",
"(",
"self",
",",
"value",
",",
"model_instance",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"base",
".",
"StateWrapper",
")",
":",
"raise",
"exceptions",
".",
"ValidationError",
"(",
"self",
".",
"error_messages",
"[",
"'wr... | 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 | [
"Validate",
"that",
"a",
"given",
"value",
"is",
"a",
"valid",
"option",
"for",
"a",
"given",
"model",
"instance",
"."
] | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/django_xworkflows/models.py#L170-L182 | train | Validate that a given value is a valid option for a given model instance. |
rbarrois/django_xworkflows | django_xworkflows/models.py | StateField.deconstruct | 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... | python | 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... | [
"def",
"deconstruct",
"(",
"self",
")",
":",
"name",
",",
"path",
",",
"args",
",",
"kwargs",
"=",
"super",
"(",
"StateField",
",",
"self",
")",
".",
"deconstruct",
"(",
")",
"# We want to display the proper class name, which isn't available",
"# at the same point f... | Deconstruction for migrations.
Return a simpler object (_SerializedWorkflow), since our Workflows
are rather hard to serialize: Django doesn't like deconstructing
metaclass-built classes. | [
"Deconstruction",
"for",
"migrations",
"."
] | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/django_xworkflows/models.py#L187-L210 | train | Deconstruction for migrations.
Return a simpler object ( _SerializedWorkflow ) since our Workflows
are rather hard to serialize |
rbarrois/django_xworkflows | django_xworkflows/models.py | WorkflowEnabledMeta._find_workflows | 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... | python | 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... | [
"def",
"_find_workflows",
"(",
"mcs",
",",
"attrs",
")",
":",
"workflows",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"attrs",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"StateField",
")",
":",
"workflows",
"[",
"k",
"]",
"="... | Find workflow definition(s) in a WorkflowEnabled definition.
This method overrides the default behavior from xworkflows in order to
use our custom StateField objects. | [
"Find",
"workflow",
"definition",
"(",
"s",
")",
"in",
"a",
"WorkflowEnabled",
"definition",
"."
] | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/django_xworkflows/models.py#L217-L227 | train | Find workflow definition in a WorkflowEnabled definition. |
rbarrois/django_xworkflows | django_xworkflows/models.py | Workflow._get_log_model_class | 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 ... | python | 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 ... | [
"def",
"_get_log_model_class",
"(",
"self",
")",
":",
"if",
"self",
".",
"log_model_class",
"is",
"not",
"None",
":",
"return",
"self",
".",
"log_model_class",
"app_label",
",",
"model_label",
"=",
"self",
".",
"log_model",
".",
"rsplit",
"(",
"'.'",
",",
... | 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. | [
"Cache",
"for",
"fetching",
"the",
"actual",
"log",
"model",
"object",
"once",
"django",
"is",
"loaded",
"."
] | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/django_xworkflows/models.py#L385-L396 | train | Cache for fetching the actual log model object once django is loaded. |
rbarrois/django_xworkflows | django_xworkflows/models.py | Workflow.db_log | 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:
... | python | 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:
... | [
"def",
"db_log",
"(",
"self",
",",
"transition",
",",
"from_state",
",",
"instance",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"log_model",
":",
"model_class",
"=",
"self",
".",
"_get_log_model_class",
"(",
")",
"extras",
... | Logs the transition into the database. | [
"Logs",
"the",
"transition",
"into",
"the",
"database",
"."
] | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/django_xworkflows/models.py#L398-L412 | train | Logs the transition into the database. |
rbarrois/django_xworkflows | django_xworkflows/models.py | Workflow.log_transition | 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... | python | 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... | [
"def",
"log_transition",
"(",
"self",
",",
"transition",
",",
"from_state",
",",
"instance",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"save",
"=",
"kwargs",
".",
"pop",
"(",
"'save'",
",",
"True",
")",
"log",
"=",
"kwargs",
".",
"pop",
... | Generic transition logging. | [
"Generic",
"transition",
"logging",
"."
] | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/django_xworkflows/models.py#L414-L423 | train | Generic transition logging. |
rbarrois/django_xworkflows | setup.py | clean_readme | 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... | python | 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... | [
"def",
"clean_readme",
"(",
"fname",
")",
":",
"with",
"codecs",
".",
"open",
"(",
"fname",
",",
"'r'",
",",
"'utf-8'",
")",
"as",
"f",
":",
"return",
"''",
".",
"join",
"(",
"re",
".",
"sub",
"(",
"r':\\w+:`([^`]+?)( <[^<>]+>)?`'",
",",
"r'``\\1``'",
... | Cleanup README.rst for proper PyPI formatting. | [
"Cleanup",
"README",
".",
"rst",
"for",
"proper",
"PyPI",
"formatting",
"."
] | 7f6c3e54e7fd64d39541bffa654c7f2e28685270 | https://github.com/rbarrois/django_xworkflows/blob/7f6c3e54e7fd64d39541bffa654c7f2e28685270/setup.py#L31-L38 | train | Cleanup README. rst for proper PyPI formatting. |
Damgaard/PyImgur | pyimgur/__init__.py | _get_album_or_image | 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) | python | 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) | [
"def",
"_get_album_or_image",
"(",
"json",
",",
"imgur",
")",
":",
"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. | [
"Return",
"a",
"gallery",
"image",
"/",
"album",
"depending",
"on",
"what",
"the",
"json",
"represent",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L66-L70 | train | Return a gallery image or album depending on what the json represent. |
Damgaard/PyImgur | pyimgur/__init__.py | Basic_object.refresh | 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)
... | python | 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)
... | [
"def",
"refresh",
"(",
"self",
")",
":",
"resp",
"=",
"self",
".",
"_imgur",
".",
"_send_request",
"(",
"self",
".",
"_INFO_URL",
")",
"self",
".",
"_populate",
"(",
"resp",
")",
"self",
".",
"_has_fetched",
"=",
"True"
] | 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. | [
"Refresh",
"this",
"objects",
"attributes",
"to",
"the",
"newest",
"values",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L220-L229 | train | Refresh the attributes of this object to the newest values. |
Damgaard/PyImgur | pyimgur/__init__.py | Album.add_images | 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... | python | 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... | [
"def",
"add_images",
"(",
"self",
",",
"images",
")",
":",
"url",
"=",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/album/{0}/add\"",
".",
"format",
"(",
"self",
".",
"id",
")",
"params",
"=",
"{",
"'ids'",
":",
"images",
"}",
"return",
"self",
... | 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. | [
"Add",
"images",
"to",
"the",
"album",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L265-L277 | train | Add images to the album. |
Damgaard/PyImgur | pyimgur/__init__.py | Album.remove_images | 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
... | python | 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
... | [
"def",
"remove_images",
"(",
"self",
",",
"images",
")",
":",
"url",
"=",
"(",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/album/{0}/\"",
"\"remove_images\"",
".",
"format",
"(",
"self",
".",
"_delete_or_id_hash",
")",
")",
"# NOTE: Returns True and ever... | 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 ... | [
"Remove",
"images",
"from",
"the",
"album",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L294-L308 | train | Remove images from the album. |
Damgaard/PyImgur | pyimgur/__init__.py | Album.set_images | 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
... | python | 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
... | [
"def",
"set_images",
"(",
"self",
",",
"images",
")",
":",
"url",
"=",
"(",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/album/\"",
"\"{0}/\"",
".",
"format",
"(",
"self",
".",
"_delete_or_id_hash",
")",
")",
"params",
"=",
"{",
"'ids'",
":",
"i... | 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. | [
"Set",
"the",
"images",
"in",
"this",
"album",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L310-L323 | train | Set the images in this album. |
Damgaard/PyImgur | pyimgur/__init__.py | Album.submit_to_gallery | 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... | python | 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... | [
"def",
"submit_to_gallery",
"(",
"self",
",",
"title",
",",
"bypass_terms",
"=",
"False",
")",
":",
"url",
"=",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/gallery/{0}\"",
".",
"format",
"(",
"self",
".",
"id",
")",
"payload",
"=",
"{",
"'title'"... | 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... | [
"Add",
"this",
"to",
"the",
"gallery",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L325-L343 | train | Submit this item to the gallery. |
Damgaard/PyImgur | pyimgur/__init__.py | Album.update | 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... | python | 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... | [
"def",
"update",
"(",
"self",
",",
"title",
"=",
"None",
",",
"description",
"=",
"None",
",",
"images",
"=",
"None",
",",
"cover",
"=",
"None",
",",
"layout",
"=",
"None",
",",
"privacy",
"=",
"None",
")",
":",
"url",
"=",
"(",
"self",
".",
"_im... | 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... | [
"Update",
"the",
"album",
"s",
"information",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L345-L381 | train | Update the album s information. |
Damgaard/PyImgur | pyimgur/__init__.py | Comment.get_replies | 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] | python | 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] | [
"def",
"get_replies",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/comment/{0}/replies\"",
".",
"format",
"(",
"self",
".",
"id",
")",
"json",
"=",
"self",
".",
"_imgur",
".",
"_send_request",
"(",
"url",
")",
... | Get the replies to this comment. | [
"Get",
"the",
"replies",
"to",
"this",
"comment",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L432-L437 | train | Get the replies to this comment. |
Damgaard/PyImgur | pyimgur/__init__.py | Gallery_item.comment | 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,
... | python | 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,
... | [
"def",
"comment",
"(",
"self",
",",
"text",
")",
":",
"url",
"=",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/comment\"",
"payload",
"=",
"{",
"'image_id'",
":",
"self",
".",
"id",
",",
"'comment'",
":",
"text",
"}",
"resp",
"=",
"self",
".",... | Make a top-level comment to this.
:param text: The comment text. | [
"Make",
"a",
"top",
"-",
"level",
"comment",
"to",
"this",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L464-L474 | train | Make a top - level comment to this. |
Damgaard/PyImgur | pyimgur/__init__.py | Gallery_item.downvote | 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)... | python | 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)... | [
"def",
"downvote",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/gallery/{0}/vote/down\"",
".",
"format",
"(",
"self",
".",
"id",
")",
"return",
"self",
".",
"_imgur",
".",
"_send_request",
"(",
"url",
",",
"needs... | 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. | [
"Dislike",
"this",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L476-L485 | train | Downvote the item with the highest priority. |
Damgaard/PyImgur | pyimgur/__init__.py | Gallery_item.get_comments | 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] | python | 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] | [
"def",
"get_comments",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/gallery/{0}/comments\"",
".",
"format",
"(",
"self",
".",
"id",
")",
"resp",
"=",
"self",
".",
"_imgur",
".",
"_send_request",
"(",
"url",
")",
... | Get a list of the top-level comments. | [
"Get",
"a",
"list",
"of",
"the",
"top",
"-",
"level",
"comments",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L487-L491 | train | Get a list of the top - level comments. |
Damgaard/PyImgur | pyimgur/__init__.py | Gallery_item.remove_from_gallery | 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... | python | 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... | [
"def",
"remove_from_gallery",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/gallery/{0}\"",
".",
"format",
"(",
"self",
".",
"id",
")",
"self",
".",
"_imgur",
".",
"_send_request",
"(",
"url",
",",
"needs_auth",
"... | Remove this image from the gallery. | [
"Remove",
"this",
"image",
"from",
"the",
"gallery",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L493-L502 | train | Remove this image from the gallery. |
Damgaard/PyImgur | pyimgur/__init__.py | Image.download | 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... | python | 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... | [
"def",
"download",
"(",
"self",
",",
"path",
"=",
"''",
",",
"name",
"=",
"None",
",",
"overwrite",
"=",
"False",
",",
"size",
"=",
"None",
")",
":",
"def",
"save_as",
"(",
"filename",
")",
":",
"local_path",
"=",
"os",
".",
"path",
".",
"join",
... | 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... | [
"Download",
"the",
"image",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L554-L600 | train | Download the image. |
Damgaard/PyImgur | pyimgur/__init__.py | Image.update | 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(),
... | python | 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(),
... | [
"def",
"update",
"(",
"self",
",",
"title",
"=",
"None",
",",
"description",
"=",
"None",
")",
":",
"url",
"=",
"(",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/image/\"",
"\"{0}\"",
".",
"format",
"(",
"self",
".",
"_delete_or_id_hash",
")",
"... | Update the image with a new title and/or description. | [
"Update",
"the",
"image",
"with",
"a",
"new",
"title",
"and",
"/",
"or",
"description",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L631-L640 | train | Update the image with a new title and or description. |
Damgaard/PyImgur | pyimgur/__init__.py | Imgur._send_request | 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 ... | python | 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 ... | [
"def",
"_send_request",
"(",
"self",
",",
"url",
",",
"needs_auth",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: Add automatic test for timed_out access_tokens and",
"# automatically refresh it before carrying out the request.",
"if",
"self",
".",
"access_token... | 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... | [
"Handles",
"top",
"level",
"functionality",
"for",
"sending",
"requests",
"to",
"Imgur",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L692-L748 | train | Send a request to the Imgur API. |
Damgaard/PyImgur | pyimgur/__init__.py | Imgur.authorization_url | 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... | python | 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... | [
"def",
"authorization_url",
"(",
"self",
",",
"response",
",",
"state",
"=",
"\"\"",
")",
":",
"return",
"AUTHORIZE_URL",
".",
"format",
"(",
"self",
".",
"_base_url",
",",
"self",
".",
"client_id",
",",
"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 authorizing your application. If it's pin then after
authorizin... | [
"Return",
"the",
"authorization",
"url",
"that",
"s",
"needed",
"to",
"authorize",
"as",
"a",
"user",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L750-L768 | train | Returns the authorization url that s needed to authorize as a user. |
Damgaard/PyImgur | pyimgur/__init__.py | Imgur.change_authentication | 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.... | python | 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.... | [
"def",
"change_authentication",
"(",
"self",
",",
"client_id",
"=",
"None",
",",
"client_secret",
"=",
"None",
",",
"access_token",
"=",
"None",
",",
"refresh_token",
"=",
"None",
")",
":",
"# TODO: Add error checking so you cannot change client_id and retain",
"# acces... | Change the current authentication. | [
"Change",
"the",
"current",
"authentication",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L770-L778 | train | Change the current authentication. |
Damgaard/PyImgur | pyimgur/__init__.py | Imgur.create_album | 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
... | python | 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
... | [
"def",
"create_album",
"(",
"self",
",",
"title",
"=",
"None",
",",
"description",
"=",
"None",
",",
"images",
"=",
"None",
",",
"cover",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"_base_url",
"+",
"\"/3/album/\"",
"payload",
"=",
"{",
"'ids'",
... | 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... | [
"Create",
"a",
"new",
"Album",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L780-L799 | train | Create a new Album. |
Damgaard/PyImgur | pyimgur/__init__.py | Imgur.exchange_code | 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... | python | 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... | [
"def",
"exchange_code",
"(",
"self",
",",
"code",
")",
":",
"params",
"=",
"{",
"'client_id'",
":",
"self",
".",
"client_id",
",",
"'client_secret'",
":",
"self",
".",
"client_secret",
",",
"'grant_type'",
":",
"'authorization_code'",
",",
"'code'",
":",
"co... | Exchange one-use code for an access_token and request_token. | [
"Exchange",
"one",
"-",
"use",
"code",
"for",
"an",
"access_token",
"and",
"request_token",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L813-L824 | train | Exchange one - use code for an access_token and request_token. |
Damgaard/PyImgur | pyimgur/__init__.py | Imgur.exchange_pin | 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... | python | 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... | [
"def",
"exchange_pin",
"(",
"self",
",",
"pin",
")",
":",
"params",
"=",
"{",
"'client_id'",
":",
"self",
".",
"client_id",
",",
"'client_secret'",
":",
"self",
".",
"client_secret",
",",
"'grant_type'",
":",
"'pin'",
",",
"'pin'",
":",
"pin",
"}",
"resu... | Exchange one-use pin for an access_token and request_token. | [
"Exchange",
"one",
"-",
"use",
"pin",
"for",
"an",
"access_token",
"and",
"request_token",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L826-L837 | train | Exchange one - use pin for an access_token and request_token. |
Damgaard/PyImgur | pyimgur/__init__.py | Imgur.get_album | 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) | python | 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) | [
"def",
"get_album",
"(",
"self",
",",
"id",
")",
":",
"url",
"=",
"self",
".",
"_base_url",
"+",
"\"/3/album/{0}\"",
".",
"format",
"(",
"id",
")",
"json",
"=",
"self",
".",
"_send_request",
"(",
"url",
")",
"return",
"Album",
"(",
"json",
",",
"self... | Return information about this album. | [
"Return",
"information",
"about",
"this",
"album",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L839-L843 | train | Return information about this album. |
Damgaard/PyImgur | pyimgur/__init__.py | Imgur.get_at_url | 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.
... | python | 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.
... | [
"def",
"get_at_url",
"(",
"self",
",",
"url",
")",
":",
"class",
"NullDevice",
"(",
")",
":",
"def",
"write",
"(",
"self",
",",
"string",
")",
":",
"pass",
"def",
"get_gallery_item",
"(",
"id",
")",
":",
"\"\"\"\n Special helper method to get galler... | 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... | [
"Return",
"a",
"object",
"representing",
"the",
"content",
"at",
"url",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L845-L939 | train | Return a object representing the content at the given url. |
Damgaard/PyImgur | pyimgur/__init__.py | Imgur.get_comment | 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) | python | 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) | [
"def",
"get_comment",
"(",
"self",
",",
"id",
")",
":",
"url",
"=",
"self",
".",
"_base_url",
"+",
"\"/3/comment/{0}\"",
".",
"format",
"(",
"id",
")",
"json",
"=",
"self",
".",
"_send_request",
"(",
"url",
")",
"return",
"Comment",
"(",
"json",
",",
... | Return information about this comment. | [
"Return",
"information",
"about",
"this",
"comment",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L941-L945 | train | Return information about this comment. |
Damgaard/PyImgur | pyimgur/__init__.py | Imgur.get_gallery | 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... | python | 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... | [
"def",
"get_gallery",
"(",
"self",
",",
"section",
"=",
"'hot'",
",",
"sort",
"=",
"'viral'",
",",
"window",
"=",
"'day'",
",",
"show_viral",
"=",
"True",
",",
"limit",
"=",
"None",
")",
":",
"url",
"=",
"(",
"self",
".",
"_base_url",
"+",
"\"/3/gall... | 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.
... | [
"Return",
"a",
"list",
"of",
"gallery",
"albums",
"and",
"gallery",
"images",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L947-L963 | train | Get a list of albums and gallery images. |
Damgaard/PyImgur | pyimgur/__init__.py | Imgur.get_gallery_album | 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... | python | 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... | [
"def",
"get_gallery_album",
"(",
"self",
",",
"id",
")",
":",
"url",
"=",
"self",
".",
"_base_url",
"+",
"\"/3/gallery/album/{0}\"",
".",
"format",
"(",
"id",
")",
"resp",
"=",
"self",
".",
"_send_request",
"(",
"url",
")",
"return",
"Gallery_album",
"(",
... | 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. | [
"Return",
"the",
"gallery",
"album",
"matching",
"the",
"id",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L965-L975 | train | Get a gallery album by id |
Damgaard/PyImgur | pyimgur/__init__.py | Imgur.get_gallery_image | 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... | python | 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... | [
"def",
"get_gallery_image",
"(",
"self",
",",
"id",
")",
":",
"url",
"=",
"self",
".",
"_base_url",
"+",
"\"/3/gallery/image/{0}\"",
".",
"format",
"(",
"id",
")",
"resp",
"=",
"self",
".",
"_send_request",
"(",
"url",
")",
"return",
"Gallery_image",
"(",
... | 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. | [
"Return",
"the",
"gallery",
"image",
"matching",
"the",
"id",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L977-L987 | train | Get a gallery image by id |
Damgaard/PyImgur | pyimgur/__init__.py | Imgur.get_image | 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) | python | 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) | [
"def",
"get_image",
"(",
"self",
",",
"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. | [
"Return",
"a",
"Image",
"object",
"representing",
"the",
"image",
"with",
"the",
"given",
"id",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L989-L993 | train | Return a Image object representing the image with the given id. |
Damgaard/PyImgur | pyimgur/__init__.py | Imgur.get_message | 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) | python | 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) | [
"def",
"get_message",
"(",
"self",
",",
"id",
")",
":",
"url",
"=",
"self",
".",
"_base_url",
"+",
"\"/3/message/{0}\"",
".",
"format",
"(",
"id",
")",
"resp",
"=",
"self",
".",
"_send_request",
"(",
"url",
")",
"return",
"Message",
"(",
"resp",
",",
... | Return a Message object for given id.
:param id: The id of the message object to return. | [
"Return",
"a",
"Message",
"object",
"for",
"given",
"id",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L995-L1003 | train | Get a message object for given id. |
Damgaard/PyImgur | pyimgur/__init__.py | Imgur.get_notification | 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) | python | 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) | [
"def",
"get_notification",
"(",
"self",
",",
"id",
")",
":",
"url",
"=",
"self",
".",
"_base_url",
"+",
"\"/3/notification/{0}\"",
".",
"format",
"(",
"id",
")",
"resp",
"=",
"self",
".",
"_send_request",
"(",
"url",
")",
"return",
"Notification",
"(",
"... | Return a Notification object.
:param id: The id of the notification object to return. | [
"Return",
"a",
"Notification",
"object",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1005-L1013 | train | Get a specific notification object. |
Damgaard/PyImgur | pyimgur/__init__.py | Imgur.get_memes_gallery | 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... | python | 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... | [
"def",
"get_memes_gallery",
"(",
"self",
",",
"sort",
"=",
"'viral'",
",",
"window",
"=",
"'week'",
",",
"limit",
"=",
"None",
")",
":",
"url",
"=",
"(",
"self",
".",
"_base_url",
"+",
"\"/3/gallery/g/memes/{0}/{1}/{2}\"",
".",
"format",
"(",
"sort",
",",
... | 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... | [
"Return",
"a",
"list",
"of",
"gallery",
"albums",
"/",
"images",
"submitted",
"to",
"the",
"memes",
"gallery"
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1015-L1029 | train | Get a list of gallery albums or images submitted to the memes gallery |
Damgaard/PyImgur | pyimgur/__init__.py | Imgur.get_subreddit_gallery | 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... | python | 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... | [
"def",
"get_subreddit_gallery",
"(",
"self",
",",
"subreddit",
",",
"sort",
"=",
"'time'",
",",
"window",
"=",
"'top'",
",",
"limit",
"=",
"None",
")",
":",
"url",
"=",
"(",
"self",
".",
"_base_url",
"+",
"\"/3/gallery/r/{0}/{1}/{2}/{3}\"",
".",
"format",
... | 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... | [
"Return",
"a",
"list",
"of",
"gallery",
"albums",
"/",
"images",
"submitted",
"to",
"a",
"subreddit",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1048-L1065 | train | Return a list of gallery albums or images submitted to a subreddit. |
Damgaard/PyImgur | pyimgur/__init__.py | Imgur.get_subreddit_image | 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}... | python | 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}... | [
"def",
"get_subreddit_image",
"(",
"self",
",",
"subreddit",
",",
"id",
")",
":",
"url",
"=",
"self",
".",
"_base_url",
"+",
"\"/3/gallery/r/{0}/{1}\"",
".",
"format",
"(",
"subreddit",
",",
"id",
")",
"resp",
"=",
"self",
".",
"_send_request",
"(",
"url",... | 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. | [
"Return",
"the",
"Gallery_image",
"with",
"the",
"id",
"submitted",
"to",
"subreddit",
"gallery"
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1067-L1076 | train | Get the Gallery_image with the id submitted to subreddit gallery
|
Damgaard/PyImgur | pyimgur/__init__.py | Imgur.get_user | 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) | python | 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) | [
"def",
"get_user",
"(",
"self",
",",
"username",
")",
":",
"url",
"=",
"self",
".",
"_base_url",
"+",
"\"/3/account/{0}\"",
".",
"format",
"(",
"username",
")",
"json",
"=",
"self",
".",
"_send_request",
"(",
"url",
")",
"return",
"User",
"(",
"json",
... | Return a User object for this username.
:param username: The name of the user we want more information about. | [
"Return",
"a",
"User",
"object",
"for",
"this",
"username",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1078-L1086 | train | Get a User object for this username. |
Damgaard/PyImgur | pyimgur/__init__.py | Imgur.refresh_access_token | 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 ... | python | 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 ... | [
"def",
"refresh_access_token",
"(",
"self",
")",
":",
"if",
"self",
".",
"client_secret",
"is",
"None",
":",
"raise",
"Exception",
"(",
"\"client_secret must be set to execute \"",
"\"refresh_access_token.\"",
")",
"if",
"self",
".",
"refresh_token",
"is",
"None",
"... | 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. | [
"Refresh",
"the",
"access_token",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1092-L1113 | train | Refresh the access_token. |
Damgaard/PyImgur | pyimgur/__init__.py | Imgur.search_gallery | 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] | python | 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] | [
"def",
"search_gallery",
"(",
"self",
",",
"q",
")",
":",
"url",
"=",
"self",
".",
"_base_url",
"+",
"\"/3/gallery/search?q={0}\"",
".",
"format",
"(",
"q",
")",
"resp",
"=",
"self",
".",
"_send_request",
"(",
"url",
")",
"return",
"[",
"_get_album_or_imag... | Search the gallery with the given query string. | [
"Search",
"the",
"gallery",
"with",
"the",
"given",
"query",
"string",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1115-L1119 | train | Search the gallery with the given query string. |
Damgaard/PyImgur | pyimgur/__init__.py | Imgur.upload_image | 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... | python | 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... | [
"def",
"upload_image",
"(",
"self",
",",
"path",
"=",
"None",
",",
"url",
"=",
"None",
",",
"title",
"=",
"None",
",",
"description",
"=",
"None",
",",
"album",
"=",
"None",
")",
":",
"if",
"bool",
"(",
"path",
")",
"==",
"bool",
"(",
"url",
")",... | 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.
:... | [
"Upload",
"the",
"image",
"at",
"either",
"path",
"or",
"url",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1121-L1162 | train | Uploads an image at either path or url. |
Damgaard/PyImgur | pyimgur/__init__.py | Message.delete | 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') | python | 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') | [
"def",
"delete",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/message/{0}\"",
".",
"format",
"(",
"self",
".",
"id",
")",
"return",
"self",
".",
"_imgur",
".",
"_send_request",
"(",
"url",
",",
"method",
"=",
... | Delete the message. | [
"Delete",
"the",
"message",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1182-L1185 | train | Delete the message. |
Damgaard/PyImgur | pyimgur/__init__.py | Message.get_thread | 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] | python | 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] | [
"def",
"get_thread",
"(",
"self",
")",
":",
"url",
"=",
"(",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/message/{0}/thread\"",
".",
"format",
"(",
"self",
".",
"first_message",
".",
"id",
")",
")",
"resp",
"=",
"self",
".",
"_imgur",
".",
"_se... | Return the message thread this Message is in. | [
"Return",
"the",
"message",
"thread",
"this",
"Message",
"is",
"in",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1187-L1192 | train | Return the message thread this Message is in. |
Damgaard/PyImgur | pyimgur/__init__.py | Message.reply | 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.
... | python | 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.
... | [
"def",
"reply",
"(",
"self",
",",
"body",
")",
":",
"return",
"self",
".",
"author",
".",
"send_message",
"(",
"body",
"=",
"body",
",",
"reply_to",
"=",
"self",
".",
"id",
")"
] | 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",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1194-L1204 | train | Reply to this message. |
Damgaard/PyImgur | pyimgur/__init__.py | User.change_settings | 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
... | python | 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
... | [
"def",
"change_settings",
"(",
"self",
",",
"bio",
"=",
"None",
",",
"public_images",
"=",
"None",
",",
"messaging_enabled",
"=",
"None",
",",
"album_privacy",
"=",
"None",
",",
"accepted_gallery_terms",
"=",
"None",
")",
":",
"# NOTE: album_privacy should maybe b... | 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... | [
"Update",
"the",
"settings",
"for",
"the",
"user",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1265-L1287 | train | Update the settings of the user. |
Damgaard/PyImgur | pyimgur/__init__.py | User.get_albums | 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,
... | python | 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,
... | [
"def",
"get_albums",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"url",
"=",
"(",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/account/{0}/albums/{1}\"",
".",
"format",
"(",
"self",
".",
"name",
",",
"'{}'",
")",
")",
"resp",
"=",
"self",
... | Return a list of the user's albums.
Secret and hidden albums are only returned if this is the logged-in
user. | [
"Return",
"a",
"list",
"of",
"the",
"user",
"s",
"albums",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1294-L1304 | train | Return a list of the user s albums. |
Damgaard/PyImgur | pyimgur/__init__.py | User.get_favorites | 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] | python | 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] | [
"def",
"get_favorites",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/account/{0}/favorites\"",
".",
"format",
"(",
"self",
".",
"name",
")",
"resp",
"=",
"self",
".",
"_imgur",
".",
"_send_request",
"(",
"url",
"... | Return the users favorited images. | [
"Return",
"the",
"users",
"favorited",
"images",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1312-L1316 | train | Return the users favorited images. |
Damgaard/PyImgur | pyimgur/__init__.py | User.get_gallery_favorites | 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... | python | 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... | [
"def",
"get_gallery_favorites",
"(",
"self",
")",
":",
"url",
"=",
"(",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/account/{0}/gallery_favorites\"",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"resp",
"=",
"self",
".",
"_imgur",
".",
"_send... | Get a list of the images in the gallery this user has favorited. | [
"Get",
"a",
"list",
"of",
"the",
"images",
"in",
"the",
"gallery",
"this",
"user",
"has",
"favorited",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1318-L1323 | train | Get a list of the images in the gallery this user has favorited. |
Damgaard/PyImgur | pyimgur/__init__.py | User.get_gallery_profile | 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) | python | 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) | [
"def",
"get_gallery_profile",
"(",
"self",
")",
":",
"url",
"=",
"(",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/account/{0}/\"",
"\"gallery_profile\"",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"return",
"self",
".",
"_imgur",
".",
"_sen... | Return the users gallery profile. | [
"Return",
"the",
"users",
"gallery",
"profile",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1325-L1329 | train | Return the users gallery profile. |
Damgaard/PyImgur | pyimgur/__init__.py | User.has_verified_email | 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.
... | python | 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.
... | [
"def",
"has_verified_email",
"(",
"self",
")",
":",
"url",
"=",
"(",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/account/{0}/\"",
"\"verifyemail\"",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"return",
"self",
".",
"_imgur",
".",
"_send_req... | 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?"
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1331-L1341 | train | Returns True if the user has verified that the email he has given is legit? |
Damgaard/PyImgur | pyimgur/__init__.py | User.get_images | 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... | python | 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... | [
"def",
"get_images",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"url",
"=",
"(",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/account/{0}/\"",
"\"images/{1}\"",
".",
"format",
"(",
"self",
".",
"name",
",",
"'{}'",
")",
")",
"resp",
"=",
... | Return all of the images associated with the user. | [
"Return",
"all",
"of",
"the",
"images",
"associated",
"with",
"the",
"user",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1343-L1348 | train | Return all of the images associated with the user. |
Damgaard/PyImgur | pyimgur/__init__.py | User.get_messages | 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/"
... | python | 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/"
... | [
"def",
"get_messages",
"(",
"self",
",",
"new",
"=",
"True",
")",
":",
"url",
"=",
"(",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/account/{0}/notifications/\"",
"\"messages\"",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"result",
"=",
"... | Return all messages sent to this user, formatted as a notification.
:param new: False for all notifications, True for only non-viewed
notifications. | [
"Return",
"all",
"messages",
"sent",
"to",
"this",
"user",
"formatted",
"as",
"a",
"notification",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1350-L1362 | train | Return all messages sent to this user formatted as a notification. |
Damgaard/PyImgur | pyimgur/__init__.py | User.get_notifications | 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... | python | 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... | [
"def",
"get_notifications",
"(",
"self",
",",
"new",
"=",
"True",
")",
":",
"url",
"=",
"(",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/account/{0}/\"",
"\"notifications\"",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"resp",
"=",
"self",... | Return all the notifications for this user. | [
"Return",
"all",
"the",
"notifications",
"for",
"this",
"user",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1364-L1373 | train | Return all the notifications for this user. |
Damgaard/PyImgur | pyimgur/__init__.py | User.get_replies | 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... | python | 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... | [
"def",
"get_replies",
"(",
"self",
",",
"new",
"=",
"True",
")",
":",
"url",
"=",
"(",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/account/{0}/\"",
"\"notifications/replies\"",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"return",
"self",
... | Return all reply notifications for this user.
:param new: False for all notifications, True for only non-viewed
notifications. | [
"Return",
"all",
"reply",
"notifications",
"for",
"this",
"user",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1375-L1384 | train | Return all replies for this user. |
Damgaard/PyImgur | pyimgur/__init__.py | User.get_settings | 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) | python | 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) | [
"def",
"get_settings",
"(",
"self",
")",
":",
"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. | [
"Returns",
"current",
"settings",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1386-L1393 | train | Returns current settings. |
Damgaard/PyImgur | pyimgur/__init__.py | User.get_submissions | 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... | python | 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... | [
"def",
"get_submissions",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"url",
"=",
"(",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/account/{0}/submissions/\"",
"\"{1}\"",
".",
"format",
"(",
"self",
".",
"name",
",",
"'{}'",
")",
")",
"resp... | Return a list of the images a user has submitted to the gallery. | [
"Return",
"a",
"list",
"of",
"the",
"images",
"a",
"user",
"has",
"submitted",
"to",
"the",
"gallery",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1400-L1405 | train | Return a list of the images a user has submitted to the gallery. |
Damgaard/PyImgur | pyimgur/__init__.py | User.send_message | 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... | python | 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... | [
"def",
"send_message",
"(",
"self",
",",
"body",
",",
"subject",
"=",
"None",
",",
"reply_to",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/message\"",
"parent_id",
"=",
"reply_to",
".",
"id",
"if",
"isinstance",... | 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... | [
"Send",
"a",
"message",
"to",
"this",
"user",
"from",
"the",
"logged",
"in",
"user",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1407-L1425 | train | Send a message to this user from the logged in user. |
Damgaard/PyImgur | pyimgur/__init__.py | User.send_verification_email | 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))
... | python | 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))
... | [
"def",
"send_verification_email",
"(",
"self",
")",
":",
"url",
"=",
"(",
"self",
".",
"_imgur",
".",
"_base_url",
"+",
"\"/3/account/{0}\"",
"\"/verifyemail\"",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"self",
".",
"_imgur",
".",
"_send_request",
... | Send verification email to this users email address.
Remember that the verification email may end up in the users spam
folder. | [
"Send",
"verification",
"email",
"to",
"this",
"users",
"email",
"address",
"."
] | 606f17078d24158632f807430f8d0b9b3cd8b312 | https://github.com/Damgaard/PyImgur/blob/606f17078d24158632f807430f8d0b9b3cd8b312/pyimgur/__init__.py#L1427-L1436 | train | Send verification email to this users email address. |
nir0s/backtrace | backtrace.py | hook | 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... | python | 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... | [
"def",
"hook",
"(",
"reverse",
"=",
"False",
",",
"align",
"=",
"False",
",",
"strip_path",
"=",
"False",
",",
"enable_on_envvar_only",
"=",
"False",
",",
"on_tty",
"=",
"False",
",",
"conservative",
"=",
"False",
",",
"styles",
"=",
"None",
",",
"tb",
... | 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... | [
"Hook",
"the",
"current",
"excepthook",
"to",
"the",
"backtrace",
"."
] | a1f75c956f669a6175088693802d5392e6bd7e51 | https://github.com/nir0s/backtrace/blob/a1f75c956f669a6175088693802d5392e6bd7e51/backtrace.py#L108-L186 | train | Hook the current excepthook to the backtrace. |
nir0s/backtrace | backtrace.py | _extract_traceback | 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... | python | 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... | [
"def",
"_extract_traceback",
"(",
"text",
")",
":",
"capture",
"=",
"False",
"entries",
"=",
"[",
"]",
"all_else",
"=",
"[",
"]",
"ignore_trace",
"=",
"False",
"# In python 3, a traceback may includes output from a reraise.",
"# e.g, an exception is captured and reraised wi... | 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... | [
"Receive",
"a",
"list",
"of",
"strings",
"representing",
"the",
"input",
"from",
"stdin",
"and",
"return",
"the",
"restructured",
"backtrace",
"."
] | a1f75c956f669a6175088693802d5392e6bd7e51 | https://github.com/nir0s/backtrace/blob/a1f75c956f669a6175088693802d5392e6bd7e51/backtrace.py#L195-L254 | train | Extract a traceback from the input text. |
nir0s/backtrace | backtrace.py | _Hook.generate_backtrace | 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 = []
... | python | 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 = []
... | [
"def",
"generate_backtrace",
"(",
"self",
",",
"styles",
")",
":",
"backtrace",
"=",
"[",
"]",
"for",
"entry",
"in",
"self",
".",
"entries",
":",
"backtrace",
".",
"append",
"(",
"self",
".",
"rebuild_entry",
"(",
"entry",
",",
"styles",
")",
")",
"# G... | 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? | [
"Return",
"the",
"(",
"potentially",
")",
"aligned",
"rebuit",
"traceback"
] | a1f75c956f669a6175088693802d5392e6bd7e51 | https://github.com/nir0s/backtrace/blob/a1f75c956f669a6175088693802d5392e6bd7e51/backtrace.py#L88-L105 | train | Return the potentially aligned traceback for the current set of entries. |
PaulHancock/Aegean | AegeanTools/models.py | classify_catalog | 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.... | python | 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.... | [
"def",
"classify_catalog",
"(",
"catalog",
")",
":",
"components",
"=",
"[",
"]",
"islands",
"=",
"[",
"]",
"simples",
"=",
"[",
"]",
"for",
"source",
"in",
"catalog",
":",
"if",
"isinstance",
"(",
"source",
",",
"OutputSource",
")",
":",
"components",
... | 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 : ... | [
"Look",
"at",
"a",
"list",
"of",
"sources",
"and",
"split",
"them",
"according",
"to",
"their",
"class",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/models.py#L520-L551 | train | Classifies a list of sources and splits them according to their class. |
PaulHancock/Aegean | AegeanTools/models.py | island_itergen | 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... | python | 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... | [
"def",
"island_itergen",
"(",
"catalog",
")",
":",
"# reverse sort so that we can pop the last elements and get an increasing island number",
"catalog",
"=",
"sorted",
"(",
"catalog",
")",
"catalog",
".",
"reverse",
"(",
")",
"group",
"=",
"[",
"]",
"# using pop and keepi... | 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
... | [
"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"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/models.py#L554-L597 | train | Iterate over a catalog of sources and return an island worth of sources at a time. |
PaulHancock/Aegean | AegeanTools/models.py | SimpleSource._sanitise | 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... | python | 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... | [
"def",
"_sanitise",
"(",
"self",
")",
":",
"for",
"k",
"in",
"self",
".",
"__dict__",
":",
"if",
"isinstance",
"(",
"self",
".",
"__dict__",
"[",
"k",
"]",
",",
"np",
".",
"float32",
")",
":",
"# np.float32 has a broken __str__ method",
"self",
".",
"__d... | Convert attributes of type npumpy.float32 to numpy.float64 so that they will print properly. | [
"Convert",
"attributes",
"of",
"type",
"npumpy",
".",
"float32",
"to",
"numpy",
".",
"float64",
"so",
"that",
"they",
"will",
"print",
"properly",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/models.py#L74-L80 | train | Sanitize the attributes of the object so that they can print properly. |
PaulHancock/Aegean | AegeanTools/models.py | SimpleSource.as_list | 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 | python | 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 | [
"def",
"as_list",
"(",
"self",
")",
":",
"self",
".",
"_sanitise",
"(",
")",
"l",
"=",
"[",
"]",
"for",
"name",
"in",
"self",
".",
"names",
":",
"l",
".",
"append",
"(",
"getattr",
"(",
"self",
",",
"name",
")",
")",
"return",
"l"
] | Return an *ordered* list of the source attributes | [
"Return",
"an",
"*",
"ordered",
"*",
"list",
"of",
"the",
"source",
"attributes"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/models.py#L89-L97 | train | Return an ordered list of the source attributes |
PaulHancock/Aegean | AegeanTools/regions.py | Region.add_circles | 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
... | python | 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
... | [
"def",
"add_circles",
"(",
"self",
",",
"ra_cen",
",",
"dec_cen",
",",
"radius",
",",
"depth",
"=",
"None",
")",
":",
"if",
"depth",
"is",
"None",
"or",
"depth",
">",
"self",
".",
"maxdepth",
":",
"depth",
"=",
"self",
".",
"maxdepth",
"try",
":",
... | 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. | [
"Add",
"one",
"or",
"more",
"circles",
"to",
"this",
"region"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/regions.py#L83-L111 | train | Add one or more circles to this region. |
PaulHancock/Aegean | AegeanTools/regions.py | Region.add_poly | 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... | python | 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... | [
"def",
"add_poly",
"(",
"self",
",",
"positions",
",",
"depth",
"=",
"None",
")",
":",
"if",
"not",
"(",
"len",
"(",
"positions",
")",
">=",
"3",
")",
":",
"raise",
"AssertionError",
"(",
"\"A minimum of three coordinate pairs are required\"",
")",
"if",
"de... | 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. | [
"Add",
"a",
"single",
"polygon",
"to",
"this",
"region",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/regions.py#L113-L135 | train | Adds a single polygon to this region. |
PaulHancock/Aegean | AegeanTools/regions.py | Region.add_pixels | 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.... | python | 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.... | [
"def",
"add_pixels",
"(",
"self",
",",
"pix",
",",
"depth",
")",
":",
"if",
"depth",
"not",
"in",
"self",
".",
"pixeldict",
":",
"self",
".",
"pixeldict",
"[",
"depth",
"]",
"=",
"set",
"(",
")",
"self",
".",
"pixeldict",
"[",
"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. | [
"Add",
"one",
"or",
"more",
"HEALPix",
"pixels",
"to",
"this",
"region",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/regions.py#L137-L151 | train | Adds one or more HEALPix pixels to this region. |
PaulHancock/Aegean | AegeanTools/regions.py | Region.get_area | 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
-------
... | python | 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
-------
... | [
"def",
"get_area",
"(",
"self",
",",
"degrees",
"=",
"True",
")",
":",
"area",
"=",
"0",
"for",
"d",
"in",
"range",
"(",
"1",
",",
"self",
".",
"maxdepth",
"+",
"1",
")",
":",
"area",
"+=",
"len",
"(",
"self",
".",
"pixeldict",
"[",
"d",
"]",
... | 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. | [
"Calculate",
"the",
"total",
"area",
"represented",
"by",
"this",
"region",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/regions.py#L153-L171 | train | Calculate the total area of the region. |
PaulHancock/Aegean | AegeanTools/regions.py | Region._demote_all | 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:... | python | 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:... | [
"def",
"_demote_all",
"(",
"self",
")",
":",
"# only do the calculations if the demoted list is empty",
"if",
"len",
"(",
"self",
".",
"demoted",
")",
"==",
"0",
":",
"pd",
"=",
"self",
".",
"pixeldict",
"for",
"d",
"in",
"range",
"(",
"1",
",",
"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. | [
"Convert",
"the",
"multi",
"-",
"depth",
"pixeldict",
"into",
"a",
"single",
"set",
"of",
"pixels",
"at",
"the",
"deepest",
"layer",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/regions.py#L185-L199 | train | Convert the multi - depth pixeldict into a single set of pixels at the deepest layer. |
PaulHancock/Aegean | AegeanTools/regions.py | Region._renorm | 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,... | python | 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,... | [
"def",
"_renorm",
"(",
"self",
")",
":",
"self",
".",
"demoted",
"=",
"set",
"(",
")",
"# convert all to lowest level",
"self",
".",
"_demote_all",
"(",
")",
"# now promote as needed",
"for",
"d",
"in",
"range",
"(",
"self",
".",
"maxdepth",
",",
"2",
",",... | Remake the pixel dictionary, merging groups of pixels at level N into a single pixel
at level N-1 | [
"Remake",
"the",
"pixel",
"dictionary",
"merging",
"groups",
"of",
"pixels",
"at",
"level",
"N",
"into",
"a",
"single",
"pixel",
"at",
"level",
"N",
"-",
"1"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/regions.py#L201-L221 | train | Re - creates the pixel dictionary for the level N. |
PaulHancock/Aegean | AegeanTools/regions.py | Region.sky_within | def sky_within(self, ra, dec, degin=False):
"""
Test whether a sky position is within this region
Parameters
----------
ra, dec : float
Sky position.
degin : bool
If True the ra/dec is interpreted as degrees, otherwise as radians.
Def... | python | def sky_within(self, ra, dec, degin=False):
"""
Test whether a sky position is within this region
Parameters
----------
ra, dec : float
Sky position.
degin : bool
If True the ra/dec is interpreted as degrees, otherwise as radians.
Def... | [
"def",
"sky_within",
"(",
"self",
",",
"ra",
",",
"dec",
",",
"degin",
"=",
"False",
")",
":",
"sky",
"=",
"self",
".",
"radec2sky",
"(",
"ra",
",",
"dec",
")",
"if",
"degin",
":",
"sky",
"=",
"np",
".",
"radians",
"(",
"sky",
")",
"theta_phi",
... | Test whether a sky position is within this region
Parameters
----------
ra, dec : float
Sky position.
degin : bool
If True the ra/dec is interpreted as degrees, otherwise as radians.
Default = False.
Returns
-------
within : ... | [
"Test",
"whether",
"a",
"sky",
"position",
"is",
"within",
"this",
"region"
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/regions.py#L223-L257 | train | Test whether a given sky position is within this region. |
PaulHancock/Aegean | AegeanTools/regions.py | Region.union | def union(self, other, renorm=True):
"""
Add another Region by performing union on their pixlists.
Parameters
----------
other : :class:`AegeanTools.regions.Region`
The region to be combined.
renorm : bool
Perform renormalisation after the operat... | python | def union(self, other, renorm=True):
"""
Add another Region by performing union on their pixlists.
Parameters
----------
other : :class:`AegeanTools.regions.Region`
The region to be combined.
renorm : bool
Perform renormalisation after the operat... | [
"def",
"union",
"(",
"self",
",",
"other",
",",
"renorm",
"=",
"True",
")",
":",
"# merge the pixels that are common to both",
"for",
"d",
"in",
"range",
"(",
"1",
",",
"min",
"(",
"self",
".",
"maxdepth",
",",
"other",
".",
"maxdepth",
")",
"+",
"1",
... | Add another Region by performing union on their pixlists.
Parameters
----------
other : :class:`AegeanTools.regions.Region`
The region to be combined.
renorm : bool
Perform renormalisation after the operation?
Default = True. | [
"Add",
"another",
"Region",
"by",
"performing",
"union",
"on",
"their",
"pixlists",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/regions.py#L259-L285 | train | Add another Region by performing union on their pixlists. |
PaulHancock/Aegean | AegeanTools/regions.py | Region.without | def without(self, other):
"""
Subtract another Region by performing a difference operation on their pixlists.
Requires both regions to have the same maxdepth.
Parameters
----------
other : :class:`AegeanTools.regions.Region`
The region to be combined.
... | python | def without(self, other):
"""
Subtract another Region by performing a difference operation on their pixlists.
Requires both regions to have the same maxdepth.
Parameters
----------
other : :class:`AegeanTools.regions.Region`
The region to be combined.
... | [
"def",
"without",
"(",
"self",
",",
"other",
")",
":",
"# work only on the lowest level",
"# TODO: Allow this to be done for regions with different depths.",
"if",
"not",
"(",
"self",
".",
"maxdepth",
"==",
"other",
".",
"maxdepth",
")",
":",
"raise",
"AssertionError",
... | Subtract another Region by performing a difference operation on their pixlists.
Requires both regions to have the same maxdepth.
Parameters
----------
other : :class:`AegeanTools.regions.Region`
The region to be combined. | [
"Subtract",
"another",
"Region",
"by",
"performing",
"a",
"difference",
"operation",
"on",
"their",
"pixlists",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/regions.py#L287-L305 | train | Subtract another Region from this one by performing a difference operation on their pixlists. |
PaulHancock/Aegean | AegeanTools/regions.py | Region.intersect | def intersect(self, other):
"""
Combine with another Region by performing intersection on their pixlists.
Requires both regions to have the same maxdepth.
Parameters
----------
other : :class:`AegeanTools.regions.Region`
The region to be combined.
""... | python | def intersect(self, other):
"""
Combine with another Region by performing intersection on their pixlists.
Requires both regions to have the same maxdepth.
Parameters
----------
other : :class:`AegeanTools.regions.Region`
The region to be combined.
""... | [
"def",
"intersect",
"(",
"self",
",",
"other",
")",
":",
"# work only on the lowest level",
"# TODO: Allow this to be done for regions with different depths.",
"if",
"not",
"(",
"self",
".",
"maxdepth",
"==",
"other",
".",
"maxdepth",
")",
":",
"raise",
"AssertionError"... | Combine with another Region by performing intersection on their pixlists.
Requires both regions to have the same maxdepth.
Parameters
----------
other : :class:`AegeanTools.regions.Region`
The region to be combined. | [
"Combine",
"with",
"another",
"Region",
"by",
"performing",
"intersection",
"on",
"their",
"pixlists",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/regions.py#L307-L325 | train | Combine with another Region by performing intersection on their pixlists. |
PaulHancock/Aegean | AegeanTools/regions.py | Region.symmetric_difference | def symmetric_difference(self, other):
"""
Combine with another Region by performing the symmetric difference of their pixlists.
Requires both regions to have the same maxdepth.
Parameters
----------
other : :class:`AegeanTools.regions.Region`
The region to ... | python | def symmetric_difference(self, other):
"""
Combine with another Region by performing the symmetric difference of their pixlists.
Requires both regions to have the same maxdepth.
Parameters
----------
other : :class:`AegeanTools.regions.Region`
The region to ... | [
"def",
"symmetric_difference",
"(",
"self",
",",
"other",
")",
":",
"# work only on the lowest level",
"# TODO: Allow this to be done for regions with different depths.",
"if",
"not",
"(",
"self",
".",
"maxdepth",
"==",
"other",
".",
"maxdepth",
")",
":",
"raise",
"Asse... | Combine with another Region by performing the symmetric difference of their pixlists.
Requires both regions to have the same maxdepth.
Parameters
----------
other : :class:`AegeanTools.regions.Region`
The region to be combined. | [
"Combine",
"with",
"another",
"Region",
"by",
"performing",
"the",
"symmetric",
"difference",
"of",
"their",
"pixlists",
"."
] | 185d2b4a51b48441a1df747efc9a5271c79399fd | https://github.com/PaulHancock/Aegean/blob/185d2b4a51b48441a1df747efc9a5271c79399fd/AegeanTools/regions.py#L327-L345 | train | Combine with another Region by performing the symmetric difference of their pixlists. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.