ladok3 4.17__py3-none-any.whl → 4.19__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 +0 -0
- ladok3/__init__.py +619 -3130
- ladok3/api.nw +1001 -10
- ladok3/ladok3.nw +70 -4
- ladok3/report.nw +124 -117
- ladok3/report.py +81 -63
- ladok3/student.nw +20 -1
- ladok3/student.py +62 -41
- ladok3/undoc.nw +54 -3111
- {ladok3-4.17.dist-info → ladok3-4.19.dist-info}/LICENSE +1 -1
- {ladok3-4.17.dist-info → ladok3-4.19.dist-info}/METADATA +28 -1
- ladok3-4.19.dist-info/RECORD +21 -0
- ladok3-4.17.dist-info/RECORD +0 -21
- {ladok3-4.17.dist-info → ladok3-4.19.dist-info}/WHEEL +0 -0
- {ladok3-4.17.dist-info → ladok3-4.19.dist-info}/entry_points.txt +0 -0
ladok3/student.py
CHANGED
|
@@ -1,54 +1,75 @@
|
|
|
1
1
|
import csv
|
|
2
2
|
import ladok3.cli
|
|
3
3
|
|
|
4
|
+
|
|
4
5
|
def print_student_data(student):
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
"""Prints the student data, all attributes, to stdout."""
|
|
7
|
+
print(f"First name: {student.first_name}")
|
|
8
|
+
print(f"Last name: {student.last_name}")
|
|
9
|
+
print(f"Personnummer: {student.personnummer}")
|
|
10
|
+
print(f"LADOK ID: {student.ladok_id}")
|
|
11
|
+
print(f"Alive: {student.alive}")
|
|
12
|
+
print(f"Suspended: ", end="")
|
|
13
|
+
if any(map(lambda x: x.is_current, student.suspensions)):
|
|
14
|
+
print("YES")
|
|
15
|
+
else:
|
|
16
|
+
print("no")
|
|
17
|
+
if student.suspensions:
|
|
18
|
+
print(f"Suspenions: ", end="")
|
|
19
|
+
for suspension in student.suspensions:
|
|
20
|
+
print(f"{suspension}", end="\n ")
|
|
21
|
+
print()
|
|
22
|
+
|
|
23
|
+
|
|
12
24
|
def print_course_data(student, args):
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
"""Prints the courses"""
|
|
26
|
+
print("Courses:")
|
|
27
|
+
for course in student.courses(code=args.course):
|
|
28
|
+
print(f"{course}")
|
|
29
|
+
if args.results:
|
|
30
|
+
for result in course.results():
|
|
31
|
+
print(f" {result}")
|
|
32
|
+
|
|
20
33
|
|
|
21
34
|
def add_command_options(parser):
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
35
|
+
student_parser = parser.add_parser(
|
|
36
|
+
"student",
|
|
37
|
+
help="Shows a student's information in LADOK",
|
|
38
|
+
description="""
|
|
25
39
|
Show a student's information in LADOK.
|
|
26
40
|
Shows information like name, personnummer, contact information.
|
|
27
|
-
"""
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
""",
|
|
42
|
+
)
|
|
43
|
+
student_parser.set_defaults(func=command)
|
|
44
|
+
student_parser.add_argument(
|
|
45
|
+
"id", help="The student's ID, either personnummer or LADOK ID"
|
|
46
|
+
)
|
|
47
|
+
student_parser.add_argument(
|
|
48
|
+
"-c",
|
|
49
|
+
"--course",
|
|
50
|
+
nargs="?",
|
|
51
|
+
const=".*",
|
|
52
|
+
help="A regular expression for which course codes to list, "
|
|
53
|
+
"use no value for listing all courses.",
|
|
54
|
+
)
|
|
55
|
+
student_parser.add_argument(
|
|
56
|
+
"-r",
|
|
57
|
+
"--results",
|
|
58
|
+
action="store_true",
|
|
59
|
+
default=False,
|
|
60
|
+
help="Set to include results for each course listed.",
|
|
61
|
+
)
|
|
62
|
+
|
|
42
63
|
|
|
43
64
|
def command(ladok, args):
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
65
|
+
try:
|
|
66
|
+
student = ladok.get_student(args.id)
|
|
67
|
+
student.alive
|
|
68
|
+
except Exception as err:
|
|
69
|
+
ladok3.cli.err(-1, f"can't fetch student data for {args.id}: {err}")
|
|
49
70
|
|
|
50
|
-
|
|
71
|
+
print_student_data(student)
|
|
51
72
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
73
|
+
if args.course:
|
|
74
|
+
print()
|
|
75
|
+
print_course_data(student, args)
|