def get_pkgs_match_input(self, input_string):
        # Select package name match input string.

        input_string = input_string.lower()
        pkg_names = []
        argv = [
            "SELECT pkg_name FROM software WHERE pkg_name LIKE ?",
            ("%" + unicode(input_string) + "%", )
        ]

        cache_info = self.get_info_from_cache_soft_db(argv)
        if cache_info:
            for (pkg_name, ) in cache_info:
                pkg_names.append(pkg_name)
        else:
            search_key = "*%s*" % input_string
            software_list = Software.select().where(
                Software.pkg_name % search_key,
                Software.language == self.default_lang_obj)
            for soft in software_list:
                pkg_names.append(soft.pkg_name)

        # Sort package name.
        pkg_names = sorted(
            pkg_names,
            cmp=lambda pkg_name_a, pkg_name_b: self.sort_match_pkgs(
                pkg_name_a, pkg_name_b, input_string))

        return pkg_names
Beispiel #2
0
    def get_pkgs_match_input(self, input_string):
        # Select package name match input string.

        input_string = input_string.lower()
        pkg_names = []
        argv = [
            "SELECT pkg_name FROM software WHERE pkg_name LIKE ?",
            ("%" + unicode(input_string) + "%",)
            ]

        cache_info = self.get_info_from_cache_soft_db(argv)
        if cache_info:
            for (pkg_name, ) in cache_info:
                pkg_names.append(pkg_name)
        else:
            search_key = "*%s*" % input_string
            software_list = Software.select().where(Software.pkg_name % search_key, Software.language==self.default_lang_obj)
            for soft in software_list:
                pkg_names.append(soft.pkg_name)

        # Sort package name.
        pkg_names = sorted(
            pkg_names,
            cmp=lambda pkg_name_a, pkg_name_b: self.sort_match_pkgs(pkg_name_a, pkg_name_b, input_string))

        return pkg_names
 def get_software_obj(self, pkg_name):
     try:
         soft = Software.select().where(
             Software.pkg_name == pkg_name,
             Software.language == self.current_lang_obj).get()
     except:
         soft = None
     return soft
Beispiel #4
0
def insert_description(lang):
    if not SoftwareData.init_language(lang.lang_code):
        print "No data for lang:", lang
    else:
        print "\ntotal for %s: %s" % (lang.lang_code, SoftwareData.select().count())
        i = 0
        for s in SoftwareData.select():
            try:
                software_obj = Software.objects.get(pkg_name=s.pkg_name)
            except:
                software_obj = Software(pkg_name=s.pkg_name)
                software_obj.save()

            try:
                l10n_obj = SoftwareL10n.objects.get(software=software_obj, language_code=lang)
            except:
                l10n_obj = SoftwareL10n(software=software_obj, language_code=lang, alias_name=s.alias_name, short_desc=s.short_desc, long_desc=s.long_desc)
                l10n_obj.save()

            i += 1
            print "\rProgress: %s" % i,
Beispiel #5
0
 def get_software_obj(self, pkg_name):
     try:
         soft = Software.select().where(Software.pkg_name == pkg_name, Software.language == self.current_lang_obj).get()
     except:
         soft = None
     return soft