当前位置: 首页>>代码示例>>Python>>正文


Python Database.get_instance方法代码示例

本文整理汇总了Python中fsgs.Database.Database.get_instance方法的典型用法代码示例。如果您正苦于以下问题:Python Database.get_instance方法的具体用法?Python Database.get_instance怎么用?Python Database.get_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fsgs.Database.Database的用法示例。


在下文中一共展示了Database.get_instance方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update_search

# 需要导入模块: from fsgs.Database import Database [as 别名]
# 或者: from fsgs.Database.Database import get_instance [as 别名]
    def update_search(self):
        search = LauncherSettings.get("config_search").strip().lower()
        print("search for", search)
        words = []
        special = []
        for word in search.split(" "):
            word = word.strip()
            if not word:
                continue
            if ":" in word[1:-1]:
                special.append(word)
            else:
                words.append(word)
        terms = GameNameUtil.extract_search_terms(" ".join(words))
        terms.update(special)

        database = Database.get_instance()

        try:
            have = int(LauncherSettings.get("database_show_games"))
        except ValueError:
            # default is show all downloadable and locally available games
            have = 1
        items = database.find_games_new(
            " ".join(terms), have=have,
            list_uuid=LauncherSettings.get("game_list_uuid"))

        self.set_items(items)
开发者ID:glaubitz,项目名称:fs-uae-debian,代码行数:30,代码来源:ConfigurationsBrowser.py

示例2: run

# 需要导入模块: from fsgs.Database import Database [as 别名]
# 或者: from fsgs.Database.Database import get_instance [as 别名]
 def run(self):
     self.defragment(FileDatabase.get_instance(), "Files.sqlite")
     self.stop_check()
     self.defragment(LockerDatabase.instance(), "Locker.sqlite")
     self.stop_check()
     self.defragment(fsgs.get_game_database(), "Amiga.sqlite")
     self.stop_check()
     self.defragment(Database.get_instance(), "Database.sqlite")
开发者ID:EdwardBetts,项目名称:fs-uae-launcher,代码行数:10,代码来源:maintenance_settings_page.py

示例3: load_configuration

# 需要导入模块: from fsgs.Database import Database [as 别名]
# 或者: from fsgs.Database.Database import get_instance [as 别名]
 def load_configuration(self, item):
     if item[str("uuid")]:
         LauncherSettings.set("parent_uuid", item[str("uuid")])
     else:
         config_path = Database.get_instance().decode_path(
             item[str("path")])
         print("load config from", config_path)
         LauncherConfig.load_file(config_path)
         LauncherSettings.set("parent_uuid", "")
开发者ID:glaubitz,项目名称:fs-uae-debian,代码行数:11,代码来源:ConfigurationsBrowser.py

示例4: temp_fix_configs

# 需要导入模块: from fsgs.Database import Database [as 别名]
# 或者: from fsgs.Database.Database import get_instance [as 别名]
    def temp_fix_configs(self, item):
        from fsgs.Database import Database
        local_game_database = Database.get_instance()
        game_database = fsgs.get_game_database()

        variants = local_game_database.find_game_variants_new(
            game_uuid=item.uuid)
        print(variants)

        ordered_list = []
        for variant in variants:

            variant["like_rating"], variant["work_rating"] = \
                game_database.get_ratings_for_game(variant["uuid"])
            variant["personal_rating"], ignored = \
                local_game_database.get_ratings_for_game(variant["uuid"])

            # user_rating = variant[5] or 0
            # global_rating = variant[3] or 0
            # user_rating = 0
            # global_rating = 0

            variant_uuid = variant["uuid"]  # variant[2]
            variant_name = variant["name"]  # variant[1]
            variant_name = variant_name.replace("\n", " (")
            variant_name = variant_name.replace(" \u00b7 ", ", ")
            variant_name += ")"
            ordered_list.append(
                ((1 - bool(variant["have"]),
                  1000 - variant["personal_rating"],
                  1000 - variant["like_rating"]),
                 (variant_uuid, variant_name, variant["database"])))
        ordered_list.sort()
        print("ordered variant list:")
        for variant in ordered_list:
            print("-", variant[1][1])
        item.configurations = [co[1] for co in ordered_list]
开发者ID:EdwardBetts,项目名称:fs-uae-launcher,代码行数:39,代码来源:gamemenu.py

示例5: update_list

# 需要导入模块: from fsgs.Database import Database [as 别名]
# 或者: from fsgs.Database.Database import get_instance [as 别名]
    def update_list(self, game_uuid):
        print("VariantsBrowser.update_list, game_uuid=", game_uuid)
        database = Database.get_instance()
        items = database.find_game_variants_new(game_uuid, have=0)

        # items = database.search_configurations(self.search)
        sortable_items = []
        for i, item in enumerate(items):
            name = item["name"]

            name = name.replace("\nAmiga \u00b7 ", "\n")
            # print(name, item[3])
            # name = name.replace("\nCD32 \u00b7 ", "\n")
            # name = item[1].replace("\n", " \u00b7 ")

            # only show variant name (without game name)
            name = name.split("\n", 1)[-1]

            game_database = fsgs.game_database(item["database"])
            item["like_rating"], item["work_rating"] = game_database\
                .get_ratings_for_game(item["uuid"])
            item["personal_rating"], ignored = database.get_ratings_for_game(
                item["uuid"])

            sort_key = (0, 1000000 - item["like_rating"],
                        1000000 - item["work_rating"], name)
            sortable_items.append(
                (sort_key, i, item))
        # print(sortable_items)
        self.items = [x[2] for x in sorted(sortable_items)]
        self.update()
        # self.set_items(self.items)
        # self.set_item_count(len(self.items))

        self.select_item(None, signal=False)

        select_index = None
        list_uuid = LauncherSettings.get("game_list_uuid")
        if list_uuid:
            list_variant_uuid = database.get_variant_for_list_and_game(
                list_uuid, game_uuid)
            print("game list", list_uuid, "override variant",
                  list_variant_uuid)
        else:
            list_variant_uuid = None
        if list_variant_uuid:
            # override variant selection from list if possible
            for i, item in enumerate(self.items):
                print(item["uuid"], item["name"], list_variant_uuid)
                if item["uuid"] == list_variant_uuid:
                    select_index = i
                    print("override select index", select_index)
                    break
        if select_index is None:
            # default index selection
            for i, item in enumerate(self.items):
                if item["personal_rating"] == 5:
                    select_index = i
                    break
            else:
                for i, item in enumerate(self.items):
                    if item["have"] >= 3:
                        select_index = i
                        break
                else:
                    for i, item in enumerate(self.items):
                        if item["have"] >= 1:
                            select_index = i
                            break
                    else:
                        if len(self.items) > 0:
                            select_index = 0

        # self.clear()
        # for i, item in enumerate(self.items):
        #     self.add_item(item["name"], icon=self.get_item_icon(i))

        self.enable(len(self.items) > 0)
        if select_index is not None:
            print("selecting variant index", select_index)
            self.select_item(select_index)
        else:
            ConfigGroup.new_config()
