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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Mareš
Odevzdávací Systém MO
Commits
0d58f1dc
Commit
0d58f1dc
authored
4 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Skript na export/import bodů
parent
82b4c76c
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
bin/import-points
+53
-0
53 additions, 0 deletions
bin/import-points
with
53 additions
and
0 deletions
bin/import-points
0 → 100755
+
53
−
0
View file @
0d58f1dc
#!/usr/bin/env python3
import
argparse
import
sys
from
mo.csv
import
FileFormat
import
mo.db
as
db
from
mo.imports
import
create_import
,
ImportType
import
mo.users
import
mo.util
from
mo.util
import
die
parser
=
argparse
.
ArgumentParser
(
description
=
'
Importuje body za úlohu (bez --import vypíše šablonu).
'
)
parser
.
add_argument
(
'
--round
'
,
'
-r
'
,
type
=
str
,
required
=
True
,
metavar
=
'
YY-C-S[p]
'
,
help
=
'
kód kola
'
)
parser
.
add_argument
(
'
--task
'
,
'
-t
'
,
type
=
str
,
required
=
True
,
metavar
=
'
ID
'
,
help
=
'
kód úlohy
'
)
parser
.
add_argument
(
'
--user
'
,
'
-u
'
,
type
=
str
,
required
=
True
,
metavar
=
'
EMAIL
'
,
help
=
'
uživatel, ktery provádí import
'
)
parser
.
add_argument
(
'
--import
'
,
'
-i
'
,
dest
=
'
import_file
'
,
type
=
str
,
metavar
=
'
NAME
'
,
help
=
'
importuje data ze souboru (TSV)
'
)
parser
.
add_argument
(
'
--add-del
'
,
default
=
False
,
action
=
'
store_true
'
,
help
=
'
povolí zakládat/rušit řešení
'
)
args
=
parser
.
parse_args
()
mo
.
util
.
init_standalone
()
sess
=
db
.
get_session
()
round_code
=
mo
.
util
.
RoundCode
.
parse
(
args
.
round
)
if
round_code
is
None
:
die
(
"
Chybná syntaxe kódu kola
"
)
round
=
mo
.
util
.
get_round_by_code
(
round_code
)
if
round
is
None
:
die
(
"
Kolo s tímto kódem neexistuje!
"
)
task
=
sess
.
query
(
db
.
Task
).
filter_by
(
round
=
round
,
code
=
args
.
task
).
one_or_none
()
if
task
is
None
:
die
(
"
Úloha s tímto kódem neexistuje
"
)
user
=
mo
.
users
.
user_by_email
(
args
.
user
)
if
user
is
None
:
die
(
f
"
Uživatel
{
args
.
user
}
neexistuje
"
)
imp
=
create_import
(
user
,
type
=
ImportType
.
points
,
fmt
=
FileFormat
.
tsv
,
round
=
round
,
task
=
task
,
allow_add_del
=
args
.
add_del
,
)
if
args
.
import_file
:
if
not
imp
.
run
(
args
.
import_file
):
sys
.
exit
(
1
)
else
:
sys
.
stdout
.
write
(
imp
.
get_template
())
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