Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hallgrim
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
Container Registry
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
hallgrim
Commits
f95cf215
Commit
f95cf215
authored
8 years ago
by
Jan Maximilian Michal
Browse files
Options
Downloads
Patches
Plain Diff
Minor tweak after script outsource
parent
84bf6abe
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hallgrim/hallgrim.py
+19
-4
19 additions, 4 deletions
hallgrim/hallgrim.py
with
19 additions
and
4 deletions
hallgrim/hallgrim.py
+
19
−
4
View file @
f95cf215
...
@@ -42,13 +42,20 @@ def get_config():
...
@@ -42,13 +42,20 @@ def get_config():
error
(
'
Could not find config file.
'
)
error
(
'
Could not find config file.
'
)
error
(
'
Please edit config.sample.ini and move it to config.ini
'
)
error
(
'
Please edit config.sample.ini and move it to config.ini
'
)
error
(
'
Continue with default values. Script might fail.
'
)
error
(
'
Continue with default values. Script might fail.
'
)
config
[
'
META
'
]
=
{
'
author
'
:
'
__default__
'
}
config
[
'
META
'
]
=
{
'
author
'
:
'
__default__
'
}
return
config
return
config
def
file_to_module
(
name
):
def
file_to_module
(
name
):
return
name
.
rstrip
(
'
.py
'
).
replace
(
'
/
'
,
'
.
'
)
return
name
.
rstrip
(
'
.py
'
).
replace
(
'
/
'
,
'
.
'
)
def
look_for_output
():
if
not
os
.
path
.
exists
(
'
output
'
):
info
(
'
Created directory
"
output/
"'
)
os
.
makedirs
(
'
output
'
)
def
type_selector
(
type
):
def
type_selector
(
type
):
if
'
multi
'
in
type
:
if
'
multi
'
in
type
:
return
'
MULTIPLE CHOICE QUESTION
'
return
'
MULTIPLE CHOICE QUESTION
'
...
@@ -141,6 +148,7 @@ def parseme():
...
@@ -141,6 +148,7 @@ def parseme():
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
if
args
.
command
==
'
gen
'
:
if
args
.
command
==
'
gen
'
:
look_for_output
()
delegator
(
args
.
out
,
args
.
input
,
args
.
instances
)
delegator
(
args
.
out
,
args
.
input
,
args
.
instances
)
if
args
.
command
==
'
upload
'
:
if
args
.
command
==
'
upload
'
:
handle_upload
(
args
.
script
,
config
)
handle_upload
(
args
.
script
,
config
)
...
@@ -163,7 +171,7 @@ def delegator(output, script_list, instances):
...
@@ -163,7 +171,7 @@ def delegator(output, script_list, instances):
"""
"""
for
script_name
in
filter
(
lambda
a
:
a
.
endswith
(
'
.py
'
),
script_list
):
for
script_name
in
filter
(
lambda
a
:
a
.
endswith
(
'
.py
'
),
script_list
):
module_name
=
os
.
path
.
basename
(
script_name
)
module_name
=
os
.
path
.
basename
(
script_name
)
spec
=
importlib
.
util
.
spec_from_file_location
(
module_name
,
script_name
)
spec
=
importlib
.
util
.
spec_from_file_location
(
module_name
,
script_name
)
script
=
importlib
.
util
.
module_from_spec
(
spec
)
script
=
importlib
.
util
.
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
script
)
spec
.
loader
.
exec_module
(
script
)
handler
=
{
handler
=
{
...
@@ -252,13 +260,20 @@ def handle_new_script(name, qtype, author, points):
...
@@ -252,13 +260,20 @@ def handle_new_script(name, qtype, author, points):
author {str} -- the author of the script
author {str} -- the author of the script
points {float} -- number of points for the task
points {float} -- number of points for the task
"""
"""
with
open
(
'
scripts/
'
+
name
+
'
.py
'
,
'
w
'
)
as
new_script
:
head
,
tail
=
os
.
path
.
split
(
name
)
if
not
os
.
path
.
exists
(
head
):
os
.
makedirs
(
head
)
if
not
tail
.
endswith
(
'
.py
'
):
base
=
tail
else
:
base
=
tail
.
rstrip
(
'
.py
'
)
with
open
(
os
.
path
.
join
(
head
,
base
+
'
.py
'
),
'
x
'
)
as
new_script
:
choice
=
''
choice
=
''
if
qtype
in
[
'
multiple choice
'
,
'
single choice
'
]:
if
qtype
in
[
'
multiple choice
'
,
'
single choice
'
]:
choice
=
'
\n
choices =
"""
\n
[X] A
\n
[ ] B
\n
[ ] C
\n
[X] D
\n
"""
\n
'
choice
=
'
\n
choices =
"""
\n
[X] A
\n
[ ] B
\n
[ ] C
\n
[X] D
\n
"""
\n
'
print
(
scaffolding
.
format
(
print
(
scaffolding
.
format
(
author
,
nam
e
,
qtype
,
points
,
choice
).
strip
(),
file
=
new_script
)
author
,
bas
e
,
qtype
,
points
,
choice
).
strip
(),
file
=
new_script
)
info
(
'
Generated new script
"
{}.
"'
.
format
(
new_script
.
name
))
info
(
'
Generated new script
"
{}.
"'
.
format
(
new_script
.
name
))
...
...
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