class documentation

class ConfigFile(ConnectorMixin, SignalEmitter): (source)

View In Hierarchy

Container object for a config file

Maps to a "base" file in the home folder, used to write new values, and an optional default file, which is used for reading only.

Note
this class implement similar API to the File class but is explicitly not a sub-class of File because config files should typically not be moved, renamed, etc. It just implements the reading and writing methods.
Unknown Field: signal
changed (): emitted when the underlying file changed (based on gio monitoring support).
Method __eq__ Undocumented
Method __init__ Undocumented
Method __repr__ Undocumented
Method check_has_changed_on_disk Undocumented
Method exists Undocumented
Method read No summary
Method readlines No summary
Method remove Remove user file, leaves default files in place
Method touch No summary
Method write Write base file, see File.write()
Method writelines Write base file, see File.writelines()
Class Variable __signals__ Undocumented
Instance Variable defaults a generator that yields default files
Instance Variable file the underlying file object for the base config file in the home folder
Property basename Undocumented

Inherited from ConnectorMixin:

Method connectto Connect to signals of another object E.g.:
Method connectto_all Convenience method to combine multiple calls to connectto().
Method disconnect_all Disconnect all signals that have been connected with connectto and friends. Typically called when you want to destroy this object.
Method disconnect_from Disc all signals that have been connected with connectto and friends to a specific object.
Method _disconnect_from Undocumented
Instance Variable _connected_signals Undocumented

Inherited from SignalEmitter:

Method __new__ Undocumented
Method block_signals Returns a context manager for blocking one or more signals
Method connect Register a handler for a specific object.
Method connect_after Like connect() but handler will be called after default handler
Method disconnect Undocumented
Method emit Undocumented
Method emit_return_first Emits a signal and stops emission on the first handler that returns a not-None value.
Method emit_return_iter Returns an generator that calls one handler on each iteration and yields the return values. This allows aggregating return values.
Method _connect Undocumented
Method _setup_signal Undocumented
Method _teardown_signal Undocumented
def __eq__(self, other): (source)

Undocumented

def __init__(self, file, defaults=None): (source)

Undocumented

def __repr__(self): (source)

Undocumented

def check_has_changed_on_disk(self): (source)

Undocumented

def exists(self): (source)

Undocumented

def read(self, fail=False): (source)
Read the base file or first default file
Parameters
failif True a FileNotFoundError error is raised when neither the base file or a default file are found. If False it will return '' for a non-existing file.
Returns
file content as a string
def readlines(self, fail=False): (source)
Read the base file or first default file
Parameters
failif True a FileNotFoundError error is raised when neither the base file or a default file are found. If False it will return [] for a non-existing file.
Returns
file content as a list of lines
def remove(self): (source)
Remove user file, leaves default files in place
def touch(self): (source)
Ensure the custom file in the home folder exists. Either by copying a default config file, or touching an empty file. Intended to be called before trying to edit the file with an external editor.
def write(self, text): (source)
Write base file, see File.write()
def writelines(self, lines): (source)
Write base file, see File.writelines()
__signals__ = (source)

Undocumented

defaults = (source)
a generator that yields default files
file = (source)
the underlying file object for the base config file in the home folder
@property
basename = (source)

Undocumented