def safe_config_file(config_file):
 config_file_lower = config_file.lower()
 if _SENSITIVE_FILENAME_REGEX.search(config_file_lower):
  return False
 proc = subprocess.Popen(['file', config_file], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
 (file_output, _) = proc.communicate()
 if ('ASCII' in file_output):
  possible_password_file = empty_or_all_comments = True
  with open(config_file) as config_fd:
   for line in config_fd:
    if (not (line.isspace() or line.lstrip().startswith('#'))):
     empty_or_all_comments = False
     if line.startswith('-----BEGIN'):
      return False
     elif (':' not in line):
      possible_password_file = False
  return (empty_or_all_comments or (not possible_password_file))
 return False

def safe_config_file ( config_file ) : config_file_lower = config_file . lower ( ) if _SENSITIVE_FILENAME_REGEX . search ( config_file_lower ) : return False proc = subprocess . Popen ( [ 'file' , config_file ] , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) ( file_output , _ ) = proc . communicate ( ) if ( 'ASCII' in file_output ) : possible_password_file = empty_or_all_comments = True with open ( config_file ) as config_fd : for line in config_fd : if ( not ( line . isspace ( ) or line . lstrip ( ) . startswith ( '#' ) ) ) : empty_or_all_comments = False if line . startswith ( '-----BEGIN' ) : return False elif ( ':' not in line ) : possible_password_file = False return ( empty_or_all_comments or ( not possible_password_file ) ) return False
returns true if config_file can be safely copied .