-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Draft of a more organized object modelling
[noissue]
- Loading branch information
Showing
120 changed files
with
187 additions
and
8,074 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
from __future__ import annotations | ||
|
||
import tempfile | ||
from dataclasses import dataclass, field | ||
from enum import Enum | ||
from pathlib import Path | ||
from typing import Optional | ||
|
||
from dynaconf import Dynaconf, Validator | ||
|
||
|
||
def init_config(setting_file: Optional[Path] = None) -> ConfigSchema: | ||
setting_files = [setting_file] if setting_file else [] | ||
return Dynaconf(settings_file=setting_files) | ||
|
||
|
||
class FindStrategy(Enum): | ||
""" | ||
Strategies on how to choose local repos, which should be used to override the defaults. | ||
Args: | ||
NONE: Don't use any local overrides. | ||
CURRENT: If the CWD is a matching repo, use that. | ||
PARENT_WORKDIR: Lookup for matching repos in the parent workdir. | ||
LOOKUP_LIST: Use an explicit lookup_list defining the path for each repo override. | ||
""" | ||
|
||
NONE = 0 | ||
CURRENT = 1 | ||
PARENT_WORKDIR = 2 | ||
LOOKUP_LIST = 3 | ||
|
||
|
||
@dataclass | ||
class ConfigSchema: | ||
remote_sync_config: RemoteSyncConfig | ||
repo_finder_config: RepoFinderConfig | ||
cli_config: CliConfig | ||
|
||
class Meta: | ||
validators: list[Validator] = [] | ||
|
||
|
||
@dataclass | ||
class RemoteSyncConfig: | ||
""" | ||
Args: | ||
sync: Wheter or not to sync (clone and rebase) changes to a managed repo. | ||
manged_repo_path: The local path to where the managed repo should operate. | ||
""" | ||
|
||
sync: bool = True | ||
managed_repo_path: Path = Path(tempfile.gettempdir()) | ||
|
||
|
||
@dataclass | ||
class RepoFinderConfig: | ||
strategy: FindStrategy = FindStrategy.CURRENT | ||
lookup_list: list[Path] = field(default_factory=list) | ||
|
||
|
||
@dataclass | ||
class CliConfig: | ||
livereload: bool = True | ||
watch_list: list[Path] = field(default_factory=list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1 @@ | ||
ADMIN_NAME = "admin" | ||
USER_NAME = "user" | ||
RESTAPI_URL_TEMPLATE = "https://docs.pulpproject.org/{}/restapi.html" | ||
|
||
DISPLAY_NAMES = { | ||
"guides": "How-to Guides", | ||
"learn": "Learn More", | ||
"tutorials": "Tutorials", | ||
"reference": "Reference", | ||
} | ||
GUIDES = DISPLAY_NAMES["guides"] | ||
LEARN = DISPLAY_NAMES["learn"] | ||
TUTORIALS = DISPLAY_NAMES["tutorials"] | ||
|
||
|
||
class Names: | ||
"""Display Names""" | ||
|
||
# content types | ||
GUIDES = "How-to Guides" | ||
LEARN = "Learn More" | ||
TUTORIALS = "Tutorials" | ||
REFERENCE = "Reference" | ||
|
||
# repo-types | ||
OTHER = "Extra" | ||
CORE = "Pulpcore" | ||
CONTENT = "Plugins" | ||
|
||
# personas | ||
USER = "User" | ||
ADMIN = "Admin" | ||
DEV = "Dev" | ||
|
||
# other | ||
PULPCORE_TUTORIAL = "Getting Started" | ||
|
||
@staticmethod | ||
def get(name: str): | ||
return getattr(Names, name.upper()) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.