1 from abc
import ABCMeta, abstractmethod
7 """Base class, contains methods used to transform Objects into
9 __metaclass__ = ABCMeta
19 def _get_actual_string(self, predicate, parameters_map):
31 """Returns a string for the given predicate name string."""
32 return self._predicate_class.get(predicate)
35 def __populate_object(parameters, obj):
36 """Sets a fields of object from set of parameters given, by invoking
37 setters methods of the object."""
38 for key, value
in obj.get_terms_type().items():
39 if isinstance(value, tuple)
and len(value) == 2:
40 name_method =
"set_" + value[0]
42 getattr(obj, name_method)(int(parameters[key]))
43 elif value[1]
is SymbolicConstant:
44 getattr(obj, name_method)(
45 SymbolicConstant(parameters[key]))
47 name_method =
"set_" + value
48 getattr(obj, name_method)(parameters[key])
51 """Returns an Object for the given string.
53 The parameter string is a string from which data are
54 extrapolated. The method return a Object for the given string
69 if parameters
is None:
79 """Insert an object into _predicate_class.
81 The method return a string representing pairing key of
84 if not issubclass(cl, Predicate):
85 raise "input class is not subclass of Predicate"
86 predicate = cl.get_predicate_name()
88 raise "Value of the object is not valid"
93 """Remove an object from _predicate_class."""
94 if not issubclass(cl, Predicate):
95 raise "input class is not subclass of Predicate"
96 predicate = cl.get_predicate_name()
100 """Returns data for the given Object.
102 The parameter obj is the Object from which data are
103 extrapolated. The method return a string data for the given
104 Object in a String format.
108 parameters_map = dict()
109 for key, value
in obj.get_terms_type().items():
110 if isinstance(value, tuple)
and len(value) == 2:
111 val = getattr(obj,
"get_" + value[0])()
113 val = getattr(obj,
"get_" + value)()
115 parameters_map[key] = val