Exemplo n.º 1
0
    def compile_files(self):
        """

        :type image_key: str
        """
        for deck_set in self.image_data.deck_sets:
            self.data_collector.add_set(deck_set)
            for deck in deck_set.decks:
                self.data_collector.add_deck(deck)

                for card in deck.cards:  # type: FlashCard
                    card_key = os.path.splitext(card.image)[0]

                    self.data_collector.add_card(card)
                    manager = CardFileManager(card_key, card.image)

                    for crop_set in card.crop_sets:  # type: CropSet
                        target_format_list = FCS.target_formats[crop_set.crop_format]

                        for target_format in target_format_list:
                            manager.add_format(target_format, crop_set)

                    src_path_root = os.path.join(FCS.original_root, deck_set.name, deck.name, card.image)
                    lines = manager.get_card_csv_lines(src_path_root, FCS.target_root)

                    for line in lines:
                        self.csv_lines.append(line)

                    x_items = manager.get_xcasset_items(FCS.target_root)
                    for item in x_items:
                        self.x_collector.add_xcasset_image(item)

                    d_images = manager.get_app_image_defs()
                    for key in d_images:
                        self.data_collector.add_image_def(d_images[key])
Exemplo n.º 2
0
    def compile_files_for_card(self, image_key, target_device=None):
        """

        :type image_key: str
        :type target_device: str
        """
        for deck_set in self.image_data.deck_sets:  # type: DeckSet
            if deck_set.contains_card_with_key(image_key):
                self.data_collector.add_set(deck_set)
                for deck in deck_set.decks:  # type: Deck
                    if deck.contains_card_with_key(image_key):
                        self.data_collector.add_deck(deck)

                        for card in deck.cards:  # type: FlashCard
                            card_key = os.path.splitext(card.image)[0]
                            if card_key == image_key:

                                self.data_collector.add_card(card)
                                manager = CardFileManager(card_key, card.image)

                                for crop_set in card.crop_sets:  # type: CropSet
                                    target_format_list = FCS.target_formats[crop_set.crop_format]

                                    for target_format in target_format_list:  # type: TargetFormat
                                        if target_device is None or target_format.name == target_device:
                                            manager.add_format(target_format, crop_set)

                                src_path_root = os.path.join(FCS.original_root, deck_set.name, deck.name, card.image)
                                lines = manager.get_card_csv_lines(src_path_root, FCS.target_root)

                                for line in lines:
                                    self.csv_lines.append(line)

                                #if target_device is None:
                                x_items = manager.get_xcasset_items(FCS.target_root)
                                for item in x_items:
                                    self.x_collector.add_xcasset_image(item)

                                d_images = manager.get_app_image_defs()
                                for key in d_images:
                                    if d_images[key] is not None:
                                        self.data_collector.add_image_def(d_images[key])