forked from openapi-generators/openapi-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
28 lines (21 loc) · 811 Bytes
/
config.py
File metadata and controls
28 lines (21 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from pathlib import Path
from typing import Dict, Optional
import yaml
from pydantic import BaseModel
class ClassOverride(BaseModel):
class_name: Optional[str] = None
module_name: Optional[str] = None
class Config(BaseModel):
class_overrides: Dict[str, ClassOverride] = {}
project_name_override: Optional[str]
package_name_override: Optional[str]
package_version_override: Optional[str]
field_prefix: str = "field_"
@staticmethod
def load_from_path(path: Path) -> "Config":
""" Creates a Config from provided JSON or YAML file and sets a bunch of globals from it """
from . import utils
config_data = yaml.safe_load(path.read_text())
config = Config(**config_data)
utils.FIELD_PREFIX = config.field_prefix
return config