_file module
- class pyflyby._file.FilePos(*args)
A (lineno, colno) position within a FileText. Both lineno and colno are 1-indexed.
- property _data
- classmethod _from_lc(lineno, colno)
- static _intint(args)
-
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)
- classmethod _from_lines(lines, filename, startpos)
- _lineno_to_index(lineno)
-
_lines:
Optional[Tuple[str,...]] = None
- alter(filename=None, startpos=None)
- classmethod concatenate(args)
Concatenate a bunch of FileText arguments. Uses the
filenameandstartposfrom the first argument.- Return type:
FileText
- property endpos
The position after the last character in the text.
- Return type:
FilePos
-
filename:
Optional[Filename]
- 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()
- pyflyby._file.atomic_write_file(filename, data)
- 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) – Function that is called for arguments directly specified in
pathnamesthat don’t exist or are otherwise inaccessible.- Return type:
listof Filename s
- pyflyby._file.which(program)
Find
programon $PATH.- Return type:
Filename
- Returns:
Program on $PATH, or
Noneif not found.
- pyflyby._file.write_file(filename, data)