repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
mrjoes/sockjs-tornado | sockjs/tornado/sessioncontainer.py | SessionContainer.remove | def remove(self, session_id):
"""Remove session object from the container
`session_id`
Session identifier
"""
session = self._items.get(session_id, None)
if session is not None:
session.promoted = -1
session.on_delete(True)
del se... | python | def remove(self, session_id):
"""Remove session object from the container
`session_id`
Session identifier
"""
session = self._items.get(session_id, None)
if session is not None:
session.promoted = -1
session.on_delete(True)
del se... | [
"def",
"remove",
"(",
"self",
",",
"session_id",
")",
":",
"session",
"=",
"self",
".",
"_items",
".",
"get",
"(",
"session_id",
",",
"None",
")",
"if",
"session",
"is",
"not",
"None",
":",
"session",
".",
"promoted",
"=",
"-",
"1",
"session",
".",
... | Remove session object from the container
`session_id`
Session identifier | [
"Remove",
"session",
"object",
"from",
"the",
"container"
] | bd3a99b407f1181f054b3b1730f438dde375ca1c | https://github.com/mrjoes/sockjs-tornado/blob/bd3a99b407f1181f054b3b1730f438dde375ca1c/sockjs/tornado/sessioncontainer.py#L101-L115 | train |
mrjoes/sockjs-tornado | sockjs/tornado/transports/streamingbase.py | StreamingTransportBase.send_complete | def send_complete(self):
"""
Verify if connection should be closed based on amount of data that was sent.
"""
self.active = True
if self.should_finish():
self._detach()
# Avoid race condition when waiting for write callback and session getting closed... | python | def send_complete(self):
"""
Verify if connection should be closed based on amount of data that was sent.
"""
self.active = True
if self.should_finish():
self._detach()
# Avoid race condition when waiting for write callback and session getting closed... | [
"def",
"send_complete",
"(",
"self",
")",
":",
"self",
".",
"active",
"=",
"True",
"if",
"self",
".",
"should_finish",
"(",
")",
":",
"self",
".",
"_detach",
"(",
")",
"if",
"not",
"self",
".",
"_finished",
":",
"self",
".",
"safe_finish",
"(",
")",
... | Verify if connection should be closed based on amount of data that was sent. | [
"Verify",
"if",
"connection",
"should",
"be",
"closed",
"based",
"on",
"amount",
"of",
"data",
"that",
"was",
"sent",
"."
] | bd3a99b407f1181f054b3b1730f438dde375ca1c | https://github.com/mrjoes/sockjs-tornado/blob/bd3a99b407f1181f054b3b1730f438dde375ca1c/sockjs/tornado/transports/streamingbase.py#L33-L47 | train |
mrjoes/sockjs-tornado | sockjs/tornado/conn.py | SockJSConnection.send | def send(self, message, binary=False):
"""Send message to the client.
`message`
Message to send.
"""
if not self.is_closed:
self.session.send_message(message, binary=binary) | python | def send(self, message, binary=False):
"""Send message to the client.
`message`
Message to send.
"""
if not self.is_closed:
self.session.send_message(message, binary=binary) | [
"def",
"send",
"(",
"self",
",",
"message",
",",
"binary",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"is_closed",
":",
"self",
".",
"session",
".",
"send_message",
"(",
"message",
",",
"binary",
"=",
"binary",
")"
] | Send message to the client.
`message`
Message to send. | [
"Send",
"message",
"to",
"the",
"client",
"."
] | bd3a99b407f1181f054b3b1730f438dde375ca1c | https://github.com/mrjoes/sockjs-tornado/blob/bd3a99b407f1181f054b3b1730f438dde375ca1c/sockjs/tornado/conn.py#L42-L49 | train |
mrjoes/sockjs-tornado | sockjs/tornado/stats.py | StatsCollector.dump | def dump(self):
"""Return dictionary with current statistical information"""
data = dict(
# Sessions
sessions_active=self.sess_active,
# Connections
connections_active=self.conn_active,
connections_ps=self.conn_ps.last_average,
# ... | python | def dump(self):
"""Return dictionary with current statistical information"""
data = dict(
# Sessions
sessions_active=self.sess_active,
# Connections
connections_active=self.conn_active,
connections_ps=self.conn_ps.last_average,
# ... | [
"def",
"dump",
"(",
"self",
")",
":",
"data",
"=",
"dict",
"(",
"sessions_active",
"=",
"self",
".",
"sess_active",
",",
"connections_active",
"=",
"self",
".",
"conn_active",
",",
"connections_ps",
"=",
"self",
".",
"conn_ps",
".",
"last_average",
",",
"p... | Return dictionary with current statistical information | [
"Return",
"dictionary",
"with",
"current",
"statistical",
"information"
] | bd3a99b407f1181f054b3b1730f438dde375ca1c | https://github.com/mrjoes/sockjs-tornado/blob/bd3a99b407f1181f054b3b1730f438dde375ca1c/sockjs/tornado/stats.py#L79-L97 | train |
mrjoes/sockjs-tornado | sockjs/tornado/basehandler.py | BaseHandler.finish | def finish(self, chunk=None):
"""Tornado `finish` handler"""
self._log_disconnect()
super(BaseHandler, self).finish(chunk) | python | def finish(self, chunk=None):
"""Tornado `finish` handler"""
self._log_disconnect()
super(BaseHandler, self).finish(chunk) | [
"def",
"finish",
"(",
"self",
",",
"chunk",
"=",
"None",
")",
":",
"self",
".",
"_log_disconnect",
"(",
")",
"super",
"(",
"BaseHandler",
",",
"self",
")",
".",
"finish",
"(",
"chunk",
")"
] | Tornado `finish` handler | [
"Tornado",
"finish",
"handler"
] | bd3a99b407f1181f054b3b1730f438dde375ca1c | https://github.com/mrjoes/sockjs-tornado/blob/bd3a99b407f1181f054b3b1730f438dde375ca1c/sockjs/tornado/basehandler.py#L42-L46 | train |
mrjoes/sockjs-tornado | sockjs/tornado/basehandler.py | BaseHandler.handle_session_cookie | def handle_session_cookie(self):
"""Handle JSESSIONID cookie logic"""
# If JSESSIONID support is disabled in the settings, ignore cookie logic
if not self.server.settings['jsessionid']:
return
cookie = self.cookies.get('JSESSIONID')
if not cookie:
cv = '... | python | def handle_session_cookie(self):
"""Handle JSESSIONID cookie logic"""
# If JSESSIONID support is disabled in the settings, ignore cookie logic
if not self.server.settings['jsessionid']:
return
cookie = self.cookies.get('JSESSIONID')
if not cookie:
cv = '... | [
"def",
"handle_session_cookie",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"server",
".",
"settings",
"[",
"'jsessionid'",
"]",
":",
"return",
"cookie",
"=",
"self",
".",
"cookies",
".",
"get",
"(",
"'JSESSIONID'",
")",
"if",
"not",
"cookie",
":",
... | Handle JSESSIONID cookie logic | [
"Handle",
"JSESSIONID",
"cookie",
"logic"
] | bd3a99b407f1181f054b3b1730f438dde375ca1c | https://github.com/mrjoes/sockjs-tornado/blob/bd3a99b407f1181f054b3b1730f438dde375ca1c/sockjs/tornado/basehandler.py#L66-L79 | train |
mrjoes/sockjs-tornado | sockjs/tornado/basehandler.py | PreflightHandler.options | def options(self, *args, **kwargs):
"""XHR cross-domain OPTIONS handler"""
self.enable_cache()
self.handle_session_cookie()
self.preflight()
if self.verify_origin():
allowed_methods = getattr(self, 'access_methods', 'OPTIONS, POST')
self.set_header('Acces... | python | def options(self, *args, **kwargs):
"""XHR cross-domain OPTIONS handler"""
self.enable_cache()
self.handle_session_cookie()
self.preflight()
if self.verify_origin():
allowed_methods = getattr(self, 'access_methods', 'OPTIONS, POST')
self.set_header('Acces... | [
"def",
"options",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"enable_cache",
"(",
")",
"self",
".",
"handle_session_cookie",
"(",
")",
"self",
".",
"preflight",
"(",
")",
"if",
"self",
".",
"verify_origin",
"(",
")",
"... | XHR cross-domain OPTIONS handler | [
"XHR",
"cross",
"-",
"domain",
"OPTIONS",
"handler"
] | bd3a99b407f1181f054b3b1730f438dde375ca1c | https://github.com/mrjoes/sockjs-tornado/blob/bd3a99b407f1181f054b3b1730f438dde375ca1c/sockjs/tornado/basehandler.py#L98-L114 | train |
mrjoes/sockjs-tornado | sockjs/tornado/basehandler.py | PreflightHandler.preflight | def preflight(self):
"""Handles request authentication"""
origin = self.request.headers.get('Origin', '*')
self.set_header('Access-Control-Allow-Origin', origin)
headers = self.request.headers.get('Access-Control-Request-Headers')
if headers:
self.set_header('Access-... | python | def preflight(self):
"""Handles request authentication"""
origin = self.request.headers.get('Origin', '*')
self.set_header('Access-Control-Allow-Origin', origin)
headers = self.request.headers.get('Access-Control-Request-Headers')
if headers:
self.set_header('Access-... | [
"def",
"preflight",
"(",
"self",
")",
":",
"origin",
"=",
"self",
".",
"request",
".",
"headers",
".",
"get",
"(",
"'Origin'",
",",
"'*'",
")",
"self",
".",
"set_header",
"(",
"'Access-Control-Allow-Origin'",
",",
"origin",
")",
"headers",
"=",
"self",
"... | Handles request authentication | [
"Handles",
"request",
"authentication"
] | bd3a99b407f1181f054b3b1730f438dde375ca1c | https://github.com/mrjoes/sockjs-tornado/blob/bd3a99b407f1181f054b3b1730f438dde375ca1c/sockjs/tornado/basehandler.py#L116-L125 | train |
mrjoes/sockjs-tornado | sockjs/tornado/session.py | ConnectionInfo.get_argument | def get_argument(self, name):
"""Return single argument by name"""
val = self.arguments.get(name)
if val:
return val[0]
return None | python | def get_argument(self, name):
"""Return single argument by name"""
val = self.arguments.get(name)
if val:
return val[0]
return None | [
"def",
"get_argument",
"(",
"self",
",",
"name",
")",
":",
"val",
"=",
"self",
".",
"arguments",
".",
"get",
"(",
"name",
")",
"if",
"val",
":",
"return",
"val",
"[",
"0",
"]",
"return",
"None"
] | Return single argument by name | [
"Return",
"single",
"argument",
"by",
"name"
] | bd3a99b407f1181f054b3b1730f438dde375ca1c | https://github.com/mrjoes/sockjs-tornado/blob/bd3a99b407f1181f054b3b1730f438dde375ca1c/sockjs/tornado/session.py#L43-L48 | train |
mrjoes/sockjs-tornado | sockjs/tornado/session.py | BaseSession.verify_state | def verify_state(self):
"""Verify if session was not yet opened. If it is, open it and call connections `on_open`"""
if self.state == CONNECTING:
self.state = OPEN
self.conn.on_open(self.conn_info) | python | def verify_state(self):
"""Verify if session was not yet opened. If it is, open it and call connections `on_open`"""
if self.state == CONNECTING:
self.state = OPEN
self.conn.on_open(self.conn_info) | [
"def",
"verify_state",
"(",
"self",
")",
":",
"if",
"self",
".",
"state",
"==",
"CONNECTING",
":",
"self",
".",
"state",
"=",
"OPEN",
"self",
".",
"conn",
".",
"on_open",
"(",
"self",
".",
"conn_info",
")"
] | Verify if session was not yet opened. If it is, open it and call connections `on_open` | [
"Verify",
"if",
"session",
"was",
"not",
"yet",
"opened",
".",
"If",
"it",
"is",
"open",
"it",
"and",
"call",
"connections",
"on_open"
] | bd3a99b407f1181f054b3b1730f438dde375ca1c | https://github.com/mrjoes/sockjs-tornado/blob/bd3a99b407f1181f054b3b1730f438dde375ca1c/sockjs/tornado/session.py#L107-L112 | train |
mrjoes/sockjs-tornado | sockjs/tornado/session.py | BaseSession.delayed_close | def delayed_close(self):
"""Delayed close - won't close immediately, but on next ioloop tick."""
self.state = CLOSING
self.server.io_loop.add_callback(self.close) | python | def delayed_close(self):
"""Delayed close - won't close immediately, but on next ioloop tick."""
self.state = CLOSING
self.server.io_loop.add_callback(self.close) | [
"def",
"delayed_close",
"(",
"self",
")",
":",
"self",
".",
"state",
"=",
"CLOSING",
"self",
".",
"server",
".",
"io_loop",
".",
"add_callback",
"(",
"self",
".",
"close",
")"
] | Delayed close - won't close immediately, but on next ioloop tick. | [
"Delayed",
"close",
"-",
"won",
"t",
"close",
"immediately",
"but",
"on",
"next",
"ioloop",
"tick",
"."
] | bd3a99b407f1181f054b3b1730f438dde375ca1c | https://github.com/mrjoes/sockjs-tornado/blob/bd3a99b407f1181f054b3b1730f438dde375ca1c/sockjs/tornado/session.py#L151-L154 | train |
mrjoes/sockjs-tornado | sockjs/tornado/session.py | Session.on_delete | def on_delete(self, forced):
"""Session expiration callback
`forced`
If session item explicitly deleted, forced will be set to True. If
item expired, will be set to False.
"""
# Do not remove connection if it was not forced and there's running connection
... | python | def on_delete(self, forced):
"""Session expiration callback
`forced`
If session item explicitly deleted, forced will be set to True. If
item expired, will be set to False.
"""
# Do not remove connection if it was not forced and there's running connection
... | [
"def",
"on_delete",
"(",
"self",
",",
"forced",
")",
":",
"if",
"not",
"forced",
"and",
"self",
".",
"handler",
"is",
"not",
"None",
"and",
"not",
"self",
".",
"is_closed",
":",
"self",
".",
"promote",
"(",
")",
"else",
":",
"self",
".",
"close",
"... | Session expiration callback
`forced`
If session item explicitly deleted, forced will be set to True. If
item expired, will be set to False. | [
"Session",
"expiration",
"callback"
] | bd3a99b407f1181f054b3b1730f438dde375ca1c | https://github.com/mrjoes/sockjs-tornado/blob/bd3a99b407f1181f054b3b1730f438dde375ca1c/sockjs/tornado/session.py#L241-L252 | train |
mrjoes/sockjs-tornado | sockjs/tornado/session.py | Session.remove_handler | def remove_handler(self, handler):
"""Detach active handler from the session
`handler`
Handler to remove
"""
super(Session, self).remove_handler(handler)
self.promote()
self.stop_heartbeat() | python | def remove_handler(self, handler):
"""Detach active handler from the session
`handler`
Handler to remove
"""
super(Session, self).remove_handler(handler)
self.promote()
self.stop_heartbeat() | [
"def",
"remove_handler",
"(",
"self",
",",
"handler",
")",
":",
"super",
"(",
"Session",
",",
"self",
")",
".",
"remove_handler",
"(",
"handler",
")",
"self",
".",
"promote",
"(",
")",
"self",
".",
"stop_heartbeat",
"(",
")"
] | Detach active handler from the session
`handler`
Handler to remove | [
"Detach",
"active",
"handler",
"from",
"the",
"session"
] | bd3a99b407f1181f054b3b1730f438dde375ca1c | https://github.com/mrjoes/sockjs-tornado/blob/bd3a99b407f1181f054b3b1730f438dde375ca1c/sockjs/tornado/session.py#L303-L312 | train |
mrjoes/sockjs-tornado | sockjs/tornado/migrate.py | WebsocketHandler.on_open | def on_open(self, info):
"""sockjs-tornado on_open handler"""
# Store some properties
self.ip = info.ip
# Create fake request object
self.request = info
# Call open
self.open() | python | def on_open(self, info):
"""sockjs-tornado on_open handler"""
# Store some properties
self.ip = info.ip
# Create fake request object
self.request = info
# Call open
self.open() | [
"def",
"on_open",
"(",
"self",
",",
"info",
")",
":",
"self",
".",
"ip",
"=",
"info",
".",
"ip",
"self",
".",
"request",
"=",
"info",
"self",
".",
"open",
"(",
")"
] | sockjs-tornado on_open handler | [
"sockjs",
"-",
"tornado",
"on_open",
"handler"
] | bd3a99b407f1181f054b3b1730f438dde375ca1c | https://github.com/mrjoes/sockjs-tornado/blob/bd3a99b407f1181f054b3b1730f438dde375ca1c/sockjs/tornado/migrate.py#L22-L31 | train |
danielfrg/s3contents | s3contents/genericmanager.py | GenericContentsManager._notebook_model_from_path | def _notebook_model_from_path(self, path, content=False, format=None):
"""
Build a notebook model from database record.
"""
model = base_model(path)
model["type"] = "notebook"
if self.fs.isfile(path):
model["last_modified"] = model["created"] = self.fs.lstat(p... | python | def _notebook_model_from_path(self, path, content=False, format=None):
"""
Build a notebook model from database record.
"""
model = base_model(path)
model["type"] = "notebook"
if self.fs.isfile(path):
model["last_modified"] = model["created"] = self.fs.lstat(p... | [
"def",
"_notebook_model_from_path",
"(",
"self",
",",
"path",
",",
"content",
"=",
"False",
",",
"format",
"=",
"None",
")",
":",
"model",
"=",
"base_model",
"(",
"path",
")",
"model",
"[",
"\"type\"",
"]",
"=",
"\"notebook\"",
"if",
"self",
".",
"fs",
... | Build a notebook model from database record. | [
"Build",
"a",
"notebook",
"model",
"from",
"database",
"record",
"."
] | d7e398c7da8836ac7579fa475bded06838e053ea | https://github.com/danielfrg/s3contents/blob/d7e398c7da8836ac7579fa475bded06838e053ea/s3contents/genericmanager.py#L111-L130 | train |
danielfrg/s3contents | s3contents/genericmanager.py | GenericContentsManager._file_model_from_path | def _file_model_from_path(self, path, content=False, format=None):
"""
Build a file model from database record.
"""
model = base_model(path)
model["type"] = "file"
if self.fs.isfile(path):
model["last_modified"] = model["created"] = self.fs.lstat(path)["ST_MTI... | python | def _file_model_from_path(self, path, content=False, format=None):
"""
Build a file model from database record.
"""
model = base_model(path)
model["type"] = "file"
if self.fs.isfile(path):
model["last_modified"] = model["created"] = self.fs.lstat(path)["ST_MTI... | [
"def",
"_file_model_from_path",
"(",
"self",
",",
"path",
",",
"content",
"=",
"False",
",",
"format",
"=",
"None",
")",
":",
"model",
"=",
"base_model",
"(",
"path",
")",
"model",
"[",
"\"type\"",
"]",
"=",
"\"file\"",
"if",
"self",
".",
"fs",
".",
... | Build a file model from database record. | [
"Build",
"a",
"file",
"model",
"from",
"database",
"record",
"."
] | d7e398c7da8836ac7579fa475bded06838e053ea | https://github.com/danielfrg/s3contents/blob/d7e398c7da8836ac7579fa475bded06838e053ea/s3contents/genericmanager.py#L132-L156 | train |
danielfrg/s3contents | s3contents/genericmanager.py | GenericContentsManager._convert_file_records | def _convert_file_records(self, paths):
"""
Applies _notebook_model_from_s3_path or _file_model_from_s3_path to each entry of `paths`,
depending on the result of `guess_type`.
"""
ret = []
for path in paths:
# path = self.fs.remove_prefix(path, self.prefix) #... | python | def _convert_file_records(self, paths):
"""
Applies _notebook_model_from_s3_path or _file_model_from_s3_path to each entry of `paths`,
depending on the result of `guess_type`.
"""
ret = []
for path in paths:
# path = self.fs.remove_prefix(path, self.prefix) #... | [
"def",
"_convert_file_records",
"(",
"self",
",",
"paths",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"path",
"in",
"paths",
":",
"if",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
"==",
"self",
".",
"fs",
".",
"dir_keep_file",
":",
"continue",
... | Applies _notebook_model_from_s3_path or _file_model_from_s3_path to each entry of `paths`,
depending on the result of `guess_type`. | [
"Applies",
"_notebook_model_from_s3_path",
"or",
"_file_model_from_s3_path",
"to",
"each",
"entry",
"of",
"paths",
"depending",
"on",
"the",
"result",
"of",
"guess_type",
"."
] | d7e398c7da8836ac7579fa475bded06838e053ea | https://github.com/danielfrg/s3contents/blob/d7e398c7da8836ac7579fa475bded06838e053ea/s3contents/genericmanager.py#L158-L177 | train |
danielfrg/s3contents | s3contents/genericmanager.py | GenericContentsManager.save | def save(self, model, path):
"""Save a file or directory model to path.
"""
self.log.debug("S3contents.GenericManager: save %s: '%s'", model, path)
if "type" not in model:
self.do_error("No model type provided", 400)
if "content" not in model and model["type"] != "dir... | python | def save(self, model, path):
"""Save a file or directory model to path.
"""
self.log.debug("S3contents.GenericManager: save %s: '%s'", model, path)
if "type" not in model:
self.do_error("No model type provided", 400)
if "content" not in model and model["type"] != "dir... | [
"def",
"save",
"(",
"self",
",",
"model",
",",
"path",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"S3contents.GenericManager: save %s: '%s'\"",
",",
"model",
",",
"path",
")",
"if",
"\"type\"",
"not",
"in",
"model",
":",
"self",
".",
"do_error",
... | Save a file or directory model to path. | [
"Save",
"a",
"file",
"or",
"directory",
"model",
"to",
"path",
"."
] | d7e398c7da8836ac7579fa475bded06838e053ea | https://github.com/danielfrg/s3contents/blob/d7e398c7da8836ac7579fa475bded06838e053ea/s3contents/genericmanager.py#L179-L205 | train |
danielfrg/s3contents | s3contents/genericmanager.py | GenericContentsManager.rename_file | def rename_file(self, old_path, new_path):
"""Rename a file or directory.
NOTE: This method is unfortunately named on the base class. It
actually moves a file or a directory.
"""
self.log.debug("S3contents.GenericManager: Init rename of '%s' to '%s'", old_path, new_path)
... | python | def rename_file(self, old_path, new_path):
"""Rename a file or directory.
NOTE: This method is unfortunately named on the base class. It
actually moves a file or a directory.
"""
self.log.debug("S3contents.GenericManager: Init rename of '%s' to '%s'", old_path, new_path)
... | [
"def",
"rename_file",
"(",
"self",
",",
"old_path",
",",
"new_path",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"S3contents.GenericManager: Init rename of '%s' to '%s'\"",
",",
"old_path",
",",
"new_path",
")",
"if",
"self",
".",
"file_exists",
"(",
"new... | Rename a file or directory.
NOTE: This method is unfortunately named on the base class. It
actually moves a file or a directory. | [
"Rename",
"a",
"file",
"or",
"directory",
"."
] | d7e398c7da8836ac7579fa475bded06838e053ea | https://github.com/danielfrg/s3contents/blob/d7e398c7da8836ac7579fa475bded06838e053ea/s3contents/genericmanager.py#L223-L237 | train |
danielfrg/s3contents | s3contents/genericmanager.py | GenericContentsManager.delete_file | def delete_file(self, path):
"""Delete the file or directory at path.
"""
self.log.debug("S3contents.GenericManager: delete_file '%s'", path)
if self.file_exists(path) or self.dir_exists(path):
self.fs.rm(path)
else:
self.no_such_entity(path) | python | def delete_file(self, path):
"""Delete the file or directory at path.
"""
self.log.debug("S3contents.GenericManager: delete_file '%s'", path)
if self.file_exists(path) or self.dir_exists(path):
self.fs.rm(path)
else:
self.no_such_entity(path) | [
"def",
"delete_file",
"(",
"self",
",",
"path",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"S3contents.GenericManager: delete_file '%s'\"",
",",
"path",
")",
"if",
"self",
".",
"file_exists",
"(",
"path",
")",
"or",
"self",
".",
"dir_exists",
"(",
... | Delete the file or directory at path. | [
"Delete",
"the",
"file",
"or",
"directory",
"at",
"path",
"."
] | d7e398c7da8836ac7579fa475bded06838e053ea | https://github.com/danielfrg/s3contents/blob/d7e398c7da8836ac7579fa475bded06838e053ea/s3contents/genericmanager.py#L239-L246 | train |
danielfrg/s3contents | s3contents/gcs_fs.py | GCSFS.path | def path(self, *path):
"""Utility to join paths including the bucket and prefix"""
path = list(filter(None, path))
path = self.unprefix(path)
items = [self.prefix_] + path
return self.join(*items) | python | def path(self, *path):
"""Utility to join paths including the bucket and prefix"""
path = list(filter(None, path))
path = self.unprefix(path)
items = [self.prefix_] + path
return self.join(*items) | [
"def",
"path",
"(",
"self",
",",
"*",
"path",
")",
":",
"path",
"=",
"list",
"(",
"filter",
"(",
"None",
",",
"path",
")",
")",
"path",
"=",
"self",
".",
"unprefix",
"(",
"path",
")",
"items",
"=",
"[",
"self",
".",
"prefix_",
"]",
"+",
"path",... | Utility to join paths including the bucket and prefix | [
"Utility",
"to",
"join",
"paths",
"including",
"the",
"bucket",
"and",
"prefix"
] | d7e398c7da8836ac7579fa475bded06838e053ea | https://github.com/danielfrg/s3contents/blob/d7e398c7da8836ac7579fa475bded06838e053ea/s3contents/gcs_fs.py#L167-L172 | train |
MagicTheGathering/mtg-sdk-python | mtgsdk/restclient.py | RestClient.get | def get(url, params={}):
"""Invoke an HTTP GET request on a url
Args:
url (string): URL endpoint to request
params (dict): Dictionary of url parameters
Returns:
dict: JSON response as a dictionary
"""
request_url = url
if len(params):... | python | def get(url, params={}):
"""Invoke an HTTP GET request on a url
Args:
url (string): URL endpoint to request
params (dict): Dictionary of url parameters
Returns:
dict: JSON response as a dictionary
"""
request_url = url
if len(params):... | [
"def",
"get",
"(",
"url",
",",
"params",
"=",
"{",
"}",
")",
":",
"request_url",
"=",
"url",
"if",
"len",
"(",
"params",
")",
":",
"request_url",
"=",
"\"{}?{}\"",
".",
"format",
"(",
"url",
",",
"urlencode",
"(",
"params",
")",
")",
"try",
":",
... | Invoke an HTTP GET request on a url
Args:
url (string): URL endpoint to request
params (dict): Dictionary of url parameters
Returns:
dict: JSON response as a dictionary | [
"Invoke",
"an",
"HTTP",
"GET",
"request",
"on",
"a",
"url"
] | 3d28fe209d72356a559321355d3f7e53ca78a9cc | https://github.com/MagicTheGathering/mtg-sdk-python/blob/3d28fe209d72356a559321355d3f7e53ca78a9cc/mtgsdk/restclient.py#L20-L40 | train |
MagicTheGathering/mtg-sdk-python | mtgsdk/querybuilder.py | QueryBuilder.find | def find(self, id):
"""Get a resource by its id
Args:
id (string): Resource id
Returns:
object: Instance of the resource type
"""
url = "{}/{}/{}".format(__endpoint__, self.type.RESOURCE, id)
response = RestClient.get(url)[self.type.RESOURCE[:-1]]... | python | def find(self, id):
"""Get a resource by its id
Args:
id (string): Resource id
Returns:
object: Instance of the resource type
"""
url = "{}/{}/{}".format(__endpoint__, self.type.RESOURCE, id)
response = RestClient.get(url)[self.type.RESOURCE[:-1]]... | [
"def",
"find",
"(",
"self",
",",
"id",
")",
":",
"url",
"=",
"\"{}/{}/{}\"",
".",
"format",
"(",
"__endpoint__",
",",
"self",
".",
"type",
".",
"RESOURCE",
",",
"id",
")",
"response",
"=",
"RestClient",
".",
"get",
"(",
"url",
")",
"[",
"self",
"."... | Get a resource by its id
Args:
id (string): Resource id
Returns:
object: Instance of the resource type | [
"Get",
"a",
"resource",
"by",
"its",
"id"
] | 3d28fe209d72356a559321355d3f7e53ca78a9cc | https://github.com/MagicTheGathering/mtg-sdk-python/blob/3d28fe209d72356a559321355d3f7e53ca78a9cc/mtgsdk/querybuilder.py#L19-L29 | train |
MagicTheGathering/mtg-sdk-python | mtgsdk/querybuilder.py | QueryBuilder.find_many | def find_many(self, url, type, resource):
"""Get a list of resources
Args:
url (string): URL to invoke
type (class): Class type
resource (string): The REST Resource
Returns:
list of object: List of resource instances
"""
return [ty... | python | def find_many(self, url, type, resource):
"""Get a list of resources
Args:
url (string): URL to invoke
type (class): Class type
resource (string): The REST Resource
Returns:
list of object: List of resource instances
"""
return [ty... | [
"def",
"find_many",
"(",
"self",
",",
"url",
",",
"type",
",",
"resource",
")",
":",
"return",
"[",
"type",
"(",
"item",
")",
"for",
"item",
"in",
"RestClient",
".",
"get",
"(",
"url",
")",
"[",
"resource",
"]",
"]"
] | Get a list of resources
Args:
url (string): URL to invoke
type (class): Class type
resource (string): The REST Resource
Returns:
list of object: List of resource instances | [
"Get",
"a",
"list",
"of",
"resources"
] | 3d28fe209d72356a559321355d3f7e53ca78a9cc | https://github.com/MagicTheGathering/mtg-sdk-python/blob/3d28fe209d72356a559321355d3f7e53ca78a9cc/mtgsdk/querybuilder.py#L31-L41 | train |
MagicTheGathering/mtg-sdk-python | mtgsdk/querybuilder.py | QueryBuilder.iter | def iter(self):
"""Gets all resources, automating paging through data
Returns:
iterable of object: Iterable of resource objects
"""
page = 1
fetch_all = True
url = "{}/{}".format(__endpoint__, self.type.RESOURCE)
if 'page' in self.params:
... | python | def iter(self):
"""Gets all resources, automating paging through data
Returns:
iterable of object: Iterable of resource objects
"""
page = 1
fetch_all = True
url = "{}/{}".format(__endpoint__, self.type.RESOURCE)
if 'page' in self.params:
... | [
"def",
"iter",
"(",
"self",
")",
":",
"page",
"=",
"1",
"fetch_all",
"=",
"True",
"url",
"=",
"\"{}/{}\"",
".",
"format",
"(",
"__endpoint__",
",",
"self",
".",
"type",
".",
"RESOURCE",
")",
"if",
"'page'",
"in",
"self",
".",
"params",
":",
"page",
... | Gets all resources, automating paging through data
Returns:
iterable of object: Iterable of resource objects | [
"Gets",
"all",
"resources",
"automating",
"paging",
"through",
"data"
] | 3d28fe209d72356a559321355d3f7e53ca78a9cc | https://github.com/MagicTheGathering/mtg-sdk-python/blob/3d28fe209d72356a559321355d3f7e53ca78a9cc/mtgsdk/querybuilder.py#L64-L89 | train |
MagicTheGathering/mtg-sdk-python | mtgsdk/querybuilder.py | QueryBuilder.array | def array(self):
"""Get all resources and return the result as an array
Returns:
array of str: Array of resources
"""
url = "{}/{}".format(__endpoint__, self.type.RESOURCE)
return RestClient.get(url, self.params)[self.type.RESOURCE] | python | def array(self):
"""Get all resources and return the result as an array
Returns:
array of str: Array of resources
"""
url = "{}/{}".format(__endpoint__, self.type.RESOURCE)
return RestClient.get(url, self.params)[self.type.RESOURCE] | [
"def",
"array",
"(",
"self",
")",
":",
"url",
"=",
"\"{}/{}\"",
".",
"format",
"(",
"__endpoint__",
",",
"self",
".",
"type",
".",
"RESOURCE",
")",
"return",
"RestClient",
".",
"get",
"(",
"url",
",",
"self",
".",
"params",
")",
"[",
"self",
".",
"... | Get all resources and return the result as an array
Returns:
array of str: Array of resources | [
"Get",
"all",
"resources",
"and",
"return",
"the",
"result",
"as",
"an",
"array"
] | 3d28fe209d72356a559321355d3f7e53ca78a9cc | https://github.com/MagicTheGathering/mtg-sdk-python/blob/3d28fe209d72356a559321355d3f7e53ca78a9cc/mtgsdk/querybuilder.py#L93-L100 | train |
dranjan/python-plyfile | plyfile.py | make2d | def make2d(array, cols=None, dtype=None):
'''
Make a 2D array from an array of arrays. The `cols' and `dtype'
arguments can be omitted if the array is not empty.
'''
if not len(array):
if cols is None or dtype is None:
raise RuntimeError(
"cols and dtype must be... | python | def make2d(array, cols=None, dtype=None):
'''
Make a 2D array from an array of arrays. The `cols' and `dtype'
arguments can be omitted if the array is not empty.
'''
if not len(array):
if cols is None or dtype is None:
raise RuntimeError(
"cols and dtype must be... | [
"def",
"make2d",
"(",
"array",
",",
"cols",
"=",
"None",
",",
"dtype",
"=",
"None",
")",
":",
"if",
"not",
"len",
"(",
"array",
")",
":",
"if",
"cols",
"is",
"None",
"or",
"dtype",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"cols and dtype mu... | Make a 2D array from an array of arrays. The `cols' and `dtype'
arguments can be omitted if the array is not empty. | [
"Make",
"a",
"2D",
"array",
"from",
"an",
"array",
"of",
"arrays",
".",
"The",
"cols",
"and",
"dtype",
"arguments",
"can",
"be",
"omitted",
"if",
"the",
"array",
"is",
"not",
"empty",
"."
] | 9f8e8708d3a071229cf292caae7d13264e11c88b | https://github.com/dranjan/python-plyfile/blob/9f8e8708d3a071229cf292caae7d13264e11c88b/plyfile.py#L91-L103 | train |
dranjan/python-plyfile | plyfile.py | PlyData._parse_header | def _parse_header(stream):
'''
Parse a PLY header from a readable file-like stream.
'''
parser = _PlyHeaderParser()
while parser.consume(stream.readline()):
pass
return PlyData(
[PlyElement(*e) for e in parser.elements],
parser.format... | python | def _parse_header(stream):
'''
Parse a PLY header from a readable file-like stream.
'''
parser = _PlyHeaderParser()
while parser.consume(stream.readline()):
pass
return PlyData(
[PlyElement(*e) for e in parser.elements],
parser.format... | [
"def",
"_parse_header",
"(",
"stream",
")",
":",
"parser",
"=",
"_PlyHeaderParser",
"(",
")",
"while",
"parser",
".",
"consume",
"(",
"stream",
".",
"readline",
"(",
")",
")",
":",
"pass",
"return",
"PlyData",
"(",
"[",
"PlyElement",
"(",
"*",
"e",
")"... | Parse a PLY header from a readable file-like stream. | [
"Parse",
"a",
"PLY",
"header",
"from",
"a",
"readable",
"file",
"-",
"like",
"stream",
"."
] | 9f8e8708d3a071229cf292caae7d13264e11c88b | https://github.com/dranjan/python-plyfile/blob/9f8e8708d3a071229cf292caae7d13264e11c88b/plyfile.py#L367-L382 | train |
dranjan/python-plyfile | plyfile.py | PlyData.read | def read(stream):
'''
Read PLY data from a readable file-like object or filename.
'''
(must_close, stream) = _open_stream(stream, 'read')
try:
data = PlyData._parse_header(stream)
for elt in data:
elt._read(stream, data.text, data.byte_ord... | python | def read(stream):
'''
Read PLY data from a readable file-like object or filename.
'''
(must_close, stream) = _open_stream(stream, 'read')
try:
data = PlyData._parse_header(stream)
for elt in data:
elt._read(stream, data.text, data.byte_ord... | [
"def",
"read",
"(",
"stream",
")",
":",
"(",
"must_close",
",",
"stream",
")",
"=",
"_open_stream",
"(",
"stream",
",",
"'read'",
")",
"try",
":",
"data",
"=",
"PlyData",
".",
"_parse_header",
"(",
"stream",
")",
"for",
"elt",
"in",
"data",
":",
"elt... | Read PLY data from a readable file-like object or filename. | [
"Read",
"PLY",
"data",
"from",
"a",
"readable",
"file",
"-",
"like",
"object",
"or",
"filename",
"."
] | 9f8e8708d3a071229cf292caae7d13264e11c88b | https://github.com/dranjan/python-plyfile/blob/9f8e8708d3a071229cf292caae7d13264e11c88b/plyfile.py#L385-L399 | train |
dranjan/python-plyfile | plyfile.py | PlyData.write | def write(self, stream):
'''
Write PLY data to a writeable file-like object or filename.
'''
(must_close, stream) = _open_stream(stream, 'write')
try:
stream.write(self.header.encode('ascii'))
stream.write(b'\n')
for elt in self:
... | python | def write(self, stream):
'''
Write PLY data to a writeable file-like object or filename.
'''
(must_close, stream) = _open_stream(stream, 'write')
try:
stream.write(self.header.encode('ascii'))
stream.write(b'\n')
for elt in self:
... | [
"def",
"write",
"(",
"self",
",",
"stream",
")",
":",
"(",
"must_close",
",",
"stream",
")",
"=",
"_open_stream",
"(",
"stream",
",",
"'write'",
")",
"try",
":",
"stream",
".",
"write",
"(",
"self",
".",
"header",
".",
"encode",
"(",
"'ascii'",
")",
... | Write PLY data to a writeable file-like object or filename. | [
"Write",
"PLY",
"data",
"to",
"a",
"writeable",
"file",
"-",
"like",
"object",
"or",
"filename",
"."
] | 9f8e8708d3a071229cf292caae7d13264e11c88b | https://github.com/dranjan/python-plyfile/blob/9f8e8708d3a071229cf292caae7d13264e11c88b/plyfile.py#L401-L414 | train |
dranjan/python-plyfile | plyfile.py | PlyData.header | def header(self):
'''
Provide PLY-formatted metadata for the instance.
'''
lines = ['ply']
if self.text:
lines.append('format ascii 1.0')
else:
lines.append('format ' +
_byte_order_reverse[self.byte_order] +
... | python | def header(self):
'''
Provide PLY-formatted metadata for the instance.
'''
lines = ['ply']
if self.text:
lines.append('format ascii 1.0')
else:
lines.append('format ' +
_byte_order_reverse[self.byte_order] +
... | [
"def",
"header",
"(",
"self",
")",
":",
"lines",
"=",
"[",
"'ply'",
"]",
"if",
"self",
".",
"text",
":",
"lines",
".",
"append",
"(",
"'format ascii 1.0'",
")",
"else",
":",
"lines",
".",
"append",
"(",
"'format '",
"+",
"_byte_order_reverse",
"[",
"se... | Provide PLY-formatted metadata for the instance. | [
"Provide",
"PLY",
"-",
"formatted",
"metadata",
"for",
"the",
"instance",
"."
] | 9f8e8708d3a071229cf292caae7d13264e11c88b | https://github.com/dranjan/python-plyfile/blob/9f8e8708d3a071229cf292caae7d13264e11c88b/plyfile.py#L417-L441 | train |
dranjan/python-plyfile | plyfile.py | PlyElement.describe | def describe(data, name, len_types={}, val_types={},
comments=[]):
'''
Construct a PlyElement from an array's metadata.
len_types and val_types can be given as mappings from list
property names to type strings (like 'u1', 'f4', etc., or
'int8', 'float32', etc.).... | python | def describe(data, name, len_types={}, val_types={},
comments=[]):
'''
Construct a PlyElement from an array's metadata.
len_types and val_types can be given as mappings from list
property names to type strings (like 'u1', 'f4', etc., or
'int8', 'float32', etc.).... | [
"def",
"describe",
"(",
"data",
",",
"name",
",",
"len_types",
"=",
"{",
"}",
",",
"val_types",
"=",
"{",
"}",
",",
"comments",
"=",
"[",
"]",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"_np",
".",
"ndarray",
")",
":",
"raise",
"TypeE... | Construct a PlyElement from an array's metadata.
len_types and val_types can be given as mappings from list
property names to type strings (like 'u1', 'f4', etc., or
'int8', 'float32', etc.). These can be used to define the length
and value types of list properties. List property lengt... | [
"Construct",
"a",
"PlyElement",
"from",
"an",
"array",
"s",
"metadata",
"."
] | 9f8e8708d3a071229cf292caae7d13264e11c88b | https://github.com/dranjan/python-plyfile/blob/9f8e8708d3a071229cf292caae7d13264e11c88b/plyfile.py#L572-L630 | train |
dranjan/python-plyfile | plyfile.py | PlyElement._read | def _read(self, stream, text, byte_order):
'''
Read the actual data from a PLY file.
'''
dtype = self.dtype(byte_order)
if text:
self._read_txt(stream)
elif _can_mmap(stream) and not self._have_list:
# Loading the data is straightforward. We will... | python | def _read(self, stream, text, byte_order):
'''
Read the actual data from a PLY file.
'''
dtype = self.dtype(byte_order)
if text:
self._read_txt(stream)
elif _can_mmap(stream) and not self._have_list:
# Loading the data is straightforward. We will... | [
"def",
"_read",
"(",
"self",
",",
"stream",
",",
"text",
",",
"byte_order",
")",
":",
"dtype",
"=",
"self",
".",
"dtype",
"(",
"byte_order",
")",
"if",
"text",
":",
"self",
".",
"_read_txt",
"(",
"stream",
")",
"elif",
"_can_mmap",
"(",
"stream",
")"... | Read the actual data from a PLY file. | [
"Read",
"the",
"actual",
"data",
"from",
"a",
"PLY",
"file",
"."
] | 9f8e8708d3a071229cf292caae7d13264e11c88b | https://github.com/dranjan/python-plyfile/blob/9f8e8708d3a071229cf292caae7d13264e11c88b/plyfile.py#L632-L658 | train |
dranjan/python-plyfile | plyfile.py | PlyElement._write | def _write(self, stream, text, byte_order):
'''
Write the data to a PLY file.
'''
if text:
self._write_txt(stream)
else:
if self._have_list:
# There are list properties, so serialization is
# slightly complicated.
... | python | def _write(self, stream, text, byte_order):
'''
Write the data to a PLY file.
'''
if text:
self._write_txt(stream)
else:
if self._have_list:
# There are list properties, so serialization is
# slightly complicated.
... | [
"def",
"_write",
"(",
"self",
",",
"stream",
",",
"text",
",",
"byte_order",
")",
":",
"if",
"text",
":",
"self",
".",
"_write_txt",
"(",
"stream",
")",
"else",
":",
"if",
"self",
".",
"_have_list",
":",
"self",
".",
"_write_bin",
"(",
"stream",
",",... | Write the data to a PLY file. | [
"Write",
"the",
"data",
"to",
"a",
"PLY",
"file",
"."
] | 9f8e8708d3a071229cf292caae7d13264e11c88b | https://github.com/dranjan/python-plyfile/blob/9f8e8708d3a071229cf292caae7d13264e11c88b/plyfile.py#L660-L676 | train |
dranjan/python-plyfile | plyfile.py | PlyElement._read_txt | def _read_txt(self, stream):
'''
Load a PLY element from an ASCII-format PLY file. The element
may contain list properties.
'''
self._data = _np.empty(self.count, dtype=self.dtype())
k = 0
for line in _islice(iter(stream.readline, b''), self.count):
... | python | def _read_txt(self, stream):
'''
Load a PLY element from an ASCII-format PLY file. The element
may contain list properties.
'''
self._data = _np.empty(self.count, dtype=self.dtype())
k = 0
for line in _islice(iter(stream.readline, b''), self.count):
... | [
"def",
"_read_txt",
"(",
"self",
",",
"stream",
")",
":",
"self",
".",
"_data",
"=",
"_np",
".",
"empty",
"(",
"self",
".",
"count",
",",
"dtype",
"=",
"self",
".",
"dtype",
"(",
")",
")",
"k",
"=",
"0",
"for",
"line",
"in",
"_islice",
"(",
"it... | Load a PLY element from an ASCII-format PLY file. The element
may contain list properties. | [
"Load",
"a",
"PLY",
"element",
"from",
"an",
"ASCII",
"-",
"format",
"PLY",
"file",
".",
"The",
"element",
"may",
"contain",
"list",
"properties",
"."
] | 9f8e8708d3a071229cf292caae7d13264e11c88b | https://github.com/dranjan/python-plyfile/blob/9f8e8708d3a071229cf292caae7d13264e11c88b/plyfile.py#L678-L709 | train |
dranjan/python-plyfile | plyfile.py | PlyElement._write_txt | def _write_txt(self, stream):
'''
Save a PLY element to an ASCII-format PLY file. The element may
contain list properties.
'''
for rec in self.data:
fields = []
for prop in self.properties:
fields.extend(prop._to_fields(rec[prop.name]))
... | python | def _write_txt(self, stream):
'''
Save a PLY element to an ASCII-format PLY file. The element may
contain list properties.
'''
for rec in self.data:
fields = []
for prop in self.properties:
fields.extend(prop._to_fields(rec[prop.name]))
... | [
"def",
"_write_txt",
"(",
"self",
",",
"stream",
")",
":",
"for",
"rec",
"in",
"self",
".",
"data",
":",
"fields",
"=",
"[",
"]",
"for",
"prop",
"in",
"self",
".",
"properties",
":",
"fields",
".",
"extend",
"(",
"prop",
".",
"_to_fields",
"(",
"re... | Save a PLY element to an ASCII-format PLY file. The element may
contain list properties. | [
"Save",
"a",
"PLY",
"element",
"to",
"an",
"ASCII",
"-",
"format",
"PLY",
"file",
".",
"The",
"element",
"may",
"contain",
"list",
"properties",
"."
] | 9f8e8708d3a071229cf292caae7d13264e11c88b | https://github.com/dranjan/python-plyfile/blob/9f8e8708d3a071229cf292caae7d13264e11c88b/plyfile.py#L711-L722 | train |
dranjan/python-plyfile | plyfile.py | PlyElement._read_bin | def _read_bin(self, stream, byte_order):
'''
Load a PLY element from a binary PLY file. The element may
contain list properties.
'''
self._data = _np.empty(self.count, dtype=self.dtype(byte_order))
for k in _range(self.count):
for prop in self.properties:
... | python | def _read_bin(self, stream, byte_order):
'''
Load a PLY element from a binary PLY file. The element may
contain list properties.
'''
self._data = _np.empty(self.count, dtype=self.dtype(byte_order))
for k in _range(self.count):
for prop in self.properties:
... | [
"def",
"_read_bin",
"(",
"self",
",",
"stream",
",",
"byte_order",
")",
":",
"self",
".",
"_data",
"=",
"_np",
".",
"empty",
"(",
"self",
".",
"count",
",",
"dtype",
"=",
"self",
".",
"dtype",
"(",
"byte_order",
")",
")",
"for",
"k",
"in",
"_range"... | Load a PLY element from a binary PLY file. The element may
contain list properties. | [
"Load",
"a",
"PLY",
"element",
"from",
"a",
"binary",
"PLY",
"file",
".",
"The",
"element",
"may",
"contain",
"list",
"properties",
"."
] | 9f8e8708d3a071229cf292caae7d13264e11c88b | https://github.com/dranjan/python-plyfile/blob/9f8e8708d3a071229cf292caae7d13264e11c88b/plyfile.py#L724-L739 | train |
dranjan/python-plyfile | plyfile.py | PlyElement._write_bin | def _write_bin(self, stream, byte_order):
'''
Save a PLY element to a binary PLY file. The element may
contain list properties.
'''
for rec in self.data:
for prop in self.properties:
prop._write_bin(rec[prop.name], stream, byte_order) | python | def _write_bin(self, stream, byte_order):
'''
Save a PLY element to a binary PLY file. The element may
contain list properties.
'''
for rec in self.data:
for prop in self.properties:
prop._write_bin(rec[prop.name], stream, byte_order) | [
"def",
"_write_bin",
"(",
"self",
",",
"stream",
",",
"byte_order",
")",
":",
"for",
"rec",
"in",
"self",
".",
"data",
":",
"for",
"prop",
"in",
"self",
".",
"properties",
":",
"prop",
".",
"_write_bin",
"(",
"rec",
"[",
"prop",
".",
"name",
"]",
"... | Save a PLY element to a binary PLY file. The element may
contain list properties. | [
"Save",
"a",
"PLY",
"element",
"to",
"a",
"binary",
"PLY",
"file",
".",
"The",
"element",
"may",
"contain",
"list",
"properties",
"."
] | 9f8e8708d3a071229cf292caae7d13264e11c88b | https://github.com/dranjan/python-plyfile/blob/9f8e8708d3a071229cf292caae7d13264e11c88b/plyfile.py#L741-L749 | train |
dranjan/python-plyfile | plyfile.py | PlyElement.header | def header(self):
'''
Format this element's metadata as it would appear in a PLY
header.
'''
lines = ['element %s %d' % (self.name, self.count)]
# Some information is lost here, since all comments are placed
# between the 'element' line and the first property de... | python | def header(self):
'''
Format this element's metadata as it would appear in a PLY
header.
'''
lines = ['element %s %d' % (self.name, self.count)]
# Some information is lost here, since all comments are placed
# between the 'element' line and the first property de... | [
"def",
"header",
"(",
"self",
")",
":",
"lines",
"=",
"[",
"'element %s %d'",
"%",
"(",
"self",
".",
"name",
",",
"self",
".",
"count",
")",
"]",
"for",
"c",
"in",
"self",
".",
"comments",
":",
"lines",
".",
"append",
"(",
"'comment '",
"+",
"c",
... | Format this element's metadata as it would appear in a PLY
header. | [
"Format",
"this",
"element",
"s",
"metadata",
"as",
"it",
"would",
"appear",
"in",
"a",
"PLY",
"header",
"."
] | 9f8e8708d3a071229cf292caae7d13264e11c88b | https://github.com/dranjan/python-plyfile/blob/9f8e8708d3a071229cf292caae7d13264e11c88b/plyfile.py#L752-L767 | train |
dranjan/python-plyfile | plyfile.py | PlyProperty._from_fields | def _from_fields(self, fields):
'''
Parse from generator. Raise StopIteration if the property could
not be read.
'''
return _np.dtype(self.dtype()).type(next(fields)) | python | def _from_fields(self, fields):
'''
Parse from generator. Raise StopIteration if the property could
not be read.
'''
return _np.dtype(self.dtype()).type(next(fields)) | [
"def",
"_from_fields",
"(",
"self",
",",
"fields",
")",
":",
"return",
"_np",
".",
"dtype",
"(",
"self",
".",
"dtype",
"(",
")",
")",
".",
"type",
"(",
"next",
"(",
"fields",
")",
")"
] | Parse from generator. Raise StopIteration if the property could
not be read. | [
"Parse",
"from",
"generator",
".",
"Raise",
"StopIteration",
"if",
"the",
"property",
"could",
"not",
"be",
"read",
"."
] | 9f8e8708d3a071229cf292caae7d13264e11c88b | https://github.com/dranjan/python-plyfile/blob/9f8e8708d3a071229cf292caae7d13264e11c88b/plyfile.py#L826-L832 | train |
dranjan/python-plyfile | plyfile.py | PlyProperty._read_bin | def _read_bin(self, stream, byte_order):
'''
Read data from a binary stream. Raise StopIteration if the
property could not be read.
'''
try:
return _read_array(stream, self.dtype(byte_order), 1)[0]
except IndexError:
raise StopIteration | python | def _read_bin(self, stream, byte_order):
'''
Read data from a binary stream. Raise StopIteration if the
property could not be read.
'''
try:
return _read_array(stream, self.dtype(byte_order), 1)[0]
except IndexError:
raise StopIteration | [
"def",
"_read_bin",
"(",
"self",
",",
"stream",
",",
"byte_order",
")",
":",
"try",
":",
"return",
"_read_array",
"(",
"stream",
",",
"self",
".",
"dtype",
"(",
"byte_order",
")",
",",
"1",
")",
"[",
"0",
"]",
"except",
"IndexError",
":",
"raise",
"S... | Read data from a binary stream. Raise StopIteration if the
property could not be read. | [
"Read",
"data",
"from",
"a",
"binary",
"stream",
".",
"Raise",
"StopIteration",
"if",
"the",
"property",
"could",
"not",
"be",
"read",
"."
] | 9f8e8708d3a071229cf292caae7d13264e11c88b | https://github.com/dranjan/python-plyfile/blob/9f8e8708d3a071229cf292caae7d13264e11c88b/plyfile.py#L841-L850 | train |
99designs/colorific | colorific/palette.py | color_stream_st | def color_stream_st(istream=sys.stdin, save_palette=False, **kwargs):
"""
Read filenames from the input stream and detect their palette.
"""
for line in istream:
filename = line.strip()
try:
palette = extract_colors(filename, **kwargs)
except Exception as e:
... | python | def color_stream_st(istream=sys.stdin, save_palette=False, **kwargs):
"""
Read filenames from the input stream and detect their palette.
"""
for line in istream:
filename = line.strip()
try:
palette = extract_colors(filename, **kwargs)
except Exception as e:
... | [
"def",
"color_stream_st",
"(",
"istream",
"=",
"sys",
".",
"stdin",
",",
"save_palette",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"for",
"line",
"in",
"istream",
":",
"filename",
"=",
"line",
".",
"strip",
"(",
")",
"try",
":",
"palette",
"=",
"e... | Read filenames from the input stream and detect their palette. | [
"Read",
"filenames",
"from",
"the",
"input",
"stream",
"and",
"detect",
"their",
"palette",
"."
] | f83e59f61295500f5527dee5894207f2f033cf35 | https://github.com/99designs/colorific/blob/f83e59f61295500f5527dee5894207f2f033cf35/colorific/palette.py#L37-L52 | train |
99designs/colorific | colorific/palette.py | color_stream_mt | def color_stream_mt(istream=sys.stdin, n=config.N_PROCESSES, **kwargs):
"""
Read filenames from the input stream and detect their palette using
multiple processes.
"""
queue = multiprocessing.Queue(1000)
lock = multiprocessing.Lock()
pool = [multiprocessing.Process(target=color_process, arg... | python | def color_stream_mt(istream=sys.stdin, n=config.N_PROCESSES, **kwargs):
"""
Read filenames from the input stream and detect their palette using
multiple processes.
"""
queue = multiprocessing.Queue(1000)
lock = multiprocessing.Lock()
pool = [multiprocessing.Process(target=color_process, arg... | [
"def",
"color_stream_mt",
"(",
"istream",
"=",
"sys",
".",
"stdin",
",",
"n",
"=",
"config",
".",
"N_PROCESSES",
",",
"**",
"kwargs",
")",
":",
"queue",
"=",
"multiprocessing",
".",
"Queue",
"(",
"1000",
")",
"lock",
"=",
"multiprocessing",
".",
"Lock",
... | Read filenames from the input stream and detect their palette using
multiple processes. | [
"Read",
"filenames",
"from",
"the",
"input",
"stream",
"and",
"detect",
"their",
"palette",
"using",
"multiple",
"processes",
"."
] | f83e59f61295500f5527dee5894207f2f033cf35 | https://github.com/99designs/colorific/blob/f83e59f61295500f5527dee5894207f2f033cf35/colorific/palette.py#L55-L81 | train |
99designs/colorific | colorific/palette.py | color_process | def color_process(queue, lock):
"Receive filenames and get the colors from their images."
while True:
block = queue.get()
if block == config.SENTINEL:
break
for filename in block:
try:
palette = extract_colors(filename)
except: # TODO... | python | def color_process(queue, lock):
"Receive filenames and get the colors from their images."
while True:
block = queue.get()
if block == config.SENTINEL:
break
for filename in block:
try:
palette = extract_colors(filename)
except: # TODO... | [
"def",
"color_process",
"(",
"queue",
",",
"lock",
")",
":",
"\"Receive filenames and get the colors from their images.\"",
"while",
"True",
":",
"block",
"=",
"queue",
".",
"get",
"(",
")",
"if",
"block",
"==",
"config",
".",
"SENTINEL",
":",
"break",
"for",
... | Receive filenames and get the colors from their images. | [
"Receive",
"filenames",
"and",
"get",
"the",
"colors",
"from",
"their",
"images",
"."
] | f83e59f61295500f5527dee5894207f2f033cf35 | https://github.com/99designs/colorific/blob/f83e59f61295500f5527dee5894207f2f033cf35/colorific/palette.py#L84-L100 | train |
99designs/colorific | colorific/palette.py | extract_colors | def extract_colors(
filename_or_img, min_saturation=config.MIN_SATURATION,
min_distance=config.MIN_DISTANCE, max_colors=config.MAX_COLORS,
min_prominence=config.MIN_PROMINENCE, n_quantized=config.N_QUANTIZED):
"""
Determine what the major colors are in the given image.
"""
if Ima... | python | def extract_colors(
filename_or_img, min_saturation=config.MIN_SATURATION,
min_distance=config.MIN_DISTANCE, max_colors=config.MAX_COLORS,
min_prominence=config.MIN_PROMINENCE, n_quantized=config.N_QUANTIZED):
"""
Determine what the major colors are in the given image.
"""
if Ima... | [
"def",
"extract_colors",
"(",
"filename_or_img",
",",
"min_saturation",
"=",
"config",
".",
"MIN_SATURATION",
",",
"min_distance",
"=",
"config",
".",
"MIN_DISTANCE",
",",
"max_colors",
"=",
"config",
".",
"MAX_COLORS",
",",
"min_prominence",
"=",
"config",
".",
... | Determine what the major colors are in the given image. | [
"Determine",
"what",
"the",
"major",
"colors",
"are",
"in",
"the",
"given",
"image",
"."
] | f83e59f61295500f5527dee5894207f2f033cf35 | https://github.com/99designs/colorific/blob/f83e59f61295500f5527dee5894207f2f033cf35/colorific/palette.py#L124-L194 | train |
99designs/colorific | colorific/palette.py | save_palette_as_image | def save_palette_as_image(filename, palette):
"Save palette as a PNG with labeled, colored blocks"
output_filename = '%s_palette.png' % filename[:filename.rfind('.')]
size = (80 * len(palette.colors), 80)
im = Image.new('RGB', size)
draw = ImageDraw.Draw(im)
for i, c in enumerate(palette.colors)... | python | def save_palette_as_image(filename, palette):
"Save palette as a PNG with labeled, colored blocks"
output_filename = '%s_palette.png' % filename[:filename.rfind('.')]
size = (80 * len(palette.colors), 80)
im = Image.new('RGB', size)
draw = ImageDraw.Draw(im)
for i, c in enumerate(palette.colors)... | [
"def",
"save_palette_as_image",
"(",
"filename",
",",
"palette",
")",
":",
"\"Save palette as a PNG with labeled, colored blocks\"",
"output_filename",
"=",
"'%s_palette.png'",
"%",
"filename",
"[",
":",
"filename",
".",
"rfind",
"(",
"'.'",
")",
"]",
"size",
"=",
"... | Save palette as a PNG with labeled, colored blocks | [
"Save",
"palette",
"as",
"a",
"PNG",
"with",
"labeled",
"colored",
"blocks"
] | f83e59f61295500f5527dee5894207f2f033cf35 | https://github.com/99designs/colorific/blob/f83e59f61295500f5527dee5894207f2f033cf35/colorific/palette.py#L235-L255 | train |
99designs/colorific | colorific/palette.py | autocrop | def autocrop(im, bgcolor):
"Crop away a border of the given background color."
if im.mode != "RGB":
im = im.convert("RGB")
bg = Image.new("RGB", im.size, bgcolor)
diff = ImageChops.difference(im, bg)
bbox = diff.getbbox()
if bbox:
return im.crop(bbox)
return im | python | def autocrop(im, bgcolor):
"Crop away a border of the given background color."
if im.mode != "RGB":
im = im.convert("RGB")
bg = Image.new("RGB", im.size, bgcolor)
diff = ImageChops.difference(im, bg)
bbox = diff.getbbox()
if bbox:
return im.crop(bbox)
return im | [
"def",
"autocrop",
"(",
"im",
",",
"bgcolor",
")",
":",
"\"Crop away a border of the given background color.\"",
"if",
"im",
".",
"mode",
"!=",
"\"RGB\"",
":",
"im",
"=",
"im",
".",
"convert",
"(",
"\"RGB\"",
")",
"bg",
"=",
"Image",
".",
"new",
"(",
"\"RG... | Crop away a border of the given background color. | [
"Crop",
"away",
"a",
"border",
"of",
"the",
"given",
"background",
"color",
"."
] | f83e59f61295500f5527dee5894207f2f033cf35 | https://github.com/99designs/colorific/blob/f83e59f61295500f5527dee5894207f2f033cf35/colorific/palette.py#L262-L272 | train |
ttu/ruuvitag-sensor | examples/post_to_influxdb.py | convert_to_influx | def convert_to_influx(mac, payload):
'''
Convert data into RuuviCollector naming schme and scale
returns:
Object to be written to InfluxDB
'''
dataFormat = payload["data_format"] if ('data_format' in payload) else None
fields = {}
fields["temperature"] = payload["tempe... | python | def convert_to_influx(mac, payload):
'''
Convert data into RuuviCollector naming schme and scale
returns:
Object to be written to InfluxDB
'''
dataFormat = payload["data_format"] if ('data_format' in payload) else None
fields = {}
fields["temperature"] = payload["tempe... | [
"def",
"convert_to_influx",
"(",
"mac",
",",
"payload",
")",
":",
"dataFormat",
"=",
"payload",
"[",
"\"data_format\"",
"]",
"if",
"(",
"'data_format'",
"in",
"payload",
")",
"else",
"None",
"fields",
"=",
"{",
"}",
"fields",
"[",
"\"temperature\"",
"]",
"... | Convert data into RuuviCollector naming schme and scale
returns:
Object to be written to InfluxDB | [
"Convert",
"data",
"into",
"RuuviCollector",
"naming",
"schme",
"and",
"scale"
] | b5d1367c26844ae5875b2964c68e7b2f4e1cb082 | https://github.com/ttu/ruuvitag-sensor/blob/b5d1367c26844ae5875b2964c68e7b2f4e1cb082/examples/post_to_influxdb.py#L35-L63 | train |
ttu/ruuvitag-sensor | ruuvitag_sensor/ruuvi_rx.py | _run_get_data_background | def _run_get_data_background(macs, queue, shared_data, bt_device):
"""
Background process function for RuuviTag Sensors
"""
run_flag = RunFlag()
def add_data(data):
if not shared_data['run_flag']:
run_flag.running = False
data[1]['time'] = datetime.utcnow().isoformat()... | python | def _run_get_data_background(macs, queue, shared_data, bt_device):
"""
Background process function for RuuviTag Sensors
"""
run_flag = RunFlag()
def add_data(data):
if not shared_data['run_flag']:
run_flag.running = False
data[1]['time'] = datetime.utcnow().isoformat()... | [
"def",
"_run_get_data_background",
"(",
"macs",
",",
"queue",
",",
"shared_data",
",",
"bt_device",
")",
":",
"run_flag",
"=",
"RunFlag",
"(",
")",
"def",
"add_data",
"(",
"data",
")",
":",
"if",
"not",
"shared_data",
"[",
"'run_flag'",
"]",
":",
"run_flag... | Background process function for RuuviTag Sensors | [
"Background",
"process",
"function",
"for",
"RuuviTag",
"Sensors"
] | b5d1367c26844ae5875b2964c68e7b2f4e1cb082 | https://github.com/ttu/ruuvitag-sensor/blob/b5d1367c26844ae5875b2964c68e7b2f4e1cb082/ruuvitag_sensor/ruuvi_rx.py#L11-L25 | train |
ttu/ruuvitag-sensor | ruuvitag_sensor/ruuvi_rx.py | RuuviTagReactive._data_update | def _data_update(subjects, queue, run_flag):
"""
Get data from backgound process and notify all subscribed observers with the new data
"""
while run_flag.running:
while not queue.empty():
data = queue.get()
for subject in [s for s in subjects i... | python | def _data_update(subjects, queue, run_flag):
"""
Get data from backgound process and notify all subscribed observers with the new data
"""
while run_flag.running:
while not queue.empty():
data = queue.get()
for subject in [s for s in subjects i... | [
"def",
"_data_update",
"(",
"subjects",
",",
"queue",
",",
"run_flag",
")",
":",
"while",
"run_flag",
".",
"running",
":",
"while",
"not",
"queue",
".",
"empty",
"(",
")",
":",
"data",
"=",
"queue",
".",
"get",
"(",
")",
"for",
"subject",
"in",
"[",
... | Get data from backgound process and notify all subscribed observers with the new data | [
"Get",
"data",
"from",
"backgound",
"process",
"and",
"notify",
"all",
"subscribed",
"observers",
"with",
"the",
"new",
"data"
] | b5d1367c26844ae5875b2964c68e7b2f4e1cb082 | https://github.com/ttu/ruuvitag-sensor/blob/b5d1367c26844ae5875b2964c68e7b2f4e1cb082/ruuvitag_sensor/ruuvi_rx.py#L34-L43 | train |
ttu/ruuvitag-sensor | examples/http_server_asyncio.py | data_update | async def data_update(queue):
"""
Update data sent by the background process to global allData variable
"""
global allData
while True:
while not queue.empty():
data = queue.get()
allData[data[0]] = data[1]
for key, value in tags.items():
if key in ... | python | async def data_update(queue):
"""
Update data sent by the background process to global allData variable
"""
global allData
while True:
while not queue.empty():
data = queue.get()
allData[data[0]] = data[1]
for key, value in tags.items():
if key in ... | [
"async",
"def",
"data_update",
"(",
"queue",
")",
":",
"global",
"allData",
"while",
"True",
":",
"while",
"not",
"queue",
".",
"empty",
"(",
")",
":",
"data",
"=",
"queue",
".",
"get",
"(",
")",
"allData",
"[",
"data",
"[",
"0",
"]",
"]",
"=",
"... | Update data sent by the background process to global allData variable | [
"Update",
"data",
"sent",
"by",
"the",
"background",
"process",
"to",
"global",
"allData",
"variable"
] | b5d1367c26844ae5875b2964c68e7b2f4e1cb082 | https://github.com/ttu/ruuvitag-sensor/blob/b5d1367c26844ae5875b2964c68e7b2f4e1cb082/examples/http_server_asyncio.py#L36-L48 | train |
ttu/ruuvitag-sensor | ruuvitag_sensor/ruuvi.py | RuuviTagSensor.convert_data | def convert_data(raw):
"""
Validate that data is from RuuviTag and get correct data part.
Returns:
tuple (int, string): Data Format type and Sensor data
"""
# TODO: Check from raw data correct data format
# Now this returns 2 also for Data Format 4
da... | python | def convert_data(raw):
"""
Validate that data is from RuuviTag and get correct data part.
Returns:
tuple (int, string): Data Format type and Sensor data
"""
# TODO: Check from raw data correct data format
# Now this returns 2 also for Data Format 4
da... | [
"def",
"convert_data",
"(",
"raw",
")",
":",
"data",
"=",
"RuuviTagSensor",
".",
"_get_data_format_2and4",
"(",
"raw",
")",
"if",
"data",
"is",
"not",
"None",
":",
"return",
"(",
"2",
",",
"data",
")",
"data",
"=",
"RuuviTagSensor",
".",
"_get_data_format_... | Validate that data is from RuuviTag and get correct data part.
Returns:
tuple (int, string): Data Format type and Sensor data | [
"Validate",
"that",
"data",
"is",
"from",
"RuuviTag",
"and",
"get",
"correct",
"data",
"part",
"."
] | b5d1367c26844ae5875b2964c68e7b2f4e1cb082 | https://github.com/ttu/ruuvitag-sensor/blob/b5d1367c26844ae5875b2964c68e7b2f4e1cb082/ruuvitag_sensor/ruuvi.py#L42-L66 | train |
ttu/ruuvitag-sensor | ruuvitag_sensor/ruuvi.py | RuuviTagSensor.find_ruuvitags | def find_ruuvitags(bt_device=''):
"""
Find all RuuviTags. Function will print the mac and the state of the sensors when found.
Function will execute as long as it is stopped. Stop ecexution with Crtl+C.
Returns:
dict: MAC and state of found sensors
"""
log.i... | python | def find_ruuvitags(bt_device=''):
"""
Find all RuuviTags. Function will print the mac and the state of the sensors when found.
Function will execute as long as it is stopped. Stop ecexution with Crtl+C.
Returns:
dict: MAC and state of found sensors
"""
log.i... | [
"def",
"find_ruuvitags",
"(",
"bt_device",
"=",
"''",
")",
":",
"log",
".",
"info",
"(",
"'Finding RuuviTags. Stop with Ctrl+C.'",
")",
"datas",
"=",
"dict",
"(",
")",
"for",
"new_data",
"in",
"RuuviTagSensor",
".",
"_get_ruuvitag_datas",
"(",
"bt_device",
"=",
... | Find all RuuviTags. Function will print the mac and the state of the sensors when found.
Function will execute as long as it is stopped. Stop ecexution with Crtl+C.
Returns:
dict: MAC and state of found sensors | [
"Find",
"all",
"RuuviTags",
".",
"Function",
"will",
"print",
"the",
"mac",
"and",
"the",
"state",
"of",
"the",
"sensors",
"when",
"found",
".",
"Function",
"will",
"execute",
"as",
"long",
"as",
"it",
"is",
"stopped",
".",
"Stop",
"ecexution",
"with",
"... | b5d1367c26844ae5875b2964c68e7b2f4e1cb082 | https://github.com/ttu/ruuvitag-sensor/blob/b5d1367c26844ae5875b2964c68e7b2f4e1cb082/ruuvitag_sensor/ruuvi.py#L69-L88 | train |
ttu/ruuvitag-sensor | ruuvitag_sensor/ruuvi.py | RuuviTagSensor.get_data_for_sensors | def get_data_for_sensors(macs=[], search_duratio_sec=5, bt_device=''):
"""
Get lates data for sensors in the MAC's list.
Args:
macs (array): MAC addresses
search_duratio_sec (int): Search duration in seconds. Default 5
bt_device (string): Bluetooth device id
... | python | def get_data_for_sensors(macs=[], search_duratio_sec=5, bt_device=''):
"""
Get lates data for sensors in the MAC's list.
Args:
macs (array): MAC addresses
search_duratio_sec (int): Search duration in seconds. Default 5
bt_device (string): Bluetooth device id
... | [
"def",
"get_data_for_sensors",
"(",
"macs",
"=",
"[",
"]",
",",
"search_duratio_sec",
"=",
"5",
",",
"bt_device",
"=",
"''",
")",
":",
"log",
".",
"info",
"(",
"'Get latest data for sensors. Stop with Ctrl+C.'",
")",
"log",
".",
"info",
"(",
"'Stops automaticall... | Get lates data for sensors in the MAC's list.
Args:
macs (array): MAC addresses
search_duratio_sec (int): Search duration in seconds. Default 5
bt_device (string): Bluetooth device id
Returns:
dict: MAC and state of found sensors | [
"Get",
"lates",
"data",
"for",
"sensors",
"in",
"the",
"MAC",
"s",
"list",
"."
] | b5d1367c26844ae5875b2964c68e7b2f4e1cb082 | https://github.com/ttu/ruuvitag-sensor/blob/b5d1367c26844ae5875b2964c68e7b2f4e1cb082/ruuvitag_sensor/ruuvi.py#L91-L112 | train |
ttu/ruuvitag-sensor | ruuvitag_sensor/ruuvi.py | RuuviTagSensor.get_datas | def get_datas(callback, macs=[], run_flag=RunFlag(), bt_device=''):
"""
Get data for all ruuvitag sensors or sensors in the MAC's list.
Args:
callback (func): callback funcion to be called when new data is received
macs (list): MAC addresses
run_flag (object)... | python | def get_datas(callback, macs=[], run_flag=RunFlag(), bt_device=''):
"""
Get data for all ruuvitag sensors or sensors in the MAC's list.
Args:
callback (func): callback funcion to be called when new data is received
macs (list): MAC addresses
run_flag (object)... | [
"def",
"get_datas",
"(",
"callback",
",",
"macs",
"=",
"[",
"]",
",",
"run_flag",
"=",
"RunFlag",
"(",
")",
",",
"bt_device",
"=",
"''",
")",
":",
"log",
".",
"info",
"(",
"'Get latest data for sensors. Stop with Ctrl+C.'",
")",
"log",
".",
"info",
"(",
... | Get data for all ruuvitag sensors or sensors in the MAC's list.
Args:
callback (func): callback funcion to be called when new data is received
macs (list): MAC addresses
run_flag (object): RunFlag object. Function executes while run_flag.running
bt_device (string... | [
"Get",
"data",
"for",
"all",
"ruuvitag",
"sensors",
"or",
"sensors",
"in",
"the",
"MAC",
"s",
"list",
"."
] | b5d1367c26844ae5875b2964c68e7b2f4e1cb082 | https://github.com/ttu/ruuvitag-sensor/blob/b5d1367c26844ae5875b2964c68e7b2f4e1cb082/ruuvitag_sensor/ruuvi.py#L115-L130 | train |
ttu/ruuvitag-sensor | ruuvitag_sensor/ruuvi.py | RuuviTagSensor._get_ruuvitag_datas | def _get_ruuvitag_datas(macs=[], search_duratio_sec=None, run_flag=RunFlag(), bt_device=''):
"""
Get data from BluetoothCommunication and handle data encoding.
Args:
macs (list): MAC addresses. Default empty list
search_duratio_sec (int): Search duration in seconds. Defa... | python | def _get_ruuvitag_datas(macs=[], search_duratio_sec=None, run_flag=RunFlag(), bt_device=''):
"""
Get data from BluetoothCommunication and handle data encoding.
Args:
macs (list): MAC addresses. Default empty list
search_duratio_sec (int): Search duration in seconds. Defa... | [
"def",
"_get_ruuvitag_datas",
"(",
"macs",
"=",
"[",
"]",
",",
"search_duratio_sec",
"=",
"None",
",",
"run_flag",
"=",
"RunFlag",
"(",
")",
",",
"bt_device",
"=",
"''",
")",
":",
"mac_blacklist",
"=",
"[",
"]",
"start_time",
"=",
"time",
".",
"time",
... | Get data from BluetoothCommunication and handle data encoding.
Args:
macs (list): MAC addresses. Default empty list
search_duratio_sec (int): Search duration in seconds. Default None
run_flag (object): RunFlag object. Function executes while run_flag.running. Default new Run... | [
"Get",
"data",
"from",
"BluetoothCommunication",
"and",
"handle",
"data",
"encoding",
"."
] | b5d1367c26844ae5875b2964c68e7b2f4e1cb082 | https://github.com/ttu/ruuvitag-sensor/blob/b5d1367c26844ae5875b2964c68e7b2f4e1cb082/ruuvitag_sensor/ruuvi.py#L133-L170 | train |
ttu/ruuvitag-sensor | ruuvitag_sensor/ruuvitag.py | RuuviTag.update | def update(self):
"""
Get lates data from the sensor and update own state.
Returns:
dict: Latest state
"""
(data_format, data) = RuuviTagSensor.get_data(self._mac, self._bt_device)
if data == self._data:
return self._state
self._data = ... | python | def update(self):
"""
Get lates data from the sensor and update own state.
Returns:
dict: Latest state
"""
(data_format, data) = RuuviTagSensor.get_data(self._mac, self._bt_device)
if data == self._data:
return self._state
self._data = ... | [
"def",
"update",
"(",
"self",
")",
":",
"(",
"data_format",
",",
"data",
")",
"=",
"RuuviTagSensor",
".",
"get_data",
"(",
"self",
".",
"_mac",
",",
"self",
".",
"_bt_device",
")",
"if",
"data",
"==",
"self",
".",
"_data",
":",
"return",
"self",
".",... | Get lates data from the sensor and update own state.
Returns:
dict: Latest state | [
"Get",
"lates",
"data",
"from",
"the",
"sensor",
"and",
"update",
"own",
"state",
"."
] | b5d1367c26844ae5875b2964c68e7b2f4e1cb082 | https://github.com/ttu/ruuvitag-sensor/blob/b5d1367c26844ae5875b2964c68e7b2f4e1cb082/ruuvitag_sensor/ruuvitag.py#L32-L52 | train |
ttu/ruuvitag-sensor | examples/post_to_influxdb_rx.py | write_to_influxdb | def write_to_influxdb(received_data):
'''
Convert data into RuuviCollecor naming schme and scale
'''
dataFormat = received_data[1]["data_format"] if ('data_format' in received_data[1]) else None
fields = {}
fields["temperature"] = received_data[1]["temperature"] if ('temperature' i... | python | def write_to_influxdb(received_data):
'''
Convert data into RuuviCollecor naming schme and scale
'''
dataFormat = received_data[1]["data_format"] if ('data_format' in received_data[1]) else None
fields = {}
fields["temperature"] = received_data[1]["temperature"] if ('temperature' i... | [
"def",
"write_to_influxdb",
"(",
"received_data",
")",
":",
"dataFormat",
"=",
"received_data",
"[",
"1",
"]",
"[",
"\"data_format\"",
"]",
"if",
"(",
"'data_format'",
"in",
"received_data",
"[",
"1",
"]",
")",
"else",
"None",
"fields",
"=",
"{",
"}",
"fie... | Convert data into RuuviCollecor naming schme and scale | [
"Convert",
"data",
"into",
"RuuviCollecor",
"naming",
"schme",
"and",
"scale"
] | b5d1367c26844ae5875b2964c68e7b2f4e1cb082 | https://github.com/ttu/ruuvitag-sensor/blob/b5d1367c26844ae5875b2964c68e7b2f4e1cb082/examples/post_to_influxdb_rx.py#L12-L40 | train |
ttu/ruuvitag-sensor | examples/http_server.py | update_data | def update_data():
"""
Update data sent by background process to global allData
"""
global allData
while not q.empty():
allData = q.get()
for key, value in tags.items():
if key in allData:
allData[key]['name'] = value | python | def update_data():
"""
Update data sent by background process to global allData
"""
global allData
while not q.empty():
allData = q.get()
for key, value in tags.items():
if key in allData:
allData[key]['name'] = value | [
"def",
"update_data",
"(",
")",
":",
"global",
"allData",
"while",
"not",
"q",
".",
"empty",
"(",
")",
":",
"allData",
"=",
"q",
".",
"get",
"(",
")",
"for",
"key",
",",
"value",
"in",
"tags",
".",
"items",
"(",
")",
":",
"if",
"key",
"in",
"al... | Update data sent by background process to global allData | [
"Update",
"data",
"sent",
"by",
"background",
"process",
"to",
"global",
"allData"
] | b5d1367c26844ae5875b2964c68e7b2f4e1cb082 | https://github.com/ttu/ruuvitag-sensor/blob/b5d1367c26844ae5875b2964c68e7b2f4e1cb082/examples/http_server.py#L44-L53 | train |
ttu/ruuvitag-sensor | ruuvitag_sensor/decoder.py | Df5Decoder._get_acceleration | def _get_acceleration(self, data):
'''Return acceleration mG'''
if (data[7:8] == 0x7FFF or
data[9:10] == 0x7FFF or
data[11:12] == 0x7FFF):
return (None, None, None)
acc_x = twos_complement((data[7] << 8) + data[8], 16)
acc_y = twos_complement(... | python | def _get_acceleration(self, data):
'''Return acceleration mG'''
if (data[7:8] == 0x7FFF or
data[9:10] == 0x7FFF or
data[11:12] == 0x7FFF):
return (None, None, None)
acc_x = twos_complement((data[7] << 8) + data[8], 16)
acc_y = twos_complement(... | [
"def",
"_get_acceleration",
"(",
"self",
",",
"data",
")",
":",
"if",
"(",
"data",
"[",
"7",
":",
"8",
"]",
"==",
"0x7FFF",
"or",
"data",
"[",
"9",
":",
"10",
"]",
"==",
"0x7FFF",
"or",
"data",
"[",
"11",
":",
"12",
"]",
"==",
"0x7FFF",
")",
... | Return acceleration mG | [
"Return",
"acceleration",
"mG"
] | b5d1367c26844ae5875b2964c68e7b2f4e1cb082 | https://github.com/ttu/ruuvitag-sensor/blob/b5d1367c26844ae5875b2964c68e7b2f4e1cb082/ruuvitag_sensor/decoder.py#L195-L205 | train |
ttu/ruuvitag-sensor | ruuvitag_sensor/decoder.py | Df5Decoder._get_powerinfo | def _get_powerinfo(self, data):
'''Return battery voltage and tx power '''
power_info = (data[13] & 0xFF) << 8 | (data[14] & 0xFF)
battery_voltage = rshift(power_info, 5) + 1600
tx_power = (power_info & 0b11111) * 2 - 40
if rshift(power_info, 5) == 0b11111111111:
bat... | python | def _get_powerinfo(self, data):
'''Return battery voltage and tx power '''
power_info = (data[13] & 0xFF) << 8 | (data[14] & 0xFF)
battery_voltage = rshift(power_info, 5) + 1600
tx_power = (power_info & 0b11111) * 2 - 40
if rshift(power_info, 5) == 0b11111111111:
bat... | [
"def",
"_get_powerinfo",
"(",
"self",
",",
"data",
")",
":",
"power_info",
"=",
"(",
"data",
"[",
"13",
"]",
"&",
"0xFF",
")",
"<<",
"8",
"|",
"(",
"data",
"[",
"14",
"]",
"&",
"0xFF",
")",
"battery_voltage",
"=",
"rshift",
"(",
"power_info",
",",
... | Return battery voltage and tx power | [
"Return",
"battery",
"voltage",
"and",
"tx",
"power"
] | b5d1367c26844ae5875b2964c68e7b2f4e1cb082 | https://github.com/ttu/ruuvitag-sensor/blob/b5d1367c26844ae5875b2964c68e7b2f4e1cb082/ruuvitag_sensor/decoder.py#L207-L218 | train |
carlosescri/DottedDict | dotted/collection.py | split_key | def split_key(key, max_keys=0):
"""Splits a key but allows dots in the key name if they're scaped properly.
Splitting this complex key:
complex_key = ".dont\.splitme.d\.o\. origen.splitme\.dontsplit.splitme."
split_key(complex_key)
results in:
['', 'dont\.splitme', 'd\.o\. origen', 'splitme\... | python | def split_key(key, max_keys=0):
"""Splits a key but allows dots in the key name if they're scaped properly.
Splitting this complex key:
complex_key = ".dont\.splitme.d\.o\. origen.splitme\.dontsplit.splitme."
split_key(complex_key)
results in:
['', 'dont\.splitme', 'd\.o\. origen', 'splitme\... | [
"def",
"split_key",
"(",
"key",
",",
"max_keys",
"=",
"0",
")",
":",
"parts",
"=",
"[",
"x",
"for",
"x",
"in",
"re",
".",
"split",
"(",
"SPLIT_REGEX",
",",
"key",
")",
"if",
"x",
"!=",
"\".\"",
"]",
"result",
"=",
"[",
"]",
"while",
"len",
"(",... | Splits a key but allows dots in the key name if they're scaped properly.
Splitting this complex key:
complex_key = ".dont\.splitme.d\.o\. origen.splitme\.dontsplit.splitme."
split_key(complex_key)
results in:
['', 'dont\.splitme', 'd\.o\. origen', 'splitme\.dontsplit', 'splitme', '']
Args:... | [
"Splits",
"a",
"key",
"but",
"allows",
"dots",
"in",
"the",
"key",
"name",
"if",
"they",
"re",
"scaped",
"properly",
"."
] | fa1cba43f414871d0f6978487d61b8760fda4a68 | https://github.com/carlosescri/DottedDict/blob/fa1cba43f414871d0f6978487d61b8760fda4a68/dotted/collection.py#L20-L50 | train |
carlosescri/DottedDict | dotted/collection.py | DottedList.to_python | def to_python(self):
"""Returns a plain python list and converts to plain python objects all
this object's descendants.
"""
result = list(self)
for index, value in enumerate(result):
if isinstance(value, DottedCollection):
result[index] = value.to_pyt... | python | def to_python(self):
"""Returns a plain python list and converts to plain python objects all
this object's descendants.
"""
result = list(self)
for index, value in enumerate(result):
if isinstance(value, DottedCollection):
result[index] = value.to_pyt... | [
"def",
"to_python",
"(",
"self",
")",
":",
"result",
"=",
"list",
"(",
"self",
")",
"for",
"index",
",",
"value",
"in",
"enumerate",
"(",
"result",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"DottedCollection",
")",
":",
"result",
"[",
"index",
... | Returns a plain python list and converts to plain python objects all
this object's descendants. | [
"Returns",
"a",
"plain",
"python",
"list",
"and",
"converts",
"to",
"plain",
"python",
"objects",
"all",
"this",
"object",
"s",
"descendants",
"."
] | fa1cba43f414871d0f6978487d61b8760fda4a68 | https://github.com/carlosescri/DottedDict/blob/fa1cba43f414871d0f6978487d61b8760fda4a68/dotted/collection.py#L238-L248 | train |
carlosescri/DottedDict | dotted/collection.py | DottedDict.to_python | def to_python(self):
"""Returns a plain python dict and converts to plain python objects all
this object's descendants.
"""
result = dict(self)
for key, value in iteritems(result):
if isinstance(value, DottedCollection):
result[key] = value.to_python(... | python | def to_python(self):
"""Returns a plain python dict and converts to plain python objects all
this object's descendants.
"""
result = dict(self)
for key, value in iteritems(result):
if isinstance(value, DottedCollection):
result[key] = value.to_python(... | [
"def",
"to_python",
"(",
"self",
")",
":",
"result",
"=",
"dict",
"(",
"self",
")",
"for",
"key",
",",
"value",
"in",
"iteritems",
"(",
"result",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"DottedCollection",
")",
":",
"result",
"[",
"key",
"]"... | Returns a plain python dict and converts to plain python objects all
this object's descendants. | [
"Returns",
"a",
"plain",
"python",
"dict",
"and",
"converts",
"to",
"plain",
"python",
"objects",
"all",
"this",
"object",
"s",
"descendants",
"."
] | fa1cba43f414871d0f6978487d61b8760fda4a68 | https://github.com/carlosescri/DottedDict/blob/fa1cba43f414871d0f6978487d61b8760fda4a68/dotted/collection.py#L315-L325 | train |
jaraco/irc | irc/server.py | IRCClient.handle_nick | def handle_nick(self, params):
"""
Handle the initial setting of the user's nickname and nick changes.
"""
nick = params
# Valid nickname?
if re.search(r'[^a-zA-Z0-9\-\[\]\'`^{}_]', nick):
raise IRCError.from_name('erroneusnickname', ':%s' % nick)
if... | python | def handle_nick(self, params):
"""
Handle the initial setting of the user's nickname and nick changes.
"""
nick = params
# Valid nickname?
if re.search(r'[^a-zA-Z0-9\-\[\]\'`^{}_]', nick):
raise IRCError.from_name('erroneusnickname', ':%s' % nick)
if... | [
"def",
"handle_nick",
"(",
"self",
",",
"params",
")",
":",
"nick",
"=",
"params",
"if",
"re",
".",
"search",
"(",
"r'[^a-zA-Z0-9\\-\\[\\]\\'`^{}_]'",
",",
"nick",
")",
":",
"raise",
"IRCError",
".",
"from_name",
"(",
"'erroneusnickname'",
",",
"':%s'",
"%",... | Handle the initial setting of the user's nickname and nick changes. | [
"Handle",
"the",
"initial",
"setting",
"of",
"the",
"user",
"s",
"nickname",
"and",
"nick",
"changes",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/server.py#L194-L239 | train |
jaraco/irc | irc/server.py | IRCClient.handle_user | def handle_user(self, params):
"""
Handle the USER command which identifies the user to the server.
"""
params = params.split(' ', 3)
if len(params) != 4:
raise IRCError.from_name(
'needmoreparams',
'USER :Not enough parameters')
... | python | def handle_user(self, params):
"""
Handle the USER command which identifies the user to the server.
"""
params = params.split(' ', 3)
if len(params) != 4:
raise IRCError.from_name(
'needmoreparams',
'USER :Not enough parameters')
... | [
"def",
"handle_user",
"(",
"self",
",",
"params",
")",
":",
"params",
"=",
"params",
".",
"split",
"(",
"' '",
",",
"3",
")",
"if",
"len",
"(",
"params",
")",
"!=",
"4",
":",
"raise",
"IRCError",
".",
"from_name",
"(",
"'needmoreparams'",
",",
"'USER... | Handle the USER command which identifies the user to the server. | [
"Handle",
"the",
"USER",
"command",
"which",
"identifies",
"the",
"user",
"to",
"the",
"server",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/server.py#L241-L256 | train |
jaraco/irc | irc/server.py | IRCClient.handle_privmsg | def handle_privmsg(self, params):
"""
Handle sending a private message to a user or channel.
"""
target, sep, msg = params.partition(' ')
if not msg:
raise IRCError.from_name(
'needmoreparams',
'PRIVMSG :Not enough parameters')
... | python | def handle_privmsg(self, params):
"""
Handle sending a private message to a user or channel.
"""
target, sep, msg = params.partition(' ')
if not msg:
raise IRCError.from_name(
'needmoreparams',
'PRIVMSG :Not enough parameters')
... | [
"def",
"handle_privmsg",
"(",
"self",
",",
"params",
")",
":",
"target",
",",
"sep",
",",
"msg",
"=",
"params",
".",
"partition",
"(",
"' '",
")",
"if",
"not",
"msg",
":",
"raise",
"IRCError",
".",
"from_name",
"(",
"'needmoreparams'",
",",
"'PRIVMSG :No... | Handle sending a private message to a user or channel. | [
"Handle",
"sending",
"a",
"private",
"message",
"to",
"a",
"user",
"or",
"channel",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/server.py#L314-L344 | train |
jaraco/irc | irc/server.py | IRCClient._send_to_others | def _send_to_others(self, message, channel):
"""
Send the message to all clients in the specified channel except for
self.
"""
other_clients = [
client for client in channel.clients
if not client == self]
for client in other_clients:
cl... | python | def _send_to_others(self, message, channel):
"""
Send the message to all clients in the specified channel except for
self.
"""
other_clients = [
client for client in channel.clients
if not client == self]
for client in other_clients:
cl... | [
"def",
"_send_to_others",
"(",
"self",
",",
"message",
",",
"channel",
")",
":",
"other_clients",
"=",
"[",
"client",
"for",
"client",
"in",
"channel",
".",
"clients",
"if",
"not",
"client",
"==",
"self",
"]",
"for",
"client",
"in",
"other_clients",
":",
... | Send the message to all clients in the specified channel except for
self. | [
"Send",
"the",
"message",
"to",
"all",
"clients",
"in",
"the",
"specified",
"channel",
"except",
"for",
"self",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/server.py#L346-L355 | train |
jaraco/irc | irc/server.py | IRCClient.handle_topic | def handle_topic(self, params):
"""
Handle a topic command.
"""
channel_name, sep, topic = params.partition(' ')
channel = self.server.channels.get(channel_name)
if not channel:
raise IRCError.from_name(
'nosuchnick', 'PRIVMSG :%s' % channel_n... | python | def handle_topic(self, params):
"""
Handle a topic command.
"""
channel_name, sep, topic = params.partition(' ')
channel = self.server.channels.get(channel_name)
if not channel:
raise IRCError.from_name(
'nosuchnick', 'PRIVMSG :%s' % channel_n... | [
"def",
"handle_topic",
"(",
"self",
",",
"params",
")",
":",
"channel_name",
",",
"sep",
",",
"topic",
"=",
"params",
".",
"partition",
"(",
"' '",
")",
"channel",
"=",
"self",
".",
"server",
".",
"channels",
".",
"get",
"(",
"channel_name",
")",
"if",... | Handle a topic command. | [
"Handle",
"a",
"topic",
"command",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/server.py#L357-L379 | train |
jaraco/irc | irc/server.py | IRCClient.handle_quit | def handle_quit(self, params):
"""
Handle the client breaking off the connection with a QUIT command.
"""
response = ':%s QUIT :%s' % (self.client_ident(), params.lstrip(':'))
# Send quit message to all clients in all channels user is in, and
# remove the user from the ch... | python | def handle_quit(self, params):
"""
Handle the client breaking off the connection with a QUIT command.
"""
response = ':%s QUIT :%s' % (self.client_ident(), params.lstrip(':'))
# Send quit message to all clients in all channels user is in, and
# remove the user from the ch... | [
"def",
"handle_quit",
"(",
"self",
",",
"params",
")",
":",
"response",
"=",
"':%s QUIT :%s'",
"%",
"(",
"self",
".",
"client_ident",
"(",
")",
",",
"params",
".",
"lstrip",
"(",
"':'",
")",
")",
"for",
"channel",
"in",
"self",
".",
"channels",
".",
... | Handle the client breaking off the connection with a QUIT command. | [
"Handle",
"the",
"client",
"breaking",
"off",
"the",
"connection",
"with",
"a",
"QUIT",
"command",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/server.py#L401-L411 | train |
jaraco/irc | irc/server.py | IRCClient.handle_dump | def handle_dump(self, params):
"""
Dump internal server information for debugging purposes.
"""
print("Clients:", self.server.clients)
for client in self.server.clients.values():
print(" ", client)
for channel in client.channels.values():
p... | python | def handle_dump(self, params):
"""
Dump internal server information for debugging purposes.
"""
print("Clients:", self.server.clients)
for client in self.server.clients.values():
print(" ", client)
for channel in client.channels.values():
p... | [
"def",
"handle_dump",
"(",
"self",
",",
"params",
")",
":",
"print",
"(",
"\"Clients:\"",
",",
"self",
".",
"server",
".",
"clients",
")",
"for",
"client",
"in",
"self",
".",
"server",
".",
"clients",
".",
"values",
"(",
")",
":",
"print",
"(",
"\" \... | Dump internal server information for debugging purposes. | [
"Dump",
"internal",
"server",
"information",
"for",
"debugging",
"purposes",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/server.py#L413-L426 | train |
jaraco/irc | irc/server.py | IRCClient.client_ident | def client_ident(self):
"""
Return the client identifier as included in many command replies.
"""
return irc.client.NickMask.from_params(
self.nick, self.user,
self.server.servername) | python | def client_ident(self):
"""
Return the client identifier as included in many command replies.
"""
return irc.client.NickMask.from_params(
self.nick, self.user,
self.server.servername) | [
"def",
"client_ident",
"(",
"self",
")",
":",
"return",
"irc",
".",
"client",
".",
"NickMask",
".",
"from_params",
"(",
"self",
".",
"nick",
",",
"self",
".",
"user",
",",
"self",
".",
"server",
".",
"servername",
")"
] | Return the client identifier as included in many command replies. | [
"Return",
"the",
"client",
"identifier",
"as",
"included",
"in",
"many",
"command",
"replies",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/server.py#L442-L448 | train |
jaraco/irc | irc/server.py | IRCClient.finish | def finish(self):
"""
The client conection is finished. Do some cleanup to ensure that the
client doesn't linger around in any channel or the client list, in case
the client didn't properly close the connection with PART and QUIT.
"""
log.info('Client disconnected: %s', s... | python | def finish(self):
"""
The client conection is finished. Do some cleanup to ensure that the
client doesn't linger around in any channel or the client list, in case
the client didn't properly close the connection with PART and QUIT.
"""
log.info('Client disconnected: %s', s... | [
"def",
"finish",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"'Client disconnected: %s'",
",",
"self",
".",
"client_ident",
"(",
")",
")",
"response",
"=",
"':%s QUIT :EOF from client'",
"%",
"self",
".",
"client_ident",
"(",
")",
"for",
"channel",
"in",... | The client conection is finished. Do some cleanup to ensure that the
client doesn't linger around in any channel or the client list, in case
the client didn't properly close the connection with PART and QUIT. | [
"The",
"client",
"conection",
"is",
"finished",
".",
"Do",
"some",
"cleanup",
"to",
"ensure",
"that",
"the",
"client",
"doesn",
"t",
"linger",
"around",
"in",
"any",
"channel",
"or",
"the",
"client",
"list",
"in",
"case",
"the",
"client",
"didn",
"t",
"p... | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/server.py#L450-L467 | train |
jaraco/irc | irc/client_aio.py | AioConnection.send_raw | def send_raw(self, string):
"""Send raw string to the server, via the asyncio transport.
The string will be padded with appropriate CR LF.
"""
log.debug('RAW: {}'.format(string))
if self.transport is None:
raise ServerNotConnectedError("Not connected.")
self... | python | def send_raw(self, string):
"""Send raw string to the server, via the asyncio transport.
The string will be padded with appropriate CR LF.
"""
log.debug('RAW: {}'.format(string))
if self.transport is None:
raise ServerNotConnectedError("Not connected.")
self... | [
"def",
"send_raw",
"(",
"self",
",",
"string",
")",
":",
"log",
".",
"debug",
"(",
"'RAW: {}'",
".",
"format",
"(",
"string",
")",
")",
"if",
"self",
".",
"transport",
"is",
"None",
":",
"raise",
"ServerNotConnectedError",
"(",
"\"Not connected.\"",
")",
... | Send raw string to the server, via the asyncio transport.
The string will be padded with appropriate CR LF. | [
"Send",
"raw",
"string",
"to",
"the",
"server",
"via",
"the",
"asyncio",
"transport",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client_aio.py#L175-L184 | train |
jaraco/irc | irc/modes.py | _parse_modes | def _parse_modes(mode_string, unary_modes=""):
"""
Parse the mode_string and return a list of triples.
If no string is supplied return an empty list.
>>> _parse_modes('')
[]
If no sign is supplied, return an empty list.
>>> _parse_modes('ab')
[]
Discard unused args.
>>> _pa... | python | def _parse_modes(mode_string, unary_modes=""):
"""
Parse the mode_string and return a list of triples.
If no string is supplied return an empty list.
>>> _parse_modes('')
[]
If no sign is supplied, return an empty list.
>>> _parse_modes('ab')
[]
Discard unused args.
>>> _pa... | [
"def",
"_parse_modes",
"(",
"mode_string",
",",
"unary_modes",
"=",
"\"\"",
")",
":",
"if",
"not",
"mode_string",
"or",
"not",
"mode_string",
"[",
"0",
"]",
"in",
"'+-'",
":",
"return",
"[",
"]",
"modes",
"=",
"[",
"]",
"parts",
"=",
"mode_string",
"."... | Parse the mode_string and return a list of triples.
If no string is supplied return an empty list.
>>> _parse_modes('')
[]
If no sign is supplied, return an empty list.
>>> _parse_modes('ab')
[]
Discard unused args.
>>> _parse_modes('+a foo bar baz')
[['+', 'a', None]]
Ret... | [
"Parse",
"the",
"mode_string",
"and",
"return",
"a",
"list",
"of",
"triples",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/modes.py#L32-L89 | train |
jaraco/irc | irc/message.py | Tag.from_group | def from_group(cls, group):
"""
Construct tags from the regex group
"""
if not group:
return
tag_items = group.split(";")
return list(map(cls.parse, tag_items)) | python | def from_group(cls, group):
"""
Construct tags from the regex group
"""
if not group:
return
tag_items = group.split(";")
return list(map(cls.parse, tag_items)) | [
"def",
"from_group",
"(",
"cls",
",",
"group",
")",
":",
"if",
"not",
"group",
":",
"return",
"tag_items",
"=",
"group",
".",
"split",
"(",
"\";\"",
")",
"return",
"list",
"(",
"map",
"(",
"cls",
".",
"parse",
",",
"tag_items",
")",
")"
] | Construct tags from the regex group | [
"Construct",
"tags",
"from",
"the",
"regex",
"group"
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/message.py#L39-L46 | train |
jaraco/irc | irc/message.py | Arguments.from_group | def from_group(group):
"""
Construct arguments from the regex group
>>> Arguments.from_group('foo')
['foo']
>>> Arguments.from_group(None)
[]
>>> Arguments.from_group('')
[]
>>> Arguments.from_group('foo bar')
['foo', 'bar']
>>... | python | def from_group(group):
"""
Construct arguments from the regex group
>>> Arguments.from_group('foo')
['foo']
>>> Arguments.from_group(None)
[]
>>> Arguments.from_group('')
[]
>>> Arguments.from_group('foo bar')
['foo', 'bar']
>>... | [
"def",
"from_group",
"(",
"group",
")",
":",
"if",
"not",
"group",
":",
"return",
"[",
"]",
"main",
",",
"sep",
",",
"ext",
"=",
"group",
".",
"partition",
"(",
"\" :\"",
")",
"arguments",
"=",
"main",
".",
"split",
"(",
")",
"if",
"sep",
":",
"a... | Construct arguments from the regex group
>>> Arguments.from_group('foo')
['foo']
>>> Arguments.from_group(None)
[]
>>> Arguments.from_group('')
[]
>>> Arguments.from_group('foo bar')
['foo', 'bar']
>>> Arguments.from_group('foo bar :baz')
... | [
"Construct",
"arguments",
"from",
"the",
"regex",
"group"
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/message.py#L51-L81 | train |
jaraco/irc | irc/features.py | FeatureSet.set | def set(self, name, value=True):
"set a feature value"
setattr(self, name.lower(), value) | python | def set(self, name, value=True):
"set a feature value"
setattr(self, name.lower(), value) | [
"def",
"set",
"(",
"self",
",",
"name",
",",
"value",
"=",
"True",
")",
":",
"\"set a feature value\"",
"setattr",
"(",
"self",
",",
"name",
".",
"lower",
"(",
")",
",",
"value",
")"
] | set a feature value | [
"set",
"a",
"feature",
"value"
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/features.py#L36-L38 | train |
jaraco/irc | irc/features.py | FeatureSet.load | def load(self, arguments):
"Load the values from the a ServerConnection arguments"
features = arguments[1:-1]
list(map(self.load_feature, features)) | python | def load(self, arguments):
"Load the values from the a ServerConnection arguments"
features = arguments[1:-1]
list(map(self.load_feature, features)) | [
"def",
"load",
"(",
"self",
",",
"arguments",
")",
":",
"\"Load the values from the a ServerConnection arguments\"",
"features",
"=",
"arguments",
"[",
"1",
":",
"-",
"1",
"]",
"list",
"(",
"map",
"(",
"self",
".",
"load_feature",
",",
"features",
")",
")"
] | Load the values from the a ServerConnection arguments | [
"Load",
"the",
"values",
"from",
"the",
"a",
"ServerConnection",
"arguments"
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/features.py#L44-L47 | train |
jaraco/irc | irc/features.py | FeatureSet._parse_PREFIX | def _parse_PREFIX(value):
"channel user prefixes"
channel_modes, channel_chars = value.split(')')
channel_modes = channel_modes[1:]
return collections.OrderedDict(zip(channel_chars, channel_modes)) | python | def _parse_PREFIX(value):
"channel user prefixes"
channel_modes, channel_chars = value.split(')')
channel_modes = channel_modes[1:]
return collections.OrderedDict(zip(channel_chars, channel_modes)) | [
"def",
"_parse_PREFIX",
"(",
"value",
")",
":",
"\"channel user prefixes\"",
"channel_modes",
",",
"channel_chars",
"=",
"value",
".",
"split",
"(",
"')'",
")",
"channel_modes",
"=",
"channel_modes",
"[",
"1",
":",
"]",
"return",
"collections",
".",
"OrderedDict... | channel user prefixes | [
"channel",
"user",
"prefixes"
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/features.py#L68-L72 | train |
jaraco/irc | irc/bot.py | SingleServerIRCBot._connect | def _connect(self):
"""
Establish a connection to the server at the front of the server_list.
"""
server = self.servers.peek()
try:
self.connect(
server.host, server.port, self._nickname,
server.password, ircname=self._realname,
... | python | def _connect(self):
"""
Establish a connection to the server at the front of the server_list.
"""
server = self.servers.peek()
try:
self.connect(
server.host, server.port, self._nickname,
server.password, ircname=self._realname,
... | [
"def",
"_connect",
"(",
"self",
")",
":",
"server",
"=",
"self",
".",
"servers",
".",
"peek",
"(",
")",
"try",
":",
"self",
".",
"connect",
"(",
"server",
".",
"host",
",",
"server",
".",
"port",
",",
"self",
".",
"_nickname",
",",
"server",
".",
... | Establish a connection to the server at the front of the server_list. | [
"Establish",
"a",
"connection",
"to",
"the",
"server",
"at",
"the",
"front",
"of",
"the",
"server_list",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/bot.py#L173-L184 | train |
jaraco/irc | irc/bot.py | SingleServerIRCBot.jump_server | def jump_server(self, msg="Changing servers"):
"""Connect to a new server, possibly disconnecting from the current.
The bot will skip to next server in the server_list each time
jump_server is called.
"""
if self.connection.is_connected():
self.connection.disconnect(... | python | def jump_server(self, msg="Changing servers"):
"""Connect to a new server, possibly disconnecting from the current.
The bot will skip to next server in the server_list each time
jump_server is called.
"""
if self.connection.is_connected():
self.connection.disconnect(... | [
"def",
"jump_server",
"(",
"self",
",",
"msg",
"=",
"\"Changing servers\"",
")",
":",
"if",
"self",
".",
"connection",
".",
"is_connected",
"(",
")",
":",
"self",
".",
"connection",
".",
"disconnect",
"(",
"msg",
")",
"next",
"(",
"self",
".",
"servers",... | Connect to a new server, possibly disconnecting from the current.
The bot will skip to next server in the server_list each time
jump_server is called. | [
"Connect",
"to",
"a",
"new",
"server",
"possibly",
"disconnecting",
"from",
"the",
"current",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/bot.py#L298-L308 | train |
jaraco/irc | irc/bot.py | SingleServerIRCBot.on_ctcp | def on_ctcp(self, connection, event):
"""Default handler for ctcp events.
Replies to VERSION and PING requests and relays DCC requests
to the on_dccchat method.
"""
nick = event.source.nick
if event.arguments[0] == "VERSION":
connection.ctcp_reply(nick, "VERS... | python | def on_ctcp(self, connection, event):
"""Default handler for ctcp events.
Replies to VERSION and PING requests and relays DCC requests
to the on_dccchat method.
"""
nick = event.source.nick
if event.arguments[0] == "VERSION":
connection.ctcp_reply(nick, "VERS... | [
"def",
"on_ctcp",
"(",
"self",
",",
"connection",
",",
"event",
")",
":",
"nick",
"=",
"event",
".",
"source",
".",
"nick",
"if",
"event",
".",
"arguments",
"[",
"0",
"]",
"==",
"\"VERSION\"",
":",
"connection",
".",
"ctcp_reply",
"(",
"nick",
",",
"... | Default handler for ctcp events.
Replies to VERSION and PING requests and relays DCC requests
to the on_dccchat method. | [
"Default",
"handler",
"for",
"ctcp",
"events",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/bot.py#L310-L325 | train |
jaraco/irc | irc/bot.py | Channel.set_mode | def set_mode(self, mode, value=None):
"""Set mode on the channel.
Arguments:
mode -- The mode (a single-character string).
value -- Value
"""
if mode in self.user_modes:
self.mode_users[mode][value] = 1
else:
self.modes[mode] = v... | python | def set_mode(self, mode, value=None):
"""Set mode on the channel.
Arguments:
mode -- The mode (a single-character string).
value -- Value
"""
if mode in self.user_modes:
self.mode_users[mode][value] = 1
else:
self.modes[mode] = v... | [
"def",
"set_mode",
"(",
"self",
",",
"mode",
",",
"value",
"=",
"None",
")",
":",
"if",
"mode",
"in",
"self",
".",
"user_modes",
":",
"self",
".",
"mode_users",
"[",
"mode",
"]",
"[",
"value",
"]",
"=",
"1",
"else",
":",
"self",
".",
"modes",
"["... | Set mode on the channel.
Arguments:
mode -- The mode (a single-character string).
value -- Value | [
"Set",
"mode",
"on",
"the",
"channel",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/bot.py#L424-L436 | train |
jaraco/irc | irc/bot.py | Channel.clear_mode | def clear_mode(self, mode, value=None):
"""Clear mode on the channel.
Arguments:
mode -- The mode (a single-character string).
value -- Value
"""
try:
if mode in self.user_modes:
del self.mode_users[mode][value]
else:
... | python | def clear_mode(self, mode, value=None):
"""Clear mode on the channel.
Arguments:
mode -- The mode (a single-character string).
value -- Value
"""
try:
if mode in self.user_modes:
del self.mode_users[mode][value]
else:
... | [
"def",
"clear_mode",
"(",
"self",
",",
"mode",
",",
"value",
"=",
"None",
")",
":",
"try",
":",
"if",
"mode",
"in",
"self",
".",
"user_modes",
":",
"del",
"self",
".",
"mode_users",
"[",
"mode",
"]",
"[",
"value",
"]",
"else",
":",
"del",
"self",
... | Clear mode on the channel.
Arguments:
mode -- The mode (a single-character string).
value -- Value | [
"Clear",
"mode",
"on",
"the",
"channel",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/bot.py#L438-L453 | train |
jaraco/irc | irc/client.py | ip_numstr_to_quad | def ip_numstr_to_quad(num):
"""
Convert an IP number as an integer given in ASCII
representation to an IP address string.
>>> ip_numstr_to_quad('3232235521')
'192.168.0.1'
>>> ip_numstr_to_quad(3232235521)
'192.168.0.1'
"""
packed = struct.pack('>L', int(num))
bytes = struct.unp... | python | def ip_numstr_to_quad(num):
"""
Convert an IP number as an integer given in ASCII
representation to an IP address string.
>>> ip_numstr_to_quad('3232235521')
'192.168.0.1'
>>> ip_numstr_to_quad(3232235521)
'192.168.0.1'
"""
packed = struct.pack('>L', int(num))
bytes = struct.unp... | [
"def",
"ip_numstr_to_quad",
"(",
"num",
")",
":",
"packed",
"=",
"struct",
".",
"pack",
"(",
"'>L'",
",",
"int",
"(",
"num",
")",
")",
"bytes",
"=",
"struct",
".",
"unpack",
"(",
"'BBBB'",
",",
"packed",
")",
"return",
"\".\"",
".",
"join",
"(",
"m... | Convert an IP number as an integer given in ASCII
representation to an IP address string.
>>> ip_numstr_to_quad('3232235521')
'192.168.0.1'
>>> ip_numstr_to_quad(3232235521)
'192.168.0.1' | [
"Convert",
"an",
"IP",
"number",
"as",
"an",
"integer",
"given",
"in",
"ASCII",
"representation",
"to",
"an",
"IP",
"address",
"string",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L1249-L1261 | train |
jaraco/irc | irc/client.py | ServerConnection.as_nick | def as_nick(self, name):
"""
Set the nick for the duration of the context.
"""
orig = self.get_nickname()
self.nick(name)
try:
yield orig
finally:
self.nick(orig) | python | def as_nick(self, name):
"""
Set the nick for the duration of the context.
"""
orig = self.get_nickname()
self.nick(name)
try:
yield orig
finally:
self.nick(orig) | [
"def",
"as_nick",
"(",
"self",
",",
"name",
")",
":",
"orig",
"=",
"self",
".",
"get_nickname",
"(",
")",
"self",
".",
"nick",
"(",
"name",
")",
"try",
":",
"yield",
"orig",
"finally",
":",
"self",
".",
"nick",
"(",
"orig",
")"
] | Set the nick for the duration of the context. | [
"Set",
"the",
"nick",
"for",
"the",
"duration",
"of",
"the",
"context",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L238-L247 | train |
jaraco/irc | irc/client.py | ServerConnection.process_data | def process_data(self):
"read and process input from self.socket"
try:
reader = getattr(self.socket, 'read', self.socket.recv)
new_data = reader(2 ** 14)
except socket.error:
# The server hung up.
self.disconnect("Connection reset by peer")
... | python | def process_data(self):
"read and process input from self.socket"
try:
reader = getattr(self.socket, 'read', self.socket.recv)
new_data = reader(2 ** 14)
except socket.error:
# The server hung up.
self.disconnect("Connection reset by peer")
... | [
"def",
"process_data",
"(",
"self",
")",
":",
"\"read and process input from self.socket\"",
"try",
":",
"reader",
"=",
"getattr",
"(",
"self",
".",
"socket",
",",
"'read'",
",",
"self",
".",
"socket",
".",
"recv",
")",
"new_data",
"=",
"reader",
"(",
"2",
... | read and process input from self.socket | [
"read",
"and",
"process",
"input",
"from",
"self",
".",
"socket"
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L249-L271 | train |
jaraco/irc | irc/client.py | ServerConnection.ctcp | def ctcp(self, ctcptype, target, parameter=""):
"""Send a CTCP command."""
ctcptype = ctcptype.upper()
tmpl = (
"\001{ctcptype} {parameter}\001" if parameter else
"\001{ctcptype}\001"
)
self.privmsg(target, tmpl.format(**vars())) | python | def ctcp(self, ctcptype, target, parameter=""):
"""Send a CTCP command."""
ctcptype = ctcptype.upper()
tmpl = (
"\001{ctcptype} {parameter}\001" if parameter else
"\001{ctcptype}\001"
)
self.privmsg(target, tmpl.format(**vars())) | [
"def",
"ctcp",
"(",
"self",
",",
"ctcptype",
",",
"target",
",",
"parameter",
"=",
"\"\"",
")",
":",
"ctcptype",
"=",
"ctcptype",
".",
"upper",
"(",
")",
"tmpl",
"=",
"(",
"\"\\001{ctcptype} {parameter}\\001\"",
"if",
"parameter",
"else",
"\"\\001{ctcptype}\\0... | Send a CTCP command. | [
"Send",
"a",
"CTCP",
"command",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L441-L448 | train |
jaraco/irc | irc/client.py | ServerConnection.kick | def kick(self, channel, nick, comment=""):
"""Send a KICK command."""
self.send_items('KICK', channel, nick, comment and ':' + comment) | python | def kick(self, channel, nick, comment=""):
"""Send a KICK command."""
self.send_items('KICK', channel, nick, comment and ':' + comment) | [
"def",
"kick",
"(",
"self",
",",
"channel",
",",
"nick",
",",
"comment",
"=",
"\"\"",
")",
":",
"self",
".",
"send_items",
"(",
"'KICK'",
",",
"channel",
",",
"nick",
",",
"comment",
"and",
"':'",
"+",
"comment",
")"
] | Send a KICK command. | [
"Send",
"a",
"KICK",
"command",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L501-L503 | train |
jaraco/irc | irc/client.py | ServerConnection.list | def list(self, channels=None, server=""):
"""Send a LIST command."""
self.send_items('LIST', ','.join(always_iterable(channels)), server) | python | def list(self, channels=None, server=""):
"""Send a LIST command."""
self.send_items('LIST', ','.join(always_iterable(channels)), server) | [
"def",
"list",
"(",
"self",
",",
"channels",
"=",
"None",
",",
"server",
"=",
"\"\"",
")",
":",
"self",
".",
"send_items",
"(",
"'LIST'",
",",
"','",
".",
"join",
"(",
"always_iterable",
"(",
"channels",
")",
")",
",",
"server",
")"
] | Send a LIST command. | [
"Send",
"a",
"LIST",
"command",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L509-L511 | train |
jaraco/irc | irc/client.py | ServerConnection.part | def part(self, channels, message=""):
"""Send a PART command."""
self.send_items('PART', ','.join(always_iterable(channels)), message) | python | def part(self, channels, message=""):
"""Send a PART command."""
self.send_items('PART', ','.join(always_iterable(channels)), message) | [
"def",
"part",
"(",
"self",
",",
"channels",
",",
"message",
"=",
"\"\"",
")",
":",
"self",
".",
"send_items",
"(",
"'PART'",
",",
"','",
".",
"join",
"(",
"always_iterable",
"(",
"channels",
")",
")",
",",
"message",
")"
] | Send a PART command. | [
"Send",
"a",
"PART",
"command",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L542-L544 | train |
jaraco/irc | irc/client.py | ServerConnection.privmsg_many | def privmsg_many(self, targets, text):
"""Send a PRIVMSG command to multiple targets."""
target = ','.join(targets)
return self.privmsg(target, text) | python | def privmsg_many(self, targets, text):
"""Send a PRIVMSG command to multiple targets."""
target = ','.join(targets)
return self.privmsg(target, text) | [
"def",
"privmsg_many",
"(",
"self",
",",
"targets",
",",
"text",
")",
":",
"target",
"=",
"','",
".",
"join",
"(",
"targets",
")",
"return",
"self",
".",
"privmsg",
"(",
"target",
",",
"text",
")"
] | Send a PRIVMSG command to multiple targets. | [
"Send",
"a",
"PRIVMSG",
"command",
"to",
"multiple",
"targets",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L562-L565 | train |
jaraco/irc | irc/client.py | ServerConnection.user | def user(self, username, realname):
"""Send a USER command."""
cmd = 'USER {username} 0 * :{realname}'.format(**locals())
self.send_raw(cmd) | python | def user(self, username, realname):
"""Send a USER command."""
cmd = 'USER {username} 0 * :{realname}'.format(**locals())
self.send_raw(cmd) | [
"def",
"user",
"(",
"self",
",",
"username",
",",
"realname",
")",
":",
"cmd",
"=",
"'USER {username} 0 * :{realname}'",
".",
"format",
"(",
"**",
"locals",
"(",
")",
")",
"self",
".",
"send_raw",
"(",
"cmd",
")"
] | Send a USER command. | [
"Send",
"a",
"USER",
"command",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L628-L631 | train |
jaraco/irc | irc/client.py | ServerConnection.whowas | def whowas(self, nick, max="", server=""):
"""Send a WHOWAS command."""
self.send_items('WHOWAS', nick, max, server) | python | def whowas(self, nick, max="", server=""):
"""Send a WHOWAS command."""
self.send_items('WHOWAS', nick, max, server) | [
"def",
"whowas",
"(",
"self",
",",
"nick",
",",
"max",
"=",
"\"\"",
",",
"server",
"=",
"\"\"",
")",
":",
"self",
".",
"send_items",
"(",
"'WHOWAS'",
",",
"nick",
",",
"max",
",",
"server",
")"
] | Send a WHOWAS command. | [
"Send",
"a",
"WHOWAS",
"command",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L657-L659 | train |
jaraco/irc | irc/client.py | ServerConnection.set_keepalive | def set_keepalive(self, interval):
"""
Set a keepalive to occur every ``interval`` on this connection.
"""
pinger = functools.partial(self.ping, 'keep-alive')
self.reactor.scheduler.execute_every(period=interval, func=pinger) | python | def set_keepalive(self, interval):
"""
Set a keepalive to occur every ``interval`` on this connection.
"""
pinger = functools.partial(self.ping, 'keep-alive')
self.reactor.scheduler.execute_every(period=interval, func=pinger) | [
"def",
"set_keepalive",
"(",
"self",
",",
"interval",
")",
":",
"pinger",
"=",
"functools",
".",
"partial",
"(",
"self",
".",
"ping",
",",
"'keep-alive'",
")",
"self",
".",
"reactor",
".",
"scheduler",
".",
"execute_every",
"(",
"period",
"=",
"interval",
... | Set a keepalive to occur every ``interval`` on this connection. | [
"Set",
"a",
"keepalive",
"to",
"occur",
"every",
"interval",
"on",
"this",
"connection",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L668-L673 | train |
jaraco/irc | irc/client.py | Reactor.server | def server(self):
"""Creates and returns a ServerConnection object."""
conn = self.connection_class(self)
with self.mutex:
self.connections.append(conn)
return conn | python | def server(self):
"""Creates and returns a ServerConnection object."""
conn = self.connection_class(self)
with self.mutex:
self.connections.append(conn)
return conn | [
"def",
"server",
"(",
"self",
")",
":",
"conn",
"=",
"self",
".",
"connection_class",
"(",
"self",
")",
"with",
"self",
".",
"mutex",
":",
"self",
".",
"connections",
".",
"append",
"(",
"conn",
")",
"return",
"conn"
] | Creates and returns a ServerConnection object. | [
"Creates",
"and",
"returns",
"a",
"ServerConnection",
"object",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L766-L772 | train |
jaraco/irc | irc/client.py | Reactor.process_data | def process_data(self, sockets):
"""Called when there is more data to read on connection sockets.
Arguments:
sockets -- A list of socket objects.
See documentation for Reactor.__init__.
"""
with self.mutex:
log.log(logging.DEBUG - 2, "process_data()")
... | python | def process_data(self, sockets):
"""Called when there is more data to read on connection sockets.
Arguments:
sockets -- A list of socket objects.
See documentation for Reactor.__init__.
"""
with self.mutex:
log.log(logging.DEBUG - 2, "process_data()")
... | [
"def",
"process_data",
"(",
"self",
",",
"sockets",
")",
":",
"with",
"self",
".",
"mutex",
":",
"log",
".",
"log",
"(",
"logging",
".",
"DEBUG",
"-",
"2",
",",
"\"process_data()\"",
")",
"for",
"sock",
",",
"conn",
"in",
"itertools",
".",
"product",
... | Called when there is more data to read on connection sockets.
Arguments:
sockets -- A list of socket objects.
See documentation for Reactor.__init__. | [
"Called",
"when",
"there",
"is",
"more",
"data",
"to",
"read",
"on",
"connection",
"sockets",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L774-L787 | train |
jaraco/irc | irc/client.py | Reactor.process_once | def process_once(self, timeout=0):
"""Process data from connections once.
Arguments:
timeout -- How long the select() call should wait if no
data is available.
This method should be called periodically to check and process
incoming data, if there are... | python | def process_once(self, timeout=0):
"""Process data from connections once.
Arguments:
timeout -- How long the select() call should wait if no
data is available.
This method should be called periodically to check and process
incoming data, if there are... | [
"def",
"process_once",
"(",
"self",
",",
"timeout",
"=",
"0",
")",
":",
"log",
".",
"log",
"(",
"logging",
".",
"DEBUG",
"-",
"2",
",",
"\"process_once()\"",
")",
"sockets",
"=",
"self",
".",
"sockets",
"if",
"sockets",
":",
"in_",
",",
"out",
",",
... | Process data from connections once.
Arguments:
timeout -- How long the select() call should wait if no
data is available.
This method should be called periodically to check and process
incoming data, if there are any. If that seems boring, look
at t... | [
"Process",
"data",
"from",
"connections",
"once",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L807-L826 | train |
jaraco/irc | irc/client.py | Reactor.disconnect_all | def disconnect_all(self, message=""):
"""Disconnects all connections."""
with self.mutex:
for conn in self.connections:
conn.disconnect(message) | python | def disconnect_all(self, message=""):
"""Disconnects all connections."""
with self.mutex:
for conn in self.connections:
conn.disconnect(message) | [
"def",
"disconnect_all",
"(",
"self",
",",
"message",
"=",
"\"\"",
")",
":",
"with",
"self",
".",
"mutex",
":",
"for",
"conn",
"in",
"self",
".",
"connections",
":",
"conn",
".",
"disconnect",
"(",
"message",
")"
] | Disconnects all connections. | [
"Disconnects",
"all",
"connections",
"."
] | 571c1f448d5d5bb92bbe2605c33148bf6e698413 | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/client.py#L844-L848 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.