Selaa lähdekoodia

Rename some things, fixes, strip()

tags/v0.1
Ben Kurtovic 12 vuotta sitten
vanhempi
commit
d9c4b4f765
2 muutettua tiedostoa jossa 12 lisäystä ja 9 poistoa
  1. +3
    -3
      mwparserfromhell/nodes/template.py
  2. +9
    -6
      mwparserfromhell/string_mixin.py

+ 3
- 3
mwparserfromhell/nodes/template.py Näytä tiedosto

@@ -59,14 +59,14 @@ class Template(Node):
return True
return False

def get_param(self, name):
def get(self, name):
name = name.strip() if isinstance(name, basestring) else unicode(name)
for param in self.params:
if param.name.strip() == name:
return param
raise ValueError(name)

def add_param(self, name, value, showkey=None):
def add(self, name, value, showkey=None):
name, value = parse_anything(name), parse_anything(value)
surface_text = value.filter_text(recursive=False)
for node in surface_text:
@@ -93,7 +93,7 @@ class Template(Node):
else:
self.params.append(Parameter(name, value, showkey)) # CONFORM TO FORMATTING CONVENTIONS?

def remove_param(self, name, keep_field=False): # DON'T MESS UP NUMBERING WITH show_key = False AND keep_field = False
def remove(self, name, keep_field=False): # DON'T MESS UP NUMBERING WITH show_key = False AND keep_field = False
name = name.strip() if isinstance(name, basestring) else unicode(name)
for param in self.params:
if param.name.strip() == name:


+ 9
- 6
mwparserfromhell/string_mixin.py Näytä tiedosto

@@ -33,32 +33,32 @@ class StringMixIn(object):
raise NotImplementedError()

def __lt__(self, other):
if isinstance(other, StringMixin):
if isinstance(other, StringMixIn):
return unicode(self) < unicode(other)
return unicode(self) < other

def __le__(self, other):
if isinstance(other, StringMixin):
if isinstance(other, StringMixIn):
return unicode(self) <= unicode(other)
return unicode(self) <= other

def __eq__(self, other):
if isinstance(other, StringMixin):
if isinstance(other, StringMixIn):
return unicode(self) == unicode(other)
return unicode(self) == other

def __ne__(self, other):
if isinstance(other, StringMixin):
if isinstance(other, StringMixIn):
return unicode(self) != unicode(other)
return unicode(self) != other

def __gt__(self, other):
if isinstance(other, StringMixin):
if isinstance(other, StringMixIn):
return unicode(self) > unicode(other)
return unicode(self) > other

def __ge__(self, other):
if isinstance(other, StringMixin):
if isinstance(other, StringMixIn):
return unicode(self) >= unicode(other)
return unicode(self) >= other

@@ -82,3 +82,6 @@ class StringMixIn(object):

def replace(self, old, new, count):
return unicode(self).replace(old, new, count)

def strip(self, chars=None):
return unicode(self).strip(chars)

Ladataan…
Peruuta
Tallenna