diff options
author | Prabhu Ramachandran | 2018-06-07 16:14:37 +0530 |
---|---|---|
committer | GitHub | 2018-06-07 16:14:37 +0530 |
commit | 4eb754c2e71922819de7390d1b4993a21763de3e (patch) | |
tree | fede3f4250f3711d31da4bb7edd262edd0a90727 /yaksh/language_registry.py | |
parent | 78ce1804d3a82327aa0da1510bb5c03d6bbff3ba (diff) | |
parent | 93bb10eae5e1364ae6492f2534f0e7864c9c4254 (diff) | |
download | online_test-4eb754c2e71922819de7390d1b4993a21763de3e.tar.gz online_test-4eb754c2e71922819de7390d1b4993a21763de3e.tar.bz2 online_test-4eb754c2e71922819de7390d1b4993a21763de3e.zip |
Merge pull request #482 from adityacp/pep8_changes
Pep8 changes
Diffstat (limited to 'yaksh/language_registry.py')
-rw-r--r-- | yaksh/language_registry.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/yaksh/language_registry.py b/yaksh/language_registry.py index 994e9ed..ec5dae9 100644 --- a/yaksh/language_registry.py +++ b/yaksh/language_registry.py @@ -1,26 +1,29 @@ from __future__ import unicode_literals import importlib -import json -import six +import six # Local imports from .settings import code_evaluators registry = None - + + def get_registry(): global registry if registry is None: registry = _LanguageRegistry() return registry + def create_evaluator_instance(metadata, test_case): """Create instance of relevant EvaluateCode class based on language""" registry = get_registry() - cls = registry.get_class(metadata.get('language'), test_case.get('test_case_type')) + cls = registry.get_class(metadata.get('language'), + test_case.get('test_case_type')) instance = cls(metadata, test_case) return instance + class _LanguageRegistry(object): def __init__(self): self._register = {} @@ -33,7 +36,6 @@ class _LanguageRegistry(object): 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 @@ -45,4 +47,3 @@ class _LanguageRegistry(object): def register(self, language, class_names): """ Register a new code evaluator class for language""" self._register[language] = class_names - |