pyfstab package¶
Submodules¶
pyfstab.fstab module¶
-
class
pyfstab.fstab.
Fstab
¶ Bases:
object
Handles reading, parsing, formatting and writing of fstab files.
Variables: - entries – (list[Entry]) - List of entries. When writing to a file, entries are listed from this list.
- entries_by_device – (dict[str, list[Entry]]) - Fstab entries by device.
- entry_by_dir – (dict[str, Entry]) - Fstab entry by directory.
- entries_by_type – (dict[str, list[Entry]]) - Fstab entries by type.
-
read_file
(handle, only_valid=False)¶ Parses entries from a file
Parameters: - handle (file) – File handle
- only_valid (bool) – Skip the entries that do not actually mount. For example, if device A is mounted to directory X and later device B is mounted to directory X, the A mount to X is undone by the system.
Returns: self
Return type:
-
read_string
(data, only_valid=False)¶ Parses entries from a data string
Parameters: - data (str) – Contents of the fstab file
- only_valid (bool) – Skip the entries that do not actually mount. For example, if device A is mounted to directory X and later device B is mounted to directory X, the A mount to X is undone by the system.
Returns: self
Return type:
pyfstab.entry module¶
-
class
pyfstab.entry.
Entry
(_device=None, _dir=None, _type=None, _options=None, _dump=None, _fsck=None)¶ Bases:
object
Handles parsing and formatting fstab line entries.
Variables: - device – (str or None) - Fstab device (1st parameter in the fstab entry)
- dir – (str or None) - Fstab device (2nd parameter in the fstab entry)
- type – (str or None) - Fstab device (3rd parameter in the fstab entry)
- options – (str or None) - Fstab device (4th parameter in the fstab entry)
- dump – (int or None) - Fstab device (5th parameter in the fstab entry)
- fsck – (int or None) - Fstab device (6th parameter in the fstab entry)
- valid – (bool) - Whether the Entry is valid or not. Can be checked with “if entry:”.
-
__init__
(_device=None, _dir=None, _type=None, _options=None, _dump=None, _fsck=None)¶ Parameters: - _device (str) – Fstab device (1st parameter in the fstab entry)
- _dir (str) – Fstab device (2nd parameter in the fstab entry)
- _type (str) – Fstab device (3rd parameter in the fstab entry)
- _options (str) – Fstab device (4th parameter in the fstab entry)
- _dump (int) – Fstab device (5th parameter in the fstab entry)
- _fsck (int) – Fstab device (6th parameter in the fstab entry)
-
read_string
(line)¶ Parses an entry from a string
Parameters: line (str) – Fstab entry line. Returns: self Return type: Entry Raises: InvalidEntry – If the data in the string cannot be parsed.
-
write_string
()¶ Formats the Entry into fstab entry line.
Returns: Fstab entry line. Return type: str Raises: InvalidEntry – A string cannot be generated because the entry is invalid.
-
exception
pyfstab.entry.
InvalidEntry
¶ Bases:
Exception
Raised when a string cannot be generated because of the Entry is invalid.
-
exception
pyfstab.entry.
InvalidFstabLine
¶ Bases:
Exception
Raised when a line is invalid in fstab. This doesn’t just mean that the Entry will be invalid but also that the system can not process the fstab file fully either.