Esempio n. 1
0
    def _choose_version_dir(self, package_dir, version):

        # get versions on disk
        version_dirs = get_package_versions(package_dir, True)

        if not version_dirs:
            return None

        # return most recent version
        unparse = unparse_version
        if not version:
            return os.path.join(package_dir, unparse(version_dirs[-1]))

        version = parse_version(version)
        if version not in version_dirs:
            return None

        else:
            return os.path.join(package_dir, unparse(version))
Esempio n. 2
0
def add_package_dir(package_dir, package_home, repo_dir):
    version = get_package_version(package_dir)

    if not version:
        raise RepositoryException, 'version not specified in package.xml'

    package_name = os.path.basename(package_dir.rstrip(os.path.sep))

    phome = package_home.replace('.', os.path.sep)
    phome = prepare_home(repo_dir, phome, package_name)

    versions = get_package_versions(phome)
    if version in versions:
        raise RepositoryException, 'version %s already exists' % version

    version_dir = os.path.join(phome, version)

    shutil.copytree(package_dir, version_dir)

    return version