repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
hozn/coilmq | coilmq/engine.py | StompEngine.unbind | def unbind(self):
"""
Unbinds this connection from queue and topic managers (freeing up resources)
and resets state.
"""
self.connected = False
self.queue_manager.disconnect(self.connection)
self.topic_manager.disconnect(self.connection) | python | def unbind(self):
"""
Unbinds this connection from queue and topic managers (freeing up resources)
and resets state.
"""
self.connected = False
self.queue_manager.disconnect(self.connection)
self.topic_manager.disconnect(self.connection) | [
"def",
"unbind",
"(",
"self",
")",
":",
"self",
".",
"connected",
"=",
"False",
"self",
".",
"queue_manager",
".",
"disconnect",
"(",
"self",
".",
"connection",
")",
"self",
".",
"topic_manager",
".",
"disconnect",
"(",
"self",
".",
"connection",
")"
] | Unbinds this connection from queue and topic managers (freeing up resources)
and resets state. | [
"Unbinds",
"this",
"connection",
"from",
"queue",
"and",
"topic",
"managers",
"(",
"freeing",
"up",
"resources",
")",
"and",
"resets",
"state",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/engine.py#L87-L94 |
hozn/coilmq | coilmq/queue.py | QueueManager.close | def close(self):
"""
Closes all resources/backends associated with this queue manager.
"""
self.log.info("Shutting down queue manager.")
if hasattr(self.store, 'close'):
self.store.close()
if hasattr(self.subscriber_scheduler, 'close'):
self.subsc... | python | def close(self):
"""
Closes all resources/backends associated with this queue manager.
"""
self.log.info("Shutting down queue manager.")
if hasattr(self.store, 'close'):
self.store.close()
if hasattr(self.subscriber_scheduler, 'close'):
self.subsc... | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"Shutting down queue manager.\"",
")",
"if",
"hasattr",
"(",
"self",
".",
"store",
",",
"'close'",
")",
":",
"self",
".",
"store",
".",
"close",
"(",
")",
"if",
"hasattr",
... | Closes all resources/backends associated with this queue manager. | [
"Closes",
"all",
"resources",
"/",
"backends",
"associated",
"with",
"this",
"queue",
"manager",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/queue.py#L99-L111 |
hozn/coilmq | coilmq/queue.py | QueueManager.subscriber_count | def subscriber_count(self, destination=None):
"""
Returns a count of the number of subscribers.
If destination is specified then it only returns count of subscribers
for that specific destination.
@param destination: The optional topic/queue destination (e.g. '/queue/foo')
... | python | def subscriber_count(self, destination=None):
"""
Returns a count of the number of subscribers.
If destination is specified then it only returns count of subscribers
for that specific destination.
@param destination: The optional topic/queue destination (e.g. '/queue/foo')
... | [
"def",
"subscriber_count",
"(",
"self",
",",
"destination",
"=",
"None",
")",
":",
"if",
"destination",
":",
"return",
"len",
"(",
"self",
".",
"_queues",
"[",
"destination",
"]",
")",
"else",
":",
"# total them up",
"total",
"=",
"0",
"for",
"k",
"in",
... | Returns a count of the number of subscribers.
If destination is specified then it only returns count of subscribers
for that specific destination.
@param destination: The optional topic/queue destination (e.g. '/queue/foo')
@type destination: C{str} | [
"Returns",
"a",
"count",
"of",
"the",
"number",
"of",
"subscribers",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/queue.py#L114-L131 |
hozn/coilmq | coilmq/queue.py | QueueManager.subscribe | def subscribe(self, connection, destination):
"""
Subscribes a connection to the specified destination (topic or queue).
@param connection: The connection to subscribe.
@type connection: L{coilmq.server.StompConnection}
@param destination: The topic/queue destination (e.g. '/q... | python | def subscribe(self, connection, destination):
"""
Subscribes a connection to the specified destination (topic or queue).
@param connection: The connection to subscribe.
@type connection: L{coilmq.server.StompConnection}
@param destination: The topic/queue destination (e.g. '/q... | [
"def",
"subscribe",
"(",
"self",
",",
"connection",
",",
"destination",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Subscribing %s to %s\"",
"%",
"(",
"connection",
",",
"destination",
")",
")",
"self",
".",
"_queues",
"[",
"destination",
"]",
".",... | Subscribes a connection to the specified destination (topic or queue).
@param connection: The connection to subscribe.
@type connection: L{coilmq.server.StompConnection}
@param destination: The topic/queue destination (e.g. '/queue/foo')
@type destination: C{str} | [
"Subscribes",
"a",
"connection",
"to",
"the",
"specified",
"destination",
"(",
"topic",
"or",
"queue",
")",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/queue.py#L134-L146 |
hozn/coilmq | coilmq/queue.py | QueueManager.unsubscribe | def unsubscribe(self, connection, destination):
"""
Unsubscribes a connection from a destination (topic or queue).
@param connection: The client connection to unsubscribe.
@type connection: L{coilmq.server.StompConnection}
@param destination: The topic/queue destination (e.g. '... | python | def unsubscribe(self, connection, destination):
"""
Unsubscribes a connection from a destination (topic or queue).
@param connection: The client connection to unsubscribe.
@type connection: L{coilmq.server.StompConnection}
@param destination: The topic/queue destination (e.g. '... | [
"def",
"unsubscribe",
"(",
"self",
",",
"connection",
",",
"destination",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Unsubscribing %s from %s\"",
"%",
"(",
"connection",
",",
"destination",
")",
")",
"if",
"connection",
"in",
"self",
".",
"_queues",... | Unsubscribes a connection from a destination (topic or queue).
@param connection: The client connection to unsubscribe.
@type connection: L{coilmq.server.StompConnection}
@param destination: The topic/queue destination (e.g. '/queue/foo')
@type destination: C{str} | [
"Unsubscribes",
"a",
"connection",
"from",
"a",
"destination",
"(",
"topic",
"or",
"queue",
")",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/queue.py#L149-L164 |
hozn/coilmq | coilmq/queue.py | QueueManager.disconnect | def disconnect(self, connection):
"""
Removes a subscriber connection, ensuring that any pending commands get requeued.
@param connection: The client connection to unsubscribe.
@type connection: L{coilmq.server.StompConnection}
"""
self.log.debug("Disconnecting %s" % con... | python | def disconnect(self, connection):
"""
Removes a subscriber connection, ensuring that any pending commands get requeued.
@param connection: The client connection to unsubscribe.
@type connection: L{coilmq.server.StompConnection}
"""
self.log.debug("Disconnecting %s" % con... | [
"def",
"disconnect",
"(",
"self",
",",
"connection",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Disconnecting %s\"",
"%",
"connection",
")",
"if",
"connection",
"in",
"self",
".",
"_pending",
":",
"pending_frame",
"=",
"self",
".",
"_pending",
"["... | Removes a subscriber connection, ensuring that any pending commands get requeued.
@param connection: The client connection to unsubscribe.
@type connection: L{coilmq.server.StompConnection} | [
"Removes",
"a",
"subscriber",
"connection",
"ensuring",
"that",
"any",
"pending",
"commands",
"get",
"requeued",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/queue.py#L167-L186 |
hozn/coilmq | coilmq/queue.py | QueueManager.send | def send(self, message):
"""
Sends a MESSAGE frame to an eligible subscriber connection.
Note that this method will modify the incoming message object to
add a message-id header (if not present) and to change the command
to 'MESSAGE' (if it is not).
@param message: The... | python | def send(self, message):
"""
Sends a MESSAGE frame to an eligible subscriber connection.
Note that this method will modify the incoming message object to
add a message-id header (if not present) and to change the command
to 'MESSAGE' (if it is not).
@param message: The... | [
"def",
"send",
"(",
"self",
",",
"message",
")",
":",
"dest",
"=",
"message",
".",
"headers",
".",
"get",
"(",
"'destination'",
")",
"if",
"not",
"dest",
":",
"raise",
"ValueError",
"(",
"\"Cannot send frame with no destination: %s\"",
"%",
"message",
")",
"... | Sends a MESSAGE frame to an eligible subscriber connection.
Note that this method will modify the incoming message object to
add a message-id header (if not present) and to change the command
to 'MESSAGE' (if it is not).
@param message: The message frame.
@type message: C{stom... | [
"Sends",
"a",
"MESSAGE",
"frame",
"to",
"an",
"eligible",
"subscriber",
"connection",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/queue.py#L189-L222 |
hozn/coilmq | coilmq/queue.py | QueueManager.ack | def ack(self, connection, frame, transaction=None):
"""
Acknowledge receipt of a message.
If the `transaction` parameter is non-null, the frame being ack'd
will be queued so that it can be requeued if the transaction
is rolled back.
@param connection: The connection th... | python | def ack(self, connection, frame, transaction=None):
"""
Acknowledge receipt of a message.
If the `transaction` parameter is non-null, the frame being ack'd
will be queued so that it can be requeued if the transaction
is rolled back.
@param connection: The connection th... | [
"def",
"ack",
"(",
"self",
",",
"connection",
",",
"frame",
",",
"transaction",
"=",
"None",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"ACK %s for %s\"",
"%",
"(",
"frame",
",",
"connection",
")",
")",
"if",
"connection",
"in",
"self",
".",
... | Acknowledge receipt of a message.
If the `transaction` parameter is non-null, the frame being ack'd
will be queued so that it can be requeued if the transaction
is rolled back.
@param connection: The connection that is acknowledging the frame.
@type connection: L{coilmq.server... | [
"Acknowledge",
"receipt",
"of",
"a",
"message",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/queue.py#L225-L259 |
hozn/coilmq | coilmq/queue.py | QueueManager.resend_transaction_frames | def resend_transaction_frames(self, connection, transaction):
"""
Resend the messages that were ACK'd in specified transaction.
This is called by the engine when there is an abort command.
@param connection: The client connection that aborted the transaction.
@type connection: ... | python | def resend_transaction_frames(self, connection, transaction):
"""
Resend the messages that were ACK'd in specified transaction.
This is called by the engine when there is an abort command.
@param connection: The client connection that aborted the transaction.
@type connection: ... | [
"def",
"resend_transaction_frames",
"(",
"self",
",",
"connection",
",",
"transaction",
")",
":",
"for",
"frame",
"in",
"self",
".",
"_transaction_frames",
"[",
"connection",
"]",
"[",
"transaction",
"]",
":",
"self",
".",
"send",
"(",
"frame",
")"
] | Resend the messages that were ACK'd in specified transaction.
This is called by the engine when there is an abort command.
@param connection: The client connection that aborted the transaction.
@type connection: L{coilmq.server.StompConnection}
@param transaction: The transaction id (... | [
"Resend",
"the",
"messages",
"that",
"were",
"ACK",
"d",
"in",
"specified",
"transaction",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/queue.py#L262-L275 |
hozn/coilmq | coilmq/queue.py | QueueManager._send_backlog | def _send_backlog(self, connection, destination=None):
"""
Sends any queued-up messages for the (optionally) specified destination to connection.
If the destination is not provided, a destination is chosen using the
L{QueueManager.queue_scheduler} scheduler algorithm.
(This me... | python | def _send_backlog(self, connection, destination=None):
"""
Sends any queued-up messages for the (optionally) specified destination to connection.
If the destination is not provided, a destination is chosen using the
L{QueueManager.queue_scheduler} scheduler algorithm.
(This me... | [
"def",
"_send_backlog",
"(",
"self",
",",
"connection",
",",
"destination",
"=",
"None",
")",
":",
"if",
"destination",
"is",
"None",
":",
"# Find all destinations that have frames and that contain this",
"# connection (subscriber).",
"eligible_queues",
"=",
"dict",
"(",
... | Sends any queued-up messages for the (optionally) specified destination to connection.
If the destination is not provided, a destination is chosen using the
L{QueueManager.queue_scheduler} scheduler algorithm.
(This method assumes it is being called from within a lock-guarded public
m... | [
"Sends",
"any",
"queued",
"-",
"up",
"messages",
"for",
"the",
"(",
"optionally",
")",
"specified",
"destination",
"to",
"connection",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/queue.py#L296-L348 |
hozn/coilmq | coilmq/queue.py | QueueManager._send_frame | def _send_frame(self, connection, frame):
"""
Sends a frame to a specific subscriber connection.
(This method assumes it is being called from within a lock-guarded public
method.)
@param connection: The subscriber connection object to send to.
@type connection: L{coilmq... | python | def _send_frame(self, connection, frame):
"""
Sends a frame to a specific subscriber connection.
(This method assumes it is being called from within a lock-guarded public
method.)
@param connection: The subscriber connection object to send to.
@type connection: L{coilmq... | [
"def",
"_send_frame",
"(",
"self",
",",
"connection",
",",
"frame",
")",
":",
"assert",
"connection",
"is",
"not",
"None",
"assert",
"frame",
"is",
"not",
"None",
"self",
".",
"log",
".",
"debug",
"(",
"\"Delivering frame %s to connection %s\"",
"%",
"(",
"f... | Sends a frame to a specific subscriber connection.
(This method assumes it is being called from within a lock-guarded public
method.)
@param connection: The subscriber connection object to send to.
@type connection: L{coilmq.server.StompConnection}
@param frame: The frame to s... | [
"Sends",
"a",
"frame",
"to",
"a",
"specific",
"subscriber",
"connection",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/queue.py#L350-L376 |
hozn/coilmq | coilmq/store/dbm.py | make_dbm | def make_dbm():
"""
Creates a DBM queue store, pulling config values from the CoilMQ configuration.
"""
try:
data_dir = config.get('coilmq', 'qstore.dbm.data_dir')
cp_ops = config.getint('coilmq', 'qstore.dbm.checkpoint_operations')
cp_timeout = config.getint('coilmq', 'qstore.db... | python | def make_dbm():
"""
Creates a DBM queue store, pulling config values from the CoilMQ configuration.
"""
try:
data_dir = config.get('coilmq', 'qstore.dbm.data_dir')
cp_ops = config.getint('coilmq', 'qstore.dbm.checkpoint_operations')
cp_timeout = config.getint('coilmq', 'qstore.db... | [
"def",
"make_dbm",
"(",
")",
":",
"try",
":",
"data_dir",
"=",
"config",
".",
"get",
"(",
"'coilmq'",
",",
"'qstore.dbm.data_dir'",
")",
"cp_ops",
"=",
"config",
".",
"getint",
"(",
"'coilmq'",
",",
"'qstore.dbm.checkpoint_operations'",
")",
"cp_timeout",
"=",... | Creates a DBM queue store, pulling config values from the CoilMQ configuration. | [
"Creates",
"a",
"DBM",
"queue",
"store",
"pulling",
"config",
"values",
"from",
"the",
"CoilMQ",
"configuration",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/store/dbm.py#L47-L66 |
hozn/coilmq | coilmq/store/dbm.py | DbmQueue.enqueue | def enqueue(self, destination, frame):
"""
Store message (frame) for specified destinationination.
@param destination: The destinationination queue name for this message (frame).
@type destination: C{str}
@param frame: The message (frame) to send to specified destinationination... | python | def enqueue(self, destination, frame):
"""
Store message (frame) for specified destinationination.
@param destination: The destinationination queue name for this message (frame).
@type destination: C{str}
@param frame: The message (frame) to send to specified destinationination... | [
"def",
"enqueue",
"(",
"self",
",",
"destination",
",",
"frame",
")",
":",
"message_id",
"=",
"frame",
".",
"headers",
".",
"get",
"(",
"'message-id'",
")",
"if",
"not",
"message_id",
":",
"raise",
"ValueError",
"(",
"\"Cannot queue a frame without message-id se... | Store message (frame) for specified destinationination.
@param destination: The destinationination queue name for this message (frame).
@type destination: C{str}
@param frame: The message (frame) to send to specified destinationination.
@type frame: C{stompclient.frame.Frame} | [
"Store",
"message",
"(",
"frame",
")",
"for",
"specified",
"destinationination",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/store/dbm.py#L146-L172 |
hozn/coilmq | coilmq/store/dbm.py | DbmQueue.dequeue | def dequeue(self, destination):
"""
Removes and returns an item from the queue (or C{None} if no items in queue).
@param destination: The queue name (destinationination).
@type destination: C{str}
@return: The first frame in the specified queue, or C{None} if there are none.
... | python | def dequeue(self, destination):
"""
Removes and returns an item from the queue (or C{None} if no items in queue).
@param destination: The queue name (destinationination).
@type destination: C{str}
@return: The first frame in the specified queue, or C{None} if there are none.
... | [
"def",
"dequeue",
"(",
"self",
",",
"destination",
")",
":",
"if",
"not",
"self",
".",
"has_frames",
"(",
"destination",
")",
":",
"return",
"None",
"message_id",
"=",
"self",
".",
"queue_metadata",
"[",
"destination",
"]",
"[",
"'frames'",
"]",
".",
"po... | Removes and returns an item from the queue (or C{None} if no items in queue).
@param destination: The queue name (destinationination).
@type destination: C{str}
@return: The first frame in the specified queue, or C{None} if there are none.
@rtype: C{stompclient.frame.Frame} | [
"Removes",
"and",
"returns",
"an",
"item",
"from",
"the",
"queue",
"(",
"or",
"C",
"{",
"None",
"}",
"if",
"no",
"items",
"in",
"queue",
")",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/store/dbm.py#L175-L197 |
hozn/coilmq | coilmq/store/dbm.py | DbmQueue.has_frames | def has_frames(self, destination):
"""
Whether specified queue has any frames.
@param destination: The queue name (destinationination).
@type destination: C{str}
@return: Whether there are any frames in the specified queue.
@rtype: C{bool}
"""
return (de... | python | def has_frames(self, destination):
"""
Whether specified queue has any frames.
@param destination: The queue name (destinationination).
@type destination: C{str}
@return: Whether there are any frames in the specified queue.
@rtype: C{bool}
"""
return (de... | [
"def",
"has_frames",
"(",
"self",
",",
"destination",
")",
":",
"return",
"(",
"destination",
"in",
"self",
".",
"queue_metadata",
")",
"and",
"bool",
"(",
"self",
".",
"queue_metadata",
"[",
"destination",
"]",
"[",
"'frames'",
"]",
")"
] | Whether specified queue has any frames.
@param destination: The queue name (destinationination).
@type destination: C{str}
@return: Whether there are any frames in the specified queue.
@rtype: C{bool} | [
"Whether",
"specified",
"queue",
"has",
"any",
"frames",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/store/dbm.py#L200-L210 |
hozn/coilmq | coilmq/store/dbm.py | DbmQueue.size | def size(self, destination):
"""
Size of the queue for specified destination.
@param destination: The queue destination (e.g. /queue/foo)
@type destination: C{str}
@return: The number of frames in specified queue.
@rtype: C{int}
"""
if not destination in... | python | def size(self, destination):
"""
Size of the queue for specified destination.
@param destination: The queue destination (e.g. /queue/foo)
@type destination: C{str}
@return: The number of frames in specified queue.
@rtype: C{int}
"""
if not destination in... | [
"def",
"size",
"(",
"self",
",",
"destination",
")",
":",
"if",
"not",
"destination",
"in",
"self",
".",
"queue_metadata",
":",
"return",
"0",
"else",
":",
"return",
"len",
"(",
"self",
".",
"queue_metadata",
"[",
"destination",
"]",
"[",
"'frames'",
"]"... | Size of the queue for specified destination.
@param destination: The queue destination (e.g. /queue/foo)
@type destination: C{str}
@return: The number of frames in specified queue.
@rtype: C{int} | [
"Size",
"of",
"the",
"queue",
"for",
"specified",
"destination",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/store/dbm.py#L213-L226 |
hozn/coilmq | coilmq/store/dbm.py | DbmQueue._sync | def _sync(self):
"""
Synchronize the cached data with the underlyind database.
Uses an internal transaction counter and compares to the checkpoint_operations
and checkpoint_timeout paramters to determine whether to persist the memory store.
In this implementation, this method w... | python | def _sync(self):
"""
Synchronize the cached data with the underlyind database.
Uses an internal transaction counter and compares to the checkpoint_operations
and checkpoint_timeout paramters to determine whether to persist the memory store.
In this implementation, this method w... | [
"def",
"_sync",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"_opcount",
">",
"self",
".",
"checkpoint_operations",
"or",
"datetime",
".",
"now",
"(",
")",
">",
"self",
".",
"_last_sync",
"+",
"self",
".",
"checkpoint_timeout",
")",
":",
"self",
".",... | Synchronize the cached data with the underlyind database.
Uses an internal transaction counter and compares to the checkpoint_operations
and checkpoint_timeout paramters to determine whether to persist the memory store.
In this implementation, this method wraps calls to C{shelve.Shelf#sync}. | [
"Synchronize",
"the",
"cached",
"data",
"with",
"the",
"underlyind",
"database",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/store/dbm.py#L246-L262 |
polyaxon/rhea | rhea/reader.py | read | def read(config_values):
"""Reads an ordered list of configuration values and deep merge the values in reverse order."""
if not config_values:
raise RheaError('Cannot read config_value: `{}`'.format(config_values))
config_values = to_list(config_values)
config = {}
for config_value in conf... | python | def read(config_values):
"""Reads an ordered list of configuration values and deep merge the values in reverse order."""
if not config_values:
raise RheaError('Cannot read config_value: `{}`'.format(config_values))
config_values = to_list(config_values)
config = {}
for config_value in conf... | [
"def",
"read",
"(",
"config_values",
")",
":",
"if",
"not",
"config_values",
":",
"raise",
"RheaError",
"(",
"'Cannot read config_value: `{}`'",
".",
"format",
"(",
"config_values",
")",
")",
"config_values",
"=",
"to_list",
"(",
"config_values",
")",
"config",
... | Reads an ordered list of configuration values and deep merge the values in reverse order. | [
"Reads",
"an",
"ordered",
"list",
"of",
"configuration",
"values",
"and",
"deep",
"merge",
"the",
"values",
"in",
"reverse",
"order",
"."
] | train | https://github.com/polyaxon/rhea/blob/f47b59777cd996d834a0497a1ab442541aaa8a62/rhea/reader.py#L11-L28 |
hozn/coilmq | coilmq/util/frames.py | parse_headers | def parse_headers(buff):
"""
Parses buffer and returns command and headers as strings
"""
preamble_lines = list(map(
lambda x: six.u(x).decode(),
iter(lambda: buff.readline().strip(), b''))
)
if not preamble_lines:
raise EmptyBuffer()
return preamble_lines[0], Ordered... | python | def parse_headers(buff):
"""
Parses buffer and returns command and headers as strings
"""
preamble_lines = list(map(
lambda x: six.u(x).decode(),
iter(lambda: buff.readline().strip(), b''))
)
if not preamble_lines:
raise EmptyBuffer()
return preamble_lines[0], Ordered... | [
"def",
"parse_headers",
"(",
"buff",
")",
":",
"preamble_lines",
"=",
"list",
"(",
"map",
"(",
"lambda",
"x",
":",
"six",
".",
"u",
"(",
"x",
")",
".",
"decode",
"(",
")",
",",
"iter",
"(",
"lambda",
":",
"buff",
".",
"readline",
"(",
")",
".",
... | Parses buffer and returns command and headers as strings | [
"Parses",
"buffer",
"and",
"returns",
"command",
"and",
"headers",
"as",
"strings"
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/util/frames.py#L41-L51 |
hozn/coilmq | coilmq/util/frames.py | Frame.pack | def pack(self):
"""
Create a string representation from object state.
@return: The string (bytes) for this stomp frame.
@rtype: C{str}
"""
self.headers.setdefault('content-length', len(self.body))
# Convert and append any existing headers to a string as the
... | python | def pack(self):
"""
Create a string representation from object state.
@return: The string (bytes) for this stomp frame.
@rtype: C{str}
"""
self.headers.setdefault('content-length', len(self.body))
# Convert and append any existing headers to a string as the
... | [
"def",
"pack",
"(",
"self",
")",
":",
"self",
".",
"headers",
".",
"setdefault",
"(",
"'content-length'",
",",
"len",
"(",
"self",
".",
"body",
")",
")",
"# Convert and append any existing headers to a string as the",
"# protocol describes.",
"headerparts",
"=",
"("... | Create a string representation from object state.
@return: The string (bytes) for this stomp frame.
@rtype: C{str} | [
"Create",
"a",
"string",
"representation",
"from",
"object",
"state",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/util/frames.py#L113-L129 |
hozn/coilmq | coilmq/util/frames.py | FrameBuffer.extract_frame | def extract_frame(self):
"""
Pulls one complete frame off the buffer and returns it.
If there is no complete message in the buffer, returns None.
Note that the buffer can contain more than once message. You
should therefore call this method in a loop (or use iterator
fu... | python | def extract_frame(self):
"""
Pulls one complete frame off the buffer and returns it.
If there is no complete message in the buffer, returns None.
Note that the buffer can contain more than once message. You
should therefore call this method in a loop (or use iterator
fu... | [
"def",
"extract_frame",
"(",
"self",
")",
":",
"# (mbytes, hbytes) = self._find_message_bytes(self.buffer)",
"# if not mbytes:",
"# return None",
"#",
"# msgdata = self.buffer[:mbytes]",
"# self.buffer = self.buffer[mbytes:]",
"# hdata = msgdata[:hbytes]",
"# # Strip off any leading wh... | Pulls one complete frame off the buffer and returns it.
If there is no complete message in the buffer, returns None.
Note that the buffer can contain more than once message. You
should therefore call this method in a loop (or use iterator
functionality exposed by class) until None retu... | [
"Pulls",
"one",
"complete",
"frame",
"off",
"the",
"buffer",
"and",
"returns",
"it",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/util/frames.py#L292-L339 |
hozn/coilmq | coilmq/scheduler.py | FavorReliableSubscriberScheduler.choice | def choice(self, subscribers, message):
"""
Choose a random connection, favoring those that are reliable from
subscriber pool to deliver specified message.
@param subscribers: Collection of subscribed connections to destination.
@type subscribers: C{list} of L{coilmq.server.Sto... | python | def choice(self, subscribers, message):
"""
Choose a random connection, favoring those that are reliable from
subscriber pool to deliver specified message.
@param subscribers: Collection of subscribed connections to destination.
@type subscribers: C{list} of L{coilmq.server.Sto... | [
"def",
"choice",
"(",
"self",
",",
"subscribers",
",",
"message",
")",
":",
"if",
"not",
"subscribers",
":",
"return",
"None",
"reliable_subscribers",
"=",
"[",
"s",
"for",
"s",
"in",
"subscribers",
"if",
"s",
".",
"reliable_subscriber",
"]",
"if",
"reliab... | Choose a random connection, favoring those that are reliable from
subscriber pool to deliver specified message.
@param subscribers: Collection of subscribed connections to destination.
@type subscribers: C{list} of L{coilmq.server.StompConnection}
@param message: The message to be del... | [
"Choose",
"a",
"random",
"connection",
"favoring",
"those",
"that",
"are",
"reliable",
"from",
"subscriber",
"pool",
"to",
"deliver",
"specified",
"message",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/scheduler.py#L96-L117 |
hozn/coilmq | coilmq/scheduler.py | RandomQueueScheduler.choice | def choice(self, queues, connection):
"""
Chooses a random queue for messages to specified connection.
@param queues: A C{dict} mapping queue name to queues (sets of frames) to which
specified connection is subscribed.
@type queues: C{dict} of C{str} to C{set} ... | python | def choice(self, queues, connection):
"""
Chooses a random queue for messages to specified connection.
@param queues: A C{dict} mapping queue name to queues (sets of frames) to which
specified connection is subscribed.
@type queues: C{dict} of C{str} to C{set} ... | [
"def",
"choice",
"(",
"self",
",",
"queues",
",",
"connection",
")",
":",
"if",
"not",
"queues",
":",
"return",
"None",
"return",
"random",
".",
"choice",
"(",
"list",
"(",
"queues",
".",
"keys",
"(",
")",
")",
")"
] | Chooses a random queue for messages to specified connection.
@param queues: A C{dict} mapping queue name to queues (sets of frames) to which
specified connection is subscribed.
@type queues: C{dict} of C{str} to C{set} of L{stompclient.frame.Frame}
@param connection: ... | [
"Chooses",
"a",
"random",
"queue",
"for",
"messages",
"to",
"specified",
"connection",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/scheduler.py#L125-L141 |
polyaxon/rhea | rhea/manager.py | Rhea.get_int | def get_int(self,
key,
is_list=False,
is_optional=False,
is_secret=False,
is_local=False,
default=None,
options=None):
"""
Get a the value corresponding to the key and converts it to `int`/`li... | python | def get_int(self,
key,
is_list=False,
is_optional=False,
is_secret=False,
is_local=False,
default=None,
options=None):
"""
Get a the value corresponding to the key and converts it to `int`/`li... | [
"def",
"get_int",
"(",
"self",
",",
"key",
",",
"is_list",
"=",
"False",
",",
"is_optional",
"=",
"False",
",",
"is_secret",
"=",
"False",
",",
"is_local",
"=",
"False",
",",
"default",
"=",
"None",
",",
"options",
"=",
"None",
")",
":",
"if",
"is_li... | Get a the value corresponding to the key and converts it to `int`/`list(int)`.
Args:
key: the dict key.
is_list: If this is one element or a list of elements.
is_optional: To raise an error if key was not found.
is_secret: If the key is a secret.
is_l... | [
"Get",
"a",
"the",
"value",
"corresponding",
"to",
"the",
"key",
"and",
"converts",
"it",
"to",
"int",
"/",
"list",
"(",
"int",
")",
"."
] | train | https://github.com/polyaxon/rhea/blob/f47b59777cd996d834a0497a1ab442541aaa8a62/rhea/manager.py#L63-L103 |
polyaxon/rhea | rhea/manager.py | Rhea.get_float | def get_float(self,
key,
is_list=False,
is_optional=False,
is_secret=False,
is_local=False,
default=None,
options=None):
"""
Get a the value corresponding to the key and converts... | python | def get_float(self,
key,
is_list=False,
is_optional=False,
is_secret=False,
is_local=False,
default=None,
options=None):
"""
Get a the value corresponding to the key and converts... | [
"def",
"get_float",
"(",
"self",
",",
"key",
",",
"is_list",
"=",
"False",
",",
"is_optional",
"=",
"False",
",",
"is_secret",
"=",
"False",
",",
"is_local",
"=",
"False",
",",
"default",
"=",
"None",
",",
"options",
"=",
"None",
")",
":",
"if",
"is_... | Get a the value corresponding to the key and converts it to `float`/`list(float)`.
Args:
key: the dict key.
is_list: If this is one element or a list of elements.
is_optional: To raise an error if key was not found.
is_secret: If the key is a secret.
... | [
"Get",
"a",
"the",
"value",
"corresponding",
"to",
"the",
"key",
"and",
"converts",
"it",
"to",
"float",
"/",
"list",
"(",
"float",
")",
"."
] | train | https://github.com/polyaxon/rhea/blob/f47b59777cd996d834a0497a1ab442541aaa8a62/rhea/manager.py#L105-L145 |
polyaxon/rhea | rhea/manager.py | Rhea.get_boolean | def get_boolean(self,
key,
is_list=False,
is_optional=False,
is_secret=False,
is_local=False,
default=None,
options=None):
"""
Get a the value corresponding to the ... | python | def get_boolean(self,
key,
is_list=False,
is_optional=False,
is_secret=False,
is_local=False,
default=None,
options=None):
"""
Get a the value corresponding to the ... | [
"def",
"get_boolean",
"(",
"self",
",",
"key",
",",
"is_list",
"=",
"False",
",",
"is_optional",
"=",
"False",
",",
"is_secret",
"=",
"False",
",",
"is_local",
"=",
"False",
",",
"default",
"=",
"None",
",",
"options",
"=",
"None",
")",
":",
"if",
"i... | Get a the value corresponding to the key and converts it to `bool`/`list(str)`.
Args:
key: the dict key.
is_list: If this is one element or a list of elements.
is_optional: To raise an error if key was not found.
is_secret: If the key is a secret.
is_... | [
"Get",
"a",
"the",
"value",
"corresponding",
"to",
"the",
"key",
"and",
"converts",
"it",
"to",
"bool",
"/",
"list",
"(",
"str",
")",
"."
] | train | https://github.com/polyaxon/rhea/blob/f47b59777cd996d834a0497a1ab442541aaa8a62/rhea/manager.py#L147-L187 |
polyaxon/rhea | rhea/manager.py | Rhea.get_string | def get_string(self,
key,
is_list=False,
is_optional=False,
is_secret=False,
is_local=False,
default=None,
options=None):
"""
Get a the value corresponding to the key and ... | python | def get_string(self,
key,
is_list=False,
is_optional=False,
is_secret=False,
is_local=False,
default=None,
options=None):
"""
Get a the value corresponding to the key and ... | [
"def",
"get_string",
"(",
"self",
",",
"key",
",",
"is_list",
"=",
"False",
",",
"is_optional",
"=",
"False",
",",
"is_secret",
"=",
"False",
",",
"is_local",
"=",
"False",
",",
"default",
"=",
"None",
",",
"options",
"=",
"None",
")",
":",
"if",
"is... | Get a the value corresponding to the key and converts it to `str`/`list(str)`.
Args:
key: the dict key.
is_list: If this is one element or a list of elements.
is_optional: To raise an error if key was not found.
is_secret: If the key is a secret.
is_l... | [
"Get",
"a",
"the",
"value",
"corresponding",
"to",
"the",
"key",
"and",
"converts",
"it",
"to",
"str",
"/",
"list",
"(",
"str",
")",
"."
] | train | https://github.com/polyaxon/rhea/blob/f47b59777cd996d834a0497a1ab442541aaa8a62/rhea/manager.py#L189-L229 |
polyaxon/rhea | rhea/manager.py | Rhea.get_dict | def get_dict(self,
key,
is_list=False,
is_optional=False,
is_secret=False,
is_local=False,
default=None,
options=None):
"""
Get a the value corresponding to the key and converts it to `... | python | def get_dict(self,
key,
is_list=False,
is_optional=False,
is_secret=False,
is_local=False,
default=None,
options=None):
"""
Get a the value corresponding to the key and converts it to `... | [
"def",
"get_dict",
"(",
"self",
",",
"key",
",",
"is_list",
"=",
"False",
",",
"is_optional",
"=",
"False",
",",
"is_secret",
"=",
"False",
",",
"is_local",
"=",
"False",
",",
"default",
"=",
"None",
",",
"options",
"=",
"None",
")",
":",
"def",
"con... | Get a the value corresponding to the key and converts it to `dict`.
Args:
key: the dict key.
is_list: If this is one element or a list of elements.
is_optional: To raise an error if key was not found.
is_secret: If the key is a secret.
is_local: If th... | [
"Get",
"a",
"the",
"value",
"corresponding",
"to",
"the",
"key",
"and",
"converts",
"it",
"to",
"dict",
"."
] | train | https://github.com/polyaxon/rhea/blob/f47b59777cd996d834a0497a1ab442541aaa8a62/rhea/manager.py#L231-L285 |
polyaxon/rhea | rhea/manager.py | Rhea.get_dict_of_dicts | def get_dict_of_dicts(self,
key,
is_optional=False,
is_secret=False,
is_local=False,
default=None,
options=None):
"""
Get a the value corresponding ... | python | def get_dict_of_dicts(self,
key,
is_optional=False,
is_secret=False,
is_local=False,
default=None,
options=None):
"""
Get a the value corresponding ... | [
"def",
"get_dict_of_dicts",
"(",
"self",
",",
"key",
",",
"is_optional",
"=",
"False",
",",
"is_secret",
"=",
"False",
",",
"is_local",
"=",
"False",
",",
"default",
"=",
"None",
",",
"options",
"=",
"None",
")",
":",
"value",
"=",
"self",
".",
"get_di... | Get a the value corresponding to the key and converts it to `dict`.
Add an extra validation that all keys have a dict as values.
Args:
key: the dict key.
is_optional: To raise an error if key was not found.
is_secret: If the key is a secret.
is_local: If... | [
"Get",
"a",
"the",
"value",
"corresponding",
"to",
"the",
"key",
"and",
"converts",
"it",
"to",
"dict",
"."
] | train | https://github.com/polyaxon/rhea/blob/f47b59777cd996d834a0497a1ab442541aaa8a62/rhea/manager.py#L287-L327 |
polyaxon/rhea | rhea/manager.py | Rhea.get_uri | def get_uri(self,
key,
is_list=False,
is_optional=False,
is_secret=False,
is_local=False,
default=None,
options=None):
"""
Get a the value corresponding to the key and converts it to `UriSpec`... | python | def get_uri(self,
key,
is_list=False,
is_optional=False,
is_secret=False,
is_local=False,
default=None,
options=None):
"""
Get a the value corresponding to the key and converts it to `UriSpec`... | [
"def",
"get_uri",
"(",
"self",
",",
"key",
",",
"is_list",
"=",
"False",
",",
"is_optional",
"=",
"False",
",",
"is_secret",
"=",
"False",
",",
"is_local",
"=",
"False",
",",
"default",
"=",
"None",
",",
"options",
"=",
"None",
")",
":",
"if",
"is_li... | Get a the value corresponding to the key and converts it to `UriSpec`.
Args
key: the dict key.
is_list: If this is one element or a list of elements.
is_optional: To raise an error if key was not found.
is_secret: If the key is a secret.
is_local: If ... | [
"Get",
"a",
"the",
"value",
"corresponding",
"to",
"the",
"key",
"and",
"converts",
"it",
"to",
"UriSpec",
"."
] | train | https://github.com/polyaxon/rhea/blob/f47b59777cd996d834a0497a1ab442541aaa8a62/rhea/manager.py#L329-L369 |
polyaxon/rhea | rhea/manager.py | Rhea.get_auth | def get_auth(self,
key,
is_list=False,
is_optional=False,
is_secret=False,
is_local=False,
default=None,
options=None):
"""
Get a the value corresponding to the key and converts it to `... | python | def get_auth(self,
key,
is_list=False,
is_optional=False,
is_secret=False,
is_local=False,
default=None,
options=None):
"""
Get a the value corresponding to the key and converts it to `... | [
"def",
"get_auth",
"(",
"self",
",",
"key",
",",
"is_list",
"=",
"False",
",",
"is_optional",
"=",
"False",
",",
"is_secret",
"=",
"False",
",",
"is_local",
"=",
"False",
",",
"default",
"=",
"None",
",",
"options",
"=",
"None",
")",
":",
"if",
"is_l... | Get a the value corresponding to the key and converts it to `AuthSpec`.
Args
key: the dict key.
is_list: If this is one element or a list of elements.
is_optional: To raise an error if key was not found.
is_secret: If the key is a secret.
is_local: If... | [
"Get",
"a",
"the",
"value",
"corresponding",
"to",
"the",
"key",
"and",
"converts",
"it",
"to",
"AuthSpec",
"."
] | train | https://github.com/polyaxon/rhea/blob/f47b59777cd996d834a0497a1ab442541aaa8a62/rhea/manager.py#L371-L411 |
polyaxon/rhea | rhea/manager.py | Rhea.get_list | def get_list(self,
key,
is_optional=False,
is_secret=False,
is_local=False,
default=None,
options=None):
"""
Get a the value corresponding to the key and converts comma separated values to a list.
... | python | def get_list(self,
key,
is_optional=False,
is_secret=False,
is_local=False,
default=None,
options=None):
"""
Get a the value corresponding to the key and converts comma separated values to a list.
... | [
"def",
"get_list",
"(",
"self",
",",
"key",
",",
"is_optional",
"=",
"False",
",",
"is_secret",
"=",
"False",
",",
"is_local",
"=",
"False",
",",
"default",
"=",
"None",
",",
"options",
"=",
"None",
")",
":",
"def",
"parse_list",
"(",
"v",
")",
":",
... | Get a the value corresponding to the key and converts comma separated values to a list.
Args:
key: the dict key.
is_optional: To raise an error if key was not found.
is_secret: If the key is a secret.
is_local: If the key is a local to this service.
d... | [
"Get",
"a",
"the",
"value",
"corresponding",
"to",
"the",
"key",
"and",
"converts",
"comma",
"separated",
"values",
"to",
"a",
"list",
"."
] | train | https://github.com/polyaxon/rhea/blob/f47b59777cd996d834a0497a1ab442541aaa8a62/rhea/manager.py#L413-L451 |
polyaxon/rhea | rhea/manager.py | Rhea._get_typed_value | def _get_typed_value(self,
key,
target_type,
type_convert,
is_optional=False,
is_secret=False,
is_local=False,
default=None,
... | python | def _get_typed_value(self,
key,
target_type,
type_convert,
is_optional=False,
is_secret=False,
is_local=False,
default=None,
... | [
"def",
"_get_typed_value",
"(",
"self",
",",
"key",
",",
"target_type",
",",
"type_convert",
",",
"is_optional",
"=",
"False",
",",
"is_secret",
"=",
"False",
",",
"is_local",
"=",
"False",
",",
"default",
"=",
"None",
",",
"options",
"=",
"None",
")",
"... | Return the value corresponding to the key converted to the given type.
Args:
key: the dict key.
target_type: The type we expect the variable or key to be in.
type_convert: A lambda expression that converts the key to the desired type.
is_optional: To raise an err... | [
"Return",
"the",
"value",
"corresponding",
"to",
"the",
"key",
"converted",
"to",
"the",
"given",
"type",
"."
] | train | https://github.com/polyaxon/rhea/blob/f47b59777cd996d834a0497a1ab442541aaa8a62/rhea/manager.py#L482-L529 |
polyaxon/rhea | rhea/manager.py | Rhea._get_typed_list_value | def _get_typed_list_value(self,
key,
target_type,
type_convert,
is_optional=False,
is_secret=False,
is_local=False,
... | python | def _get_typed_list_value(self,
key,
target_type,
type_convert,
is_optional=False,
is_secret=False,
is_local=False,
... | [
"def",
"_get_typed_list_value",
"(",
"self",
",",
"key",
",",
"target_type",
",",
"type_convert",
",",
"is_optional",
"=",
"False",
",",
"is_secret",
"=",
"False",
",",
"is_local",
"=",
"False",
",",
"default",
"=",
"None",
",",
"options",
"=",
"None",
")"... | Return the value corresponding to the key converted first to list
than each element to the given type.
Args:
key: the dict key.
target_type: The type we expect the variable or key to be in.
type_convert: A lambda expression that converts the key to the desired type.
... | [
"Return",
"the",
"value",
"corresponding",
"to",
"the",
"key",
"converted",
"first",
"to",
"list",
"than",
"each",
"element",
"to",
"the",
"given",
"type",
"."
] | train | https://github.com/polyaxon/rhea/blob/f47b59777cd996d834a0497a1ab442541aaa8a62/rhea/manager.py#L531-L587 |
hozn/coilmq | coilmq/auth/simple.py | make_simple | def make_simple():
"""
Create a L{SimpleAuthenticator} instance using values read from coilmq configuration.
@return: The configured L{SimpleAuthenticator}
@rtype: L{SimpleAuthenticator}
@raise ConfigError: If there is a configuration error.
"""
authfile = config.get('coilmq', 'auth.simple.... | python | def make_simple():
"""
Create a L{SimpleAuthenticator} instance using values read from coilmq configuration.
@return: The configured L{SimpleAuthenticator}
@rtype: L{SimpleAuthenticator}
@raise ConfigError: If there is a configuration error.
"""
authfile = config.get('coilmq', 'auth.simple.... | [
"def",
"make_simple",
"(",
")",
":",
"authfile",
"=",
"config",
".",
"get",
"(",
"'coilmq'",
",",
"'auth.simple.file'",
")",
"if",
"not",
"authfile",
":",
"raise",
"ConfigError",
"(",
"'Missing configuration parameter: auth.simple.file'",
")",
"sa",
"=",
"SimpleAu... | Create a L{SimpleAuthenticator} instance using values read from coilmq configuration.
@return: The configured L{SimpleAuthenticator}
@rtype: L{SimpleAuthenticator}
@raise ConfigError: If there is a configuration error. | [
"Create",
"a",
"L",
"{",
"SimpleAuthenticator",
"}",
"instance",
"using",
"values",
"read",
"from",
"coilmq",
"configuration",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/auth/simple.py#L29-L42 |
hozn/coilmq | coilmq/auth/simple.py | SimpleAuthenticator.from_configfile | def from_configfile(self, configfile):
"""
Initialize the authentication store from a "config"-style file.
Auth "config" file is parsed with C{ConfigParser.RawConfigParser} and must contain
an [auth] section which contains the usernames (keys) and passwords (values).
Example au... | python | def from_configfile(self, configfile):
"""
Initialize the authentication store from a "config"-style file.
Auth "config" file is parsed with C{ConfigParser.RawConfigParser} and must contain
an [auth] section which contains the usernames (keys) and passwords (values).
Example au... | [
"def",
"from_configfile",
"(",
"self",
",",
"configfile",
")",
":",
"cfg",
"=",
"ConfigParser",
"(",
")",
"if",
"hasattr",
"(",
"configfile",
",",
"'read'",
")",
":",
"cfg",
".",
"read_file",
"(",
"configfile",
")",
"else",
":",
"filesread",
"=",
"cfg",
... | Initialize the authentication store from a "config"-style file.
Auth "config" file is parsed with C{ConfigParser.RawConfigParser} and must contain
an [auth] section which contains the usernames (keys) and passwords (values).
Example auth file::
[auth]
someuser = somepa... | [
"Initialize",
"the",
"authentication",
"store",
"from",
"a",
"config",
"-",
"style",
"file",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/auth/simple.py#L64-L92 |
hozn/coilmq | coilmq/auth/simple.py | SimpleAuthenticator.authenticate | def authenticate(self, login, passcode):
"""
Authenticate the login and passcode.
@return: Whether provided login and password match values in store.
@rtype: C{bool}
"""
return login in self.store and self.store[login] == passcode | python | def authenticate(self, login, passcode):
"""
Authenticate the login and passcode.
@return: Whether provided login and password match values in store.
@rtype: C{bool}
"""
return login in self.store and self.store[login] == passcode | [
"def",
"authenticate",
"(",
"self",
",",
"login",
",",
"passcode",
")",
":",
"return",
"login",
"in",
"self",
".",
"store",
"and",
"self",
".",
"store",
"[",
"login",
"]",
"==",
"passcode"
] | Authenticate the login and passcode.
@return: Whether provided login and password match values in store.
@rtype: C{bool} | [
"Authenticate",
"the",
"login",
"and",
"passcode",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/auth/simple.py#L94-L101 |
hozn/coilmq | coilmq/protocol/__init__.py | STOMP10.process_frame | def process_frame(self, frame):
"""
Dispatches a received frame to the appropriate internal method.
@param frame: The frame that was received.
@type frame: C{stompclient.frame.Frame}
"""
cmd_method = frame.cmd.lower()
if not cmd_method in VALID_COMMANDS:
... | python | def process_frame(self, frame):
"""
Dispatches a received frame to the appropriate internal method.
@param frame: The frame that was received.
@type frame: C{stompclient.frame.Frame}
"""
cmd_method = frame.cmd.lower()
if not cmd_method in VALID_COMMANDS:
... | [
"def",
"process_frame",
"(",
"self",
",",
"frame",
")",
":",
"cmd_method",
"=",
"frame",
".",
"cmd",
".",
"lower",
"(",
")",
"if",
"not",
"cmd_method",
"in",
"VALID_COMMANDS",
":",
"raise",
"ProtocolError",
"(",
"\"Invalid STOMP command: {}\"",
".",
"format",
... | Dispatches a received frame to the appropriate internal method.
@param frame: The frame that was received.
@type frame: C{stompclient.frame.Frame} | [
"Dispatches",
"a",
"received",
"frame",
"to",
"the",
"appropriate",
"internal",
"method",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/protocol/__init__.py#L81-L124 |
hozn/coilmq | coilmq/protocol/__init__.py | STOMP10.connect | def connect(self, frame, response=None):
"""
Handle CONNECT command: Establishes a new connection and checks auth (if applicable).
"""
self.engine.log.debug("CONNECT")
if self.engine.authenticator:
login = frame.headers.get('login')
passcode = frame.heade... | python | def connect(self, frame, response=None):
"""
Handle CONNECT command: Establishes a new connection and checks auth (if applicable).
"""
self.engine.log.debug("CONNECT")
if self.engine.authenticator:
login = frame.headers.get('login')
passcode = frame.heade... | [
"def",
"connect",
"(",
"self",
",",
"frame",
",",
"response",
"=",
"None",
")",
":",
"self",
".",
"engine",
".",
"log",
".",
"debug",
"(",
"\"CONNECT\"",
")",
"if",
"self",
".",
"engine",
".",
"authenticator",
":",
"login",
"=",
"frame",
".",
"header... | Handle CONNECT command: Establishes a new connection and checks auth (if applicable). | [
"Handle",
"CONNECT",
"command",
":",
"Establishes",
"a",
"new",
"connection",
"and",
"checks",
"auth",
"(",
"if",
"applicable",
")",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/protocol/__init__.py#L126-L145 |
hozn/coilmq | coilmq/protocol/__init__.py | STOMP10.send | def send(self, frame):
"""
Handle the SEND command: Delivers a message to a queue or topic (default).
"""
dest = frame.headers.get('destination')
if not dest:
raise ProtocolError('Missing destination for SEND command.')
if dest.startswith('/queue/'):
... | python | def send(self, frame):
"""
Handle the SEND command: Delivers a message to a queue or topic (default).
"""
dest = frame.headers.get('destination')
if not dest:
raise ProtocolError('Missing destination for SEND command.')
if dest.startswith('/queue/'):
... | [
"def",
"send",
"(",
"self",
",",
"frame",
")",
":",
"dest",
"=",
"frame",
".",
"headers",
".",
"get",
"(",
"'destination'",
")",
"if",
"not",
"dest",
":",
"raise",
"ProtocolError",
"(",
"'Missing destination for SEND command.'",
")",
"if",
"dest",
".",
"st... | Handle the SEND command: Delivers a message to a queue or topic (default). | [
"Handle",
"the",
"SEND",
"command",
":",
"Delivers",
"a",
"message",
"to",
"a",
"queue",
"or",
"topic",
"(",
"default",
")",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/protocol/__init__.py#L147-L158 |
hozn/coilmq | coilmq/protocol/__init__.py | STOMP10.subscribe | def subscribe(self, frame):
"""
Handle the SUBSCRIBE command: Adds this connection to destination.
"""
ack = frame.headers.get('ack')
reliable = ack and ack.lower() == 'client'
self.engine.connection.reliable_subscriber = reliable
dest = frame.headers.get('desti... | python | def subscribe(self, frame):
"""
Handle the SUBSCRIBE command: Adds this connection to destination.
"""
ack = frame.headers.get('ack')
reliable = ack and ack.lower() == 'client'
self.engine.connection.reliable_subscriber = reliable
dest = frame.headers.get('desti... | [
"def",
"subscribe",
"(",
"self",
",",
"frame",
")",
":",
"ack",
"=",
"frame",
".",
"headers",
".",
"get",
"(",
"'ack'",
")",
"reliable",
"=",
"ack",
"and",
"ack",
".",
"lower",
"(",
")",
"==",
"'client'",
"self",
".",
"engine",
".",
"connection",
"... | Handle the SUBSCRIBE command: Adds this connection to destination. | [
"Handle",
"the",
"SUBSCRIBE",
"command",
":",
"Adds",
"this",
"connection",
"to",
"destination",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/protocol/__init__.py#L160-L176 |
hozn/coilmq | coilmq/protocol/__init__.py | STOMP10.unsubscribe | def unsubscribe(self, frame):
"""
Handle the UNSUBSCRIBE command: Removes this connection from destination.
"""
dest = frame.headers.get('destination')
if not dest:
raise ProtocolError('Missing destination for UNSUBSCRIBE command.')
if dest.startswith('/queue... | python | def unsubscribe(self, frame):
"""
Handle the UNSUBSCRIBE command: Removes this connection from destination.
"""
dest = frame.headers.get('destination')
if not dest:
raise ProtocolError('Missing destination for UNSUBSCRIBE command.')
if dest.startswith('/queue... | [
"def",
"unsubscribe",
"(",
"self",
",",
"frame",
")",
":",
"dest",
"=",
"frame",
".",
"headers",
".",
"get",
"(",
"'destination'",
")",
"if",
"not",
"dest",
":",
"raise",
"ProtocolError",
"(",
"'Missing destination for UNSUBSCRIBE command.'",
")",
"if",
"dest"... | Handle the UNSUBSCRIBE command: Removes this connection from destination. | [
"Handle",
"the",
"UNSUBSCRIBE",
"command",
":",
"Removes",
"this",
"connection",
"from",
"destination",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/protocol/__init__.py#L178-L189 |
hozn/coilmq | coilmq/protocol/__init__.py | STOMP10.begin | def begin(self, frame):
"""
Handles BEGING command: Starts a new transaction.
"""
if not frame.transaction:
raise ProtocolError("Missing transaction for BEGIN command.")
self.engine.transactions[frame.transaction] = [] | python | def begin(self, frame):
"""
Handles BEGING command: Starts a new transaction.
"""
if not frame.transaction:
raise ProtocolError("Missing transaction for BEGIN command.")
self.engine.transactions[frame.transaction] = [] | [
"def",
"begin",
"(",
"self",
",",
"frame",
")",
":",
"if",
"not",
"frame",
".",
"transaction",
":",
"raise",
"ProtocolError",
"(",
"\"Missing transaction for BEGIN command.\"",
")",
"self",
".",
"engine",
".",
"transactions",
"[",
"frame",
".",
"transaction",
... | Handles BEGING command: Starts a new transaction. | [
"Handles",
"BEGING",
"command",
":",
"Starts",
"a",
"new",
"transaction",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/protocol/__init__.py#L191-L198 |
hozn/coilmq | coilmq/protocol/__init__.py | STOMP10.commit | def commit(self, frame):
"""
Handles COMMIT command: Commits specified transaction.
"""
if not frame.transaction:
raise ProtocolError("Missing transaction for COMMIT command.")
if not frame.transaction in self.engine.transactions:
raise ProtocolError("Inv... | python | def commit(self, frame):
"""
Handles COMMIT command: Commits specified transaction.
"""
if not frame.transaction:
raise ProtocolError("Missing transaction for COMMIT command.")
if not frame.transaction in self.engine.transactions:
raise ProtocolError("Inv... | [
"def",
"commit",
"(",
"self",
",",
"frame",
")",
":",
"if",
"not",
"frame",
".",
"transaction",
":",
"raise",
"ProtocolError",
"(",
"\"Missing transaction for COMMIT command.\"",
")",
"if",
"not",
"frame",
".",
"transaction",
"in",
"self",
".",
"engine",
".",
... | Handles COMMIT command: Commits specified transaction. | [
"Handles",
"COMMIT",
"command",
":",
"Commits",
"specified",
"transaction",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/protocol/__init__.py#L200-L216 |
hozn/coilmq | coilmq/protocol/__init__.py | STOMP10.abort | def abort(self, frame):
"""
Handles ABORT command: Rolls back specified transaction.
"""
if not frame.transaction:
raise ProtocolError("Missing transaction for ABORT command.")
if not frame.transaction in self.engine.transactions:
raise ProtocolError("Inv... | python | def abort(self, frame):
"""
Handles ABORT command: Rolls back specified transaction.
"""
if not frame.transaction:
raise ProtocolError("Missing transaction for ABORT command.")
if not frame.transaction in self.engine.transactions:
raise ProtocolError("Inv... | [
"def",
"abort",
"(",
"self",
",",
"frame",
")",
":",
"if",
"not",
"frame",
".",
"transaction",
":",
"raise",
"ProtocolError",
"(",
"\"Missing transaction for ABORT command.\"",
")",
"if",
"not",
"frame",
".",
"transaction",
"in",
"self",
".",
"engine",
".",
... | Handles ABORT command: Rolls back specified transaction. | [
"Handles",
"ABORT",
"command",
":",
"Rolls",
"back",
"specified",
"transaction",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/protocol/__init__.py#L218-L230 |
hozn/coilmq | coilmq/protocol/__init__.py | STOMP10.ack | def ack(self, frame):
"""
Handles the ACK command: Acknowledges receipt of a message.
"""
if not frame.message_id:
raise ProtocolError("No message-id specified for ACK command.")
self.engine.queue_manager.ack(self.engine.connection, frame) | python | def ack(self, frame):
"""
Handles the ACK command: Acknowledges receipt of a message.
"""
if not frame.message_id:
raise ProtocolError("No message-id specified for ACK command.")
self.engine.queue_manager.ack(self.engine.connection, frame) | [
"def",
"ack",
"(",
"self",
",",
"frame",
")",
":",
"if",
"not",
"frame",
".",
"message_id",
":",
"raise",
"ProtocolError",
"(",
"\"No message-id specified for ACK command.\"",
")",
"self",
".",
"engine",
".",
"queue_manager",
".",
"ack",
"(",
"self",
".",
"e... | Handles the ACK command: Acknowledges receipt of a message. | [
"Handles",
"the",
"ACK",
"command",
":",
"Acknowledges",
"receipt",
"of",
"a",
"message",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/protocol/__init__.py#L232-L238 |
hozn/coilmq | coilmq/protocol/__init__.py | STOMP10.disconnect | def disconnect(self, frame):
"""
Handles the DISCONNECT command: Unbinds the connection.
Clients are supposed to send this command, but in practice it should not be
relied upon.
"""
self.engine.log.debug("Disconnect")
self.engine.unbind() | python | def disconnect(self, frame):
"""
Handles the DISCONNECT command: Unbinds the connection.
Clients are supposed to send this command, but in practice it should not be
relied upon.
"""
self.engine.log.debug("Disconnect")
self.engine.unbind() | [
"def",
"disconnect",
"(",
"self",
",",
"frame",
")",
":",
"self",
".",
"engine",
".",
"log",
".",
"debug",
"(",
"\"Disconnect\"",
")",
"self",
".",
"engine",
".",
"unbind",
"(",
")"
] | Handles the DISCONNECT command: Unbinds the connection.
Clients are supposed to send this command, but in practice it should not be
relied upon. | [
"Handles",
"the",
"DISCONNECT",
"command",
":",
"Unbinds",
"the",
"connection",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/protocol/__init__.py#L240-L248 |
hozn/coilmq | coilmq/protocol/__init__.py | STOMP11.nack | def nack(self, frame):
"""
Handles the NACK command: Unacknowledges receipt of a message.
For now, this is just a placeholder to implement this version of the protocol
"""
if not frame.headers.get('message-id'):
raise ProtocolError("No message-id specified for NACK co... | python | def nack(self, frame):
"""
Handles the NACK command: Unacknowledges receipt of a message.
For now, this is just a placeholder to implement this version of the protocol
"""
if not frame.headers.get('message-id'):
raise ProtocolError("No message-id specified for NACK co... | [
"def",
"nack",
"(",
"self",
",",
"frame",
")",
":",
"if",
"not",
"frame",
".",
"headers",
".",
"get",
"(",
"'message-id'",
")",
":",
"raise",
"ProtocolError",
"(",
"\"No message-id specified for NACK command.\"",
")",
"if",
"not",
"frame",
".",
"headers",
".... | Handles the NACK command: Unacknowledges receipt of a message.
For now, this is just a placeholder to implement this version of the protocol | [
"Handles",
"the",
"NACK",
"command",
":",
"Unacknowledges",
"receipt",
"of",
"a",
"message",
".",
"For",
"now",
"this",
"is",
"just",
"a",
"placeholder",
"to",
"implement",
"this",
"version",
"of",
"the",
"protocol"
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/protocol/__init__.py#L299-L307 |
hozn/coilmq | coilmq/config/__init__.py | init_config | def init_config(config_file=None):
"""
Initialize the configuration from a config file.
The values in config_file will override those already loaded from the default
configuration file (defaults.cfg, in current package).
This method does not setup logging.
@param config_file: The path to a co... | python | def init_config(config_file=None):
"""
Initialize the configuration from a config file.
The values in config_file will override those already loaded from the default
configuration file (defaults.cfg, in current package).
This method does not setup logging.
@param config_file: The path to a co... | [
"def",
"init_config",
"(",
"config_file",
"=",
"None",
")",
":",
"global",
"config",
"if",
"config_file",
"and",
"os",
".",
"path",
".",
"exists",
"(",
"config_file",
")",
":",
"read",
"=",
"config",
".",
"read",
"(",
"[",
"config_file",
"]",
")",
"if"... | Initialize the configuration from a config file.
The values in config_file will override those already loaded from the default
configuration file (defaults.cfg, in current package).
This method does not setup logging.
@param config_file: The path to a configuration file.
@type config_file: C{str}... | [
"Initialize",
"the",
"configuration",
"from",
"a",
"config",
"file",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/config/__init__.py#L45-L66 |
hozn/coilmq | coilmq/config/__init__.py | init_logging | def init_logging(logfile=None, loglevel=logging.INFO, configfile=None):
"""
Configures the logging using either basic filename + loglevel or passed config file path.
This is performed separately from L{init_config()} in order to support the case where
logging should happen independent of (usu. *after*... | python | def init_logging(logfile=None, loglevel=logging.INFO, configfile=None):
"""
Configures the logging using either basic filename + loglevel or passed config file path.
This is performed separately from L{init_config()} in order to support the case where
logging should happen independent of (usu. *after*... | [
"def",
"init_logging",
"(",
"logfile",
"=",
"None",
",",
"loglevel",
"=",
"logging",
".",
"INFO",
",",
"configfile",
"=",
"None",
")",
":",
"# If a config file was specified, we will use that in place of the",
"# explicitly",
"use_configfile",
"=",
"False",
"if",
"con... | Configures the logging using either basic filename + loglevel or passed config file path.
This is performed separately from L{init_config()} in order to support the case where
logging should happen independent of (usu. *after*) other aspects of the configuration
initialization. For example, if logging ma... | [
"Configures",
"the",
"logging",
"using",
"either",
"basic",
"filename",
"+",
"loglevel",
"or",
"passed",
"config",
"file",
"path",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/config/__init__.py#L69-L110 |
hozn/coilmq | coilmq/config/__init__.py | resolve_name | def resolve_name(name):
"""
Resolve a dotted name to some object (usually class, module, or function).
Supported naming formats include:
1. path.to.module:method
2. path.to.module.ClassName
>>> resolve_name('coilmq.store.memory.MemoryQueue')
<class 'coilmq.store.memory.MemoryQueue'... | python | def resolve_name(name):
"""
Resolve a dotted name to some object (usually class, module, or function).
Supported naming formats include:
1. path.to.module:method
2. path.to.module.ClassName
>>> resolve_name('coilmq.store.memory.MemoryQueue')
<class 'coilmq.store.memory.MemoryQueue'... | [
"def",
"resolve_name",
"(",
"name",
")",
":",
"if",
"':'",
"in",
"name",
":",
"# Normalize foo.bar.baz:main to foo.bar.baz.main",
"# (since our logic below will handle that)",
"name",
"=",
"'%s.%s'",
"%",
"tuple",
"(",
"name",
".",
"split",
"(",
"':'",
")",
")",
"... | Resolve a dotted name to some object (usually class, module, or function).
Supported naming formats include:
1. path.to.module:method
2. path.to.module.ClassName
>>> resolve_name('coilmq.store.memory.MemoryQueue')
<class 'coilmq.store.memory.MemoryQueue'>
>>> t = resolve_name('coilmq.s... | [
"Resolve",
"a",
"dotted",
"name",
"to",
"some",
"object",
"(",
"usually",
"class",
"module",
"or",
"function",
")",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/config/__init__.py#L113-L152 |
hozn/coilmq | coilmq/server/socket_server.py | StompRequestHandler.handle | def handle(self):
"""
Handle a new socket connection.
"""
# self.request is the TCP socket connected to the client
try:
while not self.server._shutdown_request_event.is_set():
try:
data = self.request.recv(8192)
... | python | def handle(self):
"""
Handle a new socket connection.
"""
# self.request is the TCP socket connected to the client
try:
while not self.server._shutdown_request_event.is_set():
try:
data = self.request.recv(8192)
... | [
"def",
"handle",
"(",
"self",
")",
":",
"# self.request is the TCP socket connected to the client",
"try",
":",
"while",
"not",
"self",
".",
"server",
".",
"_shutdown_request_event",
".",
"is_set",
"(",
")",
":",
"try",
":",
"data",
"=",
"self",
".",
"request",
... | Handle a new socket connection. | [
"Handle",
"a",
"new",
"socket",
"connection",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/server/socket_server.py#L66-L93 |
hozn/coilmq | coilmq/server/socket_server.py | StompRequestHandler.send_frame | def send_frame(self, frame):
""" Sends a frame to connected socket client.
@param frame: The frame to send.
@type frame: C{stompclient.frame.Frame}
"""
packed = frame.pack()
if self.debug: # pragma: no cover
self.log.debug("SEND: %r" % packed)
self.r... | python | def send_frame(self, frame):
""" Sends a frame to connected socket client.
@param frame: The frame to send.
@type frame: C{stompclient.frame.Frame}
"""
packed = frame.pack()
if self.debug: # pragma: no cover
self.log.debug("SEND: %r" % packed)
self.r... | [
"def",
"send_frame",
"(",
"self",
",",
"frame",
")",
":",
"packed",
"=",
"frame",
".",
"pack",
"(",
")",
"if",
"self",
".",
"debug",
":",
"# pragma: no cover",
"self",
".",
"log",
".",
"debug",
"(",
"\"SEND: %r\"",
"%",
"packed",
")",
"self",
".",
"r... | Sends a frame to connected socket client.
@param frame: The frame to send.
@type frame: C{stompclient.frame.Frame} | [
"Sends",
"a",
"frame",
"to",
"connected",
"socket",
"client",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/server/socket_server.py#L104-L113 |
hozn/coilmq | coilmq/server/socket_server.py | StompServer.server_close | def server_close(self):
"""
Closes the socket server and any associated resources.
"""
self.log.debug("Closing the socket server connection.")
TCPServer.server_close(self)
self.queue_manager.close()
self.topic_manager.close()
if hasattr(self.authenticator,... | python | def server_close(self):
"""
Closes the socket server and any associated resources.
"""
self.log.debug("Closing the socket server connection.")
TCPServer.server_close(self)
self.queue_manager.close()
self.topic_manager.close()
if hasattr(self.authenticator,... | [
"def",
"server_close",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Closing the socket server connection.\"",
")",
"TCPServer",
".",
"server_close",
"(",
"self",
")",
"self",
".",
"queue_manager",
".",
"close",
"(",
")",
"self",
".",
"top... | Closes the socket server and any associated resources. | [
"Closes",
"the",
"socket",
"server",
"and",
"any",
"associated",
"resources",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/server/socket_server.py#L161-L171 |
hozn/coilmq | coilmq/server/socket_server.py | StompServer.serve_forever | def serve_forever(self, poll_interval=0.5):
"""Handle one request at a time until shutdown.
Polls for shutdown every poll_interval seconds. Ignores
self.timeout. If you need to do periodic tasks, do them in
another thread.
"""
self._serving_event.set()
self._shut... | python | def serve_forever(self, poll_interval=0.5):
"""Handle one request at a time until shutdown.
Polls for shutdown every poll_interval seconds. Ignores
self.timeout. If you need to do periodic tasks, do them in
another thread.
"""
self._serving_event.set()
self._shut... | [
"def",
"serve_forever",
"(",
"self",
",",
"poll_interval",
"=",
"0.5",
")",
":",
"self",
".",
"_serving_event",
".",
"set",
"(",
")",
"self",
".",
"_shutdown_request_event",
".",
"clear",
"(",
")",
"TCPServer",
".",
"serve_forever",
"(",
"self",
",",
"poll... | Handle one request at a time until shutdown.
Polls for shutdown every poll_interval seconds. Ignores
self.timeout. If you need to do periodic tasks, do them in
another thread. | [
"Handle",
"one",
"request",
"at",
"a",
"time",
"until",
"shutdown",
"."
] | train | https://github.com/hozn/coilmq/blob/76b7fcf347144b3a5746423a228bed121dc564b5/coilmq/server/socket_server.py#L179-L188 |
caseman/noise | examples/animate_tex.py | create_3d_texture | def create_3d_texture(width, scale):
"""Create a grayscale 3d texture map with the specified
pixel width on each side and load it into the current texture
unit. The luminace of each texel is derived using the input
function as:
v = func(x * scale, y * scale, z * scale)
where x, y, z = 0 in the center texel of... | python | def create_3d_texture(width, scale):
"""Create a grayscale 3d texture map with the specified
pixel width on each side and load it into the current texture
unit. The luminace of each texel is derived using the input
function as:
v = func(x * scale, y * scale, z * scale)
where x, y, z = 0 in the center texel of... | [
"def",
"create_3d_texture",
"(",
"width",
",",
"scale",
")",
":",
"coords",
"=",
"range",
"(",
"width",
")",
"texel",
"=",
"(",
"ctypes",
".",
"c_byte",
"*",
"width",
"**",
"3",
")",
"(",
")",
"half",
"=",
"0",
"#width * scale / 2.0 ",
"for",
"z",
"i... | Create a grayscale 3d texture map with the specified
pixel width on each side and load it into the current texture
unit. The luminace of each texel is derived using the input
function as:
v = func(x * scale, y * scale, z * scale)
where x, y, z = 0 in the center texel of the texture.
func(x, y, z) is assumed t... | [
"Create",
"a",
"grayscale",
"3d",
"texture",
"map",
"with",
"the",
"specified",
"pixel",
"width",
"on",
"each",
"side",
"and",
"load",
"it",
"into",
"the",
"current",
"texture",
"unit",
".",
"The",
"luminace",
"of",
"each",
"texel",
"is",
"derived",
"using... | train | https://github.com/caseman/noise/blob/bb32991ab97e90882d0e46e578060717c5b90dc5/examples/animate_tex.py#L15-L39 |
caseman/noise | perlin.py | BaseNoise.randomize | def randomize(self, period=None):
"""Randomize the permutation table used by the noise functions. This
makes them generate a different noise pattern for the same inputs.
"""
if period is not None:
self.period = period
perm = list(range(self.period))
perm_right = self.period - 1
for i in list(perm):
... | python | def randomize(self, period=None):
"""Randomize the permutation table used by the noise functions. This
makes them generate a different noise pattern for the same inputs.
"""
if period is not None:
self.period = period
perm = list(range(self.period))
perm_right = self.period - 1
for i in list(perm):
... | [
"def",
"randomize",
"(",
"self",
",",
"period",
"=",
"None",
")",
":",
"if",
"period",
"is",
"not",
"None",
":",
"self",
".",
"period",
"=",
"period",
"perm",
"=",
"list",
"(",
"range",
"(",
"self",
".",
"period",
")",
")",
"perm_right",
"=",
"self... | Randomize the permutation table used by the noise functions. This
makes them generate a different noise pattern for the same inputs. | [
"Randomize",
"the",
"permutation",
"table",
"used",
"by",
"the",
"noise",
"functions",
".",
"This",
"makes",
"them",
"generate",
"a",
"different",
"noise",
"pattern",
"for",
"the",
"same",
"inputs",
"."
] | train | https://github.com/caseman/noise/blob/bb32991ab97e90882d0e46e578060717c5b90dc5/perlin.py#L113-L124 |
caseman/noise | perlin.py | SimplexNoise.noise2 | def noise2(self, x, y):
"""2D Perlin simplex noise.
Return a floating point value from -1 to 1 for the given x, y coordinate.
The same value is always returned for a given x, y pair unless the
permutation table changes (see randomize above).
"""
# Skew input space to determine which simplex (triangle)... | python | def noise2(self, x, y):
"""2D Perlin simplex noise.
Return a floating point value from -1 to 1 for the given x, y coordinate.
The same value is always returned for a given x, y pair unless the
permutation table changes (see randomize above).
"""
# Skew input space to determine which simplex (triangle)... | [
"def",
"noise2",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"# Skew input space to determine which simplex (triangle) we are in",
"s",
"=",
"(",
"x",
"+",
"y",
")",
"*",
"_F2",
"i",
"=",
"floor",
"(",
"x",
"+",
"s",
")",
"j",
"=",
"floor",
"(",
"y",
... | 2D Perlin simplex noise.
Return a floating point value from -1 to 1 for the given x, y coordinate.
The same value is always returned for a given x, y pair unless the
permutation table changes (see randomize above). | [
"2D",
"Perlin",
"simplex",
"noise",
".",
"Return",
"a",
"floating",
"point",
"value",
"from",
"-",
"1",
"to",
"1",
"for",
"the",
"given",
"x",
"y",
"coordinate",
".",
"The",
"same",
"value",
"is",
"always",
"returned",
"for",
"a",
"given",
"x",
"y",
... | train | https://github.com/caseman/noise/blob/bb32991ab97e90882d0e46e578060717c5b90dc5/perlin.py#L155-L206 |
caseman/noise | perlin.py | SimplexNoise.noise3 | def noise3(self, x, y, z):
"""3D Perlin simplex noise.
Return a floating point value from -1 to 1 for the given x, y, z coordinate.
The same value is always returned for a given x, y, z pair unless the
permutation table changes (see randomize above).
"""
# Skew the input space to determine which simple... | python | def noise3(self, x, y, z):
"""3D Perlin simplex noise.
Return a floating point value from -1 to 1 for the given x, y, z coordinate.
The same value is always returned for a given x, y, z pair unless the
permutation table changes (see randomize above).
"""
# Skew the input space to determine which simple... | [
"def",
"noise3",
"(",
"self",
",",
"x",
",",
"y",
",",
"z",
")",
":",
"# Skew the input space to determine which simplex cell we're in",
"s",
"=",
"(",
"x",
"+",
"y",
"+",
"z",
")",
"*",
"_F3",
"i",
"=",
"floor",
"(",
"x",
"+",
"s",
")",
"j",
"=",
... | 3D Perlin simplex noise.
Return a floating point value from -1 to 1 for the given x, y, z coordinate.
The same value is always returned for a given x, y, z pair unless the
permutation table changes (see randomize above). | [
"3D",
"Perlin",
"simplex",
"noise",
".",
"Return",
"a",
"floating",
"point",
"value",
"from",
"-",
"1",
"to",
"1",
"for",
"the",
"given",
"x",
"y",
"z",
"coordinate",
".",
"The",
"same",
"value",
"is",
"always",
"returned",
"for",
"a",
"given",
"x",
... | train | https://github.com/caseman/noise/blob/bb32991ab97e90882d0e46e578060717c5b90dc5/perlin.py#L208-L293 |
caseman/noise | perlin.py | TileableNoise.noise3 | def noise3(self, x, y, z, repeat, base=0.0):
"""Tileable 3D noise.
repeat specifies the integer interval in each dimension
when the noise pattern repeats.
base allows a different texture to be generated for
the same repeat interval.
"""
i = int(fmod(floor(x), repeat))
j = int(fmod(floor(y), repea... | python | def noise3(self, x, y, z, repeat, base=0.0):
"""Tileable 3D noise.
repeat specifies the integer interval in each dimension
when the noise pattern repeats.
base allows a different texture to be generated for
the same repeat interval.
"""
i = int(fmod(floor(x), repeat))
j = int(fmod(floor(y), repea... | [
"def",
"noise3",
"(",
"self",
",",
"x",
",",
"y",
",",
"z",
",",
"repeat",
",",
"base",
"=",
"0.0",
")",
":",
"i",
"=",
"int",
"(",
"fmod",
"(",
"floor",
"(",
"x",
")",
",",
"repeat",
")",
")",
"j",
"=",
"int",
"(",
"fmod",
"(",
"floor",
... | Tileable 3D noise.
repeat specifies the integer interval in each dimension
when the noise pattern repeats.
base allows a different texture to be generated for
the same repeat interval. | [
"Tileable",
"3D",
"noise",
".",
"repeat",
"specifies",
"the",
"integer",
"interval",
"in",
"each",
"dimension",
"when",
"the",
"noise",
"pattern",
"repeats",
".",
"base",
"allows",
"a",
"different",
"texture",
"to",
"be",
"generated",
"for",
"the",
"same",
"... | train | https://github.com/caseman/noise/blob/bb32991ab97e90882d0e46e578060717c5b90dc5/perlin.py#L311-L350 |
caseman/noise | shader_noise.py | ShaderNoiseTexture.load | def load(self):
"""Load the noise texture data into the current texture unit"""
glTexImage3D(GL_TEXTURE_3D, 0, GL_LUMINANCE16_ALPHA16,
self.width, self.width, self.width, 0, GL_LUMINANCE_ALPHA,
GL_UNSIGNED_SHORT, ctypes.byref(self.data)) | python | def load(self):
"""Load the noise texture data into the current texture unit"""
glTexImage3D(GL_TEXTURE_3D, 0, GL_LUMINANCE16_ALPHA16,
self.width, self.width, self.width, 0, GL_LUMINANCE_ALPHA,
GL_UNSIGNED_SHORT, ctypes.byref(self.data)) | [
"def",
"load",
"(",
"self",
")",
":",
"glTexImage3D",
"(",
"GL_TEXTURE_3D",
",",
"0",
",",
"GL_LUMINANCE16_ALPHA16",
",",
"self",
".",
"width",
",",
"self",
".",
"width",
",",
"self",
".",
"width",
",",
"0",
",",
"GL_LUMINANCE_ALPHA",
",",
"GL_UNSIGNED_SHO... | Load the noise texture data into the current texture unit | [
"Load",
"the",
"noise",
"texture",
"data",
"into",
"the",
"current",
"texture",
"unit"
] | train | https://github.com/caseman/noise/blob/bb32991ab97e90882d0e46e578060717c5b90dc5/shader_noise.py#L46-L50 |
caseman/noise | shader_noise.py | ShaderNoiseTexture.enable | def enable(self):
"""Convenience method to enable 3D texturing state so the texture may be used by the
ffpnoise shader function
"""
glEnable(GL_TEXTURE_3D)
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_REPEAT)
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_REPEAT)
glTexParameteri(GL_TEXTURE_... | python | def enable(self):
"""Convenience method to enable 3D texturing state so the texture may be used by the
ffpnoise shader function
"""
glEnable(GL_TEXTURE_3D)
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_REPEAT)
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_REPEAT)
glTexParameteri(GL_TEXTURE_... | [
"def",
"enable",
"(",
"self",
")",
":",
"glEnable",
"(",
"GL_TEXTURE_3D",
")",
"glTexParameteri",
"(",
"GL_TEXTURE_3D",
",",
"GL_TEXTURE_WRAP_S",
",",
"GL_REPEAT",
")",
"glTexParameteri",
"(",
"GL_TEXTURE_3D",
",",
"GL_TEXTURE_WRAP_T",
",",
"GL_REPEAT",
")",
"glTe... | Convenience method to enable 3D texturing state so the texture may be used by the
ffpnoise shader function | [
"Convenience",
"method",
"to",
"enable",
"3D",
"texturing",
"state",
"so",
"the",
"texture",
"may",
"be",
"used",
"by",
"the",
"ffpnoise",
"shader",
"function"
] | train | https://github.com/caseman/noise/blob/bb32991ab97e90882d0e46e578060717c5b90dc5/shader_noise.py#L52-L61 |
robotpy/pyfrc | lib/pyfrc/physics/visionsim.py | VisionSim.compute | def compute(self, now, x, y, angle):
"""
Call this when vision processing should be enabled
:param now: The value passed to ``update_sim``
:param x: Returned from physics_controller.get_position
:param y: Returned from physics_controller.get_pos... | python | def compute(self, now, x, y, angle):
"""
Call this when vision processing should be enabled
:param now: The value passed to ``update_sim``
:param x: Returned from physics_controller.get_position
:param y: Returned from physics_controller.get_pos... | [
"def",
"compute",
"(",
"self",
",",
"now",
",",
"x",
",",
"y",
",",
"angle",
")",
":",
"# Normalize angle to [-180,180]",
"output",
"=",
"[",
"]",
"angle",
"=",
"(",
"(",
"angle",
"+",
"math",
".",
"pi",
")",
"%",
"(",
"math",
".",
"pi",
"*",
"2"... | Call this when vision processing should be enabled
:param now: The value passed to ``update_sim``
:param x: Returned from physics_controller.get_position
:param y: Returned from physics_controller.get_position
:param angle: Returned from physics_control... | [
"Call",
"this",
"when",
"vision",
"processing",
"should",
"be",
"enabled",
":",
"param",
"now",
":",
"The",
"value",
"passed",
"to",
"update_sim",
":",
"param",
"x",
":",
"Returned",
"from",
"physics_controller",
".",
"get_position",
":",
"param",
"y",
":",
... | train | https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/physics/visionsim.py#L190-L236 |
partofthething/ace | ace/samples/supersmoother_friedman82.py | run_friedman82_super | def run_friedman82_super():
"""Run Friedman's test of fixed-span smoothers from Figure 2b."""
x, y = smoother_friedman82.build_sample_smoother_problem_friedman82()
plt.figure()
smooth = SuperSmoother()
smooth.specify_data_set(x, y, sort_data=True)
smooth.compute()
plt.plot(x, y, '.', label='... | python | def run_friedman82_super():
"""Run Friedman's test of fixed-span smoothers from Figure 2b."""
x, y = smoother_friedman82.build_sample_smoother_problem_friedman82()
plt.figure()
smooth = SuperSmoother()
smooth.specify_data_set(x, y, sort_data=True)
smooth.compute()
plt.plot(x, y, '.', label='... | [
"def",
"run_friedman82_super",
"(",
")",
":",
"x",
",",
"y",
"=",
"smoother_friedman82",
".",
"build_sample_smoother_problem_friedman82",
"(",
")",
"plt",
".",
"figure",
"(",
")",
"smooth",
"=",
"SuperSmoother",
"(",
")",
"smooth",
".",
"specify_data_set",
"(",
... | Run Friedman's test of fixed-span smoothers from Figure 2b. | [
"Run",
"Friedman",
"s",
"test",
"of",
"fixed",
"-",
"span",
"smoothers",
"from",
"Figure",
"2b",
"."
] | train | https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/samples/supersmoother_friedman82.py#L8-L24 |
openstack/monasca-common | monasca_common/expression_parser/alarm_expr_parser.py | main | def main():
"""Used for development and testing."""
expr_list = [
"max(-_.千幸福的笑脸{घोड़ा=馬, "
"dn2=dv2,千幸福的笑脸घ=千幸福的笑脸घ}) gte 100 "
"times 3 && "
"(min(ເຮືອນ{dn3=dv3,家=дом}) < 10 or sum(biz{dn5=dv5}) >99 and "
"count(fizzle) lt 0or count(baz) > 1)".decode('utf8'),
... | python | def main():
"""Used for development and testing."""
expr_list = [
"max(-_.千幸福的笑脸{घोड़ा=馬, "
"dn2=dv2,千幸福的笑脸घ=千幸福的笑脸घ}) gte 100 "
"times 3 && "
"(min(ເຮືອນ{dn3=dv3,家=дом}) < 10 or sum(biz{dn5=dv5}) >99 and "
"count(fizzle) lt 0or count(baz) > 1)".decode('utf8'),
... | [
"def",
"main",
"(",
")",
":",
"expr_list",
"=",
"[",
"\"max(-_.千幸福的笑脸{घोड़ा=馬, \"",
"\"dn2=dv2,千幸福的笑脸घ=千幸福的笑脸घ}) gte 100 \"",
"\"times 3 && \"",
"\"(min(ເຮືອນ{dn3=dv3,家=дом}) < 10 or sum(biz{dn5=dv5}) >99 and \"",
"\"count(fizzle) lt 0or count(baz) > 1)\"",
".",
"decode",
"(",
"'utf... | Used for development and testing. | [
"Used",
"for",
"development",
"and",
"testing",
"."
] | train | https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/expression_parser/alarm_expr_parser.py#L321-L375 |
openstack/monasca-common | monasca_common/expression_parser/alarm_expr_parser.py | SubExpr.fmtd_sub_expr_str | def fmtd_sub_expr_str(self):
"""Get the entire sub expressions as a string with spaces."""
result = u"{}({}".format(self.normalized_func,
self._metric_name)
if self._dimensions is not None:
result += "{" + self.dimensions_str + "}"
if self._... | python | def fmtd_sub_expr_str(self):
"""Get the entire sub expressions as a string with spaces."""
result = u"{}({}".format(self.normalized_func,
self._metric_name)
if self._dimensions is not None:
result += "{" + self.dimensions_str + "}"
if self._... | [
"def",
"fmtd_sub_expr_str",
"(",
"self",
")",
":",
"result",
"=",
"u\"{}({}\"",
".",
"format",
"(",
"self",
".",
"normalized_func",
",",
"self",
".",
"_metric_name",
")",
"if",
"self",
".",
"_dimensions",
"is",
"not",
"None",
":",
"result",
"+=",
"\"{\"",
... | Get the entire sub expressions as a string with spaces. | [
"Get",
"the",
"entire",
"sub",
"expressions",
"as",
"a",
"string",
"with",
"spaces",
"."
] | train | https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/expression_parser/alarm_expr_parser.py#L55-L74 |
openstack/monasca-common | monasca_common/expression_parser/alarm_expr_parser.py | SubExpr.normalized_operator | def normalized_operator(self):
"""Get the operator as one of LT, GT, LTE, or GTE."""
if self._operator.lower() == "lt" or self._operator == "<":
return u"LT"
elif self._operator.lower() == "gt" or self._operator == ">":
return u"GT"
elif self._operator.lower() == ... | python | def normalized_operator(self):
"""Get the operator as one of LT, GT, LTE, or GTE."""
if self._operator.lower() == "lt" or self._operator == "<":
return u"LT"
elif self._operator.lower() == "gt" or self._operator == ">":
return u"GT"
elif self._operator.lower() == ... | [
"def",
"normalized_operator",
"(",
"self",
")",
":",
"if",
"self",
".",
"_operator",
".",
"lower",
"(",
")",
"==",
"\"lt\"",
"or",
"self",
".",
"_operator",
"==",
"\"<\"",
":",
"return",
"u\"LT\"",
"elif",
"self",
".",
"_operator",
".",
"lower",
"(",
"... | Get the operator as one of LT, GT, LTE, or GTE. | [
"Get",
"the",
"operator",
"as",
"one",
"of",
"LT",
"GT",
"LTE",
"or",
"GTE",
"."
] | train | https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/expression_parser/alarm_expr_parser.py#L150-L159 |
robotpy/pyfrc | lib/pyfrc/physics/tankmodel.py | MotorModel.compute | def compute(self, motor_pct: float, tm_diff: float) -> float:
"""
:param motor_pct: Percentage of power for motor in range [1..-1]
:param tm_diff: Time elapsed since this function was last called
:returns: velocity
"""
appliedVoltage = self._no... | python | def compute(self, motor_pct: float, tm_diff: float) -> float:
"""
:param motor_pct: Percentage of power for motor in range [1..-1]
:param tm_diff: Time elapsed since this function was last called
:returns: velocity
"""
appliedVoltage = self._no... | [
"def",
"compute",
"(",
"self",
",",
"motor_pct",
":",
"float",
",",
"tm_diff",
":",
"float",
")",
"->",
"float",
":",
"appliedVoltage",
"=",
"self",
".",
"_nominalVoltage",
"*",
"motor_pct",
"appliedVoltage",
"=",
"math",
".",
"copysign",
"(",
"max",
"(",
... | :param motor_pct: Percentage of power for motor in range [1..-1]
:param tm_diff: Time elapsed since this function was last called
:returns: velocity | [
":",
"param",
"motor_pct",
":",
"Percentage",
"of",
"power",
"for",
"motor",
"in",
"range",
"[",
"1",
"..",
"-",
"1",
"]",
":",
"param",
"tm_diff",
":",
"Time",
"elapsed",
"since",
"this",
"function",
"was",
"last",
"called",
":",
"returns",
":",
"velo... | train | https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/physics/tankmodel.py#L77-L107 |
robotpy/pyfrc | lib/pyfrc/physics/tankmodel.py | TankModel.theory | def theory(
cls,
motor_config: MotorModelConfig,
robot_mass: units.Quantity,
gearing: float,
nmotors: int = 1,
x_wheelbase: units.Quantity = _kitbot_wheelbase,
robot_width: units.Quantity = _kitbot_width,
robot_length: units.Quantity = _kitbot_length,
... | python | def theory(
cls,
motor_config: MotorModelConfig,
robot_mass: units.Quantity,
gearing: float,
nmotors: int = 1,
x_wheelbase: units.Quantity = _kitbot_wheelbase,
robot_width: units.Quantity = _kitbot_width,
robot_length: units.Quantity = _kitbot_length,
... | [
"def",
"theory",
"(",
"cls",
",",
"motor_config",
":",
"MotorModelConfig",
",",
"robot_mass",
":",
"units",
".",
"Quantity",
",",
"gearing",
":",
"float",
",",
"nmotors",
":",
"int",
"=",
"1",
",",
"x_wheelbase",
":",
"units",
".",
"Quantity",
"=",
"_kit... | r"""
Use this to create the drivetrain model when you haven't measured
``kv`` and ``ka`` for your robot.
:param motor_config: Specifications for your motor
:param robot_mass: Mass of the robot
:param gearing: Gear ratio .. so for a... | [
"r",
"Use",
"this",
"to",
"create",
"the",
"drivetrain",
"model",
"when",
"you",
"haven",
"t",
"measured",
"kv",
"and",
"ka",
"for",
"your",
"robot",
".",
":",
"param",
"motor_config",
":",
"Specifications",
"for",
"your",
"motor",
":",
"param",
"robot_mas... | train | https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/physics/tankmodel.py#L168-L270 |
robotpy/pyfrc | lib/pyfrc/physics/tankmodel.py | TankModel.get_distance | def get_distance(
self, l_motor: float, r_motor: float, tm_diff: float
) -> typing.Tuple[float, float]:
"""
Given motor values and the amount of time elapsed since this was last
called, retrieves the x,y,angle that the robot has moved. Pass these
values to :meth:`... | python | def get_distance(
self, l_motor: float, r_motor: float, tm_diff: float
) -> typing.Tuple[float, float]:
"""
Given motor values and the amount of time elapsed since this was last
called, retrieves the x,y,angle that the robot has moved. Pass these
values to :meth:`... | [
"def",
"get_distance",
"(",
"self",
",",
"l_motor",
":",
"float",
",",
"r_motor",
":",
"float",
",",
"tm_diff",
":",
"float",
")",
"->",
"typing",
".",
"Tuple",
"[",
"float",
",",
"float",
"]",
":",
"# This isn't quite right, the right way is to use matrix math.... | Given motor values and the amount of time elapsed since this was last
called, retrieves the x,y,angle that the robot has moved. Pass these
values to :meth:`PhysicsInterface.distance_drive`.
To update your encoders, use the ``l_position`` and ``r_position``
at... | [
"Given",
"motor",
"values",
"and",
"the",
"amount",
"of",
"time",
"elapsed",
"since",
"this",
"was",
"last",
"called",
"retrieves",
"the",
"x",
"y",
"angle",
"that",
"the",
"robot",
"has",
"moved",
".",
"Pass",
"these",
"values",
"to",
":",
"meth",
":",
... | train | https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/physics/tankmodel.py#L374-L439 |
partofthething/ace | ace/validation/validate_smoothers.py | validate_basic_smoother | def validate_basic_smoother():
"""Run Friedman's test from Figure 2b."""
x, y = sort_data(*smoother_friedman82.build_sample_smoother_problem_friedman82())
plt.figure()
# plt.plot(x, y, '.', label='Data')
for span in smoother.DEFAULT_SPANS:
my_smoother = smoother.perform_smooth(x, y, span)
... | python | def validate_basic_smoother():
"""Run Friedman's test from Figure 2b."""
x, y = sort_data(*smoother_friedman82.build_sample_smoother_problem_friedman82())
plt.figure()
# plt.plot(x, y, '.', label='Data')
for span in smoother.DEFAULT_SPANS:
my_smoother = smoother.perform_smooth(x, y, span)
... | [
"def",
"validate_basic_smoother",
"(",
")",
":",
"x",
",",
"y",
"=",
"sort_data",
"(",
"*",
"smoother_friedman82",
".",
"build_sample_smoother_problem_friedman82",
"(",
")",
")",
"plt",
".",
"figure",
"(",
")",
"# plt.plot(x, y, '.', label='Data')",
"for",
"span",
... | Run Friedman's test from Figure 2b. | [
"Run",
"Friedman",
"s",
"test",
"from",
"Figure",
"2b",
"."
] | train | https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/validation/validate_smoothers.py#L23-L33 |
partofthething/ace | ace/validation/validate_smoothers.py | validate_basic_smoother_resid | def validate_basic_smoother_resid():
"""Compare residuals."""
x, y = sort_data(*smoother_friedman82.build_sample_smoother_problem_friedman82())
plt.figure()
for span in smoother.DEFAULT_SPANS:
my_smoother = smoother.perform_smooth(x, y, span)
_friedman_smooth, resids = run_friedman_smoot... | python | def validate_basic_smoother_resid():
"""Compare residuals."""
x, y = sort_data(*smoother_friedman82.build_sample_smoother_problem_friedman82())
plt.figure()
for span in smoother.DEFAULT_SPANS:
my_smoother = smoother.perform_smooth(x, y, span)
_friedman_smooth, resids = run_friedman_smoot... | [
"def",
"validate_basic_smoother_resid",
"(",
")",
":",
"x",
",",
"y",
"=",
"sort_data",
"(",
"*",
"smoother_friedman82",
".",
"build_sample_smoother_problem_friedman82",
"(",
")",
")",
"plt",
".",
"figure",
"(",
")",
"for",
"span",
"in",
"smoother",
".",
"DEFA... | Compare residuals. | [
"Compare",
"residuals",
"."
] | train | https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/validation/validate_smoothers.py#L36-L46 |
partofthething/ace | ace/validation/validate_smoothers.py | validate_supersmoother | def validate_supersmoother():
"""Validate the supersmoother."""
x, y = smoother_friedman82.build_sample_smoother_problem_friedman82()
x, y = sort_data(x, y)
my_smoother = smoother.perform_smooth(x, y, smoother_cls=supersmoother.SuperSmootherWithPlots)
# smoother.DEFAULT_BASIC_SMOOTHER = BasicFixedSp... | python | def validate_supersmoother():
"""Validate the supersmoother."""
x, y = smoother_friedman82.build_sample_smoother_problem_friedman82()
x, y = sort_data(x, y)
my_smoother = smoother.perform_smooth(x, y, smoother_cls=supersmoother.SuperSmootherWithPlots)
# smoother.DEFAULT_BASIC_SMOOTHER = BasicFixedSp... | [
"def",
"validate_supersmoother",
"(",
")",
":",
"x",
",",
"y",
"=",
"smoother_friedman82",
".",
"build_sample_smoother_problem_friedman82",
"(",
")",
"x",
",",
"y",
"=",
"sort_data",
"(",
"x",
",",
"y",
")",
"my_smoother",
"=",
"smoother",
".",
"perform_smooth... | Validate the supersmoother. | [
"Validate",
"the",
"supersmoother",
"."
] | train | https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/validation/validate_smoothers.py#L48-L61 |
partofthething/ace | ace/validation/validate_smoothers.py | validate_supersmoother_bass | def validate_supersmoother_bass():
"""Validate the supersmoother with extra bass."""
x, y = smoother_friedman82.build_sample_smoother_problem_friedman82()
plt.figure()
plt.plot(x, y, '.', label='Data')
for bass in range(0, 10, 3):
smooth = supersmoother.SuperSmoother()
smooth.set_bas... | python | def validate_supersmoother_bass():
"""Validate the supersmoother with extra bass."""
x, y = smoother_friedman82.build_sample_smoother_problem_friedman82()
plt.figure()
plt.plot(x, y, '.', label='Data')
for bass in range(0, 10, 3):
smooth = supersmoother.SuperSmoother()
smooth.set_bas... | [
"def",
"validate_supersmoother_bass",
"(",
")",
":",
"x",
",",
"y",
"=",
"smoother_friedman82",
".",
"build_sample_smoother_problem_friedman82",
"(",
")",
"plt",
".",
"figure",
"(",
")",
"plt",
".",
"plot",
"(",
"x",
",",
"y",
",",
"'.'",
",",
"label",
"="... | Validate the supersmoother with extra bass. | [
"Validate",
"the",
"supersmoother",
"with",
"extra",
"bass",
"."
] | train | https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/validation/validate_smoothers.py#L63-L75 |
partofthething/ace | ace/validation/validate_smoothers.py | validate_average_best_span | def validate_average_best_span():
"""Figure 2d? from Friedman."""
N = 200
num_trials = 400
avg = numpy.zeros(N)
for i in range(num_trials):
x, y = smoother_friedman82.build_sample_smoother_problem_friedman82(N=N)
my_smoother = smoother.perform_smooth(
x, y, smoother_cls=s... | python | def validate_average_best_span():
"""Figure 2d? from Friedman."""
N = 200
num_trials = 400
avg = numpy.zeros(N)
for i in range(num_trials):
x, y = smoother_friedman82.build_sample_smoother_problem_friedman82(N=N)
my_smoother = smoother.perform_smooth(
x, y, smoother_cls=s... | [
"def",
"validate_average_best_span",
"(",
")",
":",
"N",
"=",
"200",
"num_trials",
"=",
"400",
"avg",
"=",
"numpy",
".",
"zeros",
"(",
"N",
")",
"for",
"i",
"in",
"range",
"(",
"num_trials",
")",
":",
"x",
",",
"y",
"=",
"smoother_friedman82",
".",
"... | Figure 2d? from Friedman. | [
"Figure",
"2d?",
"from",
"Friedman",
"."
] | train | https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/validation/validate_smoothers.py#L77-L92 |
partofthething/ace | ace/validation/validate_smoothers.py | validate_known_curve | def validate_known_curve():
"""Validate on a sin function."""
plt.figure()
N = 100
x = numpy.linspace(-1, 1, N)
y = numpy.sin(4 * x)
smoother.DEFAULT_BASIC_SMOOTHER = smoother.BasicFixedSpanSmootherSlowUpdate
smooth = smoother.perform_smooth(x, y, smoother_cls=supersmoother.SuperSmoother)
... | python | def validate_known_curve():
"""Validate on a sin function."""
plt.figure()
N = 100
x = numpy.linspace(-1, 1, N)
y = numpy.sin(4 * x)
smoother.DEFAULT_BASIC_SMOOTHER = smoother.BasicFixedSpanSmootherSlowUpdate
smooth = smoother.perform_smooth(x, y, smoother_cls=supersmoother.SuperSmoother)
... | [
"def",
"validate_known_curve",
"(",
")",
":",
"plt",
".",
"figure",
"(",
")",
"N",
"=",
"100",
"x",
"=",
"numpy",
".",
"linspace",
"(",
"-",
"1",
",",
"1",
",",
"N",
")",
"y",
"=",
"numpy",
".",
"sin",
"(",
"4",
"*",
"x",
")",
"smoother",
"."... | Validate on a sin function. | [
"Validate",
"on",
"a",
"sin",
"function",
"."
] | train | https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/validation/validate_smoothers.py#L94-L108 |
partofthething/ace | ace/validation/validate_smoothers.py | finish_plot | def finish_plot():
"""Helper for plotting."""
plt.legend()
plt.grid(color='0.7')
plt.xlabel('x')
plt.ylabel('y')
plt.show() | python | def finish_plot():
"""Helper for plotting."""
plt.legend()
plt.grid(color='0.7')
plt.xlabel('x')
plt.ylabel('y')
plt.show() | [
"def",
"finish_plot",
"(",
")",
":",
"plt",
".",
"legend",
"(",
")",
"plt",
".",
"grid",
"(",
"color",
"=",
"'0.7'",
")",
"plt",
".",
"xlabel",
"(",
"'x'",
")",
"plt",
".",
"ylabel",
"(",
"'y'",
")",
"plt",
".",
"show",
"(",
")"
] | Helper for plotting. | [
"Helper",
"for",
"plotting",
"."
] | train | https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/validation/validate_smoothers.py#L110-L116 |
partofthething/ace | ace/validation/validate_smoothers.py | run_freidman_supsmu | def run_freidman_supsmu(x, y, bass_enhancement=0.0):
"""Run the FORTRAN supersmoother."""
N = len(x)
weight = numpy.ones(N)
results = numpy.zeros(N)
flags = numpy.zeros((N, 7))
mace.supsmu(x, y, weight, 1, 0.0, bass_enhancement, results, flags)
return results | python | def run_freidman_supsmu(x, y, bass_enhancement=0.0):
"""Run the FORTRAN supersmoother."""
N = len(x)
weight = numpy.ones(N)
results = numpy.zeros(N)
flags = numpy.zeros((N, 7))
mace.supsmu(x, y, weight, 1, 0.0, bass_enhancement, results, flags)
return results | [
"def",
"run_freidman_supsmu",
"(",
"x",
",",
"y",
",",
"bass_enhancement",
"=",
"0.0",
")",
":",
"N",
"=",
"len",
"(",
"x",
")",
"weight",
"=",
"numpy",
".",
"ones",
"(",
"N",
")",
"results",
"=",
"numpy",
".",
"zeros",
"(",
"N",
")",
"flags",
"=... | Run the FORTRAN supersmoother. | [
"Run",
"the",
"FORTRAN",
"supersmoother",
"."
] | train | https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/validation/validate_smoothers.py#L118-L125 |
partofthething/ace | ace/validation/validate_smoothers.py | run_friedman_smooth | def run_friedman_smooth(x, y, span):
"""Run the FORTRAN smoother."""
N = len(x)
weight = numpy.ones(N)
results = numpy.zeros(N)
residuals = numpy.zeros(N)
mace.smooth(x, y, weight, span, 1, 1e-7, results, residuals)
return results, residuals | python | def run_friedman_smooth(x, y, span):
"""Run the FORTRAN smoother."""
N = len(x)
weight = numpy.ones(N)
results = numpy.zeros(N)
residuals = numpy.zeros(N)
mace.smooth(x, y, weight, span, 1, 1e-7, results, residuals)
return results, residuals | [
"def",
"run_friedman_smooth",
"(",
"x",
",",
"y",
",",
"span",
")",
":",
"N",
"=",
"len",
"(",
"x",
")",
"weight",
"=",
"numpy",
".",
"ones",
"(",
"N",
")",
"results",
"=",
"numpy",
".",
"zeros",
"(",
"N",
")",
"residuals",
"=",
"numpy",
".",
"... | Run the FORTRAN smoother. | [
"Run",
"the",
"FORTRAN",
"smoother",
"."
] | train | https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/validation/validate_smoothers.py#L127-L134 |
partofthething/ace | ace/validation/validate_smoothers.py | run_mace_smothr | def run_mace_smothr(x, y, bass_enhancement=0.0): # pylint: disable=unused-argument
"""Run the FORTRAN SMOTHR."""
N = len(x)
weight = numpy.ones(N)
results = numpy.zeros(N)
flags = numpy.zeros((N, 7))
mace.smothr(1, x, y, weight, results, flags)
return results | python | def run_mace_smothr(x, y, bass_enhancement=0.0): # pylint: disable=unused-argument
"""Run the FORTRAN SMOTHR."""
N = len(x)
weight = numpy.ones(N)
results = numpy.zeros(N)
flags = numpy.zeros((N, 7))
mace.smothr(1, x, y, weight, results, flags)
return results | [
"def",
"run_mace_smothr",
"(",
"x",
",",
"y",
",",
"bass_enhancement",
"=",
"0.0",
")",
":",
"# pylint: disable=unused-argument",
"N",
"=",
"len",
"(",
"x",
")",
"weight",
"=",
"numpy",
".",
"ones",
"(",
"N",
")",
"results",
"=",
"numpy",
".",
"zeros",
... | Run the FORTRAN SMOTHR. | [
"Run",
"the",
"FORTRAN",
"SMOTHR",
"."
] | train | https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/validation/validate_smoothers.py#L136-L143 |
partofthething/ace | ace/validation/validate_smoothers.py | sort_data | def sort_data(x, y):
"""Sort the data."""
xy = sorted(zip(x, y))
x, y = zip(*xy)
return x, y | python | def sort_data(x, y):
"""Sort the data."""
xy = sorted(zip(x, y))
x, y = zip(*xy)
return x, y | [
"def",
"sort_data",
"(",
"x",
",",
"y",
")",
":",
"xy",
"=",
"sorted",
"(",
"zip",
"(",
"x",
",",
"y",
")",
")",
"x",
",",
"y",
"=",
"zip",
"(",
"*",
"xy",
")",
"return",
"x",
",",
"y"
] | Sort the data. | [
"Sort",
"the",
"data",
"."
] | train | https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/validation/validate_smoothers.py#L162-L166 |
partofthething/ace | ace/validation/validate_smoothers.py | BasicFixedSpanSmootherBreiman.compute | def compute(self):
"""Run smoother."""
self.smooth_result, self.cross_validated_residual = run_friedman_smooth(
self.x, self.y, self._span
) | python | def compute(self):
"""Run smoother."""
self.smooth_result, self.cross_validated_residual = run_friedman_smooth(
self.x, self.y, self._span
) | [
"def",
"compute",
"(",
"self",
")",
":",
"self",
".",
"smooth_result",
",",
"self",
".",
"cross_validated_residual",
"=",
"run_friedman_smooth",
"(",
"self",
".",
"x",
",",
"self",
".",
"y",
",",
"self",
".",
"_span",
")"
] | Run smoother. | [
"Run",
"smoother",
"."
] | train | https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/validation/validate_smoothers.py#L148-L152 |
partofthething/ace | ace/validation/validate_smoothers.py | SuperSmootherBreiman.compute | def compute(self):
"""Run SuperSmoother."""
self.smooth_result = run_freidman_supsmu(self.x, self.y)
self._store_unsorted_results(self.smooth_result, numpy.zeros(len(self.smooth_result))) | python | def compute(self):
"""Run SuperSmoother."""
self.smooth_result = run_freidman_supsmu(self.x, self.y)
self._store_unsorted_results(self.smooth_result, numpy.zeros(len(self.smooth_result))) | [
"def",
"compute",
"(",
"self",
")",
":",
"self",
".",
"smooth_result",
"=",
"run_freidman_supsmu",
"(",
"self",
".",
"x",
",",
"self",
".",
"y",
")",
"self",
".",
"_store_unsorted_results",
"(",
"self",
".",
"smooth_result",
",",
"numpy",
".",
"zeros",
"... | Run SuperSmoother. | [
"Run",
"SuperSmoother",
"."
] | train | https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/validation/validate_smoothers.py#L157-L160 |
openstack/monasca-common | monasca_common/kafka_lib/client.py | KafkaClient._get_conn | def _get_conn(self, host, port):
"""Get or create a connection to a broker using host and port"""
host_key = (host, port)
if host_key not in self.conns:
self.conns[host_key] = KafkaConnection(
host,
port,
timeout=self.timeout
... | python | def _get_conn(self, host, port):
"""Get or create a connection to a broker using host and port"""
host_key = (host, port)
if host_key not in self.conns:
self.conns[host_key] = KafkaConnection(
host,
port,
timeout=self.timeout
... | [
"def",
"_get_conn",
"(",
"self",
",",
"host",
",",
"port",
")",
":",
"host_key",
"=",
"(",
"host",
",",
"port",
")",
"if",
"host_key",
"not",
"in",
"self",
".",
"conns",
":",
"self",
".",
"conns",
"[",
"host_key",
"]",
"=",
"KafkaConnection",
"(",
... | Get or create a connection to a broker using host and port | [
"Get",
"or",
"create",
"a",
"connection",
"to",
"a",
"broker",
"using",
"host",
"and",
"port"
] | train | https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/client.py#L64-L74 |
openstack/monasca-common | monasca_common/kafka_lib/client.py | KafkaClient._get_coordinator_for_group | def _get_coordinator_for_group(self, group):
"""
Returns the coordinator broker for a consumer group.
ConsumerCoordinatorNotAvailableCode will be raised if the coordinator
does not currently exist for the group.
OffsetsLoadInProgressCode is raised if the coordinator is availabl... | python | def _get_coordinator_for_group(self, group):
"""
Returns the coordinator broker for a consumer group.
ConsumerCoordinatorNotAvailableCode will be raised if the coordinator
does not currently exist for the group.
OffsetsLoadInProgressCode is raised if the coordinator is availabl... | [
"def",
"_get_coordinator_for_group",
"(",
"self",
",",
"group",
")",
":",
"resp",
"=",
"self",
".",
"send_consumer_metadata_request",
"(",
"group",
")",
"# If there's a problem with finding the coordinator, raise the",
"# provided error",
"kafka_common",
".",
"check_error",
... | Returns the coordinator broker for a consumer group.
ConsumerCoordinatorNotAvailableCode will be raised if the coordinator
does not currently exist for the group.
OffsetsLoadInProgressCode is raised if the coordinator is available
but is still loading offsets from the internal topic | [
"Returns",
"the",
"coordinator",
"broker",
"for",
"a",
"consumer",
"group",
"."
] | train | https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/client.py#L113-L131 |
openstack/monasca-common | monasca_common/kafka_lib/client.py | KafkaClient._send_broker_unaware_request | def _send_broker_unaware_request(self, payloads, encoder_fn, decoder_fn):
"""
Attempt to send a broker-agnostic request to one of the available
brokers. Keep trying until you succeed.
"""
for (host, port) in self.hosts:
requestId = self._next_id()
log.debu... | python | def _send_broker_unaware_request(self, payloads, encoder_fn, decoder_fn):
"""
Attempt to send a broker-agnostic request to one of the available
brokers. Keep trying until you succeed.
"""
for (host, port) in self.hosts:
requestId = self._next_id()
log.debu... | [
"def",
"_send_broker_unaware_request",
"(",
"self",
",",
"payloads",
",",
"encoder_fn",
",",
"decoder_fn",
")",
":",
"for",
"(",
"host",
",",
"port",
")",
"in",
"self",
".",
"hosts",
":",
"requestId",
"=",
"self",
".",
"_next_id",
"(",
")",
"log",
".",
... | Attempt to send a broker-agnostic request to one of the available
brokers. Keep trying until you succeed. | [
"Attempt",
"to",
"send",
"a",
"broker",
"-",
"agnostic",
"request",
"to",
"one",
"of",
"the",
"available",
"brokers",
".",
"Keep",
"trying",
"until",
"you",
"succeed",
"."
] | train | https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/client.py#L139-L163 |
openstack/monasca-common | monasca_common/kafka_lib/client.py | KafkaClient._send_broker_aware_request | def _send_broker_aware_request(self, payloads, encoder_fn, decoder_fn):
"""
Group a list of request payloads by topic+partition and send them to
the leader broker for that partition using the supplied encode/decode
functions
Arguments:
payloads: list of object-like enti... | python | def _send_broker_aware_request(self, payloads, encoder_fn, decoder_fn):
"""
Group a list of request payloads by topic+partition and send them to
the leader broker for that partition using the supplied encode/decode
functions
Arguments:
payloads: list of object-like enti... | [
"def",
"_send_broker_aware_request",
"(",
"self",
",",
"payloads",
",",
"encoder_fn",
",",
"decoder_fn",
")",
":",
"# encoders / decoders do not maintain ordering currently",
"# so we need to keep this so we can rebuild order before returning",
"original_ordering",
"=",
"[",
"(",
... | Group a list of request payloads by topic+partition and send them to
the leader broker for that partition using the supplied encode/decode
functions
Arguments:
payloads: list of object-like entities with a topic (str) and
partition (int) attribute; payloads with duplicate t... | [
"Group",
"a",
"list",
"of",
"request",
"payloads",
"by",
"topic",
"+",
"partition",
"and",
"send",
"them",
"to",
"the",
"leader",
"broker",
"for",
"that",
"partition",
"using",
"the",
"supplied",
"encode",
"/",
"decode",
"functions"
] | train | https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/client.py#L165-L287 |
openstack/monasca-common | monasca_common/kafka_lib/client.py | KafkaClient._send_consumer_aware_request | def _send_consumer_aware_request(self, group, payloads, encoder_fn, decoder_fn):
"""
Send a list of requests to the consumer coordinator for the group
specified using the supplied encode/decode functions. As the payloads
that use consumer-aware requests do not contain the group (e.g.
... | python | def _send_consumer_aware_request(self, group, payloads, encoder_fn, decoder_fn):
"""
Send a list of requests to the consumer coordinator for the group
specified using the supplied encode/decode functions. As the payloads
that use consumer-aware requests do not contain the group (e.g.
... | [
"def",
"_send_consumer_aware_request",
"(",
"self",
",",
"group",
",",
"payloads",
",",
"encoder_fn",
",",
"decoder_fn",
")",
":",
"# encoders / decoders do not maintain ordering currently",
"# so we need to keep this so we can rebuild order before returning",
"original_ordering",
... | Send a list of requests to the consumer coordinator for the group
specified using the supplied encode/decode functions. As the payloads
that use consumer-aware requests do not contain the group (e.g.
OffsetFetchRequest), all payloads must be for a single group.
Arguments:
group... | [
"Send",
"a",
"list",
"of",
"requests",
"to",
"the",
"consumer",
"coordinator",
"for",
"the",
"group",
"specified",
"using",
"the",
"supplied",
"encode",
"/",
"decode",
"functions",
".",
"As",
"the",
"payloads",
"that",
"use",
"consumer",
"-",
"aware",
"reque... | train | https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/client.py#L289-L377 |
openstack/monasca-common | monasca_common/kafka_lib/client.py | KafkaClient.copy | def copy(self):
"""
Create an inactive copy of the client object, suitable for passing
to a separate thread.
Note that the copied connections are not initialized, so reinit() must
be called on the returned copy.
"""
c = copy.deepcopy(self)
for key in c.co... | python | def copy(self):
"""
Create an inactive copy of the client object, suitable for passing
to a separate thread.
Note that the copied connections are not initialized, so reinit() must
be called on the returned copy.
"""
c = copy.deepcopy(self)
for key in c.co... | [
"def",
"copy",
"(",
"self",
")",
":",
"c",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
")",
"for",
"key",
"in",
"c",
".",
"conns",
":",
"c",
".",
"conns",
"[",
"key",
"]",
"=",
"self",
".",
"conns",
"[",
"key",
"]",
".",
"copy",
"(",
")",
"r... | Create an inactive copy of the client object, suitable for passing
to a separate thread.
Note that the copied connections are not initialized, so reinit() must
be called on the returned copy. | [
"Create",
"an",
"inactive",
"copy",
"of",
"the",
"client",
"object",
"suitable",
"for",
"passing",
"to",
"a",
"separate",
"thread",
"."
] | train | https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/client.py#L405-L416 |
openstack/monasca-common | monasca_common/kafka_lib/client.py | KafkaClient.load_metadata_for_topics | def load_metadata_for_topics(self, *topics):
"""
Fetch broker and topic-partition metadata from the server,
and update internal data:
broker list, topic/partition list, and topic/parition -> broker map
This method should be called after receiving any error
Arguments:
... | python | def load_metadata_for_topics(self, *topics):
"""
Fetch broker and topic-partition metadata from the server,
and update internal data:
broker list, topic/partition list, and topic/parition -> broker map
This method should be called after receiving any error
Arguments:
... | [
"def",
"load_metadata_for_topics",
"(",
"self",
",",
"*",
"topics",
")",
":",
"topics",
"=",
"[",
"kafka_bytestring",
"(",
"t",
")",
"for",
"t",
"in",
"topics",
"]",
"if",
"topics",
":",
"for",
"topic",
"in",
"topics",
":",
"self",
".",
"reset_topic_meta... | Fetch broker and topic-partition metadata from the server,
and update internal data:
broker list, topic/partition list, and topic/parition -> broker map
This method should be called after receiving any error
Arguments:
*topics (optional): If a list of topics is provided,
... | [
"Fetch",
"broker",
"and",
"topic",
"-",
"partition",
"metadata",
"from",
"the",
"server",
"and",
"update",
"internal",
"data",
":",
"broker",
"list",
"topic",
"/",
"partition",
"list",
"and",
"topic",
"/",
"parition",
"-",
">",
"broker",
"map"
] | train | https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka_lib/client.py#L465-L560 |
openstack/monasca-common | monasca_common/kafka/consumer.py | KafkaConsumer._partition | def _partition(self):
"""Consume messages from kafka
Consume messages from kafka using the Kazoo SetPartitioner to
allow multiple consumer processes to negotiate access to the kafka
partitions
"""
# KazooClient and SetPartitioner objects need to be instantiated... | python | def _partition(self):
"""Consume messages from kafka
Consume messages from kafka using the Kazoo SetPartitioner to
allow multiple consumer processes to negotiate access to the kafka
partitions
"""
# KazooClient and SetPartitioner objects need to be instantiated... | [
"def",
"_partition",
"(",
"self",
")",
":",
"# KazooClient and SetPartitioner objects need to be instantiated after",
"# the consumer process has forked. Instantiating prior to forking",
"# gives the appearance that things are working but after forking the",
"# connection to zookeeper is lost and... | Consume messages from kafka
Consume messages from kafka using the Kazoo SetPartitioner to
allow multiple consumer processes to negotiate access to the kafka
partitions | [
"Consume",
"messages",
"from",
"kafka"
] | train | https://github.com/openstack/monasca-common/blob/61e2e00454734e2881611abec8df0d85bf7655ac/monasca_common/kafka/consumer.py#L161-L229 |
robotpy/pyfrc | lib/pyfrc/physics/core.py | PhysicsInterface.drive | def drive(self, speed, rotation_speed, tm_diff):
"""Call this from your :func:`PhysicsEngine.update_sim` function.
Will update the robot's position on the simulation field.
You can either calculate the speed & rotation manually, or you
can use the predefined functions in :mod:`... | python | def drive(self, speed, rotation_speed, tm_diff):
"""Call this from your :func:`PhysicsEngine.update_sim` function.
Will update the robot's position on the simulation field.
You can either calculate the speed & rotation manually, or you
can use the predefined functions in :mod:`... | [
"def",
"drive",
"(",
"self",
",",
"speed",
",",
"rotation_speed",
",",
"tm_diff",
")",
":",
"# if the robot is disabled, don't do anything",
"if",
"not",
"self",
".",
"robot_enabled",
":",
"return",
"distance",
"=",
"speed",
"*",
"tm_diff",
"angle",
"=",
"rotati... | Call this from your :func:`PhysicsEngine.update_sim` function.
Will update the robot's position on the simulation field.
You can either calculate the speed & rotation manually, or you
can use the predefined functions in :mod:`pyfrc.physics.drivetrains`.
The outpu... | [
"Call",
"this",
"from",
"your",
":",
"func",
":",
"PhysicsEngine",
".",
"update_sim",
"function",
".",
"Will",
"update",
"the",
"robot",
"s",
"position",
"on",
"the",
"simulation",
"field",
"."
] | train | https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/physics/core.py#L242-L270 |
robotpy/pyfrc | lib/pyfrc/physics/core.py | PhysicsInterface.vector_drive | def vector_drive(self, vx, vy, vw, tm_diff):
"""Call this from your :func:`PhysicsEngine.update_sim` function.
Will update the robot's position on the simulation field.
This moves the robot using a velocity vector relative to the robot
instead of by speed/rotation sp... | python | def vector_drive(self, vx, vy, vw, tm_diff):
"""Call this from your :func:`PhysicsEngine.update_sim` function.
Will update the robot's position on the simulation field.
This moves the robot using a velocity vector relative to the robot
instead of by speed/rotation sp... | [
"def",
"vector_drive",
"(",
"self",
",",
"vx",
",",
"vy",
",",
"vw",
",",
"tm_diff",
")",
":",
"# if the robot is disabled, don't do anything",
"if",
"not",
"self",
".",
"robot_enabled",
":",
"return",
"angle",
"=",
"vw",
"*",
"tm_diff",
"vx",
"=",
"vx",
"... | Call this from your :func:`PhysicsEngine.update_sim` function.
Will update the robot's position on the simulation field.
This moves the robot using a velocity vector relative to the robot
instead of by speed/rotation speed.
:param vx: Speed in x direct... | [
"Call",
"this",
"from",
"your",
":",
"func",
":",
"PhysicsEngine",
".",
"update_sim",
"function",
".",
"Will",
"update",
"the",
"robot",
"s",
"position",
"on",
"the",
"simulation",
"field",
".",
"This",
"moves",
"the",
"robot",
"using",
"a",
"velocity",
"v... | train | https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/physics/core.py#L272-L296 |
robotpy/pyfrc | lib/pyfrc/physics/core.py | PhysicsInterface.distance_drive | def distance_drive(self, x, y, angle):
"""Call this from your :func:`PhysicsEngine.update_sim` function.
Will update the robot's position on the simulation field.
This moves the robot some relative distance and angle from
its current position.
... | python | def distance_drive(self, x, y, angle):
"""Call this from your :func:`PhysicsEngine.update_sim` function.
Will update the robot's position on the simulation field.
This moves the robot some relative distance and angle from
its current position.
... | [
"def",
"distance_drive",
"(",
"self",
",",
"x",
",",
"y",
",",
"angle",
")",
":",
"with",
"self",
".",
"_lock",
":",
"self",
".",
"vx",
"+=",
"x",
"self",
".",
"vy",
"+=",
"y",
"self",
".",
"angle",
"+=",
"angle",
"c",
"=",
"math",
".",
"cos",
... | Call this from your :func:`PhysicsEngine.update_sim` function.
Will update the robot's position on the simulation field.
This moves the robot some relative distance and angle from
its current position.
:param x: Feet to move the robot in the x dire... | [
"Call",
"this",
"from",
"your",
":",
"func",
":",
"PhysicsEngine",
".",
"update_sim",
"function",
".",
"Will",
"update",
"the",
"robot",
"s",
"position",
"on",
"the",
"simulation",
"field",
".",
"This",
"moves",
"the",
"robot",
"some",
"relative",
"distance"... | train | https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/physics/core.py#L298-L320 |
robotpy/pyfrc | lib/pyfrc/physics/core.py | PhysicsInterface.get_position | def get_position(self):
"""
:returns: Robot's current position on the field as `(x,y,angle)`.
`x` and `y` are specified in feet, `angle` is in radians
"""
with self._lock:
return self.x, self.y, self.angle | python | def get_position(self):
"""
:returns: Robot's current position on the field as `(x,y,angle)`.
`x` and `y` are specified in feet, `angle` is in radians
"""
with self._lock:
return self.x, self.y, self.angle | [
"def",
"get_position",
"(",
"self",
")",
":",
"with",
"self",
".",
"_lock",
":",
"return",
"self",
".",
"x",
",",
"self",
".",
"y",
",",
"self",
".",
"angle"
] | :returns: Robot's current position on the field as `(x,y,angle)`.
`x` and `y` are specified in feet, `angle` is in radians | [
":",
"returns",
":",
"Robot",
"s",
"current",
"position",
"on",
"the",
"field",
"as",
"(",
"x",
"y",
"angle",
")",
".",
"x",
"and",
"y",
"are",
"specified",
"in",
"feet",
"angle",
"is",
"in",
"radians"
] | train | https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/physics/core.py#L332-L338 |
robotpy/pyfrc | lib/pyfrc/physics/core.py | PhysicsInterface.get_offset | def get_offset(self, x, y):
"""
Computes how far away and at what angle a coordinate is
located.
Distance is returned in feet, angle is returned in degrees
:returns: distance,angle offset of the given x,y coordinate
.... | python | def get_offset(self, x, y):
"""
Computes how far away and at what angle a coordinate is
located.
Distance is returned in feet, angle is returned in degrees
:returns: distance,angle offset of the given x,y coordinate
.... | [
"def",
"get_offset",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"with",
"self",
".",
"_lock",
":",
"dx",
"=",
"self",
".",
"x",
"-",
"x",
"dy",
"=",
"self",
".",
"y",
"-",
"y",
"distance",
"=",
"math",
".",
"hypot",
"(",
"dx",
",",
"dy",
")... | Computes how far away and at what angle a coordinate is
located.
Distance is returned in feet, angle is returned in degrees
:returns: distance,angle offset of the given x,y coordinate
.. versionadded:: 2018.1.7 | [
"Computes",
"how",
"far",
"away",
"and",
"at",
"what",
"angle",
"a",
"coordinate",
"is",
"located",
".",
"Distance",
"is",
"returned",
"in",
"feet",
"angle",
"is",
"returned",
"in",
"degrees",
":",
"returns",
":",
"distance",
"angle",
"offset",
"of",
"the"... | train | https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/physics/core.py#L340-L357 |
robotpy/pyfrc | lib/pyfrc/sim/robot_controller.py | RobotController._check_sleep | def _check_sleep(self, idx):
"""This ensures that the robot code called Wait() at some point"""
# TODO: There are some cases where it would be ok to do this...
if not self.fake_time.slept[idx]:
errstr = (
"%s() function is not calling wpilib.Timer.delay() in its loop... | python | def _check_sleep(self, idx):
"""This ensures that the robot code called Wait() at some point"""
# TODO: There are some cases where it would be ok to do this...
if not self.fake_time.slept[idx]:
errstr = (
"%s() function is not calling wpilib.Timer.delay() in its loop... | [
"def",
"_check_sleep",
"(",
"self",
",",
"idx",
")",
":",
"# TODO: There are some cases where it would be ok to do this...",
"if",
"not",
"self",
".",
"fake_time",
".",
"slept",
"[",
"idx",
"]",
":",
"errstr",
"=",
"(",
"\"%s() function is not calling wpilib.Timer.delay... | This ensures that the robot code called Wait() at some point | [
"This",
"ensures",
"that",
"the",
"robot",
"code",
"called",
"Wait",
"()",
"at",
"some",
"point"
] | train | https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/sim/robot_controller.py#L151-L162 |
robotpy/pyfrc | lib/pyfrc/physics/drivetrains.py | linear_deadzone | def linear_deadzone(deadzone: float) -> DeadzoneCallable:
"""
Real motors won't actually move unless you give them some minimum amount
of input. This computes an output speed for a motor and causes it to
'not move' if the input isn't high enough. Additionally, the output is
adjusted ... | python | def linear_deadzone(deadzone: float) -> DeadzoneCallable:
"""
Real motors won't actually move unless you give them some minimum amount
of input. This computes an output speed for a motor and causes it to
'not move' if the input isn't high enough. Additionally, the output is
adjusted ... | [
"def",
"linear_deadzone",
"(",
"deadzone",
":",
"float",
")",
"->",
"DeadzoneCallable",
":",
"assert",
"0.0",
"<",
"deadzone",
"<",
"1.0",
"scale_param",
"=",
"1.0",
"-",
"deadzone",
"def",
"_linear_deadzone",
"(",
"motor_input",
")",
":",
"abs_motor_input",
"... | Real motors won't actually move unless you give them some minimum amount
of input. This computes an output speed for a motor and causes it to
'not move' if the input isn't high enough. Additionally, the output is
adjusted linearly to compensate.
Example: For a deadzone of 0.2:
... | [
"Real",
"motors",
"won",
"t",
"actually",
"move",
"unless",
"you",
"give",
"them",
"some",
"minimum",
"amount",
"of",
"input",
".",
"This",
"computes",
"an",
"output",
"speed",
"for",
"a",
"motor",
"and",
"causes",
"it",
"to",
"not",
"move",
"if",
"the",... | train | https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/physics/drivetrains.py#L45-L78 |
robotpy/pyfrc | lib/pyfrc/physics/drivetrains.py | two_motor_drivetrain | def two_motor_drivetrain(l_motor, r_motor, x_wheelbase=2, speed=5, deadzone=None):
"""
.. deprecated:: 2018.2.0
Use :class:`TwoMotorDrivetrain` instead
"""
return TwoMotorDrivetrain(x_wheelbase, speed, deadzone).get_vector(l_motor, r_motor) | python | def two_motor_drivetrain(l_motor, r_motor, x_wheelbase=2, speed=5, deadzone=None):
"""
.. deprecated:: 2018.2.0
Use :class:`TwoMotorDrivetrain` instead
"""
return TwoMotorDrivetrain(x_wheelbase, speed, deadzone).get_vector(l_motor, r_motor) | [
"def",
"two_motor_drivetrain",
"(",
"l_motor",
",",
"r_motor",
",",
"x_wheelbase",
"=",
"2",
",",
"speed",
"=",
"5",
",",
"deadzone",
"=",
"None",
")",
":",
"return",
"TwoMotorDrivetrain",
"(",
"x_wheelbase",
",",
"speed",
",",
"deadzone",
")",
".",
"get_v... | .. deprecated:: 2018.2.0
Use :class:`TwoMotorDrivetrain` instead | [
"..",
"deprecated",
"::",
"2018",
".",
"2",
".",
"0",
"Use",
":",
"class",
":",
"TwoMotorDrivetrain",
"instead"
] | train | https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/physics/drivetrains.py#L146-L151 |
robotpy/pyfrc | lib/pyfrc/physics/drivetrains.py | four_motor_drivetrain | def four_motor_drivetrain(
lr_motor, rr_motor, lf_motor, rf_motor, x_wheelbase=2, speed=5, deadzone=None
):
"""
.. deprecated:: 2018.2.0
Use :class:`FourMotorDrivetrain` instead
"""
return FourMotorDrivetrain(x_wheelbase, speed, deadzone).get_vector(
lr_motor, rr_motor, lf_mot... | python | def four_motor_drivetrain(
lr_motor, rr_motor, lf_motor, rf_motor, x_wheelbase=2, speed=5, deadzone=None
):
"""
.. deprecated:: 2018.2.0
Use :class:`FourMotorDrivetrain` instead
"""
return FourMotorDrivetrain(x_wheelbase, speed, deadzone).get_vector(
lr_motor, rr_motor, lf_mot... | [
"def",
"four_motor_drivetrain",
"(",
"lr_motor",
",",
"rr_motor",
",",
"lf_motor",
",",
"rf_motor",
",",
"x_wheelbase",
"=",
"2",
",",
"speed",
"=",
"5",
",",
"deadzone",
"=",
"None",
")",
":",
"return",
"FourMotorDrivetrain",
"(",
"x_wheelbase",
",",
"speed... | .. deprecated:: 2018.2.0
Use :class:`FourMotorDrivetrain` instead | [
"..",
"deprecated",
"::",
"2018",
".",
"2",
".",
"0",
"Use",
":",
"class",
":",
"FourMotorDrivetrain",
"instead"
] | train | https://github.com/robotpy/pyfrc/blob/7672ea3f17c8d4b702a9f18a7372d95feee7e37d/lib/pyfrc/physics/drivetrains.py#L224-L233 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.