_file module
- class pyflyby._file.FilePos(*args: Any)
A (lineno, colno) position within a FileText. Both lineno and colno are 1-indexed.
- property _data: Tuple[int, int]
- static _intint(args)
- Return type:
Tuple[int,int]
- colno: int
- lineno: int
- class pyflyby._file.FileText(arg, filename=None, startpos=None)
Represents a contiguous sequence of lines from a file.
- _colno_to_index(lineindex, colno)
- Return type:
int
- _lineno_to_index(lineno)
- Return type:
int
- _lines: Tuple[str, ...] | None = None
- classmethod concatenate(args)
Concatenate a bunch of FileText arguments. Uses the
filenameandstartposfrom the first argument.- Return type:
FileText
- filename: Filename | None
- classmethod from_filename(filename)
- get_comments()
Return the comment string for each line (if any).
- Return type:
list[Optional[str]]- Returns:
The comment string for each line in the statement. If no comment is present, None is returned for that line
- property joined: str
- property lines: Tuple[str, ...]
Lines that have been split by newline.
These strings do NOT contain ‘n’.
If the input file ended in ‘n’, then the last item will be the empty string. This is to avoid having to check lines[-1].endswith(’n’) everywhere.
- Return type:
tupleofstr
- exception pyflyby._file.UnsafeFilenameError
- pyflyby._file._get_PATH()
- Return type:
Tuple[Filename,...]
- pyflyby._file.atomic_write_file(filename, data)
- Return type:
None
- pyflyby._file.expand_py_files_from_args(pathnames, on_error=<function <lambda>>)
Enumerate
*.pyfiles, recursively.Arguments that are files are always included. Arguments that are directories are recursively searched for
*.pyfiles.- Parameters:
on_error (
Callable[[Filename],Any]) – Function that is called for arguments directly specified inpathnamesthat don’t exist or are otherwise inaccessible.- Return type:
List[Filename]listof Filename s
- pyflyby._file.which(program)
Find
programon $PATH.- Return type:
Optional[Filename] Filename- Returns:
Program on $PATH, or
Noneif not found.
- pyflyby._file.write_file(filename, data)
- Return type:
None