Пример #1
0
in which the server starts. The archive settings are the composition
of a set of default settings (hard-coded in this module) and settings
(optionally) specified in the file "Archive Settings.yaml" in the
archive directory.
"""

from pathlib import Path
import os
import sys

from vesper.util.settings import Settings
from vesper.util.settings_type import SettingsType
import vesper.archive_paths as archive_paths

_DEFAULT_SETTINGS = Settings.create_from_yaml('''
database:
    engine: SQLite
''')

_SETTINGS_TYPE = SettingsType('Archive Settings', _DEFAULT_SETTINGS)

_SETTINGS_FILE_NAME = 'Archive Settings.yaml'


def _create_settings():
    archive_dir_path = Path(os.getcwd())
    settings = _load_settings_file(archive_dir_path)
    archive_paths.initialize(archive_dir_path, settings)
    return settings


def _load_settings_file(archive_dir_path):
Пример #2
0
from pathlib import Path
import os
import sys

from vesper.util.settings import Settings
from vesper.util.settings_type import SettingsType
import vesper.archive_paths as archive_paths


# TODO: Provide an upgrade path from SQLite for PostgreSQL, then deprecate
# SQLite, and then eliminate the `database.engine` setting.


_DEFAULT_SETTINGS = Settings.create_from_yaml('''
database:
    engine: SQLite
''')


_SETTINGS_TYPE = SettingsType('Archive Settings', _DEFAULT_SETTINGS)


_SETTINGS_FILE_NAME = 'Archive Settings.yaml'


def _create_settings():
    archive_dir_path = Path(os.getcwd())
    settings = _load_settings_file(archive_dir_path)
    archive_paths.initialize(archive_dir_path, settings)
    return settings
Пример #3
0
 def create_settings_from_yaml(self, s):
     settings = Settings.create_from_yaml(s)
     return Settings(self.defaults, settings)
Пример #4
0
 def test_create_from_yaml(self):
     contents = os_utils.read_file(_SETTINGS_FILE_PATH)
     settings = Settings.create_from_yaml(contents)
     self._check_settings(settings)
Пример #5
0
 def test_create_from_commented_out_yaml(self):
     settings = Settings.create_from_yaml('#')
     self._check_empty_settings(settings)
Пример #6
0
 def test_create_from_empty_yaml(self):
     settings = Settings.create_from_yaml('')
     self._check_empty_settings(settings)