Пример #1
0
 def load(self, file_path):
     try:
         with open(file_path, "rb") as tpf_file:
             self._load_entries(tpf_file)
     except OSError as exc:
         LOG.error("Error reading '{}': {}".format(file_path, exc))
         return False
     return True
Пример #2
0
    def extract_textures(self, output_dir, add_extension = True):
        for entry in self.data_entries:
            name = entry.name
            entry_path = os.path.join(output_dir, name)
            if add_extension:
                entry_path += ".dds"

            try:
                with open(entry_path, "wb") as dds_file:
                    dds_file.write(entry.data)
            except OSError as exc:
                LOG.error("Error writing texture {}: {}".format(name, exc))