MCPcopy Index your code
hub / github.com/github/spec-kit / get_project_config

Method get_project_config

src/specify_cli/extensions/__init__.py:2933–2980  ·  view source on GitHub ↗

Load project-level extension configuration. Returns: Extension configuration dictionary

(self)

Source from the content-addressed store, hash-verified

2931 return f"/{command_id}"
2932
2933 def get_project_config(self) -> Dict[str, Any]:
2934 """Load project-level extension configuration.
2935
2936 Returns:
2937 Extension configuration dictionary
2938 """
2939 if not self.config_file.exists():
2940 return {
2941 "installed": [],
2942 "settings": {"auto_execute_hooks": True},
2943 "hooks": {},
2944 }
2945
2946 try:
2947 result = yaml.safe_load(self.config_file.read_text(encoding="utf-8"))
2948 # Coerce non-dict root (including None for an empty file) to the
2949 # fully-normalized default so callers always get guaranteed fields.
2950 if not isinstance(result, dict):
2951 return {
2952 "installed": [],
2953 "settings": {"auto_execute_hooks": True},
2954 "hooks": {},
2955 }
2956 # Normalize nested fields so read-only callers like get_hooks_for_event()
2957 # never see non-dict hooks or non-list installed (Feedback)
2958 if not isinstance(result.get("hooks"), dict):
2959 result["hooks"] = {}
2960 if not isinstance(result.get("installed"), list):
2961 result["installed"] = []
2962 if not isinstance(result.get("settings"), dict):
2963 result["settings"] = {"auto_execute_hooks": True}
2964 # Sanitize hook event values: coerce non-list values to [] and filter
2965 # non-dict items so get_hooks_for_event() can safely call .get() (Feedback)
2966 for event_key in list(result["hooks"]):
2967 event_val = result["hooks"][event_key]
2968 if not isinstance(event_val, list):
2969 result["hooks"][event_key] = []
2970 else:
2971 result["hooks"][event_key] = [
2972 h for h in event_val if isinstance(h, dict)
2973 ]
2974 return result
2975 except (yaml.YAMLError, OSError, UnicodeError):
2976 return {
2977 "installed": [],
2978 "settings": {"auto_execute_hooks": True},
2979 "hooks": {},
2980 }
2981
2982 def save_project_config(self, config: Dict[str, Any]):
2983 """Save project-level extension configuration.

Callers 15

register_extensionMethod · 0.95
unregister_extensionMethod · 0.95
register_hooksMethod · 0.95
unregister_hooksMethod · 0.95
get_hooks_for_eventMethod · 0.95
enable_hooksMethod · 0.95
disable_hooksMethod · 0.95
extension_updateFunction · 0.95
extension_enableFunction · 0.95
extension_disableFunction · 0.95

Calls 2

read_textMethod · 0.80
getMethod · 0.45