<s> from atom . api import List <EOL> from . declarative import Declarative <EOL> class Pattern ( Declarative ) : <EOL> """<STR_LIT>""" <EOL> __intercepts_child_nodes__ = True <EOL> pattern_nodes = List ( ) <EOL> def initialize ( self ) : <EOL> """<STR_LIT>""" <EOL> super ( Pattern , self ) . initialize ( ) <EOL> self . refresh_items ( ) <EOL> for item in self . pattern_items ( ) : <EOL> item . initialize ( ) <EOL> def destroy ( self ) : <EOL> """<STR_LIT>""" <EOL> parent = self . parent <EOL> destroy_items = parent is None or not parent . is_destroyed <EOL> super ( Pattern , self ) . destroy ( ) <EOL> if destroy_items : <EOL> for item in self . pattern_items ( ) : <EOL> if not item . is_destroyed : <EOL> item . destroy ( ) <EOL> del self . pattern_nodes <EOL> def child_node_intercept ( self , nodes , key , f_locals ) : <EOL> """<STR_LIT>""" <EOL> self . pattern_nodes . append ( ( nodes , key , f_locals ) ) <EOL> def pattern_items ( self ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError <EOL> def refresh_items ( self ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError </s>
