mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-22 04:49:00 +00:00
Moved get_type_name outside of ConfigurationPoint
This commit is contained in:
parent
cddc29af05
commit
9cc42c1879
@ -129,6 +129,15 @@ KIND_MAP = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def get_type_name(kind):
|
||||||
|
typename = str(kind)
|
||||||
|
if '\'' in typename:
|
||||||
|
typename = typename.split('\'')[1]
|
||||||
|
elif typename.startswith('<function'):
|
||||||
|
typename = typename.split()[1]
|
||||||
|
return typename
|
||||||
|
|
||||||
|
|
||||||
class ConfigurationPoint(object):
|
class ConfigurationPoint(object):
|
||||||
"""
|
"""
|
||||||
This defines a generic configuration point for workload automation. This is
|
This defines a generic configuration point for workload automation. This is
|
||||||
@ -231,7 +240,7 @@ class ConfigurationPoint(object):
|
|||||||
try:
|
try:
|
||||||
value = self.kind(value)
|
value = self.kind(value)
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
typename = self.get_type_name()
|
typename = get_type_name(self.kind)
|
||||||
msg = 'Bad value "{}" for {}; must be {} {}'
|
msg = 'Bad value "{}" for {}; must be {} {}'
|
||||||
article = get_article(typename)
|
article = get_article(typename)
|
||||||
raise ConfigError(msg.format(value, self.name, article, typename))
|
raise ConfigError(msg.format(value, self.name, article, typename))
|
||||||
@ -241,14 +250,6 @@ class ConfigurationPoint(object):
|
|||||||
value = merge_config_values(getattr(obj, self.name), value)
|
value = merge_config_values(getattr(obj, self.name), value)
|
||||||
setattr(obj, self.name, value)
|
setattr(obj, self.name, value)
|
||||||
|
|
||||||
def get_type_name(self):
|
|
||||||
typename = str(self.kind)
|
|
||||||
if '\'' in typename:
|
|
||||||
typename = typename.split('\'')[1]
|
|
||||||
elif typename.startswith('<function'):
|
|
||||||
typename = typename.split()[1]
|
|
||||||
return typename
|
|
||||||
|
|
||||||
def validate(self, obj):
|
def validate(self, obj):
|
||||||
value = getattr(obj, self.name, None)
|
value = getattr(obj, self.name, None)
|
||||||
if value is not None:
|
if value is not None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user