summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2018-08-24 15:57:43 +0300
committerSergey Poznyakoff <gray@gnu.org>2018-08-24 15:57:43 +0300
commit509047fcdaa8afb11074c355c7ab7c4f6d6fac7f (patch)
treebdeb01c4ae69607e9574cf79da474ae628ec1929
parent0e03e260c7ae4cc598f1185be59e02c42fc72eca (diff)
downloadwikitrans-509047fcdaa8afb11074c355c7ab7c4f6d6fac7f.tar.gz
wikitrans-509047fcdaa8afb11074c355c7ab7c4f6d6fac7f.tar.bz2
Make sure subclasses can't alter the initial settings of token_class
-rw-r--r--wikitrans/wikimarkup.py48
1 files changed, 25 insertions, 23 deletions
diff --git a/wikitrans/wikimarkup.py b/wikitrans/wikimarkup.py
index d199335..0ce0e15 100644
--- a/wikitrans/wikimarkup.py
+++ b/wikitrans/wikimarkup.py
@@ -187,27 +187,6 @@ class WikiMarkupParser(object):
inline_delims = [ "''", "'''", "[", "]", "[[", "]]", "{{", "}}", "|" ]
- token_class = {
- 'NIL': WikiNode,
- 'NL': WikiNode,
- 'OTAG': WikiTagNode,
- 'CTAG': WikiTagNode,
- 'TAG': WikiTagNode,
- 'DELIM': WikiDelimNode,
- 'TEXT': WikiTextNode,
- 'PRE': WikiContentNode,
- 'PARA': WikiSeqNode,
- 'BAR': WikiNode,
- 'SEQ': WikiSeqNode,
- 'IND': WikiIndNode,
- 'REF': WikiRefNode,
- 'TMPL': WikiSeqNode,
- 'IT': WikiSeqNode,
- 'BOLD': WikiSeqNode,
- 'ELT': WikiEltNode,
- 'ENV': WikiEnvNode,
- 'LINK': WikiSeqNode,
- 'HDR': WikiHdrNode
- }
-
+ token_class = {}
+
def _new_node(self, **kwarg):
return self.token_class[kwarg['type']](self, **kwarg)
@@ -993,4 +972,27 @@ class WikiMarkup(WikiMarkupParser):
'http://www.mediawiki.org/xml/export-0.3'
"""
+ self.token_class = {
+ 'NIL': WikiNode,
+ 'NL': WikiNode,
+ 'OTAG': WikiTagNode,
+ 'CTAG': WikiTagNode,
+ 'TAG': WikiTagNode,
+ 'DELIM': WikiDelimNode,
+ 'TEXT': WikiTextNode,
+ 'PRE': WikiContentNode,
+ 'PARA': WikiSeqNode,
+ 'BAR': WikiNode,
+ 'SEQ': WikiSeqNode,
+ 'IND': WikiIndNode,
+ 'REF': WikiRefNode,
+ 'TMPL': WikiSeqNode,
+ 'IT': WikiSeqNode,
+ 'BOLD': WikiSeqNode,
+ 'ELT': WikiEltNode,
+ 'ENV': WikiEnvNode,
+ 'LINK': WikiSeqNode,
+ 'HDR': WikiHdrNode
+ }
+
for kw in keywords:
if kw == 'file':

Return to:

Send suggestions and report system problems to the System administrator.