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:
Jakob Stoklund Olesen
2016-08-31 15:44:36 -07:00
parent 88c8e9a59a
commit de330402b8
2 changed files with 8 additions and 5 deletions

View File

@@ -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)

View File

@@ -66,12 +66,12 @@ class Predicate(object):
assert self.context, "Incompatible predicate parts"
def __str__(self):
s = '{}({})'.format(
type(self).__name__,
' ,'.join(map(str, self.parts)))
if self.name:
s = '{}={}'.format(self.name, s)
return s
return '{}.{}'.format(self.context.name, self.name)
else:
return '{}({})'.format(
type(self).__name__,
', '.join(map(str, self.parts)))
def predicate_context(self):
return self.context