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 |
|---|---|---|---|---|---|---|---|---|---|---|
peterldowns/djoauth2 | djoauth2/helpers.py | update_parameters | def update_parameters(url, parameters, encoding='utf8'):
""" Updates a URL's existing GET parameters.
:param url: a base URL to which to add additional parameters.
:param parameters: a dictionary of parameters, any mix of
unicode and string objects as the parameters and the values.
:parameter encoding: the... | python | def update_parameters(url, parameters, encoding='utf8'):
""" Updates a URL's existing GET parameters.
:param url: a base URL to which to add additional parameters.
:param parameters: a dictionary of parameters, any mix of
unicode and string objects as the parameters and the values.
:parameter encoding: the... | [
"def",
"update_parameters",
"(",
"url",
",",
"parameters",
",",
"encoding",
"=",
"'utf8'",
")",
":",
"# Convert the base URL to the default encoding.",
"if",
"isinstance",
"(",
"url",
",",
"unicode",
")",
":",
"url",
"=",
"url",
".",
"encode",
"(",
"encoding",
... | Updates a URL's existing GET parameters.
:param url: a base URL to which to add additional parameters.
:param parameters: a dictionary of parameters, any mix of
unicode and string objects as the parameters and the values.
:parameter encoding: the byte encoding to use when passed unicode
for the base URL ... | [
"Updates",
"a",
"URL",
"s",
"existing",
"GET",
"parameters",
"."
] | train | https://github.com/peterldowns/djoauth2/blob/151c7619d1d7a91d720397cfecf3a29fcc9747a9/djoauth2/helpers.py#L51-L90 |
KelSolaar/Foundations | foundations/io.py | set_directory | def set_directory(path):
"""
| Creates a directory with given path.
| The directory creation is delegated to
Python :func:`os.makedirs` definition so that directories hierarchy is recursively created.
:param path: Directory path.
:type path: unicode
:return: Definition success.
:rty... | python | def set_directory(path):
"""
| Creates a directory with given path.
| The directory creation is delegated to
Python :func:`os.makedirs` definition so that directories hierarchy is recursively created.
:param path: Directory path.
:type path: unicode
:return: Definition success.
:rty... | [
"def",
"set_directory",
"(",
"path",
")",
":",
"try",
":",
"if",
"not",
"foundations",
".",
"common",
".",
"path_exists",
"(",
"path",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"> Creating directory: '{0}'.\"",
".",
"format",
"(",
"path",
")",
")",
"os",
... | | Creates a directory with given path.
| The directory creation is delegated to
Python :func:`os.makedirs` definition so that directories hierarchy is recursively created.
:param path: Directory path.
:type path: unicode
:return: Definition success.
:rtype: bool | [
"|",
"Creates",
"a",
"directory",
"with",
"given",
"path",
".",
"|",
"The",
"directory",
"creation",
"is",
"delegated",
"to",
"Python",
":",
"func",
":",
"os",
".",
"makedirs",
"definition",
"so",
"that",
"directories",
"hierarchy",
"is",
"recursively",
"cre... | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/io.py#L292-L314 |
KelSolaar/Foundations | foundations/io.py | copy | def copy(source, destination):
"""
Copies given file or directory to destination.
:param source: Source to copy from.
:type source: unicode
:param destination: Destination to copy to.
:type destination: unicode
:return: Method success.
:rtype: bool
"""
try:
if os.path.i... | python | def copy(source, destination):
"""
Copies given file or directory to destination.
:param source: Source to copy from.
:type source: unicode
:param destination: Destination to copy to.
:type destination: unicode
:return: Method success.
:rtype: bool
"""
try:
if os.path.i... | [
"def",
"copy",
"(",
"source",
",",
"destination",
")",
":",
"try",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"source",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"> Copying '{0}' file to '{1}'.\"",
".",
"format",
"(",
"source",
",",
"destination",
... | Copies given file or directory to destination.
:param source: Source to copy from.
:type source: unicode
:param destination: Destination to copy to.
:type destination: unicode
:return: Method success.
:rtype: bool | [
"Copies",
"given",
"file",
"or",
"directory",
"to",
"destination",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/io.py#L318-L340 |
KelSolaar/Foundations | foundations/io.py | remove | def remove(path):
"""
Removes given path.
:param path: Path to remove.
:type path: unicode
:return: Method success.
:rtype: bool
"""
try:
if os.path.isfile(path):
LOGGER.debug("> Removing '{0}' file.".format(path))
os.remove(path)
elif os.path.is... | python | def remove(path):
"""
Removes given path.
:param path: Path to remove.
:type path: unicode
:return: Method success.
:rtype: bool
"""
try:
if os.path.isfile(path):
LOGGER.debug("> Removing '{0}' file.".format(path))
os.remove(path)
elif os.path.is... | [
"def",
"remove",
"(",
"path",
")",
":",
"try",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"> Removing '{0}' file.\"",
".",
"format",
"(",
"path",
")",
")",
"os",
".",
"remove",
"(",
"path",
")... | Removes given path.
:param path: Path to remove.
:type path: unicode
:return: Method success.
:rtype: bool | [
"Removes",
"given",
"path",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/io.py#L344-L364 |
KelSolaar/Foundations | foundations/io.py | is_readable | def is_readable(path):
"""
Returns if given path is readable.
:param path: Path to check access.
:type path: unicode
:return: Is path writable.
:rtype: bool
"""
if os.access(path, os.R_OK):
LOGGER.debug("> '{0}' path is readable.".format(path))
return True
else:
... | python | def is_readable(path):
"""
Returns if given path is readable.
:param path: Path to check access.
:type path: unicode
:return: Is path writable.
:rtype: bool
"""
if os.access(path, os.R_OK):
LOGGER.debug("> '{0}' path is readable.".format(path))
return True
else:
... | [
"def",
"is_readable",
"(",
"path",
")",
":",
"if",
"os",
".",
"access",
"(",
"path",
",",
"os",
".",
"R_OK",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"> '{0}' path is readable.\"",
".",
"format",
"(",
"path",
")",
")",
"return",
"True",
"else",
":",
... | Returns if given path is readable.
:param path: Path to check access.
:type path: unicode
:return: Is path writable.
:rtype: bool | [
"Returns",
"if",
"given",
"path",
"is",
"readable",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/io.py#L367-L382 |
KelSolaar/Foundations | foundations/io.py | is_writable | def is_writable(path):
"""
Returns if given path is writable.
:param path: Path to check access.
:type path: unicode
:return: Is path writable.
:rtype: bool
"""
if os.access(path, os.W_OK):
LOGGER.debug("> '{0}' path is writable.".format(path))
return True
else:
... | python | def is_writable(path):
"""
Returns if given path is writable.
:param path: Path to check access.
:type path: unicode
:return: Is path writable.
:rtype: bool
"""
if os.access(path, os.W_OK):
LOGGER.debug("> '{0}' path is writable.".format(path))
return True
else:
... | [
"def",
"is_writable",
"(",
"path",
")",
":",
"if",
"os",
".",
"access",
"(",
"path",
",",
"os",
".",
"W_OK",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"> '{0}' path is writable.\"",
".",
"format",
"(",
"path",
")",
")",
"return",
"True",
"else",
":",
... | Returns if given path is writable.
:param path: Path to check access.
:type path: unicode
:return: Is path writable.
:rtype: bool | [
"Returns",
"if",
"given",
"path",
"is",
"writable",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/io.py#L385-L400 |
KelSolaar/Foundations | foundations/io.py | is_binary_file | def is_binary_file(file):
"""
Returns if given file is a binary file.
:param file: File path.
:type file: unicode
:return: Is file binary.
:rtype: bool
"""
file_handle = open(file, "rb")
try:
chunk_size = 1024
while True:
chunk = file_handle.read(chunk_s... | python | def is_binary_file(file):
"""
Returns if given file is a binary file.
:param file: File path.
:type file: unicode
:return: Is file binary.
:rtype: bool
"""
file_handle = open(file, "rb")
try:
chunk_size = 1024
while True:
chunk = file_handle.read(chunk_s... | [
"def",
"is_binary_file",
"(",
"file",
")",
":",
"file_handle",
"=",
"open",
"(",
"file",
",",
"\"rb\"",
")",
"try",
":",
"chunk_size",
"=",
"1024",
"while",
"True",
":",
"chunk",
"=",
"file_handle",
".",
"read",
"(",
"chunk_size",
")",
"if",
"chr",
"("... | Returns if given file is a binary file.
:param file: File path.
:type file: unicode
:return: Is file binary.
:rtype: bool | [
"Returns",
"if",
"given",
"file",
"is",
"a",
"binary",
"file",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/io.py#L403-L424 |
KelSolaar/Foundations | foundations/io.py | File.path | def path(self, value):
"""
Setter for **self.__path** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format("path", value)
self._... | python | def path(self, value):
"""
Setter for **self.__path** attribute.
:param value: Attribute value.
:type value: unicode
"""
if value is not None:
assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format("path", value)
self._... | [
"def",
"path",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"unicode",
",",
"\"'{0}' attribute: '{1}' type is not 'unicode'!\"",
".",
"format",
"(",
"\"path\"",
",",
"value",
")",
... | Setter for **self.__path** attribute.
:param value: Attribute value.
:type value: unicode | [
"Setter",
"for",
"**",
"self",
".",
"__path",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/io.py#L87-L97 |
KelSolaar/Foundations | foundations/io.py | File.content | def content(self, value):
"""
Setter for **self.__content** attribute.
:param value: Attribute value.
:type value: list
"""
if value is not None:
assert type(value) is list, "'{0}' attribute: '{1}' type is not 'list'!".format("content", value)
self._... | python | def content(self, value):
"""
Setter for **self.__content** attribute.
:param value: Attribute value.
:type value: list
"""
if value is not None:
assert type(value) is list, "'{0}' attribute: '{1}' type is not 'list'!".format("content", value)
self._... | [
"def",
"content",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"list",
",",
"\"'{0}' attribute: '{1}' type is not 'list'!\"",
".",
"format",
"(",
"\"content\"",
",",
"value",
")",
... | Setter for **self.__content** attribute.
:param value: Attribute value.
:type value: list | [
"Setter",
"for",
"**",
"self",
".",
"__content",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/io.py#L122-L132 |
KelSolaar/Foundations | foundations/io.py | File.cache | def cache(self, mode="r", encoding=Constants.default_codec, errors=Constants.codec_error):
"""
Reads given file content and stores it in the content cache.
:param mode: File read mode.
:type mode: unicode
:param encoding: File encoding codec.
:type encoding: unicode
... | python | def cache(self, mode="r", encoding=Constants.default_codec, errors=Constants.codec_error):
"""
Reads given file content and stores it in the content cache.
:param mode: File read mode.
:type mode: unicode
:param encoding: File encoding codec.
:type encoding: unicode
... | [
"def",
"cache",
"(",
"self",
",",
"mode",
"=",
"\"r\"",
",",
"encoding",
"=",
"Constants",
".",
"default_codec",
",",
"errors",
"=",
"Constants",
".",
"codec_error",
")",
":",
"self",
".",
"uncache",
"(",
")",
"if",
"foundations",
".",
"strings",
".",
... | Reads given file content and stores it in the content cache.
:param mode: File read mode.
:type mode: unicode
:param encoding: File encoding codec.
:type encoding: unicode
:param errors: File encoding errors handling.
:type errors: unicode
:return: Method success... | [
"Reads",
"given",
"file",
"content",
"and",
"stores",
"it",
"in",
"the",
"content",
"cache",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/io.py#L147-L180 |
KelSolaar/Foundations | foundations/io.py | File.uncache | def uncache(self):
"""
Uncaches the cached content.
:return: Method success.
:rtype: bool
"""
LOGGER.debug("> Uncaching '{0}' file content.".format(self.__path))
self.__content = []
return True | python | def uncache(self):
"""
Uncaches the cached content.
:return: Method success.
:rtype: bool
"""
LOGGER.debug("> Uncaching '{0}' file content.".format(self.__path))
self.__content = []
return True | [
"def",
"uncache",
"(",
"self",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"> Uncaching '{0}' file content.\"",
".",
"format",
"(",
"self",
".",
"__path",
")",
")",
"self",
".",
"__content",
"=",
"[",
"]",
"return",
"True"
] | Uncaches the cached content.
:return: Method success.
:rtype: bool | [
"Uncaches",
"the",
"cached",
"content",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/io.py#L182-L193 |
KelSolaar/Foundations | foundations/io.py | File.append | def append(self, mode="a", encoding=Constants.default_codec, errors=Constants.codec_error):
"""
Appends content to defined file.
:param mode: File write mode.
:type mode: unicode
:param encoding: File encoding codec.
:type encoding: unicode
:param errors: File en... | python | def append(self, mode="a", encoding=Constants.default_codec, errors=Constants.codec_error):
"""
Appends content to defined file.
:param mode: File write mode.
:type mode: unicode
:param encoding: File encoding codec.
:type encoding: unicode
:param errors: File en... | [
"def",
"append",
"(",
"self",
",",
"mode",
"=",
"\"a\"",
",",
"encoding",
"=",
"Constants",
".",
"default_codec",
",",
"errors",
"=",
"Constants",
".",
"codec_error",
")",
":",
"if",
"foundations",
".",
"strings",
".",
"is_website",
"(",
"self",
".",
"__... | Appends content to defined file.
:param mode: File write mode.
:type mode: unicode
:param encoding: File encoding codec.
:type encoding: unicode
:param errors: File encoding errors handling.
:type errors: unicode
:return: Method success.
:rtype: bool | [
"Appends",
"content",
"to",
"defined",
"file",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/io.py#L239-L267 |
KelSolaar/Foundations | foundations/io.py | File.clear | def clear(self, encoding=Constants.default_codec):
"""
Clears the defined file content.
:param encoding: File encoding codec.
:type encoding: unicode
:return: Method success.
:rtype: bool
"""
if foundations.strings.is_website(self.__path):
ra... | python | def clear(self, encoding=Constants.default_codec):
"""
Clears the defined file content.
:param encoding: File encoding codec.
:type encoding: unicode
:return: Method success.
:rtype: bool
"""
if foundations.strings.is_website(self.__path):
ra... | [
"def",
"clear",
"(",
"self",
",",
"encoding",
"=",
"Constants",
".",
"default_codec",
")",
":",
"if",
"foundations",
".",
"strings",
".",
"is_website",
"(",
"self",
".",
"__path",
")",
":",
"raise",
"foundations",
".",
"exceptions",
".",
"UrlWriteError",
"... | Clears the defined file content.
:param encoding: File encoding codec.
:type encoding: unicode
:return: Method success.
:rtype: bool | [
"Clears",
"the",
"defined",
"file",
"content",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/io.py#L270-L288 |
PMBio/limix-backup | limix/ensemble/py_splitting_core.py | cpp_best_split_full_model | def cpp_best_split_full_model(X, Uy, C, S, U, noderange, delta,
save_memory=False):
"""wrappe calling cpp splitting function"""
return CSP.best_split_full_model(X, Uy, C, S, U, noderange, delta) | python | def cpp_best_split_full_model(X, Uy, C, S, U, noderange, delta,
save_memory=False):
"""wrappe calling cpp splitting function"""
return CSP.best_split_full_model(X, Uy, C, S, U, noderange, delta) | [
"def",
"cpp_best_split_full_model",
"(",
"X",
",",
"Uy",
",",
"C",
",",
"S",
",",
"U",
",",
"noderange",
",",
"delta",
",",
"save_memory",
"=",
"False",
")",
":",
"return",
"CSP",
".",
"best_split_full_model",
"(",
"X",
",",
"Uy",
",",
"C",
",",
"S",... | wrappe calling cpp splitting function | [
"wrappe",
"calling",
"cpp",
"splitting",
"function"
] | train | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/ensemble/py_splitting_core.py#L68-L71 |
nirum-lang/nirum-python | nirum/rpc.py | WsgiApp.route | def route(self, environ, start_response):
"""Route
:param environ:
:param start_response:
"""
urls = self.url_map.bind_to_environ(environ)
request = WsgiRequest(environ)
try:
endpoint, args = urls.match()
except HTTPException as e:
... | python | def route(self, environ, start_response):
"""Route
:param environ:
:param start_response:
"""
urls = self.url_map.bind_to_environ(environ)
request = WsgiRequest(environ)
try:
endpoint, args = urls.match()
except HTTPException as e:
... | [
"def",
"route",
"(",
"self",
",",
"environ",
",",
"start_response",
")",
":",
"urls",
"=",
"self",
".",
"url_map",
".",
"bind_to_environ",
"(",
"environ",
")",
"request",
"=",
"WsgiRequest",
"(",
"environ",
")",
"try",
":",
"endpoint",
",",
"args",
"=",
... | Route
:param environ:
:param start_response: | [
"Route"
] | train | https://github.com/nirum-lang/nirum-python/blob/3f6af2f8f404fd7d5f43359661be76b4fdf00e96/nirum/rpc.py#L93-L109 |
nirum-lang/nirum-python | nirum/rpc.py | WsgiApp.rpc | def rpc(self, request, args):
"""RPC
:param request:
:args ???:
"""
if request.method != 'POST':
return self.error(405, request)
payload = request.get_data(as_text=True) or '{}'
request_method = request.args.get('method')
if not request_metho... | python | def rpc(self, request, args):
"""RPC
:param request:
:args ???:
"""
if request.method != 'POST':
return self.error(405, request)
payload = request.get_data(as_text=True) or '{}'
request_method = request.args.get('method')
if not request_metho... | [
"def",
"rpc",
"(",
"self",
",",
"request",
",",
"args",
")",
":",
"if",
"request",
".",
"method",
"!=",
"'POST'",
":",
"return",
"self",
".",
"error",
"(",
"405",
",",
"request",
")",
"payload",
"=",
"request",
".",
"get_data",
"(",
"as_text",
"=",
... | RPC
:param request:
:args ???: | [
"RPC"
] | train | https://github.com/nirum-lang/nirum-python/blob/3f6af2f8f404fd7d5f43359661be76b4fdf00e96/nirum/rpc.py#L118-L202 |
nirum-lang/nirum-python | nirum/rpc.py | WsgiApp.error | def error(self, status_code, request, message=None):
"""Handle error response.
:param int status_code:
:param request:
:return:
"""
status_code_text = HTTP_STATUS_CODES.get(status_code, 'http error')
status_error_tag = status_code_text.lower().replace(' ', '_')
... | python | def error(self, status_code, request, message=None):
"""Handle error response.
:param int status_code:
:param request:
:return:
"""
status_code_text = HTTP_STATUS_CODES.get(status_code, 'http error')
status_error_tag = status_code_text.lower().replace(' ', '_')
... | [
"def",
"error",
"(",
"self",
",",
"status_code",
",",
"request",
",",
"message",
"=",
"None",
")",
":",
"status_code_text",
"=",
"HTTP_STATUS_CODES",
".",
"get",
"(",
"status_code",
",",
"'http error'",
")",
"status_error_tag",
"=",
"status_code_text",
".",
"l... | Handle error response.
:param int status_code:
:param request:
:return: | [
"Handle",
"error",
"response",
"."
] | train | https://github.com/nirum-lang/nirum-python/blob/3f6af2f8f404fd7d5f43359661be76b4fdf00e96/nirum/rpc.py#L260-L293 |
jhermann/rudiments | src/rudiments/security.py | Credentials.auth_pair | def auth_pair(self, force_console=False):
"""Return username/password tuple, possibly prompting the user for them."""
if not self.auth_valid():
self._get_auth(force_console)
return (self.user, self.password) | python | def auth_pair(self, force_console=False):
"""Return username/password tuple, possibly prompting the user for them."""
if not self.auth_valid():
self._get_auth(force_console)
return (self.user, self.password) | [
"def",
"auth_pair",
"(",
"self",
",",
"force_console",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"auth_valid",
"(",
")",
":",
"self",
".",
"_get_auth",
"(",
"force_console",
")",
"return",
"(",
"self",
".",
"user",
",",
"self",
".",
"password",... | Return username/password tuple, possibly prompting the user for them. | [
"Return",
"username",
"/",
"password",
"tuple",
"possibly",
"prompting",
"the",
"user",
"for",
"them",
"."
] | train | https://github.com/jhermann/rudiments/blob/028ec7237946115c7b18e50557cbc5f6b824653e/src/rudiments/security.py#L56-L60 |
jhermann/rudiments | src/rudiments/security.py | Credentials._get_auth | def _get_auth(self, force_console=False):
"""Try to get login auth from known sources."""
if not self.target:
raise ValueError("Unspecified target ({!r})".format(self.target))
elif not force_console and self.URL_RE.match(self.target):
auth_url = urlparse(self.target)
... | python | def _get_auth(self, force_console=False):
"""Try to get login auth from known sources."""
if not self.target:
raise ValueError("Unspecified target ({!r})".format(self.target))
elif not force_console and self.URL_RE.match(self.target):
auth_url = urlparse(self.target)
... | [
"def",
"_get_auth",
"(",
"self",
",",
"force_console",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"target",
":",
"raise",
"ValueError",
"(",
"\"Unspecified target ({!r})\"",
".",
"format",
"(",
"self",
".",
"target",
")",
")",
"elif",
"not",
"force_... | Try to get login auth from known sources. | [
"Try",
"to",
"get",
"login",
"auth",
"from",
"known",
"sources",
"."
] | train | https://github.com/jhermann/rudiments/blob/028ec7237946115c7b18e50557cbc5f6b824653e/src/rudiments/security.py#L66-L87 |
jhermann/rudiments | src/rudiments/security.py | Credentials._get_auth_from_console | def _get_auth_from_console(self, realm):
"""Prompt for the user and password."""
self.user, self.password = self.AUTH_MEMOIZE_INPUT.get(realm, (self.user, None))
if not self.auth_valid():
if not self.user:
login = getpass.getuser()
self.user = self._ra... | python | def _get_auth_from_console(self, realm):
"""Prompt for the user and password."""
self.user, self.password = self.AUTH_MEMOIZE_INPUT.get(realm, (self.user, None))
if not self.auth_valid():
if not self.user:
login = getpass.getuser()
self.user = self._ra... | [
"def",
"_get_auth_from_console",
"(",
"self",
",",
"realm",
")",
":",
"self",
".",
"user",
",",
"self",
".",
"password",
"=",
"self",
".",
"AUTH_MEMOIZE_INPUT",
".",
"get",
"(",
"realm",
",",
"(",
"self",
".",
"user",
",",
"None",
")",
")",
"if",
"no... | Prompt for the user and password. | [
"Prompt",
"for",
"the",
"user",
"and",
"password",
"."
] | train | https://github.com/jhermann/rudiments/blob/028ec7237946115c7b18e50557cbc5f6b824653e/src/rudiments/security.py#L89-L99 |
jhermann/rudiments | src/rudiments/security.py | Credentials._get_auth_from_netrc | def _get_auth_from_netrc(self, hostname):
"""Try to find login auth in ``~/.netrc``."""
try:
hostauth = netrc(self.NETRC_FILE)
except IOError as cause:
if cause.errno != errno.ENOENT:
raise
return None
except NetrcParseError as cause:
... | python | def _get_auth_from_netrc(self, hostname):
"""Try to find login auth in ``~/.netrc``."""
try:
hostauth = netrc(self.NETRC_FILE)
except IOError as cause:
if cause.errno != errno.ENOENT:
raise
return None
except NetrcParseError as cause:
... | [
"def",
"_get_auth_from_netrc",
"(",
"self",
",",
"hostname",
")",
":",
"try",
":",
"hostauth",
"=",
"netrc",
"(",
"self",
".",
"NETRC_FILE",
")",
"except",
"IOError",
"as",
"cause",
":",
"if",
"cause",
".",
"errno",
"!=",
"errno",
".",
"ENOENT",
":",
"... | Try to find login auth in ``~/.netrc``. | [
"Try",
"to",
"find",
"login",
"auth",
"in",
"~",
"/",
".",
"netrc",
"."
] | train | https://github.com/jhermann/rudiments/blob/028ec7237946115c7b18e50557cbc5f6b824653e/src/rudiments/security.py#L101-L127 |
jhermann/rudiments | src/rudiments/security.py | Credentials._get_auth_from_keyring | def _get_auth_from_keyring(self):
"""Try to get credentials using `keyring <https://github.com/jaraco/keyring>`_."""
if not keyring:
return None
# Take user from URL if available, else the OS login name
password = self._get_password_from_keyring(self.user or getpass.getuser(... | python | def _get_auth_from_keyring(self):
"""Try to get credentials using `keyring <https://github.com/jaraco/keyring>`_."""
if not keyring:
return None
# Take user from URL if available, else the OS login name
password = self._get_password_from_keyring(self.user or getpass.getuser(... | [
"def",
"_get_auth_from_keyring",
"(",
"self",
")",
":",
"if",
"not",
"keyring",
":",
"return",
"None",
"# Take user from URL if available, else the OS login name",
"password",
"=",
"self",
".",
"_get_password_from_keyring",
"(",
"self",
".",
"user",
"or",
"getpass",
"... | Try to get credentials using `keyring <https://github.com/jaraco/keyring>`_. | [
"Try",
"to",
"get",
"credentials",
"using",
"keyring",
"<https",
":",
"//",
"github",
".",
"com",
"/",
"jaraco",
"/",
"keyring",
">",
"_",
"."
] | train | https://github.com/jhermann/rudiments/blob/028ec7237946115c7b18e50557cbc5f6b824653e/src/rudiments/security.py#L133-L144 |
jaapverloop/knot | knot.py | factory | def factory(container, name=None):
"""A decorator to register a factory on the container.
For more information see :meth:`Container.add_factory`.
"""
def register(factory):
container.add_factory(factory, name)
return factory
return register | python | def factory(container, name=None):
"""A decorator to register a factory on the container.
For more information see :meth:`Container.add_factory`.
"""
def register(factory):
container.add_factory(factory, name)
return factory
return register | [
"def",
"factory",
"(",
"container",
",",
"name",
"=",
"None",
")",
":",
"def",
"register",
"(",
"factory",
")",
":",
"container",
".",
"add_factory",
"(",
"factory",
",",
"name",
")",
"return",
"factory",
"return",
"register"
] | A decorator to register a factory on the container.
For more information see :meth:`Container.add_factory`. | [
"A",
"decorator",
"to",
"register",
"a",
"factory",
"on",
"the",
"container",
".",
"For",
"more",
"information",
"see",
":",
"meth",
":",
"Container",
".",
"add_factory",
"."
] | train | https://github.com/jaapverloop/knot/blob/6ae8c2ada5385fa770b147edba053bebb18e8347/knot.py#L17-L25 |
jaapverloop/knot | knot.py | service | def service(container, name=None):
"""A decorator to register a service on a container.
For more information see :meth:`Container.add_service`.
"""
def register(service):
container.add_service(service, name)
return service
return register | python | def service(container, name=None):
"""A decorator to register a service on a container.
For more information see :meth:`Container.add_service`.
"""
def register(service):
container.add_service(service, name)
return service
return register | [
"def",
"service",
"(",
"container",
",",
"name",
"=",
"None",
")",
":",
"def",
"register",
"(",
"service",
")",
":",
"container",
".",
"add_service",
"(",
"service",
",",
"name",
")",
"return",
"service",
"return",
"register"
] | A decorator to register a service on a container.
For more information see :meth:`Container.add_service`. | [
"A",
"decorator",
"to",
"register",
"a",
"service",
"on",
"a",
"container",
".",
"For",
"more",
"information",
"see",
":",
"meth",
":",
"Container",
".",
"add_service",
"."
] | train | https://github.com/jaapverloop/knot/blob/6ae8c2ada5385fa770b147edba053bebb18e8347/knot.py#L28-L36 |
jaapverloop/knot | knot.py | provider | def provider(container, cache, name=None):
"""A decorator to register a provider on a container.
For more information see :meth:`Container.add_provider`.
"""
def register(provider):
container.add_provider(provider, cache, name)
return provider
return register | python | def provider(container, cache, name=None):
"""A decorator to register a provider on a container.
For more information see :meth:`Container.add_provider`.
"""
def register(provider):
container.add_provider(provider, cache, name)
return provider
return register | [
"def",
"provider",
"(",
"container",
",",
"cache",
",",
"name",
"=",
"None",
")",
":",
"def",
"register",
"(",
"provider",
")",
":",
"container",
".",
"add_provider",
"(",
"provider",
",",
"cache",
",",
"name",
")",
"return",
"provider",
"return",
"regis... | A decorator to register a provider on a container.
For more information see :meth:`Container.add_provider`. | [
"A",
"decorator",
"to",
"register",
"a",
"provider",
"on",
"a",
"container",
".",
"For",
"more",
"information",
"see",
":",
"meth",
":",
"Container",
".",
"add_provider",
"."
] | train | https://github.com/jaapverloop/knot/blob/6ae8c2ada5385fa770b147edba053bebb18e8347/knot.py#L39-L47 |
jaapverloop/knot | knot.py | Container.provide | def provide(self, name):
"""Gets the value registered with ``name`` and determines whether the
value is a provider or a configuration setting. The ``KeyError`` is
raised when the ``name`` is not found.
The registered value is interpreted as a provider if it's callable. The
provi... | python | def provide(self, name):
"""Gets the value registered with ``name`` and determines whether the
value is a provider or a configuration setting. The ``KeyError`` is
raised when the ``name`` is not found.
The registered value is interpreted as a provider if it's callable. The
provi... | [
"def",
"provide",
"(",
"self",
",",
"name",
")",
":",
"rv",
"=",
"self",
"[",
"name",
"]",
"return",
"rv",
"(",
"self",
")",
"if",
"callable",
"(",
"rv",
")",
"else",
"rv"
] | Gets the value registered with ``name`` and determines whether the
value is a provider or a configuration setting. The ``KeyError`` is
raised when the ``name`` is not found.
The registered value is interpreted as a provider if it's callable. The
provider is called with a single argument... | [
"Gets",
"the",
"value",
"registered",
"with",
"name",
"and",
"determines",
"whether",
"the",
"value",
"is",
"a",
"provider",
"or",
"a",
"configuration",
"setting",
".",
"The",
"KeyError",
"is",
"raised",
"when",
"the",
"name",
"is",
"not",
"found",
"."
] | train | https://github.com/jaapverloop/knot/blob/6ae8c2ada5385fa770b147edba053bebb18e8347/knot.py#L90-L104 |
jaapverloop/knot | knot.py | Container.add_provider | def add_provider(self, provider, cache, name=None):
"""Registers a provider on the container.
:param provider:
Anything that's callable and expects exactly one argument, the
:class:`Container` object.
:param cache:
Whether to cache the return value of the pro... | python | def add_provider(self, provider, cache, name=None):
"""Registers a provider on the container.
:param provider:
Anything that's callable and expects exactly one argument, the
:class:`Container` object.
:param cache:
Whether to cache the return value of the pro... | [
"def",
"add_provider",
"(",
"self",
",",
"provider",
",",
"cache",
",",
"name",
"=",
"None",
")",
":",
"register_as",
"=",
"name",
"or",
"provider",
".",
"__name__",
"self",
"[",
"register_as",
"]",
"=",
"FunctionCache",
"(",
"provider",
")",
"if",
"cach... | Registers a provider on the container.
:param provider:
Anything that's callable and expects exactly one argument, the
:class:`Container` object.
:param cache:
Whether to cache the return value of the provider.
:param name:
Alternative name of the... | [
"Registers",
"a",
"provider",
"on",
"the",
"container",
"."
] | train | https://github.com/jaapverloop/knot/blob/6ae8c2ada5385fa770b147edba053bebb18e8347/knot.py#L120-L133 |
jaapverloop/knot | knot.py | Container.is_cached | def is_cached(self, name):
"""Determines if the return value is cached. Always returns false if
the registered value is not an instance of :class:`FunctionCache`.
:param name:
The name of the provider.
"""
try:
cached = super(Container, self).get(name).ca... | python | def is_cached(self, name):
"""Determines if the return value is cached. Always returns false if
the registered value is not an instance of :class:`FunctionCache`.
:param name:
The name of the provider.
"""
try:
cached = super(Container, self).get(name).ca... | [
"def",
"is_cached",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"cached",
"=",
"super",
"(",
"Container",
",",
"self",
")",
".",
"get",
"(",
"name",
")",
".",
"cached",
"except",
"AttributeError",
":",
"cached",
"=",
"False",
"return",
"cached"
] | Determines if the return value is cached. Always returns false if
the registered value is not an instance of :class:`FunctionCache`.
:param name:
The name of the provider. | [
"Determines",
"if",
"the",
"return",
"value",
"is",
"cached",
".",
"Always",
"returns",
"false",
"if",
"the",
"registered",
"value",
"is",
"not",
"an",
"instance",
"of",
":",
"class",
":",
"FunctionCache",
"."
] | train | https://github.com/jaapverloop/knot/blob/6ae8c2ada5385fa770b147edba053bebb18e8347/knot.py#L135-L147 |
ael-code/pyFsdb | fsdb/utils.py | copy_content | def copy_content(origin, dstPath, blockSize, mode):
''' copy the content of `origin` to `dstPath` in a safe manner.
this function will first copy the content to a temporary file
and then move it atomically to the requested destination.
if some error occurred during content copy or file mov... | python | def copy_content(origin, dstPath, blockSize, mode):
''' copy the content of `origin` to `dstPath` in a safe manner.
this function will first copy the content to a temporary file
and then move it atomically to the requested destination.
if some error occurred during content copy or file mov... | [
"def",
"copy_content",
"(",
"origin",
",",
"dstPath",
",",
"blockSize",
",",
"mode",
")",
":",
"tmpFD",
",",
"tmpPath",
"=",
"tempfile",
".",
"mkstemp",
"(",
"prefix",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"dstPath",
")",
"+",
"\"_\"",
",",
"... | copy the content of `origin` to `dstPath` in a safe manner.
this function will first copy the content to a temporary file
and then move it atomically to the requested destination.
if some error occurred during content copy or file movement
the temporary file will be deleted. | [
"copy",
"the",
"content",
"of",
"origin",
"to",
"dstPath",
"in",
"a",
"safe",
"manner",
"."
] | train | https://github.com/ael-code/pyFsdb/blob/de33a0d41373307cb32cdd7ba1991b85ff495ee3/fsdb/utils.py#L27-L65 |
jf-parent/brome | brome/runner/grid_runner.py | GridRunner.execute | def execute(self):
"""Execute the test batch
"""
try:
# START SELENIUM GRID
if BROME_CONFIG['grid_runner']['start_selenium_server']:
self.start_selenium_server()
# Get all the browsers id
self.browsers_id = BROME_CONFIG['runner_ar... | python | def execute(self):
"""Execute the test batch
"""
try:
# START SELENIUM GRID
if BROME_CONFIG['grid_runner']['start_selenium_server']:
self.start_selenium_server()
# Get all the browsers id
self.browsers_id = BROME_CONFIG['runner_ar... | [
"def",
"execute",
"(",
"self",
")",
":",
"try",
":",
"# START SELENIUM GRID",
"if",
"BROME_CONFIG",
"[",
"'grid_runner'",
"]",
"[",
"'start_selenium_server'",
"]",
":",
"self",
".",
"start_selenium_server",
"(",
")",
"# Get all the browsers id",
"self",
".",
"brow... | Execute the test batch | [
"Execute",
"the",
"test",
"batch"
] | train | https://github.com/jf-parent/brome/blob/784f45d96b83b703dd2181cb59ca8ea777c2510e/brome/runner/grid_runner.py#L38-L226 |
jf-parent/brome | brome/runner/grid_runner.py | GridRunner.run | def run(self):
"""Run all the test in the test batch
"""
executed_tests = []
try:
active_thread = 0
start_thread = True
current_index = 0
active_thread_by_browser_id = {}
test_index_by_browser_id = {}
for browser_... | python | def run(self):
"""Run all the test in the test batch
"""
executed_tests = []
try:
active_thread = 0
start_thread = True
current_index = 0
active_thread_by_browser_id = {}
test_index_by_browser_id = {}
for browser_... | [
"def",
"run",
"(",
"self",
")",
":",
"executed_tests",
"=",
"[",
"]",
"try",
":",
"active_thread",
"=",
"0",
"start_thread",
"=",
"True",
"current_index",
"=",
"0",
"active_thread_by_browser_id",
"=",
"{",
"}",
"test_index_by_browser_id",
"=",
"{",
"}",
"for... | Run all the test in the test batch | [
"Run",
"all",
"the",
"test",
"in",
"the",
"test",
"batch"
] | train | https://github.com/jf-parent/brome/blob/784f45d96b83b703dd2181cb59ca8ea777c2510e/brome/runner/grid_runner.py#L233-L333 |
jf-parent/brome | brome/runner/grid_runner.py | GridRunner.tear_down_instances | def tear_down_instances(self):
"""Tear down all instances
"""
self.info_log('Tearing down all instances...')
for instance in self.alive_instances:
instance.tear_down()
self.info_log('[Done]Tearing down all instances') | python | def tear_down_instances(self):
"""Tear down all instances
"""
self.info_log('Tearing down all instances...')
for instance in self.alive_instances:
instance.tear_down()
self.info_log('[Done]Tearing down all instances') | [
"def",
"tear_down_instances",
"(",
"self",
")",
":",
"self",
".",
"info_log",
"(",
"'Tearing down all instances...'",
")",
"for",
"instance",
"in",
"self",
".",
"alive_instances",
":",
"instance",
".",
"tear_down",
"(",
")",
"self",
".",
"info_log",
"(",
"'[Do... | Tear down all instances | [
"Tear",
"down",
"all",
"instances"
] | train | https://github.com/jf-parent/brome/blob/784f45d96b83b703dd2181cb59ca8ea777c2510e/brome/runner/grid_runner.py#L364-L373 |
jf-parent/brome | brome/runner/grid_runner.py | GridRunner.start_selenium_server | def start_selenium_server(self):
"""Start the selenium server
"""
ip = BROME_CONFIG['grid_runner']['selenium_server_ip']
port = BROME_CONFIG['grid_runner']['selenium_server_port']
def is_selenium_server_is_running():
s = socket.socket(socket.AF_INET, socket.SOCK_STR... | python | def start_selenium_server(self):
"""Start the selenium server
"""
ip = BROME_CONFIG['grid_runner']['selenium_server_ip']
port = BROME_CONFIG['grid_runner']['selenium_server_port']
def is_selenium_server_is_running():
s = socket.socket(socket.AF_INET, socket.SOCK_STR... | [
"def",
"start_selenium_server",
"(",
"self",
")",
":",
"ip",
"=",
"BROME_CONFIG",
"[",
"'grid_runner'",
"]",
"[",
"'selenium_server_ip'",
"]",
"port",
"=",
"BROME_CONFIG",
"[",
"'grid_runner'",
"]",
"[",
"'selenium_server_port'",
"]",
"def",
"is_selenium_server_is_r... | Start the selenium server | [
"Start",
"the",
"selenium",
"server"
] | train | https://github.com/jf-parent/brome/blob/784f45d96b83b703dd2181cb59ca8ea777c2510e/brome/runner/grid_runner.py#L375-L440 |
jf-parent/brome | brome/runner/browser_config.py | BrowserConfig.validate_config | def validate_config(self):
"""Validate that the browser config contains all the needed config
"""
# LOCALHOST
if self.location == 'localhost':
if 'browserName' not in self.config.keys():
msg = "Add the 'browserName' in your local_config: e.g.: 'Firefox', 'Chr... | python | def validate_config(self):
"""Validate that the browser config contains all the needed config
"""
# LOCALHOST
if self.location == 'localhost':
if 'browserName' not in self.config.keys():
msg = "Add the 'browserName' in your local_config: e.g.: 'Firefox', 'Chr... | [
"def",
"validate_config",
"(",
"self",
")",
":",
"# LOCALHOST",
"if",
"self",
".",
"location",
"==",
"'localhost'",
":",
"if",
"'browserName'",
"not",
"in",
"self",
".",
"config",
".",
"keys",
"(",
")",
":",
"msg",
"=",
"\"Add the 'browserName' in your local_c... | Validate that the browser config contains all the needed config | [
"Validate",
"that",
"the",
"browser",
"config",
"contains",
"all",
"the",
"needed",
"config"
] | train | https://github.com/jf-parent/brome/blob/784f45d96b83b703dd2181cb59ca8ea777c2510e/brome/runner/browser_config.py#L42-L59 |
jf-parent/brome | brome/runner/browser_config.py | BrowserConfig.validate_ec2_browser_config | def validate_ec2_browser_config(self):
"""Validate that the ec2 config is conform
"""
if self.config.get('launch', True):
required_keys = [
'browserName',
'platform',
'ssh_key_path',
'username',
'amiid',... | python | def validate_ec2_browser_config(self):
"""Validate that the ec2 config is conform
"""
if self.config.get('launch', True):
required_keys = [
'browserName',
'platform',
'ssh_key_path',
'username',
'amiid',... | [
"def",
"validate_ec2_browser_config",
"(",
"self",
")",
":",
"if",
"self",
".",
"config",
".",
"get",
"(",
"'launch'",
",",
"True",
")",
":",
"required_keys",
"=",
"[",
"'browserName'",
",",
"'platform'",
",",
"'ssh_key_path'",
",",
"'username'",
",",
"'amii... | Validate that the ec2 config is conform | [
"Validate",
"that",
"the",
"ec2",
"config",
"is",
"conform"
] | train | https://github.com/jf-parent/brome/blob/784f45d96b83b703dd2181cb59ca8ea777c2510e/brome/runner/browser_config.py#L79-L124 |
ParthKolekar/parthsql | parthsql/parthsql.py | Database.load_contents | def load_contents(self):
"""
Loads contents of the tables into database.
"""
with open(METADATA_FILE) as f:
lines = f.readlines()
lines = map(lambda x: x.strip(), lines)
exclude_strings = ['<begin_table>', '<end_table>']
list_of_databases_and_co... | python | def load_contents(self):
"""
Loads contents of the tables into database.
"""
with open(METADATA_FILE) as f:
lines = f.readlines()
lines = map(lambda x: x.strip(), lines)
exclude_strings = ['<begin_table>', '<end_table>']
list_of_databases_and_co... | [
"def",
"load_contents",
"(",
"self",
")",
":",
"with",
"open",
"(",
"METADATA_FILE",
")",
"as",
"f",
":",
"lines",
"=",
"f",
".",
"readlines",
"(",
")",
"lines",
"=",
"map",
"(",
"lambda",
"x",
":",
"x",
".",
"strip",
"(",
")",
",",
"lines",
")",... | Loads contents of the tables into database. | [
"Loads",
"contents",
"of",
"the",
"tables",
"into",
"database",
"."
] | train | https://github.com/ParthKolekar/parthsql/blob/98b69448aeaca1331c9db29bc85e731702a6b0d9/parthsql/parthsql.py#L28-L55 |
ParthKolekar/parthsql | parthsql/parthsql.py | Database.store_contents | def store_contents(self):
"""
Stores the contents of tables into file.
"""
string_buffer = os.linesep.join(
map(
lambda x: os.linesep.join(
["<begin_table>"] + [x.name] + x.columns + ["<end_table>"]
),
se... | python | def store_contents(self):
"""
Stores the contents of tables into file.
"""
string_buffer = os.linesep.join(
map(
lambda x: os.linesep.join(
["<begin_table>"] + [x.name] + x.columns + ["<end_table>"]
),
se... | [
"def",
"store_contents",
"(",
"self",
")",
":",
"string_buffer",
"=",
"os",
".",
"linesep",
".",
"join",
"(",
"map",
"(",
"lambda",
"x",
":",
"os",
".",
"linesep",
".",
"join",
"(",
"[",
"\"<begin_table>\"",
"]",
"+",
"[",
"x",
".",
"name",
"]",
"+... | Stores the contents of tables into file. | [
"Stores",
"the",
"contents",
"of",
"tables",
"into",
"file",
"."
] | train | https://github.com/ParthKolekar/parthsql/blob/98b69448aeaca1331c9db29bc85e731702a6b0d9/parthsql/parthsql.py#L57-L74 |
ParthKolekar/parthsql | parthsql/parthsql.py | Database.delete_table | def delete_table(self, tablename):
"""
Deletes a table from the database.
"""
self.tables = filter(lambda x: x.name != tablename, self.tables) | python | def delete_table(self, tablename):
"""
Deletes a table from the database.
"""
self.tables = filter(lambda x: x.name != tablename, self.tables) | [
"def",
"delete_table",
"(",
"self",
",",
"tablename",
")",
":",
"self",
".",
"tables",
"=",
"filter",
"(",
"lambda",
"x",
":",
"x",
".",
"name",
"!=",
"tablename",
",",
"self",
".",
"tables",
")"
] | Deletes a table from the database. | [
"Deletes",
"a",
"table",
"from",
"the",
"database",
"."
] | train | https://github.com/ParthKolekar/parthsql/blob/98b69448aeaca1331c9db29bc85e731702a6b0d9/parthsql/parthsql.py#L91-L95 |
ParthKolekar/parthsql | parthsql/parthsql.py | Database.get_table | def get_table(self, tablename):
"""
Returns the table whoose name is tablename.
"""
temp = filter(lambda x: x.name == tablename, self.tables)
if temp == list():
raise Exception("No such table")
return temp[0] | python | def get_table(self, tablename):
"""
Returns the table whoose name is tablename.
"""
temp = filter(lambda x: x.name == tablename, self.tables)
if temp == list():
raise Exception("No such table")
return temp[0] | [
"def",
"get_table",
"(",
"self",
",",
"tablename",
")",
":",
"temp",
"=",
"filter",
"(",
"lambda",
"x",
":",
"x",
".",
"name",
"==",
"tablename",
",",
"self",
".",
"tables",
")",
"if",
"temp",
"==",
"list",
"(",
")",
":",
"raise",
"Exception",
"(",... | Returns the table whoose name is tablename. | [
"Returns",
"the",
"table",
"whoose",
"name",
"is",
"tablename",
"."
] | train | https://github.com/ParthKolekar/parthsql/blob/98b69448aeaca1331c9db29bc85e731702a6b0d9/parthsql/parthsql.py#L97-L104 |
ParthKolekar/parthsql | parthsql/parthsql.py | Table.get_column_list_prefixed | def get_column_list_prefixed(self):
"""
Returns a list of columns
"""
return map(
lambda x: ".".join([self.name, x]),
self.columns
) | python | def get_column_list_prefixed(self):
"""
Returns a list of columns
"""
return map(
lambda x: ".".join([self.name, x]),
self.columns
) | [
"def",
"get_column_list_prefixed",
"(",
"self",
")",
":",
"return",
"map",
"(",
"lambda",
"x",
":",
"\".\"",
".",
"join",
"(",
"[",
"self",
".",
"name",
",",
"x",
"]",
")",
",",
"self",
".",
"columns",
")"
] | Returns a list of columns | [
"Returns",
"a",
"list",
"of",
"columns"
] | train | https://github.com/ParthKolekar/parthsql/blob/98b69448aeaca1331c9db29bc85e731702a6b0d9/parthsql/parthsql.py#L136-L143 |
ParthKolekar/parthsql | parthsql/parthsql.py | Table.get_column | def get_column(self, column):
"""
Return the values having of column.
"""
if "(" in str(column):
temp_list = column.split("(")
key = temp_list[1].strip("()")
func = temp_list[0].lower()
else:
key = column
func = None... | python | def get_column(self, column):
"""
Return the values having of column.
"""
if "(" in str(column):
temp_list = column.split("(")
key = temp_list[1].strip("()")
func = temp_list[0].lower()
else:
key = column
func = None... | [
"def",
"get_column",
"(",
"self",
",",
"column",
")",
":",
"if",
"\"(\"",
"in",
"str",
"(",
"column",
")",
":",
"temp_list",
"=",
"column",
".",
"split",
"(",
"\"(\"",
")",
"key",
"=",
"temp_list",
"[",
"1",
"]",
".",
"strip",
"(",
"\"()\"",
")",
... | Return the values having of column. | [
"Return",
"the",
"values",
"having",
"of",
"column",
"."
] | train | https://github.com/ParthKolekar/parthsql/blob/98b69448aeaca1331c9db29bc85e731702a6b0d9/parthsql/parthsql.py#L145-L188 |
ParthKolekar/parthsql | parthsql/parthsql.py | Table.delete_row | def delete_row(self, key, value):
"""
Deletes the rows where key = value.
"""
self.rows = filter(lambda x: x.get(key) != value, self.rows) | python | def delete_row(self, key, value):
"""
Deletes the rows where key = value.
"""
self.rows = filter(lambda x: x.get(key) != value, self.rows) | [
"def",
"delete_row",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"rows",
"=",
"filter",
"(",
"lambda",
"x",
":",
"x",
".",
"get",
"(",
"key",
")",
"!=",
"value",
",",
"self",
".",
"rows",
")"
] | Deletes the rows where key = value. | [
"Deletes",
"the",
"rows",
"where",
"key",
"=",
"value",
"."
] | train | https://github.com/ParthKolekar/parthsql/blob/98b69448aeaca1331c9db29bc85e731702a6b0d9/parthsql/parthsql.py#L211-L215 |
ParthKolekar/parthsql | parthsql/parthsql.py | Table.invert_delete_row | def invert_delete_row(self, key, value):
"""
Inverts delete_row and returns the rows where key = value
"""
self.rows = filter(lambda x: x.get(key) == value, self.rows) | python | def invert_delete_row(self, key, value):
"""
Inverts delete_row and returns the rows where key = value
"""
self.rows = filter(lambda x: x.get(key) == value, self.rows) | [
"def",
"invert_delete_row",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"rows",
"=",
"filter",
"(",
"lambda",
"x",
":",
"x",
".",
"get",
"(",
"key",
")",
"==",
"value",
",",
"self",
".",
"rows",
")"
] | Inverts delete_row and returns the rows where key = value | [
"Inverts",
"delete_row",
"and",
"returns",
"the",
"rows",
"where",
"key",
"=",
"value"
] | train | https://github.com/ParthKolekar/parthsql/blob/98b69448aeaca1331c9db29bc85e731702a6b0d9/parthsql/parthsql.py#L217-L221 |
ParthKolekar/parthsql | parthsql/parthsql.py | Table.invert_delete_row2 | def invert_delete_row2(self, key, value):
"""
Invert of type two where there are two columns given
"""
self.rows = filter(lambda x: x.get(key) == x.get(value), self.rows) | python | def invert_delete_row2(self, key, value):
"""
Invert of type two where there are two columns given
"""
self.rows = filter(lambda x: x.get(key) == x.get(value), self.rows) | [
"def",
"invert_delete_row2",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"rows",
"=",
"filter",
"(",
"lambda",
"x",
":",
"x",
".",
"get",
"(",
"key",
")",
"==",
"x",
".",
"get",
"(",
"value",
")",
",",
"self",
".",
"rows",
")"... | Invert of type two where there are two columns given | [
"Invert",
"of",
"type",
"two",
"where",
"there",
"are",
"two",
"columns",
"given"
] | train | https://github.com/ParthKolekar/parthsql/blob/98b69448aeaca1331c9db29bc85e731702a6b0d9/parthsql/parthsql.py#L223-L227 |
ParthKolekar/parthsql | parthsql/parthsql.py | Table.load_contents | def load_contents(self):
"""
Loads contents of Database from a filename database.csv.
"""
with open(self.name + ".csv") as f:
list_of_rows = f.readlines()
list_of_rows = map(
lambda x: x.strip(),
map(
lambda x: x.replace("\... | python | def load_contents(self):
"""
Loads contents of Database from a filename database.csv.
"""
with open(self.name + ".csv") as f:
list_of_rows = f.readlines()
list_of_rows = map(
lambda x: x.strip(),
map(
lambda x: x.replace("\... | [
"def",
"load_contents",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"name",
"+",
"\".csv\"",
")",
"as",
"f",
":",
"list_of_rows",
"=",
"f",
".",
"readlines",
"(",
")",
"list_of_rows",
"=",
"map",
"(",
"lambda",
"x",
":",
"x",
".",
"str... | Loads contents of Database from a filename database.csv. | [
"Loads",
"contents",
"of",
"Database",
"from",
"a",
"filename",
"database",
".",
"csv",
"."
] | train | https://github.com/ParthKolekar/parthsql/blob/98b69448aeaca1331c9db29bc85e731702a6b0d9/parthsql/parthsql.py#L229-L245 |
ParthKolekar/parthsql | parthsql/parthsql.py | Table.store_contents | def store_contents(self):
"""
Stores contests of the Database into a filename database.csv.
"""
string_buffer = os.linesep.join(
map(
lambda x: ",".join(x),
map(
lambda x: map(
str,
... | python | def store_contents(self):
"""
Stores contests of the Database into a filename database.csv.
"""
string_buffer = os.linesep.join(
map(
lambda x: ",".join(x),
map(
lambda x: map(
str,
... | [
"def",
"store_contents",
"(",
"self",
")",
":",
"string_buffer",
"=",
"os",
".",
"linesep",
".",
"join",
"(",
"map",
"(",
"lambda",
"x",
":",
"\",\"",
".",
"join",
"(",
"x",
")",
",",
"map",
"(",
"lambda",
"x",
":",
"map",
"(",
"str",
",",
"x",
... | Stores contests of the Database into a filename database.csv. | [
"Stores",
"contests",
"of",
"the",
"Database",
"into",
"a",
"filename",
"database",
".",
"csv",
"."
] | train | https://github.com/ParthKolekar/parthsql/blob/98b69448aeaca1331c9db29bc85e731702a6b0d9/parthsql/parthsql.py#L247-L266 |
ParthKolekar/parthsql | parthsql/parthsql.py | Table.print_contents | def print_contents(self):
"""
Prints Contents of Table.
"""
print "\t\t\t".join(self.columns)
temp_list = []
for i in self.columns:
temp_list.append(self.get_column(i))
for i in zip(*(temp_list)):
print "\t\t\t".join(map(str, i)) | python | def print_contents(self):
"""
Prints Contents of Table.
"""
print "\t\t\t".join(self.columns)
temp_list = []
for i in self.columns:
temp_list.append(self.get_column(i))
for i in zip(*(temp_list)):
print "\t\t\t".join(map(str, i)) | [
"def",
"print_contents",
"(",
"self",
")",
":",
"print",
"\"\\t\\t\\t\"",
".",
"join",
"(",
"self",
".",
"columns",
")",
"temp_list",
"=",
"[",
"]",
"for",
"i",
"in",
"self",
".",
"columns",
":",
"temp_list",
".",
"append",
"(",
"self",
".",
"get_colum... | Prints Contents of Table. | [
"Prints",
"Contents",
"of",
"Table",
"."
] | train | https://github.com/ParthKolekar/parthsql/blob/98b69448aeaca1331c9db29bc85e731702a6b0d9/parthsql/parthsql.py#L268-L277 |
praekelt/django-moderator | moderator/admin.py | CommentReplyAdmin.formfield_for_foreignkey | def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
"""
Limit canned reply options to those with same site as comment.
"""
field = super(CommentReplyAdmin, self).\
formfield_for_foreignkey(db_field, request, **kwargs)
comment_id = request.GET.get(sel... | python | def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
"""
Limit canned reply options to those with same site as comment.
"""
field = super(CommentReplyAdmin, self).\
formfield_for_foreignkey(db_field, request, **kwargs)
comment_id = request.GET.get(sel... | [
"def",
"formfield_for_foreignkey",
"(",
"self",
",",
"db_field",
",",
"request",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"field",
"=",
"super",
"(",
"CommentReplyAdmin",
",",
"self",
")",
".",
"formfield_for_foreignkey",
"(",
"db_field",
",",
"reques... | Limit canned reply options to those with same site as comment. | [
"Limit",
"canned",
"reply",
"options",
"to",
"those",
"with",
"same",
"site",
"as",
"comment",
"."
] | train | https://github.com/praekelt/django-moderator/blob/72f1d5259128ff5a1a0341d4a573bfd561ba4665/moderator/admin.py#L38-L53 |
praekelt/django-moderator | moderator/admin.py | CommentAdmin.queryset | def queryset(self, request):
"""
Exclude replies from listing since they are displayed inline as part of
listing.
For proxy models with cls apptribute limit comments to those classified
as cls.
"""
qs = super(CommentAdmin, self).queryset(request)
qs = qs.... | python | def queryset(self, request):
"""
Exclude replies from listing since they are displayed inline as part of
listing.
For proxy models with cls apptribute limit comments to those classified
as cls.
"""
qs = super(CommentAdmin, self).queryset(request)
qs = qs.... | [
"def",
"queryset",
"(",
"self",
",",
"request",
")",
":",
"qs",
"=",
"super",
"(",
"CommentAdmin",
",",
"self",
")",
".",
"queryset",
"(",
"request",
")",
"qs",
"=",
"qs",
".",
"filter",
"(",
"Q",
"(",
"user__is_staff",
"=",
"False",
")",
"|",
"Q",... | Exclude replies from listing since they are displayed inline as part of
listing.
For proxy models with cls apptribute limit comments to those classified
as cls. | [
"Exclude",
"replies",
"from",
"listing",
"since",
"they",
"are",
"displayed",
"inline",
"as",
"part",
"of",
"listing",
"."
] | train | https://github.com/praekelt/django-moderator/blob/72f1d5259128ff5a1a0341d4a573bfd561ba4665/moderator/admin.py#L86-L102 |
praekelt/django-moderator | moderator/admin.py | AdminModeratorMixin.moderate_view | def moderate_view(self, request, object_id, extra_context=None):
"""
Handles moderate object tool through a somewhat hacky changelist view
whose queryset is altered via CommentAdmin.get_changelist to only list
comments for the object under review.
"""
opts = self.model._m... | python | def moderate_view(self, request, object_id, extra_context=None):
"""
Handles moderate object tool through a somewhat hacky changelist view
whose queryset is altered via CommentAdmin.get_changelist to only list
comments for the object under review.
"""
opts = self.model._m... | [
"def",
"moderate_view",
"(",
"self",
",",
"request",
",",
"object_id",
",",
"extra_context",
"=",
"None",
")",
":",
"opts",
"=",
"self",
".",
"model",
".",
"_meta",
"app_label",
"=",
"opts",
".",
"app_label",
"view",
"=",
"CommentAdmin",
"(",
"model",
"=... | Handles moderate object tool through a somewhat hacky changelist view
whose queryset is altered via CommentAdmin.get_changelist to only list
comments for the object under review. | [
"Handles",
"moderate",
"object",
"tool",
"through",
"a",
"somewhat",
"hacky",
"changelist",
"view",
"whose",
"queryset",
"is",
"altered",
"via",
"CommentAdmin",
".",
"get_changelist",
"to",
"only",
"list",
"comments",
"for",
"the",
"object",
"under",
"review",
"... | train | https://github.com/praekelt/django-moderator/blob/72f1d5259128ff5a1a0341d4a573bfd561ba4665/moderator/admin.py#L351-L386 |
limodou/par | par/bootstrap_ext.py | bootstrap_alert | def bootstrap_alert(visitor, items):
"""
Format:
[[alert(class=error)]]:
message
"""
txt = []
for x in items:
cls = x['kwargs'].get('class', '')
if cls:
cls = 'alert-%s' % cls
txt.append('<div class="alert %s">' % cls)
if 'clos... | python | def bootstrap_alert(visitor, items):
"""
Format:
[[alert(class=error)]]:
message
"""
txt = []
for x in items:
cls = x['kwargs'].get('class', '')
if cls:
cls = 'alert-%s' % cls
txt.append('<div class="alert %s">' % cls)
if 'clos... | [
"def",
"bootstrap_alert",
"(",
"visitor",
",",
"items",
")",
":",
"txt",
"=",
"[",
"]",
"for",
"x",
"in",
"items",
":",
"cls",
"=",
"x",
"[",
"'kwargs'",
"]",
".",
"get",
"(",
"'class'",
",",
"''",
")",
"if",
"cls",
":",
"cls",
"=",
"'alert-%s'",... | Format:
[[alert(class=error)]]:
message | [
"Format",
":",
"[[",
"alert",
"(",
"class",
"=",
"error",
")",
"]]",
":",
"message"
] | train | https://github.com/limodou/par/blob/0863c339c8d0d46f8516eb4577b459b9cf2dec8d/par/bootstrap_ext.py#L36-L54 |
limodou/par | par/bootstrap_ext.py | new_bootstrap_alert | def new_bootstrap_alert(visitor, block):
"""
Format:
{% alert class=error %}
message
{% endalert %}
"""
if 'new' in block:
txt = []
cls = block['kwargs'].get('class', '')
if cls:
cls = 'alert-%s' % cls
txt.append('<div class="a... | python | def new_bootstrap_alert(visitor, block):
"""
Format:
{% alert class=error %}
message
{% endalert %}
"""
if 'new' in block:
txt = []
cls = block['kwargs'].get('class', '')
if cls:
cls = 'alert-%s' % cls
txt.append('<div class="a... | [
"def",
"new_bootstrap_alert",
"(",
"visitor",
",",
"block",
")",
":",
"if",
"'new'",
"in",
"block",
":",
"txt",
"=",
"[",
"]",
"cls",
"=",
"block",
"[",
"'kwargs'",
"]",
".",
"get",
"(",
"'class'",
",",
"''",
")",
"if",
"cls",
":",
"cls",
"=",
"'... | Format:
{% alert class=error %}
message
{% endalert %} | [
"Format",
":",
"{",
"%",
"alert",
"class",
"=",
"error",
"%",
"}",
"message",
"{",
"%",
"endalert",
"%",
"}"
] | train | https://github.com/limodou/par/blob/0863c339c8d0d46f8516eb4577b459b9cf2dec8d/par/bootstrap_ext.py#L56-L77 |
jf-parent/brome | brome/runner/local_runner.py | LocalRunner.execute | def execute(self):
"""Execute the test batch
"""
self.browser_config = BrowserConfig(
runner=self,
browser_id=BROME_CONFIG['runner_args']['localhost_runner'],
browsers_config=BROME_CONFIG['browsers_config']
)
try:
self.run()
... | python | def execute(self):
"""Execute the test batch
"""
self.browser_config = BrowserConfig(
runner=self,
browser_id=BROME_CONFIG['runner_args']['localhost_runner'],
browsers_config=BROME_CONFIG['browsers_config']
)
try:
self.run()
... | [
"def",
"execute",
"(",
"self",
")",
":",
"self",
".",
"browser_config",
"=",
"BrowserConfig",
"(",
"runner",
"=",
"self",
",",
"browser_id",
"=",
"BROME_CONFIG",
"[",
"'runner_args'",
"]",
"[",
"'localhost_runner'",
"]",
",",
"browsers_config",
"=",
"BROME_CON... | Execute the test batch | [
"Execute",
"the",
"test",
"batch"
] | train | https://github.com/jf-parent/brome/blob/784f45d96b83b703dd2181cb59ca8ea777c2510e/brome/runner/local_runner.py#L21-L41 |
jf-parent/brome | brome/runner/local_runner.py | LocalRunner.run | def run(self):
"""Run the test batch
"""
self.info_log("The test batch is ready.")
self.executed_tests = []
for test in self.tests:
localhost_instance = LocalhostInstance(
runner=self,
browser_config=self.browser_config,
... | python | def run(self):
"""Run the test batch
"""
self.info_log("The test batch is ready.")
self.executed_tests = []
for test in self.tests:
localhost_instance = LocalhostInstance(
runner=self,
browser_config=self.browser_config,
... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"info_log",
"(",
"\"The test batch is ready.\"",
")",
"self",
".",
"executed_tests",
"=",
"[",
"]",
"for",
"test",
"in",
"self",
".",
"tests",
":",
"localhost_instance",
"=",
"LocalhostInstance",
"(",
"runner... | Run the test batch | [
"Run",
"the",
"test",
"batch"
] | train | https://github.com/jf-parent/brome/blob/784f45d96b83b703dd2181cb59ca8ea777c2510e/brome/runner/local_runner.py#L43-L78 |
jf-parent/brome | brome/runner/local_runner.py | LocalRunner.terminate | def terminate(self):
"""Terminate the test batch
"""
self.info_log('The test batch is finished.')
with DbSessionContext(BROME_CONFIG['database']['mongo_database_name']) as session: # noqa
test_batch = session.query(Testbatch)\
.filter(Testbatch.mongo_id == ... | python | def terminate(self):
"""Terminate the test batch
"""
self.info_log('The test batch is finished.')
with DbSessionContext(BROME_CONFIG['database']['mongo_database_name']) as session: # noqa
test_batch = session.query(Testbatch)\
.filter(Testbatch.mongo_id == ... | [
"def",
"terminate",
"(",
"self",
")",
":",
"self",
".",
"info_log",
"(",
"'The test batch is finished.'",
")",
"with",
"DbSessionContext",
"(",
"BROME_CONFIG",
"[",
"'database'",
"]",
"[",
"'mongo_database_name'",
"]",
")",
"as",
"session",
":",
"# noqa",
"test_... | Terminate the test batch | [
"Terminate",
"the",
"test",
"batch"
] | train | https://github.com/jf-parent/brome/blob/784f45d96b83b703dd2181cb59ca8ea777c2510e/brome/runner/local_runner.py#L80-L93 |
Carbonara-Project/Guanciale | guanciale/idblib.py | idaunpack | def idaunpack(buf):
"""
Special data packing format, used in struct definitions, and .id2 files
sdk functions: pack_dd etc.
"""
buf = bytearray(buf)
def nextval(o):
val = buf[o] ; o += 1
if val == 0xff: # 32 bit value
val, = struct.unpack_from(">L", buf,... | python | def idaunpack(buf):
"""
Special data packing format, used in struct definitions, and .id2 files
sdk functions: pack_dd etc.
"""
buf = bytearray(buf)
def nextval(o):
val = buf[o] ; o += 1
if val == 0xff: # 32 bit value
val, = struct.unpack_from(">L", buf,... | [
"def",
"idaunpack",
"(",
"buf",
")",
":",
"buf",
"=",
"bytearray",
"(",
"buf",
")",
"def",
"nextval",
"(",
"o",
")",
":",
"val",
"=",
"buf",
"[",
"o",
"]",
"o",
"+=",
"1",
"if",
"val",
"==",
"0xff",
":",
"# 32 bit value\r",
"val",
",",
"=",
"st... | Special data packing format, used in struct definitions, and .id2 files
sdk functions: pack_dd etc. | [
"Special",
"data",
"packing",
"format",
"used",
"in",
"struct",
"definitions",
"and",
".",
"id2",
"files",
"sdk",
"functions",
":",
"pack_dd",
"etc",
"."
] | train | https://github.com/Carbonara-Project/Guanciale/blob/c239ffac6fb481d09c4071d1de1a09f60dc584ab/guanciale/idblib.py#L161-L194 |
Carbonara-Project/Guanciale | guanciale/idblib.py | binary_search | def binary_search(a, k):
"""
Do a binary search in an array of objects ordered by '.key'
returns the largest index for which: a[i].key <= k
like c++: a.upperbound(k)--
"""
first, last = 0, len(a)
while first < last:
mid = (first + last) >> 1
if k < a[mid].key:
... | python | def binary_search(a, k):
"""
Do a binary search in an array of objects ordered by '.key'
returns the largest index for which: a[i].key <= k
like c++: a.upperbound(k)--
"""
first, last = 0, len(a)
while first < last:
mid = (first + last) >> 1
if k < a[mid].key:
... | [
"def",
"binary_search",
"(",
"a",
",",
"k",
")",
":",
"first",
",",
"last",
"=",
"0",
",",
"len",
"(",
"a",
")",
"while",
"first",
"<",
"last",
":",
"mid",
"=",
"(",
"first",
"+",
"last",
")",
">>",
"1",
"if",
"k",
"<",
"a",
"[",
"mid",
"]"... | Do a binary search in an array of objects ordered by '.key'
returns the largest index for which: a[i].key <= k
like c++: a.upperbound(k)-- | [
"Do",
"a",
"binary",
"search",
"in",
"an",
"array",
"of",
"objects",
"ordered",
"by",
".",
"key",
"returns",
"the",
"largest",
"index",
"for",
"which",
":",
"a",
"[",
"i",
"]",
".",
"key",
"<",
"=",
"k",
"like",
"c",
"++",
":",
"a",
".",
"upperbo... | train | https://github.com/Carbonara-Project/Guanciale/blob/c239ffac6fb481d09c4071d1de1a09f60dc584ab/guanciale/idblib.py#L351-L366 |
Carbonara-Project/Guanciale | guanciale/idblib.py | IDBFile.getsectioninfo | def getsectioninfo(self, i):
"""
Returns a tuple with section parameters by index.
The parameteres are:
* compression flag
* data offset
* data size
* data checksum
Sections are stored in a fixed order: id0, id1, nam, seg, til, id2
... | python | def getsectioninfo(self, i):
"""
Returns a tuple with section parameters by index.
The parameteres are:
* compression flag
* data offset
* data size
* data checksum
Sections are stored in a fixed order: id0, id1, nam, seg, til, id2
... | [
"def",
"getsectioninfo",
"(",
"self",
",",
"i",
")",
":",
"if",
"not",
"0",
"<=",
"i",
"<",
"len",
"(",
"self",
".",
"offsets",
")",
":",
"return",
"0",
",",
"0",
",",
"0",
",",
"0",
"if",
"self",
".",
"offsets",
"[",
"i",
"]",
"==",
"0",
"... | Returns a tuple with section parameters by index.
The parameteres are:
* compression flag
* data offset
* data size
* data checksum
Sections are stored in a fixed order: id0, id1, nam, seg, til, id2 | [
"Returns",
"a",
"tuple",
"with",
"section",
"parameters",
"by",
"index",
".",
"The",
"parameteres",
"are",
":",
"*",
"compression",
"flag",
"*",
"data",
"offset",
"*",
"data",
"size",
"*",
"data",
"checksum",
"Sections",
"are",
"stored",
"in",
"a",
"fixed"... | train | https://github.com/Carbonara-Project/Guanciale/blob/c239ffac6fb481d09c4071d1de1a09f60dc584ab/guanciale/idblib.py#L252-L277 |
Carbonara-Project/Guanciale | guanciale/idblib.py | IDBFile.getpart | def getpart(self, ix):
"""
Returns a fileobject for the specified section.
This method optionally decompresses the data found in the .idb file,
and returns a file-like object, with seek, read, tell.
"""
if self.offsets[ix] == 0:
return
comp... | python | def getpart(self, ix):
"""
Returns a fileobject for the specified section.
This method optionally decompresses the data found in the .idb file,
and returns a file-like object, with seek, read, tell.
"""
if self.offsets[ix] == 0:
return
comp... | [
"def",
"getpart",
"(",
"self",
",",
"ix",
")",
":",
"if",
"self",
".",
"offsets",
"[",
"ix",
"]",
"==",
"0",
":",
"return",
"comp",
",",
"ofs",
",",
"size",
",",
"checksum",
"=",
"self",
".",
"getsectioninfo",
"(",
"ix",
")",
"fh",
"=",
"FileSect... | Returns a fileobject for the specified section.
This method optionally decompresses the data found in the .idb file,
and returns a file-like object, with seek, read, tell. | [
"Returns",
"a",
"fileobject",
"for",
"the",
"specified",
"section",
".",
"This",
"method",
"optionally",
"decompresses",
"the",
"data",
"found",
"in",
"the",
".",
"idb",
"file",
"and",
"returns",
"a",
"file",
"-",
"like",
"object",
"with",
"seek",
"read",
... | train | https://github.com/Carbonara-Project/Guanciale/blob/c239ffac6fb481d09c4071d1de1a09f60dc584ab/guanciale/idblib.py#L279-L302 |
Carbonara-Project/Guanciale | guanciale/idblib.py | BTree.find | def find(self, rel, key):
"""
Searches for a record with the specified relation to the key
A cursor object is returned, the user can call getkey, getval on the cursor
to retrieve the actual value.
or call cursor.next() / cursor.prev() to enumerate values.
'eq' ... | python | def find(self, rel, key):
"""
Searches for a record with the specified relation to the key
A cursor object is returned, the user can call getkey, getval on the cursor
to retrieve the actual value.
or call cursor.next() / cursor.prev() to enumerate values.
'eq' ... | [
"def",
"find",
"(",
"self",
",",
"rel",
",",
"key",
")",
":",
"# descend tree to leaf nearest to the `key`\r",
"page",
"=",
"self",
".",
"readpage",
"(",
"self",
".",
"firstindex",
")",
"stack",
"=",
"[",
"]",
"while",
"len",
"(",
"stack",
")",
"<",
"256... | Searches for a record with the specified relation to the key
A cursor object is returned, the user can call getkey, getval on the cursor
to retrieve the actual value.
or call cursor.next() / cursor.prev() to enumerate values.
'eq' -> record equal to the key, None when not found
... | [
"Searches",
"for",
"a",
"record",
"with",
"the",
"specified",
"relation",
"to",
"the",
"key",
"A",
"cursor",
"object",
"is",
"returned",
"the",
"user",
"can",
"call",
"getkey",
"getval",
"on",
"the",
"cursor",
"to",
"retrieve",
"the",
"actual",
"value",
".... | train | https://github.com/Carbonara-Project/Guanciale/blob/c239ffac6fb481d09c4071d1de1a09f60dc584ab/guanciale/idblib.py#L668-L713 |
Carbonara-Project/Guanciale | guanciale/idblib.py | BTree.dump | def dump(self):
""" raw dump of all records in the b-tree """
print("pagesize=%08x, reccount=%08x, pagecount=%08x" % (self.pagesize, self.reccount, self.pagecount))
self.dumpfree()
self.dumptree(self.firstindex) | python | def dump(self):
""" raw dump of all records in the b-tree """
print("pagesize=%08x, reccount=%08x, pagecount=%08x" % (self.pagesize, self.reccount, self.pagecount))
self.dumpfree()
self.dumptree(self.firstindex) | [
"def",
"dump",
"(",
"self",
")",
":",
"print",
"(",
"\"pagesize=%08x, reccount=%08x, pagecount=%08x\"",
"%",
"(",
"self",
".",
"pagesize",
",",
"self",
".",
"reccount",
",",
"self",
".",
"pagecount",
")",
")",
"self",
".",
"dumpfree",
"(",
")",
"self",
"."... | raw dump of all records in the b-tree | [
"raw",
"dump",
"of",
"all",
"records",
"in",
"the",
"b",
"-",
"tree"
] | train | https://github.com/Carbonara-Project/Guanciale/blob/c239ffac6fb481d09c4071d1de1a09f60dc584ab/guanciale/idblib.py#L715-L719 |
Carbonara-Project/Guanciale | guanciale/idblib.py | BTree.dumpfree | def dumpfree(self):
""" list all free pages """
fmt = "L" if self.version > 15 else "H"
hdrsize = 8 if self.version > 15 else 4
pn = self.firstfree
if pn == 0:
print("no free pages")
return
while pn:
self.fh.seek(pn * self.page... | python | def dumpfree(self):
""" list all free pages """
fmt = "L" if self.version > 15 else "H"
hdrsize = 8 if self.version > 15 else 4
pn = self.firstfree
if pn == 0:
print("no free pages")
return
while pn:
self.fh.seek(pn * self.page... | [
"def",
"dumpfree",
"(",
"self",
")",
":",
"fmt",
"=",
"\"L\"",
"if",
"self",
".",
"version",
">",
"15",
"else",
"\"H\"",
"hdrsize",
"=",
"8",
"if",
"self",
".",
"version",
">",
"15",
"else",
"4",
"pn",
"=",
"self",
".",
"firstfree",
"if",
"pn",
"... | list all free pages | [
"list",
"all",
"free",
"pages"
] | train | https://github.com/Carbonara-Project/Guanciale/blob/c239ffac6fb481d09c4071d1de1a09f60dc584ab/guanciale/idblib.py#L721-L742 |
Carbonara-Project/Guanciale | guanciale/idblib.py | BTree.dumpindented | def dumpindented(self, pn, indent=0):
"""
Dump all nodes of the current page with keys indented, showing how the `indent`
feature works
"""
page = self.readpage(pn)
print(" " * indent, page)
if page.isindex():
print(" " * indent, end="")
... | python | def dumpindented(self, pn, indent=0):
"""
Dump all nodes of the current page with keys indented, showing how the `indent`
feature works
"""
page = self.readpage(pn)
print(" " * indent, page)
if page.isindex():
print(" " * indent, end="")
... | [
"def",
"dumpindented",
"(",
"self",
",",
"pn",
",",
"indent",
"=",
"0",
")",
":",
"page",
"=",
"self",
".",
"readpage",
"(",
"pn",
")",
"print",
"(",
"\" \"",
"*",
"indent",
",",
"page",
")",
"if",
"page",
".",
"isindex",
"(",
")",
":",
"print",... | Dump all nodes of the current page with keys indented, showing how the `indent`
feature works | [
"Dump",
"all",
"nodes",
"of",
"the",
"current",
"page",
"with",
"keys",
"indented",
"showing",
"how",
"the",
"indent",
"feature",
"works"
] | train | https://github.com/Carbonara-Project/Guanciale/blob/c239ffac6fb481d09c4071d1de1a09f60dc584ab/guanciale/idblib.py#L744-L756 |
Carbonara-Project/Guanciale | guanciale/idblib.py | BTree.dumptree | def dumptree(self, pn):
"""
Walks entire tree, dumping all records on each page
in sequential order
"""
page = self.readpage(pn)
print("%06x: preceeding = %06x, reccount = %04x" % (pn, page.preceeding, page.count))
for ent in page.index:
print(... | python | def dumptree(self, pn):
"""
Walks entire tree, dumping all records on each page
in sequential order
"""
page = self.readpage(pn)
print("%06x: preceeding = %06x, reccount = %04x" % (pn, page.preceeding, page.count))
for ent in page.index:
print(... | [
"def",
"dumptree",
"(",
"self",
",",
"pn",
")",
":",
"page",
"=",
"self",
".",
"readpage",
"(",
"pn",
")",
"print",
"(",
"\"%06x: preceeding = %06x, reccount = %04x\"",
"%",
"(",
"pn",
",",
"page",
".",
"preceeding",
",",
"page",
".",
"count",
")",
")",
... | Walks entire tree, dumping all records on each page
in sequential order | [
"Walks",
"entire",
"tree",
"dumping",
"all",
"records",
"on",
"each",
"page",
"in",
"sequential",
"order"
] | train | https://github.com/Carbonara-Project/Guanciale/blob/c239ffac6fb481d09c4071d1de1a09f60dc584ab/guanciale/idblib.py#L758-L770 |
Carbonara-Project/Guanciale | guanciale/idblib.py | BTree.pagedump | def pagedump(self):
"""
dump the contents of all pages, ignoring links between pages,
this will enable you to view contents of pages which have become
lost due to datacorruption.
"""
self.fh.seek(self.pagesize)
pn = 1
while True:
try:
... | python | def pagedump(self):
"""
dump the contents of all pages, ignoring links between pages,
this will enable you to view contents of pages which have become
lost due to datacorruption.
"""
self.fh.seek(self.pagesize)
pn = 1
while True:
try:
... | [
"def",
"pagedump",
"(",
"self",
")",
":",
"self",
".",
"fh",
".",
"seek",
"(",
"self",
".",
"pagesize",
")",
"pn",
"=",
"1",
"while",
"True",
":",
"try",
":",
"pagedata",
"=",
"self",
".",
"fh",
".",
"read",
"(",
"self",
".",
"pagesize",
")",
"... | dump the contents of all pages, ignoring links between pages,
this will enable you to view contents of pages which have become
lost due to datacorruption. | [
"dump",
"the",
"contents",
"of",
"all",
"pages",
"ignoring",
"links",
"between",
"pages",
"this",
"will",
"enable",
"you",
"to",
"view",
"contents",
"of",
"pages",
"which",
"have",
"become",
"lost",
"due",
"to",
"datacorruption",
"."
] | train | https://github.com/Carbonara-Project/Guanciale/blob/c239ffac6fb481d09c4071d1de1a09f60dc584ab/guanciale/idblib.py#L772-L798 |
Carbonara-Project/Guanciale | guanciale/idblib.py | ID0File.prettykey | def prettykey(self, key):
"""
returns the key in a readable format.
"""
f = list(self.decodekey(key))
f[0] = f[0].decode('utf-8')
if len(f) > 2 and type(f[2]) == bytes:
f[2] = f[2].decode('utf-8')
if f[0] == '.':
if len(f) == 2:
... | python | def prettykey(self, key):
"""
returns the key in a readable format.
"""
f = list(self.decodekey(key))
f[0] = f[0].decode('utf-8')
if len(f) > 2 and type(f[2]) == bytes:
f[2] = f[2].decode('utf-8')
if f[0] == '.':
if len(f) == 2:
... | [
"def",
"prettykey",
"(",
"self",
",",
"key",
")",
":",
"f",
"=",
"list",
"(",
"self",
".",
"decodekey",
"(",
"key",
")",
")",
"f",
"[",
"0",
"]",
"=",
"f",
"[",
"0",
"]",
".",
"decode",
"(",
"'utf-8'",
")",
"if",
"len",
"(",
"f",
")",
">",
... | returns the key in a readable format. | [
"returns",
"the",
"key",
"in",
"a",
"readable",
"format",
"."
] | train | https://github.com/Carbonara-Project/Guanciale/blob/c239ffac6fb481d09c4071d1de1a09f60dc584ab/guanciale/idblib.py#L862-L893 |
Carbonara-Project/Guanciale | guanciale/idblib.py | ID0File.prettyval | def prettyval(self, val):
"""
returns the value in a readable format.
"""
if len(val) == self.wordsize and val[-1:] in (b'\x00', b'\xff'):
return "%x" % struct.unpack("<" + self.fmt, val)
if len(val) == self.wordsize and re.search(b'[\x00-\x08\x0b\x0c\x0e-\x1f]'... | python | def prettyval(self, val):
"""
returns the value in a readable format.
"""
if len(val) == self.wordsize and val[-1:] in (b'\x00', b'\xff'):
return "%x" % struct.unpack("<" + self.fmt, val)
if len(val) == self.wordsize and re.search(b'[\x00-\x08\x0b\x0c\x0e-\x1f]'... | [
"def",
"prettyval",
"(",
"self",
",",
"val",
")",
":",
"if",
"len",
"(",
"val",
")",
"==",
"self",
".",
"wordsize",
"and",
"val",
"[",
"-",
"1",
":",
"]",
"in",
"(",
"b'\\x00'",
",",
"b'\\xff'",
")",
":",
"return",
"\"%x\"",
"%",
"struct",
".",
... | returns the value in a readable format. | [
"returns",
"the",
"value",
"in",
"a",
"readable",
"format",
"."
] | train | https://github.com/Carbonara-Project/Guanciale/blob/c239ffac6fb481d09c4071d1de1a09f60dc584ab/guanciale/idblib.py#L895-L906 |
Carbonara-Project/Guanciale | guanciale/idblib.py | ID0File.nodeByName | def nodeByName(self, name):
""" Return a nodeid by name """
# note: really long names are encoded differently:
# 'N'+'\x00'+pack('Q', nameid) => ofs
# and (ofs, 'N') -> nameid
# at nodebase ( 0xFF000000, 'S', 0x100*nameid ) there is a series of blobs for max 0x80000 s... | python | def nodeByName(self, name):
""" Return a nodeid by name """
# note: really long names are encoded differently:
# 'N'+'\x00'+pack('Q', nameid) => ofs
# and (ofs, 'N') -> nameid
# at nodebase ( 0xFF000000, 'S', 0x100*nameid ) there is a series of blobs for max 0x80000 s... | [
"def",
"nodeByName",
"(",
"self",
",",
"name",
")",
":",
"# note: really long names are encoded differently:\r",
"# 'N'+'\\x00'+pack('Q', nameid) => ofs\r",
"# and (ofs, 'N') -> nameid\r",
"# at nodebase ( 0xFF000000, 'S', 0x100*nameid ) there is a series of blobs for max 0x80000 sized na... | Return a nodeid by name | [
"Return",
"a",
"nodeid",
"by",
"name"
] | train | https://github.com/Carbonara-Project/Guanciale/blob/c239ffac6fb481d09c4071d1de1a09f60dc584ab/guanciale/idblib.py#L908-L917 |
Carbonara-Project/Guanciale | guanciale/idblib.py | ID0File.makekey | def makekey(self, *args):
""" return a binary key for the nodeid, tag and optional value """
if len(args) > 1:
args = args[:1] + (args[1].encode('utf-8'),) + args[2:]
if len(args) == 3 and type(args[-1]) == str:
# node.tag.string type keys
return struct.... | python | def makekey(self, *args):
""" return a binary key for the nodeid, tag and optional value """
if len(args) > 1:
args = args[:1] + (args[1].encode('utf-8'),) + args[2:]
if len(args) == 3 and type(args[-1]) == str:
# node.tag.string type keys
return struct.... | [
"def",
"makekey",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
">",
"1",
":",
"args",
"=",
"args",
"[",
":",
"1",
"]",
"+",
"(",
"args",
"[",
"1",
"]",
".",
"encode",
"(",
"'utf-8'",
")",
",",
")",
"+",
"args",
... | return a binary key for the nodeid, tag and optional value | [
"return",
"a",
"binary",
"key",
"for",
"the",
"nodeid",
"tag",
"and",
"optional",
"value"
] | train | https://github.com/Carbonara-Project/Guanciale/blob/c239ffac6fb481d09c4071d1de1a09f60dc584ab/guanciale/idblib.py#L924-L936 |
Carbonara-Project/Guanciale | guanciale/idblib.py | ID0File.decodekey | def decodekey(self, key):
"""
splits a key in a tuple, one of:
( [ 'N', 'n', '$' ], 0, bignameid )
( [ 'N', 'n', '$' ], name )
( '-', id )
( '.', id )
( '.', id, tag )
( '.', id, tag, value )
( '.', id, 'H... | python | def decodekey(self, key):
"""
splits a key in a tuple, one of:
( [ 'N', 'n', '$' ], 0, bignameid )
( [ 'N', 'n', '$' ], name )
( '-', id )
( '.', id )
( '.', id, tag )
( '.', id, tag, value )
( '.', id, 'H... | [
"def",
"decodekey",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"[",
":",
"1",
"]",
"in",
"(",
"b'n'",
",",
"b'N'",
",",
"b'$'",
")",
":",
"if",
"key",
"[",
"1",
":",
"2",
"]",
"==",
"b\"\\x00\"",
"and",
"len",
"(",
"key",
")",
"==",
"2... | splits a key in a tuple, one of:
( [ 'N', 'n', '$' ], 0, bignameid )
( [ 'N', 'n', '$' ], name )
( '-', id )
( '.', id )
( '.', id, tag )
( '.', id, tag, value )
( '.', id, 'H', name ) | [
"splits",
"a",
"key",
"in",
"a",
"tuple",
"one",
"of",
":",
"(",
"[",
"N",
"n",
"$",
"]",
"0",
"bignameid",
")",
"(",
"[",
"N",
"n",
"$",
"]",
"name",
")",
"(",
"-",
"id",
")",
"(",
".",
"id",
")",
"(",
".",
"id",
"tag",
")",
"(",
".",
... | train | https://github.com/Carbonara-Project/Guanciale/blob/c239ffac6fb481d09c4071d1de1a09f60dc584ab/guanciale/idblib.py#L938-L965 |
Carbonara-Project/Guanciale | guanciale/idblib.py | ID0File.bytes | def bytes(self, *args):
""" return a raw value for the given arguments """
if len(args) == 1 and isinstance(args[0], BTree.Cursor):
cur = args[0]
else:
cur = self.btree.find('eq', self.makekey(*args))
if cur:
return cur.getval() | python | def bytes(self, *args):
""" return a raw value for the given arguments """
if len(args) == 1 and isinstance(args[0], BTree.Cursor):
cur = args[0]
else:
cur = self.btree.find('eq', self.makekey(*args))
if cur:
return cur.getval() | [
"def",
"bytes",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"1",
"and",
"isinstance",
"(",
"args",
"[",
"0",
"]",
",",
"BTree",
".",
"Cursor",
")",
":",
"cur",
"=",
"args",
"[",
"0",
"]",
"else",
":",
"cur",
... | return a raw value for the given arguments | [
"return",
"a",
"raw",
"value",
"for",
"the",
"given",
"arguments"
] | train | https://github.com/Carbonara-Project/Guanciale/blob/c239ffac6fb481d09c4071d1de1a09f60dc584ab/guanciale/idblib.py#L967-L975 |
Carbonara-Project/Guanciale | guanciale/idblib.py | ID0File.int | def int(self, *args):
"""
Return the integer stored in the specified node.
Any type of integer will be decoded: byte, short, long, long long
"""
data = self.bytes(*args)
if data is not None:
if len(data) == 1:
return struct.unpack("... | python | def int(self, *args):
"""
Return the integer stored in the specified node.
Any type of integer will be decoded: byte, short, long, long long
"""
data = self.bytes(*args)
if data is not None:
if len(data) == 1:
return struct.unpack("... | [
"def",
"int",
"(",
"self",
",",
"*",
"args",
")",
":",
"data",
"=",
"self",
".",
"bytes",
"(",
"*",
"args",
")",
"if",
"data",
"is",
"not",
"None",
":",
"if",
"len",
"(",
"data",
")",
"==",
"1",
":",
"return",
"struct",
".",
"unpack",
"(",
"\... | Return the integer stored in the specified node.
Any type of integer will be decoded: byte, short, long, long long | [
"Return",
"the",
"integer",
"stored",
"in",
"the",
"specified",
"node",
".",
"Any",
"type",
"of",
"integer",
"will",
"be",
"decoded",
":",
"byte",
"short",
"long",
"long",
"long"
] | train | https://github.com/Carbonara-Project/Guanciale/blob/c239ffac6fb481d09c4071d1de1a09f60dc584ab/guanciale/idblib.py#L977-L994 |
Carbonara-Project/Guanciale | guanciale/idblib.py | ID0File.string | def string(self, *args):
""" return string stored in node """
data = self.bytes(*args)
if data is not None:
return data.rstrip(b"\x00").decode('utf-8') | python | def string(self, *args):
""" return string stored in node """
data = self.bytes(*args)
if data is not None:
return data.rstrip(b"\x00").decode('utf-8') | [
"def",
"string",
"(",
"self",
",",
"*",
"args",
")",
":",
"data",
"=",
"self",
".",
"bytes",
"(",
"*",
"args",
")",
"if",
"data",
"is",
"not",
"None",
":",
"return",
"data",
".",
"rstrip",
"(",
"b\"\\x00\"",
")",
".",
"decode",
"(",
"'utf-8'",
")... | return string stored in node | [
"return",
"string",
"stored",
"in",
"node"
] | train | https://github.com/Carbonara-Project/Guanciale/blob/c239ffac6fb481d09c4071d1de1a09f60dc584ab/guanciale/idblib.py#L996-L1000 |
Carbonara-Project/Guanciale | guanciale/idblib.py | ID0File.name | def name(self, id):
"""
resolves a name, both short and long names.
"""
data = self.bytes(id, 'N')
if not data:
print("%x has no name" % id)
return
if data[:1] == b'\x00':
nameid, = struct.unpack_from(">" + self.fmt, data, 1)
... | python | def name(self, id):
"""
resolves a name, both short and long names.
"""
data = self.bytes(id, 'N')
if not data:
print("%x has no name" % id)
return
if data[:1] == b'\x00':
nameid, = struct.unpack_from(">" + self.fmt, data, 1)
... | [
"def",
"name",
"(",
"self",
",",
"id",
")",
":",
"data",
"=",
"self",
".",
"bytes",
"(",
"id",
",",
"'N'",
")",
"if",
"not",
"data",
":",
"print",
"(",
"\"%x has no name\"",
"%",
"id",
")",
"return",
"if",
"data",
"[",
":",
"1",
"]",
"==",
"b'\... | resolves a name, both short and long names. | [
"resolves",
"a",
"name",
"both",
"short",
"and",
"long",
"names",
"."
] | train | https://github.com/Carbonara-Project/Guanciale/blob/c239ffac6fb481d09c4071d1de1a09f60dc584ab/guanciale/idblib.py#L1002-L1014 |
Carbonara-Project/Guanciale | guanciale/idblib.py | ID0File.blob | def blob(self, nodeid, tag, start=0, end=0xFFFFFFFF):
"""
Blobs are stored in sequential nodes
with increasing index values.
most blobs, like scripts start at index
0, long names start at a specified
offset.
"""
startkey = self.makekey(nodeid, ... | python | def blob(self, nodeid, tag, start=0, end=0xFFFFFFFF):
"""
Blobs are stored in sequential nodes
with increasing index values.
most blobs, like scripts start at index
0, long names start at a specified
offset.
"""
startkey = self.makekey(nodeid, ... | [
"def",
"blob",
"(",
"self",
",",
"nodeid",
",",
"tag",
",",
"start",
"=",
"0",
",",
"end",
"=",
"0xFFFFFFFF",
")",
":",
"startkey",
"=",
"self",
".",
"makekey",
"(",
"nodeid",
",",
"tag",
",",
"start",
")",
"endkey",
"=",
"self",
".",
"makekey",
... | Blobs are stored in sequential nodes
with increasing index values.
most blobs, like scripts start at index
0, long names start at a specified
offset. | [
"Blobs",
"are",
"stored",
"in",
"sequential",
"nodes",
"with",
"increasing",
"index",
"values",
".",
"most",
"blobs",
"like",
"scripts",
"start",
"at",
"index",
"0",
"long",
"names",
"start",
"at",
"a",
"specified",
"offset",
"."
] | train | https://github.com/Carbonara-Project/Guanciale/blob/c239ffac6fb481d09c4071d1de1a09f60dc584ab/guanciale/idblib.py#L1016-L1033 |
Carbonara-Project/Guanciale | guanciale/idblib.py | ID1File.dump | def dump(self):
""" print first and last bits for each segment """
for seg in self.seglist:
print("==== %08x-%08x" % (seg.startea, seg.endea))
if seg.endea - seg.startea < 30:
for ea in range(seg.startea, seg.endea):
print(" %08x: %08x... | python | def dump(self):
""" print first and last bits for each segment """
for seg in self.seglist:
print("==== %08x-%08x" % (seg.startea, seg.endea))
if seg.endea - seg.startea < 30:
for ea in range(seg.startea, seg.endea):
print(" %08x: %08x... | [
"def",
"dump",
"(",
"self",
")",
":",
"for",
"seg",
"in",
"self",
".",
"seglist",
":",
"print",
"(",
"\"==== %08x-%08x\"",
"%",
"(",
"seg",
".",
"startea",
",",
"seg",
".",
"endea",
")",
")",
"if",
"seg",
".",
"endea",
"-",
"seg",
".",
"startea",
... | print first and last bits for each segment | [
"print",
"first",
"and",
"last",
"bits",
"for",
"each",
"segment"
] | train | https://github.com/Carbonara-Project/Guanciale/blob/c239ffac6fb481d09c4071d1de1a09f60dc584ab/guanciale/idblib.py#L1103-L1115 |
Carbonara-Project/Guanciale | guanciale/idblib.py | ID1File.find_segment | def find_segment(self, ea):
""" do a linear search for the given address in the segment list """
for seg in self.seglist:
if seg.startea <= ea < seg.endea:
return seg | python | def find_segment(self, ea):
""" do a linear search for the given address in the segment list """
for seg in self.seglist:
if seg.startea <= ea < seg.endea:
return seg | [
"def",
"find_segment",
"(",
"self",
",",
"ea",
")",
":",
"for",
"seg",
"in",
"self",
".",
"seglist",
":",
"if",
"seg",
".",
"startea",
"<=",
"ea",
"<",
"seg",
".",
"endea",
":",
"return",
"seg"
] | do a linear search for the given address in the segment list | [
"do",
"a",
"linear",
"search",
"for",
"the",
"given",
"address",
"in",
"the",
"segment",
"list"
] | train | https://github.com/Carbonara-Project/Guanciale/blob/c239ffac6fb481d09c4071d1de1a09f60dc584ab/guanciale/idblib.py#L1117-L1121 |
bcaller/pinyin_markdown | pinyin_markdown/numbered_accented.py | _num_vowel_to_acc | def _num_vowel_to_acc(vowel, tone):
"""Convert a numbered vowel to an accented vowel."""
try:
return VOWEL_MAP[vowel + str(tone)]
except IndexError:
raise ValueError("Vowel must be one of '{}' and tone must be a tone.".format(VOWELS)) | python | def _num_vowel_to_acc(vowel, tone):
"""Convert a numbered vowel to an accented vowel."""
try:
return VOWEL_MAP[vowel + str(tone)]
except IndexError:
raise ValueError("Vowel must be one of '{}' and tone must be a tone.".format(VOWELS)) | [
"def",
"_num_vowel_to_acc",
"(",
"vowel",
",",
"tone",
")",
":",
"try",
":",
"return",
"VOWEL_MAP",
"[",
"vowel",
"+",
"str",
"(",
"tone",
")",
"]",
"except",
"IndexError",
":",
"raise",
"ValueError",
"(",
"\"Vowel must be one of '{}' and tone must be a tone.\"",
... | Convert a numbered vowel to an accented vowel. | [
"Convert",
"a",
"numbered",
"vowel",
"to",
"an",
"accented",
"vowel",
"."
] | train | https://github.com/bcaller/pinyin_markdown/blob/d2f07233b37a885478198fb2fdf9978a250d82d3/pinyin_markdown/numbered_accented.py#L17-L22 |
bcaller/pinyin_markdown | pinyin_markdown/numbered_accented.py | numbered_syllable_to_accented | def numbered_syllable_to_accented(syllable):
"""Convert a numbered pinyin syllable to an accented pinyin syllable.
Implements the following algorithm, modified from https://github.com/tsroten/zhon:
1. If the syllable has an 'a' or 'e', put the tone over that vowel.
2. If the syllable has 'ou', ... | python | def numbered_syllable_to_accented(syllable):
"""Convert a numbered pinyin syllable to an accented pinyin syllable.
Implements the following algorithm, modified from https://github.com/tsroten/zhon:
1. If the syllable has an 'a' or 'e', put the tone over that vowel.
2. If the syllable has 'ou', ... | [
"def",
"numbered_syllable_to_accented",
"(",
"syllable",
")",
":",
"def",
"keep_case_replace",
"(",
"s",
",",
"vowel",
",",
"replacement",
")",
":",
"accented",
"=",
"s",
".",
"replace",
"(",
"vowel",
",",
"replacement",
")",
"if",
"syllable",
"[",
"0",
"]... | Convert a numbered pinyin syllable to an accented pinyin syllable.
Implements the following algorithm, modified from https://github.com/tsroten/zhon:
1. If the syllable has an 'a' or 'e', put the tone over that vowel.
2. If the syllable has 'ou', place the tone over the 'o'.
3. Otherwise, p... | [
"Convert",
"a",
"numbered",
"pinyin",
"syllable",
"to",
"an",
"accented",
"pinyin",
"syllable",
"."
] | train | https://github.com/bcaller/pinyin_markdown/blob/d2f07233b37a885478198fb2fdf9978a250d82d3/pinyin_markdown/numbered_accented.py#L25-L52 |
KelSolaar/Foundations | foundations/verbose.py | to_unicode | def to_unicode(data, encoding=Constants.default_codec, errors=Constants.codec_error):
"""
Converts given data to unicode string using package default settings, fighting **The Hell**!
Usage::
>>> to_unicode("myData")
u'myData'
>>> to_unicode("汉字/漢字")
u'\u6c49\u5b57/\u6f22\u5... | python | def to_unicode(data, encoding=Constants.default_codec, errors=Constants.codec_error):
"""
Converts given data to unicode string using package default settings, fighting **The Hell**!
Usage::
>>> to_unicode("myData")
u'myData'
>>> to_unicode("汉字/漢字")
u'\u6c49\u5b57/\u6f22\u5... | [
"def",
"to_unicode",
"(",
"data",
",",
"encoding",
"=",
"Constants",
".",
"default_codec",
",",
"errors",
"=",
"Constants",
".",
"codec_error",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"type",
"(",
"\"\"",
")",
")",
":",
"return",
"data",
"else",
... | Converts given data to unicode string using package default settings, fighting **The Hell**!
Usage::
>>> to_unicode("myData")
u'myData'
>>> to_unicode("汉字/漢字")
u'\u6c49\u5b57/\u6f22\u5b57'
:param data: Data to convert.
:type data: object
:param encoding: File encoding ... | [
"Converts",
"given",
"data",
"to",
"unicode",
"string",
"using",
"package",
"default",
"settings",
"fighting",
"**",
"The",
"Hell",
"**",
"!"
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/verbose.py#L63-L90 |
KelSolaar/Foundations | foundations/verbose.py | _LogRecord_msg | def _LogRecord_msg():
"""
Overrides logging.LogRecord.msg attribute to ensure variable content is stored as unicode.
"""
def _LogRecord_msgProperty(self):
return self.__msg
def _LogRecord_msgSetter(self, value):
self.__msg = to_unicode(value)
logging.LogRecord.msg = property(_... | python | def _LogRecord_msg():
"""
Overrides logging.LogRecord.msg attribute to ensure variable content is stored as unicode.
"""
def _LogRecord_msgProperty(self):
return self.__msg
def _LogRecord_msgSetter(self, value):
self.__msg = to_unicode(value)
logging.LogRecord.msg = property(_... | [
"def",
"_LogRecord_msg",
"(",
")",
":",
"def",
"_LogRecord_msgProperty",
"(",
"self",
")",
":",
"return",
"self",
".",
"__msg",
"def",
"_LogRecord_msgSetter",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"__msg",
"=",
"to_unicode",
"(",
"value",
")",
... | Overrides logging.LogRecord.msg attribute to ensure variable content is stored as unicode. | [
"Overrides",
"logging",
".",
"LogRecord",
".",
"msg",
"attribute",
"to",
"ensure",
"variable",
"content",
"is",
"stored",
"as",
"unicode",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/verbose.py#L118-L129 |
KelSolaar/Foundations | foundations/verbose.py | tracer | def tracer(object):
"""
| Traces execution.
| Any method / definition decorated will have it's execution traced through debug messages.
| Both object entry and exit are logged.
Entering in an object::
INFO : ---> foundations.environment.get_user_application_data_directory() <<<---
... | python | def tracer(object):
"""
| Traces execution.
| Any method / definition decorated will have it's execution traced through debug messages.
| Both object entry and exit are logged.
Entering in an object::
INFO : ---> foundations.environment.get_user_application_data_directory() <<<---
... | [
"def",
"tracer",
"(",
"object",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"object",
")",
"@",
"functools",
".",
"partial",
"(",
"foundations",
".",
"trace",
".",
"validate_tracer",
",",
"object",
")",
"def",
"tracer_wrapper",
"(",
"*",
"args",
",",
... | | Traces execution.
| Any method / definition decorated will have it's execution traced through debug messages.
| Both object entry and exit are logged.
Entering in an object::
INFO : ---> foundations.environment.get_user_application_data_directory() <<<---
Exiting from an object::
... | [
"|",
"Traces",
"execution",
".",
"|",
"Any",
"method",
"/",
"definition",
"decorated",
"will",
"have",
"it",
"s",
"execution",
"traced",
"through",
"debug",
"messages",
".",
"|",
"Both",
"object",
"entry",
"and",
"exit",
"are",
"logged",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/verbose.py#L282-L345 |
KelSolaar/Foundations | foundations/verbose.py | install_logger | def install_logger(logger=None, module=None):
"""
Installs given logger in given module or default logger in caller introspected module.
:param logger: Logger to install.
:type logger: Logger
:param module: Module.
:type module: ModuleType
:return: Logger.
:rtype: Logger
"""
lo... | python | def install_logger(logger=None, module=None):
"""
Installs given logger in given module or default logger in caller introspected module.
:param logger: Logger to install.
:type logger: Logger
:param module: Module.
:type module: ModuleType
:return: Logger.
:rtype: Logger
"""
lo... | [
"def",
"install_logger",
"(",
"logger",
"=",
"None",
",",
"module",
"=",
"None",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"Constants",
".",
"logger",
")",
"if",
"logger",
"is",
"None",
"else",
"logger",
"if",
"module",
"is",
"None",
"... | Installs given logger in given module or default logger in caller introspected module.
:param logger: Logger to install.
:type logger: Logger
:param module: Module.
:type module: ModuleType
:return: Logger.
:rtype: Logger | [
"Installs",
"given",
"logger",
"in",
"given",
"module",
"or",
"default",
"logger",
"in",
"caller",
"introspected",
"module",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/verbose.py#L348-L368 |
KelSolaar/Foundations | foundations/verbose.py | uninstall_logger | def uninstall_logger(logger=None, module=None):
"""
Uninstalls given logger in given module or default logger in caller introspected module.
:param logger: Logger to uninstall.
:type logger: Logger
:param module: Module.
:type module: ModuleType
:return: Definition success.
:rtype: bool... | python | def uninstall_logger(logger=None, module=None):
"""
Uninstalls given logger in given module or default logger in caller introspected module.
:param logger: Logger to uninstall.
:type logger: Logger
:param module: Module.
:type module: ModuleType
:return: Definition success.
:rtype: bool... | [
"def",
"uninstall_logger",
"(",
"logger",
"=",
"None",
",",
"module",
"=",
"None",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"Constants",
".",
"logger",
")",
"if",
"logger",
"is",
"None",
"else",
"logger",
"if",
"module",
"is",
"None",
... | Uninstalls given logger in given module or default logger in caller introspected module.
:param logger: Logger to uninstall.
:type logger: Logger
:param module: Module.
:type module: ModuleType
:return: Definition success.
:rtype: bool | [
"Uninstalls",
"given",
"logger",
"in",
"given",
"module",
"or",
"default",
"logger",
"in",
"caller",
"introspected",
"module",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/verbose.py#L371-L388 |
KelSolaar/Foundations | foundations/verbose.py | get_logging_console_handler | def get_logging_console_handler(logger=None, formatter=LOGGING_DEFAULT_FORMATTER):
"""
Adds a logging console handler to given logger or default logger.
:param logger: Logger to add the handler to.
:type logger: Logger
:param formatter: Handler formatter.
:type formatter: Formatter
:return:... | python | def get_logging_console_handler(logger=None, formatter=LOGGING_DEFAULT_FORMATTER):
"""
Adds a logging console handler to given logger or default logger.
:param logger: Logger to add the handler to.
:type logger: Logger
:param formatter: Handler formatter.
:type formatter: Formatter
:return:... | [
"def",
"get_logging_console_handler",
"(",
"logger",
"=",
"None",
",",
"formatter",
"=",
"LOGGING_DEFAULT_FORMATTER",
")",
":",
"logger",
"=",
"LOGGER",
"if",
"logger",
"is",
"None",
"else",
"logger",
"logging_console_handler",
"=",
"logging",
".",
"StreamHandler",
... | Adds a logging console handler to given logger or default logger.
:param logger: Logger to add the handler to.
:type logger: Logger
:param formatter: Handler formatter.
:type formatter: Formatter
:return: Added handler.
:rtype: Handler | [
"Adds",
"a",
"logging",
"console",
"handler",
"to",
"given",
"logger",
"or",
"default",
"logger",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/verbose.py#L391-L407 |
KelSolaar/Foundations | foundations/verbose.py | get_logging_file_handler | def get_logging_file_handler(logger=None, file=None, formatter=LOGGING_DEFAULT_FORMATTER):
"""
Adds a logging file handler to given logger or default logger using given file.
:param logger: Logger to add the handler to.
:type logger: Logger
:param file: File to verbose into.
:type file: unicode... | python | def get_logging_file_handler(logger=None, file=None, formatter=LOGGING_DEFAULT_FORMATTER):
"""
Adds a logging file handler to given logger or default logger using given file.
:param logger: Logger to add the handler to.
:type logger: Logger
:param file: File to verbose into.
:type file: unicode... | [
"def",
"get_logging_file_handler",
"(",
"logger",
"=",
"None",
",",
"file",
"=",
"None",
",",
"formatter",
"=",
"LOGGING_DEFAULT_FORMATTER",
")",
":",
"logger",
"=",
"LOGGER",
"if",
"logger",
"is",
"None",
"else",
"logger",
"file",
"=",
"tempfile",
".",
"Nam... | Adds a logging file handler to given logger or default logger using given file.
:param logger: Logger to add the handler to.
:type logger: Logger
:param file: File to verbose into.
:type file: unicode
:param formatter: Handler formatter.
:type formatter: Formatter
:return: Added handler.
... | [
"Adds",
"a",
"logging",
"file",
"handler",
"to",
"given",
"logger",
"or",
"default",
"logger",
"using",
"given",
"file",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/verbose.py#L410-L429 |
KelSolaar/Foundations | foundations/verbose.py | get_logging_stream_handler | def get_logging_stream_handler(logger=None, formatter=LOGGING_DEFAULT_FORMATTER):
"""
Adds a logging stream handler to given logger or default logger using given file.
:param logger: Logger to add the handler to.
:type logger: Logger
:param file: File to verbose into.
:type file: unicode
:p... | python | def get_logging_stream_handler(logger=None, formatter=LOGGING_DEFAULT_FORMATTER):
"""
Adds a logging stream handler to given logger or default logger using given file.
:param logger: Logger to add the handler to.
:type logger: Logger
:param file: File to verbose into.
:type file: unicode
:p... | [
"def",
"get_logging_stream_handler",
"(",
"logger",
"=",
"None",
",",
"formatter",
"=",
"LOGGING_DEFAULT_FORMATTER",
")",
":",
"logger",
"=",
"LOGGER",
"if",
"logger",
"is",
"None",
"else",
"logger",
"logging_stream_handler",
"=",
"logging",
".",
"StreamHandler",
... | Adds a logging stream handler to given logger or default logger using given file.
:param logger: Logger to add the handler to.
:type logger: Logger
:param file: File to verbose into.
:type file: unicode
:param formatter: Handler formatter.
:type formatter: Formatter
:return: Added handler.
... | [
"Adds",
"a",
"logging",
"stream",
"handler",
"to",
"given",
"logger",
"or",
"default",
"logger",
"using",
"given",
"file",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/verbose.py#L432-L450 |
KelSolaar/Foundations | foundations/verbose.py | remove_logging_handler | def remove_logging_handler(handler, logger=None):
"""
Removes given logging handler from given logger.
:param handler: Handler.
:type handler: Handler
:param logger: Handler logger.
:type logger: Logger
:return: Definition success.
:rtype: bool
"""
logger = LOGGER if logger is ... | python | def remove_logging_handler(handler, logger=None):
"""
Removes given logging handler from given logger.
:param handler: Handler.
:type handler: Handler
:param logger: Handler logger.
:type logger: Logger
:return: Definition success.
:rtype: bool
"""
logger = LOGGER if logger is ... | [
"def",
"remove_logging_handler",
"(",
"handler",
",",
"logger",
"=",
"None",
")",
":",
"logger",
"=",
"LOGGER",
"if",
"logger",
"is",
"None",
"else",
"logger",
"logger",
".",
"handlers",
"and",
"LOGGER",
".",
"debug",
"(",
"\"> Stopping handler: '{0}'.\"",
"."... | Removes given logging handler from given logger.
:param handler: Handler.
:type handler: Handler
:param logger: Handler logger.
:type logger: Logger
:return: Definition success.
:rtype: bool | [
"Removes",
"given",
"logging",
"handler",
"from",
"given",
"logger",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/verbose.py#L453-L468 |
KelSolaar/Foundations | foundations/verbose.py | set_verbosity_level | def set_verbosity_level(verbosity_level=3, logger=None):
"""
Defines logging verbosity level.
Available verbosity levels::
0: Critical.
1: Error.
2: Warning.
3: Info.
4: Debug.
:param verbosity_level: Verbosity level.
:type verbosity_level: int
:param l... | python | def set_verbosity_level(verbosity_level=3, logger=None):
"""
Defines logging verbosity level.
Available verbosity levels::
0: Critical.
1: Error.
2: Warning.
3: Info.
4: Debug.
:param verbosity_level: Verbosity level.
:type verbosity_level: int
:param l... | [
"def",
"set_verbosity_level",
"(",
"verbosity_level",
"=",
"3",
",",
"logger",
"=",
"None",
")",
":",
"logger",
"=",
"LOGGER",
"if",
"logger",
"is",
"None",
"else",
"logger",
"if",
"verbosity_level",
"==",
"0",
":",
"logger",
".",
"setLevel",
"(",
"logging... | Defines logging verbosity level.
Available verbosity levels::
0: Critical.
1: Error.
2: Warning.
3: Info.
4: Debug.
:param verbosity_level: Verbosity level.
:type verbosity_level: int
:param logger: Logger to set the verbosity level to.
:type logger: Logger... | [
"Defines",
"logging",
"verbosity",
"level",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/verbose.py#L471-L507 |
KelSolaar/Foundations | foundations/verbose.py | Streamer.stream | def stream(self, value):
"""
Setter for **self.__stream** attribute.
:param value: Attribute value.
:type value: list
"""
if value is not None:
assert type(value) is list, "'{0}' attribute: '{1}' type is not 'list'!".format("stream", value)
self.__st... | python | def stream(self, value):
"""
Setter for **self.__stream** attribute.
:param value: Attribute value.
:type value: list
"""
if value is not None:
assert type(value) is list, "'{0}' attribute: '{1}' type is not 'list'!".format("stream", value)
self.__st... | [
"def",
"stream",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"list",
",",
"\"'{0}' attribute: '{1}' type is not 'list'!\"",
".",
"format",
"(",
"\"stream\"",
",",
"value",
")",
"s... | Setter for **self.__stream** attribute.
:param value: Attribute value.
:type value: list | [
"Setter",
"for",
"**",
"self",
".",
"__stream",
"**",
"attribute",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/verbose.py#L170-L180 |
KelSolaar/Foundations | foundations/verbose.py | StandardOutputStreamer.write | def write(self, message):
"""
Writes given message to logger handlers.
:param message: Message.
:type message: unicode
:return: Method success.
:rtype: bool
"""
for handler in self.__logger.__dict__["handlers"]:
handler.stream.write(message)
... | python | def write(self, message):
"""
Writes given message to logger handlers.
:param message: Message.
:type message: unicode
:return: Method success.
:rtype: bool
"""
for handler in self.__logger.__dict__["handlers"]:
handler.stream.write(message)
... | [
"def",
"write",
"(",
"self",
",",
"message",
")",
":",
"for",
"handler",
"in",
"self",
".",
"__logger",
".",
"__dict__",
"[",
"\"handlers\"",
"]",
":",
"handler",
".",
"stream",
".",
"write",
"(",
"message",
")",
"return",
"True"
] | Writes given message to logger handlers.
:param message: Message.
:type message: unicode
:return: Method success.
:rtype: bool | [
"Writes",
"given",
"message",
"to",
"logger",
"handlers",
"."
] | train | https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/verbose.py#L254-L266 |
hospadar/sqlite_object | sqlite_object/_sqlite_object.py | SqliteObject._do_write | def _do_write(self):
"""
Check commit counter and do a commit if need be
"""
with self.lock:
self._commit_counter += 1
if self._commit_counter >= self._commit_every:
self._db.commit()
self._commit_counter = 0 | python | def _do_write(self):
"""
Check commit counter and do a commit if need be
"""
with self.lock:
self._commit_counter += 1
if self._commit_counter >= self._commit_every:
self._db.commit()
self._commit_counter = 0 | [
"def",
"_do_write",
"(",
"self",
")",
":",
"with",
"self",
".",
"lock",
":",
"self",
".",
"_commit_counter",
"+=",
"1",
"if",
"self",
".",
"_commit_counter",
">=",
"self",
".",
"_commit_every",
":",
"self",
".",
"_db",
".",
"commit",
"(",
")",
"self",
... | Check commit counter and do a commit if need be | [
"Check",
"commit",
"counter",
"and",
"do",
"a",
"commit",
"if",
"need",
"be"
] | train | https://github.com/hospadar/sqlite_object/blob/a24a5d297f10a7d68b5f3e3b744654efb1eee9d4/sqlite_object/_sqlite_object.py#L58-L66 |
idlesign/envbox | envbox/envs.py | register_type | def register_type(env_type, alias=None):
"""Registers environment type.
:param str|unicode|Environment env_type: Environment type or its alias
(for already registered types).
:param str|unicode alias: Alias to register type under. If not set type name is used.
:rtype: Environment
"""
... | python | def register_type(env_type, alias=None):
"""Registers environment type.
:param str|unicode|Environment env_type: Environment type or its alias
(for already registered types).
:param str|unicode alias: Alias to register type under. If not set type name is used.
:rtype: Environment
"""
... | [
"def",
"register_type",
"(",
"env_type",
",",
"alias",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"env_type",
",",
"string_types",
")",
":",
"env_type",
"=",
"TYPES",
"[",
"env_type",
"]",
"if",
"alias",
"is",
"None",
":",
"alias",
"=",
"env_type",
... | Registers environment type.
:param str|unicode|Environment env_type: Environment type or its alias
(for already registered types).
:param str|unicode alias: Alias to register type under. If not set type name is used.
:rtype: Environment | [
"Registers",
"environment",
"type",
"."
] | train | https://github.com/idlesign/envbox/blob/4d10cc007e1bc6acf924413c4c16c3b5960d460a/envbox/envs.py#L256-L278 |
bretth/woven | woven/decorators.py | run_once_per_node | def run_once_per_node(func):
"""
Decorator preventing wrapped function from running more than
once per host (not just interpreter session).
Using env.patch = True will allow the wrapped function to be run
if it has been previously executed, but not otherwise
Stores the result of a function... | python | def run_once_per_node(func):
"""
Decorator preventing wrapped function from running more than
once per host (not just interpreter session).
Using env.patch = True will allow the wrapped function to be run
if it has been previously executed, but not otherwise
Stores the result of a function... | [
"def",
"run_once_per_node",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"decorated",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"hasattr",
"(",
"env",
",",
"'patch'",
")",
":",
"env",
".",
"patch",
"=",
"F... | Decorator preventing wrapped function from running more than
once per host (not just interpreter session).
Using env.patch = True will allow the wrapped function to be run
if it has been previously executed, but not otherwise
Stores the result of a function as server state | [
"Decorator",
"preventing",
"wrapped",
"function",
"from",
"running",
"more",
"than",
"once",
"per",
"host",
"(",
"not",
"just",
"interpreter",
"session",
")",
"."
] | train | https://github.com/bretth/woven/blob/ec1da7b401a335f43129e7115fe7a4d145649f1e/woven/decorators.py#L7-L34 |
akfullfo/taskforce | taskforce/watch_files.py | watch._close | def _close(self, fd):
"""
Close the descriptor used for a path regardless
of mode.
"""
if self._mode == WF_INOTIFYX:
try: pynotifyx.rm_watch(self._inx_fd, fd)
except: pass
else:
try: os.close(fd)
except: pass | python | def _close(self, fd):
"""
Close the descriptor used for a path regardless
of mode.
"""
if self._mode == WF_INOTIFYX:
try: pynotifyx.rm_watch(self._inx_fd, fd)
except: pass
else:
try: os.close(fd)
except: pass | [
"def",
"_close",
"(",
"self",
",",
"fd",
")",
":",
"if",
"self",
".",
"_mode",
"==",
"WF_INOTIFYX",
":",
"try",
":",
"pynotifyx",
".",
"rm_watch",
"(",
"self",
".",
"_inx_fd",
",",
"fd",
")",
"except",
":",
"pass",
"else",
":",
"try",
":",
"os",
... | Close the descriptor used for a path regardless
of mode. | [
"Close",
"the",
"descriptor",
"used",
"for",
"a",
"path",
"regardless",
"of",
"mode",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/watch_files.py#L242-L252 |
akfullfo/taskforce | taskforce/watch_files.py | watch._self_pipe | def _self_pipe(self):
"""
This sets up a self-pipe so we can hand back an fd to the caller
allowing the object to manage event triggers. The ends of the pipe are
set non-blocking so it doesn't really matter if a bunch of events fill
the pipe buffer.
"""
import fcntl
... | python | def _self_pipe(self):
"""
This sets up a self-pipe so we can hand back an fd to the caller
allowing the object to manage event triggers. The ends of the pipe are
set non-blocking so it doesn't really matter if a bunch of events fill
the pipe buffer.
"""
import fcntl
... | [
"def",
"_self_pipe",
"(",
"self",
")",
":",
"import",
"fcntl",
"self",
".",
"_poll_fd",
",",
"self",
".",
"_poll_send",
"=",
"os",
".",
"pipe",
"(",
")",
"for",
"fd",
"in",
"[",
"self",
".",
"_poll_fd",
",",
"self",
".",
"_poll_send",
"]",
":",
"fl... | This sets up a self-pipe so we can hand back an fd to the caller
allowing the object to manage event triggers. The ends of the pipe are
set non-blocking so it doesn't really matter if a bunch of events fill
the pipe buffer. | [
"This",
"sets",
"up",
"a",
"self",
"-",
"pipe",
"so",
"we",
"can",
"hand",
"back",
"an",
"fd",
"to",
"the",
"caller",
"allowing",
"the",
"object",
"to",
"manage",
"event",
"triggers",
".",
"The",
"ends",
"of",
"the",
"pipe",
"are",
"set",
"non",
"-",... | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/watch_files.py#L254-L266 |
akfullfo/taskforce | taskforce/watch_files.py | watch._disappeared | def _disappeared(self, fd, path, **params):
"""
Called when an open path is no longer acessible. This will either
move the path to pending (if the 'missing' param is set for the
file), or fire an exception.
"""
log = self._getparam('log', self._discard, **params)
lo... | python | def _disappeared(self, fd, path, **params):
"""
Called when an open path is no longer acessible. This will either
move the path to pending (if the 'missing' param is set for the
file), or fire an exception.
"""
log = self._getparam('log', self._discard, **params)
lo... | [
"def",
"_disappeared",
"(",
"self",
",",
"fd",
",",
"path",
",",
"*",
"*",
"params",
")",
":",
"log",
"=",
"self",
".",
"_getparam",
"(",
"'log'",
",",
"self",
".",
"_discard",
",",
"*",
"*",
"params",
")",
"log",
".",
"debug",
"(",
"\"Path %r remo... | Called when an open path is no longer acessible. This will either
move the path to pending (if the 'missing' param is set for the
file), or fire an exception. | [
"Called",
"when",
"an",
"open",
"path",
"is",
"no",
"longer",
"acessible",
".",
"This",
"will",
"either",
"move",
"the",
"path",
"to",
"pending",
"(",
"if",
"the",
"missing",
"param",
"is",
"set",
"for",
"the",
"file",
")",
"or",
"fire",
"an",
"excepti... | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/watch_files.py#L268-L295 |
akfullfo/taskforce | taskforce/watch_files.py | watch._poll_get_stat | def _poll_get_stat(self, fd, path):
"""
Check the status of an open path. Note that we have to use stat() rather
than fstat() because we want to detect file removes and renames.
"""
try:
st = os.stat(path)
fstate = (st.st_mode, st.st_nlink, st.st_uid, st.st_g... | python | def _poll_get_stat(self, fd, path):
"""
Check the status of an open path. Note that we have to use stat() rather
than fstat() because we want to detect file removes and renames.
"""
try:
st = os.stat(path)
fstate = (st.st_mode, st.st_nlink, st.st_uid, st.st_g... | [
"def",
"_poll_get_stat",
"(",
"self",
",",
"fd",
",",
"path",
")",
":",
"try",
":",
"st",
"=",
"os",
".",
"stat",
"(",
"path",
")",
"fstate",
"=",
"(",
"st",
".",
"st_mode",
",",
"st",
".",
"st_nlink",
",",
"st",
".",
"st_uid",
",",
"st",
".",
... | Check the status of an open path. Note that we have to use stat() rather
than fstat() because we want to detect file removes and renames. | [
"Check",
"the",
"status",
"of",
"an",
"open",
"path",
".",
"Note",
"that",
"we",
"have",
"to",
"use",
"stat",
"()",
"rather",
"than",
"fstat",
"()",
"because",
"we",
"want",
"to",
"detect",
"file",
"removes",
"and",
"renames",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/watch_files.py#L297-L311 |
akfullfo/taskforce | taskforce/watch_files.py | watch._poll_trigger | def _poll_trigger(self):
"""
Trigger activity for the caller by writting a NUL to the self-pipe.
"""
try:
os.write(self._poll_send, '\0'.encode('utf-8'))
except Exception as e:
log = self._getparam('log', self._discard)
log.debug("Ignoring self-pip... | python | def _poll_trigger(self):
"""
Trigger activity for the caller by writting a NUL to the self-pipe.
"""
try:
os.write(self._poll_send, '\0'.encode('utf-8'))
except Exception as e:
log = self._getparam('log', self._discard)
log.debug("Ignoring self-pip... | [
"def",
"_poll_trigger",
"(",
"self",
")",
":",
"try",
":",
"os",
".",
"write",
"(",
"self",
".",
"_poll_send",
",",
"'\\0'",
".",
"encode",
"(",
"'utf-8'",
")",
")",
"except",
"Exception",
"as",
"e",
":",
"log",
"=",
"self",
".",
"_getparam",
"(",
... | Trigger activity for the caller by writting a NUL to the self-pipe. | [
"Trigger",
"activity",
"for",
"the",
"caller",
"by",
"writting",
"a",
"NUL",
"to",
"the",
"self",
"-",
"pipe",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/watch_files.py#L313-L321 |
akfullfo/taskforce | taskforce/watch_files.py | watch._trigger | def _trigger(self, fd, **params):
"""
We need events to fire on appearance because the code
doesn't see the file until after it has been created.
In WF_KQUEUE mode, this simulates triggering an event by firing
a oneshot timer event to fire immediately (0 msecs). Because
... | python | def _trigger(self, fd, **params):
"""
We need events to fire on appearance because the code
doesn't see the file until after it has been created.
In WF_KQUEUE mode, this simulates triggering an event by firing
a oneshot timer event to fire immediately (0 msecs). Because
... | [
"def",
"_trigger",
"(",
"self",
",",
"fd",
",",
"*",
"*",
"params",
")",
":",
"log",
"=",
"self",
".",
"_getparam",
"(",
"'log'",
",",
"self",
".",
"_discard",
",",
"*",
"*",
"params",
")",
"if",
"self",
".",
"_mode",
"==",
"WF_KQUEUE",
":",
"try... | We need events to fire on appearance because the code
doesn't see the file until after it has been created.
In WF_KQUEUE mode, this simulates triggering an event by firing
a oneshot timer event to fire immediately (0 msecs). Because
this uses the file descriptor as the timer identity a... | [
"We",
"need",
"events",
"to",
"fire",
"on",
"appearance",
"because",
"the",
"code",
"doesn",
"t",
"see",
"the",
"file",
"until",
"after",
"it",
"has",
"been",
"created",
"."
] | train | https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/watch_files.py#L334-L381 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.