parent
0fe74d35ee
commit
e2e34b8812
2 changed files with 41 additions and 0 deletions
@ -0,0 +1,17 @@ |
|||||||
|
#!/usr/bin/env python |
||||||
|
|
||||||
|
import subprocess |
||||||
|
import datetime |
||||||
|
|
||||||
|
def daterange(start, end): |
||||||
|
for n in range(int((end - start).days)): |
||||||
|
yield start + datetime.timedelta(n) |
||||||
|
|
||||||
|
start_date = datetime.date(2014, 11, 26) |
||||||
|
end_date = datetime.date(2017, 3, 26) |
||||||
|
|
||||||
|
for dt in daterange(start_date, end_date): |
||||||
|
dmy = dt.strftime('%Y-%m-%d') |
||||||
|
print dmy |
||||||
|
subprocess.check_call(['tools/line_count/yaml2csv.py', '-i', '../count/%s.yaml' % dmy, '-d', dmy, '-o', '../count/%s.csv' % dmy]) |
||||||
|
|
@ -0,0 +1,24 @@ |
|||||||
|
#!/usr/bin/env python |
||||||
|
|
||||||
|
import yaml |
||||||
|
import argparse |
||||||
|
import datetime |
||||||
|
import csv |
||||||
|
|
||||||
|
argp = argparse.ArgumentParser(description='Convert cloc yaml to bigquery csv') |
||||||
|
argp.add_argument('-i', '--input', type=str) |
||||||
|
argp.add_argument('-d', '--date', type=str, default=datetime.date.today().strftime('%Y-%m-%d')) |
||||||
|
argp.add_argument('-o', '--output', type=str, default='out.csv') |
||||||
|
args = argp.parse_args() |
||||||
|
|
||||||
|
data = yaml.load(open(args.input).read()) |
||||||
|
with open(args.output, 'w') as outf: |
||||||
|
writer = csv.DictWriter(outf, ['date', 'name', 'language', 'code', 'comment', 'blank']) |
||||||
|
for key, value in data.iteritems(): |
||||||
|
if key == 'header': continue |
||||||
|
if key == 'SUM': continue |
||||||
|
if key.startswith('third_party/'): continue |
||||||
|
row = {'name': key, 'date': args.date} |
||||||
|
row.update(value) |
||||||
|
writer.writerow(row) |
||||||
|
|
Loading…
Reference in new issue