Skip to content
Snippets Groups Projects
Commit f391c960 authored by Julien (jvoisin) Voisin's avatar Julien (jvoisin) Voisin
Browse files

Change a bit the source code organisation

parent 088c3d01
No related branches found
No related tags found
No related merge requests found
#!/bin/env python3
\ No newline at end of file
File moved
File moved
File moved
...@@ -2,12 +2,12 @@ import mimetypes ...@@ -2,12 +2,12 @@ import mimetypes
import importlib import importlib
import pkgutil import pkgutil
from .parsers import abstract from . import abstract
for module_loader, name, ispkg in pkgutil.walk_packages('.src.parsers'): for module_loader, name, ispkg in pkgutil.walk_packages('.src'):
if not name.startswith('src.parsers.'): if not name.startswith('src.'):
continue continue
elif name == 'src.parsers.abstract': elif name == 'src.abstract':
continue continue
importlib.import_module(name) importlib.import_module(name)
...@@ -16,4 +16,5 @@ def get_parser(filename: str): ...@@ -16,4 +16,5 @@ def get_parser(filename: str):
for c in abstract.AbstractParser.__subclasses__(): for c in abstract.AbstractParser.__subclasses__():
if mtype in c.mimetypes: if mtype in c.mimetypes:
return c(filename) return c(filename)
print('Nope') print('factory: %s is not supported' % mtype)
return None
File moved
File moved
...@@ -4,8 +4,7 @@ import unittest ...@@ -4,8 +4,7 @@ import unittest
import shutil import shutil
import os import os
from src import parsers from src import pdf, png, jpg, audio, office
from src.parsers import pdf, png, jpg, audio
class TestGetMeta(unittest.TestCase): class TestGetMeta(unittest.TestCase):
def test_pdf(self): def test_pdf(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment