@@ -32,6 +32,6 @@ __license__ = "MIT License" | |||||
__version__ = "0.1.dev" | __version__ = "0.1.dev" | ||||
__email__ = "ben.kurtovic@verizon.net" | __email__ = "ben.kurtovic@verizon.net" | ||||
from mwparserfromhell import nodes, parser, smart_list, string_mixin, wikicode | |||||
from . import nodes, parser, smart_list, string_mixin, wikicode | |||||
parse = lambda text: parser.Parser(text).parse() | parse = lambda text: parser.Parser(text).parse() |
@@ -20,7 +20,7 @@ | |||||
# 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 mwparserfromhell.string_mixin import StringMixIn | |||||
from ..string_mixin import StringMixIn | |||||
__all__ = ["Node"] | __all__ = ["Node"] | ||||
@@ -35,9 +35,9 @@ class Node(StringMixIn): | |||||
write(unicode(self)) | write(unicode(self)) | ||||
from mwparserfromhell.nodes import extras | |||||
from mwparserfromhell.nodes.text import Text | |||||
from mwparserfromhell.nodes.heading import Heading | |||||
from mwparserfromhell.nodes.html_entity import HTMLEntity | |||||
from mwparserfromhell.nodes.tag import Tag | |||||
from mwparserfromhell.nodes.template import Template | |||||
from . import extras | |||||
from .text import Text | |||||
from .heading import Heading | |||||
from .html_entity import HTMLEntity | |||||
from .tag import Tag | |||||
from .template import Template |
@@ -20,5 +20,5 @@ | |||||
# 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 mwparserfromhell.nodes.extras.attribute import Attribute | |||||
from mwparserfromhell.nodes.extras.parameter import Parameter | |||||
from .attribute import Attribute | |||||
from .parameter import Parameter |
@@ -20,7 +20,7 @@ | |||||
# 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 mwparserfromhell.string_mixin import StringMixIn | |||||
from ...string_mixin import StringMixIn | |||||
__all__ = ["Attribute"] | __all__ = ["Attribute"] | ||||
@@ -20,8 +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 mwparserfromhell.string_mixin import StringMixIn | |||||
from mwparserfromhell.utils import parse_anything | |||||
from ...string_mixin import StringMixIn | |||||
from ...utils import parse_anything | |||||
__all__ = ["Parameter"] | __all__ = ["Parameter"] | ||||
@@ -20,7 +20,7 @@ | |||||
# 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 mwparserfromhell.nodes import Node | |||||
from . import Node | |||||
__all__ = ["Heading"] | __all__ = ["Heading"] | ||||
@@ -22,7 +22,7 @@ | |||||
import htmlentitydefs | import htmlentitydefs | ||||
from mwparserfromhell.nodes import Node | |||||
from . import Node | |||||
__all__ = ["HTMLEntity"] | __all__ = ["HTMLEntity"] | ||||
@@ -20,7 +20,7 @@ | |||||
# 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 mwparserfromhell.nodes import Node, Text | |||||
from . import Node, Text | |||||
__all__ = ["Tag"] | __all__ = ["Tag"] | ||||
@@ -23,9 +23,9 @@ | |||||
from collections import defaultdict | from collections import defaultdict | ||||
import re | import re | ||||
from mwparserfromhell.nodes import HTMLEntity, Node, Text | |||||
from mwparserfromhell.nodes.extras import Parameter | |||||
from mwparserfromhell.utils import parse_anything | |||||
from . import HTMLEntity, Node, Text | |||||
from .extras import Parameter | |||||
from ..utils import parse_anything | |||||
__all__ = ["Template"] | __all__ = ["Template"] | ||||
@@ -20,7 +20,7 @@ | |||||
# 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 mwparserfromhell.nodes import Node | |||||
from . import Node | |||||
__all__ = ["Text"] | __all__ = ["Text"] | ||||
@@ -20,4 +20,4 @@ | |||||
# 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 mwparserfromhell.parser.demo import DemoParser as Parser | |||||
from .demo import DemoParser as Parser |
@@ -20,10 +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 mwparserfromhell.nodes import Template, Text | |||||
from mwparserfromhell.nodes.extras import Parameter | |||||
from mwparserfromhell.smart_list import SmartList | |||||
from mwparserfromhell.wikicode import Wikicode | |||||
from ..nodes import Template, Text | |||||
from ..nodes.extras import Parameter | |||||
from ..smart_list import SmartList | |||||
from ..wikicode import Wikicode | |||||
__all__ = ["DemoParser"] | __all__ = ["DemoParser"] | ||||
@@ -53,7 +53,16 @@ class SmartList(list): | |||||
if stop >= key.stop and stop != sys.maxint: | if stop >= key.stop and stop != sys.maxint: | ||||
self._children[id(child)][1][1] += diff | self._children[id(child)][1][1] += diff | ||||
__delitem__ | |||||
def __delitem__(self, key): | |||||
super(SmartList, self).__delitem__(key) | |||||
if not isinstance(key, slice): | |||||
key = slice(key, key + 1) | |||||
diff = key.stop - key.start | |||||
for child, (start, stop, step) in self._children.itervalues(): | |||||
if start > key.start: | |||||
self._children[id(child)][1][0] -= diff | |||||
if stop >= key.stop: | |||||
self._children[id(child)][1][1] -= diff | |||||
def __getslice__(self, start, stop): | def __getslice__(self, start, stop): | ||||
return self.__getitem__(slice(start, stop)) | return self.__getitem__(slice(start, stop)) | ||||
@@ -64,17 +73,14 @@ class SmartList(list): | |||||
def __delslice__(self, start, stop): | def __delslice__(self, start, stop): | ||||
self.__delitem__(slice(start, stop)) | self.__delitem__(slice(start, stop)) | ||||
__add__ | |||||
__radd__ | |||||
__iadd__ | |||||
def __add__(self, other): | |||||
return SmartList(list(self) + other) | |||||
__mul__ | |||||
def __radd__(self, other): | |||||
return SmartList(other + list(self)) | |||||
__rmul__ | |||||
__imul__ | |||||
def __iadd__(self, other): | |||||
self.extend(other) | |||||
def append(self, item): | def append(self, item): | ||||
super(SmartList, self).append(item) | super(SmartList, self).append(item) | ||||
@@ -82,21 +88,21 @@ class SmartList(list): | |||||
if stop >= len(self) - 1 and stop != sys.maxint: | if stop >= len(self) - 1 and stop != sys.maxint: | ||||
self._children[id(child)][1][1] += 1 | self._children[id(child)][1][1] += 1 | ||||
count | |||||
#count | |||||
index | |||||
#index | |||||
extend | |||||
#extend | |||||
insert | |||||
#insert | |||||
pop | |||||
#pop | |||||
remove | |||||
#remove | |||||
reverse | |||||
#reverse | |||||
sort | |||||
#sort | |||||
class _ListProxy(list): | class _ListProxy(list): | ||||
@@ -108,19 +114,19 @@ class _ListProxy(list): | |||||
def __repr__(self): | def __repr__(self): | ||||
return repr(self._render()) | return repr(self._render()) | ||||
__lt__ | |||||
#__lt__ | |||||
__le__ | |||||
#__le__ | |||||
__eq__ | |||||
#__eq__ | |||||
__ne__ | |||||
#__ne__ | |||||
__gt__ | |||||
#__gt__ | |||||
__ge__ | |||||
#__ge__ | |||||
__nonzero__ | |||||
#__nonzero__ | |||||
def __len__(self): | def __len__(self): | ||||
return (self._stop - self._start) / self._step | return (self._stop - self._start) / self._step | ||||
@@ -136,7 +142,7 @@ class _ListProxy(list): | |||||
else: | else: | ||||
self._parent[self._start + index] = item | self._parent[self._start + index] = item | ||||
__delitem__ | |||||
#__delitem__ | |||||
def __iter__(self): | def __iter__(self): | ||||
i = self._start | i = self._start | ||||
@@ -162,17 +168,14 @@ class _ListProxy(list): | |||||
def __delslice__(self, start, stop): | def __delslice__(self, start, stop): | ||||
self.__delitem__(slice(start, stop)) | self.__delitem__(slice(start, stop)) | ||||
__add__ | |||||
__radd__ | |||||
__iadd__ | |||||
__mul__ | |||||
def __add__(self, other): | |||||
return SmartList(list(self) + other) | |||||
__rmul__ | |||||
def __radd__(self, other): | |||||
return SmartList(other + list(self)) | |||||
__imul__ | |||||
def __iadd__(self, other): | |||||
self.extend(other) | |||||
@property | @property | ||||
def _start(self): | def _start(self): | ||||
@@ -208,9 +211,9 @@ class _ListProxy(list): | |||||
def insert(self, index, item): | def insert(self, index, item): | ||||
self._parent.insert(self._start + index, item) | self._parent.insert(self._start + index, item) | ||||
pop | |||||
#pop | |||||
remove | |||||
#remove | |||||
def reverse(self): | def reverse(self): | ||||
item = self._render() | item = self._render() | ||||
@@ -21,7 +21,7 @@ | |||||
# SOFTWARE. | # SOFTWARE. | ||||
import mwparserfromhell | import mwparserfromhell | ||||
from mwparserfromhell.nodes import Node | |||||
from .nodes import Node | |||||
def parse_anything(value): | def parse_anything(value): | ||||
wikicode = mwparserfromhell.wikicode.Wikicode | wikicode = mwparserfromhell.wikicode.Wikicode | ||||
@@ -23,9 +23,9 @@ | |||||
import re | import re | ||||
import sys | import sys | ||||
from mwparserfromhell.nodes import Heading, Node, Tag, Template, Text | |||||
from mwparserfromhell.string_mixin import StringMixIn | |||||
from mwparserfromhell.utils import parse_anything | |||||
from .nodes import Heading, Node, Tag, Template, Text | |||||
from .string_mixin import StringMixIn | |||||
from .utils import parse_anything | |||||
__all__ = ["Wikicode"] | __all__ = ["Wikicode"] | ||||