From 2bdf86a37dbd8a6295fbeb79fa17c7ab5541831c Mon Sep 17 00:00:00 2001 From: Youen Date: Thu, 18 May 2023 18:05:56 +0200 Subject: [PATCH] Added possibility to configure a document with file settings.json (no UI yet) --- src/data/document.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/data/document.py b/src/data/document.py index 2acf61b..c105ada 100644 --- a/src/data/document.py +++ b/src/data/document.py @@ -8,6 +8,7 @@ from unicodedata import normalize from urllib.parse import quote as url_encode from urllib.parse import unquote as url_decode import string +import json def os_path_separators(): seps = ['/','\\'] @@ -53,11 +54,20 @@ class Document: self.doc_path = doc_path self.valid = True - # TODO: actually read document settings + # Init default values self.settings = { 'multiversion': False, - 'default_version': 'main' + 'default_version': '' } + + # Read settings.json (if it exists) + json_settings_filename = self.doc_path + '/settings.json' + if os.path.exists(json_settings_filename): + with open(json_settings_filename) as f: + json_settings = json.load(f) + for key in self.settings: + if key in json_settings: + self.settings[key] = json_settings[key] def build(self): multiversion_build = self.settings['multiversion']