- Created `.gitignore` files for various directories to exclude unnecessary files. - Added `PLAN.md` to outline the project goals and architecture documentation generation. - Implemented the `archdoc-cli` with a command-line interface for initializing and generating documentation. - Developed the `archdoc-core` library for analyzing Python projects and generating architecture documentation. - Included caching mechanisms to optimize repeated analysis. - Established a comprehensive test suite to ensure functionality and error handling. - Updated `README.md` to provide an overview and installation instructions for ArchDoc.
26 lines
767 B
Python
26 lines
767 B
Python
"""Utility functions for the test project."""
|
|
|
|
import json
|
|
import os
|
|
|
|
def load_config(config_path: str) -> dict:
|
|
"""Load configuration from a JSON file."""
|
|
with open(config_path, 'r') as f:
|
|
return json.load(f)
|
|
|
|
def save_config(config: dict, config_path: str):
|
|
"""Save configuration to a JSON file."""
|
|
with open(config_path, 'w') as f:
|
|
json.dump(config, f, indent=2)
|
|
|
|
def get_file_size(filepath: str) -> int:
|
|
"""Get the size of a file in bytes."""
|
|
return os.path.getsize(filepath)
|
|
|
|
def format_bytes(size: int) -> str:
|
|
"""Format bytes into a human-readable string."""
|
|
for unit in ['B', 'KB', 'MB', 'GB']:
|
|
if size < 1024.0:
|
|
return f"{size:.1f} {unit}"
|
|
size /= 1024.0
|
|
return f"{size:.1f} TB" |