Quellcode durchsuchen

Move range/xrange compatibility code to compat.py.

tags/v0.3.3
Ben Kurtovic vor 11 Jahren
Ursprung
Commit
45aec31629
9 geänderte Dateien mit 9 neuen und 12 gelöschten Zeilen
  1. +2
    -0
      mwparserfromhell/compat.py
  2. +1
    -1
      mwparserfromhell/nodes/template.py
  3. +1
    -1
      mwparserfromhell/parser/tokenizer.py
  4. +1
    -0
      tests/_test_tree_equality.py
  5. +0
    -2
      tests/compat.py
  6. +1
    -1
      tests/test_parser.py
  7. +1
    -3
      tests/test_smart_list.py
  8. +1
    -3
      tests/test_string_mixin.py
  9. +1
    -1
      tests/test_wikicode.py

+ 2
- 0
mwparserfromhell/compat.py Datei anzeigen

@@ -16,12 +16,14 @@ py32 = py3k and sys.version_info.minor == 2
if py3k:
bytes = bytes
str = str
range = xrange
maxsize = sys.maxsize
import html.entities as htmlentities

else:
bytes = str
str = unicode
range = range
maxsize = sys.maxint
import htmlentitydefs as htmlentities



+ 1
- 1
mwparserfromhell/nodes/template.py Datei anzeigen

@@ -26,7 +26,7 @@ import re

from . import HTMLEntity, Node, Text
from .extras import Parameter
from ..compat import str
from ..compat import range, str
from ..utils import parse_anything

__all__ = ["Template"]


+ 1
- 1
mwparserfromhell/parser/tokenizer.py Datei anzeigen

@@ -25,7 +25,7 @@ from math import log
import re

from . import contexts, tokens
from ..compat import htmlentities
from ..compat import htmlentities, range
from ..definitions import (get_html_tag, is_parsable, is_single,
is_single_only, is_scheme)



+ 1
- 0
tests/_test_tree_equality.py Datei anzeigen

@@ -23,6 +23,7 @@
from __future__ import unicode_literals
from unittest import TestCase

from mwparserfromhell.compat import range
from mwparserfromhell.nodes import (Argument, Comment, Heading, HTMLEntity,
Tag, Template, Text, Wikilink)
from mwparserfromhell.nodes.extras import Attribute, Parameter


+ 0
- 2
tests/compat.py Datei anzeigen

@@ -9,12 +9,10 @@ the main library.
from mwparserfromhell.compat import py3k

if py3k:
range = range
from io import StringIO
from urllib.parse import urlencode
from urllib.request import urlopen

else:
range = xrange
from StringIO import StringIO
from urllib import urlencode, urlopen

+ 1
- 1
tests/test_parser.py Datei anzeigen

@@ -24,11 +24,11 @@ from __future__ import unicode_literals
import unittest

from mwparserfromhell import parser
from mwparserfromhell.compat import range
from mwparserfromhell.nodes import Tag, Template, Text, Wikilink
from mwparserfromhell.nodes.extras import Parameter

from ._test_tree_equality import TreeEqualityTestCase, wrap, wraptext
from .compat import range

class TestParser(TreeEqualityTestCase):
"""Tests for the Parser class itself, which tokenizes and builds nodes."""


+ 1
- 3
tests/test_smart_list.py Datei anzeigen

@@ -23,11 +23,9 @@
from __future__ import unicode_literals
import unittest

from mwparserfromhell.compat import py3k
from mwparserfromhell.compat import py3k, range
from mwparserfromhell.smart_list import SmartList, _ListProxy

from .compat import range

class TestSmartList(unittest.TestCase):
"""Test cases for the SmartList class and its child, _ListProxy."""



+ 1
- 3
tests/test_string_mixin.py Datei anzeigen

@@ -25,11 +25,9 @@ from sys import getdefaultencoding
from types import GeneratorType
import unittest

from mwparserfromhell.compat import bytes, py3k, py32, str
from mwparserfromhell.compat import bytes, py3k, py32, range, str
from mwparserfromhell.string_mixin import StringMixIn

from .compat import range

class _FakeString(StringMixIn):
def __init__(self, data):
self._data = data


+ 1
- 1
tests/test_wikicode.py Datei anzeigen

@@ -26,12 +26,12 @@ import re
from types import GeneratorType
import unittest

from mwparserfromhell.compat import py3k, str
from mwparserfromhell.nodes import (Argument, Comment, Heading, HTMLEntity,
Node, Tag, Template, Text, Wikilink)
from mwparserfromhell.smart_list import SmartList
from mwparserfromhell.wikicode import Wikicode
from mwparserfromhell import parse
from mwparserfromhell.compat import py3k, str

from ._test_tree_equality import TreeEqualityTestCase, wrap, wraptext



Laden…
Abbrechen
Speichern