Parcourir la source

Don't use f-strings; we still support Python 3.5

tags/v0.6
Ben Kurtovic il y a 3 ans
Parent
révision
d36aa34997
2 fichiers modifiés avec 10 ajouts et 9 suppressions
  1. +7
    -6
      mwparserfromhell/nodes/html_entity.py
  2. +3
    -3
      mwparserfromhell/utils.py

+ 7
- 6
mwparserfromhell/nodes/html_entity.py Voir le fichier

@@ -101,19 +101,20 @@ class HTMLEntity(Node):
intval = int(newval, 16)
except ValueError:
if newval not in htmlentities.entitydefs:
raise ValueError(f"entity value {newval!r} is not a valid name") from None
raise ValueError(
"entity value {!r} is not a valid name".format(newval)) from None
self._named = True
self._hexadecimal = False
else:
if intval < 0 or intval > 0x10FFFF:
raise ValueError(
f"entity value 0x{intval:x} is not in range(0x110000)") from None
"entity value 0x{:x} is not in range(0x110000)".format(intval)) from None
self._named = False
self._hexadecimal = True
else:
test = int(newval, 16 if self.hexadecimal else 10)
if test < 0 or test > 0x10FFFF:
raise ValueError(f"entity value {test} is not in range(0x110000)")
raise ValueError("entity value {} is not in range(0x110000)".format(test))
self._named = False
self._value = newval

@@ -121,13 +122,13 @@ class HTMLEntity(Node):
def named(self, newval):
newval = bool(newval)
if newval and self.value not in htmlentities.entitydefs:
raise ValueError(f"entity value {self.value!r} is not a valid name")
raise ValueError("entity value {!r} is not a valid name".format(self.value))
if not newval:
try:
int(self.value, 16)
except ValueError as exc:
raise ValueError(f"current entity value {self.value!r} "
f"is not a valid Unicode codepoint") from exc
raise ValueError("current entity value {!r} is not a valid "
"Unicode codepoint".format(self.value)) from exc
self._named = newval

@hexadecimal.setter


+ 3
- 3
mwparserfromhell/utils.py Voir le fichier

@@ -65,6 +65,6 @@ def parse_anything(value, context=0, skip_style_tags=False):
nodelist += parse_anything(item, context, skip_style_tags).nodes
return Wikicode(nodelist)
except TypeError as exc:
raise ValueError(f"Needs string, Node, Wikicode, file, int, None, or "
f"iterable of these, but got {type(value).__name__}: "
f"{value}") from exc
error = ("Needs string, Node, Wikicode, file, int, None, or "
"iterable of these, but got {0}: {1}")
raise ValueError(error.format(type(value).__name__, value)) from exc

Chargement…
Annuler
Enregistrer