예제 #1
0
    def Parse(self, path):
        result = []

        for package in os.listdir(path):
            package_path = os.path.join(path, package)
            if not os.path.isdir(package_path):
                continue

            for cygport in os.listdir(package_path):
                if not cygport.endswith('.cygport'):
                    continue

                # XXX: save *bl* to origversion
                match = re.match('(.*)-[0-9]+bl[0-9]+\.cygport$', cygport)

                if not match:
                    print('WARNING: unable to parse cygport: {}'.format(cygport), file=sys.stderr)
                    continue

                pkg = Package()
                pkg.name, version = SplitPackageNameVersion(match.group(1))
                pkg.version, pkg.origversion = SanitizeVersion(version)

                result.append(pkg)

        return result
예제 #2
0
    def Parse(self, path):
        result = []

        with open(path, encoding='utf-8') as file:
            reader = csv.reader(file, delimiter='|')
            for row in reader:
                pkg = Package()

                pkgname = row[0]

                # cut away string suffixws which come after version
                match = re.match('(.*?)(-[a-z_]+[0-9]*)+$', pkgname)
                if match is not None:
                    pkgname = match.group(1)

                pkg.name, version = SplitPackageNameVersion(pkgname)
                pkg.version, pkg.origversion = SanitizeVersion(version)
                pkg.comment = row[3]
                pkg.maintainers = GetMaintainers(row[5])
                pkg.category = row[6].split(' ')[0].strip()

                origin = row[1].rsplit(',', 1)[0]
                pkg.extrafields['portname'] = origin.split('/')[1]
                pkg.extrafields['origin'] = origin

                result.append(pkg)

        return result
예제 #3
0
파일: freebsd.py 프로젝트: mojca/repology
    def Parse(self, path):
        result = []

        with open(path, encoding='utf-8') as indexfile:
            for line in indexfile:
                fields = line.strip().split('|')
                if len(fields) != 13:
                    print(
                        'WARNING: package {} skipped, incorrect number of fields in INDEX'
                        .format(fields[0]),
                        file=sys.stderr)
                    continue

                pkg = Package()

                pkg.name, version = SplitPackageNameVersion(fields[0])
                pkg.version, pkg.origversion = SanitizeVersion(version)
                pkg.comment = fields[3]
                pkg.maintainers = GetMaintainers(fields[5])
                pkg.category = fields[6].split(' ')[0]

                if fields[9]:
                    pkg.homepage = fields[9]

                result.append(pkg)

        return result
예제 #4
0
파일: pkgsrc.py 프로젝트: mojca/repology
    def Parse(self, path):
        result = []

        with open(path, encoding='utf-8') as indexfile:
            for line in indexfile:
                fields = line.strip().split('|')
                if len(fields) != 12:
                    print('WARNING: package {} skipped, incorrect number of fields in INDEX'.format(fields[0]), file=sys.stderr)
                    continue

                pkg = Package()

                pkg.name, version = SplitPackageNameVersion(fields[0])
                pkg.version, pkg.origversion = SanitizeVersion(version)
                pkg.comment = fields[3]
                if fields[11]:
                    pkg.homepage = fields[11]

                # sometimes OWNER variable is used in which case
                # there's no MAINTAINER OWNER doesn't get to INDEX
                pkg.maintainers = GetMaintainers(fields[5])

                pkg.category = fields[6].split(' ')[0]

                result.append(pkg)

        return result
예제 #5
0
파일: cpan.py 프로젝트: mojca/repology
    def Parse(self, path):
        # Since data we get from CPAN is somewhat lacking, we need
        # somewhat complex parsing. Here's the example of what we get
        # in 02packages.details.txt package index downloaded from CPAN:
        #
        # Acme::constant                 0.001003  G/GL/GLITCHMR/Acme-constant-0.1.3.tar.gz
        # Acme::Constructor::Pythonic       0.002  T/TO/TOBYINK/Acme-Constructor-Pythonic-0.002.tar.gz
        # Acme::Continent                   undef  P/PE/PERIGRIN/XML-Toolkit-0.15.tar.gz
        #
        # 1. Module version (second column) does not always correspond
        #    to package version (which we need), so we need to parse
        #    package filename. The version may also be undefined.
        # 2. All package modules are listed, and we don't need them
        #    (which is not the problem as CPAN repo is shadow anyway)
        #
        # So we do out best to parse filename into package name and
        # actual version, and filter entries where module name is
        # equal to package name. Some entries are lost, some entries
        # are not even in 02packages.details.txt, some are unparsable
        # (no version, or garbage in version) but these are negligible.
        result = []

        with open(path) as packagesfile:
            parsing = False
            for line in packagesfile:
                line = line.strip()

                if not parsing:
                    if line == '':
                        parsing = True
                    continue

                module, version, package = re.split(r'[ \t]+', line)

                package_path, package_file = package.rsplit('/', 1)
                package_name = None

                if package_file.endswith('.tar.gz'):
                    package_name = package_file[0:-7]
                elif package_file.endswith('.tar.bz2'):
                    package_name = package_file[0:-8]
                elif package_file.endswith('.zip') or package_file.endswith(
                        '.tgz'):
                    package_name = package_file[0:-4]

                if package_name is None or package_name.find('-') == -1:
                    # Bad package name; XXX: log?
                    continue

                package_name, package_version = SplitPackageNameVersion(
                    package_name)
                if package_version.startswith(
                        'v') or package_version.startswith('V'):
                    package_version = package_version[1:]

                if not re.match('[0-9]', package_version):
                    # Bad version; XXX: log?
                    continue

                if module.replace('::', '-') != package_name:
                    # Submodules not really needed
                    continue

                pkg = Package()
                pkg.name = package_name
                pkg.version = package_version

                pkg.maintainers = GetMaintainers(
                    package_path.split('/')[2].lower() + '@cpan')
                pkg.homepage = 'http://search.cpan.org/dist/' + package_name + '/'

                result.append(pkg)

        return result