开发者ID:EdwardBetts,项目名称:fs-uae-launcher,代码行数:85,代码来源:VariantsBrowser.py

示例6: on_quit_signal

# 需要导入模块: from fsgs.Database import Database [as 别名]
# 或者: from fsgs.Database.Database import get_instance [as 别名]
 def on_quit_signal(self):
     database = Database.get_instance()
     for key, value in self.cache.items():
         database.set_last_game_variant(key, value)
     database.commit()
开发者ID:EdwardBetts,项目名称:fs-uae-launcher,代码行数:7,代码来源:VariantsBrowser.py

示例7: search

# 需要导入模块: from fsgs.Database import Database [as 别名]
# 或者: from fsgs.Database.Database import get_instance [as 别名]
    def search(self, search):
        print("search for", search)

        database = Database.get_instance()
        items = database.search_games(search)
        self.set_items(items)
开发者ID:EdwardBetts,项目名称:fs-uae-launcher,代码行数:8,代码来源:GameListView.py

示例8: on_select_item

# 需要导入模块: from fsgs.Database import Database [as 别名]
# 或者: from fsgs.Database.Database import get_instance [as 别名]
 def on_select_item(self, index):
     # index = self.get_index()
     database = Database.get_instance()
     info = database.get_game_info(self.items[index][0])
     self.set_game_info(info)
开发者ID:EdwardBetts,项目名称:fs-uae-launcher,代码行数:7,代码来源:GameListView.py

示例9: run

# 需要导入模块: from fsgs.Database import Database [as 别名]
# 或者: from fsgs.Database.Database import get_instance [as 别名]
 def run(self):
     with Database.get_instance() as database:
         self._run(database)
开发者ID:EdwardBetts,项目名称:fs-uae-launcher,代码行数:5,代码来源:download.py

示例10: save_config

# 需要导入模块: from fsgs.Database import Database [as 别名]
# 或者: from fsgs.Database.Database import get_instance [as 别名]
    def save_config():
        print("SaveButton.save_config")
        database = Database.get_instance()

        name = LauncherSettings.get("config_name").strip()
        if not name:
            print("no config_name")
            # FIXME: notify user
            return

        file_name = name + ".fs-uae"
        path = os.path.join(
            FSGSDirectories.get_configurations_dir(), file_name)
        with io.open(path, "w", encoding="UTF-8") as f:
            f.write("# FS-UAE configuration saved by FS-UAE Launcher\n")
            f.write("# Last saved: {0}\n".format(
                    datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S")))
            f.write("\n[fs-uae]\n")
            keys = sorted(fsgs.config.values.keys())
            for key in keys:
                value = LauncherConfig.get(key)
                if key.startswith("__"):
                    continue
                if key in LauncherConfig.no_save_keys_set:
                    continue
                # elif key == "joystick_port_2_mode" and value == "nothing":
                #     continue
                # elif key == "joystick_port_3_mode" and value == "nothing":
                #     continue
                if value == LauncherConfig.default_config.get(key, ""):
                    continue
                if value:
                    f.write("{0} = {1}\n".format(key, value))

        # scanner = ConfigurationScanner()
        # search = ConfigurationScanner.create_configuration_search(name)
        # name = scanner.create_configuration_name(name)
        # print("adding", path)
        # # deleting the path from the database first in case it already exists
        # database.delete_configuration(path=path)
        # database.delete_file(path=path)
        # database.add_file(path=path)
        # database.add_configuration(
        #     path=path, uuid="", name=name, scan=0, search=search)

        file_database = FileDatabase.get_instance()
        scanner = ConfigurationScanner()
        print("[save config] adding config", path)
        file_database.delete_file(path=path)
        with open(path, "rb") as f:
            sha1 = hashlib.sha1(f.read()).hexdigest()
        file_database.add_file(path=path, sha1=sha1)

        game_id = database.add_game(
            path=path, name=scanner.create_configuration_name(name))
        database.update_game_search_terms(
            game_id, scanner.create_search_terms(name))

        database.commit()
        file_database.commit()

        LauncherSettings.set("__config_refresh", str(time.time()))
        # Settings.set("config_changed", "0")
        LauncherConfig.set("__changed", "0")
开发者ID:glaubitz,项目名称:fs-uae-debian,代码行数:66,代码来源:savebutton.py


注:本文中的fsgs.Database.Database.get_instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。