Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Odevzdávací Systém MO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
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
Martin Mareš
Odevzdávací Systém MO
Commits
ae315d27
Commit
ae315d27
authored
4 months ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Diplomy: Zobecněno hledání standardního pozadí
parent
d0e06d55
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
mo/jobs/certs.py
+20
-12
20 additions, 12 deletions
mo/jobs/certs.py
with
20 additions
and
12 deletions
mo/jobs/certs.py
+
20
−
12
View file @
ae315d27
...
...
@@ -41,6 +41,21 @@ class BackgroundType(db.MOEnum):
def
friendly_name
(
self
)
->
str
:
return
background_type_names
[
self
]
def
find_default_background
(
self
,
round
:
db
.
Round
)
->
Optional
[
str
]:
bg
=
self
.
name
certs_dir
=
mo
.
util
.
data_dir
(
'
certs
'
)
candidates
=
[
f
'
{
round
.
round_code
()
}
/bg-
{
bg
}
.pdf
'
,
f
'
bg-
{
bg
}
.pdf
'
,
]
for
cand
in
candidates
:
bg
=
os
.
path
.
join
(
certs_dir
,
cand
)
if
os
.
path
.
isfile
(
bg
):
return
bg
return
None
background_type_names
=
{
BackgroundType
.
standard
:
"
standardní
"
,
...
...
@@ -217,18 +232,11 @@ class CertMaker:
elif
bgt
==
BackgroundType
.
blank
:
return
None
bg
=
bgt
.
name
candidates
=
[
f
'
{
self
.
round
.
round_code
()
}
/bg-
{
bg
}
.pdf
'
,
f
'
bg-
{
bg
}
.pdf
'
,
]
for
cand
in
candidates
:
bg
=
os
.
path
.
join
(
self
.
certs_dir
,
cand
)
if
os
.
path
.
isfile
(
bg
):
bg
=
bgt
.
find_default_background
(
self
.
round
)
if
bg
is
not
None
:
return
bg
raise
RuntimeError
(
"
Nemohu najít standardní pozadí
(kandidáti:
"
+
"
"
.
join
(
candidates
)
+
"
)
"
)
else
:
raise
RuntimeError
(
"
Nemohu najít standardní pozadí
"
)
def
make_certs
(
self
,
cert_type
:
db
.
CertType
)
->
None
:
certs
=
[
cert
for
cert
in
self
.
certs
if
cert
.
type
==
cert_type
]
...
...
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