repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
fedora-infra/fedora-messaging | fedora_messaging/twisted/protocol.py | FedoraMessagingProtocolV2.consume | def consume(self, callback, queue, previous_consumer=None):
"""
Register a message consumer that executes the provided callback when
messages are received.
The queue must exist prior to calling this method. If a consumer
already exists for the given queue, the callback is simply... | python | def consume(self, callback, queue, previous_consumer=None):
"""
Register a message consumer that executes the provided callback when
messages are received.
The queue must exist prior to calling this method. If a consumer
already exists for the given queue, the callback is simply... | [
"def",
"consume",
"(",
"self",
",",
"callback",
",",
"queue",
",",
"previous_consumer",
"=",
"None",
")",
":",
"if",
"queue",
"in",
"self",
".",
"_consumers",
":",
"self",
".",
"_consumers",
"[",
"queue",
"]",
".",
"callback",
"=",
"callback",
"defer",
... | Register a message consumer that executes the provided callback when
messages are received.
The queue must exist prior to calling this method. If a consumer
already exists for the given queue, the callback is simply updated and
any new messages for that consumer use the new callback.
... | [
"Register",
"a",
"message",
"consumer",
"that",
"executes",
"the",
"provided",
"callback",
"when",
"messages",
"are",
"received",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/protocol.py#L318-L461 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/protocol.py | FedoraMessagingProtocolV2.declare_exchanges | def declare_exchanges(self, exchanges):
"""
Declare a number of exchanges at once.
This simply wraps the :meth:`pika.channel.Channel.exchange_declare`
method and deals with error handling and channel allocation.
Args:
exchanges (list of dict): A list of dictionaries... | python | def declare_exchanges(self, exchanges):
"""
Declare a number of exchanges at once.
This simply wraps the :meth:`pika.channel.Channel.exchange_declare`
method and deals with error handling and channel allocation.
Args:
exchanges (list of dict): A list of dictionaries... | [
"def",
"declare_exchanges",
"(",
"self",
",",
"exchanges",
")",
":",
"channel",
"=",
"yield",
"self",
".",
"_allocate_channel",
"(",
")",
"try",
":",
"for",
"exchange",
"in",
"exchanges",
":",
"args",
"=",
"exchange",
".",
"copy",
"(",
")",
"args",
".",
... | Declare a number of exchanges at once.
This simply wraps the :meth:`pika.channel.Channel.exchange_declare`
method and deals with error handling and channel allocation.
Args:
exchanges (list of dict): A list of dictionaries, where each dictionary
represents an exchan... | [
"Declare",
"a",
"number",
"of",
"exchanges",
"at",
"once",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/protocol.py#L464-L505 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/protocol.py | FedoraMessagingProtocolV2.declare_queues | def declare_queues(self, queues):
"""
Declare a list of queues.
Args:
queues (list of dict): A list of dictionaries, where each dictionary
represents an exchange. Each dictionary can have the following keys:
* queue (str): The name of the queue
... | python | def declare_queues(self, queues):
"""
Declare a list of queues.
Args:
queues (list of dict): A list of dictionaries, where each dictionary
represents an exchange. Each dictionary can have the following keys:
* queue (str): The name of the queue
... | [
"def",
"declare_queues",
"(",
"self",
",",
"queues",
")",
":",
"channel",
"=",
"yield",
"self",
".",
"_allocate_channel",
"(",
")",
"try",
":",
"for",
"queue",
"in",
"queues",
":",
"args",
"=",
"queue",
".",
"copy",
"(",
")",
"args",
".",
"setdefault",... | Declare a list of queues.
Args:
queues (list of dict): A list of dictionaries, where each dictionary
represents an exchange. Each dictionary can have the following keys:
* queue (str): The name of the queue
* passive (bool): If true, this will ju... | [
"Declare",
"a",
"list",
"of",
"queues",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/protocol.py#L508-L548 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/protocol.py | FedoraMessagingProtocolV2.bind_queues | def bind_queues(self, bindings):
"""
Declare a set of bindings between queues and exchanges.
Args:
bindings (list of dict): A list of binding definitions. Each dictionary
must contain the "queue" key whose value is the name of the queue
to create the ... | python | def bind_queues(self, bindings):
"""
Declare a set of bindings between queues and exchanges.
Args:
bindings (list of dict): A list of binding definitions. Each dictionary
must contain the "queue" key whose value is the name of the queue
to create the ... | [
"def",
"bind_queues",
"(",
"self",
",",
"bindings",
")",
":",
"channel",
"=",
"yield",
"self",
".",
"_allocate_channel",
"(",
")",
"try",
":",
"for",
"binding",
"in",
"bindings",
":",
"try",
":",
"yield",
"channel",
".",
"queue_bind",
"(",
"*",
"*",
"b... | Declare a set of bindings between queues and exchanges.
Args:
bindings (list of dict): A list of binding definitions. Each dictionary
must contain the "queue" key whose value is the name of the queue
to create the binding on, as well as the "exchange" key whose value... | [
"Declare",
"a",
"set",
"of",
"bindings",
"between",
"queues",
"and",
"exchanges",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/protocol.py#L551-L582 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/protocol.py | FedoraMessagingProtocolV2.halt | def halt(self):
"""
Signal to consumers they should stop after finishing any messages
currently being processed, then close the connection.
Returns:
defer.Deferred: fired when all consumers have successfully stopped
and the connection is closed.
"""
... | python | def halt(self):
"""
Signal to consumers they should stop after finishing any messages
currently being processed, then close the connection.
Returns:
defer.Deferred: fired when all consumers have successfully stopped
and the connection is closed.
"""
... | [
"def",
"halt",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_closed",
":",
"# We were asked to stop because the connection is already gone.",
"# There's no graceful way to stop because we can't acknowledge",
"# messages in the middle of being processed.",
"_std_log",
".",
"info",
"... | Signal to consumers they should stop after finishing any messages
currently being processed, then close the connection.
Returns:
defer.Deferred: fired when all consumers have successfully stopped
and the connection is closed. | [
"Signal",
"to",
"consumers",
"they",
"should",
"stop",
"after",
"finishing",
"any",
"messages",
"currently",
"being",
"processed",
"then",
"close",
"the",
"connection",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/protocol.py#L585-L617 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/protocol.py | FedoraMessagingProtocol._read | def _read(self, queue_object, consumer):
"""
The loop that reads from the message queue and calls the consumer callback
wrapper.
queue_object (pika.adapters.twisted_connection.ClosableDeferredQueue):
The AMQP queue the consumer is bound to.
consumer (dict): A diction... | python | def _read(self, queue_object, consumer):
"""
The loop that reads from the message queue and calls the consumer callback
wrapper.
queue_object (pika.adapters.twisted_connection.ClosableDeferredQueue):
The AMQP queue the consumer is bound to.
consumer (dict): A diction... | [
"def",
"_read",
"(",
"self",
",",
"queue_object",
",",
"consumer",
")",
":",
"while",
"self",
".",
"_running",
":",
"try",
":",
"_channel",
",",
"delivery_frame",
",",
"properties",
",",
"body",
"=",
"yield",
"queue_object",
".",
"get",
"(",
")",
"except... | The loop that reads from the message queue and calls the consumer callback
wrapper.
queue_object (pika.adapters.twisted_connection.ClosableDeferredQueue):
The AMQP queue the consumer is bound to.
consumer (dict): A dictionary describing the consumer for the given
queue_o... | [
"The",
"loop",
"that",
"reads",
"from",
"the",
"message",
"queue",
"and",
"calls",
"the",
"consumer",
"callback",
"wrapper",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/protocol.py#L659-L704 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/protocol.py | FedoraMessagingProtocol._on_message | def _on_message(self, delivery_frame, properties, body, consumer):
"""
Callback when a message is received from the server.
This method wraps a user-registered callback for message delivery. It
decodes the message body, determines the message schema to validate the
message with,... | python | def _on_message(self, delivery_frame, properties, body, consumer):
"""
Callback when a message is received from the server.
This method wraps a user-registered callback for message delivery. It
decodes the message body, determines the message schema to validate the
message with,... | [
"def",
"_on_message",
"(",
"self",
",",
"delivery_frame",
",",
"properties",
",",
"body",
",",
"consumer",
")",
":",
"_legacy_twisted_log",
".",
"msg",
"(",
"\"Message arrived with delivery tag {tag} for {consumer}\"",
",",
"tag",
"=",
"delivery_frame",
".",
"delivery... | Callback when a message is received from the server.
This method wraps a user-registered callback for message delivery. It
decodes the message body, determines the message schema to validate the
message with, and validates the message before passing it on to the
user callback.
... | [
"Callback",
"when",
"a",
"message",
"is",
"received",
"from",
"the",
"server",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/protocol.py#L707-L794 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/protocol.py | FedoraMessagingProtocol.consume | def consume(self, callback, queue):
"""
Register a message consumer that executes the provided callback when
messages are received.
The queue must exist prior to calling this method. If a consumer
already exists for the given queue, the callback is simply updated and
an... | python | def consume(self, callback, queue):
"""
Register a message consumer that executes the provided callback when
messages are received.
The queue must exist prior to calling this method. If a consumer
already exists for the given queue, the callback is simply updated and
an... | [
"def",
"consume",
"(",
"self",
",",
"callback",
",",
"queue",
")",
":",
"if",
"queue",
"in",
"self",
".",
"_consumers",
"and",
"self",
".",
"_consumers",
"[",
"queue",
"]",
".",
"channel",
".",
"is_open",
":",
"consumer",
"=",
"Consumer",
"(",
"tag",
... | Register a message consumer that executes the provided callback when
messages are received.
The queue must exist prior to calling this method. If a consumer
already exists for the given queue, the callback is simply updated and
any new messages for that consumer use the new callback.
... | [
"Register",
"a",
"message",
"consumer",
"that",
"executes",
"the",
"provided",
"callback",
"when",
"messages",
"are",
"received",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/protocol.py#L797-L852 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/protocol.py | FedoraMessagingProtocol.cancel | def cancel(self, queue):
"""
Cancel the consumer for a queue.
Args:
queue (str): The name of the queue the consumer is subscribed to.
Returns:
defer.Deferred: A Deferred that fires when the consumer
is canceled, or None if the consumer was alread... | python | def cancel(self, queue):
"""
Cancel the consumer for a queue.
Args:
queue (str): The name of the queue the consumer is subscribed to.
Returns:
defer.Deferred: A Deferred that fires when the consumer
is canceled, or None if the consumer was alread... | [
"def",
"cancel",
"(",
"self",
",",
"queue",
")",
":",
"try",
":",
"consumer",
"=",
"self",
".",
"_consumers",
"[",
"queue",
"]",
"yield",
"consumer",
".",
"channel",
".",
"basic_cancel",
"(",
"consumer_tag",
"=",
"consumer",
".",
"tag",
")",
"except",
... | Cancel the consumer for a queue.
Args:
queue (str): The name of the queue the consumer is subscribed to.
Returns:
defer.Deferred: A Deferred that fires when the consumer
is canceled, or None if the consumer was already canceled. Wrap
the call in ... | [
"Cancel",
"the",
"consumer",
"for",
"a",
"queue",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/protocol.py#L855-L882 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/protocol.py | FedoraMessagingProtocol.resumeProducing | def resumeProducing(self):
"""
Starts or resumes the retrieval of messages from the server queue.
This method starts receiving messages from the server, they will be
passed to the consumer callback.
.. note:: This is called automatically when :meth:`.consume` is called,
... | python | def resumeProducing(self):
"""
Starts or resumes the retrieval of messages from the server queue.
This method starts receiving messages from the server, they will be
passed to the consumer callback.
.. note:: This is called automatically when :meth:`.consume` is called,
... | [
"def",
"resumeProducing",
"(",
"self",
")",
":",
"# Start consuming",
"self",
".",
"_running",
"=",
"True",
"for",
"consumer",
"in",
"self",
".",
"_consumers",
".",
"values",
"(",
")",
":",
"queue_object",
",",
"_",
"=",
"yield",
"consumer",
".",
"channel"... | Starts or resumes the retrieval of messages from the server queue.
This method starts receiving messages from the server, they will be
passed to the consumer callback.
.. note:: This is called automatically when :meth:`.consume` is called,
so users should not need to call this unle... | [
"Starts",
"or",
"resumes",
"the",
"retrieval",
"of",
"messages",
"from",
"the",
"server",
"queue",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/protocol.py#L885-L912 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/protocol.py | FedoraMessagingProtocol.pauseProducing | def pauseProducing(self):
"""
Pause the reception of messages by canceling all existing consumers.
This does not disconnect from the server.
Message reception can be resumed with :meth:`resumeProducing`.
Returns:
Deferred: fired when the production is paused.
... | python | def pauseProducing(self):
"""
Pause the reception of messages by canceling all existing consumers.
This does not disconnect from the server.
Message reception can be resumed with :meth:`resumeProducing`.
Returns:
Deferred: fired when the production is paused.
... | [
"def",
"pauseProducing",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_running",
":",
"return",
"# Exit the read loop and cancel the consumer on the server.",
"self",
".",
"_running",
"=",
"False",
"for",
"consumer",
"in",
"self",
".",
"_consumers",
".",
"val... | Pause the reception of messages by canceling all existing consumers.
This does not disconnect from the server.
Message reception can be resumed with :meth:`resumeProducing`.
Returns:
Deferred: fired when the production is paused. | [
"Pause",
"the",
"reception",
"of",
"messages",
"by",
"canceling",
"all",
"existing",
"consumers",
".",
"This",
"does",
"not",
"disconnect",
"from",
"the",
"server",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/protocol.py#L915-L931 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/protocol.py | FedoraMessagingProtocol.stopProducing | def stopProducing(self):
"""
Stop producing messages and disconnect from the server.
Returns:
Deferred: fired when the production is stopped.
"""
_legacy_twisted_log.msg("Disconnecting from the AMQP broker")
yield self.pauseProducing()
yield self.close... | python | def stopProducing(self):
"""
Stop producing messages and disconnect from the server.
Returns:
Deferred: fired when the production is stopped.
"""
_legacy_twisted_log.msg("Disconnecting from the AMQP broker")
yield self.pauseProducing()
yield self.close... | [
"def",
"stopProducing",
"(",
"self",
")",
":",
"_legacy_twisted_log",
".",
"msg",
"(",
"\"Disconnecting from the AMQP broker\"",
")",
"yield",
"self",
".",
"pauseProducing",
"(",
")",
"yield",
"self",
".",
"close",
"(",
")",
"self",
".",
"_consumers",
"=",
"{"... | Stop producing messages and disconnect from the server.
Returns:
Deferred: fired when the production is stopped. | [
"Stop",
"producing",
"messages",
"and",
"disconnect",
"from",
"the",
"server",
".",
"Returns",
":",
"Deferred",
":",
"fired",
"when",
"the",
"production",
"is",
"stopped",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/protocol.py#L934-L944 |
fedora-infra/fedora-messaging | fedora_messaging/message.py | get_class | def get_class(schema_name):
"""
Retrieve the message class associated with the schema name.
If no match is found, the default schema is returned and a warning is logged.
Args:
schema_name (six.text_type): The name of the :class:`Message` sub-class;
this is typically the Python path... | python | def get_class(schema_name):
"""
Retrieve the message class associated with the schema name.
If no match is found, the default schema is returned and a warning is logged.
Args:
schema_name (six.text_type): The name of the :class:`Message` sub-class;
this is typically the Python path... | [
"def",
"get_class",
"(",
"schema_name",
")",
":",
"global",
"_registry_loaded",
"if",
"not",
"_registry_loaded",
":",
"load_message_classes",
"(",
")",
"try",
":",
"return",
"_schema_name_to_class",
"[",
"schema_name",
"]",
"except",
"KeyError",
":",
"_log",
".",
... | Retrieve the message class associated with the schema name.
If no match is found, the default schema is returned and a warning is logged.
Args:
schema_name (six.text_type): The name of the :class:`Message` sub-class;
this is typically the Python path.
Returns:
Message: A sub-c... | [
"Retrieve",
"the",
"message",
"class",
"associated",
"with",
"the",
"schema",
"name",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/message.py#L74-L100 |
fedora-infra/fedora-messaging | fedora_messaging/message.py | get_name | def get_name(cls):
"""
Retrieve the schema name associated with a message class.
Returns:
str: The schema name.
Raises:
TypeError: If the message class isn't registered. Check your entry point
for correctness.
"""
global _registry_loaded
if not _registry_loaded:... | python | def get_name(cls):
"""
Retrieve the schema name associated with a message class.
Returns:
str: The schema name.
Raises:
TypeError: If the message class isn't registered. Check your entry point
for correctness.
"""
global _registry_loaded
if not _registry_loaded:... | [
"def",
"get_name",
"(",
"cls",
")",
":",
"global",
"_registry_loaded",
"if",
"not",
"_registry_loaded",
":",
"load_message_classes",
"(",
")",
"try",
":",
"return",
"_class_to_schema_name",
"[",
"cls",
"]",
"except",
"KeyError",
":",
"raise",
"TypeError",
"(",
... | Retrieve the schema name associated with a message class.
Returns:
str: The schema name.
Raises:
TypeError: If the message class isn't registered. Check your entry point
for correctness. | [
"Retrieve",
"the",
"schema",
"name",
"associated",
"with",
"a",
"message",
"class",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/message.py#L103-L126 |
fedora-infra/fedora-messaging | fedora_messaging/message.py | load_message_classes | def load_message_classes():
"""Load the 'fedora.messages' entry points and register the message classes."""
for message in pkg_resources.iter_entry_points("fedora.messages"):
cls = message.load()
_log.info(
"Registering the '%s' key as the '%r' class in the Message "
"cla... | python | def load_message_classes():
"""Load the 'fedora.messages' entry points and register the message classes."""
for message in pkg_resources.iter_entry_points("fedora.messages"):
cls = message.load()
_log.info(
"Registering the '%s' key as the '%r' class in the Message "
"cla... | [
"def",
"load_message_classes",
"(",
")",
":",
"for",
"message",
"in",
"pkg_resources",
".",
"iter_entry_points",
"(",
"\"fedora.messages\"",
")",
":",
"cls",
"=",
"message",
".",
"load",
"(",
")",
"_log",
".",
"info",
"(",
"\"Registering the '%s' key as the '%r' c... | Load the 'fedora.messages' entry points and register the message classes. | [
"Load",
"the",
"fedora",
".",
"messages",
"entry",
"points",
"and",
"register",
"the",
"message",
"classes",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/message.py#L129-L142 |
fedora-infra/fedora-messaging | fedora_messaging/message.py | get_message | def get_message(routing_key, properties, body):
"""
Construct a Message instance given the routing key, the properties and the
body received from the AMQP broker.
Args:
routing_key (str): The AMQP routing key (will become the message topic)
properties (pika.BasicProperties): the AMQP pr... | python | def get_message(routing_key, properties, body):
"""
Construct a Message instance given the routing key, the properties and the
body received from the AMQP broker.
Args:
routing_key (str): The AMQP routing key (will become the message topic)
properties (pika.BasicProperties): the AMQP pr... | [
"def",
"get_message",
"(",
"routing_key",
",",
"properties",
",",
"body",
")",
":",
"if",
"properties",
".",
"headers",
"is",
"None",
":",
"_log",
".",
"error",
"(",
"\"Message (body=%r) arrived without headers. \"",
"\"A publisher is misbehaving!\"",
",",
"body",
"... | Construct a Message instance given the routing key, the properties and the
body received from the AMQP broker.
Args:
routing_key (str): The AMQP routing key (will become the message topic)
properties (pika.BasicProperties): the AMQP properties
body (bytes): The encoded message body
... | [
"Construct",
"a",
"Message",
"instance",
"given",
"the",
"routing",
"key",
"the",
"properties",
"and",
"the",
"body",
"received",
"from",
"the",
"AMQP",
"broker",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/message.py#L145-L216 |
fedora-infra/fedora-messaging | fedora_messaging/message.py | dumps | def dumps(messages):
"""
Serialize messages to a JSON formatted str
Args:
messages (list): The list of messages to serialize. Each message in
the messages is subclass of Messge.
Returns:
str: Serialized messages.
Raises:
TypeError: If at least one message is no... | python | def dumps(messages):
"""
Serialize messages to a JSON formatted str
Args:
messages (list): The list of messages to serialize. Each message in
the messages is subclass of Messge.
Returns:
str: Serialized messages.
Raises:
TypeError: If at least one message is no... | [
"def",
"dumps",
"(",
"messages",
")",
":",
"serialized_messages",
"=",
"[",
"]",
"try",
":",
"for",
"message",
"in",
"messages",
":",
"message_dict",
"=",
"message",
".",
"_dump",
"(",
")",
"serialized_messages",
".",
"append",
"(",
"message_dict",
")",
"e... | Serialize messages to a JSON formatted str
Args:
messages (list): The list of messages to serialize. Each message in
the messages is subclass of Messge.
Returns:
str: Serialized messages.
Raises:
TypeError: If at least one message is not instance of Message class or su... | [
"Serialize",
"messages",
"to",
"a",
"JSON",
"formatted",
"str"
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/message.py#L219-L242 |
fedora-infra/fedora-messaging | fedora_messaging/message.py | loads | def loads(serialized_messages):
"""
Deserialize messages from a JSON formatted str
Args:
serialized_messages (JSON str):
Returns:
list: Deserialized message objects.
Raises:
ValidationError: If deserialized message validation failed.
KeyError: If serialized_message... | python | def loads(serialized_messages):
"""
Deserialize messages from a JSON formatted str
Args:
serialized_messages (JSON str):
Returns:
list: Deserialized message objects.
Raises:
ValidationError: If deserialized message validation failed.
KeyError: If serialized_message... | [
"def",
"loads",
"(",
"serialized_messages",
")",
":",
"try",
":",
"messages_dicts",
"=",
"json",
".",
"loads",
"(",
"serialized_messages",
")",
"except",
"ValueError",
":",
"_log",
".",
"error",
"(",
"\"Loading serialized messages failed.\"",
")",
"raise",
"messag... | Deserialize messages from a JSON formatted str
Args:
serialized_messages (JSON str):
Returns:
list: Deserialized message objects.
Raises:
ValidationError: If deserialized message validation failed.
KeyError: If serialized_messages aren't properly serialized.
ValueE... | [
"Deserialize",
"messages",
"from",
"a",
"JSON",
"formatted",
"str"
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/message.py#L245-L324 |
fedora-infra/fedora-messaging | fedora_messaging/message.py | Message._filter_headers | def _filter_headers(self):
"""
Add headers designed for filtering messages based on objects.
Returns:
dict: Filter-related headers to be combined with the existing headers
"""
headers = {}
for user in self.usernames:
headers["fedora_messaging_user... | python | def _filter_headers(self):
"""
Add headers designed for filtering messages based on objects.
Returns:
dict: Filter-related headers to be combined with the existing headers
"""
headers = {}
for user in self.usernames:
headers["fedora_messaging_user... | [
"def",
"_filter_headers",
"(",
"self",
")",
":",
"headers",
"=",
"{",
"}",
"for",
"user",
"in",
"self",
".",
"usernames",
":",
"headers",
"[",
"\"fedora_messaging_user_{}\"",
".",
"format",
"(",
"user",
")",
"]",
"=",
"True",
"for",
"package",
"in",
"sel... | Add headers designed for filtering messages based on objects.
Returns:
dict: Filter-related headers to be combined with the existing headers | [
"Add",
"headers",
"designed",
"for",
"filtering",
"messages",
"based",
"on",
"objects",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/message.py#L417-L435 |
fedora-infra/fedora-messaging | fedora_messaging/message.py | Message._encoded_routing_key | def _encoded_routing_key(self):
"""The encoded routing key used to publish the message on the broker."""
topic = self.topic
if config.conf["topic_prefix"]:
topic = ".".join((config.conf["topic_prefix"].rstrip("."), topic))
return topic.encode("utf-8") | python | def _encoded_routing_key(self):
"""The encoded routing key used to publish the message on the broker."""
topic = self.topic
if config.conf["topic_prefix"]:
topic = ".".join((config.conf["topic_prefix"].rstrip("."), topic))
return topic.encode("utf-8") | [
"def",
"_encoded_routing_key",
"(",
"self",
")",
":",
"topic",
"=",
"self",
".",
"topic",
"if",
"config",
".",
"conf",
"[",
"\"topic_prefix\"",
"]",
":",
"topic",
"=",
"\".\"",
".",
"join",
"(",
"(",
"config",
".",
"conf",
"[",
"\"topic_prefix\"",
"]",
... | The encoded routing key used to publish the message on the broker. | [
"The",
"encoded",
"routing",
"key",
"used",
"to",
"publish",
"the",
"message",
"on",
"the",
"broker",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/message.py#L460-L465 |
fedora-infra/fedora-messaging | fedora_messaging/message.py | Message.validate | def validate(self):
"""
Validate the headers and body with the message schema, if any.
In addition to the user-provided schema, all messages are checked against
the base schema which requires certain message headers and the that body
be a JSON object.
.. warning:: This ... | python | def validate(self):
"""
Validate the headers and body with the message schema, if any.
In addition to the user-provided schema, all messages are checked against
the base schema which requires certain message headers and the that body
be a JSON object.
.. warning:: This ... | [
"def",
"validate",
"(",
"self",
")",
":",
"for",
"schema",
"in",
"(",
"self",
".",
"headers_schema",
",",
"Message",
".",
"headers_schema",
")",
":",
"_log",
".",
"debug",
"(",
"'Validating message headers \"%r\" with schema \"%r\"'",
",",
"self",
".",
"_headers... | Validate the headers and body with the message schema, if any.
In addition to the user-provided schema, all messages are checked against
the base schema which requires certain message headers and the that body
be a JSON object.
.. warning:: This method should not be overridden by sub-c... | [
"Validate",
"the",
"headers",
"and",
"body",
"with",
"the",
"message",
"schema",
"if",
"any",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/message.py#L513-L540 |
fedora-infra/fedora-messaging | fedora_messaging/message.py | Message._dump | def _dump(self):
"""
Dump message attributes.
Returns:
dict: A dictionary of message attributes.
"""
return {
"topic": self.topic,
"headers": self._headers,
"id": self.id,
"body": self.body,
"queue": self.qu... | python | def _dump(self):
"""
Dump message attributes.
Returns:
dict: A dictionary of message attributes.
"""
return {
"topic": self.topic,
"headers": self._headers,
"id": self.id,
"body": self.body,
"queue": self.qu... | [
"def",
"_dump",
"(",
"self",
")",
":",
"return",
"{",
"\"topic\"",
":",
"self",
".",
"topic",
",",
"\"headers\"",
":",
"self",
".",
"_headers",
",",
"\"id\"",
":",
"self",
".",
"id",
",",
"\"body\"",
":",
"self",
".",
"body",
",",
"\"queue\"",
":",
... | Dump message attributes.
Returns:
dict: A dictionary of message attributes. | [
"Dump",
"message",
"attributes",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/message.py#L646-L659 |
fedora-infra/fedora-messaging | fedora_messaging/api.py | _check_callback | def _check_callback(callback):
"""
Turns a callback that is potentially a class into a callable object.
Args:
callback (object): An object that might be a class, method, or function.
if the object is a class, this creates an instance of it.
Raises:
ValueError: If an instance ca... | python | def _check_callback(callback):
"""
Turns a callback that is potentially a class into a callable object.
Args:
callback (object): An object that might be a class, method, or function.
if the object is a class, this creates an instance of it.
Raises:
ValueError: If an instance ca... | [
"def",
"_check_callback",
"(",
"callback",
")",
":",
"# If the callback is a class, create an instance of it first",
"if",
"inspect",
".",
"isclass",
"(",
"callback",
")",
":",
"callback_object",
"=",
"callback",
"(",
")",
"if",
"not",
"callable",
"(",
"callback_objec... | Turns a callback that is potentially a class into a callable object.
Args:
callback (object): An object that might be a class, method, or function.
if the object is a class, this creates an instance of it.
Raises:
ValueError: If an instance can't be created or it isn't a callable objec... | [
"Turns",
"a",
"callback",
"that",
"is",
"potentially",
"a",
"class",
"into",
"a",
"callable",
"object",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/api.py#L34-L63 |
fedora-infra/fedora-messaging | fedora_messaging/api.py | twisted_consume | def twisted_consume(callback, bindings=None, queues=None):
"""
Start a consumer using the provided callback and run it using the Twisted
event loop (reactor).
.. note:: Callbacks run in a Twisted-managed thread pool using the
:func:`twisted.internet.threads.deferToThread` API to avoid them bloc... | python | def twisted_consume(callback, bindings=None, queues=None):
"""
Start a consumer using the provided callback and run it using the Twisted
event loop (reactor).
.. note:: Callbacks run in a Twisted-managed thread pool using the
:func:`twisted.internet.threads.deferToThread` API to avoid them bloc... | [
"def",
"twisted_consume",
"(",
"callback",
",",
"bindings",
"=",
"None",
",",
"queues",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"bindings",
",",
"dict",
")",
":",
"bindings",
"=",
"[",
"bindings",
"]",
"callback",
"=",
"_check_callback",
"(",
"ca... | Start a consumer using the provided callback and run it using the Twisted
event loop (reactor).
.. note:: Callbacks run in a Twisted-managed thread pool using the
:func:`twisted.internet.threads.deferToThread` API to avoid them blocking
the event loop. If you wish to use Twisted APIs in your ca... | [
"Start",
"a",
"consumer",
"using",
"the",
"provided",
"callback",
"and",
"run",
"it",
"using",
"the",
"Twisted",
"event",
"loop",
"(",
"reactor",
")",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/api.py#L66-L121 |
fedora-infra/fedora-messaging | fedora_messaging/api.py | consume | def consume(callback, bindings=None, queues=None):
"""
Start a message consumer that executes the provided callback when messages are
received.
This API is blocking and will not return until the process receives a signal
from the operating system.
.. warning:: This API is runs the callback in ... | python | def consume(callback, bindings=None, queues=None):
"""
Start a message consumer that executes the provided callback when messages are
received.
This API is blocking and will not return until the process receives a signal
from the operating system.
.. warning:: This API is runs the callback in ... | [
"def",
"consume",
"(",
"callback",
",",
"bindings",
"=",
"None",
",",
"queues",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"bindings",
",",
"dict",
")",
":",
"bindings",
"=",
"[",
"bindings",
"]",
"if",
"bindings",
"is",
"None",
":",
"bindings",
... | Start a message consumer that executes the provided callback when messages are
received.
This API is blocking and will not return until the process receives a signal
from the operating system.
.. warning:: This API is runs the callback in the IO loop thread. This means
if your callback could r... | [
"Start",
"a",
"message",
"consumer",
"that",
"executes",
"the",
"provided",
"callback",
"when",
"messages",
"are",
"received",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/api.py#L124-L197 |
fedora-infra/fedora-messaging | fedora_messaging/api.py | publish | def publish(message, exchange=None):
"""
Publish a message to an exchange.
This is a synchronous call, meaning that when this function returns, an
acknowledgment has been received from the message broker and you can be
certain the message was published successfully.
There are some cases where ... | python | def publish(message, exchange=None):
"""
Publish a message to an exchange.
This is a synchronous call, meaning that when this function returns, an
acknowledgment has been received from the message broker and you can be
certain the message was published successfully.
There are some cases where ... | [
"def",
"publish",
"(",
"message",
",",
"exchange",
"=",
"None",
")",
":",
"pre_publish_signal",
".",
"send",
"(",
"publish",
",",
"message",
"=",
"message",
")",
"if",
"exchange",
"is",
"None",
":",
"exchange",
"=",
"config",
".",
"conf",
"[",
"\"publish... | Publish a message to an exchange.
This is a synchronous call, meaning that when this function returns, an
acknowledgment has been received from the message broker and you can be
certain the message was published successfully.
There are some cases where an error occurs despite your message being
su... | [
"Publish",
"a",
"message",
"to",
"an",
"exchange",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/api.py#L200-L250 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/factory.py | FedoraMessagingFactory.buildProtocol | def buildProtocol(self, addr):
"""Create the Protocol instance.
See the documentation of
`twisted.internet.protocol.ReconnectingClientFactory` for details.
"""
self.resetDelay()
self.client = self.protocol(self._parameters)
self.client.factory = self
self... | python | def buildProtocol(self, addr):
"""Create the Protocol instance.
See the documentation of
`twisted.internet.protocol.ReconnectingClientFactory` for details.
"""
self.resetDelay()
self.client = self.protocol(self._parameters)
self.client.factory = self
self... | [
"def",
"buildProtocol",
"(",
"self",
",",
"addr",
")",
":",
"self",
".",
"resetDelay",
"(",
")",
"self",
".",
"client",
"=",
"self",
".",
"protocol",
"(",
"self",
".",
"_parameters",
")",
"self",
".",
"client",
".",
"factory",
"=",
"self",
"self",
".... | Create the Protocol instance.
See the documentation of
`twisted.internet.protocol.ReconnectingClientFactory` for details. | [
"Create",
"the",
"Protocol",
"instance",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/factory.py#L99-L109 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/factory.py | FedoraMessagingFactory._on_client_ready | def _on_client_ready(self):
"""Called when the client is ready to send and receive messages."""
_legacy_twisted_log.msg("Successfully connected to the AMQP broker.")
yield self.client.resumeProducing()
yield self.client.declare_exchanges(self.exchanges)
yield self.client.declare... | python | def _on_client_ready(self):
"""Called when the client is ready to send and receive messages."""
_legacy_twisted_log.msg("Successfully connected to the AMQP broker.")
yield self.client.resumeProducing()
yield self.client.declare_exchanges(self.exchanges)
yield self.client.declare... | [
"def",
"_on_client_ready",
"(",
"self",
")",
":",
"_legacy_twisted_log",
".",
"msg",
"(",
"\"Successfully connected to the AMQP broker.\"",
")",
"yield",
"self",
".",
"client",
".",
"resumeProducing",
"(",
")",
"yield",
"self",
".",
"client",
".",
"declare_exchanges... | Called when the client is ready to send and receive messages. | [
"Called",
"when",
"the",
"client",
"is",
"ready",
"to",
"send",
"and",
"receive",
"messages",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/factory.py#L112-L124 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/factory.py | FedoraMessagingFactory.clientConnectionLost | def clientConnectionLost(self, connector, reason):
"""Called when the connection to the broker has been lost.
See the documentation of
`twisted.internet.protocol.ReconnectingClientFactory` for details.
"""
if not isinstance(reason.value, error.ConnectionDone):
_legac... | python | def clientConnectionLost(self, connector, reason):
"""Called when the connection to the broker has been lost.
See the documentation of
`twisted.internet.protocol.ReconnectingClientFactory` for details.
"""
if not isinstance(reason.value, error.ConnectionDone):
_legac... | [
"def",
"clientConnectionLost",
"(",
"self",
",",
"connector",
",",
"reason",
")",
":",
"if",
"not",
"isinstance",
"(",
"reason",
".",
"value",
",",
"error",
".",
"ConnectionDone",
")",
":",
"_legacy_twisted_log",
".",
"msg",
"(",
"\"Lost connection to the AMQP b... | Called when the connection to the broker has been lost.
See the documentation of
`twisted.internet.protocol.ReconnectingClientFactory` for details. | [
"Called",
"when",
"the",
"connection",
"to",
"the",
"broker",
"has",
"been",
"lost",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/factory.py#L126-L142 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/factory.py | FedoraMessagingFactory.clientConnectionFailed | def clientConnectionFailed(self, connector, reason):
"""Called when the client has failed to connect to the broker.
See the documentation of
`twisted.internet.protocol.ReconnectingClientFactory` for details.
"""
_legacy_twisted_log.msg(
"Connection to the AMQP broker... | python | def clientConnectionFailed(self, connector, reason):
"""Called when the client has failed to connect to the broker.
See the documentation of
`twisted.internet.protocol.ReconnectingClientFactory` for details.
"""
_legacy_twisted_log.msg(
"Connection to the AMQP broker... | [
"def",
"clientConnectionFailed",
"(",
"self",
",",
"connector",
",",
"reason",
")",
":",
"_legacy_twisted_log",
".",
"msg",
"(",
"\"Connection to the AMQP broker failed ({reason})\"",
",",
"reason",
"=",
"reason",
".",
"value",
",",
"logLevel",
"=",
"logging",
".",
... | Called when the client has failed to connect to the broker.
See the documentation of
`twisted.internet.protocol.ReconnectingClientFactory` for details. | [
"Called",
"when",
"the",
"client",
"has",
"failed",
"to",
"connect",
"to",
"the",
"broker",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/factory.py#L144-L157 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/factory.py | FedoraMessagingFactory.stopTrying | def stopTrying(self):
"""Stop trying to reconnect to the broker.
See the documentation of
`twisted.internet.protocol.ReconnectingClientFactory` for details.
"""
protocol.ReconnectingClientFactory.stopTrying(self)
if not self._client_ready.called:
self._client... | python | def stopTrying(self):
"""Stop trying to reconnect to the broker.
See the documentation of
`twisted.internet.protocol.ReconnectingClientFactory` for details.
"""
protocol.ReconnectingClientFactory.stopTrying(self)
if not self._client_ready.called:
self._client... | [
"def",
"stopTrying",
"(",
"self",
")",
":",
"protocol",
".",
"ReconnectingClientFactory",
".",
"stopTrying",
"(",
"self",
")",
"if",
"not",
"self",
".",
"_client_ready",
".",
"called",
":",
"self",
".",
"_client_ready",
".",
"errback",
"(",
"pika",
".",
"e... | Stop trying to reconnect to the broker.
See the documentation of
`twisted.internet.protocol.ReconnectingClientFactory` for details. | [
"Stop",
"trying",
"to",
"reconnect",
"to",
"the",
"broker",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/factory.py#L159-L171 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/factory.py | FedoraMessagingFactory.stopFactory | def stopFactory(self):
"""Stop the factory.
See the documentation of
`twisted.internet.protocol.ReconnectingClientFactory` for details.
"""
if self.client:
yield self.client.stopProducing()
protocol.ReconnectingClientFactory.stopFactory(self) | python | def stopFactory(self):
"""Stop the factory.
See the documentation of
`twisted.internet.protocol.ReconnectingClientFactory` for details.
"""
if self.client:
yield self.client.stopProducing()
protocol.ReconnectingClientFactory.stopFactory(self) | [
"def",
"stopFactory",
"(",
"self",
")",
":",
"if",
"self",
".",
"client",
":",
"yield",
"self",
".",
"client",
".",
"stopProducing",
"(",
")",
"protocol",
".",
"ReconnectingClientFactory",
".",
"stopFactory",
"(",
"self",
")"
] | Stop the factory.
See the documentation of
`twisted.internet.protocol.ReconnectingClientFactory` for details. | [
"Stop",
"the",
"factory",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/factory.py#L174-L182 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/factory.py | FedoraMessagingFactory.consume | def consume(self, callback, queue):
"""
Register a new consumer.
This consumer will be configured for every protocol this factory
produces so it will be reconfigured on network failures. If a connection
is already active, the consumer will be added to it.
Args:
... | python | def consume(self, callback, queue):
"""
Register a new consumer.
This consumer will be configured for every protocol this factory
produces so it will be reconfigured on network failures. If a connection
is already active, the consumer will be added to it.
Args:
... | [
"def",
"consume",
"(",
"self",
",",
"callback",
",",
"queue",
")",
":",
"self",
".",
"consumers",
"[",
"queue",
"]",
"=",
"callback",
"if",
"self",
".",
"_client_ready",
".",
"called",
":",
"return",
"self",
".",
"client",
".",
"consume",
"(",
"callbac... | Register a new consumer.
This consumer will be configured for every protocol this factory
produces so it will be reconfigured on network failures. If a connection
is already active, the consumer will be added to it.
Args:
callback (callable): The callback to invoke when a m... | [
"Register",
"a",
"new",
"consumer",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/factory.py#L184-L198 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/factory.py | FedoraMessagingFactory.cancel | def cancel(self, queue):
"""
Cancel the consumer for a queue.
This removes the consumer from the list of consumers to be configured for
every connection.
Args:
queue (str): The name of the queue the consumer is subscribed to.
Returns:
defer.Defer... | python | def cancel(self, queue):
"""
Cancel the consumer for a queue.
This removes the consumer from the list of consumers to be configured for
every connection.
Args:
queue (str): The name of the queue the consumer is subscribed to.
Returns:
defer.Defer... | [
"def",
"cancel",
"(",
"self",
",",
"queue",
")",
":",
"try",
":",
"del",
"self",
".",
"consumers",
"[",
"queue",
"]",
"except",
"KeyError",
":",
"pass",
"if",
"self",
".",
"client",
":",
"return",
"self",
".",
"client",
".",
"cancel",
"(",
"queue",
... | Cancel the consumer for a queue.
This removes the consumer from the list of consumers to be configured for
every connection.
Args:
queue (str): The name of the queue the consumer is subscribed to.
Returns:
defer.Deferred or None: Either a Deferred that fires whe... | [
"Cancel",
"the",
"consumer",
"for",
"a",
"queue",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/factory.py#L200-L219 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/factory.py | FedoraMessagingFactory.publish | def publish(self, message, exchange=None):
"""
Publish a :class:`fedora_messaging.message.Message` to an `exchange`_
on the message broker. This call will survive connection failures and try
until it succeeds or is canceled.
Args:
message (message.Message): The messa... | python | def publish(self, message, exchange=None):
"""
Publish a :class:`fedora_messaging.message.Message` to an `exchange`_
on the message broker. This call will survive connection failures and try
until it succeeds or is canceled.
Args:
message (message.Message): The messa... | [
"def",
"publish",
"(",
"self",
",",
"message",
",",
"exchange",
"=",
"None",
")",
":",
"exchange",
"=",
"exchange",
"or",
"config",
".",
"conf",
"[",
"\"publish_exchange\"",
"]",
"while",
"True",
":",
"client",
"=",
"yield",
"self",
".",
"whenConnected",
... | Publish a :class:`fedora_messaging.message.Message` to an `exchange`_
on the message broker. This call will survive connection failures and try
until it succeeds or is canceled.
Args:
message (message.Message): The message to publish.
exchange (str): The name of the AMQP... | [
"Publish",
"a",
":",
"class",
":",
"fedora_messaging",
".",
"message",
".",
"Message",
"to",
"an",
"exchange",
"_",
"on",
"the",
"message",
"broker",
".",
"This",
"call",
"will",
"survive",
"connection",
"failures",
"and",
"try",
"until",
"it",
"succeeds",
... | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/factory.py#L234-L263 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/factory.py | FedoraMessagingFactoryV2.buildProtocol | def buildProtocol(self, addr):
"""Create the Protocol instance.
See the documentation of
`twisted.internet.protocol.ReconnectingClientFactory` for details.
"""
self._client = self.protocol(self._parameters, confirms=self.confirms)
self._client.factory = self
@de... | python | def buildProtocol(self, addr):
"""Create the Protocol instance.
See the documentation of
`twisted.internet.protocol.ReconnectingClientFactory` for details.
"""
self._client = self.protocol(self._parameters, confirms=self.confirms)
self._client.factory = self
@de... | [
"def",
"buildProtocol",
"(",
"self",
",",
"addr",
")",
":",
"self",
".",
"_client",
"=",
"self",
".",
"protocol",
"(",
"self",
".",
"_parameters",
",",
"confirms",
"=",
"self",
".",
"confirms",
")",
"self",
".",
"_client",
".",
"factory",
"=",
"self",
... | Create the Protocol instance.
See the documentation of
`twisted.internet.protocol.ReconnectingClientFactory` for details. | [
"Create",
"the",
"Protocol",
"instance",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/factory.py#L296-L346 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/factory.py | FedoraMessagingFactoryV2.stopFactory | def stopFactory(self):
"""Stop the factory.
See the documentation of
`twisted.internet.protocol.ReconnectingClientFactory` for details.
"""
if self._client:
yield self._client.halt()
protocol.ReconnectingClientFactory.stopFactory(self) | python | def stopFactory(self):
"""Stop the factory.
See the documentation of
`twisted.internet.protocol.ReconnectingClientFactory` for details.
"""
if self._client:
yield self._client.halt()
protocol.ReconnectingClientFactory.stopFactory(self) | [
"def",
"stopFactory",
"(",
"self",
")",
":",
"if",
"self",
".",
"_client",
":",
"yield",
"self",
".",
"_client",
".",
"halt",
"(",
")",
"protocol",
".",
"ReconnectingClientFactory",
".",
"stopFactory",
"(",
"self",
")"
] | Stop the factory.
See the documentation of
`twisted.internet.protocol.ReconnectingClientFactory` for details. | [
"Stop",
"the",
"factory",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/factory.py#L349-L357 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/factory.py | FedoraMessagingFactoryV2.when_connected | def when_connected(self):
"""
Retrieve the currently-connected Protocol, or the next one to connect.
Returns:
defer.Deferred: A Deferred that fires with a connected
:class:`FedoraMessagingProtocolV2` instance. This is similar to
the whenConnected meth... | python | def when_connected(self):
"""
Retrieve the currently-connected Protocol, or the next one to connect.
Returns:
defer.Deferred: A Deferred that fires with a connected
:class:`FedoraMessagingProtocolV2` instance. This is similar to
the whenConnected meth... | [
"def",
"when_connected",
"(",
"self",
")",
":",
"if",
"self",
".",
"_client",
"and",
"not",
"self",
".",
"_client",
".",
"is_closed",
":",
"return",
"defer",
".",
"succeed",
"(",
"self",
".",
"_client",
")",
"else",
":",
"return",
"self",
".",
"_client... | Retrieve the currently-connected Protocol, or the next one to connect.
Returns:
defer.Deferred: A Deferred that fires with a connected
:class:`FedoraMessagingProtocolV2` instance. This is similar to
the whenConnected method from the Twisted endpoints APIs, which
... | [
"Retrieve",
"the",
"currently",
"-",
"connected",
"Protocol",
"or",
"the",
"next",
"one",
"to",
"connect",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/factory.py#L359-L373 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/factory.py | FedoraMessagingFactoryV2.consume | def consume(self, callback, bindings, queues):
"""
Start a consumer that lasts across individual connections.
Args:
callback (callable): A callable object that accepts one positional argument,
a :class:`Message` or a class object that implements the ``__call__``
... | python | def consume(self, callback, bindings, queues):
"""
Start a consumer that lasts across individual connections.
Args:
callback (callable): A callable object that accepts one positional argument,
a :class:`Message` or a class object that implements the ``__call__``
... | [
"def",
"consume",
"(",
"self",
",",
"callback",
",",
"bindings",
",",
"queues",
")",
":",
"expanded_bindings",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"for",
"binding",
"in",
"bindings",
":",
"for",
"key",
"in",
"binding",
"[",
"\"routing... | Start a consumer that lasts across individual connections.
Args:
callback (callable): A callable object that accepts one positional argument,
a :class:`Message` or a class object that implements the ``__call__``
method. The class will be instantiated before use.
... | [
"Start",
"a",
"consumer",
"that",
"lasts",
"across",
"individual",
"connections",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/factory.py#L376-L428 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/factory.py | FedoraMessagingFactoryV2.cancel | def cancel(self, consumers):
"""
Cancel a consumer that was previously started with consume.
Args:
consumer (list of fedora_messaging.api.Consumer): The consumers to cancel.
"""
for consumer in consumers:
del self._consumers[consumer.queue]
pr... | python | def cancel(self, consumers):
"""
Cancel a consumer that was previously started with consume.
Args:
consumer (list of fedora_messaging.api.Consumer): The consumers to cancel.
"""
for consumer in consumers:
del self._consumers[consumer.queue]
pr... | [
"def",
"cancel",
"(",
"self",
",",
"consumers",
")",
":",
"for",
"consumer",
"in",
"consumers",
":",
"del",
"self",
".",
"_consumers",
"[",
"consumer",
".",
"queue",
"]",
"protocol",
"=",
"yield",
"self",
".",
"when_connected",
"(",
")",
"yield",
"protoc... | Cancel a consumer that was previously started with consume.
Args:
consumer (list of fedora_messaging.api.Consumer): The consumers to cancel. | [
"Cancel",
"a",
"consumer",
"that",
"was",
"previously",
"started",
"with",
"consume",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/factory.py#L431-L441 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/consumer.py | Consumer.cancel | def cancel(self):
"""
Cancel the consumer and clean up resources associated with it.
Consumers that are canceled are allowed to finish processing any
messages before halting.
Returns:
defer.Deferred: A deferred that fires when the consumer has finished
pr... | python | def cancel(self):
"""
Cancel the consumer and clean up resources associated with it.
Consumers that are canceled are allowed to finish processing any
messages before halting.
Returns:
defer.Deferred: A deferred that fires when the consumer has finished
pr... | [
"def",
"cancel",
"(",
"self",
")",
":",
"# Remove it from protocol and factory so it doesn't restart later.",
"try",
":",
"del",
"self",
".",
"_protocol",
".",
"_consumers",
"[",
"self",
".",
"queue",
"]",
"except",
"(",
"KeyError",
",",
"AttributeError",
")",
":"... | Cancel the consumer and clean up resources associated with it.
Consumers that are canceled are allowed to finish processing any
messages before halting.
Returns:
defer.Deferred: A deferred that fires when the consumer has finished
processing any message it was in the mid... | [
"Cancel",
"the",
"consumer",
"and",
"clean",
"up",
"resources",
"associated",
"with",
"it",
".",
"Consumers",
"that",
"are",
"canceled",
"are",
"allowed",
"to",
"finish",
"processing",
"any",
"messages",
"before",
"halting",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/consumer.py#L70-L106 |
fedora-infra/fedora-messaging | fedora_messaging/config.py | validate_bindings | def validate_bindings(bindings):
"""
Validate the bindings configuration.
Raises:
exceptions.ConfigurationException: If the configuration provided is of an
invalid format.
"""
if not isinstance(bindings, (list, tuple)):
raise exceptions.ConfigurationException(
... | python | def validate_bindings(bindings):
"""
Validate the bindings configuration.
Raises:
exceptions.ConfigurationException: If the configuration provided is of an
invalid format.
"""
if not isinstance(bindings, (list, tuple)):
raise exceptions.ConfigurationException(
... | [
"def",
"validate_bindings",
"(",
"bindings",
")",
":",
"if",
"not",
"isinstance",
"(",
"bindings",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"raise",
"exceptions",
".",
"ConfigurationException",
"(",
"\"bindings must be a list or tuple of dictionaries, but was a ... | Validate the bindings configuration.
Raises:
exceptions.ConfigurationException: If the configuration provided is of an
invalid format. | [
"Validate",
"the",
"bindings",
"configuration",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/config.py#L357-L388 |
fedora-infra/fedora-messaging | fedora_messaging/config.py | validate_queues | def validate_queues(queues):
"""
Validate the queues configuration.
Raises:
exceptions.ConfigurationException: If the configuration provided is of an
invalid format.
"""
if not isinstance(queues, dict):
raise exceptions.ConfigurationException(
"'queues' must ... | python | def validate_queues(queues):
"""
Validate the queues configuration.
Raises:
exceptions.ConfigurationException: If the configuration provided is of an
invalid format.
"""
if not isinstance(queues, dict):
raise exceptions.ConfigurationException(
"'queues' must ... | [
"def",
"validate_queues",
"(",
"queues",
")",
":",
"if",
"not",
"isinstance",
"(",
"queues",
",",
"dict",
")",
":",
"raise",
"exceptions",
".",
"ConfigurationException",
"(",
"\"'queues' must be a dictionary mapping queue names to settings.\"",
")",
"for",
"queue",
",... | Validate the queues configuration.
Raises:
exceptions.ConfigurationException: If the configuration provided is of an
invalid format. | [
"Validate",
"the",
"queues",
"configuration",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/config.py#L391-L418 |
fedora-infra/fedora-messaging | fedora_messaging/config.py | validate_client_properties | def validate_client_properties(props):
"""
Validate the client properties setting.
This will add the "version", "information", and "product" keys if they are
missing. All other keys are application-specific.
Raises:
exceptions.ConfigurationException: If any of the basic keys are overridden... | python | def validate_client_properties(props):
"""
Validate the client properties setting.
This will add the "version", "information", and "product" keys if they are
missing. All other keys are application-specific.
Raises:
exceptions.ConfigurationException: If any of the basic keys are overridden... | [
"def",
"validate_client_properties",
"(",
"props",
")",
":",
"for",
"key",
"in",
"(",
"\"version\"",
",",
"\"information\"",
",",
"\"product\"",
")",
":",
"# Nested dictionaries are not merged so key can be missing",
"if",
"key",
"not",
"in",
"props",
":",
"props",
... | Validate the client properties setting.
This will add the "version", "information", and "product" keys if they are
missing. All other keys are application-specific.
Raises:
exceptions.ConfigurationException: If any of the basic keys are overridden. | [
"Validate",
"the",
"client",
"properties",
"setting",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/config.py#L421-L439 |
fedora-infra/fedora-messaging | fedora_messaging/config.py | LazyConfig._validate | def _validate(self):
"""
Perform checks on the configuration to assert its validity
Raises:
ConfigurationException: If the configuration is invalid.
"""
for key in self:
if key not in DEFAULTS:
raise exceptions.ConfigurationException(
... | python | def _validate(self):
"""
Perform checks on the configuration to assert its validity
Raises:
ConfigurationException: If the configuration is invalid.
"""
for key in self:
if key not in DEFAULTS:
raise exceptions.ConfigurationException(
... | [
"def",
"_validate",
"(",
"self",
")",
":",
"for",
"key",
"in",
"self",
":",
"if",
"key",
"not",
"in",
"DEFAULTS",
":",
"raise",
"exceptions",
".",
"ConfigurationException",
"(",
"'Unknown configuration key \"{}\"! Valid configuration keys are'",
"\" {}\"",
".",
"for... | Perform checks on the configuration to assert its validity
Raises:
ConfigurationException: If the configuration is invalid. | [
"Perform",
"checks",
"on",
"the",
"configuration",
"to",
"assert",
"its",
"validity"
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/config.py#L475-L491 |
fedora-infra/fedora-messaging | fedora_messaging/config.py | LazyConfig.load_config | def load_config(self, config_path=None):
"""
Load application configuration from a file and merge it with the default
configuration.
If the ``FEDORA_MESSAGING_CONF`` environment variable is set to a
filesystem path, the configuration will be loaded from that location.
Ot... | python | def load_config(self, config_path=None):
"""
Load application configuration from a file and merge it with the default
configuration.
If the ``FEDORA_MESSAGING_CONF`` environment variable is set to a
filesystem path, the configuration will be loaded from that location.
Ot... | [
"def",
"load_config",
"(",
"self",
",",
"config_path",
"=",
"None",
")",
":",
"self",
".",
"loaded",
"=",
"True",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULTS",
")",
"if",
"config_path",
"is",
"None",
":",
"if",
"\"FEDORA_MESSAGING_CONF\"",
"in",... | Load application configuration from a file and merge it with the default
configuration.
If the ``FEDORA_MESSAGING_CONF`` environment variable is set to a
filesystem path, the configuration will be loaded from that location.
Otherwise, the path defaults to ``/etc/fedora-messaging/config.... | [
"Load",
"application",
"configuration",
"from",
"a",
"file",
"and",
"merge",
"it",
"with",
"the",
"default",
"configuration",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/config.py#L493-L528 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/service.py | _ssl_context_factory | def _ssl_context_factory(parameters):
"""
Produce a Twisted SSL context object from a pika connection parameter object.
This is necessary as Twisted manages the connection, not Pika.
Args:
parameters (pika.ConnectionParameters): The connection parameters built
from the fedora_messag... | python | def _ssl_context_factory(parameters):
"""
Produce a Twisted SSL context object from a pika connection parameter object.
This is necessary as Twisted manages the connection, not Pika.
Args:
parameters (pika.ConnectionParameters): The connection parameters built
from the fedora_messag... | [
"def",
"_ssl_context_factory",
"(",
"parameters",
")",
":",
"client_cert",
"=",
"None",
"ca_cert",
"=",
"None",
"key",
"=",
"config",
".",
"conf",
"[",
"\"tls\"",
"]",
"[",
"\"keyfile\"",
"]",
"cert",
"=",
"config",
".",
"conf",
"[",
"\"tls\"",
"]",
"[",... | Produce a Twisted SSL context object from a pika connection parameter object.
This is necessary as Twisted manages the connection, not Pika.
Args:
parameters (pika.ConnectionParameters): The connection parameters built
from the fedora_messaging configuration. | [
"Produce",
"a",
"Twisted",
"SSL",
"context",
"object",
"from",
"a",
"pika",
"connection",
"parameter",
"object",
".",
"This",
"is",
"necessary",
"as",
"Twisted",
"manages",
"the",
"connection",
"not",
"Pika",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/service.py#L194-L248 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/service.py | FedoraMessagingServiceV2.stopService | def stopService(self):
"""
Gracefully stop the service.
Returns:
defer.Deferred: a Deferred which is triggered when the service has
finished shutting down.
"""
self._service.factory.stopTrying()
yield self._service.factory.stopFactory()
... | python | def stopService(self):
"""
Gracefully stop the service.
Returns:
defer.Deferred: a Deferred which is triggered when the service has
finished shutting down.
"""
self._service.factory.stopTrying()
yield self._service.factory.stopFactory()
... | [
"def",
"stopService",
"(",
"self",
")",
":",
"self",
".",
"_service",
".",
"factory",
".",
"stopTrying",
"(",
")",
"yield",
"self",
".",
"_service",
".",
"factory",
".",
"stopFactory",
"(",
")",
"yield",
"service",
".",
"MultiService",
".",
"stopService",
... | Gracefully stop the service.
Returns:
defer.Deferred: a Deferred which is triggered when the service has
finished shutting down. | [
"Gracefully",
"stop",
"the",
"service",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/service.py#L181-L191 |
fedora-infra/fedora-messaging | fedora_messaging/_session.py | _configure_tls_parameters | def _configure_tls_parameters(parameters):
"""
Configure the pika connection parameters for TLS based on the configuration.
This modifies the object provided to it. This accounts for whether or not
the new API based on the standard library's SSLContext is available for
pika.
Args:
para... | python | def _configure_tls_parameters(parameters):
"""
Configure the pika connection parameters for TLS based on the configuration.
This modifies the object provided to it. This accounts for whether or not
the new API based on the standard library's SSLContext is available for
pika.
Args:
para... | [
"def",
"_configure_tls_parameters",
"(",
"parameters",
")",
":",
"cert",
"=",
"config",
".",
"conf",
"[",
"\"tls\"",
"]",
"[",
"\"certfile\"",
"]",
"key",
"=",
"config",
".",
"conf",
"[",
"\"tls\"",
"]",
"[",
"\"keyfile\"",
"]",
"if",
"cert",
"and",
"key... | Configure the pika connection parameters for TLS based on the configuration.
This modifies the object provided to it. This accounts for whether or not
the new API based on the standard library's SSLContext is available for
pika.
Args:
parameters (pika.ConnectionParameters): The connection para... | [
"Configure",
"the",
"pika",
"connection",
"parameters",
"for",
"TLS",
"based",
"on",
"the",
"configuration",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/_session.py#L51-L112 |
fedora-infra/fedora-messaging | fedora_messaging/_session.py | PublisherSession.publish | def publish(self, message, exchange=None):
"""
Publish a :class:`fedora_messaging.message.Message` to an `exchange`_ on
the message broker.
>>> from fedora_messaging import _session, message
>>> msg = message.Message(topic='test', body={'test':'message'})
>>> sess = sess... | python | def publish(self, message, exchange=None):
"""
Publish a :class:`fedora_messaging.message.Message` to an `exchange`_ on
the message broker.
>>> from fedora_messaging import _session, message
>>> msg = message.Message(topic='test', body={'test':'message'})
>>> sess = sess... | [
"def",
"publish",
"(",
"self",
",",
"message",
",",
"exchange",
"=",
"None",
")",
":",
"message",
".",
"validate",
"(",
")",
"try",
":",
"self",
".",
"_connect_and_publish",
"(",
"exchange",
",",
"message",
")",
"except",
"(",
"pika_errs",
".",
"NackErro... | Publish a :class:`fedora_messaging.message.Message` to an `exchange`_ on
the message broker.
>>> from fedora_messaging import _session, message
>>> msg = message.Message(topic='test', body={'test':'message'})
>>> sess = session.BlockingSession()
>>> sess.publish(msg)
Ar... | [
"Publish",
"a",
":",
"class",
":",
"fedora_messaging",
".",
"message",
".",
"Message",
"to",
"an",
"exchange",
"_",
"on",
"the",
"message",
"broker",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/_session.py#L129-L174 |
fedora-infra/fedora-messaging | fedora_messaging/_session.py | ConsumerSession._shutdown | def _shutdown(self):
"""Gracefully shut down the consumer and exit."""
if self._channel:
_log.info("Halting %r consumer sessions", self._channel.consumer_tags)
self._running = False
if self._connection and self._connection.is_open:
self._connection.close()
... | python | def _shutdown(self):
"""Gracefully shut down the consumer and exit."""
if self._channel:
_log.info("Halting %r consumer sessions", self._channel.consumer_tags)
self._running = False
if self._connection and self._connection.is_open:
self._connection.close()
... | [
"def",
"_shutdown",
"(",
"self",
")",
":",
"if",
"self",
".",
"_channel",
":",
"_log",
".",
"info",
"(",
"\"Halting %r consumer sessions\"",
",",
"self",
".",
"_channel",
".",
"consumer_tags",
")",
"self",
".",
"_running",
"=",
"False",
"if",
"self",
".",
... | Gracefully shut down the consumer and exit. | [
"Gracefully",
"shut",
"down",
"the",
"consumer",
"and",
"exit",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/_session.py#L224-L233 |
fedora-infra/fedora-messaging | fedora_messaging/_session.py | ConsumerSession._on_cancelok | def _on_cancelok(self, cancel_frame):
"""
Called when the server acknowledges a cancel request.
Args:
cancel_frame (pika.spec.Basic.CancelOk): The cancelok frame from
the server.
"""
_log.info("Consumer canceled; returning all unprocessed messages to ... | python | def _on_cancelok(self, cancel_frame):
"""
Called when the server acknowledges a cancel request.
Args:
cancel_frame (pika.spec.Basic.CancelOk): The cancelok frame from
the server.
"""
_log.info("Consumer canceled; returning all unprocessed messages to ... | [
"def",
"_on_cancelok",
"(",
"self",
",",
"cancel_frame",
")",
":",
"_log",
".",
"info",
"(",
"\"Consumer canceled; returning all unprocessed messages to the queue\"",
")",
"self",
".",
"_channel",
".",
"basic_nack",
"(",
"delivery_tag",
"=",
"0",
",",
"multiple",
"=... | Called when the server acknowledges a cancel request.
Args:
cancel_frame (pika.spec.Basic.CancelOk): The cancelok frame from
the server. | [
"Called",
"when",
"the",
"server",
"acknowledges",
"a",
"cancel",
"request",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/_session.py#L235-L244 |
fedora-infra/fedora-messaging | fedora_messaging/_session.py | ConsumerSession._on_channel_open | def _on_channel_open(self, channel):
"""
Callback used when a channel is opened.
This registers all the channel callbacks.
Args:
channel (pika.channel.Channel): The channel that successfully opened.
"""
channel.add_on_close_callback(self._on_channel_close)
... | python | def _on_channel_open(self, channel):
"""
Callback used when a channel is opened.
This registers all the channel callbacks.
Args:
channel (pika.channel.Channel): The channel that successfully opened.
"""
channel.add_on_close_callback(self._on_channel_close)
... | [
"def",
"_on_channel_open",
"(",
"self",
",",
"channel",
")",
":",
"channel",
".",
"add_on_close_callback",
"(",
"self",
".",
"_on_channel_close",
")",
"channel",
".",
"add_on_cancel_callback",
"(",
"self",
".",
"_on_cancel",
")",
"channel",
".",
"basic_qos",
"("... | Callback used when a channel is opened.
This registers all the channel callbacks.
Args:
channel (pika.channel.Channel): The channel that successfully opened. | [
"Callback",
"used",
"when",
"a",
"channel",
"is",
"opened",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/_session.py#L246-L258 |
fedora-infra/fedora-messaging | fedora_messaging/_session.py | ConsumerSession._on_qosok | def _on_qosok(self, qosok_frame):
"""
Callback invoked when the server acknowledges the QoS settings.
Asserts or creates the exchanges and queues exist.
Args:
qosok_frame (pika.spec.Basic.Qos): The frame send from the server.
"""
for name, args in self._exch... | python | def _on_qosok(self, qosok_frame):
"""
Callback invoked when the server acknowledges the QoS settings.
Asserts or creates the exchanges and queues exist.
Args:
qosok_frame (pika.spec.Basic.Qos): The frame send from the server.
"""
for name, args in self._exch... | [
"def",
"_on_qosok",
"(",
"self",
",",
"qosok_frame",
")",
":",
"for",
"name",
",",
"args",
"in",
"self",
".",
"_exchanges",
".",
"items",
"(",
")",
":",
"self",
".",
"_channel",
".",
"exchange_declare",
"(",
"exchange",
"=",
"name",
",",
"exchange_type",... | Callback invoked when the server acknowledges the QoS settings.
Asserts or creates the exchanges and queues exist.
Args:
qosok_frame (pika.spec.Basic.Qos): The frame send from the server. | [
"Callback",
"invoked",
"when",
"the",
"server",
"acknowledges",
"the",
"QoS",
"settings",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/_session.py#L260-L288 |
fedora-infra/fedora-messaging | fedora_messaging/_session.py | ConsumerSession._on_channel_close | def _on_channel_close(self, channel, reply_code_or_reason, reply_text=None):
"""
Callback invoked when the channel is closed.
Args:
channel (pika.channel.Channel): The channel that got closed.
reply_code_or_reason (int|Exception): The reason why the channel
... | python | def _on_channel_close(self, channel, reply_code_or_reason, reply_text=None):
"""
Callback invoked when the channel is closed.
Args:
channel (pika.channel.Channel): The channel that got closed.
reply_code_or_reason (int|Exception): The reason why the channel
... | [
"def",
"_on_channel_close",
"(",
"self",
",",
"channel",
",",
"reply_code_or_reason",
",",
"reply_text",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"reply_code_or_reason",
",",
"pika_errs",
".",
"ChannelClosed",
")",
":",
"reply_code",
"=",
"reply_code_or_rea... | Callback invoked when the channel is closed.
Args:
channel (pika.channel.Channel): The channel that got closed.
reply_code_or_reason (int|Exception): The reason why the channel
was closed. In older versions of pika, this is the AMQP code.
reply_text (str): Th... | [
"Callback",
"invoked",
"when",
"the",
"channel",
"is",
"closed",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/_session.py#L290-L311 |
fedora-infra/fedora-messaging | fedora_messaging/_session.py | ConsumerSession._on_connection_open | def _on_connection_open(self, connection):
"""
Callback invoked when the connection is successfully established.
Args:
connection (pika.connection.SelectConnection): The newly-estabilished
connection.
"""
_log.info("Successfully opened connection to %... | python | def _on_connection_open(self, connection):
"""
Callback invoked when the connection is successfully established.
Args:
connection (pika.connection.SelectConnection): The newly-estabilished
connection.
"""
_log.info("Successfully opened connection to %... | [
"def",
"_on_connection_open",
"(",
"self",
",",
"connection",
")",
":",
"_log",
".",
"info",
"(",
"\"Successfully opened connection to %s\"",
",",
"connection",
".",
"params",
".",
"host",
")",
"self",
".",
"_channel",
"=",
"connection",
".",
"channel",
"(",
"... | Callback invoked when the connection is successfully established.
Args:
connection (pika.connection.SelectConnection): The newly-estabilished
connection. | [
"Callback",
"invoked",
"when",
"the",
"connection",
"is",
"successfully",
"established",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/_session.py#L313-L322 |
fedora-infra/fedora-messaging | fedora_messaging/_session.py | ConsumerSession._on_connection_close | def _on_connection_close(self, connection, reply_code_or_reason, reply_text=None):
"""
Callback invoked when a previously-opened connection is closed.
Args:
connection (pika.connection.SelectConnection): The connection that
was just closed.
reply_code_or_... | python | def _on_connection_close(self, connection, reply_code_or_reason, reply_text=None):
"""
Callback invoked when a previously-opened connection is closed.
Args:
connection (pika.connection.SelectConnection): The connection that
was just closed.
reply_code_or_... | [
"def",
"_on_connection_close",
"(",
"self",
",",
"connection",
",",
"reply_code_or_reason",
",",
"reply_text",
"=",
"None",
")",
":",
"self",
".",
"_channel",
"=",
"None",
"if",
"isinstance",
"(",
"reply_code_or_reason",
",",
"pika_errs",
".",
"ConnectionClosed",
... | Callback invoked when a previously-opened connection is closed.
Args:
connection (pika.connection.SelectConnection): The connection that
was just closed.
reply_code_or_reason (int|Exception): The reason why the channel
was closed. In older versions of pik... | [
"Callback",
"invoked",
"when",
"a",
"previously",
"-",
"opened",
"connection",
"is",
"closed",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/_session.py#L324-L358 |
fedora-infra/fedora-messaging | fedora_messaging/_session.py | ConsumerSession._on_connection_error | def _on_connection_error(self, connection, error_message):
"""
Callback invoked when the connection failed to be established.
Args:
connection (pika.connection.SelectConnection): The connection that
failed to open.
error_message (str): The reason the conn... | python | def _on_connection_error(self, connection, error_message):
"""
Callback invoked when the connection failed to be established.
Args:
connection (pika.connection.SelectConnection): The connection that
failed to open.
error_message (str): The reason the conn... | [
"def",
"_on_connection_error",
"(",
"self",
",",
"connection",
",",
"error_message",
")",
":",
"self",
".",
"_channel",
"=",
"None",
"if",
"isinstance",
"(",
"error_message",
",",
"pika_errs",
".",
"AMQPConnectionError",
")",
":",
"error_message",
"=",
"repr",
... | Callback invoked when the connection failed to be established.
Args:
connection (pika.connection.SelectConnection): The connection that
failed to open.
error_message (str): The reason the connection couldn't be opened. | [
"Callback",
"invoked",
"when",
"the",
"connection",
"failed",
"to",
"be",
"established",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/_session.py#L360-L373 |
fedora-infra/fedora-messaging | fedora_messaging/_session.py | ConsumerSession._on_queue_declareok | def _on_queue_declareok(self, frame):
"""
Callback invoked when a queue is successfully declared.
Args:
frame (pika.frame.Method): The message sent from the server.
"""
_log.info("Successfully declared the %s queue", frame.method.queue)
for binding in self._b... | python | def _on_queue_declareok(self, frame):
"""
Callback invoked when a queue is successfully declared.
Args:
frame (pika.frame.Method): The message sent from the server.
"""
_log.info("Successfully declared the %s queue", frame.method.queue)
for binding in self._b... | [
"def",
"_on_queue_declareok",
"(",
"self",
",",
"frame",
")",
":",
"_log",
".",
"info",
"(",
"\"Successfully declared the %s queue\"",
",",
"frame",
".",
"method",
".",
"queue",
")",
"for",
"binding",
"in",
"self",
".",
"_bindings",
":",
"if",
"binding",
"["... | Callback invoked when a queue is successfully declared.
Args:
frame (pika.frame.Method): The message sent from the server. | [
"Callback",
"invoked",
"when",
"a",
"queue",
"is",
"successfully",
"declared",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/_session.py#L388-L417 |
fedora-infra/fedora-messaging | fedora_messaging/_session.py | ConsumerSession.call_later | def call_later(self, delay, callback):
"""Schedule a one-shot timeout given delay seconds.
This method is only useful for compatibility with older versions of pika.
Args:
delay (float): Non-negative number of seconds from now until
expiration
callback (m... | python | def call_later(self, delay, callback):
"""Schedule a one-shot timeout given delay seconds.
This method is only useful for compatibility with older versions of pika.
Args:
delay (float): Non-negative number of seconds from now until
expiration
callback (m... | [
"def",
"call_later",
"(",
"self",
",",
"delay",
",",
"callback",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"_connection",
".",
"ioloop",
",",
"\"call_later\"",
")",
":",
"self",
".",
"_connection",
".",
"ioloop",
".",
"call_later",
"(",
"delay",
",",
... | Schedule a one-shot timeout given delay seconds.
This method is only useful for compatibility with older versions of pika.
Args:
delay (float): Non-negative number of seconds from now until
expiration
callback (method): The callback method, having the signature
... | [
"Schedule",
"a",
"one",
"-",
"shot",
"timeout",
"given",
"delay",
"seconds",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/_session.py#L429-L443 |
fedora-infra/fedora-messaging | fedora_messaging/_session.py | ConsumerSession.reconnect | def reconnect(self):
"""Will be invoked by the IOLoop timer if the connection is
closed. See the _on_connection_close method.
"""
# This is the old connection instance, stop its ioloop.
self._connection.ioloop.stop()
if self._running:
# Create a new connection... | python | def reconnect(self):
"""Will be invoked by the IOLoop timer if the connection is
closed. See the _on_connection_close method.
"""
# This is the old connection instance, stop its ioloop.
self._connection.ioloop.stop()
if self._running:
# Create a new connection... | [
"def",
"reconnect",
"(",
"self",
")",
":",
"# This is the old connection instance, stop its ioloop.",
"self",
".",
"_connection",
".",
"ioloop",
".",
"stop",
"(",
")",
"if",
"self",
".",
"_running",
":",
"# Create a new connection",
"self",
".",
"connect",
"(",
")... | Will be invoked by the IOLoop timer if the connection is
closed. See the _on_connection_close method. | [
"Will",
"be",
"invoked",
"by",
"the",
"IOLoop",
"timer",
"if",
"the",
"connection",
"is",
"closed",
".",
"See",
"the",
"_on_connection_close",
"method",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/_session.py#L454-L464 |
fedora-infra/fedora-messaging | fedora_messaging/_session.py | ConsumerSession.consume | def consume(self, callback, bindings=None, queues=None, exchanges=None):
"""
Consume messages from a message queue.
Simply define a callable to be used as the callback when messages are
delivered and specify the queue bindings. This call blocks. The callback
signature should acc... | python | def consume(self, callback, bindings=None, queues=None, exchanges=None):
"""
Consume messages from a message queue.
Simply define a callable to be used as the callback when messages are
delivered and specify the queue bindings. This call blocks. The callback
signature should acc... | [
"def",
"consume",
"(",
"self",
",",
"callback",
",",
"bindings",
"=",
"None",
",",
"queues",
"=",
"None",
",",
"exchanges",
"=",
"None",
")",
":",
"self",
".",
"_bindings",
"=",
"bindings",
"or",
"config",
".",
"conf",
"[",
"\"bindings\"",
"]",
"self",... | Consume messages from a message queue.
Simply define a callable to be used as the callback when messages are
delivered and specify the queue bindings. This call blocks. The callback
signature should accept a single positional argument which is an
instance of a :class:`Message` (or a sub... | [
"Consume",
"messages",
"from",
"a",
"message",
"queue",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/_session.py#L466-L513 |
fedora-infra/fedora-messaging | fedora_messaging/_session.py | ConsumerSession._on_message | def _on_message(self, channel, delivery_frame, properties, body):
"""
Callback when a message is received from the server.
This method wraps a user-registered callback for message delivery. It
decodes the message body, determines the message schema to validate the
message with, ... | python | def _on_message(self, channel, delivery_frame, properties, body):
"""
Callback when a message is received from the server.
This method wraps a user-registered callback for message delivery. It
decodes the message body, determines the message schema to validate the
message with, ... | [
"def",
"_on_message",
"(",
"self",
",",
"channel",
",",
"delivery_frame",
",",
"properties",
",",
"body",
")",
":",
"_log",
".",
"debug",
"(",
"\"Message arrived with delivery tag %s\"",
",",
"delivery_frame",
".",
"delivery_tag",
")",
"try",
":",
"message",
"="... | Callback when a message is received from the server.
This method wraps a user-registered callback for message delivery. It
decodes the message body, determines the message schema to validate the
message with, and validates the message before passing it on to the user
callback.
... | [
"Callback",
"when",
"a",
"message",
"is",
"received",
"from",
"the",
"server",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/_session.py#L515-L580 |
fedora-infra/fedora-messaging | docs/sample_schema_package/mailman_schema/utils.py | get_avatar | def get_avatar(from_header, size=64, default="retro"):
"""Get the avatar URL from the email's From header.
Args:
from_header (str): The email's From header. May contain the sender's full name.
Returns:
str: The URL to that sender's avatar.
"""
params = OrderedDict([("s", size), ("d... | python | def get_avatar(from_header, size=64, default="retro"):
"""Get the avatar URL from the email's From header.
Args:
from_header (str): The email's From header. May contain the sender's full name.
Returns:
str: The URL to that sender's avatar.
"""
params = OrderedDict([("s", size), ("d... | [
"def",
"get_avatar",
"(",
"from_header",
",",
"size",
"=",
"64",
",",
"default",
"=",
"\"retro\"",
")",
":",
"params",
"=",
"OrderedDict",
"(",
"[",
"(",
"\"s\"",
",",
"size",
")",
",",
"(",
"\"d\"",
",",
"default",
")",
"]",
")",
"query",
"=",
"pa... | Get the avatar URL from the email's From header.
Args:
from_header (str): The email's From header. May contain the sender's full name.
Returns:
str: The URL to that sender's avatar. | [
"Get",
"the",
"avatar",
"URL",
"from",
"the",
"email",
"s",
"From",
"header",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/docs/sample_schema_package/mailman_schema/utils.py#L25-L38 |
fedora-infra/fedora-messaging | docs/sample_schema_package/mailman_schema/schema.py | BaseMessage.url | def url(self):
"""An URL to the email in HyperKitty
Returns:
str or None: A relevant URL.
"""
base_url = "https://lists.fedoraproject.org/archives"
archived_at = self._get_archived_at()
if archived_at and archived_at.startswith("<"):
archived_at =... | python | def url(self):
"""An URL to the email in HyperKitty
Returns:
str or None: A relevant URL.
"""
base_url = "https://lists.fedoraproject.org/archives"
archived_at = self._get_archived_at()
if archived_at and archived_at.startswith("<"):
archived_at =... | [
"def",
"url",
"(",
"self",
")",
":",
"base_url",
"=",
"\"https://lists.fedoraproject.org/archives\"",
"archived_at",
"=",
"self",
".",
"_get_archived_at",
"(",
")",
"if",
"archived_at",
"and",
"archived_at",
".",
"startswith",
"(",
"\"<\"",
")",
":",
"archived_at"... | An URL to the email in HyperKitty
Returns:
str or None: A relevant URL. | [
"An",
"URL",
"to",
"the",
"email",
"in",
"HyperKitty"
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/docs/sample_schema_package/mailman_schema/schema.py#L52-L69 |
fedora-infra/fedora-messaging | setup.py | get_requirements | def get_requirements(requirements_file="requirements.txt"):
"""Get the contents of a file listing the requirements.
Args:
requirements_file (str): The path to the requirements file, relative
to this file.
Returns:
list: the list of requirements, or an empty... | python | def get_requirements(requirements_file="requirements.txt"):
"""Get the contents of a file listing the requirements.
Args:
requirements_file (str): The path to the requirements file, relative
to this file.
Returns:
list: the list of requirements, or an empty... | [
"def",
"get_requirements",
"(",
"requirements_file",
"=",
"\"requirements.txt\"",
")",
":",
"with",
"open",
"(",
"requirements_file",
")",
"as",
"fd",
":",
"lines",
"=",
"fd",
".",
"readlines",
"(",
")",
"dependencies",
"=",
"[",
"]",
"for",
"line",
"in",
... | Get the contents of a file listing the requirements.
Args:
requirements_file (str): The path to the requirements file, relative
to this file.
Returns:
list: the list of requirements, or an empty list if
``requirements_file`` could not be opened or... | [
"Get",
"the",
"contents",
"of",
"a",
"file",
"listing",
"the",
"requirements",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/setup.py#L18-L48 |
fedora-infra/fedora-messaging | fedora_messaging/schema_utils.py | user_avatar_url | def user_avatar_url(username, size=64, default="retro"):
"""Get the avatar URL of the provided Fedora username.
The URL is returned from the Libravatar service.
Args:
username (str): The username to get the avatar of.
size (int): Size of the avatar in pixels (it's a square).
defaul... | python | def user_avatar_url(username, size=64, default="retro"):
"""Get the avatar URL of the provided Fedora username.
The URL is returned from the Libravatar service.
Args:
username (str): The username to get the avatar of.
size (int): Size of the avatar in pixels (it's a square).
defaul... | [
"def",
"user_avatar_url",
"(",
"username",
",",
"size",
"=",
"64",
",",
"default",
"=",
"\"retro\"",
")",
":",
"openid",
"=",
"\"http://{}.id.fedoraproject.org/\"",
".",
"format",
"(",
"username",
")",
"return",
"libravatar_url",
"(",
"openid",
"=",
"openid",
... | Get the avatar URL of the provided Fedora username.
The URL is returned from the Libravatar service.
Args:
username (str): The username to get the avatar of.
size (int): Size of the avatar in pixels (it's a square).
default (str): Default avatar to return if not found.
Returns:
... | [
"Get",
"the",
"avatar",
"URL",
"of",
"the",
"provided",
"Fedora",
"username",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/schema_utils.py#L27-L40 |
fedora-infra/fedora-messaging | fedora_messaging/schema_utils.py | libravatar_url | def libravatar_url(email=None, openid=None, size=64, default="retro"):
"""Get the URL to an avatar from libravatar.
Either the user's email or openid must be provided.
If you want to use Libravatar federation (through DNS), you should install
and use the ``libravatar`` library instead. Check out the
... | python | def libravatar_url(email=None, openid=None, size=64, default="retro"):
"""Get the URL to an avatar from libravatar.
Either the user's email or openid must be provided.
If you want to use Libravatar federation (through DNS), you should install
and use the ``libravatar`` library instead. Check out the
... | [
"def",
"libravatar_url",
"(",
"email",
"=",
"None",
",",
"openid",
"=",
"None",
",",
"size",
"=",
"64",
",",
"default",
"=",
"\"retro\"",
")",
":",
"# We use an OrderedDict here to make testing easier (URL strings become",
"# predictable).",
"params",
"=",
"collection... | Get the URL to an avatar from libravatar.
Either the user's email or openid must be provided.
If you want to use Libravatar federation (through DNS), you should install
and use the ``libravatar`` library instead. Check out the
``libravatar.libravatar_url()`` function.
Args:
email (str): T... | [
"Get",
"the",
"URL",
"to",
"an",
"avatar",
"from",
"libravatar",
"."
] | train | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/schema_utils.py#L43-L73 |
sanoma/django-arctic | arctic/templatetags/arctic_tags.py | get_parameters | def get_parameters(parser, token):
"""
{% get_parameters except_field %}
"""
args = token.split_contents()
if len(args) < 2:
raise template.TemplateSyntaxError(
"get_parameters tag takes at least 1 argument"
)
return GetParametersNode(args[1].strip()) | python | def get_parameters(parser, token):
"""
{% get_parameters except_field %}
"""
args = token.split_contents()
if len(args) < 2:
raise template.TemplateSyntaxError(
"get_parameters tag takes at least 1 argument"
)
return GetParametersNode(args[1].strip()) | [
"def",
"get_parameters",
"(",
"parser",
",",
"token",
")",
":",
"args",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"args",
")",
"<",
"2",
":",
"raise",
"template",
".",
"TemplateSyntaxError",
"(",
"\"get_parameters tag takes at least 1 ar... | {% get_parameters except_field %} | [
"{",
"%",
"get_parameters",
"except_field",
"%",
"}"
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/templatetags/arctic_tags.py#L36-L45 |
sanoma/django-arctic | arctic/templatetags/arctic_tags.py | get_all_fields | def get_all_fields(obj):
"""Returns a list of all field names on the instance."""
fields = []
for f in obj._meta.fields:
fname = f.name
get_choice = "get_" + fname + "_display"
if hasattr(obj, get_choice):
value = getattr(obj, get_choice)()
else:
try:... | python | def get_all_fields(obj):
"""Returns a list of all field names on the instance."""
fields = []
for f in obj._meta.fields:
fname = f.name
get_choice = "get_" + fname + "_display"
if hasattr(obj, get_choice):
value = getattr(obj, get_choice)()
else:
try:... | [
"def",
"get_all_fields",
"(",
"obj",
")",
":",
"fields",
"=",
"[",
"]",
"for",
"f",
"in",
"obj",
".",
"_meta",
".",
"fields",
":",
"fname",
"=",
"f",
".",
"name",
"get_choice",
"=",
"\"get_\"",
"+",
"fname",
"+",
"\"_display\"",
"if",
"hasattr",
"(",... | Returns a list of all field names on the instance. | [
"Returns",
"a",
"list",
"of",
"all",
"field",
"names",
"on",
"the",
"instance",
"."
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/templatetags/arctic_tags.py#L81-L104 |
sanoma/django-arctic | arctic/templatetags/arctic_tags.py | query_string | def query_string(context, **kwargs):
"""Add param to the given query string"""
params = context["request"].GET.copy()
for key, value in list(kwargs.items()):
params[key] = value
return "?" + params.urlencode() | python | def query_string(context, **kwargs):
"""Add param to the given query string"""
params = context["request"].GET.copy()
for key, value in list(kwargs.items()):
params[key] = value
return "?" + params.urlencode() | [
"def",
"query_string",
"(",
"context",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"context",
"[",
"\"request\"",
"]",
".",
"GET",
".",
"copy",
"(",
")",
"for",
"key",
",",
"value",
"in",
"list",
"(",
"kwargs",
".",
"items",
"(",
")",
")",
... | Add param to the given query string | [
"Add",
"param",
"to",
"the",
"given",
"query",
"string"
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/templatetags/arctic_tags.py#L108-L115 |
sanoma/django-arctic | arctic/templatetags/arctic_tags.py | query_string_ordering | def query_string_ordering(context, value, **kwargs):
"""
Add ordering param to the given query string
:param context: template context
:param value: examples would be '-id' or 'id'. A minus indicates that the
default sorting is descending
:param kwargs: not used
:return: Adjust... | python | def query_string_ordering(context, value, **kwargs):
"""
Add ordering param to the given query string
:param context: template context
:param value: examples would be '-id' or 'id'. A minus indicates that the
default sorting is descending
:param kwargs: not used
:return: Adjust... | [
"def",
"query_string_ordering",
"(",
"context",
",",
"value",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"context",
"[",
"\"request\"",
"]",
".",
"GET",
".",
"copy",
"(",
")",
"# if the given value is '-id', it's core value would be 'id'",
"core_value",
"="... | Add ordering param to the given query string
:param context: template context
:param value: examples would be '-id' or 'id'. A minus indicates that the
default sorting is descending
:param kwargs: not used
:return: Adjusted query string, starting with '?' | [
"Add",
"ordering",
"param",
"to",
"the",
"given",
"query",
"string",
":",
"param",
"context",
":",
"template",
"context",
":",
"param",
"value",
":",
"examples",
"would",
"be",
"-",
"id",
"or",
"id",
".",
"A",
"minus",
"indicates",
"that",
"the",
"defaul... | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/templatetags/arctic_tags.py#L119-L162 |
sanoma/django-arctic | arctic/templatetags/arctic_tags.py | arctic_url | def arctic_url(context, link, *args, **kwargs):
"""
Resolves links into urls with optional
arguments set in self.urls. please check get_urls method in View.
We could tie this to check_url_access() to check for permissions,
including object-level.
"""
def reverse_mutable_url_args(url_args):... | python | def arctic_url(context, link, *args, **kwargs):
"""
Resolves links into urls with optional
arguments set in self.urls. please check get_urls method in View.
We could tie this to check_url_access() to check for permissions,
including object-level.
"""
def reverse_mutable_url_args(url_args):... | [
"def",
"arctic_url",
"(",
"context",
",",
"link",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"reverse_mutable_url_args",
"(",
"url_args",
")",
":",
"mutated_url_args",
"=",
"[",
"]",
"for",
"arg",
"in",
"url_args",
":",
"# listview item, a... | Resolves links into urls with optional
arguments set in self.urls. please check get_urls method in View.
We could tie this to check_url_access() to check for permissions,
including object-level. | [
"Resolves",
"links",
"into",
"urls",
"with",
"optional",
"arguments",
"set",
"in",
"self",
".",
"urls",
".",
"please",
"check",
"get_urls",
"method",
"in",
"View",
"."
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/templatetags/arctic_tags.py#L166-L206 |
sanoma/django-arctic | arctic/loading.py | get_role_model | def get_role_model():
"""
Returns the Role model that is active in this project.
"""
app_model = getattr(settings, "ARCTIC_ROLE_MODEL", "arctic.Role")
try:
return django_apps.get_model(app_model)
except ValueError:
raise ImproperlyConfigured(
"ARCTIC_ROLE_MODEL must ... | python | def get_role_model():
"""
Returns the Role model that is active in this project.
"""
app_model = getattr(settings, "ARCTIC_ROLE_MODEL", "arctic.Role")
try:
return django_apps.get_model(app_model)
except ValueError:
raise ImproperlyConfigured(
"ARCTIC_ROLE_MODEL must ... | [
"def",
"get_role_model",
"(",
")",
":",
"app_model",
"=",
"getattr",
"(",
"settings",
",",
"\"ARCTIC_ROLE_MODEL\"",
",",
"\"arctic.Role\"",
")",
"try",
":",
"return",
"django_apps",
".",
"get_model",
"(",
"app_model",
")",
"except",
"ValueError",
":",
"raise",
... | Returns the Role model that is active in this project. | [
"Returns",
"the",
"Role",
"model",
"that",
"is",
"active",
"in",
"this",
"project",
"."
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/loading.py#L6-L22 |
sanoma/django-arctic | arctic/loading.py | get_user_role_model | def get_user_role_model():
"""
Returns the UserRole model that is active in this project.
"""
app_model = getattr(settings, "ARCTIC_USER_ROLE_MODEL", "arctic.UserRole")
try:
return django_apps.get_model(app_model)
except ValueError:
raise ImproperlyConfigured(
"ARCTI... | python | def get_user_role_model():
"""
Returns the UserRole model that is active in this project.
"""
app_model = getattr(settings, "ARCTIC_USER_ROLE_MODEL", "arctic.UserRole")
try:
return django_apps.get_model(app_model)
except ValueError:
raise ImproperlyConfigured(
"ARCTI... | [
"def",
"get_user_role_model",
"(",
")",
":",
"app_model",
"=",
"getattr",
"(",
"settings",
",",
"\"ARCTIC_USER_ROLE_MODEL\"",
",",
"\"arctic.UserRole\"",
")",
"try",
":",
"return",
"django_apps",
".",
"get_model",
"(",
"app_model",
")",
"except",
"ValueError",
":"... | Returns the UserRole model that is active in this project. | [
"Returns",
"the",
"UserRole",
"model",
"that",
"is",
"active",
"in",
"this",
"project",
"."
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/loading.py#L25-L42 |
sanoma/django-arctic | arctic/generics.py | View.dispatch | def dispatch(self, request, *args, **kwargs):
"""
Most views in a CMS require a login, so this is the default setup.
If a login is not required then the requires_login property
can be set to False to disable this.
"""
if self.requires_login:
if settings.LOGIN... | python | def dispatch(self, request, *args, **kwargs):
"""
Most views in a CMS require a login, so this is the default setup.
If a login is not required then the requires_login property
can be set to False to disable this.
"""
if self.requires_login:
if settings.LOGIN... | [
"def",
"dispatch",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"requires_login",
":",
"if",
"settings",
".",
"LOGIN_URL",
"is",
"None",
"or",
"settings",
".",
"LOGOUT_URL",
"is",
"None",
":",
"... | Most views in a CMS require a login, so this is the default setup.
If a login is not required then the requires_login property
can be set to False to disable this. | [
"Most",
"views",
"in",
"a",
"CMS",
"require",
"a",
"login",
"so",
"this",
"is",
"the",
"default",
"setup",
"."
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/generics.py#L76-L99 |
sanoma/django-arctic | arctic/generics.py | View.get_breadcrumbs | def get_breadcrumbs(self):
"""
Breadcrumb format: (('name', 'url'), ...) or None if not used.
"""
if not self.breadcrumbs:
return None
else:
allowed_breadcrumbs = []
for breadcrumb in self.breadcrumbs:
# check permission based ... | python | def get_breadcrumbs(self):
"""
Breadcrumb format: (('name', 'url'), ...) or None if not used.
"""
if not self.breadcrumbs:
return None
else:
allowed_breadcrumbs = []
for breadcrumb in self.breadcrumbs:
# check permission based ... | [
"def",
"get_breadcrumbs",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"breadcrumbs",
":",
"return",
"None",
"else",
":",
"allowed_breadcrumbs",
"=",
"[",
"]",
"for",
"breadcrumb",
"in",
"self",
".",
"breadcrumbs",
":",
"# check permission based on named_url... | Breadcrumb format: (('name', 'url'), ...) or None if not used. | [
"Breadcrumb",
"format",
":",
"((",
"name",
"url",
")",
"...",
")",
"or",
"None",
"if",
"not",
"used",
"."
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/generics.py#L126-L149 |
sanoma/django-arctic | arctic/generics.py | View.get_tabs | def get_tabs(self):
"""
Tabs format: (('name', 'url'), ...) or None if tabs are not used.
"""
if not self.tabs:
return None
else:
allowed_tabs = []
for tab in self.tabs:
# check permission based on named_url
if ... | python | def get_tabs(self):
"""
Tabs format: (('name', 'url'), ...) or None if tabs are not used.
"""
if not self.tabs:
return None
else:
allowed_tabs = []
for tab in self.tabs:
# check permission based on named_url
if ... | [
"def",
"get_tabs",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"tabs",
":",
"return",
"None",
"else",
":",
"allowed_tabs",
"=",
"[",
"]",
"for",
"tab",
"in",
"self",
".",
"tabs",
":",
"# check permission based on named_url",
"if",
"not",
"view_from_ur... | Tabs format: (('name', 'url'), ...) or None if tabs are not used. | [
"Tabs",
"format",
":",
"((",
"name",
"url",
")",
"...",
")",
"or",
"None",
"if",
"tabs",
"are",
"not",
"used",
"."
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/generics.py#L151-L174 |
sanoma/django-arctic | arctic/generics.py | View.media | def media(self):
"""
Return all media required to render this view, including forms.
"""
media = self._get_common_media()
media += self._get_view_media()
media += self.get_media_assets()
return media | python | def media(self):
"""
Return all media required to render this view, including forms.
"""
media = self._get_common_media()
media += self._get_view_media()
media += self.get_media_assets()
return media | [
"def",
"media",
"(",
"self",
")",
":",
"media",
"=",
"self",
".",
"_get_common_media",
"(",
")",
"media",
"+=",
"self",
".",
"_get_view_media",
"(",
")",
"media",
"+=",
"self",
".",
"get_media_assets",
"(",
")",
"return",
"media"
] | Return all media required to render this view, including forms. | [
"Return",
"all",
"media",
"required",
"to",
"render",
"this",
"view",
"including",
"forms",
"."
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/generics.py#L262-L269 |
sanoma/django-arctic | arctic/generics.py | View._get_view_media | def _get_view_media(self):
"""
Gather view-level media assets
"""
try:
css = self.Media.css
except AttributeError:
css = {}
try:
js = self.Media.js
except AttributeError:
js = []
return Media(css=css, js=js) | python | def _get_view_media(self):
"""
Gather view-level media assets
"""
try:
css = self.Media.css
except AttributeError:
css = {}
try:
js = self.Media.js
except AttributeError:
js = []
return Media(css=css, js=js) | [
"def",
"_get_view_media",
"(",
"self",
")",
":",
"try",
":",
"css",
"=",
"self",
".",
"Media",
".",
"css",
"except",
"AttributeError",
":",
"css",
"=",
"{",
"}",
"try",
":",
"js",
"=",
"self",
".",
"Media",
".",
"js",
"except",
"AttributeError",
":",... | Gather view-level media assets | [
"Gather",
"view",
"-",
"level",
"media",
"assets"
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/generics.py#L284-L296 |
sanoma/django-arctic | arctic/generics.py | ListView.get_list_header | def get_list_header(self):
"""
Creates a list of dictionaries with the field names, labels,
field links, field css classes, order_url and order_direction,
this simplifies the creation of a table in a template.
"""
model = self.object_list.model
result = []
... | python | def get_list_header(self):
"""
Creates a list of dictionaries with the field names, labels,
field links, field css classes, order_url and order_direction,
this simplifies the creation of a table in a template.
"""
model = self.object_list.model
result = []
... | [
"def",
"get_list_header",
"(",
"self",
")",
":",
"model",
"=",
"self",
".",
"object_list",
".",
"model",
"result",
"=",
"[",
"]",
"if",
"not",
"self",
".",
"get_fields",
"(",
")",
":",
"result",
".",
"append",
"(",
"{",
"\"name\"",
":",
"\"\"",
",",
... | Creates a list of dictionaries with the field names, labels,
field links, field css classes, order_url and order_direction,
this simplifies the creation of a table in a template. | [
"Creates",
"a",
"list",
"of",
"dictionaries",
"with",
"the",
"field",
"names",
"labels",
"field",
"links",
"field",
"css",
"classes",
"order_url",
"and",
"order_direction",
"this",
"simplifies",
"the",
"creation",
"of",
"a",
"table",
"in",
"a",
"template",
"."... | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/generics.py#L416-L458 |
sanoma/django-arctic | arctic/generics.py | ListView.get_ordering | def get_ordering(self):
"""Ordering used for queryset filtering (should not contain prefix)."""
if self.sorting_field:
return [self.sorting_field]
prefix = self.get_prefix()
fields = self.get_ordering_with_prefix()
if self.prefix:
fields = [f.replace(prefi... | python | def get_ordering(self):
"""Ordering used for queryset filtering (should not contain prefix)."""
if self.sorting_field:
return [self.sorting_field]
prefix = self.get_prefix()
fields = self.get_ordering_with_prefix()
if self.prefix:
fields = [f.replace(prefi... | [
"def",
"get_ordering",
"(",
"self",
")",
":",
"if",
"self",
".",
"sorting_field",
":",
"return",
"[",
"self",
".",
"sorting_field",
"]",
"prefix",
"=",
"self",
".",
"get_prefix",
"(",
")",
"fields",
"=",
"self",
".",
"get_ordering_with_prefix",
"(",
")",
... | Ordering used for queryset filtering (should not contain prefix). | [
"Ordering",
"used",
"for",
"queryset",
"filtering",
"(",
"should",
"not",
"contain",
"prefix",
")",
"."
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/generics.py#L563-L575 |
sanoma/django-arctic | arctic/generics.py | DataListView.get_list_header | def get_list_header(self):
"""
Creates a list of dictionaries with the field names, labels,
field links, field css classes, order_url and order_direction,
this simplifies the creation of a table in a template.
"""
result = []
for field_name in self.get_fields():
... | python | def get_list_header(self):
"""
Creates a list of dictionaries with the field names, labels,
field links, field css classes, order_url and order_direction,
this simplifies the creation of a table in a template.
"""
result = []
for field_name in self.get_fields():
... | [
"def",
"get_list_header",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"for",
"field_name",
"in",
"self",
".",
"get_fields",
"(",
")",
":",
"item",
"=",
"{",
"}",
"if",
"isinstance",
"(",
"field_name",
",",
"tuple",
")",
":",
"# custom property that i... | Creates a list of dictionaries with the field names, labels,
field links, field css classes, order_url and order_direction,
this simplifies the creation of a table in a template. | [
"Creates",
"a",
"list",
"of",
"dictionaries",
"with",
"the",
"field",
"names",
"labels",
"field",
"links",
"field",
"css",
"classes",
"order_url",
"and",
"order_direction",
"this",
"simplifies",
"the",
"creation",
"of",
"a",
"table",
"in",
"a",
"template",
"."... | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/generics.py#L649-L671 |
sanoma/django-arctic | arctic/generics.py | DataListView.get_paginator | def get_paginator(
self,
dataset,
per_page,
orphans=0,
allow_empty_first_page=True,
**kwargs
):
"""Return an instance of the paginator for this view."""
return IndefinitePaginator(
dataset,
per_page,
orphans=orphans,... | python | def get_paginator(
self,
dataset,
per_page,
orphans=0,
allow_empty_first_page=True,
**kwargs
):
"""Return an instance of the paginator for this view."""
return IndefinitePaginator(
dataset,
per_page,
orphans=orphans,... | [
"def",
"get_paginator",
"(",
"self",
",",
"dataset",
",",
"per_page",
",",
"orphans",
"=",
"0",
",",
"allow_empty_first_page",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"IndefinitePaginator",
"(",
"dataset",
",",
"per_page",
",",
"orphans",
... | Return an instance of the paginator for this view. | [
"Return",
"an",
"instance",
"of",
"the",
"paginator",
"for",
"this",
"view",
"."
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/generics.py#L729-L744 |
sanoma/django-arctic | arctic/generics.py | DeleteView.get | def get(self, request, *args, **kwargs):
"""
Catch protected relations and show to user.
"""
self.object = self.get_object()
can_delete = True
protected_objects = []
collector_message = None
collector = Collector(using="default")
try:
c... | python | def get(self, request, *args, **kwargs):
"""
Catch protected relations and show to user.
"""
self.object = self.get_object()
can_delete = True
protected_objects = []
collector_message = None
collector = Collector(using="default")
try:
c... | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"object",
"=",
"self",
".",
"get_object",
"(",
")",
"can_delete",
"=",
"True",
"protected_objects",
"=",
"[",
"]",
"collector_message",
"=",
... | Catch protected relations and show to user. | [
"Catch",
"protected",
"relations",
"and",
"show",
"to",
"user",
"."
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/generics.py#L855-L884 |
sanoma/django-arctic | arctic/mixins.py | ModalMixin.get_modal_link | def get_modal_link(self, url, obj={}):
"""
Returns the metadata for a link that needs to be confirmed, if it
exists, it also parses the message and title of the url to include
row field data if needed.
"""
if not (url in self.modal_links.keys()):
return None
... | python | def get_modal_link(self, url, obj={}):
"""
Returns the metadata for a link that needs to be confirmed, if it
exists, it also parses the message and title of the url to include
row field data if needed.
"""
if not (url in self.modal_links.keys()):
return None
... | [
"def",
"get_modal_link",
"(",
"self",
",",
"url",
",",
"obj",
"=",
"{",
"}",
")",
":",
"if",
"not",
"(",
"url",
"in",
"self",
".",
"modal_links",
".",
"keys",
"(",
")",
")",
":",
"return",
"None",
"try",
":",
"if",
"type",
"(",
"obj",
")",
"!="... | Returns the metadata for a link that needs to be confirmed, if it
exists, it also parses the message and title of the url to include
row field data if needed. | [
"Returns",
"the",
"metadata",
"for",
"a",
"link",
"that",
"needs",
"to",
"be",
"confirmed",
"if",
"it",
"exists",
"it",
"also",
"parses",
"the",
"message",
"and",
"title",
"of",
"the",
"url",
"to",
"include",
"row",
"field",
"data",
"if",
"needed",
"."
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/mixins.py#L56-L90 |
sanoma/django-arctic | arctic/mixins.py | FormMixin.get_success_url | def get_success_url(self):
"""Return the URL to redirect to after processing a valid form."""
if not self.success_url:
if self.request.GET.get("inmodal"):
return reverse("arctic:redirect_to_parent")
raise ImproperlyConfigured(
"No URL to redirect t... | python | def get_success_url(self):
"""Return the URL to redirect to after processing a valid form."""
if not self.success_url:
if self.request.GET.get("inmodal"):
return reverse("arctic:redirect_to_parent")
raise ImproperlyConfigured(
"No URL to redirect t... | [
"def",
"get_success_url",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"success_url",
":",
"if",
"self",
".",
"request",
".",
"GET",
".",
"get",
"(",
"\"inmodal\"",
")",
":",
"return",
"reverse",
"(",
"\"arctic:redirect_to_parent\"",
")",
"raise",
"Imp... | Return the URL to redirect to after processing a valid form. | [
"Return",
"the",
"URL",
"to",
"redirect",
"to",
"after",
"processing",
"a",
"valid",
"form",
"."
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/mixins.py#L132-L140 |
sanoma/django-arctic | arctic/mixins.py | FormMixin._set_has_no_columns | def _set_has_no_columns(self, has_no_column, col_avg, col_last, fields):
"""
Regenerate has_no_column by adding the amount of columns at the end
"""
for index, field in has_no_column.items():
if index == len(has_no_column):
field_name = "{field}|{col_last}".fo... | python | def _set_has_no_columns(self, has_no_column, col_avg, col_last, fields):
"""
Regenerate has_no_column by adding the amount of columns at the end
"""
for index, field in has_no_column.items():
if index == len(has_no_column):
field_name = "{field}|{col_last}".fo... | [
"def",
"_set_has_no_columns",
"(",
"self",
",",
"has_no_column",
",",
"col_avg",
",",
"col_last",
",",
"fields",
")",
":",
"for",
"index",
",",
"field",
"in",
"has_no_column",
".",
"items",
"(",
")",
":",
"if",
"index",
"==",
"len",
"(",
"has_no_column",
... | Regenerate has_no_column by adding the amount of columns at the end | [
"Regenerate",
"has_no_column",
"by",
"adding",
"the",
"amount",
"of",
"columns",
"at",
"the",
"end"
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/mixins.py#L313-L328 |
sanoma/django-arctic | arctic/mixins.py | FormMixin._return_fieldset | def _return_fieldset(self, fieldset):
"""
This function became a bit messy, since it needs to deal with two
cases.
1) No fieldset, which is represented as an integer
2) A fieldset
"""
collapsible = None
description = None
try:
# Make s... | python | def _return_fieldset(self, fieldset):
"""
This function became a bit messy, since it needs to deal with two
cases.
1) No fieldset, which is represented as an integer
2) A fieldset
"""
collapsible = None
description = None
try:
# Make s... | [
"def",
"_return_fieldset",
"(",
"self",
",",
"fieldset",
")",
":",
"collapsible",
"=",
"None",
"description",
"=",
"None",
"try",
":",
"# Make sure strings with numbers work as well, do this",
"int",
"(",
"str",
"(",
"fieldset",
")",
")",
"title",
"=",
"None",
"... | This function became a bit messy, since it needs to deal with two
cases.
1) No fieldset, which is represented as an integer
2) A fieldset | [
"This",
"function",
"became",
"a",
"bit",
"messy",
"since",
"it",
"needs",
"to",
"deal",
"with",
"two",
"cases",
"."
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/mixins.py#L330-L367 |
sanoma/django-arctic | arctic/mixins.py | FormMixin._calc_avg_and_last_val | def _calc_avg_and_last_val(self, has_no_column, sum_existing_columns):
"""
Calculate the average of all columns and return a rounded down number.
Store the remainder and add it to the last row. Could be implemented
better. If the enduser wants more control, he can also just add the
... | python | def _calc_avg_and_last_val(self, has_no_column, sum_existing_columns):
"""
Calculate the average of all columns and return a rounded down number.
Store the remainder and add it to the last row. Could be implemented
better. If the enduser wants more control, he can also just add the
... | [
"def",
"_calc_avg_and_last_val",
"(",
"self",
",",
"has_no_column",
",",
"sum_existing_columns",
")",
":",
"sum_no_columns",
"=",
"len",
"(",
"has_no_column",
")",
"columns_left",
"=",
"self",
".",
"ALLOWED_COLUMNS",
"-",
"sum_existing_columns",
"if",
"sum_no_columns"... | Calculate the average of all columns and return a rounded down number.
Store the remainder and add it to the last row. Could be implemented
better. If the enduser wants more control, he can also just add the
amount of columns. Will work fine with small number (<4) of items in a
row.
... | [
"Calculate",
"the",
"average",
"of",
"all",
"columns",
"and",
"return",
"a",
"rounded",
"down",
"number",
".",
"Store",
"the",
"remainder",
"and",
"add",
"it",
"to",
"the",
"last",
"row",
".",
"Could",
"be",
"implemented",
"better",
".",
"If",
"the",
"en... | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/mixins.py#L369-L391 |
sanoma/django-arctic | arctic/mixins.py | FormMixin._split_str | def _split_str(self, field):
"""
Split title|7 into (title, 7)
"""
field_items = field.split("|")
if len(field_items) == 2:
return field_items[0], field_items[1]
elif len(field_items) == 1:
return field_items[0], None | python | def _split_str(self, field):
"""
Split title|7 into (title, 7)
"""
field_items = field.split("|")
if len(field_items) == 2:
return field_items[0], field_items[1]
elif len(field_items) == 1:
return field_items[0], None | [
"def",
"_split_str",
"(",
"self",
",",
"field",
")",
":",
"field_items",
"=",
"field",
".",
"split",
"(",
"\"|\"",
")",
"if",
"len",
"(",
"field_items",
")",
"==",
"2",
":",
"return",
"field_items",
"[",
"0",
"]",
",",
"field_items",
"[",
"1",
"]",
... | Split title|7 into (title, 7) | [
"Split",
"title|7",
"into",
"(",
"title",
"7",
")"
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/mixins.py#L393-L401 |
sanoma/django-arctic | arctic/mixins.py | ListMixin.ordering_url | def ordering_url(self, field_name):
"""
Creates a url link for sorting the given field.
The direction of sorting will be either ascending, if the field is not
yet sorted, or the opposite of the current sorting if sorted.
"""
path = self.request.path
direction = "... | python | def ordering_url(self, field_name):
"""
Creates a url link for sorting the given field.
The direction of sorting will be either ascending, if the field is not
yet sorted, or the opposite of the current sorting if sorted.
"""
path = self.request.path
direction = "... | [
"def",
"ordering_url",
"(",
"self",
",",
"field_name",
")",
":",
"path",
"=",
"self",
".",
"request",
".",
"path",
"direction",
"=",
"\"\"",
"query_params",
"=",
"self",
".",
"request",
".",
"GET",
".",
"copy",
"(",
")",
"ordering",
"=",
"self",
".",
... | Creates a url link for sorting the given field.
The direction of sorting will be either ascending, if the field is not
yet sorted, or the opposite of the current sorting if sorted. | [
"Creates",
"a",
"url",
"link",
"for",
"sorting",
"the",
"given",
"field",
"."
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/mixins.py#L561-L596 |
sanoma/django-arctic | arctic/mixins.py | ListMixin.get_fields | def get_fields(self, strip_labels=False):
"""
Hook to dynamically change the fields that will be displayed
"""
if strip_labels:
return [
f[0] if type(f) in (tuple, list) else f for f in self.fields
]
return self.fields | python | def get_fields(self, strip_labels=False):
"""
Hook to dynamically change the fields that will be displayed
"""
if strip_labels:
return [
f[0] if type(f) in (tuple, list) else f for f in self.fields
]
return self.fields | [
"def",
"get_fields",
"(",
"self",
",",
"strip_labels",
"=",
"False",
")",
":",
"if",
"strip_labels",
":",
"return",
"[",
"f",
"[",
"0",
"]",
"if",
"type",
"(",
"f",
")",
"in",
"(",
"tuple",
",",
"list",
")",
"else",
"f",
"for",
"f",
"in",
"self",... | Hook to dynamically change the fields that will be displayed | [
"Hook",
"to",
"dynamically",
"change",
"the",
"fields",
"that",
"will",
"be",
"displayed"
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/mixins.py#L598-L606 |
sanoma/django-arctic | arctic/mixins.py | ListMixin.get_ordering_fields_lookups | def get_ordering_fields_lookups(self):
"""
Getting real model fields to order by
"""
ordering_field = []
for field_name in self.get_ordering_fields():
ordering_field.append(self._get_ordering_field_lookup(field_name))
return ordering_field | python | def get_ordering_fields_lookups(self):
"""
Getting real model fields to order by
"""
ordering_field = []
for field_name in self.get_ordering_fields():
ordering_field.append(self._get_ordering_field_lookup(field_name))
return ordering_field | [
"def",
"get_ordering_fields_lookups",
"(",
"self",
")",
":",
"ordering_field",
"=",
"[",
"]",
"for",
"field_name",
"in",
"self",
".",
"get_ordering_fields",
"(",
")",
":",
"ordering_field",
".",
"append",
"(",
"self",
".",
"_get_ordering_field_lookup",
"(",
"fie... | Getting real model fields to order by | [
"Getting",
"real",
"model",
"fields",
"to",
"order",
"by"
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/mixins.py#L614-L621 |
sanoma/django-arctic | arctic/mixins.py | ListMixin._get_ordering_field_lookup | def _get_ordering_field_lookup(self, field_name):
"""
get real model field to order by
"""
field = field_name
get_field = getattr(self, "get_%s_ordering_field" % field_name, None)
if get_field:
field = get_field()
return field | python | def _get_ordering_field_lookup(self, field_name):
"""
get real model field to order by
"""
field = field_name
get_field = getattr(self, "get_%s_ordering_field" % field_name, None)
if get_field:
field = get_field()
return field | [
"def",
"_get_ordering_field_lookup",
"(",
"self",
",",
"field_name",
")",
":",
"field",
"=",
"field_name",
"get_field",
"=",
"getattr",
"(",
"self",
",",
"\"get_%s_ordering_field\"",
"%",
"field_name",
",",
"None",
")",
"if",
"get_field",
":",
"field",
"=",
"g... | get real model field to order by | [
"get",
"real",
"model",
"field",
"to",
"order",
"by"
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/mixins.py#L623-L631 |
sanoma/django-arctic | arctic/mixins.py | ListMixin.get_advanced_search_form | def get_advanced_search_form(self, data):
"""
Hook to dynamically change the advanced search form
"""
if self.get_advanced_search_form_class():
self._advanced_search_form = self.get_advanced_search_form_class()(
data=data
)
return self.... | python | def get_advanced_search_form(self, data):
"""
Hook to dynamically change the advanced search form
"""
if self.get_advanced_search_form_class():
self._advanced_search_form = self.get_advanced_search_form_class()(
data=data
)
return self.... | [
"def",
"get_advanced_search_form",
"(",
"self",
",",
"data",
")",
":",
"if",
"self",
".",
"get_advanced_search_form_class",
"(",
")",
":",
"self",
".",
"_advanced_search_form",
"=",
"self",
".",
"get_advanced_search_form_class",
"(",
")",
"(",
"data",
"=",
"data... | Hook to dynamically change the advanced search form | [
"Hook",
"to",
"dynamically",
"change",
"the",
"advanced",
"search",
"form"
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/mixins.py#L792-L800 |
sanoma/django-arctic | arctic/mixins.py | RoleAuthentication.sync | def sync(cls):
"""
Save all the roles defined in the settings that are not yet in the db
this is needed to create a foreign key relation between a user and a
role. Roles that are no longer specified in settings are set as
inactive.
"""
try:
settings_ro... | python | def sync(cls):
"""
Save all the roles defined in the settings that are not yet in the db
this is needed to create a foreign key relation between a user and a
role. Roles that are no longer specified in settings are set as
inactive.
"""
try:
settings_ro... | [
"def",
"sync",
"(",
"cls",
")",
":",
"try",
":",
"settings_roles",
"=",
"set",
"(",
"settings",
".",
"ARCTIC_ROLES",
".",
"keys",
"(",
")",
")",
"except",
"AttributeError",
":",
"settings_roles",
"=",
"set",
"(",
")",
"saved_roles",
"=",
"set",
"(",
"R... | Save all the roles defined in the settings that are not yet in the db
this is needed to create a foreign key relation between a user and a
role. Roles that are no longer specified in settings are set as
inactive. | [
"Save",
"all",
"the",
"roles",
"defined",
"in",
"the",
"settings",
"that",
"are",
"not",
"yet",
"in",
"the",
"db",
"this",
"is",
"needed",
"to",
"create",
"a",
"foreign",
"key",
"relation",
"between",
"a",
"user",
"and",
"a",
"role",
".",
"Roles",
"tha... | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/mixins.py#L820-L862 |
sanoma/django-arctic | arctic/mixins.py | RoleAuthentication.get_permission_required | def get_permission_required(cls):
"""
Get permission required property.
Must return an iterable.
"""
if cls.permission_required is None:
raise ImproperlyConfigured(
"{0} is missing the permission_required attribute. "
"Define {0}.permis... | python | def get_permission_required(cls):
"""
Get permission required property.
Must return an iterable.
"""
if cls.permission_required is None:
raise ImproperlyConfigured(
"{0} is missing the permission_required attribute. "
"Define {0}.permis... | [
"def",
"get_permission_required",
"(",
"cls",
")",
":",
"if",
"cls",
".",
"permission_required",
"is",
"None",
":",
"raise",
"ImproperlyConfigured",
"(",
"\"{0} is missing the permission_required attribute. \"",
"\"Define {0}.permission_required, or override \"",
"\"{0}.get_permi... | Get permission required property.
Must return an iterable. | [
"Get",
"permission",
"required",
"property",
".",
"Must",
"return",
"an",
"iterable",
"."
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/mixins.py#L865-L884 |
sanoma/django-arctic | arctic/mixins.py | RoleAuthentication.has_permission | def has_permission(cls, user):
"""
We override this method to customize the way permissions are checked.
Using our roles to check permissions.
"""
# no login is needed, so its always fine
if not cls.requires_login:
return True
# if user is somehow not... | python | def has_permission(cls, user):
"""
We override this method to customize the way permissions are checked.
Using our roles to check permissions.
"""
# no login is needed, so its always fine
if not cls.requires_login:
return True
# if user is somehow not... | [
"def",
"has_permission",
"(",
"cls",
",",
"user",
")",
":",
"# no login is needed, so its always fine",
"if",
"not",
"cls",
".",
"requires_login",
":",
"return",
"True",
"# if user is somehow not logged in",
"if",
"not",
"user",
".",
"is_authenticated",
":",
"return",... | We override this method to customize the way permissions are checked.
Using our roles to check permissions. | [
"We",
"override",
"this",
"method",
"to",
"customize",
"the",
"way",
"permissions",
"are",
"checked",
".",
"Using",
"our",
"roles",
"to",
"check",
"permissions",
"."
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/mixins.py#L887-L917 |
sanoma/django-arctic | arctic/mixins.py | RoleAuthentication.check_permission | def check_permission(cls, role, permission):
"""
Check if role contains permission
"""
result = permission in settings.ARCTIC_ROLES[role]
# will try to call a method with the same name as the permission
# to enable an object level permission check.
if result:
... | python | def check_permission(cls, role, permission):
"""
Check if role contains permission
"""
result = permission in settings.ARCTIC_ROLES[role]
# will try to call a method with the same name as the permission
# to enable an object level permission check.
if result:
... | [
"def",
"check_permission",
"(",
"cls",
",",
"role",
",",
"permission",
")",
":",
"result",
"=",
"permission",
"in",
"settings",
".",
"ARCTIC_ROLES",
"[",
"role",
"]",
"# will try to call a method with the same name as the permission",
"# to enable an object level permission... | Check if role contains permission | [
"Check",
"if",
"role",
"contains",
"permission"
] | train | https://github.com/sanoma/django-arctic/blob/c81b092c2643ca220708bf3c586017d9175161f5/arctic/mixins.py#L920-L932 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.