Hugo 6 лет назад
Родитель
Сommit
e457b39f32
9 измененных файлов: 13 добавлений и 13 удалений
  1. +2
    -2
      mwparserfromhell/nodes/extras/attribute.py
  2. +1
    -1
      mwparserfromhell/nodes/extras/parameter.py
  3. +3
    -3
      mwparserfromhell/nodes/html_entity.py
  4. +1
    -1
      mwparserfromhell/parser/__init__.py
  5. +1
    -1
      mwparserfromhell/parser/tokens.py
  6. +1
    -1
      mwparserfromhell/string_mixin.py
  7. +2
    -2
      scripts/memtest.py
  8. +1
    -1
      setup.py
  9. +1
    -1
      tests/_test_tokenizer.py

+ 2
- 2
mwparserfromhell/nodes/extras/attribute.py Просмотреть файл

@@ -40,7 +40,7 @@ class Attribute(StringMixIn):
pad_before_eq="", pad_after_eq="", check_quotes=True):
super(Attribute, self).__init__()
if check_quotes and not quotes and self._value_needs_quotes(value):
raise ValueError("given value {0!r} requires quotes".format(value))
raise ValueError("given value {!r} requires quotes".format(value))
self._name = name
self._value = value
self._quotes = quotes
@@ -79,7 +79,7 @@ class Attribute(StringMixIn):
"""Coerce a quote type into an acceptable value, or raise an error."""
orig, quotes = quotes, str(quotes) if quotes else None
if quotes not in [None, '"', "'"]:
raise ValueError("{0!r} is not a valid quote type".format(orig))
raise ValueError("{!r} is not a valid quote type".format(orig))
return quotes

@property


+ 1
- 1
mwparserfromhell/nodes/extras/parameter.py Просмотреть файл

@@ -41,7 +41,7 @@ class Parameter(StringMixIn):
def __init__(self, name, value, showkey=True):
super(Parameter, self).__init__()
if not showkey and not self.can_hide_key(name):
raise ValueError("key {0!r} cannot be hidden".format(name))
raise ValueError("key {!r} cannot be hidden".format(name))
self._name = name
self._value = value
self._showkey = showkey


+ 3
- 3
mwparserfromhell/nodes/html_entity.py Просмотреть файл

@@ -53,10 +53,10 @@ class HTMLEntity(Node):

def __unicode__(self):
if self.named:
return "&{0};".format(self.value)
return "&{};".format(self.value)
if self.hexadecimal:
return "&#{0}{1};".format(self.hex_char, self.value)
return "&#{0};".format(self.value)
return "&#{}{};".format(self.hex_char, self.value)
return "&#{};".format(self.value)

def __strip__(self, **kwargs):
if kwargs.get("normalize"):


+ 1
- 1
mwparserfromhell/parser/__init__.py Просмотреть файл

@@ -35,7 +35,7 @@ class ParserError(Exception):
can happen. Its appearance indicates a bug.
"""
def __init__(self, extra):
msg = "This is a bug and should be reported. Info: {0}.".format(extra)
msg = "This is a bug and should be reported. Info: {}.".format(extra)
super(ParserError, self).__init__(msg)




+ 1
- 1
mwparserfromhell/parser/tokens.py Просмотреть файл

@@ -44,7 +44,7 @@ class Token(dict):
args.append(key + "=" + repr(value[:97] + "..."))
else:
args.append(key + "=" + repr(value))
return "{0}({1})".format(type(self).__name__, ", ".join(args))
return "{}({})".format(type(self).__name__, ", ".join(args))

def __eq__(self, other):
return isinstance(other, type(self)) and dict.__eq__(self, other)


+ 1
- 1
mwparserfromhell/string_mixin.py Просмотреть файл

@@ -109,7 +109,7 @@ class StringMixIn(object):

def __getattr__(self, attr):
if not hasattr(str, attr):
raise AttributeError("{0!r} object has no attribute {1!r}".format(
raise AttributeError("{!r} object has no attribute {!r}".format(
type(self).__name__, attr))
return getattr(self.__unicode__(), attr)



+ 2
- 2
scripts/memtest.py Просмотреть файл

@@ -80,7 +80,7 @@ class MemoryTest(object):
raw = raw.encode("raw_unicode_escape")
data["input"] = raw.decode("unicode_escape")
number = str(counter).zfill(digits)
fname = "test_{0}{1}_{2}".format(name, number, data["name"])
fname = "test_{}{}_{}".format(name, number, data["name"])
self._tests.append((fname, data["input"]))
counter += 1

@@ -117,7 +117,7 @@ class MemoryTest(object):
tmpl = "{0}LEAKING{1}: {2:n} bytes, {3:.2%} inc ({4:n} bytes/loop)"
sys.stdout.write(tmpl.format(Color.YELLOW, Color.RESET, d, p, bpt))
else:
sys.stdout.write("{0}OK{1}".format(Color.GREEN, Color.RESET))
sys.stdout.write("{}OK{}".format(Color.GREEN, Color.RESET))

def run(self):
"""Run the memory test suite."""


+ 1
- 1
setup.py Просмотреть файл

@@ -89,7 +89,7 @@ setup(
url = "https://github.com/earwig/mwparserfromhell",
description = "MWParserFromHell is a parser for MediaWiki wikicode.",
long_description = long_docs,
download_url = "https://github.com/earwig/mwparserfromhell/tarball/v{0}".format(__version__),
download_url = "https://github.com/earwig/mwparserfromhell/tarball/v{}".format(__version__),
keywords = "earwig mwparserfromhell wikipedia wiki mediawiki wikicode template parsing",
license = "MIT License",
classifiers = [


+ 1
- 1
tests/_test_tokenizer.py Просмотреть файл

@@ -118,7 +118,7 @@ class TokenizerTestCase(object):
if restrict and data["name"] != restrict:
continue

fname = "test_{0}{1}_{2}".format(name, number, data["name"])
fname = "test_{}{}_{}".format(name, number, data["name"])
meth = cls._build_test_method(fname, data)
setattr(cls, fname, meth)



Загрузка…
Отмена
Сохранить