소스 검색

Relaive imports because they are awesome; more stuff in SmartList.

tags/v0.1
Ben Kurtovic 12 년 전
부모
커밋
3633f31633
15개의 변경된 파일69개의 추가작업 그리고 66개의 파일을 삭제
  1. +1
    -1
      mwparserfromhell/__init__.py
  2. +7
    -7
      mwparserfromhell/nodes/__init__.py
  3. +2
    -2
      mwparserfromhell/nodes/extras/__init__.py
  4. +1
    -1
      mwparserfromhell/nodes/extras/attribute.py
  5. +2
    -2
      mwparserfromhell/nodes/extras/parameter.py
  6. +1
    -1
      mwparserfromhell/nodes/heading.py
  7. +1
    -1
      mwparserfromhell/nodes/html_entity.py
  8. +1
    -1
      mwparserfromhell/nodes/tag.py
  9. +3
    -3
      mwparserfromhell/nodes/template.py
  10. +1
    -1
      mwparserfromhell/nodes/text.py
  11. +1
    -1
      mwparserfromhell/parser/__init__.py
  12. +4
    -4
      mwparserfromhell/parser/demo.py
  13. +40
    -37
      mwparserfromhell/smart_list.py
  14. +1
    -1
      mwparserfromhell/utils.py
  15. +3
    -3
      mwparserfromhell/wikicode.py

+ 1
- 1
mwparserfromhell/__init__.py 파일 보기

@@ -32,6 +32,6 @@ __license__ = "MIT License"
__version__ = "0.1.dev"
__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()

+ 7
- 7
mwparserfromhell/nodes/__init__.py 파일 보기

@@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from mwparserfromhell.string_mixin import StringMixIn
from ..string_mixin import StringMixIn

__all__ = ["Node"]

@@ -35,9 +35,9 @@ class Node(StringMixIn):
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

+ 2
- 2
mwparserfromhell/nodes/extras/__init__.py 파일 보기

@@ -20,5 +20,5 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from mwparserfromhell.nodes.extras.attribute import Attribute
from mwparserfromhell.nodes.extras.parameter import Parameter
from .attribute import Attribute
from .parameter import Parameter

+ 1
- 1
mwparserfromhell/nodes/extras/attribute.py 파일 보기

@@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from mwparserfromhell.string_mixin import StringMixIn
from ...string_mixin import StringMixIn

__all__ = ["Attribute"]



+ 2
- 2
mwparserfromhell/nodes/extras/parameter.py 파일 보기

@@ -20,8 +20,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# 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"]



+ 1
- 1
mwparserfromhell/nodes/heading.py 파일 보기

@@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from mwparserfromhell.nodes import Node
from . import Node

__all__ = ["Heading"]



+ 1
- 1
mwparserfromhell/nodes/html_entity.py 파일 보기

@@ -22,7 +22,7 @@

import htmlentitydefs

from mwparserfromhell.nodes import Node
from . import Node

__all__ = ["HTMLEntity"]



+ 1
- 1
mwparserfromhell/nodes/tag.py 파일 보기

@@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from mwparserfromhell.nodes import Node, Text
from . import Node, Text

__all__ = ["Tag"]



+ 3
- 3
mwparserfromhell/nodes/template.py 파일 보기

@@ -23,9 +23,9 @@
from collections import defaultdict
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"]



+ 1
- 1
mwparserfromhell/nodes/text.py 파일 보기

@@ -20,7 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from mwparserfromhell.nodes import Node
from . import Node

__all__ = ["Text"]



+ 1
- 1
mwparserfromhell/parser/__init__.py 파일 보기

@@ -20,4 +20,4 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from mwparserfromhell.parser.demo import DemoParser as Parser
from .demo import DemoParser as Parser

+ 4
- 4
mwparserfromhell/parser/demo.py 파일 보기

@@ -20,10 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# 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"]



+ 40
- 37
mwparserfromhell/smart_list.py 파일 보기

@@ -53,7 +53,16 @@ class SmartList(list):
if stop >= key.stop and stop != sys.maxint:
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):
return self.__getitem__(slice(start, stop))
@@ -64,17 +73,14 @@ class SmartList(list):
def __delslice__(self, 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):
super(SmartList, self).append(item)
@@ -82,21 +88,21 @@ class SmartList(list):
if stop >= len(self) - 1 and stop != sys.maxint:
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):
@@ -108,19 +114,19 @@ class _ListProxy(list):
def __repr__(self):
return repr(self._render())

__lt__
#__lt__

__le__
#__le__

__eq__
#__eq__

__ne__
#__ne__

__gt__
#__gt__

__ge__
#__ge__

__nonzero__
#__nonzero__

def __len__(self):
return (self._stop - self._start) / self._step
@@ -136,7 +142,7 @@ class _ListProxy(list):
else:
self._parent[self._start + index] = item

__delitem__
#__delitem__

def __iter__(self):
i = self._start
@@ -162,17 +168,14 @@ class _ListProxy(list):
def __delslice__(self, 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
def _start(self):
@@ -208,9 +211,9 @@ class _ListProxy(list):
def insert(self, index, item):
self._parent.insert(self._start + index, item)

pop
#pop

remove
#remove

def reverse(self):
item = self._render()


+ 1
- 1
mwparserfromhell/utils.py 파일 보기

@@ -21,7 +21,7 @@
# SOFTWARE.

import mwparserfromhell
from mwparserfromhell.nodes import Node
from .nodes import Node

def parse_anything(value):
wikicode = mwparserfromhell.wikicode.Wikicode


+ 3
- 3
mwparserfromhell/wikicode.py 파일 보기

@@ -23,9 +23,9 @@
import re
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"]



불러오는 중...
취소
저장