repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
agoragames/haigha | haigha/connections/rabbit_connection.py | RabbitBasicClass.publish | def publish(self, *args, **kwargs):
'''
Publish a message. Will return the id of the message if publisher
confirmations are enabled, else will return 0.
'''
if self.channel.confirm._enabled:
self._msg_id += 1
super(RabbitBasicClass, self).publish(*args, **kwar... | python | def publish(self, *args, **kwargs):
'''
Publish a message. Will return the id of the message if publisher
confirmations are enabled, else will return 0.
'''
if self.channel.confirm._enabled:
self._msg_id += 1
super(RabbitBasicClass, self).publish(*args, **kwar... | [
"def",
"publish",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"channel",
".",
"confirm",
".",
"_enabled",
":",
"self",
".",
"_msg_id",
"+=",
"1",
"super",
"(",
"RabbitBasicClass",
",",
"self",
")",
".",
"pub... | Publish a message. Will return the id of the message if publisher
confirmations are enabled, else will return 0. | [
"Publish",
"a",
"message",
".",
"Will",
"return",
"the",
"id",
"of",
"the",
"message",
"if",
"publisher",
"confirmations",
"are",
"enabled",
"else",
"will",
"return",
"0",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connections/rabbit_connection.py#L196-L204 |
agoragames/haigha | haigha/connections/rabbit_connection.py | RabbitBasicClass._recv_ack | def _recv_ack(self, method_frame):
'''Receive an ack from the broker.'''
if self._ack_listener:
delivery_tag = method_frame.args.read_longlong()
multiple = method_frame.args.read_bit()
if multiple:
while self._last_ack_id < delivery_tag:
... | python | def _recv_ack(self, method_frame):
'''Receive an ack from the broker.'''
if self._ack_listener:
delivery_tag = method_frame.args.read_longlong()
multiple = method_frame.args.read_bit()
if multiple:
while self._last_ack_id < delivery_tag:
... | [
"def",
"_recv_ack",
"(",
"self",
",",
"method_frame",
")",
":",
"if",
"self",
".",
"_ack_listener",
":",
"delivery_tag",
"=",
"method_frame",
".",
"args",
".",
"read_longlong",
"(",
")",
"multiple",
"=",
"method_frame",
".",
"args",
".",
"read_bit",
"(",
"... | Receive an ack from the broker. | [
"Receive",
"an",
"ack",
"from",
"the",
"broker",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connections/rabbit_connection.py#L206-L217 |
agoragames/haigha | haigha/connections/rabbit_connection.py | RabbitBasicClass.nack | def nack(self, delivery_tag, multiple=False, requeue=False):
'''Send a nack to the broker.'''
args = Writer()
args.write_longlong(delivery_tag).\
write_bits(multiple, requeue)
self.send_frame(MethodFrame(self.channel_id, 60, 120, args)) | python | def nack(self, delivery_tag, multiple=False, requeue=False):
'''Send a nack to the broker.'''
args = Writer()
args.write_longlong(delivery_tag).\
write_bits(multiple, requeue)
self.send_frame(MethodFrame(self.channel_id, 60, 120, args)) | [
"def",
"nack",
"(",
"self",
",",
"delivery_tag",
",",
"multiple",
"=",
"False",
",",
"requeue",
"=",
"False",
")",
":",
"args",
"=",
"Writer",
"(",
")",
"args",
".",
"write_longlong",
"(",
"delivery_tag",
")",
".",
"write_bits",
"(",
"multiple",
",",
"... | Send a nack to the broker. | [
"Send",
"a",
"nack",
"to",
"the",
"broker",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connections/rabbit_connection.py#L219-L225 |
agoragames/haigha | haigha/connections/rabbit_connection.py | RabbitBasicClass._recv_nack | def _recv_nack(self, method_frame):
'''Receive a nack from the broker.'''
if self._nack_listener:
delivery_tag = method_frame.args.read_longlong()
multiple, requeue = method_frame.args.read_bits(2)
if multiple:
while self._last_ack_id < delivery_tag:
... | python | def _recv_nack(self, method_frame):
'''Receive a nack from the broker.'''
if self._nack_listener:
delivery_tag = method_frame.args.read_longlong()
multiple, requeue = method_frame.args.read_bits(2)
if multiple:
while self._last_ack_id < delivery_tag:
... | [
"def",
"_recv_nack",
"(",
"self",
",",
"method_frame",
")",
":",
"if",
"self",
".",
"_nack_listener",
":",
"delivery_tag",
"=",
"method_frame",
".",
"args",
".",
"read_longlong",
"(",
")",
"multiple",
",",
"requeue",
"=",
"method_frame",
".",
"args",
".",
... | Receive a nack from the broker. | [
"Receive",
"a",
"nack",
"from",
"the",
"broker",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connections/rabbit_connection.py#L227-L238 |
agoragames/haigha | haigha/connections/rabbit_connection.py | RabbitBasicClass.consume | def consume(self, queue, consumer, consumer_tag='', no_local=False,
no_ack=True, exclusive=False, nowait=True, ticket=None,
cb=None, cancel_cb=None):
'''Start a queue consumer.
Accepts the following optional arg in addition to those of
`BasicClass.consume()`:
... | python | def consume(self, queue, consumer, consumer_tag='', no_local=False,
no_ack=True, exclusive=False, nowait=True, ticket=None,
cb=None, cancel_cb=None):
'''Start a queue consumer.
Accepts the following optional arg in addition to those of
`BasicClass.consume()`:
... | [
"def",
"consume",
"(",
"self",
",",
"queue",
",",
"consumer",
",",
"consumer_tag",
"=",
"''",
",",
"no_local",
"=",
"False",
",",
"no_ack",
"=",
"True",
",",
"exclusive",
"=",
"False",
",",
"nowait",
"=",
"True",
",",
"ticket",
"=",
"None",
",",
"cb"... | Start a queue consumer.
Accepts the following optional arg in addition to those of
`BasicClass.consume()`:
:param cancel_cb: a callable to be called when the broker cancels the
consumer; e.g., when the consumer's queue is deleted. See
www.rabbitmq.com/consumer-cancel.html.
... | [
"Start",
"a",
"queue",
"consumer",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connections/rabbit_connection.py#L240-L266 |
agoragames/haigha | haigha/connections/rabbit_connection.py | RabbitBasicClass.cancel | def cancel(self, consumer_tag='', nowait=True, consumer=None, cb=None):
'''
Cancel a consumer. Can choose to delete based on a consumer tag or
the function which is consuming. If deleting by function, take care
to only use a consumer once per channel.
'''
# Remove the co... | python | def cancel(self, consumer_tag='', nowait=True, consumer=None, cb=None):
'''
Cancel a consumer. Can choose to delete based on a consumer tag or
the function which is consuming. If deleting by function, take care
to only use a consumer once per channel.
'''
# Remove the co... | [
"def",
"cancel",
"(",
"self",
",",
"consumer_tag",
"=",
"''",
",",
"nowait",
"=",
"True",
",",
"consumer",
"=",
"None",
",",
"cb",
"=",
"None",
")",
":",
"# Remove the consumer's broker-cancel callback entry",
"if",
"consumer",
":",
"tag",
"=",
"self",
".",
... | Cancel a consumer. Can choose to delete based on a consumer tag or
the function which is consuming. If deleting by function, take care
to only use a consumer once per channel. | [
"Cancel",
"a",
"consumer",
".",
"Can",
"choose",
"to",
"delete",
"based",
"on",
"a",
"consumer",
"tag",
"or",
"the",
"function",
"which",
"is",
"consuming",
".",
"If",
"deleting",
"by",
"function",
"take",
"care",
"to",
"only",
"use",
"a",
"consumer",
"o... | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connections/rabbit_connection.py#L268-L288 |
agoragames/haigha | haigha/connections/rabbit_connection.py | RabbitBasicClass._recv_cancel | def _recv_cancel(self, method_frame):
'''Handle Basic.Cancel from broker
:param MethodFrame method_frame: Basic.Cancel method frame from broker
'''
self.logger.warning("consumer cancelled by broker: %r", method_frame)
consumer_tag = method_frame.args.read_shortstr()
# ... | python | def _recv_cancel(self, method_frame):
'''Handle Basic.Cancel from broker
:param MethodFrame method_frame: Basic.Cancel method frame from broker
'''
self.logger.warning("consumer cancelled by broker: %r", method_frame)
consumer_tag = method_frame.args.read_shortstr()
# ... | [
"def",
"_recv_cancel",
"(",
"self",
",",
"method_frame",
")",
":",
"self",
".",
"logger",
".",
"warning",
"(",
"\"consumer cancelled by broker: %r\"",
",",
"method_frame",
")",
"consumer_tag",
"=",
"method_frame",
".",
"args",
".",
"read_shortstr",
"(",
")",
"# ... | Handle Basic.Cancel from broker
:param MethodFrame method_frame: Basic.Cancel method frame from broker | [
"Handle",
"Basic",
".",
"Cancel",
"from",
"broker"
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connections/rabbit_connection.py#L290-L316 |
agoragames/haigha | haigha/connections/rabbit_connection.py | RabbitConfirmClass.select | def select(self, nowait=True, cb=None):
'''
Set this channel to use publisher confirmations.
'''
nowait = nowait and self.allow_nowait() and not cb
if not self._enabled:
self._enabled = True
self.channel.basic._msg_id = 0
self.channel.basic._l... | python | def select(self, nowait=True, cb=None):
'''
Set this channel to use publisher confirmations.
'''
nowait = nowait and self.allow_nowait() and not cb
if not self._enabled:
self._enabled = True
self.channel.basic._msg_id = 0
self.channel.basic._l... | [
"def",
"select",
"(",
"self",
",",
"nowait",
"=",
"True",
",",
"cb",
"=",
"None",
")",
":",
"nowait",
"=",
"nowait",
"and",
"self",
".",
"allow_nowait",
"(",
")",
"and",
"not",
"cb",
"if",
"not",
"self",
".",
"_enabled",
":",
"self",
".",
"_enabled... | Set this channel to use publisher confirmations. | [
"Set",
"this",
"channel",
"to",
"use",
"publisher",
"confirmations",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connections/rabbit_connection.py#L338-L355 |
agoragames/haigha | haigha/channel.py | Channel.close | def close(self, reply_code=0, reply_text='', class_id=0, method_id=0):
'''
Close this channel. Routes to channel.close.
'''
# In the off chance that we call this twice. A good example is if
# there's an error in close listeners and so we're still inside a
# single call t... | python | def close(self, reply_code=0, reply_text='', class_id=0, method_id=0):
'''
Close this channel. Routes to channel.close.
'''
# In the off chance that we call this twice. A good example is if
# there's an error in close listeners and so we're still inside a
# single call t... | [
"def",
"close",
"(",
"self",
",",
"reply_code",
"=",
"0",
",",
"reply_text",
"=",
"''",
",",
"class_id",
"=",
"0",
",",
"method_id",
"=",
"0",
")",
":",
"# In the off chance that we call this twice. A good example is if",
"# there's an error in close listeners and so we... | Close this channel. Routes to channel.close. | [
"Close",
"this",
"channel",
".",
"Routes",
"to",
"channel",
".",
"close",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/channel.py#L187-L196 |
agoragames/haigha | haigha/channel.py | Channel.publish_synchronous | def publish_synchronous(self, *args, **kwargs):
'''
Helper for publishing a message using transactions. If 'cb' keyword
arg is supplied, will be called when the transaction is committed.
'''
cb = kwargs.pop('cb', None)
self.tx.select()
self.basic.publish(*args, *... | python | def publish_synchronous(self, *args, **kwargs):
'''
Helper for publishing a message using transactions. If 'cb' keyword
arg is supplied, will be called when the transaction is committed.
'''
cb = kwargs.pop('cb', None)
self.tx.select()
self.basic.publish(*args, *... | [
"def",
"publish_synchronous",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"cb",
"=",
"kwargs",
".",
"pop",
"(",
"'cb'",
",",
"None",
")",
"self",
".",
"tx",
".",
"select",
"(",
")",
"self",
".",
"basic",
".",
"publish",
"(",... | Helper for publishing a message using transactions. If 'cb' keyword
arg is supplied, will be called when the transaction is committed. | [
"Helper",
"for",
"publishing",
"a",
"message",
"using",
"transactions",
".",
"If",
"cb",
"keyword",
"arg",
"is",
"supplied",
"will",
"be",
"called",
"when",
"the",
"transaction",
"is",
"committed",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/channel.py#L204-L212 |
agoragames/haigha | haigha/channel.py | Channel.dispatch | def dispatch(self, method_frame):
'''
Dispatch a method.
'''
klass = self._class_map.get(method_frame.class_id)
if klass:
klass.dispatch(method_frame)
else:
raise Channel.InvalidClass(
"class %d is not supported on channel %d",
... | python | def dispatch(self, method_frame):
'''
Dispatch a method.
'''
klass = self._class_map.get(method_frame.class_id)
if klass:
klass.dispatch(method_frame)
else:
raise Channel.InvalidClass(
"class %d is not supported on channel %d",
... | [
"def",
"dispatch",
"(",
"self",
",",
"method_frame",
")",
":",
"klass",
"=",
"self",
".",
"_class_map",
".",
"get",
"(",
"method_frame",
".",
"class_id",
")",
"if",
"klass",
":",
"klass",
".",
"dispatch",
"(",
"method_frame",
")",
"else",
":",
"raise",
... | Dispatch a method. | [
"Dispatch",
"a",
"method",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/channel.py#L214-L224 |
agoragames/haigha | haigha/channel.py | Channel.process_frames | def process_frames(self):
'''
Process the input buffer.
'''
while len(self._frame_buffer):
# It would make sense to call next_frame, but it's
# technically faster to repeat the code here.
frame = self._frame_buffer.popleft()
if self._emerg... | python | def process_frames(self):
'''
Process the input buffer.
'''
while len(self._frame_buffer):
# It would make sense to call next_frame, but it's
# technically faster to repeat the code here.
frame = self._frame_buffer.popleft()
if self._emerg... | [
"def",
"process_frames",
"(",
"self",
")",
":",
"while",
"len",
"(",
"self",
".",
"_frame_buffer",
")",
":",
"# It would make sense to call next_frame, but it's",
"# technically faster to repeat the code here.",
"frame",
"=",
"self",
".",
"_frame_buffer",
".",
"popleft",
... | Process the input buffer. | [
"Process",
"the",
"input",
"buffer",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/channel.py#L233-L285 |
agoragames/haigha | haigha/channel.py | Channel.send_frame | def send_frame(self, frame):
'''
Queue a frame for sending. Will send immediately if there are no
pending synchronous transactions on this connection.
'''
if self.closed:
if self.close_info and len(self.close_info['reply_text']) > 0:
raise ChannelClos... | python | def send_frame(self, frame):
'''
Queue a frame for sending. Will send immediately if there are no
pending synchronous transactions on this connection.
'''
if self.closed:
if self.close_info and len(self.close_info['reply_text']) > 0:
raise ChannelClos... | [
"def",
"send_frame",
"(",
"self",
",",
"frame",
")",
":",
"if",
"self",
".",
"closed",
":",
"if",
"self",
".",
"close_info",
"and",
"len",
"(",
"self",
".",
"close_info",
"[",
"'reply_text'",
"]",
")",
">",
"0",
":",
"raise",
"ChannelClosed",
"(",
"\... | Queue a frame for sending. Will send immediately if there are no
pending synchronous transactions on this connection. | [
"Queue",
"a",
"frame",
"for",
"sending",
".",
"Will",
"send",
"immediately",
"if",
"there",
"are",
"no",
"pending",
"synchronous",
"transactions",
"on",
"this",
"connection",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/channel.py#L304-L330 |
agoragames/haigha | haigha/channel.py | Channel.add_synchronous_cb | def add_synchronous_cb(self, cb):
'''
Add an expectation of a callback to release a synchronous transaction.
'''
if self.connection.synchronous or self._synchronous:
wrapper = SyncWrapper(cb)
self._pending_events.append(wrapper)
while wrapper._read:
... | python | def add_synchronous_cb(self, cb):
'''
Add an expectation of a callback to release a synchronous transaction.
'''
if self.connection.synchronous or self._synchronous:
wrapper = SyncWrapper(cb)
self._pending_events.append(wrapper)
while wrapper._read:
... | [
"def",
"add_synchronous_cb",
"(",
"self",
",",
"cb",
")",
":",
"if",
"self",
".",
"connection",
".",
"synchronous",
"or",
"self",
".",
"_synchronous",
":",
"wrapper",
"=",
"SyncWrapper",
"(",
"cb",
")",
"self",
".",
"_pending_events",
".",
"append",
"(",
... | Add an expectation of a callback to release a synchronous transaction. | [
"Add",
"an",
"expectation",
"of",
"a",
"callback",
"to",
"release",
"a",
"synchronous",
"transaction",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/channel.py#L332-L358 |
agoragames/haigha | haigha/channel.py | Channel.clear_synchronous_cb | def clear_synchronous_cb(self, cb):
'''
If the callback is the current expected callback, will clear it off the
stack. Else will raise in exception if there's an expectation but this
doesn't satisfy it.
'''
if len(self._pending_events):
ev = self._pending_eve... | python | def clear_synchronous_cb(self, cb):
'''
If the callback is the current expected callback, will clear it off the
stack. Else will raise in exception if there's an expectation but this
doesn't satisfy it.
'''
if len(self._pending_events):
ev = self._pending_eve... | [
"def",
"clear_synchronous_cb",
"(",
"self",
",",
"cb",
")",
":",
"if",
"len",
"(",
"self",
".",
"_pending_events",
")",
":",
"ev",
"=",
"self",
".",
"_pending_events",
"[",
"0",
"]",
"# We can't have a strict check using this simple mechanism,",
"# because we could ... | If the callback is the current expected callback, will clear it off the
stack. Else will raise in exception if there's an expectation but this
doesn't satisfy it. | [
"If",
"the",
"callback",
"is",
"the",
"current",
"expected",
"callback",
"will",
"clear",
"it",
"off",
"the",
"stack",
".",
"Else",
"will",
"raise",
"in",
"exception",
"if",
"there",
"s",
"an",
"expectation",
"but",
"this",
"doesn",
"t",
"satisfy",
"it",
... | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/channel.py#L360-L385 |
agoragames/haigha | haigha/channel.py | Channel._flush_pending_events | def _flush_pending_events(self):
'''
Send pending frames that are in the event queue.
'''
while len(self._pending_events) and \
isinstance(self._pending_events[0], Frame):
self._connection.send_frame(self._pending_events.popleft()) | python | def _flush_pending_events(self):
'''
Send pending frames that are in the event queue.
'''
while len(self._pending_events) and \
isinstance(self._pending_events[0], Frame):
self._connection.send_frame(self._pending_events.popleft()) | [
"def",
"_flush_pending_events",
"(",
"self",
")",
":",
"while",
"len",
"(",
"self",
".",
"_pending_events",
")",
"and",
"isinstance",
"(",
"self",
".",
"_pending_events",
"[",
"0",
"]",
",",
"Frame",
")",
":",
"self",
".",
"_connection",
".",
"send_frame",... | Send pending frames that are in the event queue. | [
"Send",
"pending",
"frames",
"that",
"are",
"in",
"the",
"event",
"queue",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/channel.py#L387-L393 |
agoragames/haigha | haigha/channel.py | Channel._closed_cb | def _closed_cb(self, final_frame=None):
'''
"Private" callback from the ChannelClass when a channel is closed. Only
called after broker initiated close, or we receive a close_ok. Caller
has the option to send a final frame, to be used to bypass any
synchronous or otherwise-pendin... | python | def _closed_cb(self, final_frame=None):
'''
"Private" callback from the ChannelClass when a channel is closed. Only
called after broker initiated close, or we receive a close_ok. Caller
has the option to send a final frame, to be used to bypass any
synchronous or otherwise-pendin... | [
"def",
"_closed_cb",
"(",
"self",
",",
"final_frame",
"=",
"None",
")",
":",
"# delete all pending data and send final frame if thre is one. note",
"# that it bypasses send_frame so that even if the closed state is set,",
"# the frame is published.",
"if",
"final_frame",
":",
"self",... | "Private" callback from the ChannelClass when a channel is closed. Only
called after broker initiated close, or we receive a close_ok. Caller
has the option to send a final frame, to be used to bypass any
synchronous or otherwise-pending frames so that the channel can be
cleanly closed. | [
"Private",
"callback",
"from",
"the",
"ChannelClass",
"when",
"a",
"channel",
"is",
"closed",
".",
"Only",
"called",
"after",
"broker",
"initiated",
"close",
"or",
"we",
"receive",
"a",
"close_ok",
".",
"Caller",
"has",
"the",
"option",
"to",
"send",
"a",
... | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/channel.py#L395-L421 |
agoragames/haigha | haigha/transports/gevent_transport.py | GeventTransport.connect | def connect(self, (host, port)):
'''
Connect using a host,port tuple
'''
super(GeventTransport, self).connect((host, port), klass=socket.socket) | python | def connect(self, (host, port)):
'''
Connect using a host,port tuple
'''
super(GeventTransport, self).connect((host, port), klass=socket.socket) | [
"def",
"connect",
"(",
"self",
",",
"(",
"host",
",",
"port",
")",
")",
":",
"super",
"(",
"GeventTransport",
",",
"self",
")",
".",
"connect",
"(",
"(",
"host",
",",
"port",
")",
",",
"klass",
"=",
"socket",
".",
"socket",
")"
] | Connect using a host,port tuple | [
"Connect",
"using",
"a",
"host",
"port",
"tuple"
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/transports/gevent_transport.py#L49-L53 |
agoragames/haigha | haigha/transports/gevent_transport.py | GeventTransport.read | def read(self, timeout=None):
'''
Read from the transport. If no data is available, should return None.
If timeout>0, will only block for `timeout` seconds.
'''
# If currently locked, another greenlet is trying to read, so yield
# control and then return none. Required if... | python | def read(self, timeout=None):
'''
Read from the transport. If no data is available, should return None.
If timeout>0, will only block for `timeout` seconds.
'''
# If currently locked, another greenlet is trying to read, so yield
# control and then return none. Required if... | [
"def",
"read",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"# If currently locked, another greenlet is trying to read, so yield",
"# control and then return none. Required if a Connection is configured",
"# to be synchronous, a sync callback is trying to read, and there's",
"# anot... | Read from the transport. If no data is available, should return None.
If timeout>0, will only block for `timeout` seconds. | [
"Read",
"from",
"the",
"transport",
".",
"If",
"no",
"data",
"is",
"available",
"should",
"return",
"None",
".",
"If",
"timeout",
">",
"0",
"will",
"only",
"block",
"for",
"timeout",
"seconds",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/transports/gevent_transport.py#L55-L80 |
agoragames/haigha | haigha/transports/gevent_transport.py | GeventTransport.buffer | def buffer(self, data):
'''
Buffer unused bytes from the input stream.
'''
self._read_lock.acquire()
try:
return super(GeventTransport, self).buffer(data)
finally:
self._read_lock.release() | python | def buffer(self, data):
'''
Buffer unused bytes from the input stream.
'''
self._read_lock.acquire()
try:
return super(GeventTransport, self).buffer(data)
finally:
self._read_lock.release() | [
"def",
"buffer",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"_read_lock",
".",
"acquire",
"(",
")",
"try",
":",
"return",
"super",
"(",
"GeventTransport",
",",
"self",
")",
".",
"buffer",
"(",
"data",
")",
"finally",
":",
"self",
".",
"_read_lo... | Buffer unused bytes from the input stream. | [
"Buffer",
"unused",
"bytes",
"from",
"the",
"input",
"stream",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/transports/gevent_transport.py#L82-L90 |
agoragames/haigha | haigha/transports/gevent_transport.py | GeventTransport.write | def write(self, data):
'''
Write some bytes to the transport.
'''
# MUST use a lock here else gevent could raise an exception if 2
# greenlets try to write at the same time. I was hoping that
# sendall() would do that blocking for me, but I guess not. May
# requir... | python | def write(self, data):
'''
Write some bytes to the transport.
'''
# MUST use a lock here else gevent could raise an exception if 2
# greenlets try to write at the same time. I was hoping that
# sendall() would do that blocking for me, but I guess not. May
# requir... | [
"def",
"write",
"(",
"self",
",",
"data",
")",
":",
"# MUST use a lock here else gevent could raise an exception if 2",
"# greenlets try to write at the same time. I was hoping that",
"# sendall() would do that blocking for me, but I guess not. May",
"# require an eventsocket-like buffer to sp... | Write some bytes to the transport. | [
"Write",
"some",
"bytes",
"to",
"the",
"transport",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/transports/gevent_transport.py#L92-L104 |
agoragames/haigha | haigha/transports/gevent_transport.py | GeventPoolTransport.process_channels | def process_channels(self, channels):
'''
Process a set of channels by calling Channel.process_frames() on each.
Some transports may choose to do this in unique ways, such as through
a pool of threads.
The default implementation will simply iterate over them and call
pro... | python | def process_channels(self, channels):
'''
Process a set of channels by calling Channel.process_frames() on each.
Some transports may choose to do this in unique ways, such as through
a pool of threads.
The default implementation will simply iterate over them and call
pro... | [
"def",
"process_channels",
"(",
"self",
",",
"channels",
")",
":",
"for",
"channel",
"in",
"channels",
":",
"self",
".",
"_pool",
".",
"spawn",
"(",
"channel",
".",
"process_frames",
")"
] | Process a set of channels by calling Channel.process_frames() on each.
Some transports may choose to do this in unique ways, such as through
a pool of threads.
The default implementation will simply iterate over them and call
process_frames() on each. | [
"Process",
"a",
"set",
"of",
"channels",
"by",
"calling",
"Channel",
".",
"process_frames",
"()",
"on",
"each",
".",
"Some",
"transports",
"may",
"choose",
"to",
"do",
"this",
"in",
"unique",
"ways",
"such",
"as",
"through",
"a",
"pool",
"of",
"threads",
... | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/transports/gevent_transport.py#L121-L131 |
agoragames/haigha | haigha/classes/protocol_class.py | ProtocolClass.dispatch | def dispatch(self, method_frame):
'''
Dispatch a method for this protocol.
'''
method = self.dispatch_map.get(method_frame.method_id)
if method:
callback = self.channel.clear_synchronous_cb(method)
callback(method_frame)
else:
raise sel... | python | def dispatch(self, method_frame):
'''
Dispatch a method for this protocol.
'''
method = self.dispatch_map.get(method_frame.method_id)
if method:
callback = self.channel.clear_synchronous_cb(method)
callback(method_frame)
else:
raise sel... | [
"def",
"dispatch",
"(",
"self",
",",
"method_frame",
")",
":",
"method",
"=",
"self",
".",
"dispatch_map",
".",
"get",
"(",
"method_frame",
".",
"method_id",
")",
"if",
"method",
":",
"callback",
"=",
"self",
".",
"channel",
".",
"clear_synchronous_cb",
"(... | Dispatch a method for this protocol. | [
"Dispatch",
"a",
"method",
"for",
"this",
"protocol",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/protocol_class.py#L73-L83 |
agoragames/haigha | haigha/reader.py | Reader.seek | def seek(self, offset, whence=0):
'''
Simple seek. Follows standard interface.
'''
if whence == 0:
self._pos = self._start_pos + offset
elif whence == 1:
self._pos += offset
else:
self._pos = (self._end_pos - 1) + offset | python | def seek(self, offset, whence=0):
'''
Simple seek. Follows standard interface.
'''
if whence == 0:
self._pos = self._start_pos + offset
elif whence == 1:
self._pos += offset
else:
self._pos = (self._end_pos - 1) + offset | [
"def",
"seek",
"(",
"self",
",",
"offset",
",",
"whence",
"=",
"0",
")",
":",
"if",
"whence",
"==",
"0",
":",
"self",
".",
"_pos",
"=",
"self",
".",
"_start_pos",
"+",
"offset",
"elif",
"whence",
"==",
"1",
":",
"self",
".",
"_pos",
"+=",
"offset... | Simple seek. Follows standard interface. | [
"Simple",
"seek",
".",
"Follows",
"standard",
"interface",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/reader.py#L65-L74 |
agoragames/haigha | haigha/reader.py | Reader._check_underflow | def _check_underflow(self, n):
'''
Raise BufferUnderflow if there's not enough bytes to satisfy
the request.
'''
if self._pos + n > self._end_pos:
raise self.BufferUnderflow() | python | def _check_underflow(self, n):
'''
Raise BufferUnderflow if there's not enough bytes to satisfy
the request.
'''
if self._pos + n > self._end_pos:
raise self.BufferUnderflow() | [
"def",
"_check_underflow",
"(",
"self",
",",
"n",
")",
":",
"if",
"self",
".",
"_pos",
"+",
"n",
">",
"self",
".",
"_end_pos",
":",
"raise",
"self",
".",
"BufferUnderflow",
"(",
")"
] | Raise BufferUnderflow if there's not enough bytes to satisfy
the request. | [
"Raise",
"BufferUnderflow",
"if",
"there",
"s",
"not",
"enough",
"bytes",
"to",
"satisfy",
"the",
"request",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/reader.py#L76-L82 |
agoragames/haigha | haigha/reader.py | Reader.buffer | def buffer(self):
'''
Get a copy of the buffer that this is reading from. Returns a
buffer object
'''
return buffer(self._input, self._start_pos,
(self._end_pos - self._start_pos)) | python | def buffer(self):
'''
Get a copy of the buffer that this is reading from. Returns a
buffer object
'''
return buffer(self._input, self._start_pos,
(self._end_pos - self._start_pos)) | [
"def",
"buffer",
"(",
"self",
")",
":",
"return",
"buffer",
"(",
"self",
".",
"_input",
",",
"self",
".",
"_start_pos",
",",
"(",
"self",
".",
"_end_pos",
"-",
"self",
".",
"_start_pos",
")",
")"
] | Get a copy of the buffer that this is reading from. Returns a
buffer object | [
"Get",
"a",
"copy",
"of",
"the",
"buffer",
"that",
"this",
"is",
"reading",
"from",
".",
"Returns",
"a",
"buffer",
"object"
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/reader.py#L90-L96 |
agoragames/haigha | haigha/reader.py | Reader.read | def read(self, n):
"""
Read n bytes.
Will raise BufferUnderflow if there's not enough bytes in the buffer.
"""
self._check_underflow(n)
rval = self._input[self._pos:self._pos + n]
self._pos += n
return rval | python | def read(self, n):
"""
Read n bytes.
Will raise BufferUnderflow if there's not enough bytes in the buffer.
"""
self._check_underflow(n)
rval = self._input[self._pos:self._pos + n]
self._pos += n
return rval | [
"def",
"read",
"(",
"self",
",",
"n",
")",
":",
"self",
".",
"_check_underflow",
"(",
"n",
")",
"rval",
"=",
"self",
".",
"_input",
"[",
"self",
".",
"_pos",
":",
"self",
".",
"_pos",
"+",
"n",
"]",
"self",
".",
"_pos",
"+=",
"n",
"return",
"rv... | Read n bytes.
Will raise BufferUnderflow if there's not enough bytes in the buffer. | [
"Read",
"n",
"bytes",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/reader.py#L98-L107 |
agoragames/haigha | haigha/reader.py | Reader.read_bit | def read_bit(self):
"""
Read a single boolean value, returns 0 or 1. Convience for single
bit fields.
Will raise BufferUnderflow if there's not enough bytes in the buffer.
"""
# Perform a faster check on underflow
if self._pos >= self._end_pos:
raise ... | python | def read_bit(self):
"""
Read a single boolean value, returns 0 or 1. Convience for single
bit fields.
Will raise BufferUnderflow if there's not enough bytes in the buffer.
"""
# Perform a faster check on underflow
if self._pos >= self._end_pos:
raise ... | [
"def",
"read_bit",
"(",
"self",
")",
":",
"# Perform a faster check on underflow",
"if",
"self",
".",
"_pos",
">=",
"self",
".",
"_end_pos",
":",
"raise",
"self",
".",
"BufferUnderflow",
"(",
")",
"result",
"=",
"ord",
"(",
"self",
".",
"_input",
"[",
"sel... | Read a single boolean value, returns 0 or 1. Convience for single
bit fields.
Will raise BufferUnderflow if there's not enough bytes in the buffer. | [
"Read",
"a",
"single",
"boolean",
"value",
"returns",
"0",
"or",
"1",
".",
"Convience",
"for",
"single",
"bit",
"fields",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/reader.py#L109-L121 |
agoragames/haigha | haigha/reader.py | Reader.read_bits | def read_bits(self, num):
'''
Read several bits packed into the same field. Will return as a list.
The bit field itself is little-endian, though the order of the
returned array looks big-endian for ease of decomposition.
Reader('\x02').read_bits(2) -> [False,True]
Reader... | python | def read_bits(self, num):
'''
Read several bits packed into the same field. Will return as a list.
The bit field itself is little-endian, though the order of the
returned array looks big-endian for ease of decomposition.
Reader('\x02').read_bits(2) -> [False,True]
Reader... | [
"def",
"read_bits",
"(",
"self",
",",
"num",
")",
":",
"# Perform a faster check on underflow",
"if",
"self",
".",
"_pos",
">=",
"self",
".",
"_end_pos",
":",
"raise",
"self",
".",
"BufferUnderflow",
"(",
")",
"if",
"num",
"<",
"0",
"or",
"num",
">=",
"9... | Read several bits packed into the same field. Will return as a list.
The bit field itself is little-endian, though the order of the
returned array looks big-endian for ease of decomposition.
Reader('\x02').read_bits(2) -> [False,True]
Reader('\x08').read_bits(2) ->
[False,Tr... | [
"Read",
"several",
"bits",
"packed",
"into",
"the",
"same",
"field",
".",
"Will",
"return",
"as",
"a",
"list",
".",
"The",
"bit",
"field",
"itself",
"is",
"little",
"-",
"endian",
"though",
"the",
"order",
"of",
"the",
"returned",
"array",
"looks",
"big"... | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/reader.py#L123-L145 |
agoragames/haigha | haigha/reader.py | Reader.read_octet | def read_octet(self, unpacker=Struct('B').unpack_from,
size=Struct('B').size):
"""
Read one byte, return as an integer
Will raise BufferUnderflow if there's not enough bytes in the buffer.
Will raise struct.error if the data is malformed
"""
# Technica... | python | def read_octet(self, unpacker=Struct('B').unpack_from,
size=Struct('B').size):
"""
Read one byte, return as an integer
Will raise BufferUnderflow if there's not enough bytes in the buffer.
Will raise struct.error if the data is malformed
"""
# Technica... | [
"def",
"read_octet",
"(",
"self",
",",
"unpacker",
"=",
"Struct",
"(",
"'B'",
")",
".",
"unpack_from",
",",
"size",
"=",
"Struct",
"(",
"'B'",
")",
".",
"size",
")",
":",
"# Technically should look at unpacker.size, but skipping that is way",
"# faster and this meth... | Read one byte, return as an integer
Will raise BufferUnderflow if there's not enough bytes in the buffer.
Will raise struct.error if the data is malformed | [
"Read",
"one",
"byte",
"return",
"as",
"an",
"integer"
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/reader.py#L147-L161 |
agoragames/haigha | haigha/reader.py | Reader.read_short | def read_short(self, unpacker=Struct('>H').unpack_from,
size=Struct('>H').size):
"""
Read an unsigned 16-bit integer
Will raise BufferUnderflow if there's not enough bytes in the buffer.
Will raise struct.error if the data is malformed
"""
self._check_... | python | def read_short(self, unpacker=Struct('>H').unpack_from,
size=Struct('>H').size):
"""
Read an unsigned 16-bit integer
Will raise BufferUnderflow if there's not enough bytes in the buffer.
Will raise struct.error if the data is malformed
"""
self._check_... | [
"def",
"read_short",
"(",
"self",
",",
"unpacker",
"=",
"Struct",
"(",
"'>H'",
")",
".",
"unpack_from",
",",
"size",
"=",
"Struct",
"(",
"'>H'",
")",
".",
"size",
")",
":",
"self",
".",
"_check_underflow",
"(",
"size",
")",
"rval",
"=",
"unpacker",
"... | Read an unsigned 16-bit integer
Will raise BufferUnderflow if there's not enough bytes in the buffer.
Will raise struct.error if the data is malformed | [
"Read",
"an",
"unsigned",
"16",
"-",
"bit",
"integer"
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/reader.py#L163-L174 |
agoragames/haigha | haigha/reader.py | Reader.read_table | def read_table(self):
"""
Read an AMQP table, and return as a Python dictionary.
Will raise BufferUnderflow if there's not enough bytes in the buffer.
Will raise UnicodeDecodeError if the text is mal-formed.
Will raise struct.error if the data is malformed
"""
# ... | python | def read_table(self):
"""
Read an AMQP table, and return as a Python dictionary.
Will raise BufferUnderflow if there's not enough bytes in the buffer.
Will raise UnicodeDecodeError if the text is mal-formed.
Will raise struct.error if the data is malformed
"""
# ... | [
"def",
"read_table",
"(",
"self",
")",
":",
"# Only need to check underflow on the table once",
"tlen",
"=",
"self",
".",
"read_long",
"(",
")",
"self",
".",
"_check_underflow",
"(",
"tlen",
")",
"end_pos",
"=",
"self",
".",
"_pos",
"+",
"tlen",
"result",
"=",... | Read an AMQP table, and return as a Python dictionary.
Will raise BufferUnderflow if there's not enough bytes in the buffer.
Will raise UnicodeDecodeError if the text is mal-formed.
Will raise struct.error if the data is malformed | [
"Read",
"an",
"AMQP",
"table",
"and",
"return",
"as",
"a",
"Python",
"dictionary",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/reader.py#L237-L253 |
agoragames/haigha | haigha/reader.py | Reader._read_field | def _read_field(self):
'''
Read a single byte for field type, then read the value.
'''
ftype = self._input[self._pos]
self._pos += 1
reader = self.field_type_map.get(ftype)
if reader:
return reader(self)
raise Reader.FieldError('Unknown field... | python | def _read_field(self):
'''
Read a single byte for field type, then read the value.
'''
ftype = self._input[self._pos]
self._pos += 1
reader = self.field_type_map.get(ftype)
if reader:
return reader(self)
raise Reader.FieldError('Unknown field... | [
"def",
"_read_field",
"(",
"self",
")",
":",
"ftype",
"=",
"self",
".",
"_input",
"[",
"self",
".",
"_pos",
"]",
"self",
".",
"_pos",
"+=",
"1",
"reader",
"=",
"self",
".",
"field_type_map",
".",
"get",
"(",
"ftype",
")",
"if",
"reader",
":",
"retu... | Read a single byte for field type, then read the value. | [
"Read",
"a",
"single",
"byte",
"for",
"field",
"type",
"then",
"read",
"the",
"value",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/reader.py#L255-L266 |
agoragames/haigha | haigha/classes/channel_class.py | ChannelClass.open | def open(self):
'''
Open the channel for communication.
'''
args = Writer()
args.write_shortstr('')
self.send_frame(MethodFrame(self.channel_id, 20, 10, args))
self.channel.add_synchronous_cb(self._recv_open_ok) | python | def open(self):
'''
Open the channel for communication.
'''
args = Writer()
args.write_shortstr('')
self.send_frame(MethodFrame(self.channel_id, 20, 10, args))
self.channel.add_synchronous_cb(self._recv_open_ok) | [
"def",
"open",
"(",
"self",
")",
":",
"args",
"=",
"Writer",
"(",
")",
"args",
".",
"write_shortstr",
"(",
"''",
")",
"self",
".",
"send_frame",
"(",
"MethodFrame",
"(",
"self",
".",
"channel_id",
",",
"20",
",",
"10",
",",
"args",
")",
")",
"self"... | Open the channel for communication. | [
"Open",
"the",
"channel",
"for",
"communication",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/channel_class.py#L47-L54 |
agoragames/haigha | haigha/classes/channel_class.py | ChannelClass._send_flow | def _send_flow(self, active):
'''
Send a flow control command.
'''
args = Writer()
args.write_bit(active)
self.send_frame(MethodFrame(self.channel_id, 20, 20, args))
self.channel.add_synchronous_cb(self._recv_flow_ok) | python | def _send_flow(self, active):
'''
Send a flow control command.
'''
args = Writer()
args.write_bit(active)
self.send_frame(MethodFrame(self.channel_id, 20, 20, args))
self.channel.add_synchronous_cb(self._recv_flow_ok) | [
"def",
"_send_flow",
"(",
"self",
",",
"active",
")",
":",
"args",
"=",
"Writer",
"(",
")",
"args",
".",
"write_bit",
"(",
"active",
")",
"self",
".",
"send_frame",
"(",
"MethodFrame",
"(",
"self",
".",
"channel_id",
",",
"20",
",",
"20",
",",
"args"... | Send a flow control command. | [
"Send",
"a",
"flow",
"control",
"command",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/channel_class.py#L76-L83 |
agoragames/haigha | haigha/classes/channel_class.py | ChannelClass._recv_flow | def _recv_flow(self, method_frame):
'''
Receive a flow control command from the broker
'''
self.channel._active = method_frame.args.read_bit()
args = Writer()
args.write_bit(self.channel.active)
self.send_frame(MethodFrame(self.channel_id, 20, 21, args))
... | python | def _recv_flow(self, method_frame):
'''
Receive a flow control command from the broker
'''
self.channel._active = method_frame.args.read_bit()
args = Writer()
args.write_bit(self.channel.active)
self.send_frame(MethodFrame(self.channel_id, 20, 21, args))
... | [
"def",
"_recv_flow",
"(",
"self",
",",
"method_frame",
")",
":",
"self",
".",
"channel",
".",
"_active",
"=",
"method_frame",
".",
"args",
".",
"read_bit",
"(",
")",
"args",
"=",
"Writer",
"(",
")",
"args",
".",
"write_bit",
"(",
"self",
".",
"channel"... | Receive a flow control command from the broker | [
"Receive",
"a",
"flow",
"control",
"command",
"from",
"the",
"broker"
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/channel_class.py#L85-L96 |
agoragames/haigha | haigha/classes/channel_class.py | ChannelClass._recv_flow_ok | def _recv_flow_ok(self, method_frame):
'''
Receive a flow control ack from the broker.
'''
self.channel._active = method_frame.args.read_bit()
if self._flow_control_cb is not None:
self._flow_control_cb() | python | def _recv_flow_ok(self, method_frame):
'''
Receive a flow control ack from the broker.
'''
self.channel._active = method_frame.args.read_bit()
if self._flow_control_cb is not None:
self._flow_control_cb() | [
"def",
"_recv_flow_ok",
"(",
"self",
",",
"method_frame",
")",
":",
"self",
".",
"channel",
".",
"_active",
"=",
"method_frame",
".",
"args",
".",
"read_bit",
"(",
")",
"if",
"self",
".",
"_flow_control_cb",
"is",
"not",
"None",
":",
"self",
".",
"_flow_... | Receive a flow control ack from the broker. | [
"Receive",
"a",
"flow",
"control",
"ack",
"from",
"the",
"broker",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/channel_class.py#L98-L104 |
agoragames/haigha | haigha/classes/channel_class.py | ChannelClass.close | def close(self, reply_code=0, reply_text='', class_id=0, method_id=0):
'''
Close this channel. Caller has the option of specifying the reason for
closure and the class and method ids of the current frame in which an
error occurred. If in the event of an exception, the channel will be
... | python | def close(self, reply_code=0, reply_text='', class_id=0, method_id=0):
'''
Close this channel. Caller has the option of specifying the reason for
closure and the class and method ids of the current frame in which an
error occurred. If in the event of an exception, the channel will be
... | [
"def",
"close",
"(",
"self",
",",
"reply_code",
"=",
"0",
",",
"reply_text",
"=",
"''",
",",
"class_id",
"=",
"0",
",",
"method_id",
"=",
"0",
")",
":",
"if",
"not",
"getattr",
"(",
"self",
",",
"'channel'",
",",
"None",
")",
"or",
"self",
".",
"... | Close this channel. Caller has the option of specifying the reason for
closure and the class and method ids of the current frame in which an
error occurred. If in the event of an exception, the channel will be
marked as immediately closed. If channel is already closed, call is
ignored... | [
"Close",
"this",
"channel",
".",
"Caller",
"has",
"the",
"option",
"of",
"specifying",
"the",
"reason",
"for",
"closure",
"and",
"the",
"class",
"and",
"method",
"ids",
"of",
"the",
"current",
"frame",
"in",
"which",
"an",
"error",
"occurred",
".",
"If",
... | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/channel_class.py#L106-L141 |
agoragames/haigha | haigha/classes/channel_class.py | ChannelClass._recv_close | def _recv_close(self, method_frame):
'''
Receive a close command from the broker.
'''
self.channel._close_info = {
'reply_code': method_frame.args.read_short(),
'reply_text': method_frame.args.read_shortstr(),
'class_id': method_frame.args.read_short()... | python | def _recv_close(self, method_frame):
'''
Receive a close command from the broker.
'''
self.channel._close_info = {
'reply_code': method_frame.args.read_short(),
'reply_text': method_frame.args.read_shortstr(),
'class_id': method_frame.args.read_short()... | [
"def",
"_recv_close",
"(",
"self",
",",
"method_frame",
")",
":",
"self",
".",
"channel",
".",
"_close_info",
"=",
"{",
"'reply_code'",
":",
"method_frame",
".",
"args",
".",
"read_short",
"(",
")",
",",
"'reply_text'",
":",
"method_frame",
".",
"args",
".... | Receive a close command from the broker. | [
"Receive",
"a",
"close",
"command",
"from",
"the",
"broker",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/channel_class.py#L143-L156 |
agoragames/haigha | haigha/classes/channel_class.py | ChannelClass._recv_close_ok | def _recv_close_ok(self, method_frame):
'''
Receive a close ack from the broker.
'''
self.channel._closed = True
self.channel._closed_cb() | python | def _recv_close_ok(self, method_frame):
'''
Receive a close ack from the broker.
'''
self.channel._closed = True
self.channel._closed_cb() | [
"def",
"_recv_close_ok",
"(",
"self",
",",
"method_frame",
")",
":",
"self",
".",
"channel",
".",
"_closed",
"=",
"True",
"self",
".",
"channel",
".",
"_closed_cb",
"(",
")"
] | Receive a close ack from the broker. | [
"Receive",
"a",
"close",
"ack",
"from",
"the",
"broker",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/channel_class.py#L158-L163 |
agoragames/haigha | haigha/classes/queue_class.py | QueueClass._cleanup | def _cleanup(self):
'''
Cleanup all the local data.
'''
self._declare_cb = None
self._bind_cb = None
self._unbind_cb = None
self._delete_cb = None
self._purge_cb = None
super(QueueClass, self)._cleanup() | python | def _cleanup(self):
'''
Cleanup all the local data.
'''
self._declare_cb = None
self._bind_cb = None
self._unbind_cb = None
self._delete_cb = None
self._purge_cb = None
super(QueueClass, self)._cleanup() | [
"def",
"_cleanup",
"(",
"self",
")",
":",
"self",
".",
"_declare_cb",
"=",
"None",
"self",
".",
"_bind_cb",
"=",
"None",
"self",
".",
"_unbind_cb",
"=",
"None",
"self",
".",
"_delete_cb",
"=",
"None",
"self",
".",
"_purge_cb",
"=",
"None",
"super",
"("... | Cleanup all the local data. | [
"Cleanup",
"all",
"the",
"local",
"data",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/queue_class.py#L40-L49 |
agoragames/haigha | haigha/classes/queue_class.py | QueueClass.bind | def bind(self, queue, exchange, routing_key='', nowait=True, arguments={},
ticket=None, cb=None):
'''
bind to a queue.
'''
nowait = nowait and self.allow_nowait() and not cb
args = Writer()
args.write_short(ticket or self.default_ticket).\
write_... | python | def bind(self, queue, exchange, routing_key='', nowait=True, arguments={},
ticket=None, cb=None):
'''
bind to a queue.
'''
nowait = nowait and self.allow_nowait() and not cb
args = Writer()
args.write_short(ticket or self.default_ticket).\
write_... | [
"def",
"bind",
"(",
"self",
",",
"queue",
",",
"exchange",
",",
"routing_key",
"=",
"''",
",",
"nowait",
"=",
"True",
",",
"arguments",
"=",
"{",
"}",
",",
"ticket",
"=",
"None",
",",
"cb",
"=",
"None",
")",
":",
"nowait",
"=",
"nowait",
"and",
"... | bind to a queue. | [
"bind",
"to",
"a",
"queue",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/queue_class.py#L86-L104 |
agoragames/haigha | haigha/classes/queue_class.py | QueueClass.unbind | def unbind(self, queue, exchange, routing_key='', arguments={},
ticket=None, cb=None):
'''
Unbind a queue from an exchange. This is always synchronous.
'''
args = Writer()
args.write_short(ticket or self.default_ticket).\
write_shortstr(queue).\
... | python | def unbind(self, queue, exchange, routing_key='', arguments={},
ticket=None, cb=None):
'''
Unbind a queue from an exchange. This is always synchronous.
'''
args = Writer()
args.write_short(ticket or self.default_ticket).\
write_shortstr(queue).\
... | [
"def",
"unbind",
"(",
"self",
",",
"queue",
",",
"exchange",
",",
"routing_key",
"=",
"''",
",",
"arguments",
"=",
"{",
"}",
",",
"ticket",
"=",
"None",
",",
"cb",
"=",
"None",
")",
":",
"args",
"=",
"Writer",
"(",
")",
"args",
".",
"write_short",
... | Unbind a queue from an exchange. This is always synchronous. | [
"Unbind",
"a",
"queue",
"from",
"an",
"exchange",
".",
"This",
"is",
"always",
"synchronous",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/queue_class.py#L112-L126 |
agoragames/haigha | haigha/classes/queue_class.py | QueueClass.purge | def purge(self, queue, nowait=True, ticket=None, cb=None):
'''
Purge all messages in a queue.
'''
nowait = nowait and self.allow_nowait() and not cb
args = Writer()
args.write_short(ticket or self.default_ticket).\
write_shortstr(queue).\
write_bi... | python | def purge(self, queue, nowait=True, ticket=None, cb=None):
'''
Purge all messages in a queue.
'''
nowait = nowait and self.allow_nowait() and not cb
args = Writer()
args.write_short(ticket or self.default_ticket).\
write_shortstr(queue).\
write_bi... | [
"def",
"purge",
"(",
"self",
",",
"queue",
",",
"nowait",
"=",
"True",
",",
"ticket",
"=",
"None",
",",
"cb",
"=",
"None",
")",
":",
"nowait",
"=",
"nowait",
"and",
"self",
".",
"allow_nowait",
"(",
")",
"and",
"not",
"cb",
"args",
"=",
"Writer",
... | Purge all messages in a queue. | [
"Purge",
"all",
"messages",
"in",
"a",
"queue",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/classes/queue_class.py#L134-L148 |
agoragames/haigha | haigha/writer.py | Writer.write_bits | def write_bits(self, *args):
'''
Write multiple bits in a single byte field. The bits will be written in
little-endian order, but should be supplied in big endian order. Will
raise ValueError when more than 8 arguments are supplied.
write_bits(True, False) => 0x02
'''
... | python | def write_bits(self, *args):
'''
Write multiple bits in a single byte field. The bits will be written in
little-endian order, but should be supplied in big endian order. Will
raise ValueError when more than 8 arguments are supplied.
write_bits(True, False) => 0x02
'''
... | [
"def",
"write_bits",
"(",
"self",
",",
"*",
"args",
")",
":",
"# Would be nice to make this a bit smarter",
"if",
"len",
"(",
"args",
")",
">",
"8",
":",
"raise",
"ValueError",
"(",
"\"Can only write 8 bits at a time\"",
")",
"self",
".",
"_output_buffer",
".",
... | Write multiple bits in a single byte field. The bits will be written in
little-endian order, but should be supplied in big endian order. Will
raise ValueError when more than 8 arguments are supplied.
write_bits(True, False) => 0x02 | [
"Write",
"multiple",
"bits",
"in",
"a",
"single",
"byte",
"field",
".",
"The",
"bits",
"will",
"be",
"written",
"in",
"little",
"-",
"endian",
"order",
"but",
"should",
"be",
"supplied",
"in",
"big",
"endian",
"order",
".",
"Will",
"raise",
"ValueError",
... | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/writer.py#L52-L67 |
agoragames/haigha | haigha/writer.py | Writer.write_bit | def write_bit(self, b, pack=Struct('B').pack):
'''
Write a single bit. Convenience method for single bit args.
'''
self._output_buffer.append(pack(True if b else False))
return self | python | def write_bit(self, b, pack=Struct('B').pack):
'''
Write a single bit. Convenience method for single bit args.
'''
self._output_buffer.append(pack(True if b else False))
return self | [
"def",
"write_bit",
"(",
"self",
",",
"b",
",",
"pack",
"=",
"Struct",
"(",
"'B'",
")",
".",
"pack",
")",
":",
"self",
".",
"_output_buffer",
".",
"append",
"(",
"pack",
"(",
"True",
"if",
"b",
"else",
"False",
")",
")",
"return",
"self"
] | Write a single bit. Convenience method for single bit args. | [
"Write",
"a",
"single",
"bit",
".",
"Convenience",
"method",
"for",
"single",
"bit",
"args",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/writer.py#L69-L74 |
agoragames/haigha | haigha/writer.py | Writer.write_octet | def write_octet(self, n, pack=Struct('B').pack):
"""
Write an integer as an unsigned 8-bit value.
"""
if 0 <= n <= 255:
self._output_buffer.append(pack(n))
else:
raise ValueError('Octet %d out of range 0..255', n)
return self | python | def write_octet(self, n, pack=Struct('B').pack):
"""
Write an integer as an unsigned 8-bit value.
"""
if 0 <= n <= 255:
self._output_buffer.append(pack(n))
else:
raise ValueError('Octet %d out of range 0..255', n)
return self | [
"def",
"write_octet",
"(",
"self",
",",
"n",
",",
"pack",
"=",
"Struct",
"(",
"'B'",
")",
".",
"pack",
")",
":",
"if",
"0",
"<=",
"n",
"<=",
"255",
":",
"self",
".",
"_output_buffer",
".",
"append",
"(",
"pack",
"(",
"n",
")",
")",
"else",
":",... | Write an integer as an unsigned 8-bit value. | [
"Write",
"an",
"integer",
"as",
"an",
"unsigned",
"8",
"-",
"bit",
"value",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/writer.py#L76-L84 |
agoragames/haigha | haigha/writer.py | Writer.write_short | def write_short(self, n, pack=Struct('>H').pack):
"""
Write an integer as an unsigned 16-bit value.
"""
if 0 <= n <= 0xFFFF:
self._output_buffer.extend(pack(n))
else:
raise ValueError('Short %d out of range 0..0xFFFF', n)
return self | python | def write_short(self, n, pack=Struct('>H').pack):
"""
Write an integer as an unsigned 16-bit value.
"""
if 0 <= n <= 0xFFFF:
self._output_buffer.extend(pack(n))
else:
raise ValueError('Short %d out of range 0..0xFFFF', n)
return self | [
"def",
"write_short",
"(",
"self",
",",
"n",
",",
"pack",
"=",
"Struct",
"(",
"'>H'",
")",
".",
"pack",
")",
":",
"if",
"0",
"<=",
"n",
"<=",
"0xFFFF",
":",
"self",
".",
"_output_buffer",
".",
"extend",
"(",
"pack",
"(",
"n",
")",
")",
"else",
... | Write an integer as an unsigned 16-bit value. | [
"Write",
"an",
"integer",
"as",
"an",
"unsigned",
"16",
"-",
"bit",
"value",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/writer.py#L86-L94 |
agoragames/haigha | haigha/writer.py | Writer.write_short_at | def write_short_at(self, n, pos, pack_into=Struct('>H').pack_into):
'''
Write an unsigned 16bit value at a specific position in the buffer.
Used for writing tables and frames.
'''
if 0 <= n <= 0xFFFF:
pack_into(self._output_buffer, pos, n)
else:
ra... | python | def write_short_at(self, n, pos, pack_into=Struct('>H').pack_into):
'''
Write an unsigned 16bit value at a specific position in the buffer.
Used for writing tables and frames.
'''
if 0 <= n <= 0xFFFF:
pack_into(self._output_buffer, pos, n)
else:
ra... | [
"def",
"write_short_at",
"(",
"self",
",",
"n",
",",
"pos",
",",
"pack_into",
"=",
"Struct",
"(",
"'>H'",
")",
".",
"pack_into",
")",
":",
"if",
"0",
"<=",
"n",
"<=",
"0xFFFF",
":",
"pack_into",
"(",
"self",
".",
"_output_buffer",
",",
"pos",
",",
... | Write an unsigned 16bit value at a specific position in the buffer.
Used for writing tables and frames. | [
"Write",
"an",
"unsigned",
"16bit",
"value",
"at",
"a",
"specific",
"position",
"in",
"the",
"buffer",
".",
"Used",
"for",
"writing",
"tables",
"and",
"frames",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/writer.py#L96-L105 |
agoragames/haigha | haigha/writer.py | Writer.write_long | def write_long(self, n, pack=Struct('>I').pack):
"""
Write an integer as an unsigned 32-bit value.
"""
if 0 <= n <= 0xFFFFFFFF:
self._output_buffer.extend(pack(n))
else:
raise ValueError('Long %d out of range 0..0xFFFFFFFF', n)
return self | python | def write_long(self, n, pack=Struct('>I').pack):
"""
Write an integer as an unsigned 32-bit value.
"""
if 0 <= n <= 0xFFFFFFFF:
self._output_buffer.extend(pack(n))
else:
raise ValueError('Long %d out of range 0..0xFFFFFFFF', n)
return self | [
"def",
"write_long",
"(",
"self",
",",
"n",
",",
"pack",
"=",
"Struct",
"(",
"'>I'",
")",
".",
"pack",
")",
":",
"if",
"0",
"<=",
"n",
"<=",
"0xFFFFFFFF",
":",
"self",
".",
"_output_buffer",
".",
"extend",
"(",
"pack",
"(",
"n",
")",
")",
"else",... | Write an integer as an unsigned 32-bit value. | [
"Write",
"an",
"integer",
"as",
"an",
"unsigned",
"32",
"-",
"bit",
"value",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/writer.py#L107-L115 |
agoragames/haigha | haigha/writer.py | Writer.write_long_at | def write_long_at(self, n, pos, pack_into=Struct('>I').pack_into):
'''
Write an unsigned 32bit value at a specific position in the buffer.
Used for writing tables and frames.
'''
if 0 <= n <= 0xFFFFFFFF:
pack_into(self._output_buffer, pos, n)
else:
... | python | def write_long_at(self, n, pos, pack_into=Struct('>I').pack_into):
'''
Write an unsigned 32bit value at a specific position in the buffer.
Used for writing tables and frames.
'''
if 0 <= n <= 0xFFFFFFFF:
pack_into(self._output_buffer, pos, n)
else:
... | [
"def",
"write_long_at",
"(",
"self",
",",
"n",
",",
"pos",
",",
"pack_into",
"=",
"Struct",
"(",
"'>I'",
")",
".",
"pack_into",
")",
":",
"if",
"0",
"<=",
"n",
"<=",
"0xFFFFFFFF",
":",
"pack_into",
"(",
"self",
".",
"_output_buffer",
",",
"pos",
",",... | Write an unsigned 32bit value at a specific position in the buffer.
Used for writing tables and frames. | [
"Write",
"an",
"unsigned",
"32bit",
"value",
"at",
"a",
"specific",
"position",
"in",
"the",
"buffer",
".",
"Used",
"for",
"writing",
"tables",
"and",
"frames",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/writer.py#L117-L126 |
agoragames/haigha | haigha/writer.py | Writer.write_longlong | def write_longlong(self, n, pack=Struct('>Q').pack):
"""
Write an integer as an unsigned 64-bit value.
"""
if 0 <= n <= 0xFFFFFFFFFFFFFFFF:
self._output_buffer.extend(pack(n))
else:
raise ValueError(
'Longlong %d out of range 0..0xFFFFFFFFF... | python | def write_longlong(self, n, pack=Struct('>Q').pack):
"""
Write an integer as an unsigned 64-bit value.
"""
if 0 <= n <= 0xFFFFFFFFFFFFFFFF:
self._output_buffer.extend(pack(n))
else:
raise ValueError(
'Longlong %d out of range 0..0xFFFFFFFFF... | [
"def",
"write_longlong",
"(",
"self",
",",
"n",
",",
"pack",
"=",
"Struct",
"(",
"'>Q'",
")",
".",
"pack",
")",
":",
"if",
"0",
"<=",
"n",
"<=",
"0xFFFFFFFFFFFFFFFF",
":",
"self",
".",
"_output_buffer",
".",
"extend",
"(",
"pack",
"(",
"n",
")",
")... | Write an integer as an unsigned 64-bit value. | [
"Write",
"an",
"integer",
"as",
"an",
"unsigned",
"64",
"-",
"bit",
"value",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/writer.py#L128-L137 |
agoragames/haigha | haigha/writer.py | Writer.write_shortstr | def write_shortstr(self, s):
"""
Write a string up to 255 bytes long after encoding. If passed
a unicode string, encode as UTF-8.
"""
if isinstance(s, unicode):
s = s.encode('utf-8')
self.write_octet(len(s))
self.write(s)
return self | python | def write_shortstr(self, s):
"""
Write a string up to 255 bytes long after encoding. If passed
a unicode string, encode as UTF-8.
"""
if isinstance(s, unicode):
s = s.encode('utf-8')
self.write_octet(len(s))
self.write(s)
return self | [
"def",
"write_shortstr",
"(",
"self",
",",
"s",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"unicode",
")",
":",
"s",
"=",
"s",
".",
"encode",
"(",
"'utf-8'",
")",
"self",
".",
"write_octet",
"(",
"len",
"(",
"s",
")",
")",
"self",
".",
"write",... | Write a string up to 255 bytes long after encoding. If passed
a unicode string, encode as UTF-8. | [
"Write",
"a",
"string",
"up",
"to",
"255",
"bytes",
"long",
"after",
"encoding",
".",
"If",
"passed",
"a",
"unicode",
"string",
"encode",
"as",
"UTF",
"-",
"8",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/writer.py#L139-L148 |
agoragames/haigha | haigha/writer.py | Writer.write_timestamp | def write_timestamp(self, t, pack=Struct('>Q').pack):
"""
Write out a Python datetime.datetime object as a 64-bit integer
representing seconds since the Unix UTC epoch.
"""
# Double check timestamp, can't imagine why it would be signed
self._output_buffer.extend(pack(long... | python | def write_timestamp(self, t, pack=Struct('>Q').pack):
"""
Write out a Python datetime.datetime object as a 64-bit integer
representing seconds since the Unix UTC epoch.
"""
# Double check timestamp, can't imagine why it would be signed
self._output_buffer.extend(pack(long... | [
"def",
"write_timestamp",
"(",
"self",
",",
"t",
",",
"pack",
"=",
"Struct",
"(",
"'>Q'",
")",
".",
"pack",
")",
":",
"# Double check timestamp, can't imagine why it would be signed",
"self",
".",
"_output_buffer",
".",
"extend",
"(",
"pack",
"(",
"long",
"(",
... | Write out a Python datetime.datetime object as a 64-bit integer
representing seconds since the Unix UTC epoch. | [
"Write",
"out",
"a",
"Python",
"datetime",
".",
"datetime",
"object",
"as",
"a",
"64",
"-",
"bit",
"integer",
"representing",
"seconds",
"since",
"the",
"Unix",
"UTC",
"epoch",
"."
] | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/writer.py#L161-L168 |
agoragames/haigha | haigha/writer.py | Writer.write_table | def write_table(self, d):
"""
Write out a Python dictionary made of up string keys, and values
that are strings, signed integers, Decimal, datetime.datetime, or
sub-dictionaries following the same constraints.
"""
# HACK: encoding of AMQP tables is broken because it requi... | python | def write_table(self, d):
"""
Write out a Python dictionary made of up string keys, and values
that are strings, signed integers, Decimal, datetime.datetime, or
sub-dictionaries following the same constraints.
"""
# HACK: encoding of AMQP tables is broken because it requi... | [
"def",
"write_table",
"(",
"self",
",",
"d",
")",
":",
"# HACK: encoding of AMQP tables is broken because it requires the",
"# length of the /encoded/ data instead of the number of items. To",
"# support streaming, fiddle with cursor position, rewinding to write",
"# the real length of the dat... | Write out a Python dictionary made of up string keys, and values
that are strings, signed integers, Decimal, datetime.datetime, or
sub-dictionaries following the same constraints. | [
"Write",
"out",
"a",
"Python",
"dictionary",
"made",
"of",
"up",
"string",
"keys",
"and",
"values",
"that",
"are",
"strings",
"signed",
"integers",
"Decimal",
"datetime",
".",
"datetime",
"or",
"sub",
"-",
"dictionaries",
"following",
"the",
"same",
"constrain... | train | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/writer.py#L173-L195 |
chrippa/python-librtmp | librtmp/packet.py | RTMPPacket.body | def body(self):
"""The body of the packet."""
view = ffi.buffer(self.packet.m_body, self.packet.m_nBodySize)
return view[:] | python | def body(self):
"""The body of the packet."""
view = ffi.buffer(self.packet.m_body, self.packet.m_nBodySize)
return view[:] | [
"def",
"body",
"(",
"self",
")",
":",
"view",
"=",
"ffi",
".",
"buffer",
"(",
"self",
".",
"packet",
".",
"m_body",
",",
"self",
".",
"packet",
".",
"m_nBodySize",
")",
"return",
"view",
"[",
":",
"]"
] | The body of the packet. | [
"The",
"body",
"of",
"the",
"packet",
"."
] | train | https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/packet.py#L103-L107 |
chrippa/python-librtmp | librtmp/logging.py | add_log_callback | def add_log_callback(callback):
"""Adds a log callback."""
global _log_callbacks
if not callable(callback):
raise ValueError("Callback must be callable")
_log_callbacks.add(callback)
return callback | python | def add_log_callback(callback):
"""Adds a log callback."""
global _log_callbacks
if not callable(callback):
raise ValueError("Callback must be callable")
_log_callbacks.add(callback)
return callback | [
"def",
"add_log_callback",
"(",
"callback",
")",
":",
"global",
"_log_callbacks",
"if",
"not",
"callable",
"(",
"callback",
")",
":",
"raise",
"ValueError",
"(",
"\"Callback must be callable\"",
")",
"_log_callbacks",
".",
"add",
"(",
"callback",
")",
"return",
... | Adds a log callback. | [
"Adds",
"a",
"log",
"callback",
"."
] | train | https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/logging.py#L36-L44 |
chrippa/python-librtmp | librtmp/stream.py | RTMPStream.read | def read(self, size):
"""Attempts to read data from the stream.
:param size: int, The maximum amount of bytes to read.
Raises :exc:`IOError` on error.
"""
# If enabled tell the server that our buffer can fit the whole
# stream, this often increases throughput alot.
... | python | def read(self, size):
"""Attempts to read data from the stream.
:param size: int, The maximum amount of bytes to read.
Raises :exc:`IOError` on error.
"""
# If enabled tell the server that our buffer can fit the whole
# stream, this often increases throughput alot.
... | [
"def",
"read",
"(",
"self",
",",
"size",
")",
":",
"# If enabled tell the server that our buffer can fit the whole",
"# stream, this often increases throughput alot.",
"if",
"self",
".",
"_update_buffer",
"and",
"not",
"self",
".",
"_updated_buffer",
"and",
"self",
".",
"... | Attempts to read data from the stream.
:param size: int, The maximum amount of bytes to read.
Raises :exc:`IOError` on error. | [
"Attempts",
"to",
"read",
"data",
"from",
"the",
"stream",
"."
] | train | https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/stream.py#L21-L43 |
chrippa/python-librtmp | librtmp/stream.py | RTMPStream.write | def write(self, data):
"""Writes data to the stream.
:param data: bytes, FLV data to write to the stream
The data passed can contain multiple FLV tags, but it MUST
always contain complete tags or undefined behaviour might
occur.
Raises :exc:`IOError` on error.
... | python | def write(self, data):
"""Writes data to the stream.
:param data: bytes, FLV data to write to the stream
The data passed can contain multiple FLV tags, but it MUST
always contain complete tags or undefined behaviour might
occur.
Raises :exc:`IOError` on error.
... | [
"def",
"write",
"(",
"self",
",",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"bytearray",
")",
":",
"data",
"=",
"bytes",
"(",
"data",
")",
"if",
"not",
"isinstance",
"(",
"data",
",",
"byte_types",
")",
":",
"raise",
"ValueError",
"(",
... | Writes data to the stream.
:param data: bytes, FLV data to write to the stream
The data passed can contain multiple FLV tags, but it MUST
always contain complete tags or undefined behaviour might
occur.
Raises :exc:`IOError` on error. | [
"Writes",
"data",
"to",
"the",
"stream",
"."
] | train | https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/stream.py#L45-L67 |
chrippa/python-librtmp | librtmp/stream.py | RTMPStream.pause | def pause(self):
"""Pauses the stream."""
res = librtmp.RTMP_Pause(self.client.rtmp, 1)
if res < 1:
raise RTMPError("Failed to pause") | python | def pause(self):
"""Pauses the stream."""
res = librtmp.RTMP_Pause(self.client.rtmp, 1)
if res < 1:
raise RTMPError("Failed to pause") | [
"def",
"pause",
"(",
"self",
")",
":",
"res",
"=",
"librtmp",
".",
"RTMP_Pause",
"(",
"self",
".",
"client",
".",
"rtmp",
",",
"1",
")",
"if",
"res",
"<",
"1",
":",
"raise",
"RTMPError",
"(",
"\"Failed to pause\"",
")"
] | Pauses the stream. | [
"Pauses",
"the",
"stream",
"."
] | train | https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/stream.py#L69-L74 |
chrippa/python-librtmp | librtmp/stream.py | RTMPStream.unpause | def unpause(self):
"""Unpauses the stream."""
res = librtmp.RTMP_Pause(self.client.rtmp, 0)
if res < 1:
raise RTMPError("Failed to unpause") | python | def unpause(self):
"""Unpauses the stream."""
res = librtmp.RTMP_Pause(self.client.rtmp, 0)
if res < 1:
raise RTMPError("Failed to unpause") | [
"def",
"unpause",
"(",
"self",
")",
":",
"res",
"=",
"librtmp",
".",
"RTMP_Pause",
"(",
"self",
".",
"client",
".",
"rtmp",
",",
"0",
")",
"if",
"res",
"<",
"1",
":",
"raise",
"RTMPError",
"(",
"\"Failed to unpause\"",
")"
] | Unpauses the stream. | [
"Unpauses",
"the",
"stream",
"."
] | train | https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/stream.py#L76-L81 |
chrippa/python-librtmp | librtmp/stream.py | RTMPStream.seek | def seek(self, time):
"""Attempts to seek in the stream.
:param time: int, Time to seek to in seconds
"""
res = librtmp.RTMP_SendSeek(self.client.rtmp, time)
if res < 1:
raise RTMPError("Failed to seek") | python | def seek(self, time):
"""Attempts to seek in the stream.
:param time: int, Time to seek to in seconds
"""
res = librtmp.RTMP_SendSeek(self.client.rtmp, time)
if res < 1:
raise RTMPError("Failed to seek") | [
"def",
"seek",
"(",
"self",
",",
"time",
")",
":",
"res",
"=",
"librtmp",
".",
"RTMP_SendSeek",
"(",
"self",
".",
"client",
".",
"rtmp",
",",
"time",
")",
"if",
"res",
"<",
"1",
":",
"raise",
"RTMPError",
"(",
"\"Failed to seek\"",
")"
] | Attempts to seek in the stream.
:param time: int, Time to seek to in seconds | [
"Attempts",
"to",
"seek",
"in",
"the",
"stream",
"."
] | train | https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/stream.py#L83-L92 |
chrippa/python-librtmp | librtmp/stream.py | RTMPStream.close | def close(self):
"""Closes the connection."""
if not self._closed:
self._closed = True
self.client.close() | python | def close(self):
"""Closes the connection."""
if not self._closed:
self._closed = True
self.client.close() | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_closed",
":",
"self",
".",
"_closed",
"=",
"True",
"self",
".",
"client",
".",
"close",
"(",
")"
] | Closes the connection. | [
"Closes",
"the",
"connection",
"."
] | train | https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/stream.py#L94-L98 |
chrippa/python-librtmp | librtmp/stream.py | RTMPStream.update_buffer | def update_buffer(self, ms):
"""Tells the server how big our buffer is (in milliseconds)."""
librtmp.RTMP_SetBufferMS(self.client.rtmp, int(ms))
librtmp.RTMP_UpdateBufferMS(self.client.rtmp) | python | def update_buffer(self, ms):
"""Tells the server how big our buffer is (in milliseconds)."""
librtmp.RTMP_SetBufferMS(self.client.rtmp, int(ms))
librtmp.RTMP_UpdateBufferMS(self.client.rtmp) | [
"def",
"update_buffer",
"(",
"self",
",",
"ms",
")",
":",
"librtmp",
".",
"RTMP_SetBufferMS",
"(",
"self",
".",
"client",
".",
"rtmp",
",",
"int",
"(",
"ms",
")",
")",
"librtmp",
".",
"RTMP_UpdateBufferMS",
"(",
"self",
".",
"client",
".",
"rtmp",
")"
... | Tells the server how big our buffer is (in milliseconds). | [
"Tells",
"the",
"server",
"how",
"big",
"our",
"buffer",
"is",
"(",
"in",
"milliseconds",
")",
"."
] | train | https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/stream.py#L100-L103 |
chrippa/python-librtmp | librtmp/rtmp.py | RTMP.set_option | def set_option(self, key, value):
"""Sets a option for this session.
For a detailed list of available options see the librtmp(3) man page.
:param key: str, A valid option key.
:param value: A value, anything that can be converted to str is valid.
Raises :exc:`ValueError` if a ... | python | def set_option(self, key, value):
"""Sets a option for this session.
For a detailed list of available options see the librtmp(3) man page.
:param key: str, A valid option key.
:param value: A value, anything that can be converted to str is valid.
Raises :exc:`ValueError` if a ... | [
"def",
"set_option",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"akey",
"=",
"AVal",
"(",
"key",
")",
"aval",
"=",
"AVal",
"(",
"value",
")",
"res",
"=",
"librtmp",
".",
"RTMP_SetOpt",
"(",
"self",
".",
"rtmp",
",",
"akey",
".",
"aval",
","... | Sets a option for this session.
For a detailed list of available options see the librtmp(3) man page.
:param key: str, A valid option key.
:param value: A value, anything that can be converted to str is valid.
Raises :exc:`ValueError` if a invalid option is specified. | [
"Sets",
"a",
"option",
"for",
"this",
"session",
"."
] | train | https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/rtmp.py#L128-L148 |
chrippa/python-librtmp | librtmp/rtmp.py | RTMP.setup_url | def setup_url(self, url):
r"""Attempt to parse a RTMP URL.
Additional options may be specified by appending space-separated
key=value pairs to the URL. Special characters in values may need
to be escaped to prevent misinterpretation by the option parser.
The escape encoding uses... | python | def setup_url(self, url):
r"""Attempt to parse a RTMP URL.
Additional options may be specified by appending space-separated
key=value pairs to the URL. Special characters in values may need
to be escaped to prevent misinterpretation by the option parser.
The escape encoding uses... | [
"def",
"setup_url",
"(",
"self",
",",
"url",
")",
":",
"self",
".",
"url",
"=",
"bytes",
"(",
"url",
",",
"\"utf8\"",
")",
"res",
"=",
"librtmp",
".",
"RTMP_SetupURL",
"(",
"self",
".",
"rtmp",
",",
"self",
".",
"url",
")",
"if",
"res",
"<",
"1",... | r"""Attempt to parse a RTMP URL.
Additional options may be specified by appending space-separated
key=value pairs to the URL. Special characters in values may need
to be escaped to prevent misinterpretation by the option parser.
The escape encoding uses a backslash followed by two hexad... | [
"r",
"Attempt",
"to",
"parse",
"a",
"RTMP",
"URL",
"."
] | train | https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/rtmp.py#L150-L170 |
chrippa/python-librtmp | librtmp/rtmp.py | RTMP.connect | def connect(self, packet=None):
"""Connect to the server.
:param packet: RTMPPacket, this packet will be sent instead
of the regular "connect" packet.
Raises :exc:`RTMPError` if the connect attempt fails.
"""
if isinstance(packet, RTMPPacket):
... | python | def connect(self, packet=None):
"""Connect to the server.
:param packet: RTMPPacket, this packet will be sent instead
of the regular "connect" packet.
Raises :exc:`RTMPError` if the connect attempt fails.
"""
if isinstance(packet, RTMPPacket):
... | [
"def",
"connect",
"(",
"self",
",",
"packet",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"packet",
",",
"RTMPPacket",
")",
":",
"packet",
"=",
"packet",
".",
"packet",
"else",
":",
"packet",
"=",
"ffi",
".",
"NULL",
"res",
"=",
"librtmp",
".",
... | Connect to the server.
:param packet: RTMPPacket, this packet will be sent instead
of the regular "connect" packet.
Raises :exc:`RTMPError` if the connect attempt fails. | [
"Connect",
"to",
"the",
"server",
"."
] | train | https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/rtmp.py#L172-L191 |
chrippa/python-librtmp | librtmp/rtmp.py | RTMP.create_stream | def create_stream(self, seek=None, writeable=False, update_buffer=True):
"""Prepares the session for streaming of audio/video
and returns a :class:`RTMPStream` object.
:param seek: int, Attempt to seek to this position.
:param writeable: bool, Make the stream writeable instead of rea... | python | def create_stream(self, seek=None, writeable=False, update_buffer=True):
"""Prepares the session for streaming of audio/video
and returns a :class:`RTMPStream` object.
:param seek: int, Attempt to seek to this position.
:param writeable: bool, Make the stream writeable instead of rea... | [
"def",
"create_stream",
"(",
"self",
",",
"seek",
"=",
"None",
",",
"writeable",
"=",
"False",
",",
"update_buffer",
"=",
"True",
")",
":",
"if",
"writeable",
":",
"librtmp",
".",
"RTMP_EnableWrite",
"(",
"self",
".",
"rtmp",
")",
"# Calling handle_packet() ... | Prepares the session for streaming of audio/video
and returns a :class:`RTMPStream` object.
:param seek: int, Attempt to seek to this position.
:param writeable: bool, Make the stream writeable instead of readable.
:param update_buffer: bool, When enabled will attempt to speed up
... | [
"Prepares",
"the",
"session",
"for",
"streaming",
"of",
"audio",
"/",
"video",
"and",
"returns",
"a",
":",
"class",
":",
"RTMPStream",
"object",
"."
] | train | https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/rtmp.py#L193-L228 |
chrippa/python-librtmp | librtmp/rtmp.py | RTMP.read_packet | def read_packet(self):
"""Reads a RTMP packet from the server.
Returns a :class:`RTMPPacket`.
Raises :exc:`RTMPError` on error.
Raises :exc:`RTMPTimeoutError` on timeout.
Usage::
>>> packet = conn.read_packet()
>>> packet.body
b'packet body ...'
... | python | def read_packet(self):
"""Reads a RTMP packet from the server.
Returns a :class:`RTMPPacket`.
Raises :exc:`RTMPError` on error.
Raises :exc:`RTMPTimeoutError` on timeout.
Usage::
>>> packet = conn.read_packet()
>>> packet.body
b'packet body ...'
... | [
"def",
"read_packet",
"(",
"self",
")",
":",
"packet",
"=",
"ffi",
".",
"new",
"(",
"\"RTMPPacket*\"",
")",
"packet_complete",
"=",
"False",
"while",
"not",
"packet_complete",
":",
"res",
"=",
"librtmp",
".",
"RTMP_ReadPacket",
"(",
"self",
".",
"rtmp",
",... | Reads a RTMP packet from the server.
Returns a :class:`RTMPPacket`.
Raises :exc:`RTMPError` on error.
Raises :exc:`RTMPTimeoutError` on timeout.
Usage::
>>> packet = conn.read_packet()
>>> packet.body
b'packet body ...' | [
"Reads",
"a",
"RTMP",
"packet",
"from",
"the",
"server",
"."
] | train | https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/rtmp.py#L242-L271 |
chrippa/python-librtmp | librtmp/rtmp.py | RTMP.send_packet | def send_packet(self, packet, queue=True):
"""Sends a RTMP packet to the server.
:param packet: RTMPPacket, the packet to send to the server.
:param queue: bool, If True, queue up the packet in a internal queue rather
than sending it right away.
"""
if no... | python | def send_packet(self, packet, queue=True):
"""Sends a RTMP packet to the server.
:param packet: RTMPPacket, the packet to send to the server.
:param queue: bool, If True, queue up the packet in a internal queue rather
than sending it right away.
"""
if no... | [
"def",
"send_packet",
"(",
"self",
",",
"packet",
",",
"queue",
"=",
"True",
")",
":",
"if",
"not",
"isinstance",
"(",
"packet",
",",
"RTMPPacket",
")",
":",
"raise",
"ValueError",
"(",
"\"A RTMPPacket argument is required\"",
")",
"return",
"librtmp",
".",
... | Sends a RTMP packet to the server.
:param packet: RTMPPacket, the packet to send to the server.
:param queue: bool, If True, queue up the packet in a internal queue rather
than sending it right away. | [
"Sends",
"a",
"RTMP",
"packet",
"to",
"the",
"server",
"."
] | train | https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/rtmp.py#L273-L286 |
chrippa/python-librtmp | librtmp/rtmp.py | RTMP.handle_packet | def handle_packet(self, packet):
"""Lets librtmp look at a packet and send a response
if needed."""
if not isinstance(packet, RTMPPacket):
raise ValueError("A RTMPPacket argument is required")
return librtmp.RTMP_ClientPacket(self.rtmp, packet.packet) | python | def handle_packet(self, packet):
"""Lets librtmp look at a packet and send a response
if needed."""
if not isinstance(packet, RTMPPacket):
raise ValueError("A RTMPPacket argument is required")
return librtmp.RTMP_ClientPacket(self.rtmp, packet.packet) | [
"def",
"handle_packet",
"(",
"self",
",",
"packet",
")",
":",
"if",
"not",
"isinstance",
"(",
"packet",
",",
"RTMPPacket",
")",
":",
"raise",
"ValueError",
"(",
"\"A RTMPPacket argument is required\"",
")",
"return",
"librtmp",
".",
"RTMP_ClientPacket",
"(",
"se... | Lets librtmp look at a packet and send a response
if needed. | [
"Lets",
"librtmp",
"look",
"at",
"a",
"packet",
"and",
"send",
"a",
"response",
"if",
"needed",
"."
] | train | https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/rtmp.py#L288-L295 |
chrippa/python-librtmp | librtmp/rtmp.py | RTMP.process_packets | def process_packets(self, transaction_id=None, invoked_method=None,
timeout=None):
"""Wait for packets and process them as needed.
:param transaction_id: int, Wait until the result of this
transaction ID is recieved.
:param invoked_method: ... | python | def process_packets(self, transaction_id=None, invoked_method=None,
timeout=None):
"""Wait for packets and process them as needed.
:param transaction_id: int, Wait until the result of this
transaction ID is recieved.
:param invoked_method: ... | [
"def",
"process_packets",
"(",
"self",
",",
"transaction_id",
"=",
"None",
",",
"invoked_method",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"start",
"=",
"time",
"(",
")",
"while",
"self",
".",
"connected",
"and",
"transaction_id",
"not",
"in",
... | Wait for packets and process them as needed.
:param transaction_id: int, Wait until the result of this
transaction ID is recieved.
:param invoked_method: int, Wait until this method is invoked
by the server.
:param timeout: int, The ... | [
"Wait",
"for",
"packets",
"and",
"process",
"them",
"as",
"needed",
"."
] | train | https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/rtmp.py#L297-L377 |
chrippa/python-librtmp | librtmp/rtmp.py | RTMP.call | def call(self, method, *args, **params):
"""Calls a method on the server."""
transaction_id = params.get("transaction_id")
if not transaction_id:
self.transaction_id += 1
transaction_id = self.transaction_id
obj = params.get("obj")
args = [method, tran... | python | def call(self, method, *args, **params):
"""Calls a method on the server."""
transaction_id = params.get("transaction_id")
if not transaction_id:
self.transaction_id += 1
transaction_id = self.transaction_id
obj = params.get("obj")
args = [method, tran... | [
"def",
"call",
"(",
"self",
",",
"method",
",",
"*",
"args",
",",
"*",
"*",
"params",
")",
":",
"transaction_id",
"=",
"params",
".",
"get",
"(",
"\"transaction_id\"",
")",
"if",
"not",
"transaction_id",
":",
"self",
".",
"transaction_id",
"+=",
"1",
"... | Calls a method on the server. | [
"Calls",
"a",
"method",
"on",
"the",
"server",
"."
] | train | https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/rtmp.py#L379-L403 |
chrippa/python-librtmp | librtmp/rtmp.py | RTMP.remote_method | def remote_method(self, method, block=False, **params):
"""Creates a Python function that will attempt to
call a remote method when used.
:param method: str, Method name on the server to call
:param block: bool, Wheter to wait for result or not
Usage::
>>> send_us... | python | def remote_method(self, method, block=False, **params):
"""Creates a Python function that will attempt to
call a remote method when used.
:param method: str, Method name on the server to call
:param block: bool, Wheter to wait for result or not
Usage::
>>> send_us... | [
"def",
"remote_method",
"(",
"self",
",",
"method",
",",
"block",
"=",
"False",
",",
"*",
"*",
"params",
")",
":",
"def",
"func",
"(",
"*",
"args",
")",
":",
"call",
"=",
"self",
".",
"call",
"(",
"method",
",",
"*",
"args",
",",
"*",
"*",
"par... | Creates a Python function that will attempt to
call a remote method when used.
:param method: str, Method name on the server to call
:param block: bool, Wheter to wait for result or not
Usage::
>>> send_usher_token = conn.remote_method("NetStream.Authenticate.UsherToken",... | [
"Creates",
"a",
"Python",
"function",
"that",
"will",
"attempt",
"to",
"call",
"a",
"remote",
"method",
"when",
"used",
"."
] | train | https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/rtmp.py#L405-L429 |
chrippa/python-librtmp | librtmp/rtmp.py | RTMPCall.result | def result(self, timeout=None):
"""Retrieves the result of the call.
:param timeout: The time to wait for a result from the server.
Raises :exc:`RTMPTimeoutError` on timeout.
"""
if self.done:
return self._result
result = self.conn.process_packets(transacti... | python | def result(self, timeout=None):
"""Retrieves the result of the call.
:param timeout: The time to wait for a result from the server.
Raises :exc:`RTMPTimeoutError` on timeout.
"""
if self.done:
return self._result
result = self.conn.process_packets(transacti... | [
"def",
"result",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"self",
".",
"done",
":",
"return",
"self",
".",
"_result",
"result",
"=",
"self",
".",
"conn",
".",
"process_packets",
"(",
"transaction_id",
"=",
"self",
".",
"transaction_id",
... | Retrieves the result of the call.
:param timeout: The time to wait for a result from the server.
Raises :exc:`RTMPTimeoutError` on timeout. | [
"Retrieves",
"the",
"result",
"of",
"the",
"call",
"."
] | train | https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/rtmp.py#L473-L489 |
chrippa/python-librtmp | librtmp/utils.py | add_signal_handler | def add_signal_handler():
"""Adds a signal handler to handle KeyboardInterrupt."""
import signal
def handler(sig, frame):
if sig == signal.SIGINT:
librtmp.RTMP_UserInterrupt()
raise KeyboardInterrupt
signal.signal(signal.SIGINT, handler) | python | def add_signal_handler():
"""Adds a signal handler to handle KeyboardInterrupt."""
import signal
def handler(sig, frame):
if sig == signal.SIGINT:
librtmp.RTMP_UserInterrupt()
raise KeyboardInterrupt
signal.signal(signal.SIGINT, handler) | [
"def",
"add_signal_handler",
"(",
")",
":",
"import",
"signal",
"def",
"handler",
"(",
"sig",
",",
"frame",
")",
":",
"if",
"sig",
"==",
"signal",
".",
"SIGINT",
":",
"librtmp",
".",
"RTMP_UserInterrupt",
"(",
")",
"raise",
"KeyboardInterrupt",
"signal",
"... | Adds a signal handler to handle KeyboardInterrupt. | [
"Adds",
"a",
"signal",
"handler",
"to",
"handle",
"KeyboardInterrupt",
"."
] | train | https://github.com/chrippa/python-librtmp/blob/6efefd5edd76cad7a3b53f7c87c1c7350448224d/librtmp/utils.py#L12-L21 |
taxpon/pymesh | pymesh/base.py | BaseMesh.set_initial_values | def set_initial_values(self):
"""Set initial values form existing self.data value
:return: None
"""
self.normals = self.data['normals']
self.vectors = numpy.ones((
self.data['vectors'].shape[0],
self.data['vectors'].shape[1],
self.data['vectors... | python | def set_initial_values(self):
"""Set initial values form existing self.data value
:return: None
"""
self.normals = self.data['normals']
self.vectors = numpy.ones((
self.data['vectors'].shape[0],
self.data['vectors'].shape[1],
self.data['vectors... | [
"def",
"set_initial_values",
"(",
"self",
")",
":",
"self",
".",
"normals",
"=",
"self",
".",
"data",
"[",
"'normals'",
"]",
"self",
".",
"vectors",
"=",
"numpy",
".",
"ones",
"(",
"(",
"self",
".",
"data",
"[",
"'vectors'",
"]",
".",
"shape",
"[",
... | Set initial values form existing self.data value
:return: None | [
"Set",
"initial",
"values",
"form",
"existing",
"self",
".",
"data",
"value",
":",
"return",
":",
"None"
] | train | https://github.com/taxpon/pymesh/blob/a90b3b2ed1408d793f3b5208dd8087b08fb7c92e/pymesh/base.py#L33-L45 |
taxpon/pymesh | pymesh/base.py | BaseMesh.rotate_x | def rotate_x(self, deg):
"""Rotate mesh around x-axis
:param float deg: Rotation angle (degree)
:return:
"""
rad = math.radians(deg)
mat = numpy.array([
[1, 0, 0, 0],
[0, math.cos(rad), math.sin(rad), 0],
[0, -math.sin(rad), math.cos(r... | python | def rotate_x(self, deg):
"""Rotate mesh around x-axis
:param float deg: Rotation angle (degree)
:return:
"""
rad = math.radians(deg)
mat = numpy.array([
[1, 0, 0, 0],
[0, math.cos(rad), math.sin(rad), 0],
[0, -math.sin(rad), math.cos(r... | [
"def",
"rotate_x",
"(",
"self",
",",
"deg",
")",
":",
"rad",
"=",
"math",
".",
"radians",
"(",
"deg",
")",
"mat",
"=",
"numpy",
".",
"array",
"(",
"[",
"[",
"1",
",",
"0",
",",
"0",
",",
"0",
"]",
",",
"[",
"0",
",",
"math",
".",
"cos",
"... | Rotate mesh around x-axis
:param float deg: Rotation angle (degree)
:return: | [
"Rotate",
"mesh",
"around",
"x",
"-",
"axis"
] | train | https://github.com/taxpon/pymesh/blob/a90b3b2ed1408d793f3b5208dd8087b08fb7c92e/pymesh/base.py#L47-L61 |
taxpon/pymesh | pymesh/base.py | BaseMesh.translate_x | def translate_x(self, d):
"""Translate mesh for x-direction
:param float d: Amount to translate
"""
mat = numpy.array([
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[d, 0, 0, 1]
])
self.vectors = self.vectors.dot(mat)
... | python | def translate_x(self, d):
"""Translate mesh for x-direction
:param float d: Amount to translate
"""
mat = numpy.array([
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[d, 0, 0, 1]
])
self.vectors = self.vectors.dot(mat)
... | [
"def",
"translate_x",
"(",
"self",
",",
"d",
")",
":",
"mat",
"=",
"numpy",
".",
"array",
"(",
"[",
"[",
"1",
",",
"0",
",",
"0",
",",
"0",
"]",
",",
"[",
"0",
",",
"1",
",",
"0",
",",
"0",
"]",
",",
"[",
"0",
",",
"0",
",",
"1",
",",... | Translate mesh for x-direction
:param float d: Amount to translate | [
"Translate",
"mesh",
"for",
"x",
"-",
"direction"
] | train | https://github.com/taxpon/pymesh/blob/a90b3b2ed1408d793f3b5208dd8087b08fb7c92e/pymesh/base.py#L93-L105 |
taxpon/pymesh | pymesh/base.py | BaseMesh.translate_y | def translate_y(self, d):
"""Translate mesh for y-direction
:param float d: Amount to translate
"""
mat = numpy.array([
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, d, 0, 1]
])
self.vectors = self.vectors.dot(mat)
... | python | def translate_y(self, d):
"""Translate mesh for y-direction
:param float d: Amount to translate
"""
mat = numpy.array([
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, d, 0, 1]
])
self.vectors = self.vectors.dot(mat)
... | [
"def",
"translate_y",
"(",
"self",
",",
"d",
")",
":",
"mat",
"=",
"numpy",
".",
"array",
"(",
"[",
"[",
"1",
",",
"0",
",",
"0",
",",
"0",
"]",
",",
"[",
"0",
",",
"1",
",",
"0",
",",
"0",
"]",
",",
"[",
"0",
",",
"0",
",",
"1",
",",... | Translate mesh for y-direction
:param float d: Amount to translate | [
"Translate",
"mesh",
"for",
"y",
"-",
"direction"
] | train | https://github.com/taxpon/pymesh/blob/a90b3b2ed1408d793f3b5208dd8087b08fb7c92e/pymesh/base.py#L107-L119 |
taxpon/pymesh | pymesh/base.py | BaseMesh.translate_z | def translate_z(self, d):
"""Translate mesh for z-direction
:param float d: Amount to translate
"""
mat = numpy.array([
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 0, d, 1]
])
self.vectors = self.vectors.dot(mat)
... | python | def translate_z(self, d):
"""Translate mesh for z-direction
:param float d: Amount to translate
"""
mat = numpy.array([
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 0, d, 1]
])
self.vectors = self.vectors.dot(mat)
... | [
"def",
"translate_z",
"(",
"self",
",",
"d",
")",
":",
"mat",
"=",
"numpy",
".",
"array",
"(",
"[",
"[",
"1",
",",
"0",
",",
"0",
",",
"0",
"]",
",",
"[",
"0",
",",
"1",
",",
"0",
",",
"0",
"]",
",",
"[",
"0",
",",
"0",
",",
"1",
",",... | Translate mesh for z-direction
:param float d: Amount to translate | [
"Translate",
"mesh",
"for",
"z",
"-",
"direction"
] | train | https://github.com/taxpon/pymesh/blob/a90b3b2ed1408d793f3b5208dd8087b08fb7c92e/pymesh/base.py#L121-L133 |
taxpon/pymesh | pymesh/base.py | BaseMesh.scale | def scale(self, sx, sy, sz):
"""Scale mesh
:param float sx: Amount to scale for x-direction
:param float sy: Amount to scale for y-direction
:param float sz: Amount to scale for z-direction
"""
mat = numpy.array([
[sx, 0, 0, 0],
[0, sy, 0, 0],
... | python | def scale(self, sx, sy, sz):
"""Scale mesh
:param float sx: Amount to scale for x-direction
:param float sy: Amount to scale for y-direction
:param float sz: Amount to scale for z-direction
"""
mat = numpy.array([
[sx, 0, 0, 0],
[0, sy, 0, 0],
... | [
"def",
"scale",
"(",
"self",
",",
"sx",
",",
"sy",
",",
"sz",
")",
":",
"mat",
"=",
"numpy",
".",
"array",
"(",
"[",
"[",
"sx",
",",
"0",
",",
"0",
",",
"0",
"]",
",",
"[",
"0",
",",
"sy",
",",
"0",
",",
"0",
"]",
",",
"[",
"0",
",",
... | Scale mesh
:param float sx: Amount to scale for x-direction
:param float sy: Amount to scale for y-direction
:param float sz: Amount to scale for z-direction | [
"Scale",
"mesh"
] | train | https://github.com/taxpon/pymesh/blob/a90b3b2ed1408d793f3b5208dd8087b08fb7c92e/pymesh/base.py#L135-L149 |
taxpon/pymesh | pymesh/base.py | BaseMesh.__calc_signed_volume | def __calc_signed_volume(triangle):
""" Calculate signed volume of given triangle
:param list of list triangle:
:rtype float
"""
v321 = triangle[2][0] * triangle[1][1] * triangle[0][2]
v231 = triangle[1][0] * triangle[2][1] * triangle[0][2]
v312 = triangle[2][0] *... | python | def __calc_signed_volume(triangle):
""" Calculate signed volume of given triangle
:param list of list triangle:
:rtype float
"""
v321 = triangle[2][0] * triangle[1][1] * triangle[0][2]
v231 = triangle[1][0] * triangle[2][1] * triangle[0][2]
v312 = triangle[2][0] *... | [
"def",
"__calc_signed_volume",
"(",
"triangle",
")",
":",
"v321",
"=",
"triangle",
"[",
"2",
"]",
"[",
"0",
"]",
"*",
"triangle",
"[",
"1",
"]",
"[",
"1",
"]",
"*",
"triangle",
"[",
"0",
"]",
"[",
"2",
"]",
"v231",
"=",
"triangle",
"[",
"1",
"]... | Calculate signed volume of given triangle
:param list of list triangle:
:rtype float | [
"Calculate",
"signed",
"volume",
"of",
"given",
"triangle",
":",
"param",
"list",
"of",
"list",
"triangle",
":",
":",
"rtype",
"float"
] | train | https://github.com/taxpon/pymesh/blob/a90b3b2ed1408d793f3b5208dd8087b08fb7c92e/pymesh/base.py#L193-L206 |
taxpon/pymesh | pymesh/base.py | BaseMesh.save_stl | def save_stl(self, path, mode=MODE_STL_AUTO, update_normals=True):
"""Save data with stl format
:param str path:
:param int mode:
:param bool update_normals:
"""
if update_normals:
self.update_normals()
filename = os.path.split(path)[-1]
if m... | python | def save_stl(self, path, mode=MODE_STL_AUTO, update_normals=True):
"""Save data with stl format
:param str path:
:param int mode:
:param bool update_normals:
"""
if update_normals:
self.update_normals()
filename = os.path.split(path)[-1]
if m... | [
"def",
"save_stl",
"(",
"self",
",",
"path",
",",
"mode",
"=",
"MODE_STL_AUTO",
",",
"update_normals",
"=",
"True",
")",
":",
"if",
"update_normals",
":",
"self",
".",
"update_normals",
"(",
")",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"... | Save data with stl format
:param str path:
:param int mode:
:param bool update_normals: | [
"Save",
"data",
"with",
"stl",
"format",
":",
"param",
"str",
"path",
":",
":",
"param",
"int",
"mode",
":",
":",
"param",
"bool",
"update_normals",
":"
] | train | https://github.com/taxpon/pymesh/blob/a90b3b2ed1408d793f3b5208dd8087b08fb7c92e/pymesh/base.py#L213-L241 |
taxpon/pymesh | pymesh/base.py | BaseMesh.save_obj | def save_obj(self, path, update_normals=True):
"""Save data with OBJ format
:param stl path:
:param bool update_normals:
"""
if update_normals:
self.update_normals()
# Create triangle_list
vectors_key_list = []
vectors_list = []
normal... | python | def save_obj(self, path, update_normals=True):
"""Save data with OBJ format
:param stl path:
:param bool update_normals:
"""
if update_normals:
self.update_normals()
# Create triangle_list
vectors_key_list = []
vectors_list = []
normal... | [
"def",
"save_obj",
"(",
"self",
",",
"path",
",",
"update_normals",
"=",
"True",
")",
":",
"if",
"update_normals",
":",
"self",
".",
"update_normals",
"(",
")",
"# Create triangle_list",
"vectors_key_list",
"=",
"[",
"]",
"vectors_list",
"=",
"[",
"]",
"norm... | Save data with OBJ format
:param stl path:
:param bool update_normals: | [
"Save",
"data",
"with",
"OBJ",
"format",
":",
"param",
"stl",
"path",
":",
":",
"param",
"bool",
"update_normals",
":"
] | train | https://github.com/taxpon/pymesh/blob/a90b3b2ed1408d793f3b5208dd8087b08fb7c92e/pymesh/base.py#L271-L325 |
taxpon/pymesh | pymesh/stl.py | Stl.__load | def __load(fh, mode=MODE_AUTO):
"""Load Mesh from STL file
:param FileIO fh: The file handle to open
:param int mode: The mode to open, default is :py:data:`AUTOMATIC`.
:return:
"""
header = fh.read(Stl.HEADER_SIZE).lower()
name = ""
data = None
i... | python | def __load(fh, mode=MODE_AUTO):
"""Load Mesh from STL file
:param FileIO fh: The file handle to open
:param int mode: The mode to open, default is :py:data:`AUTOMATIC`.
:return:
"""
header = fh.read(Stl.HEADER_SIZE).lower()
name = ""
data = None
i... | [
"def",
"__load",
"(",
"fh",
",",
"mode",
"=",
"MODE_AUTO",
")",
":",
"header",
"=",
"fh",
".",
"read",
"(",
"Stl",
".",
"HEADER_SIZE",
")",
".",
"lower",
"(",
")",
"name",
"=",
"\"\"",
"data",
"=",
"None",
"if",
"not",
"header",
".",
"strip",
"("... | Load Mesh from STL file
:param FileIO fh: The file handle to open
:param int mode: The mode to open, default is :py:data:`AUTOMATIC`.
:return: | [
"Load",
"Mesh",
"from",
"STL",
"file"
] | train | https://github.com/taxpon/pymesh/blob/a90b3b2ed1408d793f3b5208dd8087b08fb7c92e/pymesh/stl.py#L52-L78 |
taxpon/pymesh | pymesh/stl.py | Stl.__ascii_reader | def __ascii_reader(fh, header):
"""
:param fh:
:param header:
:return:
"""
lines = header.split('\n')
recoverable = [True]
def get(prefix=''):
if lines:
line = lines.pop(0)
else:
raise RuntimeError(... | python | def __ascii_reader(fh, header):
"""
:param fh:
:param header:
:return:
"""
lines = header.split('\n')
recoverable = [True]
def get(prefix=''):
if lines:
line = lines.pop(0)
else:
raise RuntimeError(... | [
"def",
"__ascii_reader",
"(",
"fh",
",",
"header",
")",
":",
"lines",
"=",
"header",
".",
"split",
"(",
"'\\n'",
")",
"recoverable",
"=",
"[",
"True",
"]",
"def",
"get",
"(",
"prefix",
"=",
"''",
")",
":",
"if",
"lines",
":",
"line",
"=",
"lines",
... | :param fh:
:param header:
:return: | [
":",
"param",
"fh",
":",
":",
"param",
"header",
":",
":",
"return",
":"
] | train | https://github.com/taxpon/pymesh/blob/a90b3b2ed1408d793f3b5208dd8087b08fb7c92e/pymesh/stl.py#L95-L168 |
neptune-ml/steppy | steppy/utils.py | initialize_logger | def initialize_logger():
"""Initialize steppy logger.
This logger is used throughout the steppy library to report computation progress.
Example:
Simple use of steppy logger:
.. code-block:: python
initialize_logger()
logger = get_logger()
... | python | def initialize_logger():
"""Initialize steppy logger.
This logger is used throughout the steppy library to report computation progress.
Example:
Simple use of steppy logger:
.. code-block:: python
initialize_logger()
logger = get_logger()
... | [
"def",
"initialize_logger",
"(",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"'steppy'",
")",
"logger",
".",
"setLevel",
"(",
"logging",
".",
"INFO",
")",
"message_format",
"=",
"logging",
".",
"Formatter",
"(",
"fmt",
"=",
"'%(asctime)s %(nam... | Initialize steppy logger.
This logger is used throughout the steppy library to report computation progress.
Example:
Simple use of steppy logger:
.. code-block:: python
initialize_logger()
logger = get_logger()
logger.info('My message inside p... | [
"Initialize",
"steppy",
"logger",
"."
] | train | https://github.com/neptune-ml/steppy/blob/856b95f1f5189e1d2ca122b891bc670adac9692b/steppy/utils.py#L8-L45 |
neptune-ml/steppy | steppy/utils.py | display_upstream_structure | def display_upstream_structure(structure_dict):
"""Displays pipeline structure in the jupyter notebook.
Args:
structure_dict (dict): dict returned by
:func:`~steppy.base.Step.upstream_structure`.
"""
graph = _create_graph(structure_dict)
plt = Image(graph.create_png())
displ... | python | def display_upstream_structure(structure_dict):
"""Displays pipeline structure in the jupyter notebook.
Args:
structure_dict (dict): dict returned by
:func:`~steppy.base.Step.upstream_structure`.
"""
graph = _create_graph(structure_dict)
plt = Image(graph.create_png())
displ... | [
"def",
"display_upstream_structure",
"(",
"structure_dict",
")",
":",
"graph",
"=",
"_create_graph",
"(",
"structure_dict",
")",
"plt",
"=",
"Image",
"(",
"graph",
".",
"create_png",
"(",
")",
")",
"display",
"(",
"plt",
")"
] | Displays pipeline structure in the jupyter notebook.
Args:
structure_dict (dict): dict returned by
:func:`~steppy.base.Step.upstream_structure`. | [
"Displays",
"pipeline",
"structure",
"in",
"the",
"jupyter",
"notebook",
"."
] | train | https://github.com/neptune-ml/steppy/blob/856b95f1f5189e1d2ca122b891bc670adac9692b/steppy/utils.py#L71-L80 |
neptune-ml/steppy | steppy/utils.py | persist_as_png | def persist_as_png(structure_dict, filepath):
"""Saves pipeline diagram to disk as png file.
Args:
structure_dict (dict): dict returned by
:func:`~steppy.base.Step.upstream_structure`
filepath (str): filepath to which the png with pipeline visualization should be persisted
"""
... | python | def persist_as_png(structure_dict, filepath):
"""Saves pipeline diagram to disk as png file.
Args:
structure_dict (dict): dict returned by
:func:`~steppy.base.Step.upstream_structure`
filepath (str): filepath to which the png with pipeline visualization should be persisted
"""
... | [
"def",
"persist_as_png",
"(",
"structure_dict",
",",
"filepath",
")",
":",
"graph",
"=",
"_create_graph",
"(",
"structure_dict",
")",
"graph",
".",
"write",
"(",
"filepath",
",",
"format",
"=",
"'png'",
")"
] | Saves pipeline diagram to disk as png file.
Args:
structure_dict (dict): dict returned by
:func:`~steppy.base.Step.upstream_structure`
filepath (str): filepath to which the png with pipeline visualization should be persisted | [
"Saves",
"pipeline",
"diagram",
"to",
"disk",
"as",
"png",
"file",
"."
] | train | https://github.com/neptune-ml/steppy/blob/856b95f1f5189e1d2ca122b891bc670adac9692b/steppy/utils.py#L83-L92 |
neptune-ml/steppy | steppy/utils.py | _create_graph | def _create_graph(structure_dict):
"""Creates pydot graph from the pipeline structure dict.
Args:
structure_dict (dict): dict returned by step.upstream_structure
Returns:
graph (pydot.Dot): object representing upstream pipeline structure (with regard to the current Step).
"""
graph... | python | def _create_graph(structure_dict):
"""Creates pydot graph from the pipeline structure dict.
Args:
structure_dict (dict): dict returned by step.upstream_structure
Returns:
graph (pydot.Dot): object representing upstream pipeline structure (with regard to the current Step).
"""
graph... | [
"def",
"_create_graph",
"(",
"structure_dict",
")",
":",
"graph",
"=",
"pydot",
".",
"Dot",
"(",
")",
"for",
"node",
"in",
"structure_dict",
"[",
"'nodes'",
"]",
":",
"graph",
".",
"add_node",
"(",
"pydot",
".",
"Node",
"(",
"node",
")",
")",
"for",
... | Creates pydot graph from the pipeline structure dict.
Args:
structure_dict (dict): dict returned by step.upstream_structure
Returns:
graph (pydot.Dot): object representing upstream pipeline structure (with regard to the current Step). | [
"Creates",
"pydot",
"graph",
"from",
"the",
"pipeline",
"structure",
"dict",
"."
] | train | https://github.com/neptune-ml/steppy/blob/856b95f1f5189e1d2ca122b891bc670adac9692b/steppy/utils.py#L95-L109 |
neptune-ml/steppy | steppy/adapter.py | Adapter.adapt | def adapt(self, all_ouputs: AllOutputs) -> DataPacket:
"""Adapt inputs for the transformer included in the step.
Args:
all_ouputs: Dict of outputs from parent steps. The keys should
match the names of these steps and the values should be their
respective outp... | python | def adapt(self, all_ouputs: AllOutputs) -> DataPacket:
"""Adapt inputs for the transformer included in the step.
Args:
all_ouputs: Dict of outputs from parent steps. The keys should
match the names of these steps and the values should be their
respective outp... | [
"def",
"adapt",
"(",
"self",
",",
"all_ouputs",
":",
"AllOutputs",
")",
"->",
"DataPacket",
":",
"adapted",
"=",
"{",
"}",
"for",
"name",
",",
"recipe",
"in",
"self",
".",
"adapting_recipes",
".",
"items",
"(",
")",
":",
"adapted",
"[",
"name",
"]",
... | Adapt inputs for the transformer included in the step.
Args:
all_ouputs: Dict of outputs from parent steps. The keys should
match the names of these steps and the values should be their
respective outputs.
Returns:
Dictionary with the same keys a... | [
"Adapt",
"inputs",
"for",
"the",
"transformer",
"included",
"in",
"the",
"step",
"."
] | train | https://github.com/neptune-ml/steppy/blob/856b95f1f5189e1d2ca122b891bc670adac9692b/steppy/adapter.py#L106-L122 |
neptune-ml/steppy | steppy/base.py | Step.upstream_structure | def upstream_structure(self):
"""Build dictionary with entire upstream pipeline structure
(with regard to the current Step).
Returns:
dict: dictionary describing the upstream pipeline structure. It has two keys:
``'edges'`` and ``'nodes'``, where:
- value of... | python | def upstream_structure(self):
"""Build dictionary with entire upstream pipeline structure
(with regard to the current Step).
Returns:
dict: dictionary describing the upstream pipeline structure. It has two keys:
``'edges'`` and ``'nodes'``, where:
- value of... | [
"def",
"upstream_structure",
"(",
"self",
")",
":",
"structure_dict",
"=",
"{",
"'edges'",
":",
"set",
"(",
")",
",",
"'nodes'",
":",
"set",
"(",
")",
"}",
"structure_dict",
"=",
"self",
".",
"_build_structure_dict",
"(",
"structure_dict",
")",
"return",
"... | Build dictionary with entire upstream pipeline structure
(with regard to the current Step).
Returns:
dict: dictionary describing the upstream pipeline structure. It has two keys:
``'edges'`` and ``'nodes'``, where:
- value of ``'edges'`` is set of tuples ``(input_st... | [
"Build",
"dictionary",
"with",
"entire",
"upstream",
"pipeline",
"structure",
"(",
"with",
"regard",
"to",
"the",
"current",
"Step",
")",
"."
] | train | https://github.com/neptune-ml/steppy/blob/856b95f1f5189e1d2ca122b891bc670adac9692b/steppy/base.py#L258-L272 |
neptune-ml/steppy | steppy/base.py | Step.fit_transform | def fit_transform(self, data):
"""Fit the model and transform data or load already processed data.
Loads cached or persisted output or adapts data for the current transformer and
executes ``transformer.fit_transform``.
Args:
data (dict): data dictionary with keys as input n... | python | def fit_transform(self, data):
"""Fit the model and transform data or load already processed data.
Loads cached or persisted output or adapts data for the current transformer and
executes ``transformer.fit_transform``.
Args:
data (dict): data dictionary with keys as input n... | [
"def",
"fit_transform",
"(",
"self",
",",
"data",
")",
":",
"if",
"data",
":",
"assert",
"isinstance",
"(",
"data",
",",
"dict",
")",
",",
"'Step {}, \"data\" argument in the \"fit_transform()\" method must be dict, '",
"'got {} instead.'",
".",
"format",
"(",
"self",... | Fit the model and transform data or load already processed data.
Loads cached or persisted output or adapts data for the current transformer and
executes ``transformer.fit_transform``.
Args:
data (dict): data dictionary with keys as input names and values as dictionaries of
... | [
"Fit",
"the",
"model",
"and",
"transform",
"data",
"or",
"load",
"already",
"processed",
"data",
"."
] | train | https://github.com/neptune-ml/steppy/blob/856b95f1f5189e1d2ca122b891bc670adac9692b/steppy/base.py#L310-L364 |
neptune-ml/steppy | steppy/base.py | Step.reset | def reset(self):
"""Reset all upstream Steps to the default training parameters and
cleans cache for all upstream Steps including this Step.
Defaults are:
'mode': 'train',
'is_fittable': True,
'force_fitting': True,
'persist_output': False,
... | python | def reset(self):
"""Reset all upstream Steps to the default training parameters and
cleans cache for all upstream Steps including this Step.
Defaults are:
'mode': 'train',
'is_fittable': True,
'force_fitting': True,
'persist_output': False,
... | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"clean_cache_upstream",
"(",
")",
"self",
".",
"set_mode_train",
"(",
")",
"for",
"step_obj",
"in",
"self",
".",
"all_upstream_steps",
".",
"values",
"(",
")",
":",
"step_obj",
".",
"is_fittable",
"=",
... | Reset all upstream Steps to the default training parameters and
cleans cache for all upstream Steps including this Step.
Defaults are:
'mode': 'train',
'is_fittable': True,
'force_fitting': True,
'persist_output': False,
'cache_output': False,
... | [
"Reset",
"all",
"upstream",
"Steps",
"to",
"the",
"default",
"training",
"parameters",
"and",
"cleans",
"cache",
"for",
"all",
"upstream",
"Steps",
"including",
"this",
"Step",
".",
"Defaults",
"are",
":",
"mode",
":",
"train",
"is_fittable",
":",
"True",
"f... | train | https://github.com/neptune-ml/steppy/blob/856b95f1f5189e1d2ca122b891bc670adac9692b/steppy/base.py#L434-L455 |
neptune-ml/steppy | steppy/base.py | Step.set_parameters_upstream | def set_parameters_upstream(self, parameters):
"""Set parameters to all upstream Steps including this Step.
Parameters is dict() where key is Step attribute, and value is new value to set.
"""
assert isinstance(parameters, dict), 'parameters must be dict, got {} instead'.format(type(para... | python | def set_parameters_upstream(self, parameters):
"""Set parameters to all upstream Steps including this Step.
Parameters is dict() where key is Step attribute, and value is new value to set.
"""
assert isinstance(parameters, dict), 'parameters must be dict, got {} instead'.format(type(para... | [
"def",
"set_parameters_upstream",
"(",
"self",
",",
"parameters",
")",
":",
"assert",
"isinstance",
"(",
"parameters",
",",
"dict",
")",
",",
"'parameters must be dict, got {} instead'",
".",
"format",
"(",
"type",
"(",
"parameters",
")",
")",
"for",
"step_obj",
... | Set parameters to all upstream Steps including this Step.
Parameters is dict() where key is Step attribute, and value is new value to set. | [
"Set",
"parameters",
"to",
"all",
"upstream",
"Steps",
"including",
"this",
"Step",
".",
"Parameters",
"is",
"dict",
"()",
"where",
"key",
"is",
"Step",
"attribute",
"and",
"value",
"is",
"new",
"value",
"to",
"set",
"."
] | train | https://github.com/neptune-ml/steppy/blob/856b95f1f5189e1d2ca122b891bc670adac9692b/steppy/base.py#L457-L469 |
neptune-ml/steppy | steppy/base.py | Step.clean_cache_step | def clean_cache_step(self):
"""Clean cache for current step.
"""
logger.info('Step {}, cleaning cache'.format(self.name))
self.output = None
return self | python | def clean_cache_step(self):
"""Clean cache for current step.
"""
logger.info('Step {}, cleaning cache'.format(self.name))
self.output = None
return self | [
"def",
"clean_cache_step",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'Step {}, cleaning cache'",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"self",
".",
"output",
"=",
"None",
"return",
"self"
] | Clean cache for current step. | [
"Clean",
"cache",
"for",
"current",
"step",
"."
] | train | https://github.com/neptune-ml/steppy/blob/856b95f1f5189e1d2ca122b891bc670adac9692b/steppy/base.py#L471-L476 |
neptune-ml/steppy | steppy/base.py | Step.clean_cache_upstream | def clean_cache_upstream(self):
"""Clean cache for all steps that are upstream to `self`.
"""
logger.info('Cleaning cache for the entire upstream pipeline')
for step in self.all_upstream_steps.values():
logger.info('Step {}, cleaning cache'.format(step.name))
step... | python | def clean_cache_upstream(self):
"""Clean cache for all steps that are upstream to `self`.
"""
logger.info('Cleaning cache for the entire upstream pipeline')
for step in self.all_upstream_steps.values():
logger.info('Step {}, cleaning cache'.format(step.name))
step... | [
"def",
"clean_cache_upstream",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'Cleaning cache for the entire upstream pipeline'",
")",
"for",
"step",
"in",
"self",
".",
"all_upstream_steps",
".",
"values",
"(",
")",
":",
"logger",
".",
"info",
"(",
"'Step {... | Clean cache for all steps that are upstream to `self`. | [
"Clean",
"cache",
"for",
"all",
"steps",
"that",
"are",
"upstream",
"to",
"self",
"."
] | train | https://github.com/neptune-ml/steppy/blob/856b95f1f5189e1d2ca122b891bc670adac9692b/steppy/base.py#L478-L485 |
neptune-ml/steppy | steppy/base.py | Step.get_step_by_name | def get_step_by_name(self, name):
"""Extracts step by name from the pipeline.
Extracted Step is a fully functional pipeline as well.
All upstream Steps are already defined.
Args:
name (str): name of the step to be fetched
Returns:
Step (obj): extracted s... | python | def get_step_by_name(self, name):
"""Extracts step by name from the pipeline.
Extracted Step is a fully functional pipeline as well.
All upstream Steps are already defined.
Args:
name (str): name of the step to be fetched
Returns:
Step (obj): extracted s... | [
"def",
"get_step_by_name",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"_validate_step_name",
"(",
"name",
")",
"name",
"=",
"str",
"(",
"name",
")",
"try",
":",
"return",
"self",
".",
"all_upstream_steps",
"[",
"name",
"]",
"except",
"KeyError",
"a... | Extracts step by name from the pipeline.
Extracted Step is a fully functional pipeline as well.
All upstream Steps are already defined.
Args:
name (str): name of the step to be fetched
Returns:
Step (obj): extracted step | [
"Extracts",
"step",
"by",
"name",
"from",
"the",
"pipeline",
"."
] | train | https://github.com/neptune-ml/steppy/blob/856b95f1f5189e1d2ca122b891bc670adac9692b/steppy/base.py#L487-L505 |
neptune-ml/steppy | steppy/base.py | Step.persist_upstream_structure | def persist_upstream_structure(self):
"""Persist json file with the upstream steps structure, that is step names and their connections."""
persist_dir = os.path.join(self.experiment_directory, '{}_upstream_structure.json'.format(self.name))
logger.info('Step {}, saving upstream pipeline structur... | python | def persist_upstream_structure(self):
"""Persist json file with the upstream steps structure, that is step names and their connections."""
persist_dir = os.path.join(self.experiment_directory, '{}_upstream_structure.json'.format(self.name))
logger.info('Step {}, saving upstream pipeline structur... | [
"def",
"persist_upstream_structure",
"(",
"self",
")",
":",
"persist_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"experiment_directory",
",",
"'{}_upstream_structure.json'",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"logger",
".",
"... | Persist json file with the upstream steps structure, that is step names and their connections. | [
"Persist",
"json",
"file",
"with",
"the",
"upstream",
"steps",
"structure",
"that",
"is",
"step",
"names",
"and",
"their",
"connections",
"."
] | train | https://github.com/neptune-ml/steppy/blob/856b95f1f5189e1d2ca122b891bc670adac9692b/steppy/base.py#L507-L511 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.