Improved Python2/3 checking logic, moved html import to top of file.
The code now checks for PY2 from six rather than PY3 for better forward
compatibility.
@@ -5,13 +5,16 @@ import re
import astropy.units as u
import astropy.io.ascii as asciitable
-from six import PY3
+from six import PY2
from ..query import BaseQuery
from ..utils import async_to_sync, prepend_docstr_nosections
from . import conf
from ..exceptions import TableParseError
+if not PY2:
+ import html # html is available in Py3 stdlib, but not in Py2
+
__all__ = ['Nist', 'NistClass']
@@ -170,8 +173,7 @@ class NistClass(BaseQuery):
try:
table = _strip_blanks(pre)
table = links_re.sub(r'\1', table)
- if PY3:
- import html
+ if not PY2:
table = html.unescape(table)
table = asciitable.read(table, Reader=asciitable.FixedWidth,
data_start=3, delimiter='|')
