From 2f179a2bf69a168cf2d6c282ee75f1dc55c5d40a Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Sat, 3 Jan 2026 16:54:12 +0100 Subject: [PATCH] feat: load tiramisu objects from cache --- src/rougail/__init__.py | 2 +- src/rougail/annotator/__init__.py | 2 +- src/rougail/annotator/family.py | 2 +- src/rougail/annotator/property.py | 2 +- src/rougail/annotator/value.py | 2 +- src/rougail/annotator/variable.py | 2 +- src/rougail/config/__init__.py | 2 +- src/rougail/convert/__init__.py | 17 +++++++++++++---- src/rougail/convert/convert.py | 10 +++++----- src/rougail/convert/object_model.py | 2 +- src/rougail/convert/path.py | 2 +- src/rougail/convert/tiramisureflector.py | 2 +- src/rougail/error.py | 2 +- src/rougail/i18n.py | 2 +- src/rougail/structural_commandline/__init__.py | 2 +- src/rougail/structural_commandline/annotator.py | 2 +- src/rougail/structural_commandline/config.py | 2 +- .../structural_commandline/object_model.py | 2 +- src/rougail/structural_directory/__init__.py | 2 +- src/rougail/structural_directory/config.py | 2 +- src/rougail/tiramisu.py | 2 +- src/rougail/types.py | 2 +- src/rougail/user_data.py | 2 +- src/rougail/utils.py | 2 +- 24 files changed, 40 insertions(+), 31 deletions(-) diff --git a/src/rougail/__init__.py b/src/rougail/__init__.py index c350ae236..bcf9c3a78 100644 --- a/src/rougail/__init__.py +++ b/src/rougail/__init__.py @@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com) Copyright (C) 2019-2021 Silique (https://www.silique.fr) -Copyright (C) 2022-2025 +Copyright (C) 2022-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the diff --git a/src/rougail/annotator/__init__.py b/src/rougail/annotator/__init__.py index dea854b03..f6106346d 100644 --- a/src/rougail/annotator/__init__.py +++ b/src/rougail/annotator/__init__.py @@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com) Copyright (C) 2019-2021 Silique (https://www.silique.fr) -Copyright (C) 2022-2025 +Copyright (C) 2022-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the diff --git a/src/rougail/annotator/family.py b/src/rougail/annotator/family.py index 46b77ed21..42e77bf9b 100644 --- a/src/rougail/annotator/family.py +++ b/src/rougail/annotator/family.py @@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com) Copyright (C) 2019-2021 Silique (https://www.silique.fr) -Copyright (C) 2022-2025 +Copyright (C) 2022-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the diff --git a/src/rougail/annotator/property.py b/src/rougail/annotator/property.py index c60ff2494..c161212a2 100644 --- a/src/rougail/annotator/property.py +++ b/src/rougail/annotator/property.py @@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com) Copyright (C) 2019-2021 Silique (https://www.silique.fr) -Copyright (C) 2022-2025 +Copyright (C) 2022-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the diff --git a/src/rougail/annotator/value.py b/src/rougail/annotator/value.py index 2c7f82443..dc048e492 100644 --- a/src/rougail/annotator/value.py +++ b/src/rougail/annotator/value.py @@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com) Copyright (C) 2019-2021 Silique (https://www.silique.fr) -Copyright (C) 2022-2025 +Copyright (C) 2022-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the diff --git a/src/rougail/annotator/variable.py b/src/rougail/annotator/variable.py index baf945760..dff87d4f3 100644 --- a/src/rougail/annotator/variable.py +++ b/src/rougail/annotator/variable.py @@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com) Copyright (C) 2019-2021 Silique (https://www.silique.fr) -Copyright (C) 2022-2025 +Copyright (C) 2022-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the diff --git a/src/rougail/config/__init__.py b/src/rougail/config/__init__.py index e4f69c1cb..48239096f 100644 --- a/src/rougail/config/__init__.py +++ b/src/rougail/config/__init__.py @@ -10,7 +10,7 @@ Cadoles (http://www.cadoles.com) Copyright (C) 2019-2021 Silique (https://www.silique.fr) -Copyright (C) 2022-2025 +Copyright (C) 2022-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the diff --git a/src/rougail/convert/__init__.py b/src/rougail/convert/__init__.py index 7728a7ec4..5f82d1564 100644 --- a/src/rougail/convert/__init__.py +++ b/src/rougail/convert/__init__.py @@ -1,5 +1,5 @@ """Silique (https://www.silique.fr) -Copyright (C) 2022-2025 +Copyright (C) 2022-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the @@ -15,6 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . """ +from pathlib import Path from typing import Optional from tiramisu import Config from warnings import warn @@ -31,17 +32,25 @@ class Rougail(UserData): def __init__( self, - rougailconfig=None, + rougailconfig: Optional[RougailConfig]=None, + load_from_tiramisu_cache: bool=False, ) -> None: if rougailconfig is None: rougailconfig = RougailConfig self.rougailconfig = rougailconfig + self.load_from_tiramisu_cache = load_from_tiramisu_cache and Path(self.rougailconfig["tiramisu_cache"]).is_file() types = rougail_type(self.rougailconfig) - self.converted = RougailConvert(self.rougailconfig, *types) + if not self.load_from_tiramisu_cache: + self.converted = RougailConvert(self.rougailconfig, *types) self.config = None def get_root_option(self): - tiram_obj = self.converted.save() + if not self.load_from_tiramisu_cache: + tiram_obj = self.converted.save() + else: + tiramisu_cache = self.rougailconfig["tiramisu_cache"] + with open(tiramisu_cache, "r", encoding="utf-8") as tiramisu: + tiram_obj = tiramisu.read() optiondescription = {} custom_types = { custom.__name__: custom diff --git a/src/rougail/convert/convert.py b/src/rougail/convert/convert.py index 41f94aafd..cde2eba16 100644 --- a/src/rougail/convert/convert.py +++ b/src/rougail/convert/convert.py @@ -10,7 +10,7 @@ Cadoles (http://www.cadoles.com) Copyright (C) 2019-2021 Silique (https://www.silique.fr) -Copyright (C) 2022-2025 +Copyright (C) 2022-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the @@ -1194,10 +1194,10 @@ class RougailConvert(ParserVariable): self.init() self.annotate() self.reflect() - output = self.reflector.get_text() + "\n" + tiram_obj = self.reflector.get_text() + "\n" filename = self.tiramisu_cache if filename: with open(filename, "w", encoding="utf-8") as tiramisu: - tiramisu.write(output) - # print(output) - return output + tiramisu.write(tiram_obj) + # print(tiram_obj) + return tiram_obj diff --git a/src/rougail/convert/object_model.py b/src/rougail/convert/object_model.py index 88488f2c5..41ba9c53f 100644 --- a/src/rougail/convert/object_model.py +++ b/src/rougail/convert/object_model.py @@ -1,7 +1,7 @@ """Rougail object model Silique (https://www.silique.fr) -Copyright (C) 2023-2025 +Copyright (C) 2023-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the diff --git a/src/rougail/convert/path.py b/src/rougail/convert/path.py index 4ea5581a3..98b35c23f 100644 --- a/src/rougail/convert/path.py +++ b/src/rougail/convert/path.py @@ -1,5 +1,5 @@ """ -Copyright (C) 2024-2025 +Copyright (C) 2024-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the diff --git a/src/rougail/convert/tiramisureflector.py b/src/rougail/convert/tiramisureflector.py index 0fe6e6935..5ff402e67 100644 --- a/src/rougail/convert/tiramisureflector.py +++ b/src/rougail/convert/tiramisureflector.py @@ -10,7 +10,7 @@ Cadoles (http://www.cadoles.com) Copyright (C) 2019-2021 Silique (https://www.silique.fr) -Copyright (C) 2022-2025 +Copyright (C) 2022-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the diff --git a/src/rougail/error.py b/src/rougail/error.py index 10074fc72..ac0de0dfa 100644 --- a/src/rougail/error.py +++ b/src/rougail/error.py @@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com) Copyright (C) 2019-2021 Silique (https://www.silique.fr) -Copyright (C) 2022-2025 +Copyright (C) 2022-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the diff --git a/src/rougail/i18n.py b/src/rougail/i18n.py index 566e5626e..803b8c765 100644 --- a/src/rougail/i18n.py +++ b/src/rougail/i18n.py @@ -8,7 +8,7 @@ Cadoles (http://www.cadoles.com) Copyright (C) 2019-2021 Silique (https://www.silique.fr) -Copyright (C) 2022-2025 +Copyright (C) 2022-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the diff --git a/src/rougail/structural_commandline/__init__.py b/src/rougail/structural_commandline/__init__.py index 1d78ef63a..dc03b228d 100644 --- a/src/rougail/structural_commandline/__init__.py +++ b/src/rougail/structural_commandline/__init__.py @@ -1,6 +1,6 @@ """ Silique (https://www.silique.fr) -Copyright (C) 2024-2025 +Copyright (C) 2024-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the diff --git a/src/rougail/structural_commandline/annotator.py b/src/rougail/structural_commandline/annotator.py index 7a6b7b00c..0bd3f2778 100644 --- a/src/rougail/structural_commandline/annotator.py +++ b/src/rougail/structural_commandline/annotator.py @@ -1,7 +1,7 @@ """Annotate to add specify attribute for tiramisu-cmdline Silique (https://www.silique.fr) -Copyright (C) 2024-2025 +Copyright (C) 2024-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the diff --git a/src/rougail/structural_commandline/config.py b/src/rougail/structural_commandline/config.py index 263ba7b3c..1bffea9d2 100644 --- a/src/rougail/structural_commandline/config.py +++ b/src/rougail/structural_commandline/config.py @@ -2,7 +2,7 @@ Config file for Rougail-structural_commandline Silique (https://www.silique.fr) -Copyright (C) 2024-2025 +Copyright (C) 2024-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the diff --git a/src/rougail/structural_commandline/object_model.py b/src/rougail/structural_commandline/object_model.py index c17462a2b..315bc6093 100644 --- a/src/rougail/structural_commandline/object_model.py +++ b/src/rougail/structural_commandline/object_model.py @@ -1,7 +1,7 @@ """Annotate to add specify attribute for tiramisu-cmdline Silique (https://www.silique.fr) -Copyright (C) 2024-2025 +Copyright (C) 2024-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the diff --git a/src/rougail/structural_directory/__init__.py b/src/rougail/structural_directory/__init__.py index b67ae0760..02b36a966 100644 --- a/src/rougail/structural_directory/__init__.py +++ b/src/rougail/structural_directory/__init__.py @@ -1,6 +1,6 @@ """ Silique (https://www.silique.fr) -Copyright (C) 2022-2025 +Copyright (C) 2022-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the diff --git a/src/rougail/structural_directory/config.py b/src/rougail/structural_directory/config.py index d7f3a53b7..6ded48823 100644 --- a/src/rougail/structural_directory/config.py +++ b/src/rougail/structural_directory/config.py @@ -1,6 +1,6 @@ """ Silique (https://www.silique.fr) -Copyright (C) 2024-2025 +Copyright (C) 2024-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the diff --git a/src/rougail/tiramisu.py b/src/rougail/tiramisu.py index eac47b36c..5b742e146 100644 --- a/src/rougail/tiramisu.py +++ b/src/rougail/tiramisu.py @@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com) Copyright (C) 2019-2021 Silique (https://www.silique.fr) -Copyright (C) 2022-2025 +Copyright (C) 2022-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the diff --git a/src/rougail/types.py b/src/rougail/types.py index 6acacb291..bff6f80b2 100644 --- a/src/rougail/types.py +++ b/src/rougail/types.py @@ -1,6 +1,6 @@ """ Silique (https://www.silique.fr) -Copyright (C) 2025 +Copyright (C) 2025-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the diff --git a/src/rougail/user_data.py b/src/rougail/user_data.py index 561d38355..7f3d9a06e 100644 --- a/src/rougail/user_data.py +++ b/src/rougail/user_data.py @@ -1,6 +1,6 @@ """ Silique (https://www.silique.fr) -Copyright (C) 2022-2025 +Copyright (C) 2022-2026 distribued with GPL-2 or later license diff --git a/src/rougail/utils.py b/src/rougail/utils.py index 62bce6bcb..334e7b5df 100644 --- a/src/rougail/utils.py +++ b/src/rougail/utils.py @@ -9,7 +9,7 @@ Cadoles (http://www.cadoles.com) Copyright (C) 2019-2021 Silique (https://www.silique.fr) -Copyright (C) 2022-2025 +Copyright (C) 2022-2026 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the