ladok3 3.7__py3-none-any.whl → 3.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ladok3 might be problematic. Click here for more details.

doc/ltxobj/ladok3.pdf CHANGED
Binary file
ladok3/report.nw CHANGED
@@ -129,8 +129,8 @@ them.
129
129
  <<check that we got all positional arguments>>
130
130
  try:
131
131
  student = ladok.get_student(args.student_id)
132
- course = student.courses(code=args.course_code)[0]
133
- result = course.results(component=args.component_code)[0]
132
+ <<look up [[course]] from [[student]]>>
133
+ <<look up [[result]] from [[course]]>>
134
134
  result.set_grade(args.grade, args.date)
135
135
  if args.finalize:
136
136
  result.finalize()
@@ -139,9 +139,25 @@ except Exception as err:
139
139
  print(f"{student}: {err}")
140
140
  except ValueError as verr:
141
141
  print(f"{verr}: {args.student_id}: {err}")
142
- @ This means that we need the following command-line arguments.
143
- The option [[args.finalize]] is already set above, so we don't need to add that
144
- one here.
142
+ @ The option [[args.finalize]] is already set above, so we don't need to add
143
+ that one here.
144
+
145
+ Both looking up the course and the component can yield index errors.
146
+ We'd like to distinguish these.
147
+ We will catch the exception, the reraise the same exception but with a better
148
+ error message.
149
+ <<look up [[course]] from [[student]]>>=
150
+ try:
151
+ course = student.courses(code=args.course_code)[0]
152
+ except IndexError:
153
+ raise Exception("f{args.course_code}: No such course for {student}")
154
+ <<look up [[result]] from [[course]]>>=
155
+ try:
156
+ result = course.results(component=args.component_code)[0]
157
+ except IndexError:
158
+ raise Exception(f"{args.component_code}: "
159
+ f"No such component for {args.course_code}")
160
+ @
145
161
 
146
162
 
147
163
  \section{Report many results given in standard input}
@@ -180,23 +196,14 @@ try:
180
196
  try:
181
197
  course = student.courses(code=course_code)[0]
182
198
  except IndexError:
183
- raise Exception(f"{course_code}: no such course.")
199
+ raise Exception(f"{course_code}: No such course for {student}")
184
200
 
185
201
  try:
186
202
  component = course.results(component=component_code)[0]
187
203
  except IndexError:
188
- raise Exception(f"{course_code} has no component {component_code}.")
204
+ raise Exception(f"{component_code}: no such component for {course_code}")
189
205
 
190
- if not component.attested and component.grade != grade:
191
- component.set_grade(grade, date)
192
- component.finalize()
193
- if args.verbose:
194
- print(f"{course_code} {student}: reported "
195
- f"{component.component} = {component.grade} ({date}).")
196
- elif component.grade != grade:
197
- print(f"{course_code} {student}: attested {component.component} "
198
- f"result {component.grade} ({component.date}) "
199
- f"is different from {grade} ({date}).")
206
+ <<set [[grade]] to [[component]], output if verbose>>
200
207
  except Exception as err:
201
208
  try:
202
209
  print(f"{course_code} {component_code}={grade} ({date}) {student}: {err}",
@@ -207,6 +214,30 @@ except Exception as err:
207
214
  file=sys.stderr)
208
215
  @
209
216
 
217
+ Now, when we set the grade, there are a few cases that should be handled.
218
+ If the grade isn't attested, we try to change it.
219
+ (This might still fail if the grade is finalized but not attested.)
220
+ If we've selected the verbose option, then we print what we have reported.
221
+
222
+ If the grade was attested, then we check if it's different.
223
+ If it's different, we output this.
224
+ If it's the same, we silently ignore it.
225
+ This is best for bulk reporting, because then we can always try to report for
226
+ all students.
227
+ <<set [[grade]] to [[component]], output if verbose>>=
228
+ if not component.attested and component.grade != grade:
229
+ component.set_grade(grade, date)
230
+ if args.finalize:
231
+ component.finalize()
232
+ if args.verbose:
233
+ print(f"{course_code} {student}: reported "
234
+ f"{component.component} = {component.grade} ({date}).")
235
+ elif component.grade != grade:
236
+ print(f"{course_code} {student}: attested {component.component} "
237
+ f"result {component.grade} ({component.date}) "
238
+ f"is different from {grade} ({date}).")
239
+ @
240
+
210
241
 
211
242
  \section{Determine which function to run}
212
243
 
ladok3/report.py CHANGED
@@ -12,8 +12,15 @@ def report_one_result(ladok, args):
12
12
  sys.exit(1)
13
13
  try:
14
14
  student = ladok.get_student(args.student_id)
