Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates 2 #9

Merged
merged 6 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ dist/
*.egg-info/
*.pyc
*.pyo
emeraldtree/_version.py
12 changes: 0 additions & 12 deletions .hgignore

This file was deleted.

2 changes: 0 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ please see the repositories:
* https://github.com/moinwiki/emeraldtree/
* http://svn.effbot.org/public/elementtree-1.3/

Please note: EmeraldTree works with Python 2.7 or >=3.4.

Changes are (c) by their authors (see also source files) and licensed
under the same Python (MIT style) license as ElementTree (see below):

Expand Down
4 changes: 2 additions & 2 deletions emeraldtree/ElementInclude.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def include(elem, loader=None):
node = loader(href, parse)
if node is None:
raise FatalIncludeError(
"cannot load %r as %r" % (href, parse)
"cannot load {!r} as {!r}".format(href, parse)
)
node = copy.copy(node)
if e.tail:
Expand All @@ -119,7 +119,7 @@ def include(elem, loader=None):
text = loader(href, parse, e.get("encoding"))
if text is None:
raise FatalIncludeError(
"cannot load %r as %r" % (href, parse)
"cannot load {!r} as {!r}".format(href, parse)
)
if i:
node = elem[i-1]
Expand Down
6 changes: 2 additions & 4 deletions emeraldtree/ElementPath.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,12 @@ def select(context, result):
def prepare_star(next, token):
def select(context, result):
for elem in result:
for e in elem:
yield e
yield from elem
return select

def prepare_dot(next, token):
def select(context, result):
for elem in result:
yield elem
yield from result
return select

def prepare_iter(next, token):
Expand Down
11 changes: 4 additions & 7 deletions emeraldtree/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,11 @@
# Tools to build element trees from HTML files.
##

import six
from six.moves import html_entities
from six.moves import html_parser
from html.parser import HTMLParser as HTMLParserBase
from html.entities import entitydefs as html_entitydefs

from . import tree

HTMLParserBase = html_parser.HTMLParser


##
# ElementTree builder for HTML source code. This builder converts an
Expand Down Expand Up @@ -148,7 +145,7 @@ def handle_charref(self, char):
# (Internal) Handles entity references.

def handle_entityref(self, name):
entity = html_entities.entitydefs.get(name)
entity = html_entitydefs.get(name)
if entity:
if len(entity) == 1:
entity = ord(entity)
Expand All @@ -165,7 +162,7 @@ def handle_entityref(self, name):
# (Internal) Handles character data.

def handle_data(self, data):
if isinstance(data, six.binary_type):
if isinstance(data, bytes):
# convert to unicode, but only if necessary
data = data.decode(self.encoding, "ignore")
self.__builder.data(data)
Expand Down
5 changes: 2 additions & 3 deletions emeraldtree/tests/test_html.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import six
from six import StringIO
from io import StringIO

from .. import html, tree

Expand All @@ -26,7 +25,7 @@ def test_read_text1():
assert isinstance(elem, tree.Element)
assert len(elem) == 1
assert elem[0] == 'b'
assert isinstance(elem[0], six.text_type)
assert isinstance(elem[0], str)

def test_read_text2():
elem = html.HTML('<a>b<c>d</c>d</a>')
Expand Down
Loading