_file module

class pyflyby._file.FilePos

A (lineno, colno) position within a FileText. Both lineno and colno are 1-indexed.

_ONE_ONE = FilePos(1,1)
property _data
classmethod _from_lc(lineno, colno)
static _intint(args)
class pyflyby._file.FileText

Represents a contiguous sequence of lines from a file.

_colno_to_index(lineindex, colno)
classmethod _from_lines(lines, filename, startpos)
_lineno_to_index(lineno)
alter(filename=None, startpos=None)
classmethod concatenate(args)

Concatenate a bunch of FileText arguments. Uses the filename and startpos from the first argument.

Return type

FileText

endpos

Computes attribute value and caches it in instance.

Example:

class MyClass(object):
    @cached_attribute
    def myMethod(self):
        # ...

Use “del inst.myMethod” to clear cache.

classmethod from_filename(filename)
joined

Computes attribute value and caches it in instance.

Example:

class MyClass(object):
    @cached_attribute
    def myMethod(self):
        # ...

Use “del inst.myMethod” to clear cache.

lines

Computes attribute value and caches it in instance.

Example:

class MyClass(object):
    @cached_attribute
    def myMethod(self):
        # ...

Use “del inst.myMethod” to clear cache.

exception pyflyby._file.UnsafeFilenameError
pyflyby._file.atomic_write_file(filename, data)
pyflyby._file.expand_py_files_from_args(pathnames, on_error=<function <lambda>>)

Enumerate *.py files, recursively.

Arguments that are files are always included. Arguments that are directories are recursively searched for *.py files.

Parameters

on_error (callable) – Function that is called for arguments directly specified in pathnames that don’t exist or are otherwise inaccessible.

Return type

list of Filename s

pyflyby._file.read_file(filename)
pyflyby._file.which(program)

Find program on $PATH.

Return type

Filename

Returns

Program on $PATH, or None if not found.

pyflyby._file.write_file(filename, data)