MCPcopy Create free account
hub / github.com/AutoForgeAI/autoforge / _load_config

Function _load_config

server/services/project_config.py:109–142  ·  view source on GitHub ↗

Load the project configuration from disk. Args: project_dir: Path to the project directory. Returns: Configuration dictionary, or empty dict if file doesn't exist or is invalid.

(project_dir: Path)

Source from the content-addressed store, hash-verified

107
108
109def _load_config(project_dir: Path) -> dict:
110 """
111 Load the project configuration from disk.
112
113 Args:
114 project_dir: Path to the project directory.
115
116 Returns:
117 Configuration dictionary, or empty dict if file doesn't exist or is invalid.
118 """
119 config_path = _get_config_path(project_dir)
120
121 if not config_path.exists():
122 return {}
123
124 try:
125 with open(config_path, "r", encoding="utf-8") as f:
126 config = json.load(f)
127
128 if not isinstance(config, dict):
129 logger.warning(
130 "Invalid config format in %s: expected dict, got %s",
131 config_path, type(config).__name__
132 )
133 return {}
134
135 return config
136
137 except json.JSONDecodeError as e:
138 logger.warning("Failed to parse config at %s: %s", config_path, e)
139 return {}
140 except OSError as e:
141 logger.warning("Failed to read config at %s: %s", config_path, e)
142 return {}
143
144
145def _save_config(project_dir: Path, config: dict) -> None:

Callers 4

get_dev_commandFunction · 0.85
set_dev_commandFunction · 0.85
clear_dev_commandFunction · 0.85
get_project_configFunction · 0.85

Calls 1

_get_config_pathFunction · 0.85

Tested by

no test coverage detected