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
CCompiler._fix_object_args
(self, objects, output_dir)
Typecheck and fix up some arguments supplied to various methods. Specifically: ensure that 'objects' is a list; if output_dir is None, replace with self.output_dir. Return fixed versions of 'objects' and 'output_dir'.
Typecheck and fix up some arguments supplied to various methods. Specifically: ensure that 'objects' is a list; if output_dir is None, replace with self.output_dir. Return fixed versions of 'objects' and 'output_dir'.
def _fix_object_args(self, objects, output_dir): """Typecheck and fix up some arguments supplied to various methods. Specifically: ensure that 'objects' is a list; if output_dir is None, replace with self.output_dir. Return fixed versions of 'objects' and 'output_dir'. """ ...
[ "def", "_fix_object_args", "(", "self", ",", "objects", ",", "output_dir", ")", ":", "if", "not", "isinstance", "(", "objects", ",", "(", "list", ",", "tuple", ")", ")", ":", "raise", "TypeError", "(", "\"'objects' must be a list or tuple of strings\"", ")", "...
[ 409, 4 ]
[ 424, 36 ]
python
en
['en', 'en', 'en']
True
CCompiler._fix_lib_args
(self, libraries, library_dirs, runtime_library_dirs)
Typecheck and fix up some of the arguments supplied to the 'link_*' methods. Specifically: ensure that all arguments are lists, and augment them with their permanent versions (eg. 'self.libraries' augments 'libraries'). Return a tuple with fixed versions of all arguments.
Typecheck and fix up some of the arguments supplied to the 'link_*' methods. Specifically: ensure that all arguments are lists, and augment them with their permanent versions (eg. 'self.libraries' augments 'libraries'). Return a tuple with fixed versions of all arguments.
def _fix_lib_args(self, libraries, library_dirs, runtime_library_dirs): """Typecheck and fix up some of the arguments supplied to the 'link_*' methods. Specifically: ensure that all arguments are lists, and augment them with their permanent versions (eg. 'self.libraries' augments 'libra...
[ "def", "_fix_lib_args", "(", "self", ",", "libraries", ",", "library_dirs", ",", "runtime_library_dirs", ")", ":", "if", "libraries", "is", "None", ":", "libraries", "=", "self", ".", "libraries", "elif", "isinstance", "(", "libraries", ",", "(", "list", ","...
[ 426, 4 ]
[ 458, 62 ]
python
en
['en', 'en', 'en']
True
CCompiler._need_link
(self, objects, output_file)
Return true if we need to relink the files listed in 'objects' to recreate 'output_file'.
Return true if we need to relink the files listed in 'objects' to recreate 'output_file'.
def _need_link(self, objects, output_file): """Return true if we need to relink the files listed in 'objects' to recreate 'output_file'. """ if self.force: return True else: if self.dry_run: newer = newer_group (objects, output_file, missin...
[ "def", "_need_link", "(", "self", ",", "objects", ",", "output_file", ")", ":", "if", "self", ".", "force", ":", "return", "True", "else", ":", "if", "self", ".", "dry_run", ":", "newer", "=", "newer_group", "(", "objects", ",", "output_file", ",", "mi...
[ 460, 4 ]
[ 471, 24 ]
python
en
['en', 'en', 'en']
True
CCompiler.detect_language
(self, sources)
Detect the language of a given file, or list of files. Uses language_map, and language_order to do the job.
Detect the language of a given file, or list of files. Uses language_map, and language_order to do the job.
def detect_language(self, sources): """Detect the language of a given file, or list of files. Uses language_map, and language_order to do the job. """ if not isinstance(sources, list): sources = [sources] lang = None index = len(self.language_order) fo...
[ "def", "detect_language", "(", "self", ",", "sources", ")", ":", "if", "not", "isinstance", "(", "sources", ",", "list", ")", ":", "sources", "=", "[", "sources", "]", "lang", "=", "None", "index", "=", "len", "(", "self", ".", "language_order", ")", ...
[ 473, 4 ]
[ 491, 19 ]
python
en
['en', 'en', 'en']
True
CCompiler.preprocess
(self, source, output_file=None, macros=None, include_dirs=None, extra_preargs=None, extra_postargs=None)
Preprocess a single C/C++ source file, named in 'source'. Output will be written to file named 'output_file', or stdout if 'output_file' not supplied. 'macros' is a list of macro definitions as for 'compile()', which will augment the macros set with 'define_macro()' and 'undefine_macro(...
Preprocess a single C/C++ source file, named in 'source'. Output will be written to file named 'output_file', or stdout if 'output_file' not supplied. 'macros' is a list of macro definitions as for 'compile()', which will augment the macros set with 'define_macro()' and 'undefine_macro(...
def preprocess(self, source, output_file=None, macros=None, include_dirs=None, extra_preargs=None, extra_postargs=None): """Preprocess a single C/C++ source file, named in 'source'. Output will be written to file named 'output_file', or stdout if 'output_file' not supplied. '...
[ "def", "preprocess", "(", "self", ",", "source", ",", "output_file", "=", "None", ",", "macros", "=", "None", ",", "include_dirs", "=", "None", ",", "extra_preargs", "=", "None", ",", "extra_postargs", "=", "None", ")", ":", "pass" ]
[ 497, 4 ]
[ 508, 12 ]
python
en
['en', 'en', 'en']
True
CCompiler.compile
(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None)
Compile one or more source files. 'sources' must be a list of filenames, most likely C/C++ files, but in reality anything that can be handled by a particular compiler and compiler class (eg. MSVCCompiler can handle resource files in 'sources'). Return a list of object filenames...
Compile one or more source files.
def compile(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None): """Compile one or more source files. 'sources' must be a list of filenames, most likely C/C++ files, but in reality anythi...
[ "def", "compile", "(", "self", ",", "sources", ",", "output_dir", "=", "None", ",", "macros", "=", "None", ",", "include_dirs", "=", "None", ",", "debug", "=", "0", ",", "extra_preargs", "=", "None", ",", "extra_postargs", "=", "None", ",", "depends", ...
[ 510, 4 ]
[ 576, 22 ]
python
en
['en', 'en', 'en']
True
CCompiler._compile
(self, obj, src, ext, cc_args, extra_postargs, pp_opts)
Compile 'src' to product 'obj'.
Compile 'src' to product 'obj'.
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): """Compile 'src' to product 'obj'.""" # A concrete compiler class that does not override compile() # should implement _compile(). pass
[ "def", "_compile", "(", "self", ",", "obj", ",", "src", ",", "ext", ",", "cc_args", ",", "extra_postargs", ",", "pp_opts", ")", ":", "# A concrete compiler class that does not override compile()", "# should implement _compile().", "pass" ]
[ 578, 4 ]
[ 582, 12 ]
python
en
['en', 'en', 'en']
True
CCompiler.create_static_lib
(self, objects, output_libname, output_dir=None, debug=0, target_lang=None)
Link a bunch of stuff together to create a static library file. The "bunch of stuff" consists of the list of object files supplied as 'objects', the extra object files supplied to 'add_link_object()' and/or 'set_link_objects()', the libraries supplied to 'add_library()' and/or 'set_libra...
Link a bunch of stuff together to create a static library file. The "bunch of stuff" consists of the list of object files supplied as 'objects', the extra object files supplied to 'add_link_object()' and/or 'set_link_objects()', the libraries supplied to 'add_library()' and/or 'set_libra...
def create_static_lib(self, objects, output_libname, output_dir=None, debug=0, target_lang=None): """Link a bunch of stuff together to create a static library file. The "bunch of stuff" consists of the list of object files supplied as 'objects', the extra object files s...
[ "def", "create_static_lib", "(", "self", ",", "objects", ",", "output_libname", ",", "output_dir", "=", "None", ",", "debug", "=", "0", ",", "target_lang", "=", "None", ")", ":", "pass" ]
[ 584, 4 ]
[ 608, 12 ]
python
en
['en', 'en', 'en']
True
CCompiler.link
(self, target_desc, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, ex...
Link a bunch of stuff together to create an executable or shared library file. The "bunch of stuff" consists of the list of object files supplied as 'objects'. 'output_filename' should be a filename. If 'output_dir' is supplied, 'output_filename' is relative to it (i.e. 'outpu...
Link a bunch of stuff together to create an executable or shared library file.
def link(self, target_desc, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, ...
[ "def", "link", "(", "self", ",", "target_desc", ",", "objects", ",", "output_filename", ",", "output_dir", "=", "None", ",", "libraries", "=", "None", ",", "library_dirs", "=", "None", ",", "runtime_library_dirs", "=", "None", ",", "export_symbols", "=", "No...
[ 616, 4 ]
[ 673, 33 ]
python
en
['en', 'en', 'en']
True
CCompiler.library_dir_option
(self, dir)
Return the compiler option to add 'dir' to the list of directories searched for libraries.
Return the compiler option to add 'dir' to the list of directories searched for libraries.
def library_dir_option(self, dir): """Return the compiler option to add 'dir' to the list of directories searched for libraries. """ raise NotImplementedError
[ "def", "library_dir_option", "(", "self", ",", "dir", ")", ":", "raise", "NotImplementedError" ]
[ 741, 4 ]
[ 745, 33 ]
python
en
['en', 'en', 'en']
True
CCompiler.runtime_library_dir_option
(self, dir)
Return the compiler option to add 'dir' to the list of directories searched for runtime libraries.
Return the compiler option to add 'dir' to the list of directories searched for runtime libraries.
def runtime_library_dir_option(self, dir): """Return the compiler option to add 'dir' to the list of directories searched for runtime libraries. """ raise NotImplementedError
[ "def", "runtime_library_dir_option", "(", "self", ",", "dir", ")", ":", "raise", "NotImplementedError" ]
[ 747, 4 ]
[ 751, 33 ]
python
en
['en', 'en', 'en']
True
CCompiler.library_option
(self, lib)
Return the compiler option to add 'lib' to the list of libraries linked into the shared library or executable.
Return the compiler option to add 'lib' to the list of libraries linked into the shared library or executable.
def library_option(self, lib): """Return the compiler option to add 'lib' to the list of libraries linked into the shared library or executable. """ raise NotImplementedError
[ "def", "library_option", "(", "self", ",", "lib", ")", ":", "raise", "NotImplementedError" ]
[ 753, 4 ]
[ 757, 33 ]
python
en
['en', 'en', 'en']
True
CCompiler.has_function
(self, funcname, includes=None, include_dirs=None, libraries=None, library_dirs=None)
Return a boolean indicating whether funcname is supported on the current platform. The optional arguments can be used to augment the compilation environment.
Return a boolean indicating whether funcname is supported on the current platform. The optional arguments can be used to augment the compilation environment.
def has_function(self, funcname, includes=None, include_dirs=None, libraries=None, library_dirs=None): """Return a boolean indicating whether funcname is supported on the current platform. The optional arguments can be used to augment the compilation environment. ""...
[ "def", "has_function", "(", "self", ",", "funcname", ",", "includes", "=", "None", ",", "include_dirs", "=", "None", ",", "libraries", "=", "None", ",", "library_dirs", "=", "None", ")", ":", "# this can't be included at module scope because it tries to", "# import ...
[ 759, 4 ]
[ 801, 19 ]
python
en
['en', 'en', 'en']
True
CCompiler.find_library_file
(self, dirs, lib, debug=0)
Search the specified list of directories for a static or shared library file 'lib' and return the full path to that file. If 'debug' true, look for a debugging version (if that makes sense on the current platform). Return None if 'lib' wasn't found in any of the specified directories. ...
Search the specified list of directories for a static or shared library file 'lib' and return the full path to that file. If 'debug' true, look for a debugging version (if that makes sense on the current platform). Return None if 'lib' wasn't found in any of the specified directories. ...
def find_library_file (self, dirs, lib, debug=0): """Search the specified list of directories for a static or shared library file 'lib' and return the full path to that file. If 'debug' true, look for a debugging version (if that makes sense on the current platform). Return None if 'li...
[ "def", "find_library_file", "(", "self", ",", "dirs", ",", "lib", ",", "debug", "=", "0", ")", ":", "raise", "NotImplementedError" ]
[ 803, 4 ]
[ 810, 33 ]
python
en
['en', 'en', 'en']
True
run_canary
()
Runs some code that will crash if the GPUs / GPU driver are suffering from a common bug. This helps to prevent contaminating results in the rest of the library with incorrect calculations.
Runs some code that will crash if the GPUs / GPU driver are suffering from a common bug. This helps to prevent contaminating results in the rest of the library with incorrect calculations.
def run_canary(): """ Runs some code that will crash if the GPUs / GPU driver are suffering from a common bug. This helps to prevent contaminating results in the rest of the library with incorrect calculations. """ # Note: please do not edit this function unless you have access to a machine ...
[ "def", "run_canary", "(", ")", ":", "# Note: please do not edit this function unless you have access to a machine", "# with GPUs suffering from the bug and can verify that the canary still", "# crashes after your edits. Due to the transient nature of the GPU bug it is", "# not possible to unit test ...
[ 12, 0 ]
[ 75, 20 ]
python
en
['en', 'error', 'th']
False
ZulipBaseCommand.get_client
(self)
Returns a Zulip Client object to be used for things done in management commands
Returns a Zulip Client object to be used for things done in management commands
def get_client(self) -> Client: """Returns a Zulip Client object to be used for things done in management commands""" return get_client("ZulipServer")
[ "def", "get_client", "(", "self", ")", "->", "Client", ":", "return", "get_client", "(", "\"ZulipServer\"", ")" ]
[ 145, 4 ]
[ 147, 40 ]
python
en
['en', 'en', 'en']
True
Timeout._validate_timeout
(cls, value, name)
Check that a timeout attribute is valid. :param value: The timeout value to validate :param name: The name of the timeout attribute to validate. This is used to specify in error messages. :return: The validated and casted version of the given value. :raises ValueError: If i...
Check that a timeout attribute is valid.
def _validate_timeout(cls, value, name): """ Check that a timeout attribute is valid. :param value: The timeout value to validate :param name: The name of the timeout attribute to validate. This is used to specify in error messages. :return: The validated and casted version ...
[ "def", "_validate_timeout", "(", "cls", ",", "value", ",", "name", ")", ":", "if", "value", "is", "_Default", ":", "return", "cls", ".", "DEFAULT_TIMEOUT", "if", "value", "is", "None", "or", "value", "is", "cls", ".", "DEFAULT_TIMEOUT", ":", "return", "v...
[ 112, 4 ]
[ 155, 20 ]
python
en
['en', 'en', 'en']
True
Timeout.from_float
(cls, timeout)
Create a new Timeout from a legacy timeout value. The timeout value used by httplib.py sets the same timeout on the connect(), and recv() socket requests. This creates a :class:`Timeout` object that sets the individual timeouts to the ``timeout`` value passed to this function. ...
Create a new Timeout from a legacy timeout value.
def from_float(cls, timeout): """ Create a new Timeout from a legacy timeout value. The timeout value used by httplib.py sets the same timeout on the connect(), and recv() socket requests. This creates a :class:`Timeout` object that sets the individual timeouts to the ``timeout`` value ...
[ "def", "from_float", "(", "cls", ",", "timeout", ")", ":", "return", "Timeout", "(", "read", "=", "timeout", ",", "connect", "=", "timeout", ")" ]
[ 158, 4 ]
[ 171, 53 ]
python
en
['en', 'en', 'en']
True
Timeout.clone
(self)
Create a copy of the timeout object Timeout properties are stored per-pool but each request needs a fresh Timeout object to ensure each one has its own start/stop configured. :return: a copy of the timeout object :rtype: :class:`Timeout`
Create a copy of the timeout object
def clone(self): """ Create a copy of the timeout object Timeout properties are stored per-pool but each request needs a fresh Timeout object to ensure each one has its own start/stop configured. :return: a copy of the timeout object :rtype: :class:`Timeout` """ ...
[ "def", "clone", "(", "self", ")", ":", "# We can't use copy.deepcopy because that will also create a new object", "# for _GLOBAL_DEFAULT_TIMEOUT, which socket.py uses as a sentinel to", "# detect the user default.", "return", "Timeout", "(", "connect", "=", "self", ".", "_connect", ...
[ 173, 4 ]
[ 185, 80 ]
python
en
['en', 'en', 'en']
True
Timeout.start_connect
(self)
Start the timeout clock, used during a connect() attempt :raises urllib3.exceptions.TimeoutStateError: if you attempt to start a timer that has been started already.
Start the timeout clock, used during a connect() attempt
def start_connect(self): """ Start the timeout clock, used during a connect() attempt :raises urllib3.exceptions.TimeoutStateError: if you attempt to start a timer that has been started already. """ if self._start_connect is not None: raise TimeoutStateError("Tim...
[ "def", "start_connect", "(", "self", ")", ":", "if", "self", ".", "_start_connect", "is", "not", "None", ":", "raise", "TimeoutStateError", "(", "\"Timeout timer has already been started.\"", ")", "self", ".", "_start_connect", "=", "current_time", "(", ")", "retu...
[ 187, 4 ]
[ 196, 34 ]
python
en
['en', 'en', 'en']
True
Timeout.get_connect_duration
(self)
Gets the time elapsed since the call to :meth:`start_connect`. :return: Elapsed time in seconds. :rtype: float :raises urllib3.exceptions.TimeoutStateError: if you attempt to get duration for a timer that hasn't been started.
Gets the time elapsed since the call to :meth:`start_connect`.
def get_connect_duration(self): """ Gets the time elapsed since the call to :meth:`start_connect`. :return: Elapsed time in seconds. :rtype: float :raises urllib3.exceptions.TimeoutStateError: if you attempt to get duration for a timer that hasn't been started. """ ...
[ "def", "get_connect_duration", "(", "self", ")", ":", "if", "self", ".", "_start_connect", "is", "None", ":", "raise", "TimeoutStateError", "(", "\"Can't get connect duration for timer that has not started.\"", ")", "return", "current_time", "(", ")", "-", "self", "."...
[ 198, 4 ]
[ 210, 51 ]
python
en
['en', 'en', 'en']
True
Timeout.connect_timeout
(self)
Get the value to use when setting a connection timeout. This will be a positive float or integer, the value None (never timeout), or the default system timeout. :return: Connect timeout. :rtype: int, float, :attr:`Timeout.DEFAULT_TIMEOUT` or None
Get the value to use when setting a connection timeout.
def connect_timeout(self): """ Get the value to use when setting a connection timeout. This will be a positive float or integer, the value None (never timeout), or the default system timeout. :return: Connect timeout. :rtype: int, float, :attr:`Timeout.DEFAULT_TIMEOUT` or None ...
[ "def", "connect_timeout", "(", "self", ")", ":", "if", "self", ".", "total", "is", "None", ":", "return", "self", ".", "_connect", "if", "self", ".", "_connect", "is", "None", "or", "self", ".", "_connect", "is", "self", ".", "DEFAULT_TIMEOUT", ":", "r...
[ 213, 4 ]
[ 228, 45 ]
python
en
['en', 'en', 'en']
True
Timeout.read_timeout
(self)
Get the value for the read timeout. This assumes some time has elapsed in the connection timeout and computes the read timeout appropriately. If self.total is set, the read timeout is dependent on the amount of time taken by the connect timeout. If the connection time has not been ...
Get the value for the read timeout.
def read_timeout(self): """ Get the value for the read timeout. This assumes some time has elapsed in the connection timeout and computes the read timeout appropriately. If self.total is set, the read timeout is dependent on the amount of time taken by the connect timeout. If t...
[ "def", "read_timeout", "(", "self", ")", ":", "if", "(", "self", ".", "total", "is", "not", "None", "and", "self", ".", "total", "is", "not", "self", ".", "DEFAULT_TIMEOUT", "and", "self", ".", "_read", "is", "not", "None", "and", "self", ".", "_read...
[ 231, 4 ]
[ 260, 29 ]
python
en
['en', 'en', 'en']
True
open_with_encoding
(filename, mode='r', encoding=None, limit_byte_check=-1)
Return opened file with a specific encoding.
Return opened file with a specific encoding.
def open_with_encoding(filename, mode='r', encoding=None, limit_byte_check=-1): """Return opened file with a specific encoding.""" if not encoding: encoding = detect_encoding(filename, limit_byte_check=limit_byte_check) return io.open(filename, mode=mode, encoding=encoding, newli...
[ "def", "open_with_encoding", "(", "filename", ",", "mode", "=", "'r'", ",", "encoding", "=", "None", ",", "limit_byte_check", "=", "-", "1", ")", ":", "if", "not", "encoding", ":", "encoding", "=", "detect_encoding", "(", "filename", ",", "limit_byte_check",...
[ 158, 0 ]
[ 164, 30 ]
python
en
['en', 'en', 'en']
True
detect_encoding
(filename, limit_byte_check=-1)
Return file encoding.
Return file encoding.
def detect_encoding(filename, limit_byte_check=-1): """Return file encoding.""" try: with open(filename, 'rb') as input_file: from lib2to3.pgen2 import tokenize as lib2to3_tokenize encoding = lib2to3_tokenize.detect_encoding(input_file.readline)[0] with open_with_encodin...
[ "def", "detect_encoding", "(", "filename", ",", "limit_byte_check", "=", "-", "1", ")", ":", "try", ":", "with", "open", "(", "filename", ",", "'rb'", ")", "as", "input_file", ":", "from", "lib2to3", ".", "pgen2", "import", "tokenize", "as", "lib2to3_token...
[ 167, 0 ]
[ 179, 24 ]
python
en
['es', 'sq', 'en']
False
readlines_from_file
(filename)
Return contents of file.
Return contents of file.
def readlines_from_file(filename): """Return contents of file.""" with open_with_encoding(filename) as input_file: return input_file.readlines()
[ "def", "readlines_from_file", "(", "filename", ")", ":", "with", "open_with_encoding", "(", "filename", ")", "as", "input_file", ":", "return", "input_file", ".", "readlines", "(", ")" ]
[ 182, 0 ]
[ 185, 37 ]
python
en
['en', 'en', 'en']
True
extended_blank_lines
(logical_line, blank_lines, blank_before, indent_level, previous_logical)
Check for missing blank lines after class declaration.
Check for missing blank lines after class declaration.
def extended_blank_lines(logical_line, blank_lines, blank_before, indent_level, previous_logical): """Check for missing blank lines after class declaration.""" if previous_logical.startswith('def '): if b...
[ "def", "extended_blank_lines", "(", "logical_line", ",", "blank_lines", ",", "blank_before", ",", "indent_level", ",", "previous_logical", ")", ":", "if", "previous_logical", ".", "startswith", "(", "'def '", ")", ":", "if", "blank_lines", "and", "pycodestyle", "....
[ 188, 0 ]
[ 206, 60 ]
python
en
['en', 'en', 'en']
True
continued_indentation
(logical_line, tokens, indent_level, hang_closing, indent_char, noqa)
Override pycodestyle's function to provide indentation information.
Override pycodestyle's function to provide indentation information.
def continued_indentation(logical_line, tokens, indent_level, hang_closing, indent_char, noqa): """Override pycodestyle's function to provide indentation information.""" first_row = tokens[0][2][0] nrows = 1 + tokens[-1][2][0] - first_row if noqa or nrows == 1: return ...
[ "def", "continued_indentation", "(", "logical_line", ",", "tokens", ",", "indent_level", ",", "hang_closing", ",", "indent_char", ",", "noqa", ")", ":", "first_row", "=", "tokens", "[", "0", "]", "[", "2", "]", "[", "0", "]", "nrows", "=", "1", "+", "t...
[ 212, 0 ]
[ 399, 57 ]
python
en
['en', 'en', 'en']
True
get_w605_position
(tokens)
workaround get pointing out position by W605.
workaround get pointing out position by W605.
def get_w605_position(tokens): """workaround get pointing out position by W605.""" # TODO: When this PR(*) change is released, use pos of pycodestyle # *: https://github.com/PyCQA/pycodestyle/pull/747 valid = [ '\n', '\\', '\'', '"', 'a', 'b', 'f', 'n', 'r', 't', 'v', '0', '1', '2', '3',...
[ "def", "get_w605_position", "(", "tokens", ")", ":", "# TODO: When this PR(*) change is released, use pos of pycodestyle", "# *: https://github.com/PyCQA/pycodestyle/pull/747", "valid", "=", "[", "'\\n'", ",", "'\\\\'", ",", "'\\''", ",", "'\"'", ",", "'a'", ",", "'b'", "...
[ 1401, 0 ]
[ 1433, 52 ]
python
en
['en', 'en', 'en']
True
get_module_imports_on_top_of_file
(source, import_line_index)
return import or from keyword position example: > 0: import sys 1: import os 2: 3: def function():
return import or from keyword position
def get_module_imports_on_top_of_file(source, import_line_index): """return import or from keyword position example: > 0: import sys 1: import os 2: 3: def function(): """ def is_string_literal(line): if line[0] in 'uUbB': line = line[1:] if lin...
[ "def", "get_module_imports_on_top_of_file", "(", "source", ",", "import_line_index", ")", ":", "def", "is_string_literal", "(", "line", ")", ":", "if", "line", "[", "0", "]", "in", "'uUbB'", ":", "line", "=", "line", "[", "1", ":", "]", "if", "line", "an...
[ 1436, 0 ]
[ 1518, 12 ]
python
en
['en', 'en', 'en']
True
get_index_offset_contents
(result, source)
Return (line_index, column_offset, line_contents).
Return (line_index, column_offset, line_contents).
def get_index_offset_contents(result, source): """Return (line_index, column_offset, line_contents).""" line_index = result['line'] - 1 return (line_index, result['column'] - 1, source[line_index])
[ "def", "get_index_offset_contents", "(", "result", ",", "source", ")", ":", "line_index", "=", "result", "[", "'line'", "]", "-", "1", "return", "(", "line_index", ",", "result", "[", "'column'", "]", "-", "1", ",", "source", "[", "line_index", "]", ")" ...
[ 1521, 0 ]
[ 1526, 31 ]
python
en
['en', 'da', 'en']
True
get_fixed_long_line
(target, previous_line, original, indent_word=' ', max_line_length=79, aggressive=False, experimental=False, verbose=False)
Break up long line and return result. Do this by generating multiple reformatted candidates and then ranking the candidates to heuristically select the best option.
Break up long line and return result.
def get_fixed_long_line(target, previous_line, original, indent_word=' ', max_line_length=79, aggressive=False, experimental=False, verbose=False): """Break up long line and return result. Do this by generating multiple reformatted candidates and then rank...
[ "def", "get_fixed_long_line", "(", "target", ",", "previous_line", ",", "original", ",", "indent_word", "=", "' '", ",", "max_line_length", "=", "79", ",", "aggressive", "=", "False", ",", "experimental", "=", "False", ",", "verbose", "=", "False", ")", "...
[ 1529, 0 ]
[ 1574, 29 ]
python
en
['en', 'da', 'en']
True
longest_line_length
(code)
Return length of longest line.
Return length of longest line.
def longest_line_length(code): """Return length of longest line.""" if len(code) == 0: return 0 return max(len(line) for line in code.splitlines())
[ "def", "longest_line_length", "(", "code", ")", ":", "if", "len", "(", "code", ")", "==", "0", ":", "return", "0", "return", "max", "(", "len", "(", "line", ")", "for", "line", "in", "code", ".", "splitlines", "(", ")", ")" ]
[ 1577, 0 ]
[ 1581, 55 ]
python
en
['en', 'no', 'en']
True
join_logical_line
(logical_line)
Return single line based on logical line input.
Return single line based on logical line input.
def join_logical_line(logical_line): """Return single line based on logical line input.""" indentation = _get_indentation(logical_line) return indentation + untokenize_without_newlines( generate_tokens(logical_line.lstrip())) + '\n'
[ "def", "join_logical_line", "(", "logical_line", ")", ":", "indentation", "=", "_get_indentation", "(", "logical_line", ")", "return", "indentation", "+", "untokenize_without_newlines", "(", "generate_tokens", "(", "logical_line", ".", "lstrip", "(", ")", ")", ")", ...
[ 1584, 0 ]
[ 1589, 54 ]
python
en
['en', 'da', 'en']
True
untokenize_without_newlines
(tokens)
Return source code based on tokens.
Return source code based on tokens.
def untokenize_without_newlines(tokens): """Return source code based on tokens.""" text = '' last_row = 0 last_column = -1 for t in tokens: token_string = t[1] (start_row, start_column) = t[2] (end_row, end_column) = t[3] if start_row > last_row: last_co...
[ "def", "untokenize_without_newlines", "(", "tokens", ")", ":", "text", "=", "''", "last_row", "=", "0", "last_column", "=", "-", "1", "for", "t", "in", "tokens", ":", "token_string", "=", "t", "[", "1", "]", "(", "start_row", ",", "start_column", ")", ...
[ 1592, 0 ]
[ 1617, 24 ]
python
en
['en', 'no', 'en']
True
_get_logical
(source_lines, result, logical_start, logical_end)
Return the logical line corresponding to the result. Assumes input is already E702-clean.
Return the logical line corresponding to the result.
def _get_logical(source_lines, result, logical_start, logical_end): """Return the logical line corresponding to the result. Assumes input is already E702-clean. """ row = result['line'] - 1 col = result['column'] - 1 ls = None le = None for i in range(0, len(logical_start), 1): ...
[ "def", "_get_logical", "(", "source_lines", ",", "result", ",", "logical_start", ",", "logical_end", ")", ":", "row", "=", "result", "[", "'line'", "]", "-", "1", "col", "=", "result", "[", "'column'", "]", "-", "1", "ls", "=", "None", "le", "=", "No...
[ 1646, 0 ]
[ 1666, 27 ]
python
en
['en', 'en', 'en']
True
reindent
(source, indent_size)
Reindent all lines.
Reindent all lines.
def reindent(source, indent_size): """Reindent all lines.""" reindenter = Reindenter(source) return reindenter.run(indent_size)
[ "def", "reindent", "(", "source", ",", "indent_size", ")", ":", "reindenter", "=", "Reindenter", "(", "source", ")", "return", "reindenter", ".", "run", "(", "indent_size", ")" ]
[ 1676, 0 ]
[ 1679, 38 ]
python
en
['en', 'en', 'en']
True
code_almost_equal
(a, b)
Return True if code is similar. Ignore whitespace when comparing specific line.
Return True if code is similar.
def code_almost_equal(a, b): """Return True if code is similar. Ignore whitespace when comparing specific line. """ split_a = split_and_strip_non_empty_lines(a) split_b = split_and_strip_non_empty_lines(b) if len(split_a) != len(split_b): return False for (index, _) in enumerate(...
[ "def", "code_almost_equal", "(", "a", ",", "b", ")", ":", "split_a", "=", "split_and_strip_non_empty_lines", "(", "a", ")", "split_b", "=", "split_and_strip_non_empty_lines", "(", "b", ")", "if", "len", "(", "split_a", ")", "!=", "len", "(", "split_b", ")", ...
[ 1682, 0 ]
[ 1698, 15 ]
python
en
['en', 'af', 'en']
True
split_and_strip_non_empty_lines
(text)
Return lines split by newline. Ignore empty lines.
Return lines split by newline.
def split_and_strip_non_empty_lines(text): """Return lines split by newline. Ignore empty lines. """ return [line.strip() for line in text.splitlines() if line.strip()]
[ "def", "split_and_strip_non_empty_lines", "(", "text", ")", ":", "return", "[", "line", ".", "strip", "(", ")", "for", "line", "in", "text", ".", "splitlines", "(", ")", "if", "line", ".", "strip", "(", ")", "]" ]
[ 1701, 0 ]
[ 1707, 71 ]
python
en
['en', 'pl', 'en']
True
fix_e265
(source, aggressive=False)
Format block comments.
Format block comments.
def fix_e265(source, aggressive=False): # pylint: disable=unused-argument """Format block comments.""" if '#' not in source: # Optimization. return source ignored_line_numbers = multiline_string_lines( source, include_docstrings=True) | set(commented_out_code_lines(source))...
[ "def", "fix_e265", "(", "source", ",", "aggressive", "=", "False", ")", ":", "# pylint: disable=unused-argument", "if", "'#'", "not", "in", "source", ":", "# Optimization.", "return", "source", "ignored_line_numbers", "=", "multiline_string_lines", "(", "source", ",...
[ 1710, 0 ]
[ 1749, 31 ]
python
en
['en', 'fr', 'en']
True
refactor
(source, fixer_names, ignore=None, filename='')
Return refactored code using lib2to3. Skip if ignore string is produced in the refactored code.
Return refactored code using lib2to3.
def refactor(source, fixer_names, ignore=None, filename=''): """Return refactored code using lib2to3. Skip if ignore string is produced in the refactored code. """ from lib2to3 import pgen2 try: new_text = refactor_with_2to3(source, fixer_names=fixer_n...
[ "def", "refactor", "(", "source", ",", "fixer_names", ",", "ignore", "=", "None", ",", "filename", "=", "''", ")", ":", "from", "lib2to3", "import", "pgen2", "try", ":", "new_text", "=", "refactor_with_2to3", "(", "source", ",", "fixer_names", "=", "fixer_...
[ 1752, 0 ]
[ 1773, 19 ]
python
en
['en', 'en', 'en']
True
fix_2to3
(source, aggressive=True, select=None, ignore=None, filename='', where='global', verbose=False)
Fix various deprecated code (via lib2to3).
Fix various deprecated code (via lib2to3).
def fix_2to3(source, aggressive=True, select=None, ignore=None, filename='', where='global', verbose=False): """Fix various deprecated code (via lib2to3).""" if not aggressive: return source select = select or [] ignore = ignore or [] return refactor(source, ...
[ "def", "fix_2to3", "(", "source", ",", "aggressive", "=", "True", ",", "select", "=", "None", ",", "ignore", "=", "None", ",", "filename", "=", "''", ",", "where", "=", "'global'", ",", "verbose", "=", "False", ")", ":", "if", "not", "aggressive", ":...
[ 1788, 0 ]
[ 1803, 38 ]
python
ca
['es', 'ca', 'en']
False
fix_w602
(source, aggressive=True)
Fix deprecated form of raising exception.
Fix deprecated form of raising exception.
def fix_w602(source, aggressive=True): """Fix deprecated form of raising exception.""" if not aggressive: return source return refactor(source, ['raise'], ignore='with_traceback')
[ "def", "fix_w602", "(", "source", ",", "aggressive", "=", "True", ")", ":", "if", "not", "aggressive", ":", "return", "source", "return", "refactor", "(", "source", ",", "[", "'raise'", "]", ",", "ignore", "=", "'with_traceback'", ")" ]
[ 1806, 0 ]
[ 1811, 63 ]
python
en
['en', 'en', 'en']
True
find_newline
(source)
Return type of newline used in source. Input is a list of lines.
Return type of newline used in source.
def find_newline(source): """Return type of newline used in source. Input is a list of lines. """ assert not isinstance(source, unicode) counter = collections.defaultdict(int) for line in source: if line.endswith(CRLF): counter[CRLF] += 1 elif line.endswith(CR): ...
[ "def", "find_newline", "(", "source", ")", ":", "assert", "not", "isinstance", "(", "source", ",", "unicode", ")", "counter", "=", "collections", ".", "defaultdict", "(", "int", ")", "for", "line", "in", "source", ":", "if", "line", ".", "endswith", "(",...
[ 1814, 0 ]
[ 1831, 70 ]
python
en
['en', 'en', 'en']
True
_get_indentword
(source)
Return indentation type.
Return indentation type.
def _get_indentword(source): """Return indentation type.""" indent_word = ' ' # Default in case source has no indentation try: for t in generate_tokens(source): if t[0] == token.INDENT: indent_word = t[1] break except (SyntaxError, tokenize.TokenEr...
[ "def", "_get_indentword", "(", "source", ")", ":", "indent_word", "=", "' '", "# Default in case source has no indentation", "try", ":", "for", "t", "in", "generate_tokens", "(", "source", ")", ":", "if", "t", "[", "0", "]", "==", "token", ".", "INDENT", ...
[ 1834, 0 ]
[ 1844, 22 ]
python
en
['en', 'da', 'en']
True
_get_indentation
(line)
Return leading whitespace.
Return leading whitespace.
def _get_indentation(line): """Return leading whitespace.""" if line.strip(): non_whitespace_index = len(line) - len(line.lstrip()) return line[:non_whitespace_index] return ''
[ "def", "_get_indentation", "(", "line", ")", ":", "if", "line", ".", "strip", "(", ")", ":", "non_whitespace_index", "=", "len", "(", "line", ")", "-", "len", "(", "line", ".", "lstrip", "(", ")", ")", "return", "line", "[", ":", "non_whitespace_index"...
[ 1847, 0 ]
[ 1853, 13 ]
python
en
['en', 'no', 'en']
True
get_diff_text
(old, new, filename)
Return text of unified diff between old and new.
Return text of unified diff between old and new.
def get_diff_text(old, new, filename): """Return text of unified diff between old and new.""" newline = '\n' diff = difflib.unified_diff( old, new, 'original/' + filename, 'fixed/' + filename, lineterm=newline) text = '' for line in diff: text += line ...
[ "def", "get_diff_text", "(", "old", ",", "new", ",", "filename", ")", ":", "newline", "=", "'\\n'", "diff", "=", "difflib", ".", "unified_diff", "(", "old", ",", "new", ",", "'original/'", "+", "filename", ",", "'fixed/'", "+", "filename", ",", "lineterm...
[ 1856, 0 ]
[ 1873, 15 ]
python
en
['en', 'en', 'en']
True
_priority_key
(pep8_result)
Key for sorting PEP8 results. Global fixes should be done first. This is important for things like indentation.
Key for sorting PEP8 results.
def _priority_key(pep8_result): """Key for sorting PEP8 results. Global fixes should be done first. This is important for things like indentation. """ priority = [ # Fix multiline colon-based before semicolon based. 'e701', # Break multiline statements early. 'e702'...
[ "def", "_priority_key", "(", "pep8_result", ")", ":", "priority", "=", "[", "# Fix multiline colon-based before semicolon based.", "'e701'", ",", "# Break multiline statements early.", "'e702'", ",", "# Things that make lines longer.", "'e225'", ",", "'e231'", ",", "# Remove ...
[ 1876, 0 ]
[ 1908, 31 ]
python
en
['en', 'en', 'en']
True
shorten_line
(tokens, source, indentation, indent_word, max_line_length, aggressive=False, experimental=False, previous_line='')
Separate line at OPERATOR. Multiple candidates will be yielded.
Separate line at OPERATOR.
def shorten_line(tokens, source, indentation, indent_word, max_line_length, aggressive=False, experimental=False, previous_line=''): """Separate line at OPERATOR. Multiple candidates will be yielded. """ for candidate in _shorten_line(tokens=tokens, ...
[ "def", "shorten_line", "(", "tokens", ",", "source", ",", "indentation", ",", "indent_word", ",", "max_line_length", ",", "aggressive", "=", "False", ",", "experimental", "=", "False", ",", "previous_line", "=", "''", ")", ":", "for", "candidate", "in", "_sh...
[ 1911, 0 ]
[ 1946, 27 ]
python
en
['en', 'id', 'en']
True
_shorten_line
(tokens, source, indentation, indent_word, aggressive=False, previous_line='')
Separate line at OPERATOR. The input is expected to be free of newlines except for inside multiline strings and at the end. Multiple candidates will be yielded.
Separate line at OPERATOR.
def _shorten_line(tokens, source, indentation, indent_word, aggressive=False, previous_line=''): """Separate line at OPERATOR. The input is expected to be free of newlines except for inside multiline strings and at the end. Multiple candidates will be yielded. """ for (token...
[ "def", "_shorten_line", "(", "tokens", ",", "source", ",", "indentation", ",", "indent_word", ",", "aggressive", "=", "False", ",", "previous_line", "=", "''", ")", ":", "for", "(", "token_type", ",", "token_string", ",", "start_offset", ",", "end_offset", "...
[ 1949, 0 ]
[ 2015, 41 ]
python
en
['en', 'id', 'en']
True
_parse_container
(tokens, index, for_or_if=None)
Parse a high-level container, such as a list, tuple, etc.
Parse a high-level container, such as a list, tuple, etc.
def _parse_container(tokens, index, for_or_if=None): """Parse a high-level container, such as a list, tuple, etc.""" # Store the opening bracket. items = [Atom(Token(*tokens[index]))] index += 1 num_tokens = len(tokens) while index < num_tokens: tok = Token(*tokens[index]) if ...
[ "def", "_parse_container", "(", "tokens", ",", "index", ",", "for_or_if", "=", "None", ")", ":", "# Store the opening bracket.", "items", "=", "[", "Atom", "(", "Token", "(", "*", "tokens", "[", "index", "]", ")", ")", "]", "index", "+=", "1", "num_token...
[ 2670, 0 ]
[ 2726, 23 ]
python
en
['en', 'en', 'en']
True
_parse_tokens
(tokens)
Parse the tokens. This converts the tokens into a form where we can manipulate them more easily.
Parse the tokens.
def _parse_tokens(tokens): """Parse the tokens. This converts the tokens into a form where we can manipulate them more easily. """ index = 0 parsed_tokens = [] num_tokens = len(tokens) while index < num_tokens: tok = Token(*tokens[index]) assert tok.token_type != tok...
[ "def", "_parse_tokens", "(", "tokens", ")", ":", "index", "=", "0", "parsed_tokens", "=", "[", "]", "num_tokens", "=", "len", "(", "tokens", ")", "while", "index", "<", "num_tokens", ":", "tok", "=", "Token", "(", "*", "tokens", "[", "index", "]", ")...
[ 2729, 0 ]
[ 2759, 24 ]
python
en
['en', 'en', 'en']
True
_reflow_lines
(parsed_tokens, indentation, max_line_length, start_on_prefix_line)
Reflow the lines so that it looks nice.
Reflow the lines so that it looks nice.
def _reflow_lines(parsed_tokens, indentation, max_line_length, start_on_prefix_line): """Reflow the lines so that it looks nice.""" if unicode(parsed_tokens[0]) == 'def': # A function definition gets indented a bit more. continued_indent = indentation + ' ' * 2 * DEFAULT_INDEN...
[ "def", "_reflow_lines", "(", "parsed_tokens", ",", "indentation", ",", "max_line_length", ",", "start_on_prefix_line", ")", ":", "if", "unicode", "(", "parsed_tokens", "[", "0", "]", ")", "==", "'def'", ":", "# A function definition gets indented a bit more.", "contin...
[ 2762, 0 ]
[ 2801, 23 ]
python
en
['en', 'en', 'en']
True
_shorten_line_at_tokens_new
(tokens, source, indentation, max_line_length)
Shorten the line taking its length into account. The input is expected to be free of newlines except for inside multiline strings and at the end.
Shorten the line taking its length into account.
def _shorten_line_at_tokens_new(tokens, source, indentation, max_line_length): """Shorten the line taking its length into account. The input is expected to be free of newlines except for inside multiline strings and at the end. """ # Yield the original source so to ...
[ "def", "_shorten_line_at_tokens_new", "(", "tokens", ",", "source", ",", "indentation", ",", "max_line_length", ")", ":", "# Yield the original source so to see if it's a better choice than the", "# shortened candidate lines we generate here.", "yield", "indentation", "+", "source"...
[ 2804, 0 ]
[ 2829, 23 ]
python
en
['en', 'en', 'en']
True
FixPEP8.fix
(self)
Return a version of the source code with PEP 8 violations fixed.
Return a version of the source code with PEP 8 violations fixed.
def fix(self): """Return a version of the source code with PEP 8 violations fixed.""" pep8_options = { 'ignore': self.options.ignore, 'select': self.options.select, 'max_line_length': self.options.max_line_length, 'hang_closing': self.options.hang_closing,...
[ "def", "fix", "(", "self", ")", ":", "pep8_options", "=", "{", "'ignore'", ":", "self", ".", "options", ".", "ignore", ",", "'select'", ":", "self", ".", "options", ".", "select", ",", "'max_line_length'", ":", "self", ".", "options", ".", "max_line_leng...
[ 575, 4 ]
[ 609, 35 ]
python
en
['en', 'en', 'en']
True
FixPEP8._fix_reindent
(self, result)
Fix a badly indented line. This is done by adding or removing from its initial indent only.
Fix a badly indented line.
def _fix_reindent(self, result): """Fix a badly indented line. This is done by adding or removing from its initial indent only. """ num_indent_spaces = int(result['info'].split()[1]) line_index = result['line'] - 1 target = self.source[line_index] self.source[l...
[ "def", "_fix_reindent", "(", "self", ",", "result", ")", ":", "num_indent_spaces", "=", "int", "(", "result", "[", "'info'", "]", ".", "split", "(", ")", "[", "1", "]", ")", "line_index", "=", "result", "[", "'line'", "]", "-", "1", "target", "=", ...
[ 611, 4 ]
[ 621, 75 ]
python
en
['en', 'en', 'en']
True
FixPEP8.fix_e112
(self, result)
Fix under-indented comments.
Fix under-indented comments.
def fix_e112(self, result): """Fix under-indented comments.""" line_index = result['line'] - 1 target = self.source[line_index] if not target.lstrip().startswith('#'): # Don't screw with invalid syntax. return [] self.source[line_index] = self.indent_wor...
[ "def", "fix_e112", "(", "self", ",", "result", ")", ":", "line_index", "=", "result", "[", "'line'", "]", "-", "1", "target", "=", "self", ".", "source", "[", "line_index", "]", "if", "not", "target", ".", "lstrip", "(", ")", ".", "startswith", "(", ...
[ 623, 4 ]
[ 632, 59 ]
python
en
['en', 'en', 'en']
True
FixPEP8.fix_e113
(self, result)
Fix unexpected indentation.
Fix unexpected indentation.
def fix_e113(self, result): """Fix unexpected indentation.""" line_index = result['line'] - 1 target = self.source[line_index] indent = _get_indentation(target) stripped = target.lstrip() self.source[line_index] = indent[1:] + stripped
[ "def", "fix_e113", "(", "self", ",", "result", ")", ":", "line_index", "=", "result", "[", "'line'", "]", "-", "1", "target", "=", "self", ".", "source", "[", "line_index", "]", "indent", "=", "_get_indentation", "(", "target", ")", "stripped", "=", "t...
[ 634, 4 ]
[ 640, 55 ]
python
en
['en', 'en', 'en']
True
FixPEP8.fix_e116
(self, result)
Fix over-indented comments.
Fix over-indented comments.
def fix_e116(self, result): """Fix over-indented comments.""" line_index = result['line'] - 1 target = self.source[line_index] indent = _get_indentation(target) stripped = target.lstrip() if not stripped.startswith('#'): # Don't screw with invalid syntax. ...
[ "def", "fix_e116", "(", "self", ",", "result", ")", ":", "line_index", "=", "result", "[", "'line'", "]", "-", "1", "target", "=", "self", ".", "source", "[", "line_index", "]", "indent", "=", "_get_indentation", "(", "target", ")", "stripped", "=", "t...
[ 642, 4 ]
[ 654, 55 ]
python
en
['en', 'en', 'en']
True
FixPEP8.fix_e117
(self, result)
Fix over-indented.
Fix over-indented.
def fix_e117(self, result): """Fix over-indented.""" line_index = result['line'] - 1 target = self.source[line_index] indent = _get_indentation(target) if indent == '\t': return [] stripped = target.lstrip() self.source[line_index] = indent[1:] + st...
[ "def", "fix_e117", "(", "self", ",", "result", ")", ":", "line_index", "=", "result", "[", "'line'", "]", "-", "1", "target", "=", "self", ".", "source", "[", "line_index", "]", "indent", "=", "_get_indentation", "(", "target", ")", "if", "indent", "==...
[ 656, 4 ]
[ 667, 55 ]
python
en
['en', 'en', 'en']
False
FixPEP8.fix_e125
(self, result)
Fix indentation undistinguish from the next logical line.
Fix indentation undistinguish from the next logical line.
def fix_e125(self, result): """Fix indentation undistinguish from the next logical line.""" num_indent_spaces = int(result['info'].split()[1]) line_index = result['line'] - 1 target = self.source[line_index] spaces_to_add = num_indent_spaces - len(_get_indentation(target)) ...
[ "def", "fix_e125", "(", "self", ",", "result", ")", ":", "num_indent_spaces", "=", "int", "(", "result", "[", "'info'", "]", ".", "split", "(", ")", "[", "1", "]", ")", "line_index", "=", "result", "[", "'line'", "]", "-", "1", "target", "=", "self...
[ 669, 4 ]
[ 685, 29 ]
python
en
['en', 'en', 'en']
True
FixPEP8.fix_e131
(self, result)
Fix indentation undistinguish from the next logical line.
Fix indentation undistinguish from the next logical line.
def fix_e131(self, result): """Fix indentation undistinguish from the next logical line.""" num_indent_spaces = int(result['info'].split()[1]) line_index = result['line'] - 1 target = self.source[line_index] spaces_to_add = num_indent_spaces - len(_get_indentation(target)) ...
[ "def", "fix_e131", "(", "self", ",", "result", ")", ":", "num_indent_spaces", "=", "int", "(", "result", "[", "'info'", "]", ".", "split", "(", ")", "[", "1", "]", ")", "line_index", "=", "result", "[", "'line'", "]", "-", "1", "target", "=", "self...
[ 687, 4 ]
[ 700, 70 ]
python
en
['en', 'en', 'en']
True
FixPEP8.fix_e201
(self, result)
Remove extraneous whitespace.
Remove extraneous whitespace.
def fix_e201(self, result): """Remove extraneous whitespace.""" line_index = result['line'] - 1 target = self.source[line_index] offset = result['column'] - 1 fixed = fix_whitespace(target, offset=offset, replacement=...
[ "def", "fix_e201", "(", "self", ",", "result", ")", ":", "line_index", "=", "result", "[", "'line'", "]", "-", "1", "target", "=", "self", ".", "source", "[", "line_index", "]", "offset", "=", "result", "[", "'column'", "]", "-", "1", "fixed", "=", ...
[ 702, 4 ]
[ 712, 39 ]
python
en
['en', 'mk', 'en']
True
FixPEP8.fix_e224
(self, result)
Remove extraneous whitespace around operator.
Remove extraneous whitespace around operator.
def fix_e224(self, result): """Remove extraneous whitespace around operator.""" target = self.source[result['line'] - 1] offset = result['column'] - 1 fixed = target[:offset] + target[offset:].replace('\t', ' ') self.source[result['line'] - 1] = fixed
[ "def", "fix_e224", "(", "self", ",", "result", ")", ":", "target", "=", "self", ".", "source", "[", "result", "[", "'line'", "]", "-", "1", "]", "offset", "=", "result", "[", "'column'", "]", "-", "1", "fixed", "=", "target", "[", ":", "offset", ...
[ 714, 4 ]
[ 719, 47 ]
python
en
['en', 'sr', 'en']
True
FixPEP8.fix_e225
(self, result)
Fix missing whitespace around operator.
Fix missing whitespace around operator.
def fix_e225(self, result): """Fix missing whitespace around operator.""" target = self.source[result['line'] - 1] offset = result['column'] - 1 fixed = target[:offset] + ' ' + target[offset:] # Only proceed if non-whitespace characters match. # And make sure we don't br...
[ "def", "fix_e225", "(", "self", ",", "result", ")", ":", "target", "=", "self", ".", "source", "[", "result", "[", "'line'", "]", "-", "1", "]", "offset", "=", "result", "[", "'column'", "]", "-", "1", "fixed", "=", "target", "[", ":", "offset", ...
[ 721, 4 ]
[ 750, 21 ]
python
en
['en', 'sn', 'en']
True
FixPEP8.fix_e231
(self, result)
Add missing whitespace.
Add missing whitespace.
def fix_e231(self, result): """Add missing whitespace.""" line_index = result['line'] - 1 target = self.source[line_index] offset = result['column'] fixed = target[:offset].rstrip() + ' ' + target[offset:].lstrip() self.source[line_index] = fixed
[ "def", "fix_e231", "(", "self", ",", "result", ")", ":", "line_index", "=", "result", "[", "'line'", "]", "-", "1", "target", "=", "self", ".", "source", "[", "line_index", "]", "offset", "=", "result", "[", "'column'", "]", "fixed", "=", "target", "...
[ 752, 4 ]
[ 758, 39 ]
python
en
['en', 'en', 'en']
True
FixPEP8.fix_e251
(self, result)
Remove whitespace around parameter '=' sign.
Remove whitespace around parameter '=' sign.
def fix_e251(self, result): """Remove whitespace around parameter '=' sign.""" line_index = result['line'] - 1 target = self.source[line_index] # This is necessary since pycodestyle sometimes reports columns that # goes past the end of the physical line. This happens in cases li...
[ "def", "fix_e251", "(", "self", ",", "result", ")", ":", "line_index", "=", "result", "[", "'line'", "]", "-", "1", "target", "=", "self", ".", "source", "[", "line_index", "]", "# This is necessary since pycodestyle sometimes reports columns that", "# goes past the...
[ 760, 4 ]
[ 785, 47 ]
python
en
['en', 'sn', 'en']
True
FixPEP8.fix_e262
(self, result)
Fix spacing after comment hash.
Fix spacing after comment hash.
def fix_e262(self, result): """Fix spacing after comment hash.""" target = self.source[result['line'] - 1] offset = result['column'] code = target[:offset].rstrip(' \t#') comment = target[offset:].lstrip(' \t#') fixed = code + (' # ' + comment if comment.strip() else '...
[ "def", "fix_e262", "(", "self", ",", "result", ")", ":", "target", "=", "self", ".", "source", "[", "result", "[", "'line'", "]", "-", "1", "]", "offset", "=", "result", "[", "'column'", "]", "code", "=", "target", "[", ":", "offset", "]", ".", "...
[ 787, 4 ]
[ 797, 47 ]
python
en
['en', 'en', 'en']
True
FixPEP8.fix_e271
(self, result)
Fix extraneous whitespace around keywords.
Fix extraneous whitespace around keywords.
def fix_e271(self, result): """Fix extraneous whitespace around keywords.""" line_index = result['line'] - 1 target = self.source[line_index] offset = result['column'] - 1 fixed = fix_whitespace(target, offset=offset, ...
[ "def", "fix_e271", "(", "self", ",", "result", ")", ":", "line_index", "=", "result", "[", "'line'", "]", "-", "1", "target", "=", "self", ".", "source", "[", "line_index", "]", "offset", "=", "result", "[", "'column'", "]", "-", "1", "fixed", "=", ...
[ 799, 4 ]
[ 812, 43 ]
python
en
['en', 'el-Latn', 'en']
True
FixPEP8.fix_e301
(self, result)
Add missing blank line.
Add missing blank line.
def fix_e301(self, result): """Add missing blank line.""" cr = '\n' self.source[result['line'] - 1] = cr + self.source[result['line'] - 1]
[ "def", "fix_e301", "(", "self", ",", "result", ")", ":", "cr", "=", "'\\n'", "self", ".", "source", "[", "result", "[", "'line'", "]", "-", "1", "]", "=", "cr", "+", "self", ".", "source", "[", "result", "[", "'line'", "]", "-", "1", "]" ]
[ 814, 4 ]
[ 817, 78 ]
python
cy
['et', 'cy', 'en']
False
FixPEP8.fix_e302
(self, result)
Add missing 2 blank lines.
Add missing 2 blank lines.
def fix_e302(self, result): """Add missing 2 blank lines.""" add_linenum = 2 - int(result['info'].split()[-1]) offset = 1 if self.source[result['line'] - 2].strip() == "\\": offset = 2 cr = '\n' * add_linenum self.source[result['line'] - offset] = ( ...
[ "def", "fix_e302", "(", "self", ",", "result", ")", ":", "add_linenum", "=", "2", "-", "int", "(", "result", "[", "'info'", "]", ".", "split", "(", ")", "[", "-", "1", "]", ")", "offset", "=", "1", "if", "self", ".", "source", "[", "result", "[...
[ 819, 4 ]
[ 828, 9 ]
python
en
['et', 'en', 'en']
True
FixPEP8.fix_e303
(self, result)
Remove extra blank lines.
Remove extra blank lines.
def fix_e303(self, result): """Remove extra blank lines.""" delete_linenum = int(result['info'].split('(')[1].split(')')[0]) - 2 delete_linenum = max(1, delete_linenum) # We need to count because pycodestyle reports an offset line number if # there are comments. cnt = 0 ...
[ "def", "fix_e303", "(", "self", ",", "result", ")", ":", "delete_linenum", "=", "int", "(", "result", "[", "'info'", "]", ".", "split", "(", "'('", ")", "[", "1", "]", ".", "split", "(", "')'", ")", "[", "0", "]", ")", "-", "2", "delete_linenum",...
[ 830, 4 ]
[ 847, 29 ]
python
en
['es', 'en', 'en']
True
FixPEP8.fix_e304
(self, result)
Remove blank line following function decorator.
Remove blank line following function decorator.
def fix_e304(self, result): """Remove blank line following function decorator.""" line = result['line'] - 2 if not self.source[line].strip(): self.source[line] = ''
[ "def", "fix_e304", "(", "self", ",", "result", ")", ":", "line", "=", "result", "[", "'line'", "]", "-", "2", "if", "not", "self", ".", "source", "[", "line", "]", ".", "strip", "(", ")", ":", "self", ".", "source", "[", "line", "]", "=", "''" ...
[ 849, 4 ]
[ 853, 34 ]
python
en
['en', 'en', 'en']
True
FixPEP8.fix_e305
(self, result)
Add missing 2 blank lines after end of function or class.
Add missing 2 blank lines after end of function or class.
def fix_e305(self, result): """Add missing 2 blank lines after end of function or class.""" add_delete_linenum = 2 - int(result['info'].split()[-1]) cnt = 0 offset = result['line'] - 2 modified_lines = [] if add_delete_linenum < 0: # delete cr add_...
[ "def", "fix_e305", "(", "self", ",", "result", ")", ":", "add_delete_linenum", "=", "2", "-", "int", "(", "result", "[", "'info'", "]", ".", "split", "(", ")", "[", "-", "1", "]", ")", "cnt", "=", "0", "offset", "=", "result", "[", "'line'", "]",...
[ 855, 4 ]
[ 886, 29 ]
python
en
['en', 'en', 'en']
True
FixPEP8.fix_e401
(self, result)
Put imports on separate lines.
Put imports on separate lines.
def fix_e401(self, result): """Put imports on separate lines.""" line_index = result['line'] - 1 target = self.source[line_index] offset = result['column'] - 1 if not target.lstrip().startswith('import'): return [] indentation = re.split(pattern=r'\bimport\b...
[ "def", "fix_e401", "(", "self", ",", "result", ")", ":", "line_index", "=", "result", "[", "'line'", "]", "-", "1", "target", "=", "self", ".", "source", "[", "line_index", "]", "offset", "=", "result", "[", "'column'", "]", "-", "1", "if", "not", ...
[ 888, 4 ]
[ 901, 39 ]
python
en
['en', 'en', 'en']
True
FixPEP8.fix_long_line_logically
(self, result, logical)
Try to make lines fit within --max-line-length characters.
Try to make lines fit within --max-line-length characters.
def fix_long_line_logically(self, result, logical): """Try to make lines fit within --max-line-length characters.""" if ( not logical or len(logical[2]) == 1 or self.source[result['line'] - 1].lstrip().startswith('#') ): return self.fix_long_line_p...
[ "def", "fix_long_line_logically", "(", "self", ",", "result", ",", "logical", ")", ":", "if", "(", "not", "logical", "or", "len", "(", "logical", "[", "2", "]", ")", "==", "1", "or", "self", ".", "source", "[", "result", "[", "'line'", "]", "-", "1...
[ 920, 4 ]
[ 953, 17 ]
python
en
['en', 'en', 'en']
True
FixPEP8.fix_long_line_physically
(self, result)
Try to make lines fit within --max-line-length characters.
Try to make lines fit within --max-line-length characters.
def fix_long_line_physically(self, result): """Try to make lines fit within --max-line-length characters.""" line_index = result['line'] - 1 target = self.source[line_index] previous_line = get_item(self.source, line_index - 1, default='') next_line = get_item(self.source, line_...
[ "def", "fix_long_line_physically", "(", "self", ",", "result", ")", ":", "line_index", "=", "result", "[", "'line'", "]", "-", "1", "target", "=", "self", ".", "source", "[", "line_index", "]", "previous_line", "=", "get_item", "(", "self", ".", "source", ...
[ 955, 4 ]
[ 976, 17 ]
python
en
['en', 'en', 'en']
True
FixPEP8.fix_e502
(self, result)
Remove extraneous escape of newline.
Remove extraneous escape of newline.
def fix_e502(self, result): """Remove extraneous escape of newline.""" (line_index, _, target) = get_index_offset_contents(result, self.source) self.source[line_index] = target.rstrip('\n\r \t\\') + '\n'
[ "def", "fix_e502", "(", "self", ",", "result", ")", ":", "(", "line_index", ",", "_", ",", "target", ")", "=", "get_index_offset_contents", "(", "result", ",", "self", ".", "source", ")", "self", ".", "source", "[", "line_index", "]", "=", "target", "....
[ 1009, 4 ]
[ 1013, 67 ]
python
en
['en', 'mk', 'en']
True
FixPEP8.fix_e701
(self, result)
Put colon-separated compound statement on separate lines.
Put colon-separated compound statement on separate lines.
def fix_e701(self, result): """Put colon-separated compound statement on separate lines.""" line_index = result['line'] - 1 target = self.source[line_index] c = result['column'] fixed_source = (target[:c] + '\n' + _get_indentation(target) + self.indent_wo...
[ "def", "fix_e701", "(", "self", ",", "result", ")", ":", "line_index", "=", "result", "[", "'line'", "]", "-", "1", "target", "=", "self", ".", "source", "[", "line_index", "]", "c", "=", "result", "[", "'column'", "]", "fixed_source", "=", "(", "tar...
[ 1015, 4 ]
[ 1025, 51 ]
python
en
['en', 'en', 'en']
True
FixPEP8.fix_e702
(self, result, logical)
Put semicolon-separated compound statement on separate lines.
Put semicolon-separated compound statement on separate lines.
def fix_e702(self, result, logical): """Put semicolon-separated compound statement on separate lines.""" if not logical: return [] # pragma: no cover logical_lines = logical[2] # Avoid applying this when indented. # https://docs.python.org/reference/compound_stmts.h...
[ "def", "fix_e702", "(", "self", ",", "result", ",", "logical", ")", ":", "if", "not", "logical", ":", "return", "[", "]", "# pragma: no cover", "logical_lines", "=", "logical", "[", "2", "]", "# Avoid applying this when indented.", "# https://docs.python.org/referen...
[ 1027, 4 ]
[ 1073, 31 ]
python
en
['en', 'en', 'en']
True
FixPEP8.fix_e704
(self, result)
Fix multiple statements on one line def
Fix multiple statements on one line def
def fix_e704(self, result): """Fix multiple statements on one line def""" (line_index, _, target) = get_index_offset_contents(result, self.source) match = STARTSWITH_DEF_REGEX.match(target) if match: self.source[line...
[ "def", "fix_e704", "(", "self", ",", "result", ")", ":", "(", "line_index", ",", "_", ",", "target", ")", "=", "get_index_offset_contents", "(", "result", ",", "self", ".", "source", ")", "match", "=", "STARTSWITH_DEF_REGEX", ".", "match", "(", "target", ...
[ 1075, 4 ]
[ 1084, 47 ]
python
en
['en', 'en', 'en']
True
FixPEP8.fix_e711
(self, result)
Fix comparison with None.
Fix comparison with None.
def fix_e711(self, result): """Fix comparison with None.""" (line_index, offset, target) = get_index_offset_contents(result, self.source) right_offset = offset + 2 if right_offset >= len(target): return [] ...
[ "def", "fix_e711", "(", "self", ",", "result", ")", ":", "(", "line_index", ",", "offset", ",", "target", ")", "=", "get_index_offset_contents", "(", "result", ",", "self", ".", "source", ")", "right_offset", "=", "offset", "+", "2", "if", "right_offset", ...
[ 1086, 4 ]
[ 1106, 69 ]
python
en
['en', 'it', 'en']
True
FixPEP8.fix_e712
(self, result)
Fix (trivial case of) comparison with boolean.
Fix (trivial case of) comparison with boolean.
def fix_e712(self, result): """Fix (trivial case of) comparison with boolean.""" (line_index, offset, target) = get_index_offset_contents(result, self.source) # Handle very easy "not" special cases. if re.match(r'^\s*if [\...
[ "def", "fix_e712", "(", "self", ",", "result", ")", ":", "(", "line_index", ",", "offset", ",", "target", ")", "=", "get_index_offset_contents", "(", "result", ",", "self", ".", "source", ")", "# Handle very easy \"not\" special cases.", "if", "re", ".", "matc...
[ 1108, 4 ]
[ 1144, 54 ]
python
en
['en', 'en', 'en']
True
FixPEP8.fix_e713
(self, result)
Fix (trivial case of) non-membership check.
Fix (trivial case of) non-membership check.
def fix_e713(self, result): """Fix (trivial case of) non-membership check.""" (line_index, offset, target) = get_index_offset_contents(result, self.source) # to convert once 'not in' -> 'in' before_target = target[:offset]...
[ "def", "fix_e713", "(", "self", ",", "result", ")", ":", "(", "line_index", ",", "offset", ",", "target", ")", "=", "get_index_offset_contents", "(", "result", ",", "self", ".", "source", ")", "# to convert once 'not in' -> 'in'", "before_target", "=", "target",...
[ 1146, 4 ]
[ 1176, 52 ]
python
en
['en', 'gl', 'en']
True
FixPEP8.fix_e714
(self, result)
Fix object identity should be 'is not' case.
Fix object identity should be 'is not' case.
def fix_e714(self, result): """Fix object identity should be 'is not' case.""" (line_index, offset, target) = get_index_offset_contents(result, self.source) # to convert once 'is not' -> 'is' before_target = target[:offset...
[ "def", "fix_e714", "(", "self", ",", "result", ")", ":", "(", "line_index", ",", "offset", ",", "target", ")", "=", "get_index_offset_contents", "(", "result", ",", "self", ".", "source", ")", "# to convert once 'is not' -> 'is'", "before_target", "=", "target",...
[ 1178, 4 ]
[ 1207, 52 ]
python
en
['en', 'en', 'en']
True
FixPEP8.fix_e722
(self, result)
fix bare except
fix bare except
def fix_e722(self, result): """fix bare except""" (line_index, _, target) = get_index_offset_contents(result, self.source) match = BARE_EXCEPT_REGEX.search(target) if match: self.source[line_index] = '{}{}{}'.format(...
[ "def", "fix_e722", "(", "self", ",", "result", ")", ":", "(", "line_index", ",", "_", ",", "target", ")", "=", "get_index_offset_contents", "(", "result", ",", "self", ".", "source", ")", "match", "=", "BARE_EXCEPT_REGEX", ".", "search", "(", "target", "...
[ 1209, 4 ]
[ 1217, 37 ]
python
en
['en', 'it', 'en']
True
FixPEP8.fix_e731
(self, result)
Fix do not assign a lambda expression check.
Fix do not assign a lambda expression check.
def fix_e731(self, result): """Fix do not assign a lambda expression check.""" (line_index, _, target) = get_index_offset_contents(result, self.source) match = LAMBDA_REGEX.search(target) if match: end = match.end() ...
[ "def", "fix_e731", "(", "self", ",", "result", ")", ":", "(", "line_index", ",", "_", ",", "target", ")", "=", "get_index_offset_contents", "(", "result", ",", "self", ".", "source", ")", "match", "=", "LAMBDA_REGEX", ".", "search", "(", "target", ")", ...
[ 1219, 4 ]
[ 1228, 38 ]
python
en
['gl', 'lb', 'en']
False
FixPEP8.fix_w291
(self, result)
Remove trailing whitespace.
Remove trailing whitespace.
def fix_w291(self, result): """Remove trailing whitespace.""" fixed_line = self.source[result['line'] - 1].rstrip() self.source[result['line'] - 1] = fixed_line + '\n'
[ "def", "fix_w291", "(", "self", ",", "result", ")", ":", "fixed_line", "=", "self", ".", "source", "[", "result", "[", "'line'", "]", "-", "1", "]", ".", "rstrip", "(", ")", "self", ".", "source", "[", "result", "[", "'line'", "]", "-", "1", "]",...
[ 1230, 4 ]
[ 1233, 59 ]
python
en
['en', 'it', 'en']
True
FixPEP8.fix_w391
(self, _)
Remove trailing blank lines.
Remove trailing blank lines.
def fix_w391(self, _): """Remove trailing blank lines.""" blank_count = 0 for line in reversed(self.source): line = line.rstrip() if line: break else: blank_count += 1 original_length = len(self.source) self.sou...
[ "def", "fix_w391", "(", "self", ",", "_", ")", ":", "blank_count", "=", "0", "for", "line", "in", "reversed", "(", "self", ".", "source", ")", ":", "line", "=", "line", ".", "rstrip", "(", ")", "if", "line", ":", "break", "else", ":", "blank_count"...
[ 1235, 4 ]
[ 1247, 44 ]
python
en
['en', 'en', 'en']
True
ReformattedLines.previous_item
(self)
Return the previous non-whitespace item.
Return the previous non-whitespace item.
def previous_item(self): """Return the previous non-whitespace item.""" return self._prev_item
[ "def", "previous_item", "(", "self", ")", ":", "return", "self", ".", "_prev_item" ]
[ 2167, 4 ]
[ 2169, 30 ]
python
en
['en', 'el-Latn', 'en']
True
ReformattedLines.current_size
(self)
The size of the current line minus the indentation.
The size of the current line minus the indentation.
def current_size(self): """The size of the current line minus the indentation.""" size = 0 for item in reversed(self._lines): size += item.size if isinstance(item, self._LineBreak): break return size
[ "def", "current_size", "(", "self", ")", ":", "size", "=", "0", "for", "item", "in", "reversed", "(", "self", ".", "_lines", ")", ":", "size", "+=", "item", ".", "size", "if", "isinstance", "(", "item", ",", "self", ".", "_LineBreak", ")", ":", "br...
[ 2174, 4 ]
[ 2182, 19 ]
python
en
['en', 'en', 'en']
True
ReformattedLines._add_item
(self, item, indent_amt)
Add an item to the line. Reflow the line to get the best formatting after the item is inserted. The bracket depth indicates if the item is being inserted inside of a container or not.
Add an item to the line.
def _add_item(self, item, indent_amt): """Add an item to the line. Reflow the line to get the best formatting after the item is inserted. The bracket depth indicates if the item is being inserted inside of a container or not. """ if self._prev_item and self._prev_item.i...
[ "def", "_add_item", "(", "self", ",", "item", ",", "indent_amt", ")", ":", "if", "self", ".", "_prev_item", "and", "self", ".", "_prev_item", ".", "is_string", "and", "item", ".", "is_string", ":", "# Place consecutive string literals on separate lines.", "self", ...
[ 2201, 4 ]
[ 2240, 43 ]
python
en
['en', 'en', 'en']
True
ReformattedLines._prevent_default_initializer_splitting
(self, item, indent_amt)
Prevent splitting between a default initializer. When there is a default initializer, it's best to keep it all on the same line. It's nicer and more readable, even if it goes over the maximum allowable line length. This goes back along the current line to determine if we have a default ...
Prevent splitting between a default initializer.
def _prevent_default_initializer_splitting(self, item, indent_amt): """Prevent splitting between a default initializer. When there is a default initializer, it's best to keep it all on the same line. It's nicer and more readable, even if it goes over the maximum allowable line length. T...
[ "def", "_prevent_default_initializer_splitting", "(", "self", ",", "item", ",", "indent_amt", ")", ":", "if", "unicode", "(", "item", ")", "==", "'='", ":", "# This is the assignment in the initializer. Just remove spaces for", "# now.", "self", ".", "_delete_whitespace",...
[ 2278, 4 ]
[ 2315, 42 ]
python
en
['en', 'nl', 'en']
True
ReformattedLines._split_after_delimiter
(self, item, indent_amt)
Split the line only after a delimiter.
Split the line only after a delimiter.
def _split_after_delimiter(self, item, indent_amt): """Split the line only after a delimiter.""" self._delete_whitespace() if self.fits_on_current_line(item.size): return last_space = None for current_item in reversed(self._lines): if ( l...
[ "def", "_split_after_delimiter", "(", "self", ",", "item", ",", "indent_amt", ")", ":", "self", ".", "_delete_whitespace", "(", ")", "if", "self", ".", "fits_on_current_line", "(", "item", ".", "size", ")", ":", "return", "last_space", "=", "None", "for", ...
[ 2317, 4 ]
[ 2342, 73 ]
python
en
['en', 'en', 'en']
True
ReformattedLines._enforce_space
(self, item)
Enforce a space in certain situations. There are cases where we will want a space where normally we wouldn't put one. This just enforces the addition of a space.
Enforce a space in certain situations.
def _enforce_space(self, item): """Enforce a space in certain situations. There are cases where we will want a space where normally we wouldn't put one. This just enforces the addition of a space. """ if isinstance(self._lines[-1], (self._Space, self._Line...
[ "def", "_enforce_space", "(", "self", ",", "item", ")", ":", "if", "isinstance", "(", "self", ".", "_lines", "[", "-", "1", "]", ",", "(", "self", ".", "_Space", ",", "self", ".", "_LineBreak", ",", "self", ".", "_Indent", ")", ")", ":", "return", ...
[ 2344, 4 ]
[ 2368, 45 ]
python
en
['en', 'en', 'en']
True
ReformattedLines._delete_whitespace
(self)
Delete all whitespace from the end of the line.
Delete all whitespace from the end of the line.
def _delete_whitespace(self): """Delete all whitespace from the end of the line.""" while isinstance(self._lines[-1], (self._Space, self._LineBreak, self._Indent)): del self._lines[-1]
[ "def", "_delete_whitespace", "(", "self", ")", ":", "while", "isinstance", "(", "self", ".", "_lines", "[", "-", "1", "]", ",", "(", "self", ".", "_Space", ",", "self", ".", "_LineBreak", ",", "self", ".", "_Indent", ")", ")", ":", "del", "self", "...
[ 2370, 4 ]
[ 2374, 31 ]
python
en
['en', 'en', 'en']
True
Container._get_extent
(self, index)
The extent of the full element. E.g., the length of a function call or keyword.
The extent of the full element.
def _get_extent(self, index): """The extent of the full element. E.g., the length of a function call or keyword. """ extent = 0 prev_item = get_item(self._items, index - 1) seen_dot = prev_item and unicode(prev_item) == '.' while index < len(self._items): ...
[ "def", "_get_extent", "(", "self", ",", "index", ")", ":", "extent", "=", "0", "prev_item", "=", "get_item", "(", "self", ".", "_items", ",", "index", "-", "1", ")", "seen_dot", "=", "prev_item", "and", "unicode", "(", "prev_item", ")", "==", "'.'", ...
[ 2542, 4 ]
[ 2577, 21 ]
python
en
['en', 'en', 'en']
True
_read_parameters
(parameters_file)
Read parameters file .. warning : The parameters file contains the length of the region along each axe. While creating the region, we are assuming that the z axe points upwards and therefore all values beneath the surface are negative, and the x and y axes are all positive wit...
Read parameters file
def _read_parameters(parameters_file): """ Read parameters file .. warning : The parameters file contains the length of the region along each axe. While creating the region, we are assuming that the z axe points upwards and therefore all values beneath the surface are negative, and...
[ "def", "_read_parameters", "(", "parameters_file", ")", ":", "parameters", "=", "{", "}", "read_shape", ",", "read_max_coords", "=", "False", ",", "False", "with", "open", "(", "parameters_file", ",", "\"r\"", ")", "as", "params_file", ":", "for", "line", "i...
[ 10, 0 ]
[ 73, 21 ]
python
en
['en', 'error', 'th']
False
_read_times
(path, print_step, max_steps, steps_slice)
Read the time files generated by Mandyoc code Parameters ---------- path : str Path to the folder where the Mandyoc files are located. print_step : int Only steps multiple of ``print_step`` are saved by Mandyoc. max_steps : int Maximum number of steps. Mandyoc could bre...
Read the time files generated by Mandyoc code
def _read_times(path, print_step, max_steps, steps_slice): """ Read the time files generated by Mandyoc code Parameters ---------- path : str Path to the folder where the Mandyoc files are located. print_step : int Only steps multiple of ``print_step`` are saved by Mandyoc. ...
[ "def", "_read_times", "(", "path", ",", "print_step", ",", "max_steps", ",", "steps_slice", ")", ":", "steps", ",", "times", "=", "[", "]", ",", "[", "]", "# Define the mininun and maximun step", "if", "steps_slice", "is", "not", "None", ":", "min_steps_slice"...
[ 76, 0 ]
[ 122, 23 ]
python
en
['en', 'error', 'th']
False
register_range
(pgrange, pyrange, conn_or_curs, globally=False)
Create and register an adapter and the typecasters to convert between a PostgreSQL |range|_ type and a PostgreSQL `Range` subclass. :param pgrange: the name of the PostgreSQL |range| type. Can be schema-qualified :param pyrange: a `Range` strict subclass, or just a name to give to a new cla...
Create and register an adapter and the typecasters to convert between a PostgreSQL |range|_ type and a PostgreSQL `Range` subclass.
def register_range(pgrange, pyrange, conn_or_curs, globally=False): """Create and register an adapter and the typecasters to convert between a PostgreSQL |range|_ type and a PostgreSQL `Range` subclass. :param pgrange: the name of the PostgreSQL |range| type. Can be schema-qualified :param pyra...
[ "def", "register_range", "(", "pgrange", ",", "pyrange", ",", "conn_or_curs", ",", "globally", "=", "False", ")", ":", "caster", "=", "RangeCaster", ".", "_from_db", "(", "pgrange", ",", "pyrange", ",", "conn_or_curs", ")", "caster", ".", "_register", "(", ...
[ 210, 0 ]
[ 238, 17 ]
python
en
['en', 'en', 'en']
True