|
3 | 3 | import pytz |
4 | 4 |
|
5 | 5 | import git_logger |
6 | | - |
| 6 | +import export_sheets |
7 | 7 |
|
8 | 8 | def parse_args(): |
9 | 9 | parser = argparse.ArgumentParser() |
10 | 10 | parser.add_argument("-p", help="log pull requests", action="store_true") |
11 | 11 | parser.add_argument("-i", help="log issues", action="store_true") |
| 12 | + parser.add_argument("-e", help="export table to google sheets", action="store_true") |
12 | 13 | parser.add_argument('-t', '--token', type=str, required=True, help='token github account') |
13 | 14 | parser.add_argument('-l', '--list', type=str, required=True, help='repos names file') |
14 | 15 | parser.add_argument('-o', '--out', type=str, required=True, help='output filename') |
15 | 16 | parser.add_argument('-s', '--start', type=str, required=False, help='start time', default='2000/01/01-00:00:00') |
16 | 17 | parser.add_argument('-f', '--finish', type=str, required=False, help='finish time', default='2400/01/01-00:00:00') |
| 18 | + parser.add_argument('--google_token', type=str, required=False, help='Specify path to google token file') |
| 19 | + parser.add_argument('--table_id', type=str, required=False, |
| 20 | + help='Specify Google sheet document id (can find in url)') |
| 21 | + parser.add_argument('--sheet_id', type=str, required=False, |
| 22 | + help='Specify title for a sheet in a document in which data will be printed') |
| 23 | + args = parser.parse_args() |
| 24 | + |
| 25 | + if args.e: |
| 26 | + for action in parser._actions: |
| 27 | + if action.dest == 'google_token': |
| 28 | + action.required = True |
| 29 | + if action.dest == 'table_id': |
| 30 | + action.required = True |
| 31 | + if action.dest == 'sheet_id': |
| 32 | + action.required = True |
17 | 33 | return parser.parse_args() |
18 | 34 |
|
19 | 35 |
|
@@ -43,10 +59,16 @@ def main(): |
43 | 59 | finish = parse_time(args.finish.split('-')) |
44 | 60 | if not args.p and not args.i: |
45 | 61 | git_logger.log_commits(client, repositories, csv_name, start, finish) |
| 62 | + if (args.e): |
| 63 | + export_sheets.write_data_to_table(csv_name, args.google_token, args.table_id, args.sheet_id) |
46 | 64 | if args.p: |
47 | 65 | git_logger.log_pull_requests(client, repositories, csv_name, token, start, finish) |
| 66 | + if (args.e): |
| 67 | + export_sheets.write_data_to_table(csv_name, args.google_token, args.table_id, args.sheet_id) |
48 | 68 | if args.i: |
49 | 69 | git_logger.log_issues(client, repositories, csv_name, token, start, finish) |
| 70 | + if (args.e): |
| 71 | + export_sheets.write_data_to_table(csv_name, args.google_token, args.table_id, args.sheet_id) |
50 | 72 |
|
51 | 73 |
|
52 | 74 |
|
|
0 commit comments