<s> """<STR_LIT>""" <EOL> import fileinput <EOL> import re <EOL> import sys <EOL> from atomic_reactor . plugin import PreBuildPlugin <EOL> from atomic_reactor . util import ImageName <EOL> class ChangeFromPlugin ( PreBuildPlugin ) : <EOL> key = "<STR_LIT>" <EOL> def __init__ ( self , tasker , workflow , base_image = None ) : <EOL> """<STR_LIT>""" <EOL> super ( ChangeFromPlugin , self ) . __init__ ( tasker , workflow ) <EOL> self . base_image = ImageName . parse ( base_image ) if base_image else None <EOL> def run ( self ) : <EOL> """<STR_LIT>""" <EOL> base_image = self . base_image or self . workflow . builder . base_image <EOL> try : <EOL> base_image_id = self . workflow . base_image_inspect [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> self . log . error ( "<STR_LIT>" , self . workflow . base_image_inspect ) <EOL> raise <EOL> self . log . debug ( "<STR_LIT>" , base_image , base_image_id ) <EOL> for line in fileinput . input ( self . workflow . builder . df_path , inplace = <NUM_LIT:1> ) : <EOL> re_match = re . match ( r"<STR_LIT>" , line ) <EOL> if re_match : <EOL> new_from = "<STR_LIT>" % base_image_id <EOL> sys . stdout . write ( new_from + '<STR_LIT:\n>' ) <EOL> self . log . info ( "<STR_LIT>" , re_match . group ( <NUM_LIT:0> ) , new_from ) <EOL> else : <EOL> sys . stdout . write ( line ) </s>
