| @@ -20,6 +20,8 @@ | |||||
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
| # SOFTWARE. | # SOFTWARE. | ||||
| from __future__ import unicode_literals | |||||
| """ | """ | ||||
| `mwparserfromhell <https://github.com/earwig/mwparserfromhell>`_ (the MediaWiki | `mwparserfromhell <https://github.com/earwig/mwparserfromhell>`_ (the MediaWiki | ||||
| Parser from Hell) is a Python package that provides an easy-to-use and | Parser from Hell) is a Python package that provides an easy-to-use and | ||||
| @@ -20,6 +20,9 @@ | |||||
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
| # SOFTWARE. | # SOFTWARE. | ||||
| from __future__ import unicode_literals | |||||
| from ..compat import str | |||||
| from ..string_mixin import StringMixIn | from ..string_mixin import StringMixIn | ||||
| __all__ = ["Node", "Text", "Heading", "HTMLEntity", "Tag", "Template"] | __all__ = ["Node", "Text", "Heading", "HTMLEntity", "Tag", "Template"] | ||||
| @@ -35,7 +38,7 @@ class Node(StringMixIn): | |||||
| return None | return None | ||||
| def __showtree__(self, write, get, mark): | def __showtree__(self, write, get, mark): | ||||
| write(unicode(self)) | |||||
| write(str(self)) | |||||
| from . import extras | from . import extras | ||||
| @@ -22,8 +22,8 @@ | |||||
| from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
| from ...compat import str | |||||
| from ...string_mixin import StringMixIn | from ...string_mixin import StringMixIn | ||||
| from ...compat import str, bytes | |||||
| __all__ = ["Attribute"] | __all__ = ["Attribute"] | ||||
| @@ -22,9 +22,9 @@ | |||||
| from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
| from ...compat import str | |||||
| from ...string_mixin import StringMixIn | from ...string_mixin import StringMixIn | ||||
| from ...utils import parse_anything | from ...utils import parse_anything | ||||
| from ...compat import str, bytes | |||||
| __all__ = ["Parameter"] | __all__ = ["Parameter"] | ||||
| @@ -20,7 +20,10 @@ | |||||
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
| # SOFTWARE. | # SOFTWARE. | ||||
| from __future__ import unicode_literals | |||||
| from . import Node | from . import Node | ||||
| from ..compat import str | |||||
| __all__ = ["Heading"] | __all__ = ["Heading"] | ||||
| @@ -31,7 +34,7 @@ class Heading(Node): | |||||
| self._level = level | self._level = level | ||||
| def __unicode__(self): | def __unicode__(self): | ||||
| return ("=" * self.level) + unicode(self.title) + ("=" * self.level) | |||||
| return ("=" * self.level) + str(self.title) + ("=" * self.level) | |||||
| def __iternodes__(self, getter): | def __iternodes__(self, getter): | ||||
| yield None, self | yield None, self | ||||
| @@ -23,7 +23,7 @@ | |||||
| from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
| from . import Node | from . import Node | ||||
| from ..compat import str, bytes, htmlentitydefs | |||||
| from ..compat import htmlentities | |||||
| __all__ = ["HTMLEntity"] | __all__ = ["HTMLEntity"] | ||||
| @@ -102,7 +102,7 @@ class HTMLEntity(Node): | |||||
| def normalize(self): | def normalize(self): | ||||
| if self.named: | if self.named: | ||||
| return unichr(htmlentitydefs.name2codepoint[self.value]) | |||||
| return unichr(htmlentities.name2codepoint[self.value]) | |||||
| if self.hexadecimal: | if self.hexadecimal: | ||||
| return self._unichr(int(self.value, 16)) | return self._unichr(int(self.value, 16)) | ||||
| return self._unichr(int(self.value)) | return self._unichr(int(self.value)) | ||||
| @@ -23,7 +23,7 @@ | |||||
| from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
| from . import Node, Text | from . import Node, Text | ||||
| from ..compat import str, bytes | |||||
| from ..compat import str | |||||
| __all__ = ["Tag"] | __all__ = ["Tag"] | ||||
| @@ -91,16 +91,16 @@ class Tag(Node): | |||||
| if self.self_closing: | if self.self_closing: | ||||
| return open_ | return open_ | ||||
| else: | else: | ||||
| return open_ + unicode(self.contents) + close | |||||
| return open_ + str(self.contents) + close | |||||
| result = "<" + unicode(self.tag) | |||||
| result = "<" + str(self.tag) | |||||
| if self.attrs: | if self.attrs: | ||||
| result += " " + " ".join([unicode(attr) for attr in self.attrs]) | |||||
| result += " " + " ".join([str(attr) for attr in self.attrs]) | |||||
| if self.self_closing: | if self.self_closing: | ||||
| result += " " * self.open_padding + "/>" | result += " " * self.open_padding + "/>" | ||||
| else: | else: | ||||
| result += " " * self.open_padding + ">" + unicode(self.contents) | |||||
| result += "</" + unicode(self.tag) + " " * self.close_padding + ">" | |||||
| result += " " * self.open_padding + ">" + str(self.contents) | |||||
| result += "</" + str(self.tag) + " " * self.close_padding + ">" | |||||
| return result | return result | ||||
| def __iternodes__(self, getter): | def __iternodes__(self, getter): | ||||
| @@ -124,9 +124,8 @@ class Tag(Node): | |||||
| def __showtree__(self, write, get, mark): | def __showtree__(self, write, get, mark): | ||||
| tagnodes = self.tag.nodes | tagnodes = self.tag.nodes | ||||
| if (not self.attrs and len(tagnodes) == 1 and | |||||
| isinstance(tagnodes[0], Text)): | |||||
| write("<" + unicode(tagnodes[0]) + ">") | |||||
| if (not self.attrs and len(tagnodes) == 1 and isinstance(tagnodes[0], Text)): | |||||
| write("<" + str(tagnodes[0]) + ">") | |||||
| else: | else: | ||||
| write("<") | write("<") | ||||
| get(self.tag) | get(self.tag) | ||||
| @@ -140,7 +139,7 @@ class Tag(Node): | |||||
| write(">") | write(">") | ||||
| get(self.contents) | get(self.contents) | ||||
| if len(tagnodes) == 1 and isinstance(tagnodes[0], Text): | if len(tagnodes) == 1 and isinstance(tagnodes[0], Text): | ||||
| write("</" + unicode(tagnodes[0]) + ">") | |||||
| write("</" + str(tagnodes[0]) + ">") | |||||
| else: | else: | ||||
| write("</") | write("</") | ||||
| get(self.tag) | get(self.tag) | ||||
| @@ -26,8 +26,8 @@ import re | |||||
| from . import HTMLEntity, Node, Text | from . import HTMLEntity, Node, Text | ||||
| from .extras import Parameter | from .extras import Parameter | ||||
| from ..compat import basestring, str | |||||
| from ..utils import parse_anything | from ..utils import parse_anything | ||||
| from ..compat import str, bytes, basestring | |||||
| __all__ = ["Template"] | __all__ = ["Template"] | ||||
| @@ -87,7 +87,8 @@ class Template(Node): | |||||
| best = max(theories.values()) | best = max(theories.values()) | ||||
| confidence = float(best) / sum(theories.values()) | confidence = float(best) / sum(theories.values()) | ||||
| if confidence > 0.75: | if confidence > 0.75: | ||||
| return tuple(theories.keys())[tuple(theories.values()).index(best)] | |||||
| keys = tuple(theories.keys()) | |||||
| return keys[tuple(theories.values()).index(best)] | |||||
| def _get_spacing_conventions(self): | def _get_spacing_conventions(self): | ||||
| before_theories = defaultdict(lambda: 0) | before_theories = defaultdict(lambda: 0) | ||||
| @@ -23,7 +23,7 @@ | |||||
| from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
| from . import Node | from . import Node | ||||
| from ..compat import str, bytes, basestring | |||||
| from ..compat import str | |||||
| __all__ = ["Text"] | __all__ = ["Text"] | ||||
| @@ -20,6 +20,8 @@ | |||||
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
| # SOFTWARE. | # SOFTWARE. | ||||
| from __future__ import unicode_literals | |||||
| from .compat import maxsize, py3k | from .compat import maxsize, py3k | ||||
| __all__ = ["SmartList"] | __all__ = ["SmartList"] | ||||
| @@ -22,12 +22,11 @@ | |||||
| from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
| import re | import re | ||||
| import sys | |||||
| from .compat import maxsize, str | |||||
| from .nodes import Heading, Node, Tag, Template, Text | from .nodes import Heading, Node, Tag, Template, Text | ||||
| from .string_mixin import StringMixIn | from .string_mixin import StringMixIn | ||||
| from .utils import parse_anything | from .utils import parse_anything | ||||
| from .compat import str, bytes | |||||
| __all__ = ["Wikicode"] | __all__ = ["Wikicode"] | ||||
| @@ -230,7 +229,7 @@ class Wikicode(StringMixIn): | |||||
| headings = [head for head in headings if head.level in levels] | headings = [head for head in headings if head.level in levels] | ||||
| sections = [] | sections = [] | ||||
| buffers = [[sys.maxint, 0]] | |||||
| buffers = [[maxsize, 0]] | |||||
| i = 0 | i = 0 | ||||
| while i < len(self.nodes): | while i < len(self.nodes): | ||||
| if self.nodes[i] in headings: | if self.nodes[i] in headings: | ||||