當前位置: 首頁>>代碼示例>>Python>>正文


Python Parser.get_abilities_dict方法代碼示例

本文整理匯總了Python中parsing.parser.Parser.get_abilities_dict方法的典型用法代碼示例。如果您正苦於以下問題:Python Parser.get_abilities_dict方法的具體用法?Python Parser.get_abilities_dict怎麽用?Python Parser.get_abilities_dict使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在parsing.parser.Parser的用法示例。


在下文中一共展示了Parser.get_abilities_dict方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: parse_ship_descriptor

# 需要導入模塊: from parsing.parser import Parser [as 別名]
# 或者: from parsing.parser.Parser import get_abilities_dict [as 別名]
 def parse_ship_descriptor(ship: Ship, line: dict, lines: list, event: tuple):
     """
     Parse an event_descriptor of the SHIP type. Supports ability,
     component and crew type operations.
     :param ship: Ship instance for the spawn described by lines
     :param line: Trigger line dictionary
     :param lines: List of lines in this spawn
     :param event: Event descriptor tuple (PatternParser docstring)
     :return: The result of results this SHIP event descriptor
     """
     if event[0] != Patterns.SHIP:
         raise InvalidDescriptor(event)
     event_type, args = event[1], event[2:]  # "ability", "component", "crew"
     # Parse Component selected
     if event_type == "component":
         # Component must be selected on the Ship for this spawn
         component, = args
         return PatternParser.get_component_in_ship(lines, ship, component)
     # Parse Crew selected
     elif event_type == "crew":
         crew, = args
         return PatternParser.get_crew_in_ship(ship, crew)
     # Parse Ability Available
     elif event_type == "ability":
         return PatternParser.parse_ability_availability(line, lines, event, ship)
     # Parse ship type selected
     elif event_type == "type":
         # TODO: Optimize usage
         player = Parser.get_player_id_list(lines)
         abs_dict = Parser.get_abilities_dict(lines, player)
         ship_name = ship.name if ship is None else Parser.get_ship_for_dict(abs_dict)
         ship_type, = args
         return get_ship_category(ship_name) == ship_type
     raise InvalidDescriptor(event)
開發者ID:RedFantom,項目名稱:GSF-Parser-Public,代碼行數:36,代碼來源:patterns.py

示例2: get_component_in_ship

# 需要導入模塊: from parsing.parser import Parser [as 別名]
# 或者: from parsing.parser.Parser import get_abilities_dict [as 別名]
 def get_component_in_ship(lines: list, ship: Ship, component: (str, Component)):
     """Return whether a component is found within a Ship instance"""
     if isinstance(component, Component):
         name, category = component.name, component.category
     else:  # str
         name = component
         category = PatternParser.get_component_category(component)
     player = Parser.get_player_id_list(lines)
     abilities = Parser.get_abilities_dict(lines, player)
     if name in abilities:
         return True
     if ship is None:
         return False  # Ship option not available at results time
     if category not in ship:
         return False  # Configured improperly at results time
     categories = (category,)
     if "Weapon" in category:  # Extend to double primaries/secondaries
         categories += (category[0] + "2",)
     # Loop over categories
     result = False
     for category in categories:
         if category not in ship:  # Double primaries/secondaries
             continue
         component = ship[category]
         if not isinstance(component, Component):  # Improper config
             print("[PatternParser] Improperly configured Ship instance:", ship, component)
             continue
         if component.name == name:
             result = True
             break
         continue
     return result
開發者ID:RedFantom,項目名稱:GSF-Parser-Public,代碼行數:34,代碼來源:patterns.py

示例3: _select_date

# 需要導入模塊: from parsing.parser import Parser [as 別名]
# 或者: from parsing.parser.Parser import get_abilities_dict [as 別名]
 def _select_date(self, date: datetime):
     """Callback for Calendar widget selection command"""
     self.clear_data_widgets()
     self._tree.delete(*self._tree.get_children(""))
     if date not in self._dates:
         return
     self._files: List[str] = self._dates[date]
     for f, file in enumerate(sorted(self._files)):
         name = Parser.get_player_name_raw(file)
         cube, matches, spawns = Parser.split_combatlog_file(file)
         for m, match in enumerate(sorted(matches[::2])):
             match = datetime.strftime(match, "%H:%M, {}".format(name))
             match_iid = "{},{}".format(f, m)
             self._tree.insert("", tk.END, text=match, iid=match_iid)
             for s, spawn in enumerate(sorted(spawns[m])):
                 spawn = datetime.strftime(spawn, "%H:%M:%S")
                 player_list: List[str] = Parser.get_player_id_list(cube[m][s])
                 abs_dict: Dict[str: int] = Parser.get_abilities_dict(cube[m][s], player_list)
                 ships: List[str] = Parser.get_ship_for_dict(abs_dict)
                 ship = self.format_ships_list(ships)
                 spawn = "{}{}".format(spawn, ship)
                 spawn_iid = "{},{},{}".format(f, m, s)
                 self._tree.insert(match_iid, tk.END, text=spawn, iid=spawn_iid)
開發者ID:RedFantom,項目名稱:GSF-Parser-Public,代碼行數:25,代碼來源:file.py

示例4: test_get_abilities_dict

# 需要導入模塊: from parsing.parser import Parser [as 別名]
# 或者: from parsing.parser.Parser import get_abilities_dict [as 別名]
 def test_get_abilities_dict(self):
     lines = Parser.read_file(self.FILE)
     player = Parser.get_player_id_list(lines)
     abilities = Parser.get_abilities_dict(lines, player)
     self.assertIsInstance(abilities, dict)
開發者ID:RedFantom,項目名稱:GSF-Parser-Public,代碼行數:7,代碼來源:test_parser.py


注:本文中的parsing.parser.Parser.get_abilities_dict方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。