#NEWLINE# @ register . filter #NEWLINE# def templated( template_path ) : #NEWLINE# #INDENT# import djsupervisor.config #NEWLINE# project_dir = current_context [ 'PROJECT_DIR' ] #NEWLINE# full_path = os . path . join ( project_dir , template_path ) #NEWLINE# templated_path = ( full_path + '.templated' ) #NEWLINE# created = ( not os . path . exists ( templated_path ) ) #NEWLINE# with open ( templated , 'r' ) as f : #NEWLINE# #INDENT# templated = djsupervisor . config . render_config ( f . read ( ) , current_context ) #NEWLINE# #UNINDENT# with open ( templated_path , 'w' ) as f : #NEWLINE# #INDENT# f . write ( templated ) #NEWLINE# #UNINDENT# if created : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# info = os . stat ( full_path ) #NEWLINE# shutil . copystat ( full_path , templated_path ) #NEWLINE# os . chown ( templated_path , info . st_uid , info . st_gid ) #NEWLINE# #UNINDENT# except EnvironmentError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# return templated_path