Commit 7eefb956 authored by Guillaume Binet's avatar Guillaume Binet

Removed unused util functions.

parent 00128656
......@@ -7,7 +7,6 @@ import sys
import time
from platform import system
from functools import wraps
from html import entities
log = logging.getLogger(__name__)
......@@ -65,14 +64,6 @@ def format_timedelta(timedelta):
return f'{hours:d} hours and {minutes:d} minutes'
# Introspect to know from which plugin a command is implemented
def get_class_for_method(meth):
for cls in inspect.getmro(type(meth.__self__)):
if meth.__name__ in cls.__dict__:
return cls
return None
INVALID_VERSION_EXCEPTION = 'version %s in not in format "x.y.z" or "x.y.z-{beta,alpha,rc1,rc2...}" for example "1.2.2"'
......@@ -105,35 +96,6 @@ def version2tuple(version):
return tuple(response)
def unescape_xml(text):
"""
Removes HTML or XML character references and entities from a text string.
@param text The HTML (or XML) source text.
@return The plain text, as a Unicode string, if necessary.
"""
def fixup(m):
txt = m.group(0)
if txt[:2] == "&#":
# character reference
try:
if txt[:3] == "&#x":
return chr(int(txt[3:-1], 16))
else:
return chr(int(txt[2:-1]))
except ValueError:
pass
else:
# named entity
try:
txt = chr(entities.name2codepoint[txt[1:-1]])
except KeyError:
pass
return txt # leave as is
return re.sub(r'&#?\w+;', fixup, text)
REMOVE_EOL = re.compile(r'\n')
REINSERT_EOLS = re.compile(r'</p>|</li>|<br/>', re.I)
ZAP_TAGS = re.compile(r'<[^>]+>')
......
......@@ -44,10 +44,6 @@ def test_formattimedelta():
assert '1 hours and 13 minutes' == format_timedelta(td)
def unescape_test():
assert unescape_xml('&#32;') == ' '
def test_storage():
key = 'test'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment