repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
MacHu-GWU/pymongo_mate-project | pymongo_mate/mongomock_mate.py | _load | def _load(db_data, db):
"""
Load :class:`mongomock.database.Database` from dict data.
"""
if db.name != db_data["name"]:
raise ValueError("dbname doesn't matches! Maybe wrong database data.")
db.__init__(client=db._client, name=db.name)
for col_name, col_data in iteritems(db_data["_coll... | python | def _load(db_data, db):
"""
Load :class:`mongomock.database.Database` from dict data.
"""
if db.name != db_data["name"]:
raise ValueError("dbname doesn't matches! Maybe wrong database data.")
db.__init__(client=db._client, name=db.name)
for col_name, col_data in iteritems(db_data["_coll... | [
"def",
"_load",
"(",
"db_data",
",",
"db",
")",
":",
"if",
"db",
".",
"name",
"!=",
"db_data",
"[",
"\"name\"",
"]",
":",
"raise",
"ValueError",
"(",
"\"dbname doesn't matches! Maybe wrong database data.\"",
")",
"db",
".",
"__init__",
"(",
"client",
"=",
"d... | Load :class:`mongomock.database.Database` from dict data. | [
"Load",
":",
"class",
":",
"mongomock",
".",
"database",
".",
"Database",
"from",
"dict",
"data",
"."
] | train | https://github.com/MacHu-GWU/pymongo_mate-project/blob/be53170c2db54cb705b9e548d32ef26c773ff7f3/pymongo_mate/mongomock_mate.py#L29-L43 |
MacHu-GWU/pymongo_mate-project | pymongo_mate/mongomock_mate.py | dump_db | def dump_db(db, file,
pretty=False,
overwrite=False,
verbose=True):
"""
Dump :class:`mongomock.database.Database` to a local file. Only support
``*.json`` or ``*.gz`` (compressed json file)
:param db: instance of :class:`mongomock.database.Database`.
:param file:... | python | def dump_db(db, file,
pretty=False,
overwrite=False,
verbose=True):
"""
Dump :class:`mongomock.database.Database` to a local file. Only support
``*.json`` or ``*.gz`` (compressed json file)
:param db: instance of :class:`mongomock.database.Database`.
:param file:... | [
"def",
"dump_db",
"(",
"db",
",",
"file",
",",
"pretty",
"=",
"False",
",",
"overwrite",
"=",
"False",
",",
"verbose",
"=",
"True",
")",
":",
"db_data",
"=",
"_dump",
"(",
"db",
")",
"json",
".",
"dump",
"(",
"db_data",
",",
"file",
",",
"pretty",
... | Dump :class:`mongomock.database.Database` to a local file. Only support
``*.json`` or ``*.gz`` (compressed json file)
:param db: instance of :class:`mongomock.database.Database`.
:param file: file path.
:param pretty: bool, toggle on jsonize into pretty format.
:param overwrite: bool, allow overwri... | [
"Dump",
":",
"class",
":",
"mongomock",
".",
"database",
".",
"Database",
"to",
"a",
"local",
"file",
".",
"Only",
"support",
"*",
".",
"json",
"or",
"*",
".",
"gz",
"(",
"compressed",
"json",
"file",
")"
] | train | https://github.com/MacHu-GWU/pymongo_mate-project/blob/be53170c2db54cb705b9e548d32ef26c773ff7f3/pymongo_mate/mongomock_mate.py#L46-L64 |
MacHu-GWU/pymongo_mate-project | pymongo_mate/mongomock_mate.py | load_db | def load_db(file, db, verbose=True):
"""
Load :class:`mongomock.database.Database` from a local file.
:param file: file path.
:param db: instance of :class:`mongomock.database.Database`.
:param verbose: bool, toggle on log.
:return: loaded db.
"""
db_data = json.load(file, verbose=verbo... | python | def load_db(file, db, verbose=True):
"""
Load :class:`mongomock.database.Database` from a local file.
:param file: file path.
:param db: instance of :class:`mongomock.database.Database`.
:param verbose: bool, toggle on log.
:return: loaded db.
"""
db_data = json.load(file, verbose=verbo... | [
"def",
"load_db",
"(",
"file",
",",
"db",
",",
"verbose",
"=",
"True",
")",
":",
"db_data",
"=",
"json",
".",
"load",
"(",
"file",
",",
"verbose",
"=",
"verbose",
")",
"return",
"_load",
"(",
"db_data",
",",
"db",
")"
] | Load :class:`mongomock.database.Database` from a local file.
:param file: file path.
:param db: instance of :class:`mongomock.database.Database`.
:param verbose: bool, toggle on log.
:return: loaded db. | [
"Load",
":",
"class",
":",
"mongomock",
".",
"database",
".",
"Database",
"from",
"a",
"local",
"file",
"."
] | train | https://github.com/MacHu-GWU/pymongo_mate-project/blob/be53170c2db54cb705b9e548d32ef26c773ff7f3/pymongo_mate/mongomock_mate.py#L67-L77 |
Synerty/peek-plugin-base | peek_plugin_base/storage/StorageUtil.py | makeOrmValuesSubqueryCondition | def makeOrmValuesSubqueryCondition(ormSession, column, values: List[Union[int, str]]):
""" Make Orm Values Subquery
:param ormSession: The orm session instance
:param column: The column from the Declarative table, eg TableItem.colName
:param values: A list of string or int values
"""
if isPostG... | python | def makeOrmValuesSubqueryCondition(ormSession, column, values: List[Union[int, str]]):
""" Make Orm Values Subquery
:param ormSession: The orm session instance
:param column: The column from the Declarative table, eg TableItem.colName
:param values: A list of string or int values
"""
if isPostG... | [
"def",
"makeOrmValuesSubqueryCondition",
"(",
"ormSession",
",",
"column",
",",
"values",
":",
"List",
"[",
"Union",
"[",
"int",
",",
"str",
"]",
"]",
")",
":",
"if",
"isPostGreSQLDialect",
"(",
"ormSession",
".",
"bind",
")",
":",
"return",
"column",
".",... | Make Orm Values Subquery
:param ormSession: The orm session instance
:param column: The column from the Declarative table, eg TableItem.colName
:param values: A list of string or int values | [
"Make",
"Orm",
"Values",
"Subquery"
] | train | https://github.com/Synerty/peek-plugin-base/blob/276101d028e1ee0678af514c761b74cce5a5cda9/peek_plugin_base/storage/StorageUtil.py#L25-L43 |
Synerty/peek-plugin-base | peek_plugin_base/storage/StorageUtil.py | makeCoreValuesSubqueryCondition | def makeCoreValuesSubqueryCondition(engine, column, values: List[Union[int, str]]):
""" Make Core Values Subquery
:param engine: The database engine, used to determine the dialect
:param column: The column, eg TableItem.__table__.c.colName
:param values: A list of string or int values
"""
if i... | python | def makeCoreValuesSubqueryCondition(engine, column, values: List[Union[int, str]]):
""" Make Core Values Subquery
:param engine: The database engine, used to determine the dialect
:param column: The column, eg TableItem.__table__.c.colName
:param values: A list of string or int values
"""
if i... | [
"def",
"makeCoreValuesSubqueryCondition",
"(",
"engine",
",",
"column",
",",
"values",
":",
"List",
"[",
"Union",
"[",
"int",
",",
"str",
"]",
"]",
")",
":",
"if",
"isPostGreSQLDialect",
"(",
"engine",
")",
":",
"return",
"column",
".",
"in_",
"(",
"valu... | Make Core Values Subquery
:param engine: The database engine, used to determine the dialect
:param column: The column, eg TableItem.__table__.c.colName
:param values: A list of string or int values | [
"Make",
"Core",
"Values",
"Subquery"
] | train | https://github.com/Synerty/peek-plugin-base/blob/276101d028e1ee0678af514c761b74cce5a5cda9/peek_plugin_base/storage/StorageUtil.py#L46-L62 |
etcher-be/epab | epab/utils/_resource_path.py | resource_path | def resource_path(package_name: str, relative_path: typing.Union[str, Path]) -> Path:
""" Get absolute path to resource, works for dev and for PyInstaller """
relative_path = Path(relative_path)
methods = [
_get_from_dev,
_get_from_package,
_get_from_sys,
]
for method in meth... | python | def resource_path(package_name: str, relative_path: typing.Union[str, Path]) -> Path:
""" Get absolute path to resource, works for dev and for PyInstaller """
relative_path = Path(relative_path)
methods = [
_get_from_dev,
_get_from_package,
_get_from_sys,
]
for method in meth... | [
"def",
"resource_path",
"(",
"package_name",
":",
"str",
",",
"relative_path",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"Path",
"]",
")",
"->",
"Path",
":",
"relative_path",
"=",
"Path",
"(",
"relative_path",
")",
"methods",
"=",
"[",
"_get_from_dev",... | Get absolute path to resource, works for dev and for PyInstaller | [
"Get",
"absolute",
"path",
"to",
"resource",
"works",
"for",
"dev",
"and",
"for",
"PyInstaller"
] | train | https://github.com/etcher-be/epab/blob/024cde74d058281aa66e6e4b7b71dccbe803b1c1/epab/utils/_resource_path.py#L25-L38 |
asmodehn/filefinder2 | filefinder2/_utils.py | _verbose_message | def _verbose_message(message, *args, **kwargs):
"""Print the message to stderr if -v/PYTHONVERBOSE is turned on."""
verbosity = kwargs.pop('verbosity', 1)
if sys.flags.verbose >= verbosity:
if not message.startswith(('#', 'import ')):
message = '# ' + message
print(message.format... | python | def _verbose_message(message, *args, **kwargs):
"""Print the message to stderr if -v/PYTHONVERBOSE is turned on."""
verbosity = kwargs.pop('verbosity', 1)
if sys.flags.verbose >= verbosity:
if not message.startswith(('#', 'import ')):
message = '# ' + message
print(message.format... | [
"def",
"_verbose_message",
"(",
"message",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"verbosity",
"=",
"kwargs",
".",
"pop",
"(",
"'verbosity'",
",",
"1",
")",
"if",
"sys",
".",
"flags",
".",
"verbose",
">=",
"verbosity",
":",
"if",
"not",... | Print the message to stderr if -v/PYTHONVERBOSE is turned on. | [
"Print",
"the",
"message",
"to",
"stderr",
"if",
"-",
"v",
"/",
"PYTHONVERBOSE",
"is",
"turned",
"on",
"."
] | train | https://github.com/asmodehn/filefinder2/blob/3f0b211ce11a34562e2a2160e039ae5290b68d6b/filefinder2/_utils.py#L14-L20 |
clusterpoint/python-client-api | pycps/connection.py | Connection._open_connection | def _open_connection(self):
""" Open a new connection socket to the CPS."""
if self._scheme == 'unix':
self._connection = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0)
self._connection.connect(self._path)
elif self._scheme == 'tcp':
self._connection = s... | python | def _open_connection(self):
""" Open a new connection socket to the CPS."""
if self._scheme == 'unix':
self._connection = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0)
self._connection.connect(self._path)
elif self._scheme == 'tcp':
self._connection = s... | [
"def",
"_open_connection",
"(",
"self",
")",
":",
"if",
"self",
".",
"_scheme",
"==",
"'unix'",
":",
"self",
".",
"_connection",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_UNIX",
",",
"socket",
".",
"SOCK_STREAM",
",",
"0",
")",
"self",
".",... | Open a new connection socket to the CPS. | [
"Open",
"a",
"new",
"connection",
"socket",
"to",
"the",
"CPS",
"."
] | train | https://github.com/clusterpoint/python-client-api/blob/fabf9bd8355aa54ba08fd6649e48f16e2c35eacd/pycps/connection.py#L94-L105 |
clusterpoint/python-client-api | pycps/connection.py | Connection._send_request | def _send_request(self, xml_request):
""" Send the prepared XML request block to the CPS using the corect protocol.
Args:
xml_request -- A fully formed xml request string for the CPS.
Returns:
The raw xml response string.
Raises:
... | python | def _send_request(self, xml_request):
""" Send the prepared XML request block to the CPS using the corect protocol.
Args:
xml_request -- A fully formed xml request string for the CPS.
Returns:
The raw xml response string.
Raises:
... | [
"def",
"_send_request",
"(",
"self",
",",
"xml_request",
")",
":",
"if",
"self",
".",
"_scheme",
"==",
"'http'",
":",
"return",
"self",
".",
"_send_http_request",
"(",
"xml_request",
")",
"else",
":",
"return",
"self",
".",
"_send_socket_request",
"(",
"xml_... | Send the prepared XML request block to the CPS using the corect protocol.
Args:
xml_request -- A fully formed xml request string for the CPS.
Returns:
The raw xml response string.
Raises:
ConnectionError -- Can't establish a connecti... | [
"Send",
"the",
"prepared",
"XML",
"request",
"block",
"to",
"the",
"CPS",
"using",
"the",
"corect",
"protocol",
"."
] | train | https://github.com/clusterpoint/python-client-api/blob/fabf9bd8355aa54ba08fd6649e48f16e2c35eacd/pycps/connection.py#L108-L123 |
clusterpoint/python-client-api | pycps/connection.py | Connection._send_http_request | def _send_http_request(self, xml_request):
""" Send a request via HTTP protocol.
Args:
xml_request -- A fully formed xml request string for the CPS.
Returns:
The raw xml response string.
"""
headers = {"Host": self._host, "Content-Type": ... | python | def _send_http_request(self, xml_request):
""" Send a request via HTTP protocol.
Args:
xml_request -- A fully formed xml request string for the CPS.
Returns:
The raw xml response string.
"""
headers = {"Host": self._host, "Content-Type": ... | [
"def",
"_send_http_request",
"(",
"self",
",",
"xml_request",
")",
":",
"headers",
"=",
"{",
"\"Host\"",
":",
"self",
".",
"_host",
",",
"\"Content-Type\"",
":",
"\"text/xml\"",
",",
"\"Recipient\"",
":",
"self",
".",
"_storage",
"}",
"try",
":",
"# Retry on... | Send a request via HTTP protocol.
Args:
xml_request -- A fully formed xml request string for the CPS.
Returns:
The raw xml response string. | [
"Send",
"a",
"request",
"via",
"HTTP",
"protocol",
"."
] | train | https://github.com/clusterpoint/python-client-api/blob/fabf9bd8355aa54ba08fd6649e48f16e2c35eacd/pycps/connection.py#L125-L144 |
clusterpoint/python-client-api | pycps/connection.py | Connection._send_socket_request | def _send_socket_request(self, xml_request):
""" Send a request via protobuf.
Args:
xml_request -- A fully formed xml request string for the CPS.
Returns:
The raw xml response string.
"""
def to_variant(number):
buff = []
... | python | def _send_socket_request(self, xml_request):
""" Send a request via protobuf.
Args:
xml_request -- A fully formed xml request string for the CPS.
Returns:
The raw xml response string.
"""
def to_variant(number):
buff = []
... | [
"def",
"_send_socket_request",
"(",
"self",
",",
"xml_request",
")",
":",
"def",
"to_variant",
"(",
"number",
")",
":",
"buff",
"=",
"[",
"]",
"while",
"number",
":",
"byte",
"=",
"number",
"%",
"128",
"number",
"=",
"number",
"//",
"128",
"if",
"numbe... | Send a request via protobuf.
Args:
xml_request -- A fully formed xml request string for the CPS.
Returns:
The raw xml response string. | [
"Send",
"a",
"request",
"via",
"protobuf",
"."
] | train | https://github.com/clusterpoint/python-client-api/blob/fabf9bd8355aa54ba08fd6649e48f16e2c35eacd/pycps/connection.py#L146-L280 |
clusterpoint/python-client-api | pycps/connection.py | Connection.similar_text | def similar_text(self, *args, **kwargs):
""" Search for documents that are similar to directly supplied text or to the textual content of an existing document.
Args:
text -- Text to found something similar to.
len -- Number of keywords to extract from the source.
quo... | python | def similar_text(self, *args, **kwargs):
""" Search for documents that are similar to directly supplied text or to the textual content of an existing document.
Args:
text -- Text to found something similar to.
len -- Number of keywords to extract from the source.
quo... | [
"def",
"similar_text",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"SimilarRequest",
"(",
"self",
",",
"*",
"args",
",",
"mode",
"=",
"'text'",
",",
"*",
"*",
"kwargs",
")",
".",
"send",
"(",
")"
] | Search for documents that are similar to directly supplied text or to the textual content of an existing document.
Args:
text -- Text to found something similar to.
len -- Number of keywords to extract from the source.
quota -- Minimum number of keywords matching in the dest... | [
"Search",
"for",
"documents",
"that",
"are",
"similar",
"to",
"directly",
"supplied",
"text",
"or",
"to",
"the",
"textual",
"content",
"of",
"an",
"existing",
"document",
"."
] | train | https://github.com/clusterpoint/python-client-api/blob/fabf9bd8355aa54ba08fd6649e48f16e2c35eacd/pycps/connection.py#L510-L527 |
thespacedoctor/rockfinder | rockfinder/cl_utils.py | main | def main(arguments=None):
"""
*The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command*
"""
# setup the command-line util settings
su = tools(
arguments=arguments,
docString=__doc__,
logLevel="WARNING",
opt... | python | def main(arguments=None):
"""
*The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command*
"""
# setup the command-line util settings
su = tools(
arguments=arguments,
docString=__doc__,
logLevel="WARNING",
opt... | [
"def",
"main",
"(",
"arguments",
"=",
"None",
")",
":",
"# setup the command-line util settings",
"su",
"=",
"tools",
"(",
"arguments",
"=",
"arguments",
",",
"docString",
"=",
"__doc__",
",",
"logLevel",
"=",
"\"WARNING\"",
",",
"options_first",
"=",
"False",
... | *The main function used when ``cl_utils.py`` is run as a single script from the cl, or when installed as a cl command* | [
"*",
"The",
"main",
"function",
"used",
"when",
"cl_utils",
".",
"py",
"is",
"run",
"as",
"a",
"single",
"script",
"from",
"the",
"cl",
"or",
"when",
"installed",
"as",
"a",
"cl",
"command",
"*"
] | train | https://github.com/thespacedoctor/rockfinder/blob/631371032d4d4166ee40484e93d35a0efc400600/rockfinder/cl_utils.py#L40-L146 |
thombashi/thutils | thutils/common.py | safe_division | def safe_division(dividend, divisor):
"""
:return:
nan: invalid arguments
:rtype: float
"""
try:
divisor = float(divisor)
dividend = float(dividend)
except (TypeError, ValueError, AssertionError):
return float("nan")
try:
return dividend / divisor
... | python | def safe_division(dividend, divisor):
"""
:return:
nan: invalid arguments
:rtype: float
"""
try:
divisor = float(divisor)
dividend = float(dividend)
except (TypeError, ValueError, AssertionError):
return float("nan")
try:
return dividend / divisor
... | [
"def",
"safe_division",
"(",
"dividend",
",",
"divisor",
")",
":",
"try",
":",
"divisor",
"=",
"float",
"(",
"divisor",
")",
"dividend",
"=",
"float",
"(",
"dividend",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
",",
"AssertionError",
")",
":",
"... | :return:
nan: invalid arguments
:rtype: float | [
":",
"return",
":",
"nan",
":",
"invalid",
"arguments",
":",
"rtype",
":",
"float"
] | train | https://github.com/thombashi/thutils/blob/9eba767cfc26b38cd66b83b99aee0c31b8b90dec/thutils/common.py#L17-L33 |
thombashi/thutils | thutils/common.py | compare_version | def compare_version(lhs_version, rhs_version):
"""
<Major>.<Minor>.<Revision> 形式のバージョン文字列を比較する。
:return:
0<: LHSがRHSより小さい
0: LHS == RHS
0>: LHSがRHSより大きい
:rtype: int
"""
lhs_major, lhs_minor, lhs_revision = [
int(v) for v in lhs_version.split(".")]
rhs_major,... | python | def compare_version(lhs_version, rhs_version):
"""
<Major>.<Minor>.<Revision> 形式のバージョン文字列を比較する。
:return:
0<: LHSがRHSより小さい
0: LHS == RHS
0>: LHSがRHSより大きい
:rtype: int
"""
lhs_major, lhs_minor, lhs_revision = [
int(v) for v in lhs_version.split(".")]
rhs_major,... | [
"def",
"compare_version",
"(",
"lhs_version",
",",
"rhs_version",
")",
":",
"lhs_major",
",",
"lhs_minor",
",",
"lhs_revision",
"=",
"[",
"int",
"(",
"v",
")",
"for",
"v",
"in",
"lhs_version",
".",
"split",
"(",
"\".\"",
")",
"]",
"rhs_major",
",",
"rhs_... | <Major>.<Minor>.<Revision> 形式のバージョン文字列を比較する。
:return:
0<: LHSがRHSより小さい
0: LHS == RHS
0>: LHSがRHSより大きい
:rtype: int | [
"<Major",
">",
".",
"<Minor",
">",
".",
"<Revision",
">",
"形式のバージョン文字列を比較する。"
] | train | https://github.com/thombashi/thutils/blob/9eba767cfc26b38cd66b83b99aee0c31b8b90dec/thutils/common.py#L108-L139 |
thombashi/thutils | thutils/common.py | dump_dict | def dump_dict(dict_input, indent=4):
"""
辞書型変数を文字列に変換して返す
"""
dict_work = dict(dict_input)
"""
for key, value in six.iteritems(dict_input):
if any([f(value) for f in (is_float, isDict, is_list_or_tuple)]):
dict_work[key] = value
continue
try:
... | python | def dump_dict(dict_input, indent=4):
"""
辞書型変数を文字列に変換して返す
"""
dict_work = dict(dict_input)
"""
for key, value in six.iteritems(dict_input):
if any([f(value) for f in (is_float, isDict, is_list_or_tuple)]):
dict_work[key] = value
continue
try:
... | [
"def",
"dump_dict",
"(",
"dict_input",
",",
"indent",
"=",
"4",
")",
":",
"dict_work",
"=",
"dict",
"(",
"dict_input",
")",
"\"\"\"\n for key, value in six.iteritems(dict_input):\n if any([f(value) for f in (is_float, isDict, is_list_or_tuple)]):\n dict_work[key]... | 辞書型変数を文字列に変換して返す | [
"辞書型変数を文字列に変換して返す"
] | train | https://github.com/thombashi/thutils/blob/9eba767cfc26b38cd66b83b99aee0c31b8b90dec/thutils/common.py#L192-L230 |
bioidiap/gridtk | gridtk/tools.py | makedirs_safe | def makedirs_safe(fulldir):
"""Creates a directory if it does not exists. Takes into consideration
concurrent access support. Works like the shell's 'mkdir -p'.
"""
try:
if not os.path.exists(fulldir): os.makedirs(fulldir)
except OSError as exc: # Python >2.5
import errno
if exc.errno == errno.EE... | python | def makedirs_safe(fulldir):
"""Creates a directory if it does not exists. Takes into consideration
concurrent access support. Works like the shell's 'mkdir -p'.
"""
try:
if not os.path.exists(fulldir): os.makedirs(fulldir)
except OSError as exc: # Python >2.5
import errno
if exc.errno == errno.EE... | [
"def",
"makedirs_safe",
"(",
"fulldir",
")",
":",
"try",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"fulldir",
")",
":",
"os",
".",
"makedirs",
"(",
"fulldir",
")",
"except",
"OSError",
"as",
"exc",
":",
"# Python >2.5",
"import",
"errno"... | Creates a directory if it does not exists. Takes into consideration
concurrent access support. Works like the shell's 'mkdir -p'. | [
"Creates",
"a",
"directory",
"if",
"it",
"does",
"not",
"exists",
".",
"Takes",
"into",
"consideration",
"concurrent",
"access",
"support",
".",
"Works",
"like",
"the",
"shell",
"s",
"mkdir",
"-",
"p",
"."
] | train | https://github.com/bioidiap/gridtk/blob/9e3291b8b50388682908927231b2730db1da147d/gridtk/tools.py#L74-L84 |
bioidiap/gridtk | gridtk/tools.py | str_ | def str_(name):
"""Return the string representation of the given 'name'.
If it is a bytes object, it will be converted into str.
If it is a str object, it will simply be resurned."""
if isinstance(name, bytes) and not isinstance(name, str):
return name.decode('utf8')
else:
return name | python | def str_(name):
"""Return the string representation of the given 'name'.
If it is a bytes object, it will be converted into str.
If it is a str object, it will simply be resurned."""
if isinstance(name, bytes) and not isinstance(name, str):
return name.decode('utf8')
else:
return name | [
"def",
"str_",
"(",
"name",
")",
":",
"if",
"isinstance",
"(",
"name",
",",
"bytes",
")",
"and",
"not",
"isinstance",
"(",
"name",
",",
"str",
")",
":",
"return",
"name",
".",
"decode",
"(",
"'utf8'",
")",
"else",
":",
"return",
"name"
] | Return the string representation of the given 'name'.
If it is a bytes object, it will be converted into str.
If it is a str object, it will simply be resurned. | [
"Return",
"the",
"string",
"representation",
"of",
"the",
"given",
"name",
".",
"If",
"it",
"is",
"a",
"bytes",
"object",
"it",
"will",
"be",
"converted",
"into",
"str",
".",
"If",
"it",
"is",
"a",
"str",
"object",
"it",
"will",
"simply",
"be",
"resurn... | train | https://github.com/bioidiap/gridtk/blob/9e3291b8b50388682908927231b2730db1da147d/gridtk/tools.py#L87-L94 |
bioidiap/gridtk | gridtk/tools.py | qsub | def qsub(command, queue=None, cwd=True, name=None, deps=[], stdout='',
stderr='', env=[], array=None, context='grid', hostname=None,
memfree=None, hvmem=None, gpumem=None, pe_opt=None, io_big=False):
"""Submits a shell job to a given grid queue
Keyword parameters:
command
The command to be submitted... | python | def qsub(command, queue=None, cwd=True, name=None, deps=[], stdout='',
stderr='', env=[], array=None, context='grid', hostname=None,
memfree=None, hvmem=None, gpumem=None, pe_opt=None, io_big=False):
"""Submits a shell job to a given grid queue
Keyword parameters:
command
The command to be submitted... | [
"def",
"qsub",
"(",
"command",
",",
"queue",
"=",
"None",
",",
"cwd",
"=",
"True",
",",
"name",
"=",
"None",
",",
"deps",
"=",
"[",
"]",
",",
"stdout",
"=",
"''",
",",
"stderr",
"=",
"''",
",",
"env",
"=",
"[",
"]",
",",
"array",
"=",
"None",... | Submits a shell job to a given grid queue
Keyword parameters:
command
The command to be submitted to the grid
queue
A valid queue name or None, to use the default queue
cwd
If the job should change to the current working directory before starting
name
An optional name to set for the job. ... | [
"Submits",
"a",
"shell",
"job",
"to",
"a",
"given",
"grid",
"queue"
] | train | https://github.com/bioidiap/gridtk/blob/9e3291b8b50388682908927231b2730db1da147d/gridtk/tools.py#L97-L263 |
bioidiap/gridtk | gridtk/tools.py | qstat | def qstat(jobid, context='grid'):
"""Queries status of a given job.
Keyword parameters:
jobid
The job identifier as returned by qsub()
context
The setshell context in which we should try a 'qsub'. Normally you don't
need to change the default. This variable can also be set to a context
dictio... | python | def qstat(jobid, context='grid'):
"""Queries status of a given job.
Keyword parameters:
jobid
The job identifier as returned by qsub()
context
The setshell context in which we should try a 'qsub'. Normally you don't
need to change the default. This variable can also be set to a context
dictio... | [
"def",
"qstat",
"(",
"jobid",
",",
"context",
"=",
"'grid'",
")",
":",
"scmd",
"=",
"[",
"'qstat'",
",",
"'-j'",
",",
"'%d'",
"%",
"jobid",
",",
"'-f'",
"]",
"logger",
".",
"debug",
"(",
"\"Qstat command '%s'\"",
",",
"' '",
".",
"join",
"(",
"scmd",... | Queries status of a given job.
Keyword parameters:
jobid
The job identifier as returned by qsub()
context
The setshell context in which we should try a 'qsub'. Normally you don't
need to change the default. This variable can also be set to a context
dictionary in which case we just setup using ... | [
"Queries",
"status",
"of",
"a",
"given",
"job",
"."
] | train | https://github.com/bioidiap/gridtk/blob/9e3291b8b50388682908927231b2730db1da147d/gridtk/tools.py#L281-L314 |
bioidiap/gridtk | gridtk/tools.py | qdel | def qdel(jobid, context='grid'):
"""Halts a given job.
Keyword parameters:
jobid
The job identifier as returned by qsub()
context
The setshell context in which we should try a 'qsub'. Normally you don't
need to change the default. This variable can also be set to a context
dictionary in which... | python | def qdel(jobid, context='grid'):
"""Halts a given job.
Keyword parameters:
jobid
The job identifier as returned by qsub()
context
The setshell context in which we should try a 'qsub'. Normally you don't
need to change the default. This variable can also be set to a context
dictionary in which... | [
"def",
"qdel",
"(",
"jobid",
",",
"context",
"=",
"'grid'",
")",
":",
"scmd",
"=",
"[",
"'qdel'",
",",
"'%d'",
"%",
"jobid",
"]",
"logger",
".",
"debug",
"(",
"\"Qdel command '%s'\"",
",",
"' '",
".",
"join",
"(",
"scmd",
")",
")",
"from",
".",
"se... | Halts a given job.
Keyword parameters:
jobid
The job identifier as returned by qsub()
context
The setshell context in which we should try a 'qsub'. Normally you don't
need to change the default. This variable can also be set to a context
dictionary in which case we just setup using that context... | [
"Halts",
"a",
"given",
"job",
"."
] | train | https://github.com/bioidiap/gridtk/blob/9e3291b8b50388682908927231b2730db1da147d/gridtk/tools.py#L316-L336 |
ajyoon/blur | examples/softlife/softlife.py | update_state | def update_state(world):
"""
Increment the world state, determining which cells live, die, or appear.
Args:
world (list[list]): A square matrix of cells
Returns: None
"""
world_size = len(world)
def wrap(index):
"""Wrap an index around the other end of the array"""
... | python | def update_state(world):
"""
Increment the world state, determining which cells live, die, or appear.
Args:
world (list[list]): A square matrix of cells
Returns: None
"""
world_size = len(world)
def wrap(index):
"""Wrap an index around the other end of the array"""
... | [
"def",
"update_state",
"(",
"world",
")",
":",
"world_size",
"=",
"len",
"(",
"world",
")",
"def",
"wrap",
"(",
"index",
")",
":",
"\"\"\"Wrap an index around the other end of the array\"\"\"",
"return",
"index",
"%",
"world_size",
"for",
"x",
"in",
"range",
"("... | Increment the world state, determining which cells live, die, or appear.
Args:
world (list[list]): A square matrix of cells
Returns: None | [
"Increment",
"the",
"world",
"state",
"determining",
"which",
"cells",
"live",
"die",
"or",
"appear",
"."
] | train | https://github.com/ajyoon/blur/blob/25fcf083af112bb003956a7a7e1c6ff7d8fef279/examples/softlife/softlife.py#L37-L77 |
ajyoon/blur | examples/softlife/softlife.py | click_event | def click_event(event):
"""On click, bring the cell under the cursor to Life"""
grid_x_coord = int(divmod(event.x, cell_size)[0])
grid_y_coord = int(divmod(event.y, cell_size)[0])
world[grid_x_coord][grid_y_coord].value = True
color = world[x][y].color_alive.get_as_hex()
canvas.itemconfig(canvas... | python | def click_event(event):
"""On click, bring the cell under the cursor to Life"""
grid_x_coord = int(divmod(event.x, cell_size)[0])
grid_y_coord = int(divmod(event.y, cell_size)[0])
world[grid_x_coord][grid_y_coord].value = True
color = world[x][y].color_alive.get_as_hex()
canvas.itemconfig(canvas... | [
"def",
"click_event",
"(",
"event",
")",
":",
"grid_x_coord",
"=",
"int",
"(",
"divmod",
"(",
"event",
".",
"x",
",",
"cell_size",
")",
"[",
"0",
"]",
")",
"grid_y_coord",
"=",
"int",
"(",
"divmod",
"(",
"event",
".",
"y",
",",
"cell_size",
")",
"[... | On click, bring the cell under the cursor to Life | [
"On",
"click",
"bring",
"the",
"cell",
"under",
"the",
"cursor",
"to",
"Life"
] | train | https://github.com/ajyoon/blur/blob/25fcf083af112bb003956a7a7e1c6ff7d8fef279/examples/softlife/softlife.py#L80-L86 |
ajyoon/blur | examples/softlife/softlife.py | draw_canvas | def draw_canvas():
"""Render the tkinter canvas based on the state of ``world``"""
for x in range(len(world)):
for y in range(len(world[x])):
if world[x][y].value:
color = world[x][y].color_alive.get_as_hex()
else:
color = world[x][y].color_dead.ge... | python | def draw_canvas():
"""Render the tkinter canvas based on the state of ``world``"""
for x in range(len(world)):
for y in range(len(world[x])):
if world[x][y].value:
color = world[x][y].color_alive.get_as_hex()
else:
color = world[x][y].color_dead.ge... | [
"def",
"draw_canvas",
"(",
")",
":",
"for",
"x",
"in",
"range",
"(",
"len",
"(",
"world",
")",
")",
":",
"for",
"y",
"in",
"range",
"(",
"len",
"(",
"world",
"[",
"x",
"]",
")",
")",
":",
"if",
"world",
"[",
"x",
"]",
"[",
"y",
"]",
".",
... | Render the tkinter canvas based on the state of ``world`` | [
"Render",
"the",
"tkinter",
"canvas",
"based",
"on",
"the",
"state",
"of",
"world"
] | train | https://github.com/ajyoon/blur/blob/25fcf083af112bb003956a7a7e1c6ff7d8fef279/examples/softlife/softlife.py#L89-L97 |
pwaller/inf | inf.py | Inf.div | def div(p, q):
"""
``p / q`` returning the correct infinity instead of
raising ZeroDivisionError.
"""
from math import copysign
if q != 0.0:
# Normal case, no infinities.
return p / q
elif p == 0.0:
return p / q # Doesn't ret... | python | def div(p, q):
"""
``p / q`` returning the correct infinity instead of
raising ZeroDivisionError.
"""
from math import copysign
if q != 0.0:
# Normal case, no infinities.
return p / q
elif p == 0.0:
return p / q # Doesn't ret... | [
"def",
"div",
"(",
"p",
",",
"q",
")",
":",
"from",
"math",
"import",
"copysign",
"if",
"q",
"!=",
"0.0",
":",
"# Normal case, no infinities.",
"return",
"p",
"/",
"q",
"elif",
"p",
"==",
"0.0",
":",
"return",
"p",
"/",
"q",
"# Doesn't return, raises an ... | ``p / q`` returning the correct infinity instead of
raising ZeroDivisionError. | [
"p",
"/",
"q",
"returning",
"the",
"correct",
"infinity",
"instead",
"of",
"raising",
"ZeroDivisionError",
"."
] | train | https://github.com/pwaller/inf/blob/2af6d7c33fb33470a6bcd7b555d01618839ff77b/inf.py#L11-L29 |
concordusapps/alchemist | alchemist/commands/shell.py | _make_context | def _make_context(context=None):
"""Create the namespace of items already pre-imported when using shell.
Accepts a dict with the desired namespace as the key, and the object as the
value.
"""
namespace = {'db': db, 'session': db.session}
namespace.update(_iter_context())
if context is not ... | python | def _make_context(context=None):
"""Create the namespace of items already pre-imported when using shell.
Accepts a dict with the desired namespace as the key, and the object as the
value.
"""
namespace = {'db': db, 'session': db.session}
namespace.update(_iter_context())
if context is not ... | [
"def",
"_make_context",
"(",
"context",
"=",
"None",
")",
":",
"namespace",
"=",
"{",
"'db'",
":",
"db",
",",
"'session'",
":",
"db",
".",
"session",
"}",
"namespace",
".",
"update",
"(",
"_iter_context",
"(",
")",
")",
"if",
"context",
"is",
"not",
... | Create the namespace of items already pre-imported when using shell.
Accepts a dict with the desired namespace as the key, and the object as the
value. | [
"Create",
"the",
"namespace",
"of",
"items",
"already",
"pre",
"-",
"imported",
"when",
"using",
"shell",
"."
] | train | https://github.com/concordusapps/alchemist/blob/822571366271b5dca0ac8bf41df988c6a3b61432/alchemist/commands/shell.py#L19-L31 |
concordusapps/alchemist | alchemist/db/operations/sql.py | init | def init(**kwargs):
"""Initialize the specified names in the specified databases.
The general process is as follows:
- Ensure the database in question exists
- Ensure all tables exist in the database.
"""
# TODO: Iterate through all engines in name set.
database = kwargs.pop('database'... | python | def init(**kwargs):
"""Initialize the specified names in the specified databases.
The general process is as follows:
- Ensure the database in question exists
- Ensure all tables exist in the database.
"""
# TODO: Iterate through all engines in name set.
database = kwargs.pop('database'... | [
"def",
"init",
"(",
"*",
"*",
"kwargs",
")",
":",
"# TODO: Iterate through all engines in name set.",
"database",
"=",
"kwargs",
".",
"pop",
"(",
"'database'",
",",
"False",
")",
"if",
"database",
"and",
"not",
"database_exists",
"(",
"engine",
"[",
"'default'",... | Initialize the specified names in the specified databases.
The general process is as follows:
- Ensure the database in question exists
- Ensure all tables exist in the database. | [
"Initialize",
"the",
"specified",
"names",
"in",
"the",
"specified",
"databases",
"."
] | train | https://github.com/concordusapps/alchemist/blob/822571366271b5dca0ac8bf41df988c6a3b61432/alchemist/db/operations/sql.py#L57-L73 |
concordusapps/alchemist | alchemist/db/operations/sql.py | clear | def clear(**kwargs):
"""Clear the specified names from the specified databases.
This can be highly destructive as it destroys tables and when all names
are removed from a database, the database itself.
"""
database = kwargs.pop('database', False)
expression = lambda target, table: table.drop(t... | python | def clear(**kwargs):
"""Clear the specified names from the specified databases.
This can be highly destructive as it destroys tables and when all names
are removed from a database, the database itself.
"""
database = kwargs.pop('database', False)
expression = lambda target, table: table.drop(t... | [
"def",
"clear",
"(",
"*",
"*",
"kwargs",
")",
":",
"database",
"=",
"kwargs",
".",
"pop",
"(",
"'database'",
",",
"False",
")",
"expression",
"=",
"lambda",
"target",
",",
"table",
":",
"table",
".",
"drop",
"(",
"target",
")",
"test",
"=",
"lambda",... | Clear the specified names from the specified databases.
This can be highly destructive as it destroys tables and when all names
are removed from a database, the database itself. | [
"Clear",
"the",
"specified",
"names",
"from",
"the",
"specified",
"databases",
"."
] | train | https://github.com/concordusapps/alchemist/blob/822571366271b5dca0ac8bf41df988c6a3b61432/alchemist/db/operations/sql.py#L76-L93 |
concordusapps/alchemist | alchemist/db/operations/sql.py | flush | def flush(**kwargs):
"""Flush the specified names from the specified databases.
This can be highly destructive as it destroys all data.
"""
expression = lambda target, table: target.execute(table.delete())
test = lambda target, table: not table.exists(target)
op(expression, reversed(metadata.s... | python | def flush(**kwargs):
"""Flush the specified names from the specified databases.
This can be highly destructive as it destroys all data.
"""
expression = lambda target, table: target.execute(table.delete())
test = lambda target, table: not table.exists(target)
op(expression, reversed(metadata.s... | [
"def",
"flush",
"(",
"*",
"*",
"kwargs",
")",
":",
"expression",
"=",
"lambda",
"target",
",",
"table",
":",
"target",
".",
"execute",
"(",
"table",
".",
"delete",
"(",
")",
")",
"test",
"=",
"lambda",
"target",
",",
"table",
":",
"not",
"table",
"... | Flush the specified names from the specified databases.
This can be highly destructive as it destroys all data. | [
"Flush",
"the",
"specified",
"names",
"from",
"the",
"specified",
"databases",
"."
] | train | https://github.com/concordusapps/alchemist/blob/822571366271b5dca0ac8bf41df988c6a3b61432/alchemist/db/operations/sql.py#L96-L105 |
concordusapps/alchemist | alchemist/db/operations/sql.py | is_table_included | def is_table_included(table, names):
"""Determines if the table is included by reference in the names.
A table can be named by its component or its model (using the short-name
or a full python path).
eg. 'package.models.SomeModel' or 'package:SomeModel' or 'package'
would all include 'SomeMode... | python | def is_table_included(table, names):
"""Determines if the table is included by reference in the names.
A table can be named by its component or its model (using the short-name
or a full python path).
eg. 'package.models.SomeModel' or 'package:SomeModel' or 'package'
would all include 'SomeMode... | [
"def",
"is_table_included",
"(",
"table",
",",
"names",
")",
":",
"# No names indicates that every table is included.",
"if",
"not",
"names",
":",
"return",
"True",
"# Introspect the table and pull out the model and component from it.",
"model",
",",
"component",
"=",
"table"... | Determines if the table is included by reference in the names.
A table can be named by its component or its model (using the short-name
or a full python path).
eg. 'package.models.SomeModel' or 'package:SomeModel' or 'package'
would all include 'SomeModel'. | [
"Determines",
"if",
"the",
"table",
"is",
"included",
"by",
"reference",
"in",
"the",
"names",
"."
] | train | https://github.com/concordusapps/alchemist/blob/822571366271b5dca0ac8bf41df988c6a3b61432/alchemist/db/operations/sql.py#L108-L139 |
coded-by-hand/mass | env/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/__init__.py | autocomplete | def autocomplete():
"""Command and option completion for the main option parser (and options)
and its subcommands (and options).
Enable by sourcing one of the completion shell scripts (bash or zsh).
"""
# Don't complete if user hasn't sourced bash_completion file.
if 'PIP_AUTO_COMPLETE' not in ... | python | def autocomplete():
"""Command and option completion for the main option parser (and options)
and its subcommands (and options).
Enable by sourcing one of the completion shell scripts (bash or zsh).
"""
# Don't complete if user hasn't sourced bash_completion file.
if 'PIP_AUTO_COMPLETE' not in ... | [
"def",
"autocomplete",
"(",
")",
":",
"# Don't complete if user hasn't sourced bash_completion file.",
"if",
"'PIP_AUTO_COMPLETE'",
"not",
"in",
"os",
".",
"environ",
":",
"return",
"cwords",
"=",
"os",
".",
"environ",
"[",
"'COMP_WORDS'",
"]",
".",
"split",
"(",
... | Command and option completion for the main option parser (and options)
and its subcommands (and options).
Enable by sourcing one of the completion shell scripts (bash or zsh). | [
"Command",
"and",
"option",
"completion",
"for",
"the",
"main",
"option",
"parser",
"(",
"and",
"options",
")",
"and",
"its",
"subcommands",
"(",
"and",
"options",
")",
"."
] | train | https://github.com/coded-by-hand/mass/blob/59005479efed3cd8598a8f0c66791a4482071899/env/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/__init__.py#L18-L80 |
labeneator/flask-cavage | flask_cavage.py | CavageSignature.secret_loader | def secret_loader(self, callback):
"""
Decorate a method that receives a key id and returns a secret key
"""
if not callback or not callable(callback):
raise Exception("Please pass in a callable that loads secret keys")
self.secret_loader_callback = callback
r... | python | def secret_loader(self, callback):
"""
Decorate a method that receives a key id and returns a secret key
"""
if not callback or not callable(callback):
raise Exception("Please pass in a callable that loads secret keys")
self.secret_loader_callback = callback
r... | [
"def",
"secret_loader",
"(",
"self",
",",
"callback",
")",
":",
"if",
"not",
"callback",
"or",
"not",
"callable",
"(",
"callback",
")",
":",
"raise",
"Exception",
"(",
"\"Please pass in a callable that loads secret keys\"",
")",
"self",
".",
"secret_loader_callback"... | Decorate a method that receives a key id and returns a secret key | [
"Decorate",
"a",
"method",
"that",
"receives",
"a",
"key",
"id",
"and",
"returns",
"a",
"secret",
"key"
] | train | https://github.com/labeneator/flask-cavage/blob/7144841eaf289b469ba77507e19d9012284272d4/flask_cavage.py#L168-L175 |
labeneator/flask-cavage | flask_cavage.py | CavageSignature.context_loader | def context_loader(self, callback):
"""
Decorate a method that receives a key id and returns an object or dict
that will be available in the request context as g.cavage_context
"""
if not callback or not callable(callback):
raise Exception("Please pass in a callable t... | python | def context_loader(self, callback):
"""
Decorate a method that receives a key id and returns an object or dict
that will be available in the request context as g.cavage_context
"""
if not callback or not callable(callback):
raise Exception("Please pass in a callable t... | [
"def",
"context_loader",
"(",
"self",
",",
"callback",
")",
":",
"if",
"not",
"callback",
"or",
"not",
"callable",
"(",
"callback",
")",
":",
"raise",
"Exception",
"(",
"\"Please pass in a callable that loads your context.\"",
")",
"self",
".",
"context_loader_callb... | Decorate a method that receives a key id and returns an object or dict
that will be available in the request context as g.cavage_context | [
"Decorate",
"a",
"method",
"that",
"receives",
"a",
"key",
"id",
"and",
"returns",
"an",
"object",
"or",
"dict",
"that",
"will",
"be",
"available",
"in",
"the",
"request",
"context",
"as",
"g",
".",
"cavage_context"
] | train | https://github.com/labeneator/flask-cavage/blob/7144841eaf289b469ba77507e19d9012284272d4/flask_cavage.py#L177-L185 |
labeneator/flask-cavage | flask_cavage.py | CavageSignature.replay_checker | def replay_checker(self, callback):
"""
Decorate a method that receives the request headers and returns a bool
indicating whether we should proceed with the request. This can be used
to protect against replay attacks. For example, this method could check
the request date header v... | python | def replay_checker(self, callback):
"""
Decorate a method that receives the request headers and returns a bool
indicating whether we should proceed with the request. This can be used
to protect against replay attacks. For example, this method could check
the request date header v... | [
"def",
"replay_checker",
"(",
"self",
",",
"callback",
")",
":",
"if",
"not",
"callback",
"or",
"not",
"callable",
"(",
"callback",
")",
":",
"raise",
"Exception",
"(",
"\"Please pass in a callable that protects against replays\"",
")",
"self",
".",
"replay_checker_... | Decorate a method that receives the request headers and returns a bool
indicating whether we should proceed with the request. This can be used
to protect against replay attacks. For example, this method could check
the request date header value is within a delta value of the server time. | [
"Decorate",
"a",
"method",
"that",
"receives",
"the",
"request",
"headers",
"and",
"returns",
"a",
"bool",
"indicating",
"whether",
"we",
"should",
"proceed",
"with",
"the",
"request",
".",
"This",
"can",
"be",
"used",
"to",
"protect",
"against",
"replay",
"... | train | https://github.com/labeneator/flask-cavage/blob/7144841eaf289b469ba77507e19d9012284272d4/flask_cavage.py#L187-L197 |
littlemo/moear-package-mobi | moear_package_mobi/spiders/mobi.py | MobiSpider.parse | def parse(self, response):
"""
从 self.data 中将文章信息格式化为 :class:`.MoearPackageMobiItem`
"""
# 工作&输出路径
self.template_dir = self.settings.get('TEMPLATE_DIR')
shutil.rmtree(
self.settings.get('BUILD_SOURCE_DIR'), ignore_errors=True)
self.build_source_dir = u... | python | def parse(self, response):
"""
从 self.data 中将文章信息格式化为 :class:`.MoearPackageMobiItem`
"""
# 工作&输出路径
self.template_dir = self.settings.get('TEMPLATE_DIR')
shutil.rmtree(
self.settings.get('BUILD_SOURCE_DIR'), ignore_errors=True)
self.build_source_dir = u... | [
"def",
"parse",
"(",
"self",
",",
"response",
")",
":",
"# 工作&输出路径",
"self",
".",
"template_dir",
"=",
"self",
".",
"settings",
".",
"get",
"(",
"'TEMPLATE_DIR'",
")",
"shutil",
".",
"rmtree",
"(",
"self",
".",
"settings",
".",
"get",
"(",
"'BUILD_SOURCE... | 从 self.data 中将文章信息格式化为 :class:`.MoearPackageMobiItem` | [
"从",
"self",
".",
"data",
"中将文章信息格式化为",
":",
"class",
":",
".",
"MoearPackageMobiItem"
] | train | https://github.com/littlemo/moear-package-mobi/blob/189a077bd0ad5309607957b3f1c0b65eae40ec90/moear_package_mobi/spiders/mobi.py#L63-L105 |
littlemo/moear-package-mobi | moear_package_mobi/spiders/mobi.py | MobiSpider.filter_images_urls | def filter_images_urls(image_urls, image_filter, common_image_filter=None):
'''
图片链接过滤器,根据传入的过滤器规则,对图片链接列表进行过滤并返回结果列表
:param list(str) image_urls: 图片链接字串列表
:param list(str) image_filter: 过滤器字串列表
:param list(str) common_image_filter: 可选,通用的基础过滤器,
会在定制过滤器前对传入图片应用
... | python | def filter_images_urls(image_urls, image_filter, common_image_filter=None):
'''
图片链接过滤器,根据传入的过滤器规则,对图片链接列表进行过滤并返回结果列表
:param list(str) image_urls: 图片链接字串列表
:param list(str) image_filter: 过滤器字串列表
:param list(str) common_image_filter: 可选,通用的基础过滤器,
会在定制过滤器前对传入图片应用
... | [
"def",
"filter_images_urls",
"(",
"image_urls",
",",
"image_filter",
",",
"common_image_filter",
"=",
"None",
")",
":",
"common_image_filter",
"=",
"common_image_filter",
"or",
"[",
"]",
"# 对图片过滤器进行完整性验证",
"image_filter",
"=",
"json",
".",
"loads",
"(",
"image_filte... | 图片链接过滤器,根据传入的过滤器规则,对图片链接列表进行过滤并返回结果列表
:param list(str) image_urls: 图片链接字串列表
:param list(str) image_filter: 过滤器字串列表
:param list(str) common_image_filter: 可选,通用的基础过滤器,
会在定制过滤器前对传入图片应用
:return: 过滤后的结果链接列表,以及被过滤掉的链接列表
:rtype: list(str), list(str)
:raises TypeErro... | [
"图片链接过滤器,根据传入的过滤器规则,对图片链接列表进行过滤并返回结果列表"
] | train | https://github.com/littlemo/moear-package-mobi/blob/189a077bd0ad5309607957b3f1c0b65eae40ec90/moear_package_mobi/spiders/mobi.py#L112-L150 |
littlemo/moear-package-mobi | moear_package_mobi/spiders/mobi.py | MobiSpider.generate_mobi_file | def generate_mobi_file(self):
'''
使用 :mod:`subprocess` 模块调用 ``KindleGen`` 工具,
将已准备好的书籍源文件编译生成 ``mobi`` 文件
'''
opf_file = os.path.join(self.build_source_dir, 'moear.opf')
command_list = [self.kg, opf_file]
output = subprocess.Popen(
command_list, stdout... | python | def generate_mobi_file(self):
'''
使用 :mod:`subprocess` 模块调用 ``KindleGen`` 工具,
将已准备好的书籍源文件编译生成 ``mobi`` 文件
'''
opf_file = os.path.join(self.build_source_dir, 'moear.opf')
command_list = [self.kg, opf_file]
output = subprocess.Popen(
command_list, stdout... | [
"def",
"generate_mobi_file",
"(",
"self",
")",
":",
"opf_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"build_source_dir",
",",
"'moear.opf'",
")",
"command_list",
"=",
"[",
"self",
".",
"kg",
",",
"opf_file",
"]",
"output",
"=",
"subproc... | 使用 :mod:`subprocess` 模块调用 ``KindleGen`` 工具,
将已准备好的书籍源文件编译生成 ``mobi`` 文件 | [
"使用",
":",
"mod",
":",
"subprocess",
"模块调用",
"KindleGen",
"工具,",
"将已准备好的书籍源文件编译生成",
"mobi",
"文件"
] | train | https://github.com/littlemo/moear-package-mobi/blob/189a077bd0ad5309607957b3f1c0b65eae40ec90/moear_package_mobi/spiders/mobi.py#L152-L167 |
littlemo/moear-package-mobi | moear_package_mobi/spiders/mobi.py | MobiSpider.closed | def closed(self, reason):
'''
异步爬取本地化处理完成后,使用结果数据,进行输出文件的渲染,渲染完毕,
调用 :meth:`.MobiSpider.generate_mobi_file` 方法,生成目标 ``mobi`` 文件
'''
# 拷贝封面&报头图片文件
utils.mkdirp(os.path.join(self.build_source_dir, 'images'))
self._logger.info(self.options)
shutil.copy(
... | python | def closed(self, reason):
'''
异步爬取本地化处理完成后,使用结果数据,进行输出文件的渲染,渲染完毕,
调用 :meth:`.MobiSpider.generate_mobi_file` 方法,生成目标 ``mobi`` 文件
'''
# 拷贝封面&报头图片文件
utils.mkdirp(os.path.join(self.build_source_dir, 'images'))
self._logger.info(self.options)
shutil.copy(
... | [
"def",
"closed",
"(",
"self",
",",
"reason",
")",
":",
"# 拷贝封面&报头图片文件",
"utils",
".",
"mkdirp",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"build_source_dir",
",",
"'images'",
")",
")",
"self",
".",
"_logger",
".",
"info",
"(",
"self",
".... | 异步爬取本地化处理完成后,使用结果数据,进行输出文件的渲染,渲染完毕,
调用 :meth:`.MobiSpider.generate_mobi_file` 方法,生成目标 ``mobi`` 文件 | [
"异步爬取本地化处理完成后,使用结果数据,进行输出文件的渲染,渲染完毕,",
"调用",
":",
"meth",
":",
".",
"MobiSpider",
".",
"generate_mobi_file",
"方法,生成目标",
"mobi",
"文件"
] | train | https://github.com/littlemo/moear-package-mobi/blob/189a077bd0ad5309607957b3f1c0b65eae40ec90/moear_package_mobi/spiders/mobi.py#L169-L255 |
six8/corona-cipr | src/cipr/commands/image.py | makeicons | def makeicons(source):
"""
Create all the neccessary icons from source image
"""
im = Image.open(source)
for name, (_, w, h, func) in icon_sizes.iteritems():
print('Making icon %s...' % name)
tn = func(im, (w, h))
bg = Image.new('RGBA', (w, h), (255, 255, 255))
x = (w... | python | def makeicons(source):
"""
Create all the neccessary icons from source image
"""
im = Image.open(source)
for name, (_, w, h, func) in icon_sizes.iteritems():
print('Making icon %s...' % name)
tn = func(im, (w, h))
bg = Image.new('RGBA', (w, h), (255, 255, 255))
x = (w... | [
"def",
"makeicons",
"(",
"source",
")",
":",
"im",
"=",
"Image",
".",
"open",
"(",
"source",
")",
"for",
"name",
",",
"(",
"_",
",",
"w",
",",
"h",
",",
"func",
")",
"in",
"icon_sizes",
".",
"iteritems",
"(",
")",
":",
"print",
"(",
"'Making icon... | Create all the neccessary icons from source image | [
"Create",
"all",
"the",
"neccessary",
"icons",
"from",
"source",
"image"
] | train | https://github.com/six8/corona-cipr/blob/a2f45761080c874afa39bf95fd5c4467c8eae272/src/cipr/commands/image.py#L57-L70 |
cohorte/cohorte-herald | python/herald/transports/xmpp/utils.py | dump_element | def dump_element(element):
"""
Dumps the content of the given ElementBase object to a string
:param element: An ElementBase object
:return: A full description of its content
:raise TypeError: Invalid object
"""
# Check type
try:
assert isinstance(element, sleekxmpp.ElementBase)
... | python | def dump_element(element):
"""
Dumps the content of the given ElementBase object to a string
:param element: An ElementBase object
:return: A full description of its content
:raise TypeError: Invalid object
"""
# Check type
try:
assert isinstance(element, sleekxmpp.ElementBase)
... | [
"def",
"dump_element",
"(",
"element",
")",
":",
"# Check type",
"try",
":",
"assert",
"isinstance",
"(",
"element",
",",
"sleekxmpp",
".",
"ElementBase",
")",
"except",
"AssertionError",
":",
"raise",
"TypeError",
"(",
"\"Not an ElementBase: {0}\"",
".",
"format"... | Dumps the content of the given ElementBase object to a string
:param element: An ElementBase object
:return: A full description of its content
:raise TypeError: Invalid object | [
"Dumps",
"the",
"content",
"of",
"the",
"given",
"ElementBase",
"object",
"to",
"a",
"string"
] | train | https://github.com/cohorte/cohorte-herald/blob/bb3445d0031c8b3abad71e6219cc559b49faa3ee/python/herald/transports/xmpp/utils.py#L53-L82 |
cohorte/cohorte-herald | python/herald/transports/xmpp/utils.py | RoomCreator.create_room | def create_room(self, room, service, nick, config=None,
callback=None, errback=None, room_jid=None):
"""
Prepares the creation of a room.
The callback is a method with two arguments:
- room: Bare JID of the room
- nick: Nick used to create the room
... | python | def create_room(self, room, service, nick, config=None,
callback=None, errback=None, room_jid=None):
"""
Prepares the creation of a room.
The callback is a method with two arguments:
- room: Bare JID of the room
- nick: Nick used to create the room
... | [
"def",
"create_room",
"(",
"self",
",",
"room",
",",
"service",
",",
"nick",
",",
"config",
"=",
"None",
",",
"callback",
"=",
"None",
",",
"errback",
"=",
"None",
",",
"room_jid",
"=",
"None",
")",
":",
"self",
".",
"__logger",
".",
"debug",
"(",
... | Prepares the creation of a room.
The callback is a method with two arguments:
- room: Bare JID of the room
- nick: Nick used to create the room
The errback is a method with 4 arguments:
- room: Bare JID of the room
- nick: Nick used to create the room
... | [
"Prepares",
"the",
"creation",
"of",
"a",
"room",
"."
] | train | https://github.com/cohorte/cohorte-herald/blob/bb3445d0031c8b3abad71e6219cc559b49faa3ee/python/herald/transports/xmpp/utils.py#L136-L177 |
cohorte/cohorte-herald | python/herald/transports/xmpp/utils.py | RoomCreator.__safe_callback | def __safe_callback(self, room_data):
"""
Safe use of the callback method, to avoid errors propagation
:param room_data: A RoomData object
"""
method = room_data.callback
if method is not None:
try:
method(room_data.room, room_data.nick)
... | python | def __safe_callback(self, room_data):
"""
Safe use of the callback method, to avoid errors propagation
:param room_data: A RoomData object
"""
method = room_data.callback
if method is not None:
try:
method(room_data.room, room_data.nick)
... | [
"def",
"__safe_callback",
"(",
"self",
",",
"room_data",
")",
":",
"method",
"=",
"room_data",
".",
"callback",
"if",
"method",
"is",
"not",
"None",
":",
"try",
":",
"method",
"(",
"room_data",
".",
"room",
",",
"room_data",
".",
"nick",
")",
"except",
... | Safe use of the callback method, to avoid errors propagation
:param room_data: A RoomData object | [
"Safe",
"use",
"of",
"the",
"callback",
"method",
"to",
"avoid",
"errors",
"propagation"
] | train | https://github.com/cohorte/cohorte-herald/blob/bb3445d0031c8b3abad71e6219cc559b49faa3ee/python/herald/transports/xmpp/utils.py#L179-L191 |
cohorte/cohorte-herald | python/herald/transports/xmpp/utils.py | RoomCreator.__safe_errback | def __safe_errback(self, room_data, err_condition, err_text):
"""
Safe use of the callback method, to avoid errors propagation
:param room_data: A RoomData object
:param err_condition: Category of error
:param err_text: Description of the error
"""
method = room_... | python | def __safe_errback(self, room_data, err_condition, err_text):
"""
Safe use of the callback method, to avoid errors propagation
:param room_data: A RoomData object
:param err_condition: Category of error
:param err_text: Description of the error
"""
method = room_... | [
"def",
"__safe_errback",
"(",
"self",
",",
"room_data",
",",
"err_condition",
",",
"err_text",
")",
":",
"method",
"=",
"room_data",
".",
"errback",
"if",
"method",
"is",
"not",
"None",
":",
"try",
":",
"method",
"(",
"room_data",
".",
"room",
",",
"room... | Safe use of the callback method, to avoid errors propagation
:param room_data: A RoomData object
:param err_condition: Category of error
:param err_text: Description of the error | [
"Safe",
"use",
"of",
"the",
"callback",
"method",
"to",
"avoid",
"errors",
"propagation"
] | train | https://github.com/cohorte/cohorte-herald/blob/bb3445d0031c8b3abad71e6219cc559b49faa3ee/python/herald/transports/xmpp/utils.py#L193-L207 |
cohorte/cohorte-herald | python/herald/transports/xmpp/utils.py | RoomCreator.__on_presence | def __on_presence(self, data):
"""
Got a presence stanza
"""
room_jid = data['from'].bare
muc_presence = data['muc']
room = muc_presence['room']
nick = muc_presence['nick']
with self.__lock:
try:
# Get room state machine
... | python | def __on_presence(self, data):
"""
Got a presence stanza
"""
room_jid = data['from'].bare
muc_presence = data['muc']
room = muc_presence['room']
nick = muc_presence['nick']
with self.__lock:
try:
# Get room state machine
... | [
"def",
"__on_presence",
"(",
"self",
",",
"data",
")",
":",
"room_jid",
"=",
"data",
"[",
"'from'",
"]",
".",
"bare",
"muc_presence",
"=",
"data",
"[",
"'muc'",
"]",
"room",
"=",
"muc_presence",
"[",
"'room'",
"]",
"nick",
"=",
"muc_presence",
"[",
"'n... | Got a presence stanza | [
"Got",
"a",
"presence",
"stanza"
] | train | https://github.com/cohorte/cohorte-herald/blob/bb3445d0031c8b3abad71e6219cc559b49faa3ee/python/herald/transports/xmpp/utils.py#L209-L275 |
cohorte/cohorte-herald | python/herald/transports/xmpp/utils.py | MarksCallback.__call | def __call(self):
"""
Calls the callback method
"""
try:
if self.__callback is not None:
self.__callback(self.__successes, self.__errors)
except Exception as ex:
self.__logger.exception("Error calling back count down "
... | python | def __call(self):
"""
Calls the callback method
"""
try:
if self.__callback is not None:
self.__callback(self.__successes, self.__errors)
except Exception as ex:
self.__logger.exception("Error calling back count down "
... | [
"def",
"__call",
"(",
"self",
")",
":",
"try",
":",
"if",
"self",
".",
"__callback",
"is",
"not",
"None",
":",
"self",
".",
"__callback",
"(",
"self",
".",
"__successes",
",",
"self",
".",
"__errors",
")",
"except",
"Exception",
"as",
"ex",
":",
"sel... | Calls the callback method | [
"Calls",
"the",
"callback",
"method"
] | train | https://github.com/cohorte/cohorte-herald/blob/bb3445d0031c8b3abad71e6219cc559b49faa3ee/python/herald/transports/xmpp/utils.py#L305-L316 |
cohorte/cohorte-herald | python/herald/transports/xmpp/utils.py | MarksCallback.__mark | def __mark(self, element, mark_set):
"""
Marks an element
:param element: The element to mark
:param mark_set: The set corresponding to the mark
:return: True if the element was known
"""
try:
# The given element can be of a different type than the or... | python | def __mark(self, element, mark_set):
"""
Marks an element
:param element: The element to mark
:param mark_set: The set corresponding to the mark
:return: True if the element was known
"""
try:
# The given element can be of a different type than the or... | [
"def",
"__mark",
"(",
"self",
",",
"element",
",",
"mark_set",
")",
":",
"try",
":",
"# The given element can be of a different type than the original",
"# one (JID instead of str, ...), so we retrieve the original one",
"original",
"=",
"self",
".",
"__elements",
".",
"pop",... | Marks an element
:param element: The element to mark
:param mark_set: The set corresponding to the mark
:return: True if the element was known | [
"Marks",
"an",
"element"
] | train | https://github.com/cohorte/cohorte-herald/blob/bb3445d0031c8b3abad71e6219cc559b49faa3ee/python/herald/transports/xmpp/utils.py#L318-L337 |
earlye/nephele | nephele/AwsEni.py | AwsEni.do_refresh | def do_refresh(self,args):
"""Refresh the view of the eni"""
pprint(AwsConnectionFactory.getEc2Client().describe_network_interfaces(NetworkInterfaceIds=[self.physicalId])); | python | def do_refresh(self,args):
"""Refresh the view of the eni"""
pprint(AwsConnectionFactory.getEc2Client().describe_network_interfaces(NetworkInterfaceIds=[self.physicalId])); | [
"def",
"do_refresh",
"(",
"self",
",",
"args",
")",
":",
"pprint",
"(",
"AwsConnectionFactory",
".",
"getEc2Client",
"(",
")",
".",
"describe_network_interfaces",
"(",
"NetworkInterfaceIds",
"=",
"[",
"self",
".",
"physicalId",
"]",
")",
")"
] | Refresh the view of the eni | [
"Refresh",
"the",
"view",
"of",
"the",
"eni"
] | train | https://github.com/earlye/nephele/blob/a7dadc68f4124671457f09119419978c4d22013e/nephele/AwsEni.py#L13-L15 |
funkybob/knights-templater | knights/tags.py | do_super | def do_super(parser, token):
'''
Access the parent templates block.
{% super name %}
'''
name = token.strip()
return ast.YieldFrom(
value=_a.Call(_a.Attribute(_a.Call(_a.Name('super')), name), [
# _a.Attribute(_a.Name('context'), 'parent'),
_a.Name('context'),
... | python | def do_super(parser, token):
'''
Access the parent templates block.
{% super name %}
'''
name = token.strip()
return ast.YieldFrom(
value=_a.Call(_a.Attribute(_a.Call(_a.Name('super')), name), [
# _a.Attribute(_a.Name('context'), 'parent'),
_a.Name('context'),
... | [
"def",
"do_super",
"(",
"parser",
",",
"token",
")",
":",
"name",
"=",
"token",
".",
"strip",
"(",
")",
"return",
"ast",
".",
"YieldFrom",
"(",
"value",
"=",
"_a",
".",
"Call",
"(",
"_a",
".",
"Attribute",
"(",
"_a",
".",
"Call",
"(",
"_a",
".",
... | Access the parent templates block.
{% super name %} | [
"Access",
"the",
"parent",
"templates",
"block",
"."
] | train | https://github.com/funkybob/knights-templater/blob/b15cdbaae7d824d02f7f03ca04599ae94bb759dd/knights/tags.py#L45-L57 |
funkybob/knights-templater | knights/tags.py | _create_with_scope | def _create_with_scope(body, kwargs):
'''
Helper function to wrap a block in a scope stack:
with ContextScope(context, **kwargs) as context:
... body ...
'''
return ast.With(
items=[
ast.withitem(
context_expr=_a.Call(
_a.Name('Context... | python | def _create_with_scope(body, kwargs):
'''
Helper function to wrap a block in a scope stack:
with ContextScope(context, **kwargs) as context:
... body ...
'''
return ast.With(
items=[
ast.withitem(
context_expr=_a.Call(
_a.Name('Context... | [
"def",
"_create_with_scope",
"(",
"body",
",",
"kwargs",
")",
":",
"return",
"ast",
".",
"With",
"(",
"items",
"=",
"[",
"ast",
".",
"withitem",
"(",
"context_expr",
"=",
"_a",
".",
"Call",
"(",
"_a",
".",
"Name",
"(",
"'ContextScope'",
")",
",",
"["... | Helper function to wrap a block in a scope stack:
with ContextScope(context, **kwargs) as context:
... body ... | [
"Helper",
"function",
"to",
"wrap",
"a",
"block",
"in",
"a",
"scope",
"stack",
":"
] | train | https://github.com/funkybob/knights-templater/blob/b15cdbaae7d824d02f7f03ca04599ae94bb759dd/knights/tags.py#L74-L93 |
funkybob/knights-templater | knights/tags.py | do_for | def do_for(parser, token):
'''
{% for a, b, c in iterable %}
{% endfor %}
We create the structure:
with ContextWrapper(context) as context:
for a, b, c in iterable:
context.update(a=a, b=b, c=c)
...
If there is a {% empty %} clause, we create:
if iterable... | python | def do_for(parser, token):
'''
{% for a, b, c in iterable %}
{% endfor %}
We create the structure:
with ContextWrapper(context) as context:
for a, b, c in iterable:
context.update(a=a, b=b, c=c)
...
If there is a {% empty %} clause, we create:
if iterable... | [
"def",
"do_for",
"(",
"parser",
",",
"token",
")",
":",
"code",
"=",
"ast",
".",
"parse",
"(",
"'for %s: pass'",
"%",
"token",
",",
"mode",
"=",
"'exec'",
")",
"# Grab the ast.For node",
"loop",
"=",
"code",
".",
"body",
"[",
"0",
"]",
"# Wrap its source... | {% for a, b, c in iterable %}
{% endfor %}
We create the structure:
with ContextWrapper(context) as context:
for a, b, c in iterable:
context.update(a=a, b=b, c=c)
...
If there is a {% empty %} clause, we create:
if iterable:
{ above code }
else:
... | [
"{",
"%",
"for",
"a",
"b",
"c",
"in",
"iterable",
"%",
"}"
] | train | https://github.com/funkybob/knights-templater/blob/b15cdbaae7d824d02f7f03ca04599ae94bb759dd/knights/tags.py#L106-L168 |
funkybob/knights-templater | knights/tags.py | macro | def macro(parser, token):
'''
Works just like block, but does not render.
'''
name = token.strip()
parser.build_method(name, endnodes=['endmacro'])
return ast.Yield(value=ast.Str(s='')) | python | def macro(parser, token):
'''
Works just like block, but does not render.
'''
name = token.strip()
parser.build_method(name, endnodes=['endmacro'])
return ast.Yield(value=ast.Str(s='')) | [
"def",
"macro",
"(",
"parser",
",",
"token",
")",
":",
"name",
"=",
"token",
".",
"strip",
"(",
")",
"parser",
".",
"build_method",
"(",
"name",
",",
"endnodes",
"=",
"[",
"'endmacro'",
"]",
")",
"return",
"ast",
".",
"Yield",
"(",
"value",
"=",
"a... | Works just like block, but does not render. | [
"Works",
"just",
"like",
"block",
"but",
"does",
"not",
"render",
"."
] | train | https://github.com/funkybob/knights-templater/blob/b15cdbaae7d824d02f7f03ca04599ae94bb759dd/knights/tags.py#L215-L221 |
funkybob/knights-templater | knights/tags.py | use | def use(parser, token):
'''
Counterpart to `macro`, lets you render any block/macro in place.
'''
args, kwargs = parser.parse_args(token)
assert isinstance(args[0], ast.Str), \
'First argument to "include" tag must be a string'
name = args[0].s
action = ast.YieldFrom(
value... | python | def use(parser, token):
'''
Counterpart to `macro`, lets you render any block/macro in place.
'''
args, kwargs = parser.parse_args(token)
assert isinstance(args[0], ast.Str), \
'First argument to "include" tag must be a string'
name = args[0].s
action = ast.YieldFrom(
value... | [
"def",
"use",
"(",
"parser",
",",
"token",
")",
":",
"args",
",",
"kwargs",
"=",
"parser",
".",
"parse_args",
"(",
"token",
")",
"assert",
"isinstance",
"(",
"args",
"[",
"0",
"]",
",",
"ast",
".",
"Str",
")",
",",
"'First argument to \"include\" tag mus... | Counterpart to `macro`, lets you render any block/macro in place. | [
"Counterpart",
"to",
"macro",
"lets",
"you",
"render",
"any",
"block",
"/",
"macro",
"in",
"place",
"."
] | train | https://github.com/funkybob/knights-templater/blob/b15cdbaae7d824d02f7f03ca04599ae94bb759dd/knights/tags.py#L225-L245 |
cohorte/cohorte-herald | python/snippets/herald_mqtt/beans.py | Future.execute | def execute(self, method, args, kwargs):
"""
Execute the given method and stores its result.
The result is considered "done" even if the method raises an exception
:param method: The method to execute
:param args: Method positional arguments
:param kwargs: Method keyword... | python | def execute(self, method, args, kwargs):
"""
Execute the given method and stores its result.
The result is considered "done" even if the method raises an exception
:param method: The method to execute
:param args: Method positional arguments
:param kwargs: Method keyword... | [
"def",
"execute",
"(",
"self",
",",
"method",
",",
"args",
",",
"kwargs",
")",
":",
"# Normalize arguments",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"[",
"]",
"if",
"kwargs",
"is",
"None",
":",
"kwargs",
"=",
"{",
"}",
"try",
":",
"# Call the m... | Execute the given method and stores its result.
The result is considered "done" even if the method raises an exception
:param method: The method to execute
:param args: Method positional arguments
:param kwargs: Method keyword arguments
:raise Exception: The exception raised by ... | [
"Execute",
"the",
"given",
"method",
"and",
"stores",
"its",
"result",
".",
"The",
"result",
"is",
"considered",
"done",
"even",
"if",
"the",
"method",
"raises",
"an",
"exception"
] | train | https://github.com/cohorte/cohorte-herald/blob/bb3445d0031c8b3abad71e6219cc559b49faa3ee/python/snippets/herald_mqtt/beans.py#L37-L64 |
cohorte/cohorte-herald | python/snippets/herald_mqtt/beans.py | Future.result | def result(self, timeout=None):
"""
Waits up to timeout for the result the threaded job.
Returns immediately the result if the job has already been done.
:param timeout: The maximum time to wait for a result (in seconds)
:raise OSError: The timeout raised before the job finished... | python | def result(self, timeout=None):
"""
Waits up to timeout for the result the threaded job.
Returns immediately the result if the job has already been done.
:param timeout: The maximum time to wait for a result (in seconds)
:raise OSError: The timeout raised before the job finished... | [
"def",
"result",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"self",
".",
"_done_event",
".",
"wait",
"(",
"timeout",
")",
"or",
"self",
".",
"_done_event",
".",
"is_set",
"(",
")",
":",
"if",
"self",
".",
"_exception",
"is",
"not",
"... | Waits up to timeout for the result the threaded job.
Returns immediately the result if the job has already been done.
:param timeout: The maximum time to wait for a result (in seconds)
:raise OSError: The timeout raised before the job finished
:raise Exception: Raises the exception that... | [
"Waits",
"up",
"to",
"timeout",
"for",
"the",
"result",
"the",
"threaded",
"job",
".",
"Returns",
"immediately",
"the",
"result",
"if",
"the",
"job",
"has",
"already",
"been",
"done",
"."
] | train | https://github.com/cohorte/cohorte-herald/blob/bb3445d0031c8b3abad71e6219cc559b49faa3ee/python/snippets/herald_mqtt/beans.py#L74-L90 |
cohorte/cohorte-herald | python/snippets/herald_mqtt/beans.py | AbstractRouter.get_link | def get_link(self, peer):
"""
Retrieves a link to the peer
:param peer: A Peer description
:return: A link to the peer, None if none available
"""
assert isinstance(peer, Peer)
for protocol in self._protocols:
try:
# Try to get a link... | python | def get_link(self, peer):
"""
Retrieves a link to the peer
:param peer: A Peer description
:return: A link to the peer, None if none available
"""
assert isinstance(peer, Peer)
for protocol in self._protocols:
try:
# Try to get a link... | [
"def",
"get_link",
"(",
"self",
",",
"peer",
")",
":",
"assert",
"isinstance",
"(",
"peer",
",",
"Peer",
")",
"for",
"protocol",
"in",
"self",
".",
"_protocols",
":",
"try",
":",
"# Try to get a link",
"return",
"protocol",
".",
"get_link",
"(",
"peer",
... | Retrieves a link to the peer
:param peer: A Peer description
:return: A link to the peer, None if none available | [
"Retrieves",
"a",
"link",
"to",
"the",
"peer"
] | train | https://github.com/cohorte/cohorte-herald/blob/bb3445d0031c8b3abad71e6219cc559b49faa3ee/python/snippets/herald_mqtt/beans.py#L217-L236 |
cohorte/cohorte-herald | python/snippets/herald_mqtt/beans.py | AbstractLink.send | def send(self, message):
"""
Sends a message (synchronous)
:param message: Message to send
:return: Message response(s)
"""
future = self.post(message)
future.join()
return future.result | python | def send(self, message):
"""
Sends a message (synchronous)
:param message: Message to send
:return: Message response(s)
"""
future = self.post(message)
future.join()
return future.result | [
"def",
"send",
"(",
"self",
",",
"message",
")",
":",
"future",
"=",
"self",
".",
"post",
"(",
"message",
")",
"future",
".",
"join",
"(",
")",
"return",
"future",
".",
"result"
] | Sends a message (synchronous)
:param message: Message to send
:return: Message response(s) | [
"Sends",
"a",
"message",
"(",
"synchronous",
")"
] | train | https://github.com/cohorte/cohorte-herald/blob/bb3445d0031c8b3abad71e6219cc559b49faa3ee/python/snippets/herald_mqtt/beans.py#L260-L269 |
colecrtr/django-naguine | naguine/core/composedfunction.py | resolve_composed_functions | def resolve_composed_functions(data, recursive=True):
"""
Calls `ComposedFunction`s and returns its return value. By default, this
function will recursively iterate dicts, lists, tuples, and sets and
replace all `ComposedFunction`s with their return value.
"""
if isinstance(data, ComposedFuncti... | python | def resolve_composed_functions(data, recursive=True):
"""
Calls `ComposedFunction`s and returns its return value. By default, this
function will recursively iterate dicts, lists, tuples, and sets and
replace all `ComposedFunction`s with their return value.
"""
if isinstance(data, ComposedFuncti... | [
"def",
"resolve_composed_functions",
"(",
"data",
",",
"recursive",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"ComposedFunction",
")",
":",
"data",
"=",
"data",
"(",
")",
"if",
"recursive",
":",
"if",
"isinstance",
"(",
"data",
",",
"d... | Calls `ComposedFunction`s and returns its return value. By default, this
function will recursively iterate dicts, lists, tuples, and sets and
replace all `ComposedFunction`s with their return value. | [
"Calls",
"ComposedFunction",
"s",
"and",
"returns",
"its",
"return",
"value",
".",
"By",
"default",
"this",
"function",
"will",
"recursively",
"iterate",
"dicts",
"lists",
"tuples",
"and",
"sets",
"and",
"replace",
"all",
"ComposedFunction",
"s",
"with",
"their"... | train | https://github.com/colecrtr/django-naguine/blob/984da05dec15a4139788831e7fc060c2b7cb7fd3/naguine/core/composedfunction.py#L4-L28 |
openstack/stacktach-shoebox | shoebox/roll_manager.py | WritingRollManager.write | def write(self, metadata, payload):
"""Write metadata
metadata is string:string dict.
payload must be encoded as string.
"""
a = self.get_active_archive()
a.write(metadata, payload)
if self._should_roll_archive():
self._roll_archive() | python | def write(self, metadata, payload):
"""Write metadata
metadata is string:string dict.
payload must be encoded as string.
"""
a = self.get_active_archive()
a.write(metadata, payload)
if self._should_roll_archive():
self._roll_archive() | [
"def",
"write",
"(",
"self",
",",
"metadata",
",",
"payload",
")",
":",
"a",
"=",
"self",
".",
"get_active_archive",
"(",
")",
"a",
".",
"write",
"(",
"metadata",
",",
"payload",
")",
"if",
"self",
".",
"_should_roll_archive",
"(",
")",
":",
"self",
... | Write metadata
metadata is string:string dict.
payload must be encoded as string. | [
"Write",
"metadata"
] | train | https://github.com/openstack/stacktach-shoebox/blob/792b0fb25dee4eb1a18f841f2b3a2b9d01472627/shoebox/roll_manager.py#L116-L125 |
duniter/duniter-python-api | examples/request_data.py | main | async def main():
"""
Main code (synchronous requests)
"""
# Create Client from endpoint string in Duniter format
client = Client(BMAS_ENDPOINT)
# Get the node summary infos by dedicated method (with json schema validation)
print("\nCall bma.node.summary:")
response = await client(bma.n... | python | async def main():
"""
Main code (synchronous requests)
"""
# Create Client from endpoint string in Duniter format
client = Client(BMAS_ENDPOINT)
# Get the node summary infos by dedicated method (with json schema validation)
print("\nCall bma.node.summary:")
response = await client(bma.n... | [
"async",
"def",
"main",
"(",
")",
":",
"# Create Client from endpoint string in Duniter format",
"client",
"=",
"Client",
"(",
"BMAS_ENDPOINT",
")",
"# Get the node summary infos by dedicated method (with json schema validation)",
"print",
"(",
"\"\\nCall bma.node.summary:\"",
")",... | Main code (synchronous requests) | [
"Main",
"code",
"(",
"synchronous",
"requests",
")"
] | train | https://github.com/duniter/duniter-python-api/blob/3a1e5d61a2f72f5afaf29d010c6cf4dff3648165/examples/request_data.py#L16-L72 |
bradrf/configstruct | configstruct/section_struct.py | SectionStruct.might_prefer | def might_prefer(self, **items):
'''Items to take precedence if their values are not None (never saved)'''
self._overrides = dict((k, v) for (k, v) in items.items() if v is not None) | python | def might_prefer(self, **items):
'''Items to take precedence if their values are not None (never saved)'''
self._overrides = dict((k, v) for (k, v) in items.items() if v is not None) | [
"def",
"might_prefer",
"(",
"self",
",",
"*",
"*",
"items",
")",
":",
"self",
".",
"_overrides",
"=",
"dict",
"(",
"(",
"k",
",",
"v",
")",
"for",
"(",
"k",
",",
"v",
")",
"in",
"items",
".",
"items",
"(",
")",
"if",
"v",
"is",
"not",
"None",... | Items to take precedence if their values are not None (never saved) | [
"Items",
"to",
"take",
"precedence",
"if",
"their",
"values",
"are",
"not",
"None",
"(",
"never",
"saved",
")"
] | train | https://github.com/bradrf/configstruct/blob/aeea8fbba1e2daa0a0c38eeb9622d1716c0bb3e8/configstruct/section_struct.py#L13-L15 |
bradrf/configstruct | configstruct/section_struct.py | SectionStruct.sync_with | def sync_with(self, config, conflict_resolver):
'''Synchronizes current set of key/values in this instance with those in the config.'''
if not config.has_section(self._name):
config.add_section(self._name)
resolved = self._sync_and_resolve(config, conflict_resolver)
self._add... | python | def sync_with(self, config, conflict_resolver):
'''Synchronizes current set of key/values in this instance with those in the config.'''
if not config.has_section(self._name):
config.add_section(self._name)
resolved = self._sync_and_resolve(config, conflict_resolver)
self._add... | [
"def",
"sync_with",
"(",
"self",
",",
"config",
",",
"conflict_resolver",
")",
":",
"if",
"not",
"config",
".",
"has_section",
"(",
"self",
".",
"_name",
")",
":",
"config",
".",
"add_section",
"(",
"self",
".",
"_name",
")",
"resolved",
"=",
"self",
"... | Synchronizes current set of key/values in this instance with those in the config. | [
"Synchronizes",
"current",
"set",
"of",
"key",
"/",
"values",
"in",
"this",
"instance",
"with",
"those",
"in",
"the",
"config",
"."
] | train | https://github.com/bradrf/configstruct/blob/aeea8fbba1e2daa0a0c38eeb9622d1716c0bb3e8/configstruct/section_struct.py#L17-L22 |
bradrf/configstruct | configstruct/section_struct.py | SectionStruct._sync_and_resolve | def _sync_and_resolve(self, config, resolver):
'''Synchronize all items represented by the config according to the resolver and return a
set of keys that have been resolved.'''
resolved = set()
for key, theirs in config.items(self._name):
theirs = self._real_value_of(theirs)
... | python | def _sync_and_resolve(self, config, resolver):
'''Synchronize all items represented by the config according to the resolver and return a
set of keys that have been resolved.'''
resolved = set()
for key, theirs in config.items(self._name):
theirs = self._real_value_of(theirs)
... | [
"def",
"_sync_and_resolve",
"(",
"self",
",",
"config",
",",
"resolver",
")",
":",
"resolved",
"=",
"set",
"(",
")",
"for",
"key",
",",
"theirs",
"in",
"config",
".",
"items",
"(",
"self",
".",
"_name",
")",
":",
"theirs",
"=",
"self",
".",
"_real_va... | Synchronize all items represented by the config according to the resolver and return a
set of keys that have been resolved. | [
"Synchronize",
"all",
"items",
"represented",
"by",
"the",
"config",
"according",
"to",
"the",
"resolver",
"and",
"return",
"a",
"set",
"of",
"keys",
"that",
"have",
"been",
"resolved",
"."
] | train | https://github.com/bradrf/configstruct/blob/aeea8fbba1e2daa0a0c38eeb9622d1716c0bb3e8/configstruct/section_struct.py#L27-L40 |
bradrf/configstruct | configstruct/section_struct.py | SectionStruct._add_new_items | def _add_new_items(self, config, seen):
'''Add new (unseen) items to the config.'''
for (key, value) in self.items():
if key not in seen:
self._set_value(config, key, value) | python | def _add_new_items(self, config, seen):
'''Add new (unseen) items to the config.'''
for (key, value) in self.items():
if key not in seen:
self._set_value(config, key, value) | [
"def",
"_add_new_items",
"(",
"self",
",",
"config",
",",
"seen",
")",
":",
"for",
"(",
"key",
",",
"value",
")",
"in",
"self",
".",
"items",
"(",
")",
":",
"if",
"key",
"not",
"in",
"seen",
":",
"self",
".",
"_set_value",
"(",
"config",
",",
"ke... | Add new (unseen) items to the config. | [
"Add",
"new",
"(",
"unseen",
")",
"items",
"to",
"the",
"config",
"."
] | train | https://github.com/bradrf/configstruct/blob/aeea8fbba1e2daa0a0c38eeb9622d1716c0bb3e8/configstruct/section_struct.py#L42-L46 |
calve/prof | prof/work.py | Work.upload | def upload(self, baseurl, filename):
"""Upload filename to this work"""
# Prof is really dirty, we need to re-get the project page before upload
payload = {
'id_projet': self.field
}
prof_session.post(baseurl+"/main.php", params=payload)
# We also need to get ... | python | def upload(self, baseurl, filename):
"""Upload filename to this work"""
# Prof is really dirty, we need to re-get the project page before upload
payload = {
'id_projet': self.field
}
prof_session.post(baseurl+"/main.php", params=payload)
# We also need to get ... | [
"def",
"upload",
"(",
"self",
",",
"baseurl",
",",
"filename",
")",
":",
"# Prof is really dirty, we need to re-get the project page before upload",
"payload",
"=",
"{",
"'id_projet'",
":",
"self",
".",
"field",
"}",
"prof_session",
".",
"post",
"(",
"baseurl",
"+",... | Upload filename to this work | [
"Upload",
"filename",
"to",
"this",
"work"
] | train | https://github.com/calve/prof/blob/c6e034f45ab60908dea661e8271bc44758aeedcf/prof/work.py#L35-L51 |
ohenrik/tabs | tabs/tabs.py | get_all_classes | def get_all_classes(module_name):
"""Load all non-abstract classes from package"""
module = importlib.import_module(module_name)
return getmembers(module, lambda m: isclass(m) and not isabstract(m)) | python | def get_all_classes(module_name):
"""Load all non-abstract classes from package"""
module = importlib.import_module(module_name)
return getmembers(module, lambda m: isclass(m) and not isabstract(m)) | [
"def",
"get_all_classes",
"(",
"module_name",
")",
":",
"module",
"=",
"importlib",
".",
"import_module",
"(",
"module_name",
")",
"return",
"getmembers",
"(",
"module",
",",
"lambda",
"m",
":",
"isclass",
"(",
"m",
")",
"and",
"not",
"isabstract",
"(",
"m... | Load all non-abstract classes from package | [
"Load",
"all",
"non",
"-",
"abstract",
"classes",
"from",
"package"
] | train | https://github.com/ohenrik/tabs/blob/039ced6c5612ecdd551aeaac63789862aba05711/tabs/tabs.py#L12-L15 |
ohenrik/tabs | tabs/tabs.py | Tabs.get | def get(self, table_name):
"""Load table class by name, class not yet initialized"""
assert table_name in self.tabs, \
"Table not avaiable. Avaiable tables: {}".format(
", ".join(self.tabs.keys())
)
return self.tabs[table_name] | python | def get(self, table_name):
"""Load table class by name, class not yet initialized"""
assert table_name in self.tabs, \
"Table not avaiable. Avaiable tables: {}".format(
", ".join(self.tabs.keys())
)
return self.tabs[table_name] | [
"def",
"get",
"(",
"self",
",",
"table_name",
")",
":",
"assert",
"table_name",
"in",
"self",
".",
"tabs",
",",
"\"Table not avaiable. Avaiable tables: {}\"",
".",
"format",
"(",
"\", \"",
".",
"join",
"(",
"self",
".",
"tabs",
".",
"keys",
"(",
")",
")",
... | Load table class by name, class not yet initialized | [
"Load",
"table",
"class",
"by",
"name",
"class",
"not",
"yet",
"initialized"
] | train | https://github.com/ohenrik/tabs/blob/039ced6c5612ecdd551aeaac63789862aba05711/tabs/tabs.py#L70-L76 |
ohenrik/tabs | tabs/tabs.py | Tabs._update_sys_path | def _update_sys_path(self, package_path=None):
"""Updates and adds current directory to sys path"""
self.package_path = package_path
if not self.package_path in sys.path:
sys.path.append(self.package_path) | python | def _update_sys_path(self, package_path=None):
"""Updates and adds current directory to sys path"""
self.package_path = package_path
if not self.package_path in sys.path:
sys.path.append(self.package_path) | [
"def",
"_update_sys_path",
"(",
"self",
",",
"package_path",
"=",
"None",
")",
":",
"self",
".",
"package_path",
"=",
"package_path",
"if",
"not",
"self",
".",
"package_path",
"in",
"sys",
".",
"path",
":",
"sys",
".",
"path",
".",
"append",
"(",
"self",... | Updates and adds current directory to sys path | [
"Updates",
"and",
"adds",
"current",
"directory",
"to",
"sys",
"path"
] | train | https://github.com/ohenrik/tabs/blob/039ced6c5612ecdd551aeaac63789862aba05711/tabs/tabs.py#L78-L82 |
ohenrik/tabs | tabs/tabs.py | Tabs.find_tabs | def find_tabs(self, custom_table_classes=None):
"""Finds all classes that are subcalss of Table and loads them into
a dictionary named tables."""
for module_name in get_all_modules(self.package_path):
for name, _type in get_all_classes(module_name):
# pylint: disable... | python | def find_tabs(self, custom_table_classes=None):
"""Finds all classes that are subcalss of Table and loads them into
a dictionary named tables."""
for module_name in get_all_modules(self.package_path):
for name, _type in get_all_classes(module_name):
# pylint: disable... | [
"def",
"find_tabs",
"(",
"self",
",",
"custom_table_classes",
"=",
"None",
")",
":",
"for",
"module_name",
"in",
"get_all_modules",
"(",
"self",
".",
"package_path",
")",
":",
"for",
"name",
",",
"_type",
"in",
"get_all_classes",
"(",
"module_name",
")",
":"... | Finds all classes that are subcalss of Table and loads them into
a dictionary named tables. | [
"Finds",
"all",
"classes",
"that",
"are",
"subcalss",
"of",
"Table",
"and",
"loads",
"them",
"into",
"a",
"dictionary",
"named",
"tables",
"."
] | train | https://github.com/ohenrik/tabs/blob/039ced6c5612ecdd551aeaac63789862aba05711/tabs/tabs.py#L89-L98 |
ohenrik/tabs | tabs/tabs.py | Tabs.describe_all | def describe_all(self, full=False):
"""Prints description information about all tables registered
Args:
full (bool): Also prints description of post processors.
"""
for table in self.tabs:
yield self.tabs[table]().describe(full) | python | def describe_all(self, full=False):
"""Prints description information about all tables registered
Args:
full (bool): Also prints description of post processors.
"""
for table in self.tabs:
yield self.tabs[table]().describe(full) | [
"def",
"describe_all",
"(",
"self",
",",
"full",
"=",
"False",
")",
":",
"for",
"table",
"in",
"self",
".",
"tabs",
":",
"yield",
"self",
".",
"tabs",
"[",
"table",
"]",
"(",
")",
".",
"describe",
"(",
"full",
")"
] | Prints description information about all tables registered
Args:
full (bool): Also prints description of post processors. | [
"Prints",
"description",
"information",
"about",
"all",
"tables",
"registered",
"Args",
":",
"full",
"(",
"bool",
")",
":",
"Also",
"prints",
"description",
"of",
"post",
"processors",
"."
] | train | https://github.com/ohenrik/tabs/blob/039ced6c5612ecdd551aeaac63789862aba05711/tabs/tabs.py#L100-L106 |
merry-bits/DBQuery | src/dbquery/sqlite.py | SQLiteDB._connect | def _connect(self):
"""Try to create a connection to the database if not yet connected.
"""
if self._connection is not None:
raise RuntimeError('Close connection first.')
self._connection = connect(self._database, **self._kwds)
self._connection.isolation_level = None | python | def _connect(self):
"""Try to create a connection to the database if not yet connected.
"""
if self._connection is not None:
raise RuntimeError('Close connection first.')
self._connection = connect(self._database, **self._kwds)
self._connection.isolation_level = None | [
"def",
"_connect",
"(",
"self",
")",
":",
"if",
"self",
".",
"_connection",
"is",
"not",
"None",
":",
"raise",
"RuntimeError",
"(",
"'Close connection first.'",
")",
"self",
".",
"_connection",
"=",
"connect",
"(",
"self",
".",
"_database",
",",
"*",
"*",
... | Try to create a connection to the database if not yet connected. | [
"Try",
"to",
"create",
"a",
"connection",
"to",
"the",
"database",
"if",
"not",
"yet",
"connected",
"."
] | train | https://github.com/merry-bits/DBQuery/blob/5f46dc94e2721129f8a799b5f613373e6cd9cb73/src/dbquery/sqlite.py#L27-L33 |
onyxfish/clan | clan/diff.py | DiffCommand.add_argparser | def add_argparser(self, root, parents):
"""
Add arguments for this command.
"""
parser = root.add_parser('diff', parents=parents)
parser.set_defaults(func=self)
parser.add_argument(
'--secrets',
dest='secrets', action='store',
help='Pa... | python | def add_argparser(self, root, parents):
"""
Add arguments for this command.
"""
parser = root.add_parser('diff', parents=parents)
parser.set_defaults(func=self)
parser.add_argument(
'--secrets',
dest='secrets', action='store',
help='Pa... | [
"def",
"add_argparser",
"(",
"self",
",",
"root",
",",
"parents",
")",
":",
"parser",
"=",
"root",
".",
"add_parser",
"(",
"'diff'",
",",
"parents",
"=",
"parents",
")",
"parser",
".",
"set_defaults",
"(",
"func",
"=",
"self",
")",
"parser",
".",
"add_... | Add arguments for this command. | [
"Add",
"arguments",
"for",
"this",
"command",
"."
] | train | https://github.com/onyxfish/clan/blob/415ddd027ea81013f2d62d75aec6da70703df49c/clan/diff.py#L41-L78 |
onyxfish/clan | clan/diff.py | DiffCommand.diff | def diff(self, report_a, report_b):
"""
Generate a diff for two data reports.
"""
arguments = GLOBAL_ARGUMENTS + ['run_date']
output = OrderedDict([
('a', OrderedDict([(arg, report_a[arg]) for arg in arguments])),
('b', OrderedDict([(arg, report_b[arg]) f... | python | def diff(self, report_a, report_b):
"""
Generate a diff for two data reports.
"""
arguments = GLOBAL_ARGUMENTS + ['run_date']
output = OrderedDict([
('a', OrderedDict([(arg, report_a[arg]) for arg in arguments])),
('b', OrderedDict([(arg, report_b[arg]) f... | [
"def",
"diff",
"(",
"self",
",",
"report_a",
",",
"report_b",
")",
":",
"arguments",
"=",
"GLOBAL_ARGUMENTS",
"+",
"[",
"'run_date'",
"]",
"output",
"=",
"OrderedDict",
"(",
"[",
"(",
"'a'",
",",
"OrderedDict",
"(",
"[",
"(",
"arg",
",",
"report_a",
"[... | Generate a diff for two data reports. | [
"Generate",
"a",
"diff",
"for",
"two",
"data",
"reports",
"."
] | train | https://github.com/onyxfish/clan/blob/415ddd027ea81013f2d62d75aec6da70703df49c/clan/diff.py#L80-L140 |
onyxfish/clan | clan/diff.py | DiffCommand.txt | def txt(self, diff, f):
"""
Generate a text report for a diff.
"""
env = Environment(
loader=PackageLoader('clan', 'templates'),
trim_blocks=True,
lstrip_blocks=True
)
template = env.get_template('diff.txt')
def format_row(lab... | python | def txt(self, diff, f):
"""
Generate a text report for a diff.
"""
env = Environment(
loader=PackageLoader('clan', 'templates'),
trim_blocks=True,
lstrip_blocks=True
)
template = env.get_template('diff.txt')
def format_row(lab... | [
"def",
"txt",
"(",
"self",
",",
"diff",
",",
"f",
")",
":",
"env",
"=",
"Environment",
"(",
"loader",
"=",
"PackageLoader",
"(",
"'clan'",
",",
"'templates'",
")",
",",
"trim_blocks",
"=",
"True",
",",
"lstrip_blocks",
"=",
"True",
")",
"template",
"="... | Generate a text report for a diff. | [
"Generate",
"a",
"text",
"report",
"for",
"a",
"diff",
"."
] | train | https://github.com/onyxfish/clan/blob/415ddd027ea81013f2d62d75aec6da70703df49c/clan/diff.py#L142-L180 |
onyxfish/clan | clan/diff.py | DiffCommand.html | def html(self, diff, f):
"""
Generate a text report for a diff.
"""
env = Environment(loader=PackageLoader('clan', 'templates'))
template = env.get_template('diff.html')
def number_class(v):
if v is None:
return ''
if v > 0:
... | python | def html(self, diff, f):
"""
Generate a text report for a diff.
"""
env = Environment(loader=PackageLoader('clan', 'templates'))
template = env.get_template('diff.html')
def number_class(v):
if v is None:
return ''
if v > 0:
... | [
"def",
"html",
"(",
"self",
",",
"diff",
",",
"f",
")",
":",
"env",
"=",
"Environment",
"(",
"loader",
"=",
"PackageLoader",
"(",
"'clan'",
",",
"'templates'",
")",
")",
"template",
"=",
"env",
".",
"get_template",
"(",
"'diff.html'",
")",
"def",
"numb... | Generate a text report for a diff. | [
"Generate",
"a",
"text",
"report",
"for",
"a",
"diff",
"."
] | train | https://github.com/onyxfish/clan/blob/415ddd027ea81013f2d62d75aec6da70703df49c/clan/diff.py#L182-L210 |
django-fluent/fluentcms-emailtemplates | fluentcms_emailtemplates/extensions.py | EmailContentPlugin.render_html | def render_html(self, request, instance, context):
"""
Custom rendering function for HTML output
"""
render_template = self.get_render_template(request, instance, email_format='html')
if not render_template:
return str(u"{No HTML rendering defined for class '%s'}" % s... | python | def render_html(self, request, instance, context):
"""
Custom rendering function for HTML output
"""
render_template = self.get_render_template(request, instance, email_format='html')
if not render_template:
return str(u"{No HTML rendering defined for class '%s'}" % s... | [
"def",
"render_html",
"(",
"self",
",",
"request",
",",
"instance",
",",
"context",
")",
":",
"render_template",
"=",
"self",
".",
"get_render_template",
"(",
"request",
",",
"instance",
",",
"email_format",
"=",
"'html'",
")",
"if",
"not",
"render_template",
... | Custom rendering function for HTML output | [
"Custom",
"rendering",
"function",
"for",
"HTML",
"output"
] | train | https://github.com/django-fluent/fluentcms-emailtemplates/blob/29f032dab9f60d05db852d2a1adcbd16e18017d1/fluentcms_emailtemplates/extensions.py#L71-L85 |
django-fluent/fluentcms-emailtemplates | fluentcms_emailtemplates/extensions.py | EmailContentPlugin.render_text | def render_text(self, request, instance, context):
"""
Custom rendering function for HTML output
"""
render_template = self.get_render_template(request, instance, email_format='text')
if not render_template:
# If there is no TEXT variation, create it by removing the H... | python | def render_text(self, request, instance, context):
"""
Custom rendering function for HTML output
"""
render_template = self.get_render_template(request, instance, email_format='text')
if not render_template:
# If there is no TEXT variation, create it by removing the H... | [
"def",
"render_text",
"(",
"self",
",",
"request",
",",
"instance",
",",
"context",
")",
":",
"render_template",
"=",
"self",
".",
"get_render_template",
"(",
"request",
",",
"instance",
",",
"email_format",
"=",
"'text'",
")",
"if",
"not",
"render_template",
... | Custom rendering function for HTML output | [
"Custom",
"rendering",
"function",
"for",
"HTML",
"output"
] | train | https://github.com/django-fluent/fluentcms-emailtemplates/blob/29f032dab9f60d05db852d2a1adcbd16e18017d1/fluentcms_emailtemplates/extensions.py#L87-L105 |
commonwealth-of-puerto-rico/libre | libre/apps/origins/models.py | Origin.copy_data | def copy_data(self):
"""
Copy the data from the it's point of origin, serializing it,
storing it serialized as well as in it's raw form and calculate
a running hash of the serialized representation
"""
HASH_FUNCTION = hashlib.sha256()
try:
raw_iterato... | python | def copy_data(self):
"""
Copy the data from the it's point of origin, serializing it,
storing it serialized as well as in it's raw form and calculate
a running hash of the serialized representation
"""
HASH_FUNCTION = hashlib.sha256()
try:
raw_iterato... | [
"def",
"copy_data",
"(",
"self",
")",
":",
"HASH_FUNCTION",
"=",
"hashlib",
".",
"sha256",
"(",
")",
"try",
":",
"raw_iterator",
"=",
"self",
".",
"get_binary_iterator",
"(",
")",
"except",
"AttributeError",
":",
"raw_iterator",
"=",
"self",
".",
"get_non_bi... | Copy the data from the it's point of origin, serializing it,
storing it serialized as well as in it's raw form and calculate
a running hash of the serialized representation | [
"Copy",
"the",
"data",
"from",
"the",
"it",
"s",
"point",
"of",
"origin",
"serializing",
"it",
"storing",
"it",
"serialized",
"as",
"well",
"as",
"in",
"it",
"s",
"raw",
"form",
"and",
"calculate",
"a",
"running",
"hash",
"of",
"the",
"serialized",
"repr... | train | https://github.com/commonwealth-of-puerto-rico/libre/blob/5b32f4ab068b515d2ea652b182e161271ba874e8/libre/apps/origins/models.py#L43-L76 |
commonwealth-of-puerto-rico/libre | libre/apps/origins/models.py | OriginURL.get_binary_iterator | def get_binary_iterator(self):
"""
Generator to stream the remote file piece by piece.
"""
CHUNK_SIZE = 1024
return (item for item in requests.get(self.url).iter_content(CHUNK_SIZE)) | python | def get_binary_iterator(self):
"""
Generator to stream the remote file piece by piece.
"""
CHUNK_SIZE = 1024
return (item for item in requests.get(self.url).iter_content(CHUNK_SIZE)) | [
"def",
"get_binary_iterator",
"(",
"self",
")",
":",
"CHUNK_SIZE",
"=",
"1024",
"return",
"(",
"item",
"for",
"item",
"in",
"requests",
".",
"get",
"(",
"self",
".",
"url",
")",
".",
"iter_content",
"(",
"CHUNK_SIZE",
")",
")"
] | Generator to stream the remote file piece by piece. | [
"Generator",
"to",
"stream",
"the",
"remote",
"file",
"piece",
"by",
"piece",
"."
] | train | https://github.com/commonwealth-of-puerto-rico/libre/blob/5b32f4ab068b515d2ea652b182e161271ba874e8/libre/apps/origins/models.py#L105-L110 |
commonwealth-of-puerto-rico/libre | libre/apps/origins/models.py | OriginPath.get_binary_iterator | def get_binary_iterator(self):
"""
Generator to read a file piece by piece.
"""
CHUNK_SIZE = 1024
file_object = open(self.path)
while True:
data = file_object.read(CHUNK_SIZE)
if not data:
break
yield data
file... | python | def get_binary_iterator(self):
"""
Generator to read a file piece by piece.
"""
CHUNK_SIZE = 1024
file_object = open(self.path)
while True:
data = file_object.read(CHUNK_SIZE)
if not data:
break
yield data
file... | [
"def",
"get_binary_iterator",
"(",
"self",
")",
":",
"CHUNK_SIZE",
"=",
"1024",
"file_object",
"=",
"open",
"(",
"self",
".",
"path",
")",
"while",
"True",
":",
"data",
"=",
"file_object",
".",
"read",
"(",
"CHUNK_SIZE",
")",
"if",
"not",
"data",
":",
... | Generator to read a file piece by piece. | [
"Generator",
"to",
"read",
"a",
"file",
"piece",
"by",
"piece",
"."
] | train | https://github.com/commonwealth-of-puerto-rico/libre/blob/5b32f4ab068b515d2ea652b182e161271ba874e8/libre/apps/origins/models.py#L135-L148 |
jeremyschulman/halutz | halutz/request_factory.py | RequestFactory.command_request | def command_request(self, method, path):
"""
Returns a callable request for a given http method and API path.
You can then use this request to execute the command, and get
the response value:
>>> rqst = client.command_request('get', '/api/hcl')
>>> resp, ok = rqs... | python | def command_request(self, method, path):
"""
Returns a callable request for a given http method and API path.
You can then use this request to execute the command, and get
the response value:
>>> rqst = client.command_request('get', '/api/hcl')
>>> resp, ok = rqs... | [
"def",
"command_request",
"(",
"self",
",",
"method",
",",
"path",
")",
":",
"op",
"=",
"self",
".",
"client",
".",
"swagger_spec",
".",
"get_op_for_request",
"(",
"method",
",",
"path",
")",
"if",
"not",
"op",
":",
"raise",
"RuntimeError",
"(",
"'no com... | Returns a callable request for a given http method and API path.
You can then use this request to execute the command, and get
the response value:
>>> rqst = client.command_request('get', '/api/hcl')
>>> resp, ok = rqst()
Parameters
----------
method : s... | [
"Returns",
"a",
"callable",
"request",
"for",
"a",
"given",
"http",
"method",
"and",
"API",
"path",
".",
"You",
"can",
"then",
"use",
"this",
"request",
"to",
"execute",
"the",
"command",
"and",
"get",
"the",
"response",
"value",
":"
] | train | https://github.com/jeremyschulman/halutz/blob/6bb398dc99bf723daabd9eda02494a11252ee109/halutz/request_factory.py#L47-L75 |
jeremyschulman/halutz | halutz/request_factory.py | RequestFactory.path_requests | def path_requests(self, path):
"""
Returns a Resource instace that will have attributes, one for each of the http-methods
supported on that path. For example:
>>> hcl_api = client.path_requests('/api/hcl/{id}')
>>> dir(hcl_api)
[u'delete', u'get', u'put']
... | python | def path_requests(self, path):
"""
Returns a Resource instace that will have attributes, one for each of the http-methods
supported on that path. For example:
>>> hcl_api = client.path_requests('/api/hcl/{id}')
>>> dir(hcl_api)
[u'delete', u'get', u'put']
... | [
"def",
"path_requests",
"(",
"self",
",",
"path",
")",
":",
"path_spec",
"=",
"self",
".",
"client",
".",
"origin_spec",
"[",
"'paths'",
"]",
".",
"get",
"(",
"path",
")",
"if",
"not",
"path_spec",
":",
"raise",
"RuntimeError",
"(",
"\"no path found for: %... | Returns a Resource instace that will have attributes, one for each of the http-methods
supported on that path. For example:
>>> hcl_api = client.path_requests('/api/hcl/{id}')
>>> dir(hcl_api)
[u'delete', u'get', u'put']
>>> resp, ok = hcl_api.get(id='Arista_vE... | [
"Returns",
"a",
"Resource",
"instace",
"that",
"will",
"have",
"attributes",
"one",
"for",
"each",
"of",
"the",
"http",
"-",
"methods",
"supported",
"on",
"that",
"path",
".",
"For",
"example",
":"
] | train | https://github.com/jeremyschulman/halutz/blob/6bb398dc99bf723daabd9eda02494a11252ee109/halutz/request_factory.py#L77-L107 |
ff0000/scarlet | scarlet/cms/internal_tags/fields.py | TaggedRelationWidget.get_add_link | def get_add_link(self):
"""
Appends the popup=1 query string to the url so the
destination url treats it as a popup.
"""
url = super(TaggedRelationWidget, self).get_add_link()
if url:
qs = self.get_add_qs()
if qs:
url = "%s&%s" % (... | python | def get_add_link(self):
"""
Appends the popup=1 query string to the url so the
destination url treats it as a popup.
"""
url = super(TaggedRelationWidget, self).get_add_link()
if url:
qs = self.get_add_qs()
if qs:
url = "%s&%s" % (... | [
"def",
"get_add_link",
"(",
"self",
")",
":",
"url",
"=",
"super",
"(",
"TaggedRelationWidget",
",",
"self",
")",
".",
"get_add_link",
"(",
")",
"if",
"url",
":",
"qs",
"=",
"self",
".",
"get_add_qs",
"(",
")",
"if",
"qs",
":",
"url",
"=",
"\"%s&%s\"... | Appends the popup=1 query string to the url so the
destination url treats it as a popup. | [
"Appends",
"the",
"popup",
"=",
"1",
"query",
"string",
"to",
"the",
"url",
"so",
"the",
"destination",
"url",
"treats",
"it",
"as",
"a",
"popup",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/internal_tags/fields.py#L41-L52 |
ff0000/scarlet | scarlet/cms/templatetags/cms.py | render_view | def render_view(parser, token):
"""
Return an string version of a View with as_string method.
First argument is the name of the view. Any other arguments
should be keyword arguments and will be passed to the view.
Example:
{% render_view viewname var1=xx var2=yy %}
"""
bits = token.spl... | python | def render_view(parser, token):
"""
Return an string version of a View with as_string method.
First argument is the name of the view. Any other arguments
should be keyword arguments and will be passed to the view.
Example:
{% render_view viewname var1=xx var2=yy %}
"""
bits = token.spl... | [
"def",
"render_view",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"n",
"=",
"len",
"(",
"bits",
")",
"if",
"n",
"<",
"2",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes at least one view as argument\... | Return an string version of a View with as_string method.
First argument is the name of the view. Any other arguments
should be keyword arguments and will be passed to the view.
Example:
{% render_view viewname var1=xx var2=yy %} | [
"Return",
"an",
"string",
"version",
"of",
"a",
"View",
"with",
"as_string",
"method",
".",
"First",
"argument",
"is",
"the",
"name",
"of",
"the",
"view",
".",
"Any",
"other",
"arguments",
"should",
"be",
"keyword",
"arguments",
"and",
"will",
"be",
"passe... | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/templatetags/cms.py#L104-L132 |
ff0000/scarlet | scarlet/cms/templatetags/cms.py | bundle_view | def bundle_view(parser, token):
"""
Returns an string version of a bundle view. This is done by
calling the `get_string_from_view` method of the provided bundle.
This tag expects that the request object as well as the
the original url_params are available in the context.
Requires two arguments... | python | def bundle_view(parser, token):
"""
Returns an string version of a bundle view. This is done by
calling the `get_string_from_view` method of the provided bundle.
This tag expects that the request object as well as the
the original url_params are available in the context.
Requires two arguments... | [
"def",
"bundle_view",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
"<",
"3",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes at least two arguments\"",
"\" bundle and view_na... | Returns an string version of a bundle view. This is done by
calling the `get_string_from_view` method of the provided bundle.
This tag expects that the request object as well as the
the original url_params are available in the context.
Requires two arguments bundle and the name of the view
you wan... | [
"Returns",
"an",
"string",
"version",
"of",
"a",
"bundle",
"view",
".",
"This",
"is",
"done",
"by",
"calling",
"the",
"get_string_from_view",
"method",
"of",
"the",
"provided",
"bundle",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/templatetags/cms.py#L136-L167 |
ff0000/scarlet | scarlet/cms/templatetags/cms.py | bundle_url | def bundle_url(parser, token):
"""
Returns an a url for given a bundle and a view name.
This is done by calling the `get_view_url` method
of the provided bundle.
This tag expects that the request object as well as the
the original url_params are available in the context.
Requires two argum... | python | def bundle_url(parser, token):
"""
Returns an a url for given a bundle and a view name.
This is done by calling the `get_view_url` method
of the provided bundle.
This tag expects that the request object as well as the
the original url_params are available in the context.
Requires two argum... | [
"def",
"bundle_url",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
"<",
"3",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes at least two arguments\"",
"\" bundle and view_nam... | Returns an a url for given a bundle and a view name.
This is done by calling the `get_view_url` method
of the provided bundle.
This tag expects that the request object as well as the
the original url_params are available in the context.
Requires two arguments bundle and the name of the view
yo... | [
"Returns",
"an",
"a",
"url",
"for",
"given",
"a",
"bundle",
"and",
"a",
"view",
"name",
".",
"This",
"is",
"done",
"by",
"calling",
"the",
"get_view_url",
"method",
"of",
"the",
"provided",
"bundle",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/templatetags/cms.py#L171-L220 |
ff0000/scarlet | scarlet/cms/templatetags/cms.py | user_url | def user_url(user, bundle):
"""
Filter for a user object. Checks if a user has
permission to change other users.
"""
if not user:
return False
bundle = bundle.admin_site.get_bundle_for_model(User)
edit = None
if bundle:
edit = bundle.get_view_url('main', user)
retur... | python | def user_url(user, bundle):
"""
Filter for a user object. Checks if a user has
permission to change other users.
"""
if not user:
return False
bundle = bundle.admin_site.get_bundle_for_model(User)
edit = None
if bundle:
edit = bundle.get_view_url('main', user)
retur... | [
"def",
"user_url",
"(",
"user",
",",
"bundle",
")",
":",
"if",
"not",
"user",
":",
"return",
"False",
"bundle",
"=",
"bundle",
".",
"admin_site",
".",
"get_bundle_for_model",
"(",
"User",
")",
"edit",
"=",
"None",
"if",
"bundle",
":",
"edit",
"=",
"bun... | Filter for a user object. Checks if a user has
permission to change other users. | [
"Filter",
"for",
"a",
"user",
"object",
".",
"Checks",
"if",
"a",
"user",
"has",
"permission",
"to",
"change",
"other",
"users",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/templatetags/cms.py#L224-L237 |
klahnakoski/pyLibrary | jx_python/group_by.py | groupby | def groupby(data, keys=None, size=None, min_size=None, max_size=None, contiguous=False):
"""
:param data:
:param keys:
:param size:
:param min_size:
:param max_size:
:param contiguous: MAINTAIN THE ORDER OF THE DATA, STARTING THE NEW GROUP WHEN THE SELECTOR CHANGES
:return: return list o... | python | def groupby(data, keys=None, size=None, min_size=None, max_size=None, contiguous=False):
"""
:param data:
:param keys:
:param size:
:param min_size:
:param max_size:
:param contiguous: MAINTAIN THE ORDER OF THE DATA, STARTING THE NEW GROUP WHEN THE SELECTOR CHANGES
:return: return list o... | [
"def",
"groupby",
"(",
"data",
",",
"keys",
"=",
"None",
",",
"size",
"=",
"None",
",",
"min_size",
"=",
"None",
",",
"max_size",
"=",
"None",
",",
"contiguous",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"Container",
")",
":",
"... | :param data:
:param keys:
:param size:
:param min_size:
:param max_size:
:param contiguous: MAINTAIN THE ORDER OF THE DATA, STARTING THE NEW GROUP WHEN THE SELECTOR CHANGES
:return: return list of (keys, values) PAIRS, WHERE
keys IS IN LEAF FORM (FOR USE WITH {"eq": terms} OPERA... | [
":",
"param",
"data",
":",
":",
"param",
"keys",
":",
":",
"param",
"size",
":",
":",
"param",
"min_size",
":",
":",
"param",
"max_size",
":",
":",
"param",
"contiguous",
":",
"MAINTAIN",
"THE",
"ORDER",
"OF",
"THE",
"DATA",
"STARTING",
"THE",
"NEW",
... | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/group_by.py#L27-L81 |
Galarzaa90/tibia.py | tibiapy/guild.py | Guild.ranks | def ranks(self) -> List[str]:
""":class:`list` of :class:`str`: Ranks in their hierarchical order."""
return list(OrderedDict.fromkeys((m.rank for m in self.members))) | python | def ranks(self) -> List[str]:
""":class:`list` of :class:`str`: Ranks in their hierarchical order."""
return list(OrderedDict.fromkeys((m.rank for m in self.members))) | [
"def",
"ranks",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"list",
"(",
"OrderedDict",
".",
"fromkeys",
"(",
"(",
"m",
".",
"rank",
"for",
"m",
"in",
"self",
".",
"members",
")",
")",
")"
] | :class:`list` of :class:`str`: Ranks in their hierarchical order. | [
":",
"class",
":",
"list",
"of",
":",
"class",
":",
"str",
":",
"Ranks",
"in",
"their",
"hierarchical",
"order",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/guild.py#L105-L107 |
Galarzaa90/tibia.py | tibiapy/guild.py | Guild.from_content | def from_content(cls, content):
"""Creates an instance of the class from the HTML content of the guild's page.
Parameters
-----------
content: :class:`str`
The HTML content of the page.
Returns
----------
:class:`Guild`
The guild containe... | python | def from_content(cls, content):
"""Creates an instance of the class from the HTML content of the guild's page.
Parameters
-----------
content: :class:`str`
The HTML content of the page.
Returns
----------
:class:`Guild`
The guild containe... | [
"def",
"from_content",
"(",
"cls",
",",
"content",
")",
":",
"if",
"\"An internal error has occurred\"",
"in",
"content",
":",
"return",
"None",
"parsed_content",
"=",
"parse_tibiacom_content",
"(",
"content",
")",
"try",
":",
"name_header",
"=",
"parsed_content",
... | Creates an instance of the class from the HTML content of the guild's page.
Parameters
-----------
content: :class:`str`
The HTML content of the page.
Returns
----------
:class:`Guild`
The guild contained in the page or None if it doesn't exist.
... | [
"Creates",
"an",
"instance",
"of",
"the",
"class",
"from",
"the",
"HTML",
"content",
"of",
"the",
"guild",
"s",
"page",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/guild.py#L112-L154 |
Galarzaa90/tibia.py | tibiapy/guild.py | Guild.from_tibiadata | def from_tibiadata(cls, content):
"""Builds a guild object from a TibiaData character response.
Parameters
----------
content: :class:`str`
The json string from the TibiaData response.
Returns
-------
:class:`Guild`
The guild contained in... | python | def from_tibiadata(cls, content):
"""Builds a guild object from a TibiaData character response.
Parameters
----------
content: :class:`str`
The json string from the TibiaData response.
Returns
-------
:class:`Guild`
The guild contained in... | [
"def",
"from_tibiadata",
"(",
"cls",
",",
"content",
")",
":",
"json_content",
"=",
"parse_json",
"(",
"content",
")",
"guild",
"=",
"cls",
"(",
")",
"try",
":",
"guild_obj",
"=",
"json_content",
"[",
"\"guild\"",
"]",
"if",
"\"error\"",
"in",
"guild_obj",... | Builds a guild object from a TibiaData character response.
Parameters
----------
content: :class:`str`
The json string from the TibiaData response.
Returns
-------
:class:`Guild`
The guild contained in the description or ``None``.
Raises... | [
"Builds",
"a",
"guild",
"object",
"from",
"a",
"TibiaData",
"character",
"response",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/guild.py#L157-L208 |
Galarzaa90/tibia.py | tibiapy/guild.py | Guild._parse_current_member | def _parse_current_member(self, previous_rank, values):
"""
Parses the column texts of a member row into a member dictionary.
Parameters
----------
previous_rank: :class:`dict`[int, str]
The last rank present in the rows.
values: tuple[:class:`str`]
... | python | def _parse_current_member(self, previous_rank, values):
"""
Parses the column texts of a member row into a member dictionary.
Parameters
----------
previous_rank: :class:`dict`[int, str]
The last rank present in the rows.
values: tuple[:class:`str`]
... | [
"def",
"_parse_current_member",
"(",
"self",
",",
"previous_rank",
",",
"values",
")",
":",
"rank",
",",
"name",
",",
"vocation",
",",
"level",
",",
"joined",
",",
"status",
"=",
"values",
"rank",
"=",
"previous_rank",
"[",
"1",
"]",
"if",
"rank",
"==",
... | Parses the column texts of a member row into a member dictionary.
Parameters
----------
previous_rank: :class:`dict`[int, str]
The last rank present in the rows.
values: tuple[:class:`str`]
A list of row contents. | [
"Parses",
"the",
"column",
"texts",
"of",
"a",
"member",
"row",
"into",
"a",
"member",
"dictionary",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/guild.py#L212-L232 |
Galarzaa90/tibia.py | tibiapy/guild.py | Guild._parse_application_info | def _parse_application_info(self, info_container):
"""
Parses the guild's application info.
Parameters
----------
info_container: :class:`bs4.Tag`
The parsed content of the information container.
"""
m = applications_regex.search(info_container.text)
... | python | def _parse_application_info(self, info_container):
"""
Parses the guild's application info.
Parameters
----------
info_container: :class:`bs4.Tag`
The parsed content of the information container.
"""
m = applications_regex.search(info_container.text)
... | [
"def",
"_parse_application_info",
"(",
"self",
",",
"info_container",
")",
":",
"m",
"=",
"applications_regex",
".",
"search",
"(",
"info_container",
".",
"text",
")",
"if",
"m",
":",
"self",
".",
"open_applications",
"=",
"m",
".",
"group",
"(",
"1",
")",... | Parses the guild's application info.
Parameters
----------
info_container: :class:`bs4.Tag`
The parsed content of the information container. | [
"Parses",
"the",
"guild",
"s",
"application",
"info",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/guild.py#L234-L245 |
Galarzaa90/tibia.py | tibiapy/guild.py | Guild._parse_guild_disband_info | def _parse_guild_disband_info(self, info_container):
"""
Parses the guild's disband info, if available.
Parameters
----------
info_container: :class:`bs4.Tag`
The parsed content of the information container.
"""
m = disband_regex.search(info_container... | python | def _parse_guild_disband_info(self, info_container):
"""
Parses the guild's disband info, if available.
Parameters
----------
info_container: :class:`bs4.Tag`
The parsed content of the information container.
"""
m = disband_regex.search(info_container... | [
"def",
"_parse_guild_disband_info",
"(",
"self",
",",
"info_container",
")",
":",
"m",
"=",
"disband_regex",
".",
"search",
"(",
"info_container",
".",
"text",
")",
"if",
"m",
":",
"self",
".",
"disband_condition",
"=",
"m",
".",
"group",
"(",
"2",
")",
... | Parses the guild's disband info, if available.
Parameters
----------
info_container: :class:`bs4.Tag`
The parsed content of the information container. | [
"Parses",
"the",
"guild",
"s",
"disband",
"info",
"if",
"available",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/guild.py#L247-L259 |
Galarzaa90/tibia.py | tibiapy/guild.py | Guild._parse_guild_guildhall | def _parse_guild_guildhall(self, info_container):
"""
Parses the guild's guildhall info.
Parameters
----------
info_container: :class:`bs4.Tag`
The parsed content of the information container.
"""
m = guildhall_regex.search(info_container.text)
... | python | def _parse_guild_guildhall(self, info_container):
"""
Parses the guild's guildhall info.
Parameters
----------
info_container: :class:`bs4.Tag`
The parsed content of the information container.
"""
m = guildhall_regex.search(info_container.text)
... | [
"def",
"_parse_guild_guildhall",
"(",
"self",
",",
"info_container",
")",
":",
"m",
"=",
"guildhall_regex",
".",
"search",
"(",
"info_container",
".",
"text",
")",
"if",
"m",
":",
"paid_until",
"=",
"parse_tibia_date",
"(",
"m",
".",
"group",
"(",
"\"date\""... | Parses the guild's guildhall info.
Parameters
----------
info_container: :class:`bs4.Tag`
The parsed content of the information container. | [
"Parses",
"the",
"guild",
"s",
"guildhall",
"info",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/guild.py#L261-L273 |
Galarzaa90/tibia.py | tibiapy/guild.py | Guild._parse_guild_homepage | def _parse_guild_homepage(self, info_container):
"""
Parses the guild's homepage info.
Parameters
----------
info_container: :class:`bs4.Tag`
The parsed content of the information container.
"""
m = homepage_regex.search(info_container.text)
i... | python | def _parse_guild_homepage(self, info_container):
"""
Parses the guild's homepage info.
Parameters
----------
info_container: :class:`bs4.Tag`
The parsed content of the information container.
"""
m = homepage_regex.search(info_container.text)
i... | [
"def",
"_parse_guild_homepage",
"(",
"self",
",",
"info_container",
")",
":",
"m",
"=",
"homepage_regex",
".",
"search",
"(",
"info_container",
".",
"text",
")",
"if",
"m",
":",
"self",
".",
"homepage",
"=",
"m",
".",
"group",
"(",
"1",
")"
] | Parses the guild's homepage info.
Parameters
----------
info_container: :class:`bs4.Tag`
The parsed content of the information container. | [
"Parses",
"the",
"guild",
"s",
"homepage",
"info",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/guild.py#L275-L286 |
Galarzaa90/tibia.py | tibiapy/guild.py | Guild._parse_guild_info | def _parse_guild_info(self, info_container):
"""
Parses the guild's general information and applies the found values.
Parameters
----------
info_container: :class:`bs4.Tag`
The parsed content of the information container.
"""
m = founded_regex.search(... | python | def _parse_guild_info(self, info_container):
"""
Parses the guild's general information and applies the found values.
Parameters
----------
info_container: :class:`bs4.Tag`
The parsed content of the information container.
"""
m = founded_regex.search(... | [
"def",
"_parse_guild_info",
"(",
"self",
",",
"info_container",
")",
":",
"m",
"=",
"founded_regex",
".",
"search",
"(",
"info_container",
".",
"text",
")",
"if",
"m",
":",
"description",
"=",
"m",
".",
"group",
"(",
"\"desc\"",
")",
".",
"strip",
"(",
... | Parses the guild's general information and applies the found values.
Parameters
----------
info_container: :class:`bs4.Tag`
The parsed content of the information container. | [
"Parses",
"the",
"guild",
"s",
"general",
"information",
"and",
"applies",
"the",
"found",
"values",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/guild.py#L288-L303 |
Galarzaa90/tibia.py | tibiapy/guild.py | Guild._parse_logo | def _parse_logo(self, parsed_content):
"""
Parses the guild logo and saves it to the instance.
Parameters
----------
parsed_content: :class:`bs4.Tag`
The parsed content of the page.
Returns
-------
:class:`bool`
Whether the logo w... | python | def _parse_logo(self, parsed_content):
"""
Parses the guild logo and saves it to the instance.
Parameters
----------
parsed_content: :class:`bs4.Tag`
The parsed content of the page.
Returns
-------
:class:`bool`
Whether the logo w... | [
"def",
"_parse_logo",
"(",
"self",
",",
"parsed_content",
")",
":",
"logo_img",
"=",
"parsed_content",
".",
"find",
"(",
"'img'",
",",
"{",
"'height'",
":",
"'64'",
"}",
")",
"if",
"logo_img",
"is",
"None",
":",
"return",
"False",
"self",
".",
"logo_url"... | Parses the guild logo and saves it to the instance.
Parameters
----------
parsed_content: :class:`bs4.Tag`
The parsed content of the page.
Returns
-------
:class:`bool`
Whether the logo was found or not. | [
"Parses",
"the",
"guild",
"logo",
"and",
"saves",
"it",
"to",
"the",
"instance",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/guild.py#L305-L324 |
Galarzaa90/tibia.py | tibiapy/guild.py | Guild._parse_guild_members | def _parse_guild_members(self, parsed_content):
"""
Parses the guild's member and invited list.
Parameters
----------
parsed_content: :class:`bs4.Tag`
The parsed content of the guild's page
"""
member_rows = parsed_content.find_all("tr", {'bgcolor': [... | python | def _parse_guild_members(self, parsed_content):
"""
Parses the guild's member and invited list.
Parameters
----------
parsed_content: :class:`bs4.Tag`
The parsed content of the guild's page
"""
member_rows = parsed_content.find_all("tr", {'bgcolor': [... | [
"def",
"_parse_guild_members",
"(",
"self",
",",
"parsed_content",
")",
":",
"member_rows",
"=",
"parsed_content",
".",
"find_all",
"(",
"\"tr\"",
",",
"{",
"'bgcolor'",
":",
"[",
"\"#D4C0A1\"",
",",
"\"#F1E0C6\"",
"]",
"}",
")",
"previous_rank",
"=",
"{",
"... | Parses the guild's member and invited list.
Parameters
----------
parsed_content: :class:`bs4.Tag`
The parsed content of the guild's page | [
"Parses",
"the",
"guild",
"s",
"member",
"and",
"invited",
"list",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/guild.py#L326-L343 |
Galarzaa90/tibia.py | tibiapy/guild.py | Guild._parse_invited_member | def _parse_invited_member(self, values):
"""
Parses the column texts of an invited row into a invited dictionary.
Parameters
----------
values: tuple[:class:`str`]
A list of row contents.
"""
name, date = values
if date != "Invitation Date":
... | python | def _parse_invited_member(self, values):
"""
Parses the column texts of an invited row into a invited dictionary.
Parameters
----------
values: tuple[:class:`str`]
A list of row contents.
"""
name, date = values
if date != "Invitation Date":
... | [
"def",
"_parse_invited_member",
"(",
"self",
",",
"values",
")",
":",
"name",
",",
"date",
"=",
"values",
"if",
"date",
"!=",
"\"Invitation Date\"",
":",
"self",
".",
"invites",
".",
"append",
"(",
"GuildInvite",
"(",
"name",
",",
"date",
")",
")"
] | Parses the column texts of an invited row into a invited dictionary.
Parameters
----------
values: tuple[:class:`str`]
A list of row contents. | [
"Parses",
"the",
"column",
"texts",
"of",
"an",
"invited",
"row",
"into",
"a",
"invited",
"dictionary",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/guild.py#L345-L356 |
Galarzaa90/tibia.py | tibiapy/guild.py | ListedGuild.get_world_list_url | def get_world_list_url(cls, world):
"""Gets the Tibia.com URL for the guild section of a specific world.
Parameters
----------
world: :class:`str`
The name of the world.
Returns
-------
:class:`str`
The URL to the guild's page
"""... | python | def get_world_list_url(cls, world):
"""Gets the Tibia.com URL for the guild section of a specific world.
Parameters
----------
world: :class:`str`
The name of the world.
Returns
-------
:class:`str`
The URL to the guild's page
"""... | [
"def",
"get_world_list_url",
"(",
"cls",
",",
"world",
")",
":",
"return",
"GUILD_LIST_URL",
"+",
"urllib",
".",
"parse",
".",
"quote",
"(",
"world",
".",
"title",
"(",
")",
".",
"encode",
"(",
"'iso-8859-1'",
")",
")"
] | Gets the Tibia.com URL for the guild section of a specific world.
Parameters
----------
world: :class:`str`
The name of the world.
Returns
-------
:class:`str`
The URL to the guild's page | [
"Gets",
"the",
"Tibia",
".",
"com",
"URL",
"for",
"the",
"guild",
"section",
"of",
"a",
"specific",
"world",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/guild.py#L443-L456 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.