Add casual string representation of named settings and predicates.
Use 'group.setting' format for named predicates, only display the expression for anonymous predicates.
This commit is contained in:
@@ -35,6 +35,9 @@ class Setting(object):
|
||||
self.byte_offset = None
|
||||
self.group = SettingGroup.append(self)
|
||||
|
||||
def __str__(self):
|
||||
return '{}.{}'.format(self.group.name, self.name)
|
||||
|
||||
def predicate_context(self):
|
||||
"""
|
||||
Return the context where this setting can be evaluated as a (leaf)
|
||||
|
||||
@@ -66,12 +66,12 @@ class Predicate(object):
|
||||
assert self.context, "Incompatible predicate parts"
|
||||
|
||||
def __str__(self):
|
||||
s = '{}({})'.format(
|
||||
if self.name:
|
||||
return '{}.{}'.format(self.context.name, self.name)
|
||||
else:
|
||||
return '{}({})'.format(
|
||||
type(self).__name__,
|
||||
', '.join(map(str, self.parts)))
|
||||
if self.name:
|
||||
s = '{}={}'.format(self.name, s)
|
||||
return s
|
||||
|
||||
def predicate_context(self):
|
||||
return self.context
|
||||
|
||||
Reference in New Issue
Block a user