Пример #1
0
    def __init__(self):
        self.analyzers = {}
        plugin_mgr = DAMNPluginManagerSingleton.get()

        for plugin in plugin_mgr.getPluginsOfCategory('Analyzer'):
            if plugin.plugin_object.is_activated:
                for mimetype in plugin.plugin_object.handled_types:
                    self.analyzers[mimetype] = plugin
Пример #2
0
    def __init__(self):
        self.analyzers = {}
        plugin_mgr = DAMNPluginManagerSingleton.get()

        for plugin in plugin_mgr.getPluginsOfCategory('Analyzer'):
            if plugin.plugin_object.is_activated:
                for mimetype in plugin.plugin_object.handled_types:
                    self.analyzers[mimetype] = plugin
Пример #3
0
    def __init__(self):
        self.analyzers = {}
        plugin_mgr = DAMNPluginManagerSingleton.get()

        for plugin in plugin_mgr.getPluginsOfCategory('Analyzer'):
            if plugin.plugin_object.is_activated:
                for mimetype in plugin.plugin_object.handled_types:
                    analyzer = self.analyzers.setdefault(mimetype, [])
                    if plugin not in analyzer:
                        analyzer.append(plugin)
Пример #4
0
    def __init__(self, path):
        self._path = path
        self.transcoders = {}
        plugin_mgr = DAMNPluginManagerSingleton.get()

        for plugin in plugin_mgr.getPluginsOfCategory('Transcoder'):
            if plugin.plugin_object.is_activated:
                for src, _ in plugin.plugin_object.convert_map.items():
                    if not src in self.transcoders:
                        self.transcoders[src] = []
                    self.transcoders[src].append(plugin)

        self._build_target_mimetypes()
Пример #5
0
    def test_transcoder_constructor(self, stat, is_existing_file, guess_type):
        guess_type.return_value = ['some/mime', None]
        is_existing_file.return_value = True
        mock = MockDAMNPluginManager()
        DAMNPluginManagerSingleton.get = classmethod(lambda x: mock)
        assert mock == DAMNPluginManagerSingleton.get()
        transcoder = Transcoder('dstpath')

        target_mimes = transcoder.get_target_mimetypes()

        assert 'some/mime' in target_mimes
        assert 'some/other' in target_mimes

        target_mime = transcoder.get_target_mimetype('some/mime', 'some/mime')
Пример #6
0
    def test_analyzer_constructor(self, stat, is_existing_file, guess_type):
        guess_type.return_value = ['some/mime', None]
        is_existing_file.return_value = True
        mock = MockDAMNPluginManager()
        DAMNPluginManagerSingleton.get = classmethod(lambda x: mock)
        assert mock == DAMNPluginManagerSingleton.get()
        analyzer = Analyzer()

        mime_types = analyzer.get_supported_mimetypes()
        assert 'some/mime' in mime_types
        assert 'some/other' in mime_types

        descr = analyzer.analyze_file('somefakefile')
        assert descr is not None

        is_existing_file.return_value = False
        self.assertRaises(AnalyzerException, analyzer.analyze_file, 'somefakefile')


        is_existing_file.return_value = True
        guess_type.return_value = ['mime/thatwedonthave', None]
        self.assertRaises(AnalyzerException, analyzer.analyze_file, 'somefakefile')
Пример #7
0
    def test_analyzer_constructor(self, stat, is_existing_file, guess_type):
        guess_type.return_value = ['some/mime', None]
        is_existing_file.return_value = True
        mock = MockDAMNPluginManager()
        DAMNPluginManagerSingleton.get = classmethod(lambda x: mock)
        assert mock == DAMNPluginManagerSingleton.get()
        analyzer = Analyzer()

        mime_types = analyzer.get_supported_mimetypes()
        assert 'some/mime' in mime_types
        assert 'some/other' in mime_types

        descr = analyzer.analyze_file('somefakefile')
        assert descr is not None

        is_existing_file.return_value = False
        self.assertRaises(AnalyzerException, analyzer.analyze_file,
                          'somefakefile')

        is_existing_file.return_value = True
        guess_type.return_value = ['mime/thatwedonthave', None]
        self.assertRaises(AnalyzerException, analyzer.analyze_file,
                          'somefakefile')