Skip to content

Commit 0398cb7

Browse files
rename sheet_id to sheet_name
1 parent c905a31 commit 0398cb7

File tree

8 files changed

+29
-29
lines changed

8 files changed

+29
-29
lines changed

moodle_export/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
Получение данных и в файл, и в Google таблицу:
2020

21-
```python3 grades_parser.py grades_parser --moodle_token "your token" --url http://e.moevm.info --course_id "your course id"[,"id",..] --csv_path "name of file" [--percentages] [--options github] --google_token "your google token" --table_id "your table id"[,"id",..] [--sheet_id "name of sheet"[,"name",..]] ```
21+
```python3 grades_parser.py grades_parser --moodle_token "your token" --url http://e.moevm.info --course_id "your course id"[,"id",..] --csv_path "name of file" [--percentages] [--options github] --google_token "your google token" --table_id "your table id"[,"id",..] [--sheet_name "name of sheet"[,"name",..]] ```
2222

2323
Получение данных и в файл, и на Яндекс Диск:
2424

@@ -36,7 +36,7 @@
3636

3737
Запуск докер контейнера с параметрами:
3838

39-
``` docker run --rm grades_parser --moodle_token "your token" --url http://e.moevm.info --course_id "your course id"[,"id",..] --csv_path "name of file" [--percentages] [--options github] --google_token "your google token" --table_id "your table id"[,"id",..] [--sheet_id "name of sheet"[,"name",..]] ```
39+
``` docker run --rm grades_parser --moodle_token "your token" --url http://e.moevm.info --course_id "your course id"[,"id",..] --csv_path "name of file" [--percentages] [--options github] --google_token "your google token" --table_id "your table id"[,"id",..] [--sheet_name "name of sheet"[,"name",..]] ```
4040

4141

4242
## Получение Moodle Токена.

moodle_export/args_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def arg_parser():
99
parser.add_argument('--csv_path', type=str, required=True, help='Specify path to output csv file')
1010
parser.add_argument('--google_token', type=str, required=False, help='Specify path to google token file')
1111
parser.add_argument('--table_id', type=lambda s: [i for i in s.split(',')], required=False, help='Specify Google sheet document id (can find in url)')
12-
parser.add_argument('--sheet_id', type=lambda s: [i for i in s.split(',')], required=False, help='Specify title for a sheet in a document in which data will be printed')
12+
parser.add_argument('--sheet_name', type=lambda s: [i for i in s.split(',')], required=False, help='Specify title for a sheet in a document in which data will be printed')
1313
parser.add_argument('--yandex_token', type=str, required=False, help='Specify Yandex token from https://oauth.yandex.ru/client/new application')
1414
parser.add_argument('--yandex_path', type=str, required=False, help='Specify output filename on Yandex Disk')
1515
parser.add_argument('--percentages', required=False, action='store_true', help='If set then grades will be printed as percentages')

moodle_export/grades_parser.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,17 @@ def main(cls):
153153
elif i == len(cls.args.table_id) - 1:
154154
table_id = cls.args.table_id[i]
155155

156-
if cls.args.sheet_id:
157-
for i in range(0, len(cls.args.sheet_id)):
156+
if cls.args.sheet_name:
157+
for i in range(0, len(cls.args.sheet_name)):
158158
if cls.args.course_id[i] == course_id:
159-
sheet_id = cls.args.sheet_id[i]
159+
sheet_name = cls.args.sheet_name[i]
160160
break
161161
else:
162-
sheet_id = cls.args.sheet_id[i] + ' ' + course_id
162+
sheet_name = cls.args.sheet_name[i] + ' ' + course_id
163163
else:
164-
sheet_id = 'course ' + course_id
164+
sheet_name = 'course ' + course_id
165165

166-
sheets.write_data_to_table(df, cls.args.google_token, table_id, sheet_id)
166+
sheets.write_data_to_table(df, cls.args.google_token, table_id, sheet_name)
167167

168168
# write data to yandex disk
169169
if cls.args.yandex_token and cls.args.yandex_path:

moodle_export/sheets.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33
import args_parser
44

55

6-
def write_data_to_table(df_data, google_token, table_id, sheet_id):
7-
if google_token and sheet_id and table_id:
6+
def write_data_to_table(df_data, google_token, table_id, sheet_name):
7+
if google_token and sheet_name and table_id:
88
gc = pygsheets.authorize(service_file=google_token)
99
sh = gc.open_by_key(table_id)
1010

1111
try:
12-
sh.worksheets('title', sheet_id)
12+
sh.worksheets('title', sheet_name)
1313
except:
14-
sh.add_worksheet(sheet_id)
14+
sh.add_worksheet(sheet_name)
1515

16-
wk_content = sh.worksheet_by_title(sheet_id)
16+
wk_content = sh.worksheet_by_title(sheet_name)
1717

1818
wk_content.set_dataframe(df_data, 'A1', copy_head=True)
1919

2020

