#NEWLINE# def check_existing( package , pkg_files , formula_def , conn = None ) : #NEWLINE# #INDENT# '\n    Check the filesystem for existing files\n    ' #NEWLINE# if ( conn is None ) : #NEWLINE# #INDENT# conn = init ( ) #NEWLINE# #UNINDENT# existing_files = [ ] #NEWLINE# for member in pkg_files : #NEWLINE# #INDENT# if member . isdir ( ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# tld = formula_def . get ( 'top_level_dir' , new_name ) #NEWLINE# new_name = member . name . replace ( '{0}/' . format ( package ) , '' ) #NEWLINE# if ( not new_name . startswith ( tld ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if member . name . startswith ( '{0}/_' . format ( package ) ) : #NEWLINE# #INDENT# out_file = os . path . join ( conn [ 'formula_path' ] , new_name ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( member . name == '{0}/pillar.example' . format ( package ) ) : #NEWLINE# #INDENT# new_name = '{0}.sls.orig' . format ( package ) #NEWLINE# out_file = os . path . join ( conn [ 'pillar_path' ] , new_name ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if package . endswith ( '-conf' ) : #NEWLINE# #INDENT# out_file = os . path . join ( salt . syspaths . CONFIG_DIR , new_name ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if package . endswith ( '-reactor' ) : #NEWLINE# #INDENT# out_file = os . path . join ( conn [ 'reactor_path' ] , member . name ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# out_file = os . path . join ( conn [ 'formula_path' ] , member . name ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if os . path . exists ( out_file ) : #NEWLINE# #INDENT# existing_files . append ( out_file ) #NEWLINE# if ( not __opts__ [ 'force' ] ) : #NEWLINE# #INDENT# log . error ( '{0} already exists, not installing' . format ( out_file ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return existing_files