Skip to content

Uncompress

flowtask.components.Uncompress

Uncompress

Uncompress(loop=None, job=None, stat=None, **kwargs)

Bases: CompressSupport, FlowComponent

Uncompress

Overview

    The Uncompress class is a component for decompressing files in various archive formats, including but not limited to:
    7z (.7z), ACE (.ace), ALZIP (.alz), AR (.a), ARC (.arc), ARJ (.arj), BZIP2 (.bz2), CAB (.cab), compress (.Z), 
    CPIO (.cpio), DEB (.deb), DMS (.dms), GZIP (.gz), LRZIP (.lrz), LZH (.lha, .lzh), LZIP (.lz), LZMA (.lzma), 
    LZOP (.lzo), RPM (.rpm), RAR (.rar), RZIP (.rz), TAR (.tar), XZ (.xz), ZIP (.zip, .jar), and ZOO (.zoo). 
    It extracts the specified compressed file into a target directory and can optionally delete the source file 
    upon successful extraction.

.. table:: Properties
:widths: auto

    +----------------+----------+-----------+---------------------------------------------------------------+
    | Name           | Required | Summary                                                                   |
    +----------------+----------+-----------+---------------------------------------------------------------+
    | filename       |   Yes    | The path to the compressed file to be decompressed.                       |
    +----------------+----------+-----------+---------------------------------------------------------------+
    | directory      |   Yes    | The target directory where files will be extracted.                       |
    +----------------+----------+-----------+---------------------------------------------------------------+
    | delete_source  |   No     | Boolean indicating if the source file should be deleted post-extraction.  |
    +----------------+----------+-----------+---------------------------------------------------------------+
    | extract        |   No     | Dictionary specifying filenames to extract and/or output directory.       |
    +----------------+----------+-----------+---------------------------------------------------------------+
    | password       |   No     | Optional password for encrypted files in supported formats.               |
    +----------------+----------+-----------+---------------------------------------------------------------+

Returns

    This component extracts files from the specified compressed archive into the designated directory and returns
    a list of paths to the extracted files. It tracks metrics for the output directory and compressed file name.
    If configured, the original compressed file is deleted after extraction. Errors related to file corruption 
    or extraction issues are logged and raised as exceptions.


Example:

```yaml
Uncompress:
  filename: organizational_unit_ancestors_{yesterday}.zip
  masks:
    yesterday:
    - yesterday
    - mask: '%Y-%m-%d'
  directory: /home/ubuntu/symbits/polestar/files/organizational_unit_ancestors/
  extract:
    filenames:
    - OrganizationalUnitAncestors.csv
    directory: /home/ubuntu/symbits/polestar/files/organizational_unit_ancestors/
  delete_source: false
```