2121
def main():
2222
args = args_parser.arg_parser()
23-
write_data_to_table(args.csv_path, args.google_token, args.table_id, args.sheet_id)
23+
write_data_to_table(args.csv_path, args.google_token, args.table_id, args.sheet_name)
2424

2525

2626
if __name__ == "__main__":

stepik_export/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
Получение данных и в файл, и в Google таблицу:
1515

16-
``` python3 stepik_parser.py --client_id "Your client id" --client_secret "Your client secret" --url https://stepik.org:443/api --course_id "Your course id" --class_id "Your class id" --csv_path grades --google_token "Path to your google token" --table_id "Your table id" [--sheet_id "Name of sheet"] ```
16+
``` python3 stepik_parser.py --client_id "Your client id" --client_secret "Your client secret" --url https://stepik.org:443/api --course_id "Your course id" --class_id "Your class id" --csv_path grades --google_token "Path to your google token" --table_id "Your table id" [--sheet_name "Name of sheet"] ```
1717

1818
Получение данных и в файл, и на Яндекс Диск:
1919

@@ -31,7 +31,7 @@
3131

3232
Запуск докер контейнера с параметрами:
3333

34-
``` docker run -v "Path to your google token":/app/ --rm stepik_parser.py --client_id "Your client id" --client_secret "Your client secret" --url https://stepik.org:443/api --course_id "Your course id" --class_id "Your class id" --csv_path grades --google_token "Path to your google token" --table_id "Your table id" [--sheet_id "Name of sheet"] ```
34+
``` docker run -v "Path to your google token":/app/ --rm stepik_parser.py --client_id "Your client id" --client_secret "Your client secret" --url https://stepik.org:443/api --course_id "Your course id" --class_id "Your class id" --csv_path grades --google_token "Path to your google token" --table_id "Your table id" [--sheet_name "Name of sheet"] ```
3535

3636

3737
## Получение Stepik Токена.

stepik_export/args_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def arg_parser():
1111
parser.add_argument('--csv_path', type=str, required=True, help='Specify path to output csv file')
1212
parser.add_argument('--google_token', type=str, required=False, help='Specify path to google token file')
1313
parser.add_argument('--table_id', type=str, required=False, help='Specify Google sheet document id (can find in url)')
14-
parser.add_argument('--sheet_id', type=str, required=False, help='Specify title for a sheet in a document in which data will be printed')
14+
parser.add_argument('--sheet_name', type=str, required=False, help='Specify title for a sheet in a document in which data will be printed')
1515
parser.add_argument('--yandex_token', type=str, required=False, help='Specify Yandex token from https://oauth.yandex.ru/client/new application')
1616
parser.add_argument('--yandex_path', type=str, required=False, help='Specify output filename on Yandex Disk')
1717
args = parser.parse_args()

stepik_export/sheets.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
}]
1111

1212

13-
def write_data_to_table(csv_path, google_token, table_id, sheet_id):
14-
if google_token and sheet_id and table_id:
13+
def write_data_to_table(csv_path, google_token, table_id, sheet_name):
14+
if google_token and sheet_name and table_id:
1515
gc = pygsheets.authorize(service_file=google_token)
1616
sh = gc.open_by_key(table_id)
1717

1818
try:
19-
sh.worksheets('title', sheet_id)
19+
sh.worksheets('title', sheet_name)
2020
except:
21-
sh.add_worksheet(sheet_id)
21+
sh.add_worksheet(sheet_name)
2222

23-
wk_content = sh.worksheet_by_title(sheet_id)
23+
wk_content = sh.worksheet_by_title(sheet_name)
2424

2525
if csv_path:
2626
df = pd.read_csv(csv_path)
@@ -33,7 +33,7 @@ def write_data_to_table(csv_path, google_token, table_id, sheet_id):
3333

3434
def main():
3535
args = args_parser.arg_parser()
36-
write_data_to_table(args.csv_path, args.google_token, args.table_id, args.sheet_id)
36+
write_data_to_table(args.csv_path, args.google_token, args.table_id, args.sheet_name)
3737

3838

3939
if __name__ == "__main__":

stepik_export/stepik_parser.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@ def main():
135135
# write data to sheets document
136136
if args.google_token and args.table_id:
137137
print('Send data to Google Sheets')
138-
if args.sheet_id:
139-
sheet_id = args.sheet_id
138+
if args.sheet_name:
139+
sheet_name = args.sheet_name
140140
else:
141-
sheet_id = 'course ' + args.course_id
142-
sheets.write_data_to_table(csv_path, args.google_token, args.table_id, sheet_id)
143-
print(f'Check data in your table! List name is: {sheet_id}')
141+
sheet_name = 'course ' + args.course_id
142+
sheets.write_data_to_table(csv_path, args.google_token, args.table_id, sheet_name)
143+
print(f'Check data in your table! List name is: {sheet_name}')
144144
print('********************************************************')
145145

146146
# write data to yandex disk

0 commit comments

Comments
 (0)