diff pytouhou/resource/anmwrapper.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 40d5f3083ebc
line wrap: on
line diff
--- a/pytouhou/resource/anmwrapper.py
+++ b/pytouhou/resource/anmwrapper.py
@@ -1,12 +1,38 @@
-from itertools import izip, chain, repeat
+# -*- encoding: utf-8 -*-
+##
+## Copyright (C) 2012 Thibaut Girka <thib@sitedethib.com>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published
+## by the Free Software Foundation; version 3 only.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+
+from itertools import repeat
 
 
 class AnmWrapper(object):
-    def __init__(self, anm_files, offsets=()):
+    def __init__(self, anm_files, offsets=None):
+        """Wrapper for scripts and sprites described in “anm_files”.
+
+        The optional “offsets” argument specifies a list of offsets to be added
+        to script and sprite numbers of each file described in “anm_files”.
+
+        That is, if anm_files[0] and anm_files[1] each have only one sprite,
+        numbered 0 in both cases, and offsets=(0, 1), the first file's sprite
+        will be numbered 0 and the second file's will be numbered 1.
+        """
         self.scripts = {}
         self.sprites = {}
 
-        for anm, offset in izip(anm_files, chain(offsets, repeat(0))):
+        if not offsets:
+            offsets = repeat(0) # “offsets” defaults to zeroes
+
+        for anm, offset in zip(anm_files, offsets):
             for script_id, script in anm.scripts.iteritems():
                 self.scripts[script_id + offset] = (anm, script) #TODO: check
             for sprite_id, sprite in anm.sprites.iteritems():