15
- course = student.courses(code=args.course_code)[0]
16
- result = course.results(component=args.component_code)[0]
15
+ try:
16
+ course = student.courses(code=args.course_code)[0]
17
+ except IndexError:
18
+ raise Exception("f{args.course_code}: No such course for {student}")
19
+ try:
20
+ result = course.results(component=args.component_code)[0]
21
+ except IndexError:
22
+ raise Exception(f"{args.component_code}: "
23
+ f"No such component for {args.course_code}")
17
24
  result.set_grade(args.grade, args.date)
18
25
  if args.finalize:
19
26
  result.finalize()
@@ -32,16 +39,17 @@ def report_many_results(ladok, args):
32
39
  try:
33
40
  course = student.courses(code=course_code)[0]
34
41
  except IndexError:
35
- raise Exception(f"{course_code}: no such course.")
42
+ raise Exception(f"{course_code}: No such course for {student}")
36
43
 
37
44
  try:
38
45
  component = course.results(component=component_code)[0]
39
46
  except IndexError:
40
- raise Exception(f"{course_code} has no component {component_code}.")
47
+ raise Exception(f"{component_code}: no such component for {course_code}")
41
48
 
42
49
  if not component.attested and component.grade != grade:
43
50
  component.set_grade(grade, date)
44
- component.finalize()
51
+ if args.finalize:
52
+ component.finalize()
45
53
  if args.verbose:
46
54
  print(f"{course_code} {student}: reported "
47
55
  f"{component.component} = {component.grade} ({date}).")
ladok3/student.nw CHANGED
@@ -63,6 +63,17 @@ student_parser.add_argument("-c", "--course",
63
63
  )
64
64
  @
65
65
 
66
+ \subsection{A results flag}
67
+
68
+ We also want a flag for specifying whether or not to include the results of
69
+ each course.
70
+ <<add student command arguments to student parser>>=
71
+ student_parser.add_argument("-r", "--results",
72
+ action="store_true", default=False,
73
+ help="Set to include results for each course listed."
74
+ )
75
+ @
76
+
66
77
  \section{Print the student data}
67
78
 
68
79
  Now that we have the student identifier, we can simply use that to fetch the
@@ -80,7 +91,7 @@ print_student_data(student)
80
91
 
81
92
  if args.course:
82
93
  print()
83
- print_course_data(student, args.course)
94
+ print_course_data(student, args)
84
95
  @
85
96
 
86
97
  \subsection{Printing personal student data}
@@ -102,13 +113,15 @@ def print_student_data(student):
102
113
 
103
114
  To print the student's course data, we simply filter the courses on the option
104
115
  that the user supplies.
105
- We then print all results for each course.
116
+ We then print all courses and, if the flag is set, we also print the results
117
+ for each course.
106
118
  <<functions>>=
107
- def print_course_data(student, course):
119
+ def print_course_data(student, args):
108
120
  """Prints the courses"""
109
121
  print("Courses:")
110
- for course in student.courses(code=course):
122
+ for course in student.courses(code=args.course):
111
123
  print(f"{course}")
112
- for result in course.results():
113
- print(f" {result}")
124
+ if args.results:
125
+ for result in course.results():
126
+ print(f" {result}")
114
127
  @
ladok3/student.py CHANGED
@@ -9,13 +9,14 @@ def print_student_data(student):
9
9
  print(f"LADOK ID: {student.ladok_id}")
10
10
  print(f"Alive: {student.alive}")
11
11
  print(f"Suspended: {student.suspensions}")
12
- def print_course_data(student, course):
12
+ def print_course_data(student, args):
13
13
  """Prints the courses"""
14
14
  print("Courses:")
15
- for course in student.courses(code=course):
15
+ for course in student.courses(code=args.course):
16
16
  print(f"{course}")
17
- for result in course.results():
18
- print(f" {result}")
17
+ if args.results:
18
+ for result in course.results():
19
+ print(f" {result}")
19
20
 
20
21
  def add_command_options(parser):
21
22
  student_parser = parser.add_parser("student",
@@ -34,6 +35,10 @@ def add_command_options(parser):
34
35
  help="A regular expression for which course codes to list, " \
35
36
  "use no value for listing all courses."
36
37
  )
38
+ student_parser.add_argument("-r", "--results",
39
+ action="store_true", default=False,
40
+ help="Set to include results for each course listed."
41
+ )
37
42
 
38
43
  def command(ladok, args):
39
44
  try:
@@ -46,4 +51,4 @@ def command(ladok, args):
46
51
 
47
52
  if args.course:
48
53
  print()
49
- print_course_data(student, args.course)
54
+ print_course_data(student, args)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ladok3
3
- Version: 3.7
3
+ Version: 3.8
4
4
  Summary: Python wrapper and CLI for the LADOK3 REST API.
