<s> """<STR_LIT>""" <EOL> from webassets import six <EOL> from webassets . six . moves import map <EOL> from webassets . six . moves import zip <EOL> from webassets . exceptions import BundleError , BuildError <EOL> from webassets . utils import RegistryMetaclass , is_url , hash_func <EOL> __all__ = ( '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , ) <EOL> SKIP_CACHE = object ( ) <EOL> """<STR_LIT>""" <EOL> class BaseUpdater ( six . with_metaclass ( RegistryMetaclass ( <EOL> clazz = lambda : BaseUpdater , attribute = '<STR_LIT>' , <EOL> desc = '<STR_LIT>' ) ) ) : <EOL> """<STR_LIT>""" <EOL> def needs_rebuild ( self , bundle , ctx ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def build_done ( self , bundle , ctx ) : <EOL> """<STR_LIT>""" <EOL> get_updater = BaseUpdater . resolve <EOL> class BundleDefUpdater ( BaseUpdater ) : <EOL> """<STR_LIT>""" <EOL> def check_bundle_definition ( self , bundle , ctx ) : <EOL> if not ctx . cache : <EOL> return False <EOL> cache_key = ( '<STR_LIT>' , bundle . output ) <EOL> current_hash = "<STR_LIT:%s>" % hash_func ( bundle ) <EOL> cached_hash = ctx . cache . get ( cache_key ) <EOL> if not cached_hash is None : <EOL> return cached_hash != current_hash <EOL> return False <EOL> def needs_rebuild ( self , bundle , ctx ) : <EOL> return self . check_bundle_definition ( bundle , ctx ) <EOL> def build_done ( self , bundle , ctx ) : <EOL> if not ctx . cache : <EOL> return False <EOL> cache_key = ( '<STR_LIT>' , bundle . output ) <EOL> cache_value = "<STR_LIT:%s>" % hash_func ( bundle ) <EOL> ctx . cache . set ( cache_key , cache_value ) <EOL> class TimestampUpdater ( BundleDefUpdater ) : <EOL> id = '<STR_LIT>' <EOL> def check_timestamps ( self , bundle , ctx , o_modified = None ) : <EOL> from . bundle import Bundle <EOL> from webassets . version import TimestampVersion <EOL> if not o_modified : <EOL> try : <EOL> resolved_output = bundle . resolve_output ( ctx ) <EOL> except BundleError : <EOL> if ctx . manifest is None : <EOL> raise BuildError ( ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % ( bundle , ctx . versions ) ) ) <EOL> return True <EOL> try : <EOL> o_modified = TimestampVersion . get_timestamp ( resolved_output ) <EOL> except OSError : <EOL> return True <EOL> from webassets . bundle import wrap <EOL> for iterator , result in ( <EOL> ( lambda e : map ( lambda s : s [ <NUM_LIT:1> ] , bundle . resolve_contents ( e ) ) , True ) , <EOL> ( bundle . resolve_depends , SKIP_CACHE ) <EOL> ) : <EOL> for item in iterator ( ctx ) : <EOL> if isinstance ( item , Bundle ) : <EOL> nested_result = self . check_timestamps ( item , wrap ( ctx , item ) , o_modified ) <EOL> if nested_result : <EOL> return nested_result <EOL> elif not is_url ( item ) : <EOL> try : <EOL> s_modified = TimestampVersion . get_timestamp ( item ) <EOL> except OSError : <EOL> return result <EOL> else : <EOL> if s_modified > o_modified : <EOL> return result <EOL> return False <EOL> def needs_rebuild ( self , bundle , ctx ) : <EOL> return super ( TimestampUpdater , self ) . needs_rebuild ( bundle , ctx ) or self . check_timestamps ( bundle , ctx ) <EOL> def build_done ( self , bundle , ctx ) : <EOL> bundle . _resolved_depends = None <EOL> super ( TimestampUpdater , self ) . build_done ( bundle , ctx ) <EOL> class AlwaysUpdater ( BaseUpdater ) : <EOL> id = '<STR_LIT>' <EOL> def needs_rebuild ( self , bundle , ctx ) : <EOL> return True </s>
