Metadata-Version: 2.4
Name: kompress
Version: 0.3.20260707
Summary: pathlib.Path adapters to transparently read data from compressed files and folders
Project-URL: Homepage, https://github.com/karlicoss/kompress
Author-email: "Dima Gerasimov (@karlicoss)" <karlicoss@gmail.com>
Maintainer-email: "Dima Gerasimov (@karlicoss)" <karlicoss@gmail.com>
License: MIT License
        
        Copyright (c) 2023 Dmitrii Gerasimov
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Requires-Python: >=3.10
Requires-Dist: typing-extensions
Provides-Extra: lz4
Requires-Dist: lz4; extra == 'lz4'
Provides-Extra: zstd
Requires-Dist: zstandard; (python_version < '3.14') and extra == 'zstd'
Description-Content-Type: text/markdown

`kompress` lets you transparently decompress common archive formats while using `pathlib.Path` objects.

It attempts to keep the API as close to pathlib, but things may not be perfect yet

The common case for this is:

- You have a compressed file that when decompressed contains some text
- You have a function (perhaps from another library, that you don't control), that knows how to take a `pathlib.Path` object and call `.read()` or `.read_text()` on it

Without wrapping the function or adding logic to let it read from compressed files, this lets you do the following:

```python
from pathlib import Path
from kompress import CPath, is_compressed

def char_count(path: Path) -> int:
    # here, if a CPath is passed, it decompresses and returns a string
    return len(path.read_text())

inp = input("Enter a file to process: ")  # file came from user
char_count(CPath(inp))
```

This currently supports these archive formats:

- `.xz`
- `.zip`
- `.zst`
- `.tar.gz`
- `.gz`
- `.zstd` (since `python3.14`, on older version use `pip install 'kompress[zstd]'`)
- `.lz4` (`pip install 'kompress[lz4]'`)

If it doesn't recognize the filetype, it will just call `pathlib.Path.open`, reading it like a regular file.

Originally discussed in this [HPI issue](https://github.com/karlicoss/HPI/issues/20)

## Installing

`pip install kompress`

