cinchdb 0.1.15__py3-none-any.whl → 0.1.17__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,73 +0,0 @@
1
- """Maintenance mode utilities for CinchDB."""
2
-
3
- from pathlib import Path
4
- import json
5
- from typing import Dict, Any, Optional
6
-
7
- from cinchdb.core.path_utils import get_branch_path
8
-
9
-
10
- class MaintenanceError(Exception):
11
- """Exception raised when operation blocked by maintenance mode."""
12
-
13
- pass
14
-
15
-
16
- def is_branch_in_maintenance(project_root: Path, database: str, branch: str) -> bool:
17
- """Check if a branch is in maintenance mode.
18
-
19
- Args:
20
- project_root: Path to project root
21
- database: Database name
22
- branch: Branch name
23
-
24
- Returns:
25
- True if in maintenance mode, False otherwise
26
- """
27
- branch_path = get_branch_path(project_root, database, branch)
28
- maintenance_file = branch_path / ".maintenance_mode"
29
- return maintenance_file.exists()
30
-
31
-
32
- def get_maintenance_info(
33
- project_root: Path, database: str, branch: str
34
- ) -> Optional[Dict[str, Any]]:
35
- """Get maintenance mode information if active.
36
-
37
- Args:
38
- project_root: Path to project root
39
- database: Database name
40
- branch: Branch name
41
-
42
- Returns:
43
- Maintenance info dict or None if not in maintenance
44
- """
45
- branch_path = get_branch_path(project_root, database, branch)
46
- maintenance_file = branch_path / ".maintenance_mode"
47
-
48
- if maintenance_file.exists():
49
- with open(maintenance_file, "r") as f:
50
- return json.load(f)
51
-
52
- return None
53
-
54
-
55
- def check_maintenance_mode(project_root: Path, database: str, branch: str) -> None:
56
- """Check maintenance mode and raise error if active.
57
-
58
- Args:
59
- project_root: Path to project root
60
- database: Database name
61
- branch: Branch name
62
-
63
- Raises:
64
- MaintenanceError: If branch is in maintenance mode
65
- """
66
- if is_branch_in_maintenance(project_root, database, branch):
67
- info = get_maintenance_info(project_root, database, branch)
68
- reason = (
69
- info.get("reason", "Maintenance in progress")
70
- if info
71
- else "Maintenance in progress"
72
- )
73
- raise MaintenanceError(f"Branch '{branch}' is in maintenance mode: {reason}")