Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 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()
Exemplo n.º 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')
Exemplo n.º 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')
Exemplo n.º 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')