66
77
88def main ():
9- '''
9+ """
1010 Getting user input and preforming corresponding actions.
1111 Available functions:
1212 - Create course/topic in classroom.
1313 - Print existing courses/topics.
1414 - Update teacher list.
1515 - Update student list.
16- '''
16+ """
1717
1818 logging .basicConfig (level = logging .INFO )
19- parser = argparse .ArgumentParser (description = 'ROSE Classroom' )
20- parser .add_argument ('--course' , action = 'store_true' ,
21- help = 'A flag for course actions, stores True. '
22- 'Has to be followed by an action as --create. '
23- 'If not specified, will be False.' )
24- parser .add_argument ('--topic' , action = 'store_true' ,
25- help = 'A flag for topic actions, stores True. '
26- 'Has to be followed by an action as --create. '
27- 'If not specified, will be False.' )
28- parser .add_argument ('--create' , '-c' , dest = 'name' ,
29- help = 'Creating a new instance using given name. '
30- 'If not specified, cannot be created. '
31- 'Follows an instance type as --course. '
32- 'For creating Topics, Assignments and more '
33- 'please specify the course/topic id using -i.' )
34- parser .add_argument ('--print' , '-p' , action = "store_true" ,
35- help = 'Printing existing instances.' )
36- parser .add_argument ('--teacher_list' , '-t' , dest = 'teacher_list' ,
37- help = 'Adding teachers using a list, '
38- 'expects a csv file. '
39- 'If course exists, '
40- 'please provide course ID using -i.' )
41- parser .add_argument ('--student_list' , '-s' , dest = 'student_list' ,
42- help = 'Adding students using a list, '
43- 'expects csv file. '
44- 'If course exists, '
45- 'please provide course ID using -i.' )
46- parser .add_argument ('--id' , '-i' ,
47- help = 'Specifies an instance id. Can be used for '
48- 'adding student lists or teacher lists, adding '
49- 'Topics, Homework and more. '
50- 'Please specify the needed action. '
51- 'Use combined with instance type as --course.' )
19+ parser = argparse .ArgumentParser (description = "ROSE Classroom" )
20+ parser .add_argument (
21+ "--course" ,
22+ action = "store_true" ,
23+ help = "A flag for course actions, stores True. "
24+ "Has to be followed by an action as --create. "
25+ "If not specified, will be False." ,
26+ )
27+ parser .add_argument (
28+ "--topic" ,
29+ action = "store_true" ,
30+ help = "A flag for topic actions, stores True. "
31+ "Has to be followed by an action as --create. "
32+ "If not specified, will be False." ,
33+ )
34+ parser .add_argument (
35+ "--create" ,
36+ "-c" ,
37+ dest = "name" ,
38+ help = "Creating a new instance using given name. "
39+ "If not specified, cannot be created. "
40+ "Follows an instance type as --course. "
41+ "For creating Topics, Assignments and more "
42+ "please specify the course/topic id using -i." ,
43+ )
44+ parser .add_argument (
45+ "--print" , "-p" , action = "store_true" , help = "Printing existing instances."
46+ )
47+ parser .add_argument (
48+ "--teacher_list" ,
49+ "-t" ,
50+ dest = "teacher_list" ,
51+ help = "Adding teachers using a list, "
52+ "expects a csv file. "
53+ "If course exists, "
54+ "please provide course ID using -i." ,
55+ )
56+ parser .add_argument (
57+ "--student_list" ,
58+ "-s" ,
59+ dest = "student_list" ,
60+ help = "Adding students using a list, "
61+ "expects csv file. "
62+ "If course exists, "
63+ "please provide course ID using -i." ,
64+ )
65+ parser .add_argument (
66+ "--id" ,
67+ "-i" ,
68+ help = "Specifies an instance id. Can be used for "
69+ "adding student lists or teacher lists, adding "
70+ "Topics, Homework and more. "
71+ "Please specify the needed action. "
72+ "Use combined with instance type as --course." ,
73+ )
5274
5375 args = parser .parse_args ()
5476
55- ''' Set up the service to google classroom'''
77+ """ Set up the service to google classroom"""
5678 service = connect_service .create_service ()
5779
5880 if args .id and len (args .id ) < 12 :
59- print (' Please check the ID specified and try again.' )
81+ print (" Please check the ID specified and try again." )
6082 elif args .course and not args .topic :
6183 if args .name :
6284 args .id = course_creator .create_course (service , args .name )
63- print (f' The id returned { args .id } ' )
85+ print (f" The id returned { args .id } " )
6486 elif args .print :
6587 course_creator .print_courses (service )
6688 elif not args .id :
67- print (' Please use --help to inspect the possible actions.' )
89+ print (" Please use --help to inspect the possible actions." )
6890 else :
6991 if args .teacher_list :
70- course_creator .create_invitation (service , args , ' TEACHER' )
92+ course_creator .create_invitation (service , args , " TEACHER" )
7193
7294 if args .student_list :
73- course_creator .create_invitation (service , args , ' STUDENT' )
95+ course_creator .create_invitation (service , args , " STUDENT" )
7496
7597 no_list = args .student_list is None and args .teacher_list is None
76- if ( no_list ) :
77- print (' Please use -h to check the available actions.' )
98+ if no_list :
99+ print (" Please use -h to check the available actions." )
78100 elif args .topic :
79101 if args .course and args .id :
80102 if args .print :
@@ -83,8 +105,8 @@ def main():
83105 if args .name :
84106 content_edit .create_topic (service , args .name , args .id )
85107 else :
86- print (' Wrong action' )
108+ print (" Wrong action" )
87109
88110
89- if __name__ == ' __main__' :
111+ if __name__ == " __main__" :
90112 main ()
0 commit comments