comparison pytouhou/resource/loader.py @ 430:c9433188ffdb

Remove AnmWrapper, since ANMs are lists of entries now.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 03 Aug 2013 15:49:04 +0200
parents 40d5f3083ebc
children 69c73023f7a0
comparison
equal deleted inserted replaced
429:40d5f3083ebc 430:c9433188ffdb
25 from pytouhou.formats.msg import MSG 25 from pytouhou.formats.msg import MSG
26 from pytouhou.formats.sht import SHT 26 from pytouhou.formats.sht import SHT
27 from pytouhou.formats.exe import SHT as EoSDSHT, InvalidExeException 27 from pytouhou.formats.exe import SHT as EoSDSHT, InvalidExeException
28 from pytouhou.formats.music import Track 28 from pytouhou.formats.music import Track
29 from pytouhou.formats.fmt import FMT 29 from pytouhou.formats.fmt import FMT
30
31
32 from pytouhou.resource.anmwrapper import AnmWrapper
33 30
34 from pytouhou.utils.helpers import get_logger 31 from pytouhou.utils.helpers import get_logger
35 32
36 logger = get_logger(__name__) 33 logger = get_logger(__name__)
37 34
186 def get_fmt(self, name): 183 def get_fmt(self, name):
187 file = self.get_file(name) 184 file = self.get_file(name)
188 return FMT.read(file) #TODO: modular 185 return FMT.read(file) #TODO: modular
189 186
190 187
191 def get_anm_wrapper(self, names, offsets=None): 188 def get_single_anm(self, name):
192 """Create an AnmWrapper for ANM files “names”. 189 """Hack for EoSD, since it doesn’t support multi-entries ANMs."""
193 190 anm = self.get_anm(name)
194 If one of the files “names” does not exist or is not a valid ANM file, 191 assert len(anm) == 1
195 raises an exception. 192 return anm[0]
196 """
197 return AnmWrapper((self.get_anm(name) for name in names), offsets)
198 193
199 194
200 def get_anm_wrapper2(self, names, offsets=None): 195 def get_multi_anm(self, names):
201 """Create an AnmWrapper for ANM files “names”. 196 """Hack for EoSD, since it doesn’t support multi-entries ANMs."""
202 197 return sum((self.get_anm(name) for name in names), [])
203 Stop at the first non-existent or invalid ANM file if there is one,
204 and return an AnmWrapper for all the previous correct files.
205 """
206 anms = []
207
208 try:
209 for name in names:
210 anms.append(self.get_anm(name))
211 except KeyError:
212 pass
213
214 return AnmWrapper(anms, offsets)
215