def from_filename(self, filename):
        '''
        Convert an absolute filename into key.
        '''
        i = len(self.base_directory)
        if filename[:i] != self.base_directory:
            raise ValueError('Filename needs to start with "%s";\nyou passed "%s".' % (self.base_directory, filename))

        if filename.endswith(self.extension):
            if len(self.extension) > 0:
                j = -len(self.extension)
            else:
                j = None
            return self.key_transformer.from_path(tuple(filename[i:j].strip('/').split('/')))
Convert an absolute filename into key.