Metadata-Version: 2.4
Name: geraci
Version: 2.0.0
Summary: A fast, easy and complete file and directory management library
Home-page: https://github.com/Rp-ics/Geraci
Author: Rpx
Author-email: cubyc.ro@gmail.com
License: MIT
Project-URL: Source, https://github.com/Rp-ics/Geraci
Project-URL: Tracker, https://github.com/Rp-ics/Geraci/issues
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: System :: Filesystems
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Intended Audience :: Developers
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: watchdog>=2.0.0
Requires-Dist: portalocker>=2.0.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: project-url
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# Geraci

A fast, easy and complete file and directory management library for Python.

```
pip install geraci
```

## Quick Start

```python
from geraci import File, Folder

# Read and write files
f = File("note.txt")
f.write("Hello, World!").append("\nSecond line")
print(f.read())

# Chain operations
f.copy("backup.txt").rename("backup_old.txt")

# File info with hash
info = File("note.txt").info()
print(info.size_human, info.hash_sha256)

# List and search
folder = Folder("my_project")
for py_file in folder.glob("**/*.py", exclude="test_*"):
    print(py_file)

# File locking
with File("data.json").lock():
    f.write('{"key": "value"}')

# Compress / extract
File("document.pdf").compress("docs.zip")
Folder("photos").compress("photos.tar.gz")
```

## Features

- **File operations**: read, write, append, copy, move, rename, delete
- **Folder operations**: create, delete, list, walk, size
- **Glob searching**: pattern matching with exclusions
- **File watching**: watchdog integration with callbacks
- **Sync/Backup**: incremental folder sync with hash comparison
- **Compression**: zip, tar, tar.gz, gz, bz2
- **Locking**: cross-platform file locking
- **Async support**: all operations available as async
- **Metadata**: file info, hash, size formatting
- **Logging**: configurable logging system
- **No dependencies** beyond watchdog and portalocker

## File Class

| Method | Description | Returns |
|---|---|---|
| `read()` | Read file content | `str` |
| `write(content)` | Write to file | `self` |
| `append(content)` | Append to file | `self` |
| `copy(dst)` | Copy file | `File` (new) |
| `move(dst)` | Move file | `self` |
| `rename(name)` | Rename file | `self` |
| `delete()` | Delete file | `None` |
| `compress(archive)` | Compress file | `self` |
| `lock()` | Lock file | `FileLock` (ctx) |
| `info()` | File metadata | `FileInfo` |
| `exists()` | Check existence | `bool` |
| `aread()` | Async read | `await str` |
| `awrite(content)` | Async write | `await self` |
| `acopy(dst)` | Async copy | `await File` |
| `amove(dst)` | Async move | `await self` |
| `adelete()` | Async delete | `await None` |

## Folder Class

| Method | Description | Returns |
|---|---|---|
| `create()` | Create directory | `self` |
| `delete(recursive)` | Delete directory | `None` |
| `list(recursive)` | List contents | `List[File | Folder]` |
| `walk()` | Walk recursively | `Iterator[File | Folder]` |
| `glob(pattern, exclude)` | Search files | `List[File]` |
| `sync(dst)` | Sync to destination | `self` |
| `watch(...)` | Watch for changes | `Observer` |
| `compress(archive)` | Compress folder | `self` |
| `size()` | Total size | `int` |
| `exists()` | Check existence | `bool` |

## Standalone Functions

```python
from geraci import read_file, write_file, copy_file, move_file
from geraci import glob_files, watch_folder, sync_folders
from geraci import compress_file, decompress
```

## Async

```python
from geraci import aread, awrite, acopy, amove, aglob

content = await aread("file.txt")
await awrite("file.txt", "new content")
files = await aglob("src", "**/*.py")
```

## Watchdog

```python
from geraci import watch_folder

def handler(event):
    print(f"{event.event_type}: {event.src_path}")

observer = watch_folder("input/", on_created=handler, on_modified=handler)
# observer.stop() to stop
```

Or use the FileWatcher class:

```python
from geraci import FileWatcher

watcher = FileWatcher("data/").start()
watcher.on_event(lambda e: print(e))
# watcher.stop()
```

## Logging

```python
from geraci import configure_logging

configure_logging(level="DEBUG", file="geraci.log")
```

## License

MIT
