tools/bdconfig/lib/google_hadoop/bdconfig_lib/config_commands.py
def AddLineToFile(file_name, line, dry_run):
  """Appends the given line to the given file if it is not already present."""
  with open(file_name, 'a+') as f:
    line = line.strip()
    if line in (f_line.strip() for f_line in f):
      logging.warn(
          'Line: "{0}" already in file "{1}"; not appending to file'.format(
              line, file_name))
    elif dry_run:
      print 'Appending line "{0}" to file "{1}"'.format(line, file_name)
    else:
      f.write(os.linesep)
      f.write(line)
      f.write(os.linesep)
      logging.info('Updated file: "{0}"'.format(file_name))
Appends the given line to the given file if it is not already present.
Appends the given line to the given file if it is not already present.
Appends the given line to the given file if it is not already present .
def AddLineToFile(file_name, line, dry_run):
  with open(file_name, 'a+') as f:
    line = line.strip()
    if line in (f_line.strip() for f_line in f):
      logging.warn(
          'Line: "{0}" already in file "{1}"; not appending to file'.format(
              line, file_name))
    elif dry_run:
      print 'Appending line "{0}" to file "{1}"'.format(line, file_name)
    else:
      f.write(os.linesep)
      f.write(line)
      f.write(os.linesep)
      logging.info('Updated file: "{0}"'.format(file_name))
def AddLineToFile ( file_name , line , dry_run ) : with open ( file_name , 'a+' ) as f : line = line . strip ( ) if line in ( f_line . strip ( ) for f_line in f ) : logging . warn ( 'Line: "{0}" already in file "{1}"; not appending to file' . format ( line , file_name ) ) elif dry_run : print 'Appending line "{0}" to file "{1}"' . format ( line , file_name ) else : f . write ( os . linesep ) f . write ( line ) f . write ( os . linesep ) logging . info ( 'Updated file: "{0}"' . format ( file_name ) )
Appends the given line to the given file if it is not already present.
Appends the given line to the given file if it is not already present .
"""Appends the given line to the given file if it is not already present."""
file_name
line
dry_run