cfg: Move /plinth.config to plinth/develop.config

- Avoid a top level source code file.

- Makes it clear that the configuration file is only meant for development
purposes.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2020-06-23 22:21:22 -07:00 committed by James Valleroy
parent 62fc33e12c
commit 50ef5861d0
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
3 changed files with 11 additions and 7 deletions

View File

@ -53,9 +53,8 @@ config_files = []
def get_develop_config_path():
"""Return config path of current source folder for development mode."""
root_directory = os.path.dirname(os.path.realpath(__file__))
root_directory = os.path.join(root_directory, '..')
root_directory = os.path.realpath(root_directory)
config_path = os.path.join(root_directory, 'plinth.config')
config_path = os.path.join(root_directory, 'develop.config')
return config_path
@ -79,9 +78,13 @@ def read_file(config_path):
# Keep a note of configuration files read.
config_files.append(config_path)
parser = configparser.ConfigParser(defaults={
'parent_dir': pathlib.Path(config_path).parent.resolve(),
})
parser = configparser.ConfigParser(
defaults={
'parent_dir':
pathlib.Path(config_path).parent.resolve(),
'parent_parent_dir':
pathlib.Path(config_path).parent.parent.resolve(),
})
parser.read(config_path)
config_items = (

View File

@ -1,6 +1,6 @@
[Path]
# directory locations
file_root = %(parent_dir)s
file_root = %(parent_parent_dir)s
config_dir = %(file_root)s/data/etc/plinth
data_dir = %(file_root)s/data/var/lib/plinth
server_dir = /plinth

View File

@ -54,7 +54,8 @@ def test_read_develop_config_file():
"""Verify that the correct develop config file is used."""
test_dir = os.path.dirname(os.path.realpath(__file__))
develop_root = os.path.realpath(os.path.join(test_dir, '..', '..'))
develop_config_file = os.path.join(develop_root, 'plinth.config')
develop_config_file = os.path.join(develop_root, 'plinth',
'develop.config')
config_path = cfg.get_develop_config_path()
cfg.read_file(config_path)
assert cfg.config_files[-1] == develop_config_file