Exemple #1
0
def _parse_html(index_url, folder, project_name, version=None):
    # TODO: use correct encoding
    html_content = urlopen(index_url).read().decode('utf-8')
    artifacts = []
    found_versions = set()
    for match in re.finditer(link_pattern, html_content):
        link = match.group(1)
        if index_url.endswith('/'):
            url = index_url + link
        elif index_url.endswith('.html'):
            url = index_url.rsplit('/', 1)[0] + '/' + link
        else:
            url = index_url + '/' + link
        if '#' in link:
            # TODO: parse digest info to detect any file content corruption
            link, _ = link.split('#', 1)
        if '/' in link:
            _, filename = link.rsplit('/', 1)
        else:
            filename = link
        try:
            _, file_version, _, _ = parse_filename(filename,
                                                   project_name=project_name)
        except ValueError:
            # not a supported artifact
            continue

        if version is not None and file_version != version:
            found_versions.add(file_version)
            continue

        artifacts.append((url, os.path.join(folder, filename)))
    return artifacts, list(sorted(found_versions))
Exemple #2
0
def _parse_html(index_url, folder, project_name, version=None):
    # TODO: use correct encoding
    html_content = urlopen(index_url).read().decode('utf-8')
    artifacts = []
    found_versions = set()
    for match in re.finditer(link_pattern, html_content):
        link = match.group(1)
        if index_url.endswith('/'):
            url = index_url + link
        elif index_url.endswith('.html'):
            url = index_url.rsplit('/', 1)[0] + '/' + link
        else:
            url = index_url + '/' + link
        if '#' in link:
            # TODO: parse digest info to detect any file content corruption
            link, _ = link.split('#', 1)
        if '/' in link:
            _, filename = link.rsplit('/', 1)
        else:
            filename = link
        try:
            _, file_version, _, _ = parse_filename(filename,
                                                   project_name=project_name)
        except ValueError:
            # not a supported artifact
            continue

        if version is not None and file_version != version:
            found_versions.add(file_version)
            continue

        artifacts.append((url, os.path.join(folder, filename)))
    return artifacts, list(sorted(found_versions))
Exemple #3
0
    def run(self):
        metadata = self.distribution.metadata
        project_name = metadata.get_name()
        version = safe_version(metadata.get_version())
        print("Collecting artifacts for %s==%s in 'dist' folder:" %
              (project_name, version))
        dist_files = []
        for filename in os.listdir('dist'):
            try:
                _, file_version, pyversion, command = parse_filename(
                    filename, project_name=project_name)
                if file_version != version:
                    continue
            except ValueError:
                continue
            filepath = os.path.join('dist', filename)
            dist_files.append((command, pyversion, filepath))

        if not dist_files:
            raise DistutilsOptionError(
                "No file collected from the 'dist' folder")

        for command, pyversion, filepath in dist_files:
            self.upload_file(command, pyversion, filepath)
Exemple #4
0
    def run(self):
        metadata = self.distribution.metadata
        project_name = metadata.get_name()
        version = safe_version(metadata.get_version())
        print("Collecting artifacts for %s==%s in 'dist' folder:" %
              (project_name, version))
        dist_files = []
        for filename in os.listdir('dist'):
            try:
                _, file_version, pyversion, command = parse_filename(
                    filename, project_name=project_name)
                if file_version != version:
                    continue
            except ValueError:
                continue
            filepath = os.path.join('dist', filename)
            dist_files.append((command, pyversion, filepath))

        if not dist_files:
            raise DistutilsOptionError(
                "No file collected from the 'dist' folder")

        for command, pyversion, filepath in dist_files:
            self.upload_file(command, pyversion, filepath)