Skip to content

Selected patches from Calibre #245

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

Merged
merged 5 commits into from
May 22, 2016
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Clean up the constants imports in html5parser
  • Loading branch information
gsnedders committed May 22, 2016
commit 0a885c655192dca52484c83ea607f94720525da1
23 changes: 12 additions & 11 deletions html5lib/html5parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
from .treebuilders._base import Marker

from . import utils
from . import constants
from .constants import spaceCharacters, asciiUpper2Lower
from .constants import specialElements
from .constants import headingElements
from .constants import cdataElements, rcdataElements
from .constants import tokenTypes, ReparseException, namespaces
from .constants import htmlIntegrationPointElements, mathmlTextIntegrationPointElements
from .constants import adjustForeignAttributes as adjustForeignAttributesMap
from .constants import E
from .constants import (
spaceCharacters, asciiUpper2Lower,
specialElements, headingElements, cdataElements, rcdataElements,
tokenTypes, tagTokenTypes,
namespaces,
htmlIntegrationPointElements, mathmlTextIntegrationPointElements,
adjustForeignAttributes as adjustForeignAttributesMap,
E,
ReparseException
)


def parse(doc, treebuilder="etree", encoding=None,
Expand Down Expand Up @@ -434,7 +435,7 @@ def getPhases(debug):
def log(function):
"""Logger that records which phase processes each token"""
type_names = dict((value, key) for key, value in
constants.tokenTypes.items())
tokenTypes.items())

def wrapped(self, *args, **kwargs):
if function.__name__.startswith("process") and len(args) > 0:
Expand All @@ -443,7 +444,7 @@ def wrapped(self, *args, **kwargs):
info = {"type": type_names[token['type']]}
except:
raise
if token['type'] in constants.tagTokenTypes:
if token['type'] in tagTokenTypes:
info["name"] = token['name']

self.parser.log.append((self.parser.tokenizer.state.__name__,
Expand Down