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


Python Parser.get_gsf_in_file方法代码示例

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


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

示例1: update_files

# 需要导入模块: from parsing.parser import Parser [as 别名]
# 或者: from parsing.parser.Parser import get_gsf_in_file [as 别名]
 def update_files(self):
     """Update the Calendar with the new files"""
     self.clear_data_widgets()
     self._dates.clear()
     folder = variables.settings["parsing"]["path"]
     if not os.path.exists(folder):
         messagebox.showerror("Error",
             "The specified CombatLogs folder does not exist. Please "
             "choose a different folder.")
         folder = filedialog.askdirectory()
         variables.settings.write_settings({"parsing": {"path": folder}})
         return self.update_files()
     files = [f for f in os.listdir(folder) if Parser.get_gsf_in_file(f)]
     self.create_splash(len(files))
     match_count: Dict[datetime: int] = DateKeyDict()
     for file in files:
         date = Parser.parse_filename(file)
         if date is None:  # Failed to parse
             continue
         if date not in match_count:
             match_count[date] = 0
         match_count[date] += Parser.count_matches(file)
         if date not in self._dates:
             self._dates[date] = list()
         self._dates[date].append(file)
         self._splash.increment()
     self._calendar.update_heatmap(match_count)
     self.destroy_splash()
开发者ID:RedFantom,项目名称:GSF-Parser-Public,代码行数:30,代码来源:file.py

示例2: update_files

# 需要导入模块: from parsing.parser import Parser [as 别名]
# 或者: from parsing.parser.Parser import get_gsf_in_file [as 别名]
 def update_files(self, silent=False):
     """
     Function that checks files found in the in the settings
     specified folder for GSF matches and if those are found in a
     file, it gets added to the listbox. Provides error handling.
     """
     self.file_tree.delete(*self.file_tree.get_children())
     self.clear_data_widgets()
     self.main_window.ship_frame.ship_label_var.set("")
     try:
         old_cwd = os.getcwd()
         os.chdir(variables.settings["parsing"]["path"])
         os.chdir(old_cwd)
     except OSError:
         tkinter.messagebox.showerror("Error",
                                      "The CombatLogs folder found in the settings file is not valid. Please "
                                      "choose another folder.")
         folder = tkinter.filedialog.askdirectory(title="CombatLogs folder")
         variables.settings.write_settings({'parsing': {'path': folder}})
         variables.settings.read_settings()
     combatlogs_folder = variables.settings["parsing"]["path"]
     file_list = os.listdir(combatlogs_folder)
     if not silent:
         splash_screen = SplashScreen(self.main_window, len(file_list), title="Loading files")
     else:
         splash_screen = None
     if len(file_list) > 100:
         tkinter.messagebox.showinfo("Suggestion", "Your CombatLogs folder contains a lot of CombatLogs, {0} to be "
                                                   "precise. How about moving them to a nice archive folder? This "
                                                   "will speed up some processes "
                                                   "significantly.".format(len(file_list)))
     self.file_tree.insert("", tk.END, iid="all", text="All CombatLogs")
     file_list = list(reversed(sorted(file_list)) if not self.ascending else sorted(file_list))
     if self.main_window.splash is not None and self.main_window.splash.winfo_exists():
         self.main_window.splash.update_max(len(file_list))
     for number, file in enumerate(file_list):
         if not Parser.get_gsf_in_file(file):
             continue
         file_string = Parser.parse_filename(file)
         if file_string is None:
             continue
         self.file_string_dict[file_string] = file
         number += 1
         if splash_screen is not None:
             splash_screen.increment()
             splash_screen.update()
         self.insert_file(file_string)
         if self.main_window.splash is not None and self.main_window.splash.winfo_exists():
             self.main_window.splash.increment()
     if splash_screen is not None:
         splash_screen.destroy()
     return
开发者ID:RedFantom,项目名称:GSF-Parser-Public,代码行数:54,代码来源:fileframe.py

示例3: filter

# 需要导入模块: from parsing.parser import Parser [as 别名]
# 或者: from parsing.parser.Parser import get_gsf_in_file [as 别名]
    def filter(self, search=False):
        """
        Go through all file filters and apply them to the list of files
        in the CombatLogs folder. Insert them into the file_frame
        file_tree widget when the file passed the filters.
        :param search: if search is True, the function will calculate
            the amount of files found and ask the user whether the
            results should be displayed first
        """
        # logs, matches or spawns
        results = []
        files = os.listdir(variables.settings["parsing"]["path"])
        files_done = 0
        splash = SplashScreen(self, len(files))
        # Clear the widgets in the file frame
        self.window.file_select_frame.file_string_dict.clear()
        self.window.file_select_frame.clear_data_widgets()
        self.window.file_select_frame.file_tree.delete(*self.window.file_select_frame.file_tree.get_children())
        # Start looping over the files in the CombatLogs folder
        for file_name in files:
            # Set passed to True. Will be set to False in some filter code
            passed = True
            # Update the SplashScreen progress bar
            files_done += 1
            splash.update_max(files_done)
            # If the file does not end with .txt, it's not a CombatLog
            if not file_name.endswith(".txt") or not Parser.get_gsf_in_file(file_name):
                continue
            # Open the CombatLog
            lines = Parser.read_file(file_name)
            # Parse the CombatLog to get the data to filter against
            player_list = Parser.get_player_id_list(lines)
            file_cube, match_timings, spawn_timings = Parser.split_combatlog(lines, player_list)
            (abilities, damagedealt, damagetaken, selfdamage, healing, _, _, _, _,
             enemy_dmg_d, enemy_dmg_t, _, _) = Parser.parse_file(file_cube, player_list)
            matches = len(file_cube)
            damagedealt, damagetaken, selfdamage, healing = (
                damagedealt / matches,
                damagetaken / matches,
                selfdamage / matches,
                healing / matches
            )
            # If Ship filters are enabled, check file against ship filters
            if self.filter_type_vars["Ships"].get() is True:
                print("Ships filters are enabled")
                if not self.check_ships_file(self.ships_intvars, abilities):
                    print("Continuing in file {0} because of Ships".format(file_name))
                    continue

            # If the Components filters are enabled, check against Components filters
            if self.filter_type_vars["Components"].get() is True:
                print("Components filters are enabled")
                for dictionary in self.comps_vars:
                    if not self.check_components(dictionary, abilities):
                        # Passed is applied here as "continue" will not work inside this for loop
                        passed = False
                        break
                if not passed:
                    print("Continuing in file {0} because of Components".format(file_name))
                    continue

            if self.filter_type_vars["Date"].get() is True:
                print("Date filters are enabled")
                date = Parser.parse_filename(file_name)
                if not date:
                    print("Continuing in file {0} because the filename could not be parsed".format(file_name))
                    continue
                if self.start_date_widget.selection > date:
                    print("Continuing in file {0} because of the start date".format(file_name))
                    continue
                if self.end_date_widget.selection < date:
                    print("Continuing in file {0} because of the end date".format(file_name))
                    continue

            enemies = sum(True if dmg > 0 else False for dmg in enemy_dmg_d.values())
            killassists = sum(True if dmg > 0 else False for dmg in enemy_dmg_t.values())

            if self.filter_type_vars["Statistics"].get() is True:
                for (scale_type, scale_max), (_, scale_min) in \
                        zip(self.statistics_scales_max.items(), self.statistics_scales_min.items()):
                    value = locals()[scale_type]
                    min, max = scale_min.value, scale_max.value
                    condition = min <= value <= max if max > min else min <= value
                    if condition is False:
                        continue

            results.append(file_name)
        print("Amount of results: {0}".format(len(results)))
        print("Results: {0}".format(results))
        splash.destroy()
        if search and len(results) is not 0:
            print("Search is enabled")
            if not tkinter.messagebox.askyesno("Search results",
                                               "With the filters you specified, %s results were found. Would you like "
                                               "to view them?" % len(results)):
                return
        if len(results) == 0:
            tkinter.messagebox.showinfo("Search results",
                                        "With the filters you specified, no results were found.")
            return
#.........这里部分代码省略.........
开发者ID:RedFantom,项目名称:GSF-Parser-Public,代码行数:103,代码来源:filters.py

示例4: test_get_gsf_in_file

# 需要导入模块: from parsing.parser import Parser [as 别名]
# 或者: from parsing.parser.Parser import get_gsf_in_file [as 别名]
 def test_get_gsf_in_file(self):
     self.assertTrue(Parser.get_gsf_in_file(self.FILE))
开发者ID:RedFantom,项目名称:GSF-Parser-Public,代码行数:4,代码来源:test_parser.py


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