summaryrefslogtreecommitdiff
path: root/yaksh/language_registry.py
diff options
context:
space:
mode:
authorankitjavalkar2016-12-07 14:59:07 +0530
committerankitjavalkar2016-12-20 12:46:02 +0530
commitdee13fa4f8006d5266c02d6290b0e98d31413a9f (patch)
treed34bfed626a5e23689047318eda966c2495a2cfa /yaksh/language_registry.py
parent1400eeb1d5af1cd1d69e015a19a319ab35d357c4 (diff)
downloadonline_test-dee13fa4f8006d5266c02d6290b0e98d31413a9f.tar.gz
online_test-dee13fa4f8006d5266c02d6290b0e98d31413a9f.tar.bz2
online_test-dee13fa4f8006d5266c02d6290b0e98d31413a9f.zip
Refactor code server and python evaluator
Diffstat (limited to 'yaksh/language_registry.py')
-rw-r--r--yaksh/language_registry.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/yaksh/language_registry.py b/yaksh/language_registry.py
index 0e0140b..8d3aad2 100644
--- a/yaksh/language_registry.py
+++ b/yaksh/language_registry.py
@@ -14,15 +14,16 @@ def get_registry():
registry = _LanguageRegistry()
return registry
-def unpack_json(json_data):
- data = json.loads(json_data)
- return data
+# def unpack_json_to_python_obj(json_data):
+# data = json.loads(json_data)
+# return data
-def create_evaluator_instance(language, test_case_type, json_data, in_dir):
+def create_evaluator_instance(metadata, test_case): #create_evaluator_instance
"""Create instance of relevant EvaluateCode class based on language"""
registry = get_registry()
- cls = registry.get_class(language, test_case_type)
- instance = cls(in_dir)
+ cls = registry.get_class(metadata.get('language'), test_case.get('test_case_type'))
+ # instance = cls(in_dir)
+ instance = cls(metadata, test_case)
return instance
class _LanguageRegistry(object):
@@ -36,8 +37,8 @@ class _LanguageRegistry(object):
""" Get the code evaluator class for the given language """
if not self._register.get(language):
self._register[language] = code_evaluators.get(language)
-
test_case_register = self._register[language]
+
cls = test_case_register.get(test_case_type)
module_name, class_name = cls.rsplit(".", 1)
# load the module, will raise ImportError if module cannot be loaded