Esempio n. 1
0
def projects_info(dbo, project_names):
    """Return details about specific projects

    :param dbo: dnf base object
    :type dbo: dnf.Base
    :param project_names: List of names of projects to get info about
    :type project_names: str
    :returns: List of project info dicts with pkg_to_project as well as epoch, version, release, etc.
    :rtype: list of dicts

    If project_names is None it will return the full list of available packages
    """
    if project_names:
        pkgs = dbo.sack.query().available().filter(name__glob=project_names)
    else:
        pkgs = dbo.sack.query().available()

    # iterate over pkgs
    # - if pkg.name isn't in the results yet, add pkg_to_project_info in sorted position
    # - if pkg.name is already in results, get its builds. If the build for pkg is different
    #   in any way (version, arch, etc.) add it to the entry's builds list. If it is the same,
    #   skip it.
    results = []
    results_names = {}
    for p in pkgs:
        if p.name.lower() not in results_names:
            idx = insort_left(results, pkg_to_project_info(p), key=lambda p: p["name"].lower())
            results_names[p.name.lower()] = idx
        else:
            build = pkg_to_build(p)
            if build not in results[results_names[p.name.lower()]]["builds"]:
                results[results_names[p.name.lower()]]["builds"].append(build)

    return results
Esempio n. 2
0
 def test_insort_left_key_dict(self):
     unsorted = [{
         "name": "Maggie"
     }, {
         "name": "Homer"
     }, {
         "name": "Bart"
     }, {
         "name": "Marge"
     }]
     results = []
     for x in unsorted:
         insort_left(results, x, key=lambda p: p["name"].lower())
     self.assertEqual(results, [{
         "name": "Bart"
     }, {
         "name": "Homer"
     }, {
         "name": "Maggie"
     }, {
         "name": "Marge"
     }])
Esempio n. 3
0
 def test_insort_left_key_strings(self):
     unsorted = ["Maggie", "Homer", "Bart", "Marge"]
     results = []
     for x in unsorted:
         insort_left(results, x, key=lambda p: p.lower())
     self.assertEqual(results, ["Bart", "Homer", "Maggie", "Marge"])
Esempio n. 4
0
 def test_insort_left_nokey(self):
     results = []
     for x in range(0, 10):
         insort_left(results, x)
     self.assertEqual(results, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])