Beispiel #1
0
    def get_objects(self, prefix='a'):
        """
        returns the packages beginning with prefix
        and belonging to suite if specified.
        """
        prefix = prefix.lower()
        suite = request.args.get("suite") or ""
        suite = suite.lower()
        if suite == "all":
            suite = ""
        if prefix in qry.pkg_names_get_packages_prefixes(
                app.config["CACHE_DIR"]):
            try:
                if not suite:
                    packages = qry.get_pkg_filter_prefix(session,
                                                         prefix).all()
                else:
                    packages = qry.get_pkg_filter_prefix(session,
                                                         prefix,
                                                         suite).all()

                packages = [p.to_dict() for p in packages]
            except Exception as e:
                raise Http500Error(e)
            return dict(packages=packages,
                        prefix=prefix,
                        suite=suite)
        else:
            raise Http404Error("prefix unknown: %s" % str(prefix))
Beispiel #2
0
 def test_packages_prefixes(self):
     self.assertEqual(
         qry.pkg_names_get_packages_prefixes(
             self.app_wrapper.app.config["CACHE_DIR"]), [
                 'b', 'c', 'd', 'f', 'g', 'l', 'libc', 'm', 'n', 'o', 'p',
                 's', 'u'
             ])
Beispiel #3
0
    def get_objects(self, prefix='a'):
        """
        returns the packages beginning with prefix
        and belonging to suite if specified.
        """
        prefix = prefix.lower()
        suite = request.args.get("suite") or ""
        suite = suite.lower()
        if suite == "all":
            suite = ""
        if prefix in qry.pkg_names_get_packages_prefixes(
                app.config["CACHE_DIR"]):
            try:
                if not suite:
                    packages = qry.get_pkg_filter_prefix(session,
                                                         prefix).all()
                else:
                    packages = qry.get_pkg_filter_prefix(session,
                                                         prefix,
                                                         suite).all()

                packages = [p.to_dict() for p in packages]
            except Exception as e:
                raise Http500Error(e)
            return dict(packages=packages,
                        prefix=prefix,
                        suite=suite)
        else:
            raise Http404Error("prefix unknown: %s" % str(prefix))
Beispiel #4
0
 def test_packages_prefixes(self):
     self.assertEqual(
         qry.pkg_names_get_packages_prefixes(
             self.app_wrapper.app.config["CACHE_DIR"]),
         [
             "a", "b", "c", "d", "f", "g", "l", "libc", "m", "n", "o", "p",
             "s", "u"
         ],
     )
Beispiel #5
0
def skeleton_variables():
    update_ts_file = os.path.join(app.config['CACHE_DIR'], 'last-update')
    # TODO, this part should be moved to per blueprint context processor
    last_update = local_info.read_update_ts(update_ts_file)

    packages_prefixes = qry.pkg_names_get_packages_prefixes(
        app.config["CACHE_DIR"])

    credits_file = os.path.join(app.config["LOCAL_DIR"], "credits.html")
    credits = local_info.read_html(credits_file)

    return dict(packages_prefixes=packages_prefixes,
                searchform=SearchForm(),
                last_update=last_update,
                credits=credits)
Beispiel #6
0
def skeleton_variables():
    update_ts_file = os.path.join(app.config['CACHE_DIR'], 'last-update')
    # TODO, this part should be moved to per blueprint context processor
    last_update = local_info.read_update_ts(update_ts_file)

    packages_prefixes = qry.pkg_names_get_packages_prefixes(
        app.config["CACHE_DIR"])

    credits_file = os.path.join(app.config["LOCAL_DIR"], "credits.html")
    credits = local_info.read_html(credits_file)

    return dict(packages_prefixes=packages_prefixes,
                searchform=SearchForm(),
                last_update=last_update,
                credits=credits,
                name=app.import_name)
Beispiel #7
0
 def test_packages_prefixes(self):
     self.assertEqual(qry.pkg_names_get_packages_prefixes(
         self.app_wrapper.app.config["CACHE_DIR"]),
         ['b', 'c', 'd', 'f', 'g', 'l', 'libc', 'm',
          'n', 'o', 'p', 's', 'u'])