Skip to content

Commit 3faecc5

Browse files
committed
function call export_sheets moved to main
1 parent 850621b commit 3faecc5

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

export_sheets.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
11
import pygsheets
22
import pandas as pd
3-
import argparse
4-
53

64
INT_MASS = [{
75
"one": 1,
86
"two": 2,
97
"what?": 3
108
}]
11-
def arg_parser():
12-
parser = argparse.ArgumentParser()
13-
parser.add_argument('--csv_path', type=str, required=True, help='Specify path to output csv file')
14-
parser.add_argument('--google_token', type=str, required=False, help='Specify path to google token file')
15-
parser.add_argument('--table_id', type=str, required=False, help='Specify Google sheet document id (can find in url)')
16-
parser.add_argument('--sheet_id', type=str, required=False, help='Specify title for a sheet in a document in which data will be printed')
17-
args = parser.parse_args()
18-
return args
199

2010
def write_data_to_table(csv_path, google_token, table_id, sheet_id):
2111
if google_token and sheet_id and table_id :
@@ -41,10 +31,3 @@ def write_data_to_table(csv_path, google_token, table_id, sheet_id):
4131
wk_content.set_dataframe(df, 'A1', copy_head=True)
4232

4333

44-
def main():
45-
args = arg_parser()
46-
write_data_to_table(args.csv_path, args.google_token, args.table_id, args.sheet_id)
47-
48-
49-
if __name__ == "__main__":
50-
main()

main.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
11
import argparse
22
import git_logger
3-
3+
import export_sheets
44

55
def parse_args():
66
parser = argparse.ArgumentParser()
77
parser.add_argument("-p", help="log pull requests", action="store_true")
88
parser.add_argument("-i", help="log issues", action="store_true")
9+
parser.add_argument("-e", help="log issues", action="store_true")
910
parser.add_argument('-t', '--token', type=str, required=True, help='token github account')
1011
parser.add_argument('-l', '--list', type=str, required=True, help='repos names file')
1112
parser.add_argument('-o', '--out', type=str, required=True, help='output filename')
13+
parser.add_argument('--google_token', type=str, required=False, help='Specify path to google token file')
14+
parser.add_argument('--table_id', type=str, required=False,
15+
help='Specify Google sheet document id (can find in url)')
16+
parser.add_argument('--sheet_id', type=str, required=False,
17+
help='Specify title for a sheet in a document in which data will be printed')
18+
args = parser.parse_args()
19+
if args.e:
20+
for action in parser._actions:
21+
if action.dest == 'google_token':
22+
action.required = True
23+
if action.dest == 'table_id':
24+
action.required = True
25+
if action.dest == 'sheet_id':
26+
action.required = True
1227
return parser.parse_args()
1328

1429

@@ -25,10 +40,17 @@ def main():
2540
else:
2641
if not args.p and not args.i:
2742
git_logger.log_commits(client, repositories, csv_name)
43+
if (args.e):
44+
export_sheets.write_data_to_table(csv_name, args.google_token, args.table_id, args.sheet_id)
2845
if args.p:
2946
git_logger.log_pull_requests(client, repositories, csv_name)
47+
if (args.e):
48+
export_sheets.write_data_to_table(csv_name, args.google_token, args.table_id, args.sheet_id)
3049
if args.i:
3150
git_logger.log_issues(client, repositories, csv_name)
51+
if (args.e):
52+
export_sheets.write_data_to_table(csv_name, args.google_token, args.table_id, args.sheet_id)
53+
3254

3355

3456
if __name__ == '__main__':

0 commit comments

Comments
 (0)