Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hektor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Jan Maximilian Michal
hektor
Commits
f62d4b8e
There was a problem fetching the pipeline summary.
Verified
Commit
f62d4b8e
authored
7 years ago
by
Jan Maximilian Michal
Browse files
Options
Downloads
Patches
Plain Diff
Allow broken matrikulation numbers in xls
parent
3b6eac53
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/xls.py
+12
-5
12 additions, 5 deletions
lib/xls.py
with
12 additions
and
5 deletions
lib/xls.py
+
12
−
5
View file @
f62d4b8e
...
...
@@ -48,24 +48,31 @@ user_t = namedtuple('user_head', 'name matrikel_no')
task_head_re
=
re
.
compile
(
r
'
^Quellcode Frage (?P<title>.*?) ?(\d{8})?$
'
)
# nor parsing the weird mat no
matno_re
=
re
.
compile
(
r
'
^(?P<matrikel_no>\d
{8}
)-(\d+)-(\d+)$
'
)
matno_re
=
re
.
compile
(
r
'
^(?P<matrikel_no>\d
+
)-(\d+)-(\d+)$
'
)
TABWIDTH
=
4
def
converter
(
infile
,
usernames
=
None
,
number_of_tasks
=
0
,
):
def
converter
(
infile
,
usernames
=
None
,
number_of_tasks
=
0
):
# Modify these iterators in order to change extraction behaviour
def
sheet_iter_meta
(
sheet
):
def
sheet_iter_meta
(
sheet
,
silent
=
True
):
"""
yield first and second col entry as tuple of (name, matnr)
"""
for
row
in
(
sheet
.
row
(
i
)
for
i
in
range
(
1
,
sheet
.
nrows
)):
match
=
re
.
search
(
matno_re
,
row
[
1
].
value
)
if
match
:
if
not
silent
and
len
(
match
.
group
(
'
matrikel_no
'
))
!=
8
:
print
(
'
[WARN] %s has odd matrikelno %s
'
%
(
row
[
0
].
value
,
match
.
group
(
'
matrikel_no
'
)))
yield
row
[
0
].
value
,
match
.
group
(
'
matrikel_no
'
)
else
:
if
not
silent
:
print
(
'
[WARN] could not parse row %s
'
%
row
[
0
])
yield
row
[
0
].
value
,
row
[
1
].
value
def
sheet_iter_data
(
sheet
):
"""
yields all source code tit
e
l and code tuples
"""
"""
yields all source code titl
e
and code tuples
"""
def
row
(
i
):
return
sheet
.
row
(
i
)
for
top
,
low
in
((
row
(
i
),
row
(
i
+
1
))
for
i
in
range
(
sheet
.
nrows
-
1
)):
...
...
@@ -77,7 +84,7 @@ def converter(infile, usernames=None, number_of_tasks=0,):
meta
,
*
data
=
open_workbook
(
infile
,
open
(
os
.
devnull
,
'
w
'
)).
sheets
()
# nice!
name2mat
=
dict
(
sheet_iter_meta
(
meta
))
name2mat
=
dict
(
sheet_iter_meta
(
meta
,
silent
=
False
))
assert
len
(
name2mat
)
==
len
(
data
),
'
{} names != {} sheets
'
.
format
(
len
(
name2mat
),
len
(
data
))
# noqa
# from xls to lists and namedtuples
...
...
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