Browse Source

Applying latest commit from develop

tags/v0.3
Ben Kurtovic 11 years ago
parent
commit
d8814968b7
1 changed files with 11 additions and 8 deletions
  1. +11
    -8
      mwparserfromhell/parser/__init__.py

+ 11
- 8
mwparserfromhell/parser/__init__.py View File

@@ -26,16 +26,16 @@ modules: the :py:mod:`~.tokenizer` and the :py:mod:`~.builder`. This module
joins them together under one interface. joins them together under one interface.
""" """


from .builder import Builder
from .tokenizer import Tokenizer
try: try:
from ._builder import CBuilder as Builder
from ._tokenizer import CTokenizer
use_c = True
except ImportError: except ImportError:
from .builder import Builder
try:
from ._tokenizer import CTokenizer as Tokenizer
except ImportError:
from .tokenizer import Tokenizer
CTokenizer = None
use_c = False


__all__ = ["Parser"]
__all__ = ["use_c", "Parser"]


class Parser(object): class Parser(object):
"""Represents a parser for wikicode. """Represents a parser for wikicode.
@@ -48,7 +48,10 @@ class Parser(object):


def __init__(self, text): def __init__(self, text):
self.text = text self.text = text
self._tokenizer = Tokenizer()
if use_c and CTokenizer:
self._tokenizer = CTokenizer()
else:
self._tokenizer = Tokenizer()
self._builder = Builder() self._builder = Builder()


def parse(self): def parse(self):


Loading…
Cancel
Save