diff --git a/swh/indexer/__init__.py b/swh/indexer/__init__.py index 7bf9448..1d36165 100644 --- a/swh/indexer/__init__.py +++ b/swh/indexer/__init__.py @@ -1,30 +1,27 @@ # Copyright (C) 2016 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information -from .mimetype import ContentMimetypeIndexer -from .language import ContentLanguageIndexer -from .ctags import CtagsIndexer - INDEXER_CLASSES = { - 'mimetype': ContentMimetypeIndexer, - 'language': ContentLanguageIndexer, - 'ctags': CtagsIndexer, + 'mimetype': 'swh.indexer.mimetype.ContentMimetypeIndexer', + 'language': 'swh.indexer.language.ContentLanguageIndexer', + 'ctags': 'swh.indexer.ctags.CtagsIndexer', + 'license': 'swh.indexer.license.ContentLicenseIndexer', } TASK_NAMES = { 'orchestrator_all': 'swh.indexer.tasks.SWHOrchestratorAllContentsTask', 'orchestrator_text': 'swh.indexer.tasks.SWHOrchestratorTextContentsTask', 'mimetype': 'swh.indexer.tasks.SWHContentMimetypeTask', 'language': 'swh.indexer.tasks.SWHContentLanguageTask', 'ctags': 'swh.indexer.tasks.SWHCtagsTask', + 'license': 'swh.indexer.tasks.SWHContentLicenseTask', } __all__ = [ 'INDEXER_CLASSES', 'TASK_NAMES', - 'ContentMimetypeIndexer', 'ContentLanguageIndexer', 'CtagsIndexer', ] diff --git a/swh/indexer/tasks.py b/swh/indexer/tasks.py index 611294d..8fd5876 100644 --- a/swh/indexer/tasks.py +++ b/swh/indexer/tasks.py @@ -1,62 +1,75 @@ # Copyright (C) 2016 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information from swh.scheduler.task import Task from .orchestrator import OrchestratorAllContentsIndexer from .orchestrator import OrchestratorTextContentsIndexer -from . import ContentMimetypeIndexer, ContentLanguageIndexer, CtagsIndexer +from .mimetype import ContentMimetypeIndexer +from .language import ContentLanguageIndexer +from .ctags import CtagsIndexer +from .license import ContentLicenseIndexer class SWHOrchestratorAllContentsTask(Task): """Main task in charge of reading batch contents (of any type) and broadcasting them back to other tasks. """ task_queue = 'swh_indexer_orchestrator_content_all' def run(self, *args, **kwargs): OrchestratorAllContentsIndexer().run(*args, **kwargs) class SWHOrchestratorTextContentsTask(Task): """Main task in charge of reading batch contents (of type text) and broadcasting them back to other tasks. """ task_queue = 'swh_indexer_orchestrator_content_text' def run(self, *args, **kwargs): OrchestratorTextContentsIndexer().run(*args, **kwargs) class SWHContentMimetypeTask(Task): """Task which computes the mimetype, encoding from the sha1's content. """ task_queue = 'swh_indexer_content_mimetype' def run(self, *args, **kwargs): ContentMimetypeIndexer().run(*args, **kwargs) class SWHContentLanguageTask(Task): """Task which computes the language from the sha1's content. """ task_queue = 'swh_indexer_content_language' def run(self, *args, **kwargs): ContentLanguageIndexer().run(*args, **kwargs) class SWHCtagsTask(Task): """Task which computes ctags from the sha1's content. """ task_queue = 'swh_indexer_content_ctags' def run(self, *args, **kwargs): CtagsIndexer().run(*args, **kwargs) + + +class SWHContentLicenseTask(Task): + """Task which computes licenses from the sha1's content. + + """ + task_queue = 'swh_indexer_content_license' + + def run(self, *args, **kwargs): + ContentLicenseIndexer().run(*args, **kwargs)