Browse Source

Clarify flags.

tags/v0.1
Ben Kurtovic 12 years ago
parent
commit
034ac99ebe
2 changed files with 5 additions and 3 deletions
  1. +4
    -2
      mwparserfromhell/nodes/template.py
  2. +1
    -1
      mwparserfromhell/wikicode.py

+ 4
- 2
mwparserfromhell/nodes/template.py View File

@@ -29,6 +29,8 @@ from mwparserfromhell.utils import parse_anything


__all__ = ["Template"] __all__ = ["Template"]


FLAGS = re.DOTALL | re.UNICODE

class Template(Node): class Template(Node):
def __init__(self, name, params=None): def __init__(self, name, params=None):
self._name = name self._name = name
@@ -51,7 +53,7 @@ class Template(Node):
code.replace(node, node.replace(char, replacement)) code.replace(node, node.replace(char, replacement))


def _blank_param_value(self, value): def _blank_param_value(self, value):
match = re.search("^(\s*).*?(\s*)$", value, re.DOTALL|re.UNICODE)
match = re.search("^(\s*).*?(\s*)$", unicode(value), FLAGS)
value.nodes = [Text(match.group(1)), Text(match.group(2))] value.nodes = [Text(match.group(1)), Text(match.group(2))]


def _select_theory(self, theories): def _select_theory(self, theories):
@@ -65,7 +67,7 @@ class Template(Node):
before_theories = defaultdict(lambda: 0) before_theories = defaultdict(lambda: 0)
after_theories = defaultdict(lambda: 0) after_theories = defaultdict(lambda: 0)
for param in self.params: for param in self.params:
match = re.search("^(\s*).*?(\s*)$", param.value, re.S|re.U)
match = re.search("^(\s*).*?(\s*)$", unicode(param.value), FLAGS)
before, after = match.group(1), match.group(2) before, after = match.group(1), match.group(2)
before_theories[before] += 1 before_theories[before] += 1
after_theories[after] += 1 after_theories[after] += 1


+ 1
- 1
mwparserfromhell/wikicode.py View File

@@ -28,7 +28,7 @@ from mwparserfromhell.utils import parse_anything


__all__ = ["Wikicode"] __all__ = ["Wikicode"]


FLAGS = re.I | re.S | re.U
FLAGS = re.IGNORECASE | re.DOTALL | re.UNICODE


class Wikicode(StringMixIn): class Wikicode(StringMixIn):
def __init__(self, nodes): def __init__(self, nodes):


Loading…
Cancel
Save