Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
run_clippy
(*flags)
Runs cargo-clippy with certain arguments.
Runs cargo-clippy with certain arguments.
def run_clippy(*flags): 'Runs cargo-clippy with certain arguments.' run_tool('clippy', *flags)
[ "def", "run_clippy", "(", "*", "flags", ")", ":", "run_tool", "(", "'clippy'", ",", "*", "flags", ")" ]
[ 82, 0 ]
[ 84, 30 ]
python
en
['en', 'en', 'en']
True
build
(*test_flags)
Builds the test crate.
Builds the test crate.
def build(*test_flags): 'Builds the test crate.' build_args = [ '--package', 'uefi-test-runner', *test_flags, ] if SETTINGS['config'] == 'release': build_args.append('--release') if SETTINGS['ci']: build_args.extend(['--features', 'ci']) run_build(*build_args)...
[ "def", "build", "(", "*", "test_flags", ")", ":", "build_args", "=", "[", "'--package'", ",", "'uefi-test-runner'", ",", "*", "test_flags", ",", "]", "if", "SETTINGS", "[", "'config'", "]", "==", "'release'", ":", "build_args", ".", "append", "(", "'--rele...
[ 86, 0 ]
[ 114, 41 ]
python
en
['en', 'en', 'en']
True
clippy
()
Runs Clippy on all projects
Runs Clippy on all projects
def clippy(): 'Runs Clippy on all projects' run_clippy('--all')
[ "def", "clippy", "(", ")", ":", "run_clippy", "(", "'--all'", ")" ]
[ 116, 0 ]
[ 119, 23 ]
python
en
['en', 'en', 'en']
True
doc
()
Generates documentation for the library crates.
Generates documentation for the library crates.
def doc(): 'Generates documentation for the library crates.' sp.run([ 'cargo', 'doc', '--no-deps', '--package', 'uefi', '--package', 'uefi-macros', '--package', 'uefi-services', ], check=True)
[ "def", "doc", "(", ")", ":", "sp", ".", "run", "(", "[", "'cargo'", ",", "'doc'", ",", "'--no-deps'", ",", "'--package'", ",", "'uefi'", ",", "'--package'", ",", "'uefi-macros'", ",", "'--package'", ",", "'uefi-services'", ",", "]", ",", "check", "=", ...
[ 121, 0 ]
[ 128, 18 ]
python
en
['en', 'en', 'en']
True
ovmf_files
(ovmf_dir)
Returns the tuple of paths to the OVMF code and vars firmware files, given the directory
Returns the tuple of paths to the OVMF code and vars firmware files, given the directory
def ovmf_files(ovmf_dir): 'Returns the tuple of paths to the OVMF code and vars firmware files, given the directory' if SETTINGS['arch'] == 'x86_64': return ovmf_dir / 'OVMF_CODE.fd', ovmf_dir / 'OVMF_VARS.fd' if SETTINGS['arch'] == 'aarch64': return ovmf_dir / 'QEMU_EFI-pflash.raw', ovmf_di...
[ "def", "ovmf_files", "(", "ovmf_dir", ")", ":", "if", "SETTINGS", "[", "'arch'", "]", "==", "'x86_64'", ":", "return", "ovmf_dir", "/", "'OVMF_CODE.fd'", ",", "ovmf_dir", "/", "'OVMF_VARS.fd'", "if", "SETTINGS", "[", "'arch'", "]", "==", "'aarch64'", ":", ...
[ 130, 0 ]
[ 136, 58 ]
python
en
['en', 'en', 'en']
True
check_ovmf_dir
(ovmf_dir)
Check whether the given directory contains necessary OVMF files
Check whether the given directory contains necessary OVMF files
def check_ovmf_dir(ovmf_dir): 'Check whether the given directory contains necessary OVMF files' ovmf_code, ovmf_vars = ovmf_files(ovmf_dir) return ovmf_code.is_file() and ovmf_vars.is_file()
[ "def", "check_ovmf_dir", "(", "ovmf_dir", ")", ":", "ovmf_code", ",", "ovmf_vars", "=", "ovmf_files", "(", "ovmf_dir", ")", "return", "ovmf_code", ".", "is_file", "(", ")", "and", "ovmf_vars", ".", "is_file", "(", ")" ]
[ 138, 0 ]
[ 141, 54 ]
python
en
['en', 'en', 'en']
True
find_ovmf
()
Find path to OVMF files
Find path to OVMF files
def find_ovmf(): 'Find path to OVMF files' # If the path is specified in the settings, use it. if SETTINGS['ovmf_dir'] is not None: ovmf_dir = SETTINGS['ovmf_dir'] if check_ovmf_dir(ovmf_dir): return ovmf_dir raise FileNotFoundError(f'OVMF files not found in `{ovmf_dir}`...
[ "def", "find_ovmf", "(", ")", ":", "# If the path is specified in the settings, use it.", "if", "SETTINGS", "[", "'ovmf_dir'", "]", "is", "not", "None", ":", "ovmf_dir", "=", "SETTINGS", "[", "'ovmf_dir'", "]", "if", "check_ovmf_dir", "(", "ovmf_dir", ")", ":", ...
[ 143, 0 ]
[ 169, 61 ]
python
en
['en', 'en', 'en']
True
run_qemu
()
Runs the code in QEMU.
Runs the code in QEMU.
def run_qemu(): 'Runs the code in QEMU.' # Rebuild all the changes. build('--features', 'qemu') ovmf_code, ovmf_vars = ovmf_files(find_ovmf()) qemu_monitor_pipe = 'qemu-monitor' arch = SETTINGS['arch'] qemu_flags = [ # Disable default devices. # QEMU by defaults enables ...
[ "def", "run_qemu", "(", ")", ":", "# Rebuild all the changes.", "build", "(", "'--features'", ",", "'qemu'", ")", "ovmf_code", ",", "ovmf_vars", "=", "ovmf_files", "(", "find_ovmf", "(", ")", ")", "qemu_monitor_pipe", "=", "'qemu-monitor'", "arch", "=", "SETTING...
[ 171, 0 ]
[ 337, 67 ]
python
en
['en', 'co', 'en']
True
main
()
Runs the user-requested actions.
Runs the user-requested actions.
def main(): 'Runs the user-requested actions.' # Clear any Rust flags which might affect the build. os.environ['RUSTFLAGS'] = '' desc = 'Build script for UEFI programs' parser = argparse.ArgumentParser(description=desc) parser.add_argument('verb', help='command to run', type=str, ...
[ "def", "main", "(", ")", ":", "# Clear any Rust flags which might affect the build.", "os", ".", "environ", "[", "'RUSTFLAGS'", "]", "=", "''", "desc", "=", "'Build script for UEFI programs'", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", ...
[ 339, 0 ]
[ 388, 53 ]
python
en
['en', 'en', 'en']
True
fix_duplicate_attachments
(apps: StateApps, schema_editor: DatabaseSchemaEditor)
Migration 0041 had a bug, where if multiple messages referenced the same attachment, rather than creating a single attachment object for all of them, we would incorrectly create one for each message. This results in exceptions looking up the Attachment object corresponding to a file that was used in mul...
Migration 0041 had a bug, where if multiple messages referenced the same attachment, rather than creating a single attachment object for all of them, we would incorrectly create one for each message. This results in exceptions looking up the Attachment object corresponding to a file that was used in mul...
def fix_duplicate_attachments(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: """Migration 0041 had a bug, where if multiple messages referenced the same attachment, rather than creating a single attachment object for all of them, we would incorrectly create one for each message. This res...
[ "def", "fix_duplicate_attachments", "(", "apps", ":", "StateApps", ",", "schema_editor", ":", "DatabaseSchemaEditor", ")", "->", "None", ":", "Attachment", "=", "apps", ".", "get_model", "(", "\"zerver\"", ",", "\"Attachment\"", ")", "# Loop through all groups of Atta...
[ 7, 0 ]
[ 41, 22 ]
python
en
['en', 'en', 'en']
True
match
(pattern, string, flags=0)
Try to apply the pattern at the start of the string, returning a match object, or None if no match was found.
Try to apply the pattern at the start of the string, returning a match object, or None if no match was found.
def match(pattern, string, flags=0): """Try to apply the pattern at the start of the string, returning a match object, or None if no match was found.""" return _compile(pattern, flags).match(string)
[ "def", "match", "(", "pattern", ",", "string", ",", "flags", "=", "0", ")", ":", "return", "_compile", "(", "pattern", ",", "flags", ")", ".", "match", "(", "string", ")" ]
[ 168, 0 ]
[ 171, 49 ]
python
en
['en', 'en', 'en']
True
fullmatch
(pattern, string, flags=0)
Try to apply the pattern to all of the string, returning a match object, or None if no match was found.
Try to apply the pattern to all of the string, returning a match object, or None if no match was found.
def fullmatch(pattern, string, flags=0): """Try to apply the pattern to all of the string, returning a match object, or None if no match was found.""" return _compile(pattern, flags).fullmatch(string)
[ "def", "fullmatch", "(", "pattern", ",", "string", ",", "flags", "=", "0", ")", ":", "return", "_compile", "(", "pattern", ",", "flags", ")", ".", "fullmatch", "(", "string", ")" ]
[ 173, 0 ]
[ 176, 53 ]
python
en
['en', 'en', 'en']
True
search
(pattern, string, flags=0)
Scan through string looking for a match to the pattern, returning a match object, or None if no match was found.
Scan through string looking for a match to the pattern, returning a match object, or None if no match was found.
def search(pattern, string, flags=0): """Scan through string looking for a match to the pattern, returning a match object, or None if no match was found.""" return _compile(pattern, flags).search(string)
[ "def", "search", "(", "pattern", ",", "string", ",", "flags", "=", "0", ")", ":", "return", "_compile", "(", "pattern", ",", "flags", ")", ".", "search", "(", "string", ")" ]
[ 178, 0 ]
[ 181, 50 ]
python
en
['en', 'en', 'en']
True
sub
(pattern, repl, string, count=0, flags=0)
Return the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in string by the replacement repl. repl can be either a string or a callable; if a string, backslash escapes in it are processed. If it is a callable, it's passed the match object and must return a repl...
Return the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in string by the replacement repl. repl can be either a string or a callable; if a string, backslash escapes in it are processed. If it is a callable, it's passed the match object and must return a repl...
def sub(pattern, repl, string, count=0, flags=0): """Return the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in string by the replacement repl. repl can be either a string or a callable; if a string, backslash escapes in it are processed. If it is a callable...
[ "def", "sub", "(", "pattern", ",", "repl", ",", "string", ",", "count", "=", "0", ",", "flags", "=", "0", ")", ":", "return", "_compile", "(", "pattern", ",", "flags", ")", ".", "sub", "(", "repl", ",", "string", ",", "count", ")" ]
[ 183, 0 ]
[ 190, 60 ]
python
en
['en', 'en', 'en']
True
subn
(pattern, repl, string, count=0, flags=0)
Return a 2-tuple containing (new_string, number). new_string is the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in the source string by the replacement repl. number is the number of substitutions that were made. repl can be either a string or a callable; if ...
Return a 2-tuple containing (new_string, number). new_string is the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in the source string by the replacement repl. number is the number of substitutions that were made. repl can be either a string or a callable; if ...
def subn(pattern, repl, string, count=0, flags=0): """Return a 2-tuple containing (new_string, number). new_string is the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in the source string by the replacement repl. number is the number of substitutions that wer...
[ "def", "subn", "(", "pattern", ",", "repl", ",", "string", ",", "count", "=", "0", ",", "flags", "=", "0", ")", ":", "return", "_compile", "(", "pattern", ",", "flags", ")", ".", "subn", "(", "repl", ",", "string", ",", "count", ")" ]
[ 192, 0 ]
[ 201, 61 ]
python
en
['en', 'en', 'en']
True
split
(pattern, string, maxsplit=0, flags=0)
Split the source string by the occurrences of the pattern, returning a list containing the resulting substrings. If capturing parentheses are used in pattern, then the text of all groups in the pattern are also returned as part of the resulting list. If maxsplit is nonzero, at most maxsplit splits occ...
Split the source string by the occurrences of the pattern, returning a list containing the resulting substrings. If capturing parentheses are used in pattern, then the text of all groups in the pattern are also returned as part of the resulting list. If maxsplit is nonzero, at most maxsplit splits occ...
def split(pattern, string, maxsplit=0, flags=0): """Split the source string by the occurrences of the pattern, returning a list containing the resulting substrings. If capturing parentheses are used in pattern, then the text of all groups in the pattern are also returned as part of the resulting li...
[ "def", "split", "(", "pattern", ",", "string", ",", "maxsplit", "=", "0", ",", "flags", "=", "0", ")", ":", "return", "_compile", "(", "pattern", ",", "flags", ")", ".", "split", "(", "string", ",", "maxsplit", ")" ]
[ 203, 0 ]
[ 211, 59 ]
python
en
['en', 'en', 'en']
True
findall
(pattern, string, flags=0)
Return a list of all non-overlapping matches in the string. If one or more capturing groups are present in the pattern, return a list of groups; this will be a list of tuples if the pattern has more than one group. Empty matches are included in the result.
Return a list of all non-overlapping matches in the string.
def findall(pattern, string, flags=0): """Return a list of all non-overlapping matches in the string. If one or more capturing groups are present in the pattern, return a list of groups; this will be a list of tuples if the pattern has more than one group. Empty matches are included in the result....
[ "def", "findall", "(", "pattern", ",", "string", ",", "flags", "=", "0", ")", ":", "return", "_compile", "(", "pattern", ",", "flags", ")", ".", "findall", "(", "string", ")" ]
[ 213, 0 ]
[ 221, 51 ]
python
en
['en', 'en', 'en']
True
finditer
(pattern, string, flags=0)
Return an iterator over all non-overlapping matches in the string. For each match, the iterator returns a match object. Empty matches are included in the result.
Return an iterator over all non-overlapping matches in the string. For each match, the iterator returns a match object.
def finditer(pattern, string, flags=0): """Return an iterator over all non-overlapping matches in the string. For each match, the iterator returns a match object. Empty matches are included in the result.""" return _compile(pattern, flags).finditer(string)
[ "def", "finditer", "(", "pattern", ",", "string", ",", "flags", "=", "0", ")", ":", "return", "_compile", "(", "pattern", ",", "flags", ")", ".", "finditer", "(", "string", ")" ]
[ 223, 0 ]
[ 228, 52 ]
python
en
['en', 'en', 'en']
True
compile
(pattern, flags=0)
Compile a regular expression pattern, returning a pattern object.
Compile a regular expression pattern, returning a pattern object.
def compile(pattern, flags=0): "Compile a regular expression pattern, returning a pattern object." return _compile(pattern, flags)
[ "def", "compile", "(", "pattern", ",", "flags", "=", "0", ")", ":", "return", "_compile", "(", "pattern", ",", "flags", ")" ]
[ 230, 0 ]
[ 232, 35 ]
python
en
['en', 'en', 'en']
True
purge
()
Clear the regular expression caches
Clear the regular expression caches
def purge(): "Clear the regular expression caches" _cache.clear() _compile_repl.cache_clear()
[ "def", "purge", "(", ")", ":", "_cache", ".", "clear", "(", ")", "_compile_repl", ".", "cache_clear", "(", ")" ]
[ 234, 0 ]
[ 237, 31 ]
python
en
['en', 'en', 'en']
True
template
(pattern, flags=0)
Compile a template pattern, returning a pattern object
Compile a template pattern, returning a pattern object
def template(pattern, flags=0): "Compile a template pattern, returning a pattern object" return _compile(pattern, flags|T)
[ "def", "template", "(", "pattern", ",", "flags", "=", "0", ")", ":", "return", "_compile", "(", "pattern", ",", "flags", "|", "T", ")" ]
[ 239, 0 ]
[ 241, 37 ]
python
en
['en', 'en', 'en']
True
escape
(pattern)
Escape all the characters in pattern except ASCII letters, numbers and '_'.
Escape all the characters in pattern except ASCII letters, numbers and '_'.
def escape(pattern): """ Escape all the characters in pattern except ASCII letters, numbers and '_'. """ if isinstance(pattern, str): alphanum = _alphanum_str s = list(pattern) for i, c in enumerate(pattern): if c not in alphanum: if c == "\000": ...
[ "def", "escape", "(", "pattern", ")", ":", "if", "isinstance", "(", "pattern", ",", "str", ")", ":", "alphanum", "=", "_alphanum_str", "s", "=", "list", "(", "pattern", ")", "for", "i", ",", "c", "in", "enumerate", "(", "pattern", ")", ":", "if", "...
[ 248, 0 ]
[ 275, 23 ]
python
en
['en', 'error', 'th']
False
make_command
(*args)
Create a CommandArgs object.
Create a CommandArgs object.
def make_command(*args): # type: (Union[str, HiddenText, CommandArgs]) -> CommandArgs """ Create a CommandArgs object. """ command_args = [] # type: CommandArgs for arg in args: # Check for list instead of CommandArgs since CommandArgs is # only known during type-checking. ...
[ "def", "make_command", "(", "*", "args", ")", ":", "# type: (Union[str, HiddenText, CommandArgs]) -> CommandArgs", "command_args", "=", "[", "]", "# type: CommandArgs", "for", "arg", "in", "args", ":", "# Check for list instead of CommandArgs since CommandArgs is", "# only know...
[ 26, 0 ]
[ 41, 23 ]
python
en
['en', 'error', 'th']
False
format_command_args
(args)
Format command arguments for display.
Format command arguments for display.
def format_command_args(args): # type: (Union[List[str], CommandArgs]) -> str """ Format command arguments for display. """ # For HiddenText arguments, display the redacted form by calling str(). # Also, we don't apply str() to arguments that aren't HiddenText since # this can trigger a Unic...
[ "def", "format_command_args", "(", "args", ")", ":", "# type: (Union[List[str], CommandArgs]) -> str", "# For HiddenText arguments, display the redacted form by calling str().", "# Also, we don't apply str() to arguments that aren't HiddenText since", "# this can trigger a UnicodeDecodeError in Py...
[ 44, 0 ]
[ 57, 5 ]
python
en
['en', 'error', 'th']
False
reveal_command_args
(args)
Return the arguments in their raw, unredacted form.
Return the arguments in their raw, unredacted form.
def reveal_command_args(args): # type: (Union[List[str], CommandArgs]) -> List[str] """ Return the arguments in their raw, unredacted form. """ return [ arg.secret if isinstance(arg, HiddenText) else arg for arg in args ]
[ "def", "reveal_command_args", "(", "args", ")", ":", "# type: (Union[List[str], CommandArgs]) -> List[str]", "return", "[", "arg", ".", "secret", "if", "isinstance", "(", "arg", ",", "HiddenText", ")", "else", "arg", "for", "arg", "in", "args", "]" ]
[ 60, 0 ]
[ 67, 5 ]
python
en
['en', 'error', 'th']
False
make_subprocess_output_error
( cmd_args, # type: Union[List[str], CommandArgs] cwd, # type: Optional[str] lines, # type: List[Text] exit_status, # type: int )
Create and return the error message to use to log a subprocess error with command output. :param lines: A list of lines, each ending with a newline.
Create and return the error message to use to log a subprocess error with command output.
def make_subprocess_output_error( cmd_args, # type: Union[List[str], CommandArgs] cwd, # type: Optional[str] lines, # type: List[Text] exit_status, # type: int ): # type: (...) -> Text """ Create and return the error message to use to log a subprocess error with comm...
[ "def", "make_subprocess_output_error", "(", "cmd_args", ",", "# type: Union[List[str], CommandArgs]", "cwd", ",", "# type: Optional[str]", "lines", ",", "# type: List[Text]", "exit_status", ",", "# type: int", ")", ":", "# type: (...) -> Text", "command", "=", "format_command...
[ 70, 0 ]
[ 109, 14 ]
python
en
['en', 'error', 'th']
False
call_subprocess
( cmd, # type: Union[List[str], CommandArgs] show_stdout=False, # type: bool cwd=None, # type: Optional[str] on_returncode='raise', # type: str extra_ok_returncodes=None, # type: Optional[Iterable[int]] command_desc=None, # type: Optional[str] extra_environ=None, # type: Optional[Mapp...
Args: show_stdout: if true, use INFO to log the subprocess's stderr and stdout streams. Otherwise, use DEBUG. Defaults to False. extra_ok_returncodes: an iterable of integer return codes that are acceptable, in addition to 0. Defaults to None, which means []. unset_environ: an i...
Args: show_stdout: if true, use INFO to log the subprocess's stderr and stdout streams. Otherwise, use DEBUG. Defaults to False. extra_ok_returncodes: an iterable of integer return codes that are acceptable, in addition to 0. Defaults to None, which means []. unset_environ: an i...
def call_subprocess( cmd, # type: Union[List[str], CommandArgs] show_stdout=False, # type: bool cwd=None, # type: Optional[str] on_returncode='raise', # type: str extra_ok_returncodes=None, # type: Optional[Iterable[int]] command_desc=None, # type: Optional[str] extra_environ=None, # ...
[ "def", "call_subprocess", "(", "cmd", ",", "# type: Union[List[str], CommandArgs]", "show_stdout", "=", "False", ",", "# type: bool", "cwd", "=", "None", ",", "# type: Optional[str]", "on_returncode", "=", "'raise'", ",", "# type: str", "extra_ok_returncodes", "=", "Non...
[ 112, 0 ]
[ 254, 30 ]
python
en
['en', 'error', 'th']
False
runner_with_spinner_message
(message)
Provide a subprocess_runner that shows a spinner message. Intended for use with for pep517's Pep517HookCaller. Thus, the runner has an API that matches what's expected by Pep517HookCaller.subprocess_runner.
Provide a subprocess_runner that shows a spinner message.
def runner_with_spinner_message(message): # type: (str) -> Callable[..., None] """Provide a subprocess_runner that shows a spinner message. Intended for use with for pep517's Pep517HookCaller. Thus, the runner has an API that matches what's expected by Pep517HookCaller.subprocess_runner. """ d...
[ "def", "runner_with_spinner_message", "(", "message", ")", ":", "# type: (str) -> Callable[..., None]", "def", "runner", "(", "cmd", ",", "# type: List[str]", "cwd", "=", "None", ",", "# type: Optional[str]", "extra_environ", "=", "None", "# type: Optional[Mapping[str, Any]...
[ 257, 0 ]
[ 279, 17 ]
python
en
['en', 'en', 'en']
True
_const_compare_digest_backport
(a, b)
Compare two digests of equal length in constant time. The digests must be of type str/bytes. Returns True if the digests match, and False otherwise.
Compare two digests of equal length in constant time.
def _const_compare_digest_backport(a, b): """ Compare two digests of equal length in constant time. The digests must be of type str/bytes. Returns True if the digests match, and False otherwise. """ result = abs(len(a) - len(b)) for l, r in zip(bytearray(a), bytearray(b)): result |=...
[ "def", "_const_compare_digest_backport", "(", "a", ",", "b", ")", ":", "result", "=", "abs", "(", "len", "(", "a", ")", "-", "len", "(", "b", ")", ")", "for", "l", ",", "r", "in", "zip", "(", "bytearray", "(", "a", ")", ",", "bytearray", "(", "...
[ 23, 0 ]
[ 33, 22 ]
python
en
['en', 'error', 'th']
False
assert_fingerprint
(cert, fingerprint)
Checks if given fingerprint matches the supplied certificate. :param cert: Certificate as bytes object. :param fingerprint: Fingerprint as string of hexdigits, can be interspersed by colons.
Checks if given fingerprint matches the supplied certificate.
def assert_fingerprint(cert, fingerprint): """ Checks if given fingerprint matches the supplied certificate. :param cert: Certificate as bytes object. :param fingerprint: Fingerprint as string of hexdigits, can be interspersed by colons. """ fingerprint = fingerprint.replace(":...
[ "def", "assert_fingerprint", "(", "cert", ",", "fingerprint", ")", ":", "fingerprint", "=", "fingerprint", ".", "replace", "(", "\":\"", ",", "\"\"", ")", ".", "lower", "(", ")", "digest_length", "=", "len", "(", "fingerprint", ")", "hashfunc", "=", "HASHF...
[ 154, 0 ]
[ 180, 9 ]
python
en
['en', 'error', 'th']
False
resolve_cert_reqs
(candidate)
Resolves the argument to a numeric constant, which can be passed to the wrap_socket function/method from the ssl module. Defaults to :data:`ssl.CERT_REQUIRED`. If given a string it is assumed to be the name of the constant in the :mod:`ssl` module or its abbreviation. (So you can specify `REQUI...
Resolves the argument to a numeric constant, which can be passed to the wrap_socket function/method from the ssl module. Defaults to :data:`ssl.CERT_REQUIRED`. If given a string it is assumed to be the name of the constant in the :mod:`ssl` module or its abbreviation. (So you can specify `REQUI...
def resolve_cert_reqs(candidate): """ Resolves the argument to a numeric constant, which can be passed to the wrap_socket function/method from the ssl module. Defaults to :data:`ssl.CERT_REQUIRED`. If given a string it is assumed to be the name of the constant in the :mod:`ssl` module or its abb...
[ "def", "resolve_cert_reqs", "(", "candidate", ")", ":", "if", "candidate", "is", "None", ":", "return", "CERT_REQUIRED", "if", "isinstance", "(", "candidate", ",", "str", ")", ":", "res", "=", "getattr", "(", "ssl", ",", "candidate", ",", "None", ")", "i...
[ 183, 0 ]
[ 203, 20 ]
python
en
['en', 'error', 'th']
False
resolve_ssl_version
(candidate)
like resolve_cert_reqs
like resolve_cert_reqs
def resolve_ssl_version(candidate): """ like resolve_cert_reqs """ if candidate is None: return PROTOCOL_TLS if isinstance(candidate, str): res = getattr(ssl, candidate, None) if res is None: res = getattr(ssl, "PROTOCOL_" + candidate) return res ret...
[ "def", "resolve_ssl_version", "(", "candidate", ")", ":", "if", "candidate", "is", "None", ":", "return", "PROTOCOL_TLS", "if", "isinstance", "(", "candidate", ",", "str", ")", ":", "res", "=", "getattr", "(", "ssl", ",", "candidate", ",", "None", ")", "...
[ 206, 0 ]
[ 219, 20 ]
python
en
['en', 'error', 'th']
False
create_urllib3_context
( ssl_version=None, cert_reqs=None, options=None, ciphers=None )
All arguments have the same meaning as ``ssl_wrap_socket``. By default, this function does a lot of the same work that ``ssl.create_default_context`` does on Python 3.4+. It: - Disables SSLv2, SSLv3, and compression - Sets a restricted set of server ciphers If you wish to enable SSLv3, you can do...
All arguments have the same meaning as ``ssl_wrap_socket``.
def create_urllib3_context( ssl_version=None, cert_reqs=None, options=None, ciphers=None ): """All arguments have the same meaning as ``ssl_wrap_socket``. By default, this function does a lot of the same work that ``ssl.create_default_context`` does on Python 3.4+. It: - Disables SSLv2, SSLv3, and...
[ "def", "create_urllib3_context", "(", "ssl_version", "=", "None", ",", "cert_reqs", "=", "None", ",", "options", "=", "None", ",", "ciphers", "=", "None", ")", ":", "context", "=", "SSLContext", "(", "ssl_version", "or", "PROTOCOL_TLS", ")", "context", ".", ...
[ 222, 0 ]
[ 295, 18 ]
python
en
['en', 'en', 'en']
True
ssl_wrap_socket
( sock, keyfile=None, certfile=None, cert_reqs=None, ca_certs=None, server_hostname=None, ssl_version=None, ciphers=None, ssl_context=None, ca_cert_dir=None, key_password=None, ca_cert_data=None, )
All arguments except for server_hostname, ssl_context, and ca_cert_dir have the same meaning as they do when using :func:`ssl.wrap_socket`. :param server_hostname: When SNI is supported, the expected hostname of the certificate :param ssl_context: A pre-made :class:`SSLContext` object....
All arguments except for server_hostname, ssl_context, and ca_cert_dir have the same meaning as they do when using :func:`ssl.wrap_socket`.
def ssl_wrap_socket( sock, keyfile=None, certfile=None, cert_reqs=None, ca_certs=None, server_hostname=None, ssl_version=None, ciphers=None, ssl_context=None, ca_cert_dir=None, key_password=None, ca_cert_data=None, ): """ All arguments except for server_hostname, ...
[ "def", "ssl_wrap_socket", "(", "sock", ",", "keyfile", "=", "None", ",", "certfile", "=", "None", ",", "cert_reqs", "=", "None", ",", "ca_certs", "=", "None", ",", "server_hostname", "=", "None", ",", "ssl_version", "=", "None", ",", "ciphers", "=", "Non...
[ 298, 0 ]
[ 389, 36 ]
python
en
['en', 'error', 'th']
False
is_ipaddress
(hostname)
Detects whether the hostname given is an IPv4 or IPv6 address. Also detects IPv6 addresses with Zone IDs. :param str hostname: Hostname to examine. :return: True if the hostname is an IP address, False otherwise.
Detects whether the hostname given is an IPv4 or IPv6 address. Also detects IPv6 addresses with Zone IDs.
def is_ipaddress(hostname): """Detects whether the hostname given is an IPv4 or IPv6 address. Also detects IPv6 addresses with Zone IDs. :param str hostname: Hostname to examine. :return: True if the hostname is an IP address, False otherwise. """ if not six.PY2 and isinstance(hostname, bytes):...
[ "def", "is_ipaddress", "(", "hostname", ")", ":", "if", "not", "six", ".", "PY2", "and", "isinstance", "(", "hostname", ",", "bytes", ")", ":", "# IDN A-label bytes are ASCII compatible.", "hostname", "=", "hostname", ".", "decode", "(", "\"ascii\"", ")", "ret...
[ 392, 0 ]
[ 402, 83 ]
python
en
['en', 'en', 'en']
True
_is_key_file_encrypted
(key_file)
Detects if a key file is encrypted or not.
Detects if a key file is encrypted or not.
def _is_key_file_encrypted(key_file): """Detects if a key file is encrypted or not.""" with open(key_file, "r") as f: for line in f: # Look for Proc-Type: 4,ENCRYPTED if "ENCRYPTED" in line: return True return False
[ "def", "_is_key_file_encrypted", "(", "key_file", ")", ":", "with", "open", "(", "key_file", ",", "\"r\"", ")", "as", "f", ":", "for", "line", "in", "f", ":", "# Look for Proc-Type: 4,ENCRYPTED", "if", "\"ENCRYPTED\"", "in", "line", ":", "return", "True", "r...
[ 405, 0 ]
[ 413, 16 ]
python
en
['en', 'en', 'en']
True
get_active_worker_queues
(only_test_queues: bool = False)
Returns all (either test, or real) worker queues.
Returns all (either test, or real) worker queues.
def get_active_worker_queues(only_test_queues: bool = False) -> List[str]: """Returns all (either test, or real) worker queues.""" return [ queue_name for queue_name in worker_classes.keys() if bool(queue_name in test_queues) == only_test_queues ]
[ "def", "get_active_worker_queues", "(", "only_test_queues", ":", "bool", "=", "False", ")", "->", "List", "[", "str", "]", ":", "return", "[", "queue_name", "for", "queue_name", "in", "worker_classes", ".", "keys", "(", ")", "if", "bool", "(", "queue_name", ...
[ 154, 0 ]
[ 160, 5 ]
python
en
['en', 'en', 'en']
True
LoopQueueProcessingWorker.consume
(self, event: Dict[str, Any])
In LoopQueueProcessingWorker, consume is used just for automated tests
In LoopQueueProcessingWorker, consume is used just for automated tests
def consume(self, event: Dict[str, Any]) -> None: """In LoopQueueProcessingWorker, consume is used just for automated tests""" self.consume_batch([event])
[ "def", "consume", "(", "self", ",", "event", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "None", ":", "self", ".", "consume_batch", "(", "[", "event", "]", ")" ]
[ 407, 4 ]
[ 409, 35 ]
python
en
['en', 'en', 'en']
True
register_default_envs
(env_registry)
Register default envs. For this set of env families we register a function that can later create an actual registry entry when required. This allows us to import only Python modules that we use.
Register default envs. For this set of env families we register a function that can later create an actual registry entry when required. This allows us to import only Python modules that we use.
def register_default_envs(env_registry): """ Register default envs. For this set of env families we register a function that can later create an actual registry entry when required. This allows us to import only Python modules that we use. """ def doom_funcs(): from envs.doom.doom_utils...
[ "def", "register_default_envs", "(", "env_registry", ")", ":", "def", "doom_funcs", "(", ")", ":", "from", "envs", ".", "doom", ".", "doom_utils", "import", "make_doom_env", "from", "envs", ".", "doom", ".", "doom_params", "import", "add_doom_env_args", ",", "...
[ 85, 0 ]
[ 139, 91 ]
python
en
['en', 'error', 'th']
False
global_env_registry
()
:return: global env registry :rtype: EnvRegistry
:return: global env registry :rtype: EnvRegistry
def global_env_registry(): """ :return: global env registry :rtype: EnvRegistry """ ensure_env_registry_initialized() return ENV_REGISTRY
[ "def", "global_env_registry", "(", ")", ":", "ensure_env_registry_initialized", "(", ")", "return", "ENV_REGISTRY" ]
[ 152, 0 ]
[ 158, 23 ]
python
en
['en', 'error', 'th']
False
EnvRegistry.register_env
( self, env_name_prefix, make_env_func, add_extra_params_func=None, override_default_params_func=None, )
A standard thing to do in RL frameworks is to just rely on unique environment names registered in Gym. SampleFactory supports a mechanism on top of that, we define "environment families", e.g. "atari", or "doom", and certain things can be defined per env family rather than for specific environm...
A standard thing to do in RL frameworks is to just rely on unique environment names registered in Gym. SampleFactory supports a mechanism on top of that, we define "environment families", e.g. "atari", or "doom", and certain things can be defined per env family rather than for specific environm...
def register_env( self, env_name_prefix, make_env_func, add_extra_params_func=None, override_default_params_func=None, ): """ A standard thing to do in RL frameworks is to just rely on unique environment names registered in Gym. SampleFactory supports a mechanism on top of that, ...
[ "def", "register_env", "(", "self", ",", "env_name_prefix", ",", "make_env_func", ",", "add_extra_params_func", "=", "None", ",", "override_default_params_func", "=", "None", ",", ")", ":", "assert", "callable", "(", "make_env_func", ")", ",", "'make_env_func should...
[ 17, 4 ]
[ 58, 68 ]
python
en
['en', 'error', 'th']
False
EnvRegistry.register_env_deferred
(self, env_name_prefix, register_env_family_func)
Same as register_env but we defer the creation of the registry entry until we actually need it.
Same as register_env but we defer the creation of the registry entry until we actually need it.
def register_env_deferred(self, env_name_prefix, register_env_family_func): """Same as register_env but we defer the creation of the registry entry until we actually need it.""" assert callable(register_env_family_func) self.registry[env_name_prefix] = register_env_family_func
[ "def", "register_env_deferred", "(", "self", ",", "env_name_prefix", ",", "register_env_family_func", ")", ":", "assert", "callable", "(", "register_env_family_func", ")", "self", ".", "registry", "[", "env_name_prefix", "]", "=", "register_env_family_func" ]
[ 60, 4 ]
[ 64, 65 ]
python
en
['en', 'en', 'en']
True
EnvRegistry.resolve_env_name
(self, full_env_name)
:param full_env_name: complete name of the environment, to be passed to the make_env_func, e.g. atari_breakout :return: env registry entry :rtype: EnvRegistryEntry
:param full_env_name: complete name of the environment, to be passed to the make_env_func, e.g. atari_breakout :return: env registry entry :rtype: EnvRegistryEntry
def resolve_env_name(self, full_env_name): """ :param full_env_name: complete name of the environment, to be passed to the make_env_func, e.g. atari_breakout :return: env registry entry :rtype: EnvRegistryEntry """ # we find a match with a registered env family prefix ...
[ "def", "resolve_env_name", "(", "self", ",", "full_env_name", ")", ":", "# we find a match with a registered env family prefix", "for", "env_prefix", ",", "registry_entry", "in", "self", ".", "registry", ".", "items", "(", ")", ":", "if", "not", "full_env_name", "."...
[ 66, 4 ]
[ 82, 44 ]
python
en
['en', 'error', 'th']
False
getTreeBuilder
(treeType, implementation=None, **kwargs)
Get a TreeBuilder class for various types of trees with built-in support :arg treeType: the name of the tree type required (case-insensitive). Supported values are: * "dom" - A generic builder for DOM implementations, defaulting to a xml.dom.minidom based implementation. * "etree...
Get a TreeBuilder class for various types of trees with built-in support
def getTreeBuilder(treeType, implementation=None, **kwargs): """Get a TreeBuilder class for various types of trees with built-in support :arg treeType: the name of the tree type required (case-insensitive). Supported values are: * "dom" - A generic builder for DOM implementations, defaulting t...
[ "def", "getTreeBuilder", "(", "treeType", ",", "implementation", "=", "None", ",", "*", "*", "kwargs", ")", ":", "treeType", "=", "treeType", ".", "lower", "(", ")", "if", "treeType", "not", "in", "treeBuilderCache", ":", "if", "treeType", "==", "\"dom\"",...
[ 38, 0 ]
[ 87, 41 ]
python
en
['en', 'en', 'en']
True
load
(root)
Given a source directory (root) of a package, return an importlib.metadata.Distribution object with metadata build from that package.
Given a source directory (root) of a package, return an importlib.metadata.Distribution object with metadata build from that package.
def load(root): """ Given a source directory (root) of a package, return an importlib.metadata.Distribution object with metadata build from that package. """ root = os.path.expanduser(root) system = compat_system(root) builder = functools.partial(build, source_dir=root, system=system) ...
[ "def", "load", "(", "root", ")", ":", "root", "=", "os", ".", "path", ".", "expanduser", "(", "root", ")", "system", "=", "compat_system", "(", "root", ")", "builder", "=", "functools", ".", "partial", "(", "build", ",", "source_dir", "=", "root", ",...
[ 61, 0 ]
[ 71, 42 ]
python
en
['en', 'error', 'th']
False
MultiTableMixin.handle_server_filter
(self, request, table=None)
Update the table server filter information in the session. Returns True if the filter has been changed.
Update the table server filter information in the session.
def handle_server_filter(self, request, table=None): """Update the table server filter information in the session. Returns True if the filter has been changed. """ if not table: table = self.get_table() filter_info = self.get_server_filter_info(request, table) ...
[ "def", "handle_server_filter", "(", "self", ",", "request", ",", "table", "=", "None", ")", ":", "if", "not", "table", ":", "table", "=", "self", ".", "get_table", "(", ")", "filter_info", "=", "self", ".", "get_server_filter_info", "(", "request", ",", ...
[ 159, 4 ]
[ 172, 37 ]
python
en
['en', 'en', 'en']
True
MultiTableMixin.update_server_filter_action
(self, request, table=None)
Update the table server side filter action. It is done based on the current filter. The filter info may be stored in the session and this will restore it.
Update the table server side filter action.
def update_server_filter_action(self, request, table=None): """Update the table server side filter action. It is done based on the current filter. The filter info may be stored in the session and this will restore it. """ if not table: table = self.get_table() ...
[ "def", "update_server_filter_action", "(", "self", ",", "request", ",", "table", "=", "None", ")", ":", "if", "not", "table", ":", "table", "=", "self", ".", "get_table", "(", ")", "filter_info", "=", "self", ".", "get_server_filter_info", "(", "request", ...
[ 174, 4 ]
[ 187, 69 ]
python
en
['en', 'en', 'en']
True
DataTableView.get_filters
(self, filters=None, filters_map=None)
Converts a string given by the user into a valid api filter value. :filters: Default filter values. {'filter1': filter_value, 'filter2': filter_value} :filters_map: mapping between user input and valid api filter values. {'filter_name':{_("true_value"):True, _("false_value"):Fal...
Converts a string given by the user into a valid api filter value.
def get_filters(self, filters=None, filters_map=None): """Converts a string given by the user into a valid api filter value. :filters: Default filter values. {'filter1': filter_value, 'filter2': filter_value} :filters_map: mapping between user input and valid api filter values. ...
[ "def", "get_filters", "(", "self", ",", "filters", "=", "None", ",", "filters_map", "=", "None", ")", ":", "filters", "=", "filters", "or", "{", "}", "filters_map", "=", "filters_map", "or", "{", "}", "filter_action", "=", "self", ".", "table", ".", "_...
[ 289, 4 ]
[ 313, 22 ]
python
en
['en', 'en', 'en']
True
serialize
(input, tree="etree", encoding=None, **serializer_opts)
Serializes the input token stream using the specified treewalker :arg input: the token stream to serialize :arg tree: the treewalker to use :arg encoding: the encoding to use :arg serializer_opts: any options to pass to the :py:class:`html5lib.serializer.HTMLSerializer` that gets created ...
Serializes the input token stream using the specified treewalker
def serialize(input, tree="etree", encoding=None, **serializer_opts): """Serializes the input token stream using the specified treewalker :arg input: the token stream to serialize :arg tree: the treewalker to use :arg encoding: the encoding to use :arg serializer_opts: any options to pass to the...
[ "def", "serialize", "(", "input", ",", "tree", "=", "\"etree\"", ",", "encoding", "=", "None", ",", "*", "*", "serializer_opts", ")", ":", "# XXX: Should we cache this?", "walker", "=", "treewalkers", ".", "getTreeWalker", "(", "tree", ")", "s", "=", "HTMLSe...
[ 74, 0 ]
[ 100, 44 ]
python
en
['en', 'en', 'en']
True
HTMLSerializer.__init__
(self, **kwargs)
Initialize HTMLSerializer :arg inject_meta_charset: Whether or not to inject the meta charset. Defaults to ``True``. :arg quote_attr_values: Whether to quote attribute values that don't require quoting per legacy browser behavior (``"legacy"``), when required by th...
Initialize HTMLSerializer
def __init__(self, **kwargs): """Initialize HTMLSerializer :arg inject_meta_charset: Whether or not to inject the meta charset. Defaults to ``True``. :arg quote_attr_values: Whether to quote attribute values that don't require quoting per legacy browser behavior (``"le...
[ "def", "__init__", "(", "self", ",", "*", "*", "kwargs", ")", ":", "unexpected_args", "=", "frozenset", "(", "kwargs", ")", "-", "frozenset", "(", "self", ".", "options", ")", "if", "len", "(", "unexpected_args", ")", ">", "0", ":", "raise", "TypeError...
[ 134, 4 ]
[ 221, 27 ]
python
de
['de', 'en', 'nl']
False
HTMLSerializer.render
(self, treewalker, encoding=None)
Serializes the stream from the treewalker into a string :arg treewalker: the treewalker to serialize :arg encoding: the string encoding to use :returns: the serialized tree Example: >>> from html5lib import parse, getTreeWalker >>> from html5lib.serializer import HTM...
Serializes the stream from the treewalker into a string
def render(self, treewalker, encoding=None): """Serializes the stream from the treewalker into a string :arg treewalker: the treewalker to serialize :arg encoding: the string encoding to use :returns: the serialized tree Example: >>> from html5lib import parse, getTr...
[ "def", "render", "(", "self", ",", "treewalker", ",", "encoding", "=", "None", ")", ":", "if", "encoding", ":", "return", "b\"\"", ".", "join", "(", "list", "(", "self", ".", "serialize", "(", "treewalker", ",", "encoding", ")", ")", ")", "else", ":"...
[ 374, 4 ]
[ 397, 60 ]
python
en
['en', 'en', 'en']
True
read_keys
(base, key)
Return list of registry keys.
Return list of registry keys.
def read_keys(base, key): """Return list of registry keys.""" try: handle = RegOpenKeyEx(base, key) except RegError: return None L = [] i = 0 while True: try: k = RegEnumKey(handle, i) except RegError: break L.append(k) i +=...
[ "def", "read_keys", "(", "base", ",", "key", ")", ":", "try", ":", "handle", "=", "RegOpenKeyEx", "(", "base", ",", "key", ")", "except", "RegError", ":", "return", "None", "L", "=", "[", "]", "i", "=", "0", "while", "True", ":", "try", ":", "k",...
[ 54, 0 ]
[ 69, 12 ]
python
en
['en', 'no', 'en']
True
read_values
(base, key)
Return dict of registry keys and values. All names are converted to lowercase.
Return dict of registry keys and values.
def read_values(base, key): """Return dict of registry keys and values. All names are converted to lowercase. """ try: handle = RegOpenKeyEx(base, key) except RegError: return None d = {} i = 0 while True: try: name, value, type = RegEnumValue(handle,...
[ "def", "read_values", "(", "base", ",", "key", ")", ":", "try", ":", "handle", "=", "RegOpenKeyEx", "(", "base", ",", "key", ")", "except", "RegError", ":", "return", "None", "d", "=", "{", "}", "i", "=", "0", "while", "True", ":", "try", ":", "n...
[ 71, 0 ]
[ 90, 12 ]
python
en
['en', 'en', 'en']
True
get_build_version
()
Return the version of MSVC that was used to build Python. For Python 2.3 and up, the version number is included in sys.version. For earlier versions, assume the compiler is MSVC 6.
Return the version of MSVC that was used to build Python.
def get_build_version(): """Return the version of MSVC that was used to build Python. For Python 2.3 and up, the version number is included in sys.version. For earlier versions, assume the compiler is MSVC 6. """ prefix = "MSC v." i = sys.version.find(prefix) if i == -1: return 6 ...
[ "def", "get_build_version", "(", ")", ":", "prefix", "=", "\"MSC v.\"", "i", "=", "sys", ".", "version", ".", "find", "(", "prefix", ")", "if", "i", "==", "-", "1", ":", "return", "6", "i", "=", "i", "+", "len", "(", "prefix", ")", "s", ",", "r...
[ 146, 0 ]
[ 169, 15 ]
python
en
['en', 'en', 'en']
True
get_build_architecture
()
Return the processor architecture. Possible results are "Intel" or "AMD64".
Return the processor architecture.
def get_build_architecture(): """Return the processor architecture. Possible results are "Intel" or "AMD64". """ prefix = " bit (" i = sys.version.find(prefix) if i == -1: return "Intel" j = sys.version.find(")", i) return sys.version[i+len(prefix):j]
[ "def", "get_build_architecture", "(", ")", ":", "prefix", "=", "\" bit (\"", "i", "=", "sys", ".", "version", ".", "find", "(", "prefix", ")", "if", "i", "==", "-", "1", ":", "return", "\"Intel\"", "j", "=", "sys", ".", "version", ".", "find", "(", ...
[ 171, 0 ]
[ 182, 39 ]
python
en
['en', 'it', 'en']
True
normalize_and_reduce_paths
(paths)
Return a list of normalized paths with duplicates removed. The current order of paths is maintained.
Return a list of normalized paths with duplicates removed.
def normalize_and_reduce_paths(paths): """Return a list of normalized paths with duplicates removed. The current order of paths is maintained. """ # Paths are normalized so things like: /a and /a/ aren't both preserved. reduced_paths = [] for p in paths: np = os.path.normpath(p) ...
[ "def", "normalize_and_reduce_paths", "(", "paths", ")", ":", "# Paths are normalized so things like: /a and /a/ aren't both preserved.", "reduced_paths", "=", "[", "]", "for", "p", "in", "paths", ":", "np", "=", "os", ".", "path", ".", "normpath", "(", "p", ")", ...
[ 184, 0 ]
[ 196, 24 ]
python
en
['en', 'en', 'en']
True
MSVCCompiler.find_exe
(self, exe)
Return path to an MSVC executable program. Tries to find the program in several places: first, one of the MSVC program search paths from the registry; next, the directories in the PATH environment variable. If any of those work, return an absolute path that is known to exist. If none ...
Return path to an MSVC executable program.
def find_exe(self, exe): """Return path to an MSVC executable program. Tries to find the program in several places: first, one of the MSVC program search paths from the registry; next, the directories in the PATH environment variable. If any of those work, return an absolute pa...
[ "def", "find_exe", "(", "self", ",", "exe", ")", ":", "for", "p", "in", "self", ".", "__paths", ":", "fn", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "abspath", "(", "p", ")", ",", "exe", ")", "if", "os", ".", "path", ...
[ 564, 4 ]
[ 584, 18 ]
python
en
['en', 'en', 'en']
True
MSVCCompiler.get_msvc_paths
(self, path, platform='x86')
Get a list of devstudio directories (include, lib or path). Return a list of strings. The list will be empty if unable to access the registry or appropriate registry keys not found.
Get a list of devstudio directories (include, lib or path).
def get_msvc_paths(self, path, platform='x86'): """Get a list of devstudio directories (include, lib or path). Return a list of strings. The list will be empty if unable to access the registry or appropriate registry keys not found. """ if not _can_read_reg: return ...
[ "def", "get_msvc_paths", "(", "self", ",", "path", ",", "platform", "=", "'x86'", ")", ":", "if", "not", "_can_read_reg", ":", "return", "[", "]", "path", "=", "path", "+", "\" dirs\"", "if", "self", ".", "__version", ">=", "7", ":", "key", "=", "(",...
[ 586, 4 ]
[ 620, 17 ]
python
en
['en', 'en', 'en']
True
MSVCCompiler.set_path_env_var
(self, name)
Set environment variable 'name' to an MSVC path type value. This is equivalent to a SET command prior to execution of spawned commands.
Set environment variable 'name' to an MSVC path type value.
def set_path_env_var(self, name): """Set environment variable 'name' to an MSVC path type value. This is equivalent to a SET command prior to execution of spawned commands. """ if name == "lib": p = self.get_msvc_paths("library") else: p = self.g...
[ "def", "set_path_env_var", "(", "self", ",", "name", ")", ":", "if", "name", "==", "\"lib\"", ":", "p", "=", "self", ".", "get_msvc_paths", "(", "\"library\"", ")", "else", ":", "p", "=", "self", ".", "get_msvc_paths", "(", "name", ")", "if", "p", ":...
[ 622, 4 ]
[ 634, 42 ]
python
en
['en', 'en', 'en']
True
make_distribution_for_install_requirement
(install_req)
Returns a Distribution for the given InstallRequirement
Returns a Distribution for the given InstallRequirement
def make_distribution_for_install_requirement(install_req): # type: (InstallRequirement) -> AbstractDistribution """Returns a Distribution for the given InstallRequirement """ # Editable requirements will always be source distributions. They use the # legacy logic until we create a modern standard f...
[ "def", "make_distribution_for_install_requirement", "(", "install_req", ")", ":", "# type: (InstallRequirement) -> AbstractDistribution", "# Editable requirements will always be source distributions. They use the", "# legacy logic until we create a modern standard for them.", "if", "install_req"...
[ 9, 0 ]
[ 23, 42 ]
python
en
['en', 'en', 'en']
True
mkpath
(name, mode=0o777, verbose=1, dry_run=0)
Create a directory and any missing ancestor directories. If the directory already exists (or if 'name' is the empty string, which means the current directory, which of course exists), then do nothing. Raise DistutilsFileError if unable to create some directory along the way (eg. some sub-path exists, b...
Create a directory and any missing ancestor directories.
def mkpath(name, mode=0o777, verbose=1, dry_run=0): """Create a directory and any missing ancestor directories. If the directory already exists (or if 'name' is the empty string, which means the current directory, which of course exists), then do nothing. Raise DistutilsFileError if unable to create so...
[ "def", "mkpath", "(", "name", ",", "mode", "=", "0o777", ",", "verbose", "=", "1", ",", "dry_run", "=", "0", ")", ":", "global", "_path_created", "# Detect a common bug -- name is None", "if", "not", "isinstance", "(", "name", ",", "str", ")", ":", "raise"...
[ 16, 0 ]
[ 77, 23 ]
python
en
['en', 'en', 'en']
True
create_tree
(base_dir, files, mode=0o777, verbose=1, dry_run=0)
Create all the empty directories under 'base_dir' needed to put 'files' there. 'base_dir' is just the name of a directory which doesn't necessarily exist yet; 'files' is a list of filenames to be interpreted relative to 'base_dir'. 'base_dir' + the directory portion of every file in 'files' will b...
Create all the empty directories under 'base_dir' needed to put 'files' there.
def create_tree(base_dir, files, mode=0o777, verbose=1, dry_run=0): """Create all the empty directories under 'base_dir' needed to put 'files' there. 'base_dir' is just the name of a directory which doesn't necessarily exist yet; 'files' is a list of filenames to be interpreted relative to 'base_di...
[ "def", "create_tree", "(", "base_dir", ",", "files", ",", "mode", "=", "0o777", ",", "verbose", "=", "1", ",", "dry_run", "=", "0", ")", ":", "# First get the list of directories to create", "need_dir", "=", "set", "(", ")", "for", "file", "in", "files", "...
[ 79, 0 ]
[ 96, 59 ]
python
en
['en', 'en', 'en']
True
copy_tree
(src, dst, preserve_mode=1, preserve_times=1, preserve_symlinks=0, update=0, verbose=1, dry_run=0)
Copy an entire directory tree 'src' to a new location 'dst'. Both 'src' and 'dst' must be directory names. If 'src' is not a directory, raise DistutilsFileError. If 'dst' does not exist, it is created with 'mkpath()'. The end result of the copy is that every file in 'src' is copied to 'dst', and dir...
Copy an entire directory tree 'src' to a new location 'dst'.
def copy_tree(src, dst, preserve_mode=1, preserve_times=1, preserve_symlinks=0, update=0, verbose=1, dry_run=0): """Copy an entire directory tree 'src' to a new location 'dst'. Both 'src' and 'dst' must be directory names. If 'src' is not a directory, raise DistutilsFileError. If 'dst' does...
[ "def", "copy_tree", "(", "src", ",", "dst", ",", "preserve_mode", "=", "1", ",", "preserve_times", "=", "1", ",", "preserve_symlinks", "=", "0", ",", "update", "=", "0", ",", "verbose", "=", "1", ",", "dry_run", "=", "0", ")", ":", "from", "distutils...
[ 98, 0 ]
[ 165, 18 ]
python
en
['en', 'en', 'en']
True
_build_cmdtuple
(path, cmdtuples)
Helper for remove_tree().
Helper for remove_tree().
def _build_cmdtuple(path, cmdtuples): """Helper for remove_tree().""" for f in os.listdir(path): real_f = os.path.join(path,f) if os.path.isdir(real_f) and not os.path.islink(real_f): _build_cmdtuple(real_f, cmdtuples) else: cmdtuples.append((os.remove, real_f)) ...
[ "def", "_build_cmdtuple", "(", "path", ",", "cmdtuples", ")", ":", "for", "f", "in", "os", ".", "listdir", "(", "path", ")", ":", "real_f", "=", "os", ".", "path", ".", "join", "(", "path", ",", "f", ")", "if", "os", ".", "path", ".", "isdir", ...
[ 167, 0 ]
[ 175, 38 ]
python
da
['da', 'it', 'en']
False
remove_tree
(directory, verbose=1, dry_run=0)
Recursively remove an entire directory tree. Any errors are ignored (apart from being reported to stdout if 'verbose' is true).
Recursively remove an entire directory tree.
def remove_tree(directory, verbose=1, dry_run=0): """Recursively remove an entire directory tree. Any errors are ignored (apart from being reported to stdout if 'verbose' is true). """ global _path_created if verbose >= 1: log.info("removing '%s' (and everything under it)", directory) ...
[ "def", "remove_tree", "(", "directory", ",", "verbose", "=", "1", ",", "dry_run", "=", "0", ")", ":", "global", "_path_created", "if", "verbose", ">=", "1", ":", "log", ".", "info", "(", "\"removing '%s' (and everything under it)\"", ",", "directory", ")", "...
[ 177, 0 ]
[ 199, 61 ]
python
en
['en', 'en', 'en']
True
ensure_relative
(path)
Take the full path 'path', and make it a relative path. This is useful to make 'path' the second argument to os.path.join().
Take the full path 'path', and make it a relative path.
def ensure_relative(path): """Take the full path 'path', and make it a relative path. This is useful to make 'path' the second argument to os.path.join(). """ drive, path = os.path.splitdrive(path) if path[0:1] == os.sep: path = drive + path[1:] return path
[ "def", "ensure_relative", "(", "path", ")", ":", "drive", ",", "path", "=", "os", ".", "path", ".", "splitdrive", "(", "path", ")", "if", "path", "[", "0", ":", "1", "]", "==", "os", ".", "sep", ":", "path", "=", "drive", "+", "path", "[", "1",...
[ 201, 0 ]
[ 209, 15 ]
python
en
['en', 'en', 'en']
True
get_realm_email_validator
(realm: Realm)
RESTRICTIVE REALMS: Some realms only allow emails within a set of domains that are configured in RealmDomain. We get the set of domains up front so that folks can validate multiple emails without multiple round trips to the database.
RESTRICTIVE REALMS:
def get_realm_email_validator(realm: Realm) -> Callable[[str], None]: if not realm.emails_restricted_to_domains: # Should we also do '+' check for non-resticted realms? if realm.disallow_disposable_email_addresses: return validate_disposable # allow any email through ret...
[ "def", "get_realm_email_validator", "(", "realm", ":", "Realm", ")", "->", "Callable", "[", "[", "str", "]", ",", "None", "]", ":", "if", "not", "realm", ".", "emails_restricted_to_domains", ":", "# Should we also do '+' check for non-resticted realms?", "if", "real...
[ 27, 0 ]
[ 76, 19 ]
python
en
['en', 'error', 'th']
False
email_allowed_for_realm
(email: str, realm: Realm)
Avoid calling this in a loop! Instead, call get_realm_email_validator() outside of the loop.
Avoid calling this in a loop! Instead, call get_realm_email_validator() outside of the loop.
def email_allowed_for_realm(email: str, realm: Realm) -> None: """ Avoid calling this in a loop! Instead, call get_realm_email_validator() outside of the loop. """ get_realm_email_validator(realm)(email)
[ "def", "email_allowed_for_realm", "(", "email", ":", "str", ",", "realm", ":", "Realm", ")", "->", "None", ":", "get_realm_email_validator", "(", "realm", ")", "(", "email", ")" ]
[ 83, 0 ]
[ 89, 43 ]
python
en
['en', 'error', 'th']
False
get_existing_user_errors
( target_realm: Realm, emails: Set[str], verbose: bool = False, )
We use this function even for a list of one emails. It checks "new" emails to make sure that they don't already exist. There's a bit of fiddly logic related to cross-realm bots and mirror dummies too.
We use this function even for a list of one emails.
def get_existing_user_errors( target_realm: Realm, emails: Set[str], verbose: bool = False, ) -> Dict[str, Tuple[str, bool]]: """ We use this function even for a list of one emails. It checks "new" emails to make sure that they don't already exist. There's a bit of fiddly logic related ...
[ "def", "get_existing_user_errors", "(", "target_realm", ":", "Realm", ",", "emails", ":", "Set", "[", "str", "]", ",", "verbose", ":", "bool", "=", "False", ",", ")", "->", "Dict", "[", "str", ",", "Tuple", "[", "str", ",", "bool", "]", "]", ":", "...
[ 118, 0 ]
[ 188, 17 ]
python
en
['en', 'error', 'th']
False
validate_email_not_already_in_realm
( target_realm: Realm, email: str, verbose: bool = True )
NOTE: Only use this to validate that a single email is not already used in the realm. We should start using bulk_check_new_emails() for any endpoint that takes multiple emails, such as the "invite" interface.
NOTE: Only use this to validate that a single email is not already used in the realm.
def validate_email_not_already_in_realm( target_realm: Realm, email: str, verbose: bool = True ) -> None: """ NOTE: Only use this to validate that a single email is not already used in the realm. We should start using bulk_check_new_emails() for any endpoint that takes multi...
[ "def", "validate_email_not_already_in_realm", "(", "target_realm", ":", "Realm", ",", "email", ":", "str", ",", "verbose", ":", "bool", "=", "True", ")", "->", "None", ":", "error_dict", "=", "get_existing_user_errors", "(", "target_realm", ",", "{", "email", ...
[ 191, 0 ]
[ 209, 34 ]
python
en
['en', 'error', 'th']
False
setup
(**attrs)
The gateway to the Distutils: do everything your setup script needs to do, in a highly flexible and user-driven way. Briefly: create a Distribution instance; find and parse config files; parse the command line; run each Distutils command found there, customized by the options supplied to 'setup()' (as ...
The gateway to the Distutils: do everything your setup script needs to do, in a highly flexible and user-driven way. Briefly: create a Distribution instance; find and parse config files; parse the command line; run each Distutils command found there, customized by the options supplied to 'setup()' (as ...
def setup (**attrs): """The gateway to the Distutils: do everything your setup script needs to do, in a highly flexible and user-driven way. Briefly: create a Distribution instance; find and parse config files; parse the command line; run each Distutils command found there, customized by the options ...
[ "def", "setup", "(", "*", "*", "attrs", ")", ":", "global", "_setup_stop_after", ",", "_setup_distribution", "# Determine the distribution class -- either caller-supplied or", "# our Distribution (see below).", "klass", "=", "attrs", ".", "get", "(", "'distclass'", ")", "...
[ 56, 0 ]
[ 164, 15 ]
python
en
['en', 'en', 'en']
True
run_setup
(script_name, script_args=None, stop_after="run")
Run a setup script in a somewhat controlled environment, and return the Distribution instance that drives things. This is useful if you need to find out the distribution meta-data (passed as keyword args from 'script' to 'setup()', or the contents of the config files or command-line. 'script_name'...
Run a setup script in a somewhat controlled environment, and return the Distribution instance that drives things. This is useful if you need to find out the distribution meta-data (passed as keyword args from 'script' to 'setup()', or the contents of the config files or command-line.
def run_setup (script_name, script_args=None, stop_after="run"): """Run a setup script in a somewhat controlled environment, and return the Distribution instance that drives things. This is useful if you need to find out the distribution meta-data (passed as keyword args from 'script' to 'setup()', or ...
[ "def", "run_setup", "(", "script_name", ",", "script_args", "=", "None", ",", "stop_after", "=", "\"run\"", ")", ":", "if", "stop_after", "not", "in", "(", "'init'", ",", "'config'", ",", "'commandline'", ",", "'run'", ")", ":", "raise", "ValueError", "(",...
[ 169, 0 ]
[ 231, 30 ]
python
en
['en', 'en', 'en']
True
stn
(s, length, encoding, errors)
Convert a string to a null-terminated bytes object.
Convert a string to a null-terminated bytes object.
def stn(s, length, encoding, errors): """Convert a string to a null-terminated bytes object. """ s = s.encode(encoding, errors) return s[:length] + (length - len(s)) * NUL
[ "def", "stn", "(", "s", ",", "length", ",", "encoding", ",", "errors", ")", ":", "s", "=", "s", ".", "encode", "(", "encoding", ",", "errors", ")", "return", "s", "[", ":", "length", "]", "+", "(", "length", "-", "len", "(", "s", ")", ")", "*...
[ 184, 0 ]
[ 188, 47 ]
python
en
['en', 'en', 'en']
True
nts
(s, encoding, errors)
Convert a null-terminated bytes object to a string.
Convert a null-terminated bytes object to a string.
def nts(s, encoding, errors): """Convert a null-terminated bytes object to a string. """ p = s.find(b"\0") if p != -1: s = s[:p] return s.decode(encoding, errors)
[ "def", "nts", "(", "s", ",", "encoding", ",", "errors", ")", ":", "p", "=", "s", ".", "find", "(", "b\"\\0\"", ")", "if", "p", "!=", "-", "1", ":", "s", "=", "s", "[", ":", "p", "]", "return", "s", ".", "decode", "(", "encoding", ",", "erro...
[ 190, 0 ]
[ 196, 37 ]
python
en
['en', 'en', 'en']
True
nti
(s)
Convert a number field to a python number.
Convert a number field to a python number.
def nti(s): """Convert a number field to a python number. """ # There are two possible encodings for a number field, see # itn() below. if s[0] != chr(0o200): try: n = int(nts(s, "ascii", "strict") or "0", 8) except ValueError: raise InvalidHeaderError("invali...
[ "def", "nti", "(", "s", ")", ":", "# There are two possible encodings for a number field, see", "# itn() below.", "if", "s", "[", "0", "]", "!=", "chr", "(", "0o200", ")", ":", "try", ":", "n", "=", "int", "(", "nts", "(", "s", ",", "\"ascii\"", ",", "\"...
[ 198, 0 ]
[ 213, 12 ]
python
en
['en', 'en', 'en']
True
itn
(n, digits=8, format=DEFAULT_FORMAT)
Convert a python number to a number field.
Convert a python number to a number field.
def itn(n, digits=8, format=DEFAULT_FORMAT): """Convert a python number to a number field. """ # POSIX 1003.1-1988 requires numbers to be encoded as a string of # octal digits followed by a null-byte, this allows values up to # (8**(digits-1))-1. GNU tar allows storing numbers greater than # tha...
[ "def", "itn", "(", "n", ",", "digits", "=", "8", ",", "format", "=", "DEFAULT_FORMAT", ")", ":", "# POSIX 1003.1-1988 requires numbers to be encoded as a string of", "# octal digits followed by a null-byte, this allows values up to", "# (8**(digits-1))-1. GNU tar allows storing numbe...
[ 215, 0 ]
[ 240, 12 ]
python
en
['en', 'en', 'en']
True
calc_chksums
(buf)
Calculate the checksum for a member's header by summing up all characters except for the chksum field which is treated as if it was filled with spaces. According to the GNU tar sources, some tars (Sun and NeXT) calculate chksum with signed char, which will be different if there are chars in ...
Calculate the checksum for a member's header by summing up all characters except for the chksum field which is treated as if it was filled with spaces. According to the GNU tar sources, some tars (Sun and NeXT) calculate chksum with signed char, which will be different if there are chars in ...
def calc_chksums(buf): """Calculate the checksum for a member's header by summing up all characters except for the chksum field which is treated as if it was filled with spaces. According to the GNU tar sources, some tars (Sun and NeXT) calculate chksum with signed char, which will be di...
[ "def", "calc_chksums", "(", "buf", ")", ":", "unsigned_chksum", "=", "256", "+", "sum", "(", "struct", ".", "unpack", "(", "\"148B\"", ",", "buf", "[", ":", "148", "]", ")", "+", "struct", ".", "unpack", "(", "\"356B\"", ",", "buf", "[", "156", ":"...
[ 242, 0 ]
[ 253, 41 ]
python
en
['en', 'en', 'en']
True
copyfileobj
(src, dst, length=None)
Copy length bytes from fileobj src to fileobj dst. If length is None, copy the entire content.
Copy length bytes from fileobj src to fileobj dst. If length is None, copy the entire content.
def copyfileobj(src, dst, length=None): """Copy length bytes from fileobj src to fileobj dst. If length is None, copy the entire content. """ if length == 0: return if length is None: while True: buf = src.read(16*1024) if not buf: break ...
[ "def", "copyfileobj", "(", "src", ",", "dst", ",", "length", "=", "None", ")", ":", "if", "length", "==", "0", ":", "return", "if", "length", "is", "None", ":", "while", "True", ":", "buf", "=", "src", ".", "read", "(", "16", "*", "1024", ")", ...
[ 255, 0 ]
[ 282, 10 ]
python
en
['en', 'pt', 'en']
True
filemode
(mode)
Convert a file's mode to a string of the form -rwxrwxrwx. Used by TarFile.list()
Convert a file's mode to a string of the form -rwxrwxrwx. Used by TarFile.list()
def filemode(mode): """Convert a file's mode to a string of the form -rwxrwxrwx. Used by TarFile.list() """ perm = [] for table in filemode_table: for bit, char in table: if mode & bit == bit: perm.append(char) break else: ...
[ "def", "filemode", "(", "mode", ")", ":", "perm", "=", "[", "]", "for", "table", "in", "filemode_table", ":", "for", "bit", ",", "char", "in", "table", ":", "if", "mode", "&", "bit", "==", "bit", ":", "perm", ".", "append", "(", "char", ")", "bre...
[ 311, 0 ]
[ 324, 24 ]
python
en
['en', 'en', 'en']
True
is_tarfile
(name)
Return True if name points to a tar archive that we are able to handle, else return False.
Return True if name points to a tar archive that we are able to handle, else return False.
def is_tarfile(name): """Return True if name points to a tar archive that we are able to handle, else return False. """ try: t = open(name) t.close() return True except TarError: return False
[ "def", "is_tarfile", "(", "name", ")", ":", "try", ":", "t", "=", "open", "(", "name", ")", "t", ".", "close", "(", ")", "return", "True", "except", "TarError", ":", "return", "False" ]
[ 2594, 0 ]
[ 2603, 20 ]
python
en
['en', 'en', 'en']
True
_Stream.__init__
(self, name, mode, comptype, fileobj, bufsize)
Construct a _Stream object.
Construct a _Stream object.
def __init__(self, name, mode, comptype, fileobj, bufsize): """Construct a _Stream object. """ self._extfileobj = True if fileobj is None: fileobj = _LowLevelFile(name, mode) self._extfileobj = False if comptype == '*': # Enable transparent co...
[ "def", "__init__", "(", "self", ",", "name", ",", "mode", ",", "comptype", ",", "fileobj", ",", "bufsize", ")", ":", "self", ".", "_extfileobj", "=", "True", "if", "fileobj", "is", "None", ":", "fileobj", "=", "_LowLevelFile", "(", "name", ",", "mode",...
[ 398, 4 ]
[ 448, 17 ]
python
en
['en', 'en', 'en']
True
_Stream._init_write_gz
(self)
Initialize for writing with gzip compression.
Initialize for writing with gzip compression.
def _init_write_gz(self): """Initialize for writing with gzip compression. """ self.cmp = self.zlib.compressobj(9, self.zlib.DEFLATED, -self.zlib.MAX_WBITS, self.zlib.DEF_MEM_LEVEL, ...
[ "def", "_init_write_gz", "(", "self", ")", ":", "self", ".", "cmp", "=", "self", ".", "zlib", ".", "compressobj", "(", "9", ",", "self", ".", "zlib", ".", "DEFLATED", ",", "-", "self", ".", "zlib", ".", "MAX_WBITS", ",", "self", ".", "zlib", ".", ...
[ 454, 4 ]
[ 466, 69 ]
python
en
['en', 'en', 'en']
True
_Stream.write
(self, s)
Write string s to the stream.
Write string s to the stream.
def write(self, s): """Write string s to the stream. """ if self.comptype == "gz": self.crc = self.zlib.crc32(s, self.crc) self.pos += len(s) if self.comptype != "tar": s = self.cmp.compress(s) self.__write(s)
[ "def", "write", "(", "self", ",", "s", ")", ":", "if", "self", ".", "comptype", "==", "\"gz\"", ":", "self", ".", "crc", "=", "self", ".", "zlib", ".", "crc32", "(", "s", ",", "self", ".", "crc", ")", "self", ".", "pos", "+=", "len", "(", "s"...
[ 468, 4 ]
[ 476, 23 ]
python
en
['en', 'en', 'en']
True
_Stream.__write
(self, s)
Write string s to the stream if a whole new block is ready to be written.
Write string s to the stream if a whole new block is ready to be written.
def __write(self, s): """Write string s to the stream if a whole new block is ready to be written. """ self.buf += s while len(self.buf) > self.bufsize: self.fileobj.write(self.buf[:self.bufsize]) self.buf = self.buf[self.bufsize:]
[ "def", "__write", "(", "self", ",", "s", ")", ":", "self", ".", "buf", "+=", "s", "while", "len", "(", "self", ".", "buf", ")", ">", "self", ".", "bufsize", ":", "self", ".", "fileobj", ".", "write", "(", "self", ".", "buf", "[", ":", "self", ...
[ 478, 4 ]
[ 485, 46 ]
python
en
['en', 'en', 'en']
True
_Stream.close
(self)
Close the _Stream object. No operation should be done on it afterwards.
Close the _Stream object. No operation should be done on it afterwards.
def close(self): """Close the _Stream object. No operation should be done on it afterwards. """ if self.closed: return if self.mode == "w" and self.comptype != "tar": self.buf += self.cmp.flush() if self.mode == "w" and self.buf: s...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "closed", ":", "return", "if", "self", ".", "mode", "==", "\"w\"", "and", "self", ".", "comptype", "!=", "\"tar\"", ":", "self", ".", "buf", "+=", "self", ".", "cmp", ".", "flush", "(", ")...
[ 487, 4 ]
[ 513, 26 ]
python
en
['en', 'en', 'en']
True
_Stream._init_read_gz
(self)
Initialize for reading a gzip compressed fileobj.
Initialize for reading a gzip compressed fileobj.
def _init_read_gz(self): """Initialize for reading a gzip compressed fileobj. """ self.cmp = self.zlib.decompressobj(-self.zlib.MAX_WBITS) self.dbuf = b"" # taken from gzip.GzipFile with some alterations if self.__read(2) != b"\037\213": raise ReadError("not ...
[ "def", "_init_read_gz", "(", "self", ")", ":", "self", ".", "cmp", "=", "self", ".", "zlib", ".", "decompressobj", "(", "-", "self", ".", "zlib", ".", "MAX_WBITS", ")", "self", ".", "dbuf", "=", "b\"\"", "# taken from gzip.GzipFile with some alterations", "i...
[ 515, 4 ]
[ 544, 26 ]
python
en
['en', 'en', 'pt']
True
_Stream.tell
(self)
Return the stream's file pointer position.
Return the stream's file pointer position.
def tell(self): """Return the stream's file pointer position. """ return self.pos
[ "def", "tell", "(", "self", ")", ":", "return", "self", ".", "pos" ]
[ 546, 4 ]
[ 549, 23 ]
python
en
['en', 'en', 'en']
True
_Stream.seek
(self, pos=0)
Set the stream's file pointer to pos. Negative seeking is forbidden.
Set the stream's file pointer to pos. Negative seeking is forbidden.
def seek(self, pos=0): """Set the stream's file pointer to pos. Negative seeking is forbidden. """ if pos - self.pos >= 0: blocks, remainder = divmod(pos - self.pos, self.bufsize) for i in range(blocks): self.read(self.bufsize) self....
[ "def", "seek", "(", "self", ",", "pos", "=", "0", ")", ":", "if", "pos", "-", "self", ".", "pos", ">=", "0", ":", "blocks", ",", "remainder", "=", "divmod", "(", "pos", "-", "self", ".", "pos", ",", "self", ".", "bufsize", ")", "for", "i", "i...
[ 551, 4 ]
[ 562, 23 ]
python
en
['en', 'en', 'en']
True
_Stream.read
(self, size=None)
Return the next size number of bytes from the stream. If size is not defined, return all bytes of the stream up to EOF.
Return the next size number of bytes from the stream. If size is not defined, return all bytes of the stream up to EOF.
def read(self, size=None): """Return the next size number of bytes from the stream. If size is not defined, return all bytes of the stream up to EOF. """ if size is None: t = [] while True: buf = self._read(self.bufsize) ...
[ "def", "read", "(", "self", ",", "size", "=", "None", ")", ":", "if", "size", "is", "None", ":", "t", "=", "[", "]", "while", "True", ":", "buf", "=", "self", ".", "_read", "(", "self", ".", "bufsize", ")", "if", "not", "buf", ":", "break", "...
[ 564, 4 ]
[ 580, 18 ]
python
en
['en', 'en', 'en']
True
_Stream._read
(self, size)
Return size bytes from the stream.
Return size bytes from the stream.
def _read(self, size): """Return size bytes from the stream. """ if self.comptype == "tar": return self.__read(size) c = len(self.dbuf) while c < size: buf = self.__read(self.bufsize) if not buf: break try: ...
[ "def", "_read", "(", "self", ",", "size", ")", ":", "if", "self", ".", "comptype", "==", "\"tar\"", ":", "return", "self", ".", "__read", "(", "size", ")", "c", "=", "len", "(", "self", ".", "dbuf", ")", "while", "c", "<", "size", ":", "buf", "...
[ 582, 4 ]
[ 601, 18 ]
python
en
['en', 'en', 'en']
True
_Stream.__read
(self, size)
Return size bytes from stream. If internal buffer is empty, read another block from the stream.
Return size bytes from stream. If internal buffer is empty, read another block from the stream.
def __read(self, size): """Return size bytes from stream. If internal buffer is empty, read another block from the stream. """ c = len(self.buf) while c < size: buf = self.fileobj.read(self.bufsize) if not buf: break self.buf...
[ "def", "__read", "(", "self", ",", "size", ")", ":", "c", "=", "len", "(", "self", ".", "buf", ")", "while", "c", "<", "size", ":", "buf", "=", "self", ".", "fileobj", ".", "read", "(", "self", ".", "bufsize", ")", "if", "not", "buf", ":", "b...
[ 603, 4 ]
[ 616, 18 ]
python
en
['en', 'fy', 'en']
True
_FileInFile.tell
(self)
Return the current file position.
Return the current file position.
def tell(self): """Return the current file position. """ return self.position
[ "def", "tell", "(", "self", ")", ":", "return", "self", ".", "position" ]
[ 741, 4 ]
[ 744, 28 ]
python
en
['en', 'en', 'en']
True
_FileInFile.seek
(self, position)
Seek to a position in the file.
Seek to a position in the file.
def seek(self, position): """Seek to a position in the file. """ self.position = position
[ "def", "seek", "(", "self", ",", "position", ")", ":", "self", ".", "position", "=", "position" ]
[ 746, 4 ]
[ 749, 32 ]
python
en
['en', 'en', 'en']
True
_FileInFile.read
(self, size=None)
Read data from the file.
Read data from the file.
def read(self, size=None): """Read data from the file. """ if size is None: size = self.size - self.position else: size = min(size, self.size - self.position) buf = b"" while size > 0: while True: data, start, stop, off...
[ "def", "read", "(", "self", ",", "size", "=", "None", ")", ":", "if", "size", "is", "None", ":", "size", "=", "self", ".", "size", "-", "self", ".", "position", "else", ":", "size", "=", "min", "(", "size", ",", "self", ".", "size", "-", "self"...
[ 751, 4 ]
[ 777, 18 ]
python
en
['en', 'en', 'en']
True
ExFileObject.read
(self, size=None)
Read at most size bytes from the file. If size is not present or None, read all data until EOF is reached.
Read at most size bytes from the file. If size is not present or None, read all data until EOF is reached.
def read(self, size=None): """Read at most size bytes from the file. If size is not present or None, read all data until EOF is reached. """ if self.closed: raise ValueError("I/O operation on closed file") buf = b"" if self.buffer: if size is N...
[ "def", "read", "(", "self", ",", "size", "=", "None", ")", ":", "if", "self", ".", "closed", ":", "raise", "ValueError", "(", "\"I/O operation on closed file\"", ")", "buf", "=", "b\"\"", "if", "self", ".", "buffer", ":", "if", "size", "is", "None", ":...
[ 809, 4 ]
[ 831, 18 ]
python
en
['en', 'en', 'en']
True
ExFileObject.readline
(self, size=-1)
Read one entire line from the file. If size is present and non-negative, return a string with at most that size, which may be an incomplete line.
Read one entire line from the file. If size is present and non-negative, return a string with at most that size, which may be an incomplete line.
def readline(self, size=-1): """Read one entire line from the file. If size is present and non-negative, return a string with at most that size, which may be an incomplete line. """ if self.closed: raise ValueError("I/O operation on closed file") pos = ...
[ "def", "readline", "(", "self", ",", "size", "=", "-", "1", ")", ":", "if", "self", ".", "closed", ":", "raise", "ValueError", "(", "\"I/O operation on closed file\"", ")", "pos", "=", "self", ".", "buffer", ".", "find", "(", "b\"\\n\"", ")", "+", "1",...
[ 836, 4 ]
[ 863, 18 ]
python
en
['en', 'en', 'en']
True
ExFileObject.readlines
(self)
Return a list with all remaining lines.
Return a list with all remaining lines.
def readlines(self): """Return a list with all remaining lines. """ result = [] while True: line = self.readline() if not line: break result.append(line) return result
[ "def", "readlines", "(", "self", ")", ":", "result", "=", "[", "]", "while", "True", ":", "line", "=", "self", ".", "readline", "(", ")", "if", "not", "line", ":", "break", "result", ".", "append", "(", "line", ")", "return", "result" ]
[ 865, 4 ]
[ 873, 21 ]
python
en
['en', 'en', 'en']
True
ExFileObject.tell
(self)
Return the current file position.
Return the current file position.
def tell(self): """Return the current file position. """ if self.closed: raise ValueError("I/O operation on closed file") return self.position
[ "def", "tell", "(", "self", ")", ":", "if", "self", ".", "closed", ":", "raise", "ValueError", "(", "\"I/O operation on closed file\"", ")", "return", "self", ".", "position" ]
[ 875, 4 ]
[ 881, 28 ]
python
en
['en', 'en', 'en']
True
ExFileObject.seek
(self, pos, whence=os.SEEK_SET)
Seek to a position in the file.
Seek to a position in the file.
def seek(self, pos, whence=os.SEEK_SET): """Seek to a position in the file. """ if self.closed: raise ValueError("I/O operation on closed file") if whence == os.SEEK_SET: self.position = min(max(pos, 0), self.size) elif whence == os.SEEK_CUR: ...
[ "def", "seek", "(", "self", ",", "pos", ",", "whence", "=", "os", ".", "SEEK_SET", ")", ":", "if", "self", ".", "closed", ":", "raise", "ValueError", "(", "\"I/O operation on closed file\"", ")", "if", "whence", "==", "os", ".", "SEEK_SET", ":", "self", ...
[ 883, 4 ]
[ 902, 40 ]
python
en
['en', 'en', 'en']
True
ExFileObject.close
(self)
Close the file object.
Close the file object.
def close(self): """Close the file object. """ self.closed = True
[ "def", "close", "(", "self", ")", ":", "self", ".", "closed", "=", "True" ]
[ 904, 4 ]
[ 907, 26 ]
python
en
['en', 'en', 'en']
True