コード例 #1
0
    def _search(cls, names, descriptions, operator):
        op_and = lambda x, y: x & y
        op_or = lambda x, y: x | y

        operator_func = ({'or': op_or, 'and': op_and}).get(operator.lower(), op_and)
        result = []

        packages = PackageVersion.select(
            Package.name,
            PackageVersion,
        ).join(Package).where(
            operator_func(
                Package.name in tuple(names),
                PackageVersion.description.contains(descriptions)
            )
        )

        for version in packages:
            pkg_dict = dict(
                name=version.package.name,
                version=str(version.version),
                summary=version.description,
                _pypi_ordering=1,
            )

            result.append(pkg_dict)

        return result
コード例 #2
0
    def get_version(package, version):
        package = normalize_package_name(package)
        q = PackageVersion.select().join(Package).join(PackageFile).where(
            Package.lower_name == package,
            PackageVersion.version == version,
        ).limit(1)

        if not q.count():
            raise HTTPError(404)

        return q[0]
コード例 #3
0
ファイル: version.py プロジェクト: heysion/pypi-server
    def get_version(package, version):
        package = normalize_package_name(package)
        q = PackageVersion.select().join(Package).join(PackageFile).where(
            Package.lower_name == package,
            PackageVersion.version == version,
        ).limit(1)

        if not q.count():
            raise HTTPError(404)

        return q[0]