Skip to content

Commit

Permalink
Version 0.7.0-dev.4 - WIP Commit
Browse files Browse the repository at this point in the history
- Moving computers again
  • Loading branch information
CCP-Zeulix committed Apr 11, 2024
1 parent 975fe4d commit 65011e0
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fidelius/gateway/file/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from ._filerepo import *
from ._fileadmin import *
Empty file.
36 changes: 36 additions & 0 deletions fidelius/gateway/file/_filerepo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
__all__ = [
'MockFideliusRepo',
]

from fidelius.structs import *
from fidelius.gateway._abstract import *

import json

import logging
log = logging.getLogger(__name__)


class MockFideliusRepo(_BaseFideliusRepo):
def __init__(self, app_props: FideliusAppProps, pre_seeded_cache: Optional[Union[dict, str]] = None, **kwargs):
super().__init__(app_props, **kwargs)
self._cache: Dict[str, str] = {}
self._loaded: bool = False

self._pre_seeded_cache = pre_seeded_cache

def get_app_param(self, name: str, env: Optional[str] = None) -> Optional[str]:
self._load_all()
return self._cache.get(self.get_full_path(name, env=env), None)

def get_shared_param(self, name: str, folder: str, env: Optional[str] = None) -> Optional[str]:
self._load_all()
return self._cache.get(self.get_full_path(name, folder=folder, env=env), None)

def _load_all(self):
if not self._loaded:
if isinstance(self._pre_seeded_cache, dict):
self._cache = self._pre_seeded_cache
elif isinstance(self._pre_seeded_cache, str) and self._pre_seeded_cache.lower().endswith('.json'):
with open(self._pre_seeded_cache, 'r') as fin:
self._cache = json.load(fin)

0 comments on commit 65011e0

Please sign in to comment.