summaryrefslogtreecommitdiff
path: root/wikitrans/wikimarkup.py
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 /wikitrans/wikimarkup.py
parent0e03e260c7ae4cc598f1185be59e02c42fc72eca (diff)
downloadwikitrans-509047fcdaa8afb11074c355c7ab7c4f6d6fac7f.tar.gz
wikitrans-509047fcdaa8afb11074c355c7ab7c4f6d6fac7f.tar.bz2
Make sure subclasses can't alter the initial settings of token_class
Diffstat (limited to 'wikitrans/wikimarkup.py')
-rw-r--r--wikitrans/wikimarkup.py46
1 files changed, 24 insertions, 22 deletions
diff --git a/wikitrans/wikimarkup.py b/wikitrans/wikimarkup.py
index d199335..0ce0e15 100644
--- a/wikitrans/wikimarkup.py
+++ b/wikitrans/wikimarkup.py
@@ -186,28 +186,7 @@ class WikiMarkupParser(object):
186 186
187 inline_delims = [ "''", "'''", "[", "]", "[[", "]]", "{{", "}}", "|" ] 187 inline_delims = [ "''", "'''", "[", "]", "[[", "]]", "{{", "}}", "|" ]
188 188
189 token_class = { 189 token_class = {}
190 'NIL': WikiNode,
191 'NL': WikiNode,
192 'OTAG': WikiTagNode,
193 'CTAG': WikiTagNode,
194 'TAG': WikiTagNode,
195 'DELIM': WikiDelimNode,
196 'TEXT': WikiTextNode,
197 'PRE': WikiContentNode,
198 'PARA': WikiSeqNode,
199 'BAR': WikiNode,
200 'SEQ': WikiSeqNode,
201 'IND': WikiIndNode,
202 'REF': WikiRefNode,
203 'TMPL': WikiSeqNode,
204 'IT': WikiSeqNode,
205 'BOLD': WikiSeqNode,
206 'ELT': WikiEltNode,
207 'ENV': WikiEnvNode,
208 'LINK': WikiSeqNode,
209 'HDR': WikiHdrNode
210 }
211 190
212 def _new_node(self, **kwarg): 191 def _new_node(self, **kwarg):
213 return self.token_class[kwarg['type']](self, **kwarg) 192 return self.token_class[kwarg['type']](self, **kwarg)
@@ -992,6 +971,29 @@ class WikiMarkup(WikiMarkupParser):
992 Base URL for media files. Default is 971 Base URL for media files. Default is
993 'http://www.mediawiki.org/xml/export-0.3' 972 'http://www.mediawiki.org/xml/export-0.3'
994 """ 973 """
974 self.token_class = {
975 'NIL': WikiNode,
976 'NL': WikiNode,
977 'OTAG': WikiTagNode,
978 'CTAG': WikiTagNode,
979 'TAG': WikiTagNode,
980 'DELIM': WikiDelimNode,
981 'TEXT': WikiTextNode,
982 'PRE': WikiContentNode,
983 'PARA': WikiSeqNode,
984 'BAR': WikiNode,
985 'SEQ': WikiSeqNode,
986 'IND': WikiIndNode,
987 'REF': WikiRefNode,
988 'TMPL': WikiSeqNode,
989 'IT': WikiSeqNode,
990 'BOLD': WikiSeqNode,
991 'ELT': WikiEltNode,
992 'ENV': WikiEnvNode,
993 'LINK': WikiSeqNode,
994 'HDR': WikiHdrNode
995 }
996
995 for kw in keywords: 997 for kw in keywords:
996 if kw == 'file': 998 if kw == 'file':
997 self.file = keywords[kw] 999 self.file = keywords[kw]

Return to:

Send suggestions and report system problems to the System administrator.