From c54584bf5ae0b4973464da1e033c6628b82e9cd5 Mon Sep 17 00:00:00 2001
From: Timotej Lazar <timotej.lazar@fri.uni-lj.si>
Date: Tue, 2 Oct 2018 13:25:55 +0200
Subject: test_task.py: simplify load_{params,task} functions

---
 kpov_judge/test_task.py | 16 +++++-----------
 1 file 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
-- 
cgit v1.2.1