pygacity.util.collectors module¶
- class pygacity.util.collectors.ByteCollector(line_length: int = 80, comment_char: str = '#', byte_collector: str = '')[source]¶
Bases:
objectA simple string manager
The main object in a ByteCollector instance is a string of bytes (byte_collector). The string can be appended to by anoter string or the contents of a file. The string can have “comments” written to it.
- has_statement(statement: str, end: str = '\n', exclude: str = '#')[source]¶
Determines if a particular statement is on at least one non-comment line
- injest_file(filename: str)[source]¶
Appends contents of file ‘filename’ to the string
- Parameters:
filename (str) – the name of the file
- class pygacity.util.collectors.FileCollector(initial: list[str | Path] = None)[source]¶
Bases:
UserListA class for handling collections of files to be managed together as Paths
- append(item: str | Path)[source]¶
Appends a file path to the collection
- Parameters:
item (str | Path) – the file path to append
- archive(basepath: Path, delete: bool = False)[source]¶
Archives the files in the collection into a single compressed file. If OS is Windows, makes a zipfile; if Linux, makes a tarball of the files in the collection.
- Parameters:
basepath (Path) – basename of the resulting tarball or zipfile
delete (bool, optional) – if True, deletes the original files after archiving (default is False)