diff sat/plugins/plugin_misc_text_syntaxes.py @ 3715:b9718216a1c0 0.9

merge bookmark 0.9
author Goffi <goffi@goffi.org>
date Wed, 01 Dec 2021 16:13:31 +0100
parents 09f5ac48ffe3
children 33d75cd3c371
line wrap: on
line diff
--- a/sat/plugins/plugin_misc_text_syntaxes.py	Tue Nov 30 23:31:09 2021 +0100
+++ b/sat/plugins/plugin_misc_text_syntaxes.py	Wed Dec 01 16:13:31 2021 +0100
@@ -166,33 +166,35 @@
     SYNTAX_XHTML = _SYNTAX_XHTML
     SYNTAX_MARKDOWN = "markdown"
     SYNTAX_TEXT = "text"
-    syntaxes = {}
     # default_syntax must be lower case
     default_syntax = SYNTAX_XHTML
 
-    params = """
-    <params>
-    <individual>
-    <category name="%(category_name)s" label="%(category_label)s">
-        <param name="%(name)s" label="%(label)s" type="list" security="0">
-            %(options)s
-        </param>
-    </category>
-    </individual>
-    </params>
-    """
-
-    params_data = {
-        "category_name": CATEGORY,
-        "category_label": _(CATEGORY),
-        "name": NAME,
-        "label": _(NAME),
-        "syntaxes": syntaxes,
-    }
 
     def __init__(self, host):
         log.info(_("Text syntaxes plugin initialization"))
         self.host = host
+        self.syntaxes = {}
+
+        self.params = """
+            <params>
+            <individual>
+            <category name="%(category_name)s" label="%(category_label)s">
+                <param name="%(name)s" label="%(label)s" type="list" security="0">
+                    %(options)s
+                </param>
+            </category>
+            </individual>
+            </params>
+        """
+
+        self.params_data = {
+            "category_name": CATEGORY,
+            "category_label": _(CATEGORY),
+            "name": NAME,
+            "label": _(NAME),
+            "syntaxes": self.syntaxes,
+        }
+
         self.addSyntax(
             self.SYNTAX_XHTML,
             lambda xhtml: defer.succeed(xhtml),
@@ -264,7 +266,7 @@
             xml_tools.cleanXHTML = self.cleanXHTML
 
     def _updateParamOptions(self):
-        data_synt = TextSyntaxes.syntaxes
+        data_synt = self.syntaxes
         default_synt = TextSyntaxes.default_syntax
         syntaxes = []
 
@@ -280,8 +282,8 @@
             selected = 'selected="true"' if syntax == default_synt else ""
             options.append('<option value="%s" %s/>' % (syntax, selected))
 
-        TextSyntaxes.params_data["options"] = "\n".join(options)
-        self.host.memory.updateParams(TextSyntaxes.params % TextSyntaxes.params_data)
+        self.params_data["options"] = "\n".join(options)
+        self.host.memory.updateParams(self.params % self.params_data)
 
     def getCurrentSyntax(self, profile):
         """ Return the selected syntax for the given profile
@@ -393,7 +395,7 @@
             syntax_to = self.getCurrentSyntax(profile)
         else:
             syntax_to = syntax_to.lower().strip()
-        syntaxes = TextSyntaxes.syntaxes
+        syntaxes = self.syntaxes
         if syntax_from not in syntaxes:
             raise exceptions.NotFound(syntax_from)
         if syntax_to not in syntaxes:
@@ -438,7 +440,7 @@
                 )
             )
 
-        syntaxes = TextSyntaxes.syntaxes
+        syntaxes = self.syntaxes
         key = name.lower().strip()
         if key in syntaxes:
             raise exceptions.ConflictError(