Kaynağa Gözat

Clarify flags.

tags/v0.1
Ben Kurtovic 12 yıl önce
ebeveyn
işleme
034ac99ebe
2 değiştirilmiş dosya ile 5 ekleme ve 3 silme
  1. +4
    -2
      mwparserfromhell/nodes/template.py
  2. +1
    -1
      mwparserfromhell/wikicode.py

+ 4
- 2
mwparserfromhell/nodes/template.py Dosyayı Görüntüle

@@ -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 Dosyayı Görüntüle

@@ -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):


Yükleniyor…
İptal
Kaydet