Mercurial > touhou
comparison pytouhou/resource/loader.py @ 285:2100276c289d
Document some AnmWrapper related functions.
| author | Thibaut Girka <thib@sitedethib.com> |
|---|---|
| date | Sun, 12 Feb 2012 15:51:00 +0100 |
| parents | dbb1a86c0235 |
| children | a09ac4650e0d |
comparison
equal
deleted
inserted
replaced
| 284:91eb0afcb1e3 | 285:2100276c289d |
|---|---|
| 1 # -*- encoding: utf-8 -*- | |
| 2 ## | |
| 3 ## Copyright (C) 2012 Thibaut Girka <thib@sitedethib.com> | |
| 4 ## | |
| 5 ## This program is free software; you can redistribute it and/or modify | |
| 6 ## it under the terms of the GNU General Public License as published | |
| 7 ## by the Free Software Foundation; version 3 only. | |
| 8 ## | |
| 9 ## This program is distributed in the hope that it will be useful, | |
| 10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 ## GNU General Public License for more details. | |
| 13 ## | |
| 14 | |
| 1 import os | 15 import os |
| 2 from glob import glob | 16 from glob import glob |
| 3 from itertools import chain | 17 from itertools import chain |
| 4 from io import BytesIO | 18 from io import BytesIO |
| 5 | 19 |
| 161 with open(path, 'rb') as file: | 175 with open(path, 'rb') as file: |
| 162 characters = EoSDSHT.read(file) #TODO: modular | 176 characters = EoSDSHT.read(file) #TODO: modular |
| 163 return characters | 177 return characters |
| 164 | 178 |
| 165 | 179 |
| 166 def get_anm_wrapper(self, names, offsets=()): | 180 def get_anm_wrapper(self, names, offsets=None): |
| 181 """Create an AnmWrapper for ANM files “names”. | |
| 182 | |
| 183 If one of the files “names” does not exist or is not a valid ANM file, | |
| 184 raises an exception. | |
| 185 """ | |
| 167 return AnmWrapper((self.get_anm(name) for name in names), offsets) | 186 return AnmWrapper((self.get_anm(name) for name in names), offsets) |
| 168 | 187 |
| 169 | 188 |
| 170 def get_anm_wrapper2(self, names, offsets=()): | 189 def get_anm_wrapper2(self, names, offsets=None): |
| 190 """Create an AnmWrapper for ANM files “names”. | |
| 191 | |
| 192 Stop at the first non-existent or invalid ANM file if there is one, | |
| 193 and return an AnmWrapper for all the previous correct files. | |
| 194 """ | |
| 171 anms = [] | 195 anms = [] |
| 172 | 196 |
| 173 try: | 197 try: |
| 174 for name in names: | 198 for name in names: |
| 175 anms.append(self.get_anm(name)) | 199 anms.append(self.get_anm(name)) |
