Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lflex-celcat-survival
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
poquet
millian
lflex-celcat-survival
Commits
e2a05ac1
Commit
e2a05ac1
authored
7 months ago
by
Millian Poquet
Browse files
Options
Downloads
Patches
Plain Diff
code: add course types & improve debuggability
parent
a343591f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lflex_celcat_survival/events.py
+38
-33
38 additions, 33 deletions
lflex_celcat_survival/events.py
with
38 additions
and
33 deletions
lflex_celcat_survival/events.py
+
38
−
33
View file @
e2a05ac1
...
@@ -11,7 +11,7 @@ import re
...
@@ -11,7 +11,7 @@ import re
from
.
import
fetch
from
.
import
fetch
ROOM_RE
=
re
.
compile
(
r
'
^(?:FSI|F2SMH) / (.*)$
'
)
ROOM_RE
=
re
.
compile
(
r
'
^(?:FSI|F2SMH) / (.*)$
'
)
COURSE_TYPE_RE
=
re
.
compile
(
r
'
COURS|COURS/TD|TD|TP|CONTROLE CONTINU|CONTROLE PARTIEL
'
)
COURSE_TYPE_RE
=
re
.
compile
(
r
'
COURS|COURS/TD|TD|TP|CONTROLE CONTINU|CONTROLE PARTIEL
|EXAMEN|Controle de Substitution|CONSULTATION DE COPIES
'
)
STUDENT_GROUP_RE
=
re
.
compile
(
r
'
K?IN[A-Z0-9]+
'
)
STUDENT_GROUP_RE
=
re
.
compile
(
r
'
K?IN[A-Z0-9]+
'
)
class
CelcatEvents
:
class
CelcatEvents
:
...
@@ -98,47 +98,52 @@ def parse_description(row):
...
@@ -98,47 +98,52 @@ def parse_description(row):
groups
=
[]
groups
=
[]
course_type
=
'
unset
'
course_type
=
'
unset
'
if
len
(
fields
)
==
0
:
try
:
raise
ValueError
(
f
'
There should be at least 1 field, but fields are
{
fields
}
'
)
if
len
(
fields
)
==
0
:
elif
len
(
fields
)
==
1
:
raise
ValueError
(
f
'
There should be at least 1 field, but fields are
{
fields
}
'
)
# probably not a course. examples: "CONGES\r\n" or "FERIE\r\n"
elif
len
(
fields
)
==
1
:
course_type
=
fields
[
0
]
# probably not a course. examples: "CONGES\r\n" or "FERIE\r\n"
else
:
course_type
=
fields
[
0
]
# first fields should be the room, but this is not always set
else
:
while
(
m
:
=
ROOM_RE
.
match
(
fields
[
0
]))
is
not
None
:
# first fields should be the room, but this is not always set
rooms
.
append
(
m
[
1
])
while
(
m
:
=
ROOM_RE
.
match
(
fields
[
0
]))
is
not
None
:
rooms
.
append
(
m
[
1
])
fields
=
fields
[
1
:]
# assume that the next field is the course name, and skip it
fields
=
fields
[
1
:]
fields
=
fields
[
1
:]
# assume that the next field is the course name, and skip it
# skip notes at the end of the fields until they look like a course type
fields
=
fields
[
1
:]
while
COURSE_TYPE_RE
.
match
(
fields
[
-
1
])
is
None
:
fields
=
fields
[:
-
1
]
if
len
(
fields
)
<=
0
:
break
# skip notes at the end of the fields until they look like
a course type
# last field is
a course type
while
COURSE_TYPE_RE
.
match
(
fields
[
-
1
])
is
None
:
course_type
=
fields
[
-
1
]
fields
=
fields
[:
-
1
]
fields
=
fields
[:
-
1
]
if
len
(
fields
)
<=
0
:
break
# last field is a course type
# the last field may be a teacher, but this is optional
course_type
=
fields
[
-
1
]
if
STUDENT_GROUP_RE
.
match
(
fields
[
-
1
])
is
None
:
fields
=
fields
[:
-
1
]
teacher
=
fields
[
-
1
]
fields
=
fields
[:
-
1
]
# the last field may be a teacher, but this is optional
# all remaining fields should be student groups
if
STUDENT_GROUP_RE
.
match
(
fields
[
-
1
])
is
None
:
groups
=
[]
teacher
=
fields
[
-
1
]
while
len
(
fields
)
>
0
and
(
m
:
=
STUDENT_GROUP_RE
.
match
(
fields
[
0
]))
is
not
None
:
fields
=
fields
[:
-
1
]
groups
.
append
(
m
[
0
])
fields
=
fields
[
1
:]
# all remaining fields should be student groups
if
len
(
rooms
)
==
0
:
groups
=
[]
rooms
=
[
'
unset
'
]
while
len
(
fields
)
>
0
and
(
m
:
=
STUDENT_GROUP_RE
.
match
(
fields
[
0
]))
is
not
None
:
if
len
(
groups
)
==
0
:
groups
.
append
(
m
[
0
])
groups
=
[
'
unset
'
]
fields
=
fields
[
1
:]
if
len
(
rooms
)
==
0
:
return
pd
.
Series
([
rooms
,
teacher
,
course_type
,
groups
],
index
=
[
'
rooms_parsed
'
,
'
teacher_parsed
'
,
'
course_type_parsed
'
,
'
groups_parsed
'
])
rooms
=
[
'
unset
'
]
except
Exception
as
e
:
if
len
(
groups
)
==
0
:
print
(
f
"
Could not parse an event description. fields=
{
preparse_fields
}
"
)
groups
=
[
'
unset
'
]
raise
e
return
pd
.
Series
([
rooms
,
teacher
,
course_type
,
groups
],
index
=
[
'
rooms_parsed
'
,
'
teacher_parsed
'
,
'
course_type_parsed
'
,
'
groups_parsed
'
])
def
request_slots_by_mod_code
(
flat_slot_df
,
session
):
def
request_slots_by_mod_code
(
flat_slot_df
,
session
):
subject_codes
=
list
(
flat_slot_df
[
'
mod_code
'
].
dropna
().
unique
())
subject_codes
=
list
(
flat_slot_df
[
'
mod_code
'
].
dropna
().
unique
())
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment