Explorar el Código

Clarify flags.

tags/v0.1
Ben Kurtovic hace 12 años
padre
commit
034ac99ebe
Se han modificado 2 ficheros con 5 adiciones y 3 borrados
  1. +4
    -2
      mwparserfromhell/nodes/template.py
  2. +1
    -1
      mwparserfromhell/wikicode.py

+ 4
- 2
mwparserfromhell/nodes/template.py Ver fichero

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

__all__ = ["Template"]

FLAGS = re.DOTALL | re.UNICODE

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

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))]

def _select_theory(self, theories):
@@ -65,7 +67,7 @@ class Template(Node):
before_theories = defaultdict(lambda: 0)
after_theories = defaultdict(lambda: 0)
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_theories[before] += 1
after_theories[after] += 1


+ 1
- 1
mwparserfromhell/wikicode.py Ver fichero

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

__all__ = ["Wikicode"]

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

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


Cargando…
Cancelar
Guardar