#!/usr/bin/env python # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. '''Tool to create a new, empty .grd file with all the basic sections. ''' from grit.tool import interface from grit import constants from grit import util # The contents of the new .grd file _FILE_CONTENTS = '''\ ''' % constants.ENCODING_CHECK class NewGrd(interface.Tool): '''Usage: grit newgrd OUTPUT_FILE Creates a new, empty .grd file OUTPUT_FILE with comments about what to put where in the file.''' def ShortDescription(self): return 'Create a new empty .grd file.' def Run(self, global_options, my_arguments): if not len(my_arguments) == 1: print 'This tool requires exactly one argument, the name of the output file.' return 2 filename = my_arguments[0] with util.WrapOutputStream(open(filename, 'w'), 'utf-8') as out: out.write(_FILE_CONTENTS) print "Wrote file %s" % filename