1
0
mirror of https://github.com/openSUSE/osc.git synced 2026-01-31 01:49:00 +01:00
Files
github.com_openSUSE_osc/osc/git_scm/configuration.py
2025-09-23 13:06:46 +02:00

32 lines
789 B
Python

from typing import Optional
class Configuration:
"""
A wrapper to configuration.yaml file that lives in obs/configuration, in the main branch.
"""
@classmethod
def from_file(cls, path: str) -> "Configuration":
from ..util import yaml as osc_yaml
with open(path, "r", encoding="utf-8") as f:
data = osc_yaml.yaml_load(f)
obj = cls(data)
return obj
@classmethod
def from_string(cls, text: str) -> "Configuration":
from ..util import yaml as osc_yaml
data = osc_yaml.yaml_loads(text)
obj = cls(data)
return obj
def __init__(self, data: dict):
self._data = data
@property
def obs_apiurl(self) -> Optional[str]:
return self._data.get("obs_apiurl", None)