Ejemplo n.º 1
0
    def __init__(self, fpath = None, default = None):
        # this is used for the default encryption when nothing
        # match the filters from the filter file; if no filter
        # file is specified then this will just always be used
        self.default = None
        if default is not None:
            parts = default.split(',')
            options = ','.join(parts[2:])
            tag = parts[0]
            plugin = parts[1]
            self.default = (tag, plugin, options, None)

        filters = []
        if fpath is not None:
            # load the encryption filter file
            fd = open(fpath, 'rb')
            lines = fd.readlines()
            fd.close()

            for line in lines:
                line = line.strip()
                if line[0] == '#':
                    parts = line[1:].split(',')
                    options = ','.join(parts[2:])
                    tag = parts[0]
                    plugin = parts[1]
                    filter = Filter()
                    filters.append((tag, plugin, options, filter))
                if header is None:
                    logger.debug('junk before header line in encryption filter file [%s]' % line)
                    continue
                filter.parseAndAddFilterLine(line)

        self.filters = filters
Ejemplo n.º 2
0
    def __init__(self, fpath = None, default = None):
        # this is used for the default encryption when nothing
        # match the filters from the filter file; if no filter
        # file is specified then this will just always be used
        self.default = None
        if default is not None:
            parts = default.split(',')
            options = ','.join(parts[2:])
            tag = parts[0]
            plugin = parts[1]
            self.default = (tag, plugin, options, None)

        filters = []
        if fpath is not None:
            # load the encryption filter file
            fd = open(fpath, 'rb')
            lines = fd.readlines()
            fd.close()

            for line in lines:
                line = line.strip()
                if line[0] == '#':
                    parts = line[1:].split(',')
                    options = ','.join(parts[2:])
                    tag = parts[0]
                    plugin = parts[1]
                    filter = Filter()
                    filters.append((tag, plugin, options, filter))
                if header is None:
                    logger.debug('junk before header line in encryption filter file [%s]' % line)
                    continue
                filter.parseAndAddFilterLine(line)

        self.filters = filters