buildframework/helium/sf/python/pythoncore/lib/archive/scanners.py
author wbernard
Fri, 13 Aug 2010 14:59:05 +0300
changeset 628 7c4a911dc066
parent 587 85df38eb4012
child 645 b8d81fa19e7d
permissions -rw-r--r--
helium_11.0.0-e00f171ca185
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     1
#============================================================================ 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     2
#Name        : scanners.py 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     3
#Part of     : Helium 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     4
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     5
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     6
#All rights reserved.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     7
#This component and the accompanying materials are made available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     8
#under the terms of the License "Eclipse Public License v1.0"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     9
#which accompanies this distribution, and is available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    10
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    11
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    12
#Initial Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    13
#Nokia Corporation - initial contribution.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    14
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    15
#Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    16
#
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    17
#Description:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
#===============================================================================
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    19
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    20
""" Implementation of the available scanner for """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    21
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    22
import os
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    23
import fileutils
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    24
import logging
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    25
import codecs
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    26
import pathaddition
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    28
import archive.selectors
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    29
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
_logger = logging.getLogger('archive.scanners')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
_logger_abld = logging.getLogger('archive.scanners.abld')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
logging.basicConfig()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
#logger_abld.setLevel(logging.DEBUG)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    34
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
class Scanner(fileutils.AbstractScanner):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
    """ Abstract class that represent and input source. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    38
    def __init__(self, config):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
        fileutils.AbstractScanner.__init__(self)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
        self._config = config
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
        self.setup()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
    def setup(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
        """ Setting up the scanner. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
        [self.add_include(inc) for inc in self._config.get_list('include', [])]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
        [self.add_exclude(ex) for ex in self._config.get_list('exclude', [])]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
        [self.add_exclude_file(ex) for ex in self._config.get_list('exclude_file', [])]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    48
        [self.add_exclude_lst(filename) for filename in self._config.get_list('exclude.lst', [])]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
        [self.add_filetype(filetype) for filetype in self._config.get_list('filetype', [])]
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    50
        [self.add_selector(archive.selectors.get_selector(selector, self._config)) for selector in self._config.get_list('selector', [])]
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
        # To support old features.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
        # TODO: inform customers and remove.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53
        if 'distribution.policy.s60' in self._config:
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    54
            self.add_selector(archive.selectors.get_selector('distribution.policy.s60', self._config))
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    56
    def add_exclude_lst(self, filename):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    57
        """ Adding excludes from exclude list. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    58
        if not os.path.exists(filename):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    59
            raise Exception("Could not find '%s'." % filename)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    60
        root_dir = os.path.normpath(self._config['root.dir'])
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    61
        flh = codecs.open(filename, 'r', 'utf-8')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    62
        for line in flh:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    63
            path = os.path.normpath(line.strip())
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
            if os.path.splitdrive(root_dir)[0] != "":
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    65
                path = os.path.join(os.path.splitdrive(root_dir)[0], path)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    66
            if fileutils.destinsrc(root_dir, path):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    67
                pathrel = pathaddition.relative.abs2rel(path, root_dir)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    68
                _logger.debug("pathrel: %s" % (pathrel))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    69
                self.add_exclude(pathrel)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    70
            else:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    71
                _logger.warning("path '%s' is not under '%s', ignoring." % (path, root_dir))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    72
        flh.close()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    73
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    74
    def scan(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    75
        """ Generator method that scan the relevant input source.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    76
            This method need to be overloaded by the specialized class.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    77
            return fullpath name
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    78
        """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    79
        raise  NotImplementedError()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    80
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    81
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    82
class AbldWhatScanner(Scanner):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    83
    """ Scanning the filesystem. """    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    84
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    85
    def __init__(self, config):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    86
        Scanner.__init__(self, config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    87
        self.root_dir = unicode(os.path.normpath(self._config['root.dir']))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    88
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    89
    def scan(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    90
        """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    91
            Abld what commands.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    92
            include property have not effect on the selection mechanism.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    93
        """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    94
        os.environ["SYMBIANBUILD_DEPENDENCYOFF"] = "1"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    95
        for path in self._config.get_list('abld.exportpath', []):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    96
            _logger_abld.debug("abld.exportpath: %s" % path)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    97
            if os.path.exists(os.path.join(self.root_dir, path, 'bld.inf')):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    98
                os.chdir(os.path.join(self.root_dir, path))                
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    99
                os.popen('bldmake bldfiles -k')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   100
                for result in self._scan_abld_what("abld export -what -k"):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   101
                    yield result
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   102
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   103
        for path in self._config.get_list('abld.buildpath', []):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   104
            _logger_abld.debug("abld.buildpath: %s" % path)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   105
            if os.path.exists(os.path.join(self.root_dir, path, 'bld.inf')):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   106
                for type_ in self._config.get_list('abld.type', ['armv5']):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   107
                    os.environ["EPOCROOT"] = self._config.get('abld.epocroot','\\')
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   108
                    os.environ["PATH"] = os.environ["EPOCROOT"] + "epoc32\\tools;" + os.environ["EPOCROOT"] + "epoc32\\gcc\\bin;" + os.environ["PATH"]
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   109
                    _logger_abld.debug("abld.type: %s" % type_)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   110
                    os.chdir(os.path.join(self.root_dir, path))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   111
                    os.popen("bldmake bldfiles -k")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   112
                    os.popen("abld makefile %s -k" % type_)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   113
                    for result in self._scan_abld_what("abld build -what %s" % type_):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   114
                        yield result
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   115
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   116
    def _run_cmd(self, cmd):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   117
        """ Run command."""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   118
        _logger_abld.debug("command: %s" % cmd)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   119
        process = os.popen(cmd)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   120
        abld_output = process.read()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   121
        err = process.close()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   122
        return (err, abld_output)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   123
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   124
    def _scan_abld_what(self, cmd):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   125
        """ Abld what output parser."""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   126
        (_, abld_output) = self._run_cmd(cmd)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   127
        _logger_abld.debug("abld_output: %s" % abld_output)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   128
        for what_path in abld_output.split("\n"):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   129
            what_path = what_path.strip()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   130
            if (what_path.startswith('\\') or what_path.startswith('/')) and self.is_filetype(what_path) \
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   131
                and not self.is_excluded(what_path) and self.is_selected(what_path):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   132
                if os.path.exists(what_path):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   133
                    _logger_abld.debug("adding: %s" % what_path)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   134
                    yield what_path
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   135
                else:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   136
                    _logger.error("Could not find '%s'." % what_path)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   137
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   138
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   139
class FileSystemScanner(fileutils.FileScanner, Scanner):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   140
    """ Scanning the filesystem. """    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   141
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   142
    def __init__(self, config):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   143
        fileutils.FileScanner.__init__(self, unicode(os.path.normpath(config['root.dir'])))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   144
        Scanner.__init__(self, config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   145
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   146
    def scan(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   147
        """ 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   148
            Implement the scanning of the filesystem.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   149
            Actually delegate scanning of a directory to Filescanner.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   150
        """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   151
        for path in fileutils.FileScanner.scan(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   152
            yield path
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   153
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   154
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   155
class InputFileScanner(fileutils.FileScanner, Scanner):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   156
    """ Scanning the filesystem. """    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   157
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   158
    def __init__(self, config):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   159
        """ Initialisation. """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   160
        fileutils.FileScanner.__init__(self, unicode(os.path.normpath(config['root.dir'])))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   161
        Scanner.__init__(self, config)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   162
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   163
    def scan(self):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   164
        """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   165
        ::
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   166
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   167
            <set name="scanners" value="input.file"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   168
            <set name="root.dir" value="${build.drive}"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   169
            <set name="input.files" value="file1.lst,file2.lst,file3.lst"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   170
            <set name="exclude" value="epoc32/**/*.dll"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   171
        """
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   172
        for input_file in self._config.get_list('input.files', []):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   173
            _logger.info("Include content from: %s" % input_file)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   174
            handle = open(input_file, "r")
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   175
            for line in handle.readlines():
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   176
                path = os.path.join(self._config['root.dir'], line.strip())
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   177
                if os.path.exists(path):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   178
                    if self.is_filetype(path) \
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   179
                        and not self.is_excluded(path) and self.is_selected(path):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   180
                        yield path
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   181
                else:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   182
                    _logger.info("File not found: %s" % path)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   183
            handle.close()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   184
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   185
__scanners = {'default': FileSystemScanner,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   186
              'input.file': InputFileScanner,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   187
              'abld.what': AbldWhatScanner,
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   188
              }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   189
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   190
def get_scanners(names, config):
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   191
    """get scanners"""
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   192
    result = []
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   193
    for name in names:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   194
        if name in __scanners:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   195
            result.append(__scanners[name](config))
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   196
        else:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   197
            raise Exception("ERROR: Could not find scanner '%s'." % name)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   198
    return result