Metadata-Version: 2.4
Name: clamdpy
Version: 0.2.0
Summary: A Python wrapper around clamd, the ClamAV daemon
Project-URL: Homepage, https://github.com/Viicos/clamdpy
Project-URL: Source, https://github.com/Viicos/clamdpy
Project-URL: Changelog, https://github.com/Viicos/clamdpy/blob/main/CHANGELOG.md
Author-email: Viicos <65306057+Viicos@users.noreply.github.com>
License: MIT License
        
        Copyright (c) 2023 Viicos
        
        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
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# clamdpy

A Python wrapper around `clamd`, the [ClamAV](https://www.clamav.net/) daemon.

This is a maintained and updated fork of https://github.com/graingert/python-clamd/, credit goes to the original developer(s).

[![Python versions](https://img.shields.io/pypi/pyversions/clamdpy.svg)](https://www.python.org/downloads/)
[![PyPI version](https://img.shields.io/pypi/v/clamdpy.svg)](https://pypi.org/project/clamdpy/)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

## Installation

Using `pip`:

```sh
pip install clamdpy
```

## Usage

```python
from io import BytesIO

from clamdpy import ClamdNetworkSocket

clamd = ClamdNetworkSocket(
    host="127.0.0.1",
    port=3310,
    timeout=15,
)

clamd.ping()
#> 'PONG'

clamd.version()
#> VersionInfo(version='ClamAV 0.103.9', signature=27065, signature_date=datetime(2023, 10, 18, 9, 49, 14))

# Raw response can be fetched as well:
clamd.version(raw=True)
#> 'ClamAV 0.103.9/27065/Wed Oct 18 09:49:14 2023'

clamd.instream(BytesIO(b"data"))
#> ScanResult(path='stream', reason=None, status='OK')
```

Most of the [clamd commands](https://github.com/Cisco-Talos/clamav/blob/main/docs/man/clamd.8.in) are implemented (a couple ones are missing and should be implemented sooner or later).

It is possible to use [UNIX sockets](https://docs.python.org/3/library/socket.html#socket.AF_UNIX) as well:

```python
from clamdpy import ClamdUnixSocket

clamd = ClamdUnixSocket(path="/var/run/clamav/clamd.ctl")
```

### Line delimitations

By default, `\n` will be used to terminate lines. Clamd also supports `NULL` characters:

```python
from clamdpy import ClamdNetworkSocket

clamd = ClamdNetworkSocket(line_terminator="z")
```

> [!WARNING]\
> Support for the `NULL` character isn't tested and may not work as it doesn't play well with Python. Use with caution.
