def _create_dists(self, email, filename): """ Create a /dists/... file and return it in the appropraite format. ``email`` Email address to filter on. ``filename`` Filename requested. This should be something like: "dists/unstable/main/source/Sources". """ splitfilename = filename.split('/') if not len(splitfilename) == 5: log.error('File not found') abort(404, 'File not found') dists, dist, component, arch, type = filename.split('/') if arch.startswith('binary-'): arch = arch[7:] user = meta.session.query(User).filter_by(email=email).first() if user is None: log.error('User not found') abort(404, 'User not found') repo = Repository(config['debexpo.repository']) if type.startswith('Sources'): out_file = repo.get_sources_file(dist, component, user.id) elif type.startswith('Packages'): out_file = repo.get_packages_file(dist, component, arch, user.id) else: log.error('File not found') abort(404, 'File not found') if type.endswith('.gz'): return zlib.compress(out_file) elif type.endswith('.bz2'): return bz2.compress(out_file) else: return out_file