summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-10-02 13:25:55 +0200
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-10-02 13:25:55 +0200
commitc54584bf5ae0b4973464da1e033c6628b82e9cd5 (patch)
tree2c327ff8e3fd121dff62bd202f38591be2a3d495
parent071b8c1abe145f8111d22b57651a85e4991bfd95 (diff)
test_task.py: simplify load_{params,task} functions
-rwxr-xr-xkpov_judge/test_task.py16
1 files changed, 5 insertions, 11 deletions
diff --git a/kpov_judge/test_task.py b/kpov_judge/test_task.py
index 206e809..a3eace5 100755
--- a/kpov_judge/test_task.py
+++ b/kpov_judge/test_task.py
@@ -75,14 +75,11 @@ def http_auth(url, username, password):
urllib.request.install_opener(opener)
def load_task(stream):
- # the stream should compile into at least the function
- # task(...) and a dictionary "params_meta".
+ # the stream should definitions for the functions task(…),
+ # task_check and gen_params, and a dictionary params_meta
source = stream.read()
- t = compile(source, 'task.py', 'exec')
d = {}
- exec(t, d)
- # get a list of arguments for task(...)
- # args_list = inspect.getargs(task.func_code)[0]
+ exec(compile(source, 'task.py', 'exec'), d)
return d['task'], d['task_check'], d['params_meta'], d['gen_params']
def locate_task(params, argparser, quiet=False):
@@ -118,12 +115,9 @@ def locate_task(params, argparser, quiet=False):
def load_params(filename):
try:
with open(filename) as f:
- saved_params = yaml.load(f)
+ return yaml.load(f)
except:
- saved_params = dict()
- if saved_params is None:
- saved_params = dict()
- return saved_params
+ return {}
if __name__ == '__main__':
# get the parameters needed to get to the task, such as the URLs, the name of the task and optionally an ID from the student