5
5
  Home-page: https://github.com/dbosk/ladok3
6
6
  License: MIT
@@ -1,4 +1,4 @@
1
- doc/ltxobj/ladok3.pdf,sha256=icIbzJ8YAOai3DhC7XrIMphm7LGkclZHwxGzPl3u_-E,1334876
1
+ doc/ltxobj/ladok3.pdf,sha256=c0iYxLo-08604cbpbqH0H2kPY7C0r__Zde1B9T53yEM,1335740
2
2
  ladok3/.gitignore,sha256=QOcCshtjIsFasi4vaqFcooBWPJkxVWaoYEWOBBtdY_w,81
3
3
  ladok3/Makefile,sha256=Jy6OFjoVLU9YivnVxctxI_zrUOK9ysEOiistJ3ST6Nw,557
4
4
  ladok3/__init__.py,sha256=bdFgx0CHaosa5hDqmLbIGjq6IoVHkXqO--yaIpuOOGU,228872
@@ -10,14 +10,14 @@ ladok3/data.py,sha256=mCHySFtQL_oh6mkfMbgRM4T1bnM8HR45eumgoKFwomk,5893
10
10
  ladok3/kth.py,sha256=aoodYd2bLQcPNQiFwyP0mppJO399UcqUgUhN9wzVwBA,3720
11
11
  ladok3/ladok.bash,sha256=zGfTFdtos2zLjV13pzfK-1uCy2b_lF2qUKMoL2ExW7c,1441
12
12
  ladok3/ladok3.nw,sha256=UoiEJAIihPNrHuMHWjoNoz7pl2hDEkziGE3B6X6zbk0,50144
13
- ladok3/report.nw,sha256=_PUV9Qrg1aUuxiqcQg3VNOApOY3oDdTEJSCOdRiluyc,7303
14
- ladok3/report.py,sha256=rNCIiPTd9egw8iXSSKsmyrcF3NebqinpuRxfphcyIjo,4082
15
- ladok3/student.nw,sha256=RFS3Uo-l_dYsmm41Psh4EPO3LpJQ2ipDSLBsFhlkTco,3356
16
- ladok3/student.py,sha256=3YRf6WXimFBusH-sBiWKJhEJ_W-qfzqVPox2sLJNFCI,1531
13
+ ladok3/report.nw,sha256=DuJWJuslBxo8n2hxWZvao_nRWQO1TIAlJLF0BMc-Mto,8461
14
+ ladok3/report.py,sha256=PwLeoB2MXDlVPI5zNs4hICchKVPMmQlMIRHiBKW0xn4,4387
15
+ ladok3/student.nw,sha256=zayn9_b9jCKeMnZxSGS_EuSmF3ojOBHQDMUMMkpRssI,3747
16
+ ladok3/student.py,sha256=TaYn2rpbQnzummB-8xz-sUEV31Gh0CUmU0QkF6VgEic,1703
17
17
  ladok3/test.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  ladok3/undoc.nw,sha256=NyHuVIzrRqJPM39MyAlZNEE7PbXdUDJFQ2kJ0NfdwQI,180333
19
- ladok3-3.7.dist-info/LICENSE,sha256=s_C5qznXAvDRrzU7vRd4eqzshyIkAfPwGyVBihGeOdM,1155
20
- ladok3-3.7.dist-info/METADATA,sha256=Jelc3ichBPu0MfSaO58NbteMHOAuenpMG4Z6-X95NEc,8098
21
- ladok3-3.7.dist-info/WHEEL,sha256=kLuE8m1WYU0Ig0_YEGrXyTtiJvKPpLpDEiChiNyei5Y,88
22
- ladok3-3.7.dist-info/entry_points.txt,sha256=pi-KKP5Obo0AyuDjXQUpadS9kIvAY2_5ORhPgEYlJv8,41
23
- ladok3-3.7.dist-info/RECORD,,
19
+ ladok3-3.8.dist-info/LICENSE,sha256=s_C5qznXAvDRrzU7vRd4eqzshyIkAfPwGyVBihGeOdM,1155
20
+ ladok3-3.8.dist-info/METADATA,sha256=uFSCD7Y5d9z6rv6BuE7EXBb0Exk9AxKodSY3mQnc4ug,8098
21
+ ladok3-3.8.dist-info/WHEEL,sha256=kLuE8m1WYU0Ig0_YEGrXyTtiJvKPpLpDEiChiNyei5Y,88
22
+ ladok3-3.8.dist-info/entry_points.txt,sha256=pi-KKP5Obo0AyuDjXQUpadS9kIvAY2_5ORhPgEYlJv8,41
23
+ ladok3-3.8.dist-info/RECORD,,
File without changes
File without changes