DynamicFile¶
This module contains all the different DynamicFiles and their base class. DynamicFiles provide mechanisms to transform or manipulate dotfiles before actually linking them. The DynamicFile will generate a new file that will be linked instead and makes sure that user-made changes are preserved.
DynamicFile |
The abstract base class for any dynamic generated file. |
EncryptedFile |
This implementation of a dynamic files allows to decrypt encrypted files. |
FilteredFile |
This is implementation of a dynamic files allows to run a shell command on a dotfile before linking. |
SplittedFile |
This is of a dynamic files allows to join multiple dotfiles together to one dotfile. |
-
class
dynamicfile.
DynamicFile
(name)¶ Bases:
object
The abstract base class for any dynamic generated file. It provides the update functionality and some basic information.
-
name
¶ Name of the file
Type: str
-
md5sum
¶ A checksum of the contents of the file
Type: str
-
sources
¶ A list of paths of files that are used as source to generate the dynmaic file
Type: list
-
SUBDIR
¶ This constant needs to be implemented by subclasses. It tells the DynamicFile where to store the generated content of the file. It should be different for every type of DynamicFile, so the user can find them easier and can view different "stages" of the generation if the DynamicFile was nested.
-
__init__
(name)¶ Constructor
Parameters: name (str) -- Name of the file
-
_generate_file
()¶ This abstract method is used to generate the contents of the DynamicFile from sources.
Returns: bytearray -- The raw generated content
-
add_source
(target)¶ Adds a source path and normalizes it.
Parameters: target (str) -- A path to a file that will be used as source
-
getdir
()¶ Gets the path of the directory that is used to store the generated file.
Returns: str -- The path to the directory
-
getpath
()¶ Gets the path of the generated file
Returns: str -- The full path to the generated file
-
update
()¶ Generates the newest version of the file and writes it if it is not in its subdir yet.
-
-
class
dynamicfile.
EncryptedFile
(name)¶ Bases:
dynamicfile.DynamicFile
This implementation of a dynamic files allows to decrypt encrypted files.
-
SUBDIR
= 'decrypted'¶ Subdirectory used by EncryptedFile
-
_generate_file
()¶ Decrypts the first file in
self.sources
using gpg.Returns: bytearray -- The content of the decrypted file
-
-
class
dynamicfile.
FilteredFile
(name, shell_command)¶ Bases:
dynamicfile.DynamicFile
This is implementation of a dynamic files allows to run a shell command on a dotfile before linking.
-
SUBDIR
= 'piped'¶ Subdirectory used by FilteredFile
-
__init__
(name, shell_command)¶ Constructor.
Parameters: - name (str) -- Name of the file
- shell_command (str) -- A shell command that the file will be piped into
-
_generate_file
()¶ Pipes the content of the first file in
self.sources
into the specified shell comand.Returns: bytearray -- The output of the shell command
-
-
class
dynamicfile.
SplittedFile
(name)¶ Bases:
dynamicfile.DynamicFile
This is of a dynamic files allows to join multiple dotfiles together to one dotfile.
-
SUBDIR
= 'merged'¶ Subdirectory used by SplittedFile
-
_generate_file
()¶ Merges all files from
:class:`~interpreters.self`.sources
in order.Returns: bytearray -- The content of all files merged together
-