Commits

Anonymous committed ec6e52d

hachoir-parser:
* Rename Parser to HachoirParser and HachoirParser don't inherint from any other class
* Create new Parser: inherint from HachoirParser and GenericParser

  • Participants
  • Parent commits 9d0f281

Comments (0)

Files changed (3)

File hachoir-parser/hachoir_parser/__init__.py

 __version__ = "0.8.0"
 
-from hachoir_parser.parser import Parser
+from hachoir_parser.parser import HachoirParser, Parser
 from hachoir_parser.parser_list import ParserList, HachoirParserList
 from hachoir_parser.guess import (guessParser,
     parseStream, createParser, createEditor)

File hachoir-parser/hachoir_parser/parser.py

 from hachoir_core.error import HACHOIR_ERRORS, error
 from hachoir_core.tools import makePrintable
 
-class Parser(GenericParser):
+class HachoirParser:
     """
     A parser is the root of all other fields. It create first level of fields
     and have special attributes and methods:
       None otherwise).
     """
 
-    def __init__(self, stream):
-        # Call parent constructor
-        GenericParser.__init__(self, stream, None)
+    def __init__(self):
         self._mime_type = None
 
     #--- Methods that can be overridden -------------------------------------
         return self._filename_extension
     filename_suffix = property(_getFilenameSuffix)
 
+class Parser(HachoirParser, GenericParser):
+    def __init__(self, stream):
+        GenericParser.__init__(self, stream, None)
+        HachoirParser.__init__(self)
+

File hachoir-parser/hachoir_parser/parser_list.py

 import types
 from hachoir_core.error import HachoirError
 from hachoir_core.i18n import _
-from hachoir_parser import Parser
+from hachoir_parser import HachoirParser
 from hachoir_core import config
 
 ### Parser list ################################################################
             attributes = ( getattr(module, name) for name in dir(module) )
             parsers = list( attr for attr in attributes \
                 if isinstance(attr, type) \
-                   and issubclass(attr, Parser) \
+                   and issubclass(attr, HachoirParser) \
                    and hasattr(attr, "tags"))
             for parser in parsers:
                 self.add(parser)