2 # Copyright 2017 gRPC authors.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
21 argp = argparse.ArgumentParser(description='Convert cloc yaml to bigquery csv')
22 argp.add_argument('-i', '--input', type=str)
23 argp.add_argument('-d',
26 default=datetime.date.today().strftime('%Y-%m-%d'))
27 argp.add_argument('-o', '--output', type=str, default='out.csv')
28 args = argp.parse_args()
30 data = yaml.load(open(args.input).read())
31 with open(args.output, 'w') as outf:
32 writer = csv.DictWriter(
33 outf, ['date', 'name', 'language', 'code', 'comment', 'blank'])
34 for key, value in data.iteritems():
39 if key.startswith('third_party/'):
41 row = {'name': key, 'date': args.date}