Skip to content
Snippets Groups Projects
Select Git revision
  • handle_html
  • master default protected
  • add_epub
  • #96
  • office
  • refactor_office
  • implement_lightweight_mode_msoffice
  • 0.7.0
  • 0.6.0
  • 0.5.0
  • 0.4.0
  • 0.3.1
  • 0.3.0
  • 0.2.0
  • 0.1.3
  • 0.1.2
  • 0.1.1
  • 0.1.0
18 results

CONTRIBUTING.md

Blame
  • Forked from jvoisin / mat2
    Source project has a limited visibility.
    After you've reviewed these contribution guidelines, you'll be all set to contribute to this project.
    parser_factory.py 600 B
    import mimetypes
    import importlib
    import pkgutil
    
    from . import abstract
    
    from typing import Type, TypeVar
    
    T = TypeVar('T', bound='abstract.AbstractParser')
    
    for module_loader, name, ispkg in pkgutil.walk_packages('.src'):
        if not name.startswith('src.'):
            continue
        elif name == 'src.abstract':
            continue
        importlib.import_module(name)
    
    def get_parser(filename: str) -> (T, str):
        mtype, _ = mimetypes.guess_type(filename)
        for c in abstract.AbstractParser.__subclasses__():
            if mtype in c.mimetypes:
                return c(filename), mtype
        return None, mtype