Browse Source

Forgot to add compat.py

tags/v0.1
Riamse 11 years ago
parent
commit
a24821057c
2 changed files with 30 additions and 0 deletions
  1. +16
    -0
      mwparserfromhell/compat.py
  2. +14
    -0
      test.py

+ 16
- 0
mwparserfromhell/compat.py View File

@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
import sys
v = sys.version_info[0]
if v >= 3:
bytes = bytes
str = str
basestring = (str, bytes)
import html.entities as htmlentitydefs
else:
bytes = str
str = unicode
basestring = basestring
import htmlentitydefs

+ 14
- 0
test.py View File

@@ -0,0 +1,14 @@
import mwparserfromhell
text = "foo {{spam|eggs}} bar"
code = mwparserfromhell.parse(text)
template = code.filter_templates()[0]
template.name
template.params
template.params[0].value
template.params[0].name
template.params[0].showkey
template.params[0].showkey = True
template.params[0].name = "apples"
code
template.add("pears", "{{plums}}")
code.filter_templates(recursive=True)

Loading…
Cancel
Save