<s> '''<STR_LIT>''' <EOL> __docformat__ = '<STR_LIT>' <EOL> __version__ = '<STR_LIT>' <EOL> class MapFilter : <EOL> def __init__ ( self , maps , properties ) : <EOL> self . maps = maps <EOL> self . properties = properties <EOL> def __call__ ( self , cells ) : <EOL> '''<STR_LIT>''' <EOL> if not self . properties : <EOL> return cells <EOL> r = [ ] <EOL> for cell in cells : <EOL> for k , v in self . properties . items ( ) : <EOL> if k == '<STR_LIT:id>' : <EOL> if cell . id == v : continue <EOL> else : break <EOL> if cell . properties [ k ] == v : <EOL> continue <EOL> if not hasattr ( cell , '<STR_LIT>' ) and cell . tile . properties [ k ] == v : <EOL> continue <EOL> break <EOL> else : <EOL> r . append ( cell ) <EOL> return r <EOL> class SpriteFilter : <EOL> def __init__ ( self , sprites , properties ) : <EOL> self . sprites = sprites <EOL> self . properties = properties <EOL> def __call__ ( self , sprites ) : <EOL> '''<STR_LIT>''' <EOL> if not self . properties : <EOL> return sprites <EOL> r = [ ] <EOL> for sprite in sprites : <EOL> for k , v in self . properties . items ( ) : <EOL> if k == '<STR_LIT:id>' : <EOL> if sprite . id == v : continue <EOL> else : break <EOL> if sprite . properties [ k ] != v : break <EOL> else : <EOL> r . append ( sprite ) <EOL> return r <EOL> def for_cells ( * maps , ** criteria ) : <EOL> def decorate ( func ) : <EOL> if maps : m = maps [ <NUM_LIT:0> ] <EOL> else : m = None <EOL> if m or criteria : <EOL> m = MapFilter ( m , criteria ) <EOL> if hasattr ( func , '<STR_LIT>' ) : <EOL> if func . map_filters is None : <EOL> raise ValueError , '<STR_LIT>' <EOL> func . map_filters . append ( m ) <EOL> else : <EOL> func . map_filters = [ m ] <EOL> else : <EOL> func . map_filters = None <EOL> if not hasattr ( func , '<STR_LIT>' ) : <EOL> func . sprite_filters = [ ] <EOL> return func <EOL> return decorate <EOL> class FitlerPass : <EOL> pass <EOL> def for_sprites ( * sprites , ** criteria ) : <EOL> def decorate ( func ) : <EOL> if sprites : s = sprites [ <NUM_LIT:0> ] <EOL> else : s = None <EOL> if s or criteria : <EOL> s = SpriteFilter ( s , criteria ) <EOL> if hasattr ( func , '<STR_LIT>' ) : <EOL> if func . sprite_filters is None : <EOL> raise ValueError , '<STR_LIT>' <EOL> func . sprite_filters . append ( s ) <EOL> else : <EOL> func . sprite_filters = [ s ] <EOL> else : <EOL> func . sprite_filters = None <EOL> if not hasattr ( func , '<STR_LIT>' ) : <EOL> func . map_filters = [ ] <EOL> return func <EOL> return decorate </s>
