From ef9fe5c0e2cceefdfc3434b609702669439343df Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Fri, 21 Feb 2020 07:08:00 -0800 Subject: [PATCH] Shadow lexicon title with fallback to name --- amanuensis/lexicon/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/amanuensis/lexicon/__init__.py b/amanuensis/lexicon/__init__.py index 7342c5e..ce46d2a 100644 --- a/amanuensis/lexicon/__init__.py +++ b/amanuensis/lexicon/__init__.py @@ -44,6 +44,8 @@ class LexiconModel(): def __getattr__(self, key): if key not in self.config: raise AttributeError(key) + if key == 'title': + return self.config.get('title') or f'Lexicon {self.config.name}' return self.config.get(key) def __str__(self): @@ -57,7 +59,7 @@ class LexiconModel(): def add_log(self, message): now = int(time.time()) - with json_rw(self.config_path) as j: + with self.edit() as j: j['log'].append([now, message]) def status(self):