summaryrefslogtreecommitdiff
path: root/kpov_judge
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2019-02-21 00:45:27 +0100
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2019-02-21 00:45:27 +0100
commitaa6170a5655853a8e64375e7abca5845bc82bec3 (patch)
tree720306a353d1d07e234bd1b484e26f6218448125 /kpov_judge
parent88cdb867368e93ec59740fa1b5a1440d2f438d05 (diff)
test_task: reorder helper functions
Diffstat (limited to 'kpov_judge')
-rwxr-xr-xkpov_judge/test_task.py37
1 files changed, 18 insertions, 19 deletions
diff --git a/kpov_judge/test_task.py b/kpov_judge/test_task.py
index ad8c963..4e9561f 100755
--- a/kpov_judge/test_task.py
+++ b/kpov_judge/test_task.py
@@ -64,20 +64,11 @@ def add_meta_to_argparser(argparser, meta, defaults={}):
argparser.add_argument('--'+k, nargs='?', type=str, help=desc,
default=defaults.get(k, None))
-def http_auth(url, username, password):
- password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
- password_mgr.add_password(None, url, username, password)
- handler = urllib.request.HTTPBasicAuthHandler(password_mgr)
- opener = urllib.request.build_opener(handler)
- urllib.request.install_opener(opener) # now all calls to urlopen use our opener
-
-def load_task(stream):
- # the stream should definitions for the functions task(…),
- # task_check and gen_params, and a dictionary params_meta
- source = stream.read()
- d = {}
- exec(compile(source, 'task.py', 'exec'), globals(), d)
- return d['task'], d['task_check'], d['params_meta'], d['gen_params']
+def load_params(filename):
+ try:
+ return yaml.load(open(filename))
+ except:
+ return {}
def locate_task(params, argparser, quiet=False):
# first the URL where all tasks are stored
@@ -104,11 +95,19 @@ def locate_task(params, argparser, quiet=False):
print()
return params
-def load_params(filename):
- try:
- return yaml.load(open(filename))
- except:
- return {}
+def http_auth(url, username, password):
+ password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
+ password_mgr.add_password(None, url, username, password)
+ handler = urllib.request.HTTPBasicAuthHandler(password_mgr)
+ opener = urllib.request.build_opener(handler)
+ urllib.request.install_opener(opener) # now all calls to urlopen use our opener
+
+def load_task(stream):
+ # the stream should definitions for the functions task(…),
+ # task_check and gen_params, and a dictionary params_meta
+ d = {}
+ exec(compile(source, 'task.py', 'exec'), globals(), d)
+ return d['task'], d['task_check'], d['params_meta'], d['gen_params']
if __name__ == '__main__':