FileAutomation

Automation-first Python library for local file / directory / zip operations, HTTP downloads, and remote storage (Google Drive, S3, Azure Blob, Dropbox, SFTP). Actions are defined as JSON and dispatched through a central registry so they can be executed in-process, from disk, over a TCP socket, or over HTTP.

Architecture

Layered architecture with Facade + Registry + Command + Strategy patterns:

automation_file/
├── __init__.py          # Public API facade (__all__); launch_ui is loaded lazily via __getattr__
├── __main__.py          # CLI entry: subcommands plus the legacy -e/-d/-c/--execute_str flags
├── exceptions.py        # FileAutomationException hierarchy
├── logging_config.py    # file_automation_logger (file + stderr handlers)
├── core/                # Engine: action_registry (ActionRegistry, build_default_registry), action_executor
│                        # (shared `executor`), callback_executor, package_loader, plugins, dag_executor,
│                        # action_queue, json_store, substitution; cross-cutting helpers: retry, quota,
│                        # rate_limit, circuit_breaker, file_lock, sqlite_lock, checksum, manifest, crypto,
│                        # secrets, config, config_watcher, audit, metrics, tracing, progress, fim, content_store
├── local/               # Strategy modules: file/dir/zip/tar/archive ops, sync, diff, text/JSON/data edits,
│                        # templates, versioning, trash, shell_ops (argv-only subprocess), conditional;
│                        # safe_paths.py guards against path traversal
├── remote/              # url_validator (SSRF guard), http_download, cross_backend, fsspec_bridge, and one
│                        # subpackage per backend: google_drive, s3, azure_blob, dropbox_api, sftp, ftp,
│                        # onedrive, box (client.py + *_ops.py + register_<backend>_ops); smb and webdav
│                        # have a client only
├── server/              # tcp_server, http_server, mcp_server (MCP over stdio), web_ui, metrics_server,
│                        # action_acl (ActionACL), network_guards (ensure_loopback)
├── client/              # HTTPActionClient for the HTTP action server
├── trigger/, scheduler/, notify/   # watchdog file triggers, cron scheduler, notification sinks;
│                                   # each registers its own FA_* ops
├── project/             # ProjectBuilder, create_project_dir
├── ui/                  # PySide6 GUI: launcher.launch_ui, main_window.MainWindow, worker.ActionWorker,
│                        # log_widget.LogPanel, tabs/ (home, local, http, JSON editor, servers, scheduler,
│                        # trigger, progress; the cloud backends are panels grouped under transfer_tab)
└── utils/               # file discovery, fast find, grep, duplicate finder, backup rotation

architecture.md §2 carries the same map with one row per directory; keep the two in step.

Key design patterns in use:

Key types

Branching & CI

Development

python -m pip install -r dev_requirements.txt pytest pytest-cov
python -m pip install -e ".[dev]"       # ruff, mypy, pre-commit
python -m pytest tests/ -v --tb=short
ruff check automation_file/ tests/
ruff format --check automation_file/ tests/
mypy automation_file/
python -m automation_file --help

Testing:

Conventions

Security

All code must follow secure-by-default principles. Review every change against the checklist below.

General rules

Network requests (SSRF prevention)

Network requests (TLS)

Subprocess execution

TCP server

HTTP server

Path traversal

SFTP host verification

Reliability (retry / quota)

Google Drive

File I/O

Plugin / package loading

Secrets and credentials

Dependency security

Code quality (SonarQube / Codacy compliance)

All code must satisfy common static-analysis rules. Review every change against the checklist below.

Complexity & size

Exception handling

Pythonic correctness

Naming & style (PEP 8)

Duplication & dead code

Logging, printing, assertions

Hardcoded values & secrets

Boolean & return hygiene

Imports

Running the linter

Documentation

Stage commits, progress.md, docs/updates/ and architecture.md

Workspace rule shared by every repository under D:\Codes (full text: D:\Codes\CLAUDE.md).

Commit & PR rules