forked from M-Labs/artiq
1
0
Fork 0

applets/TitleApplet: support hierarchical datasets in titles

This commit is contained in:
Sebastien Bourdeauducq 2016-04-06 17:21:35 +08:00
parent 356afb045c
commit 364e3d48ab
1 changed files with 3 additions and 3 deletions

View File

@ -236,7 +236,7 @@ class TitleApplet(SimpleApplet):
self.argparser.add_argument("--title", default=None, self.argparser.add_argument("--title", default=None,
help="set title (can be a Python format " help="set title (can be a Python format "
"string where field names are dataset " "string where field names are dataset "
"names)") "names, replace '.' with '/')")
def args_init(self): def args_init(self):
SimpleApplet.args_init(self) SimpleApplet.args_init(self)
@ -248,12 +248,12 @@ class TitleApplet(SimpleApplet):
break break
if not format_field: if not format_field:
raise ValueError("Invalid title format string") raise ValueError("Invalid title format string")
self.dataset_title.add(format_field) self.dataset_title.add(format_field.replace("/", "."))
self.datasets |= self.dataset_title self.datasets |= self.dataset_title
def emit_data_changed(self, data, mod_buffer): def emit_data_changed(self, data, mod_buffer):
if self.args.title is not None: if self.args.title is not None:
title_values = {k: data.get(k, (False, None))[1] title_values = {k.replace(".", "/"): data.get(k, (False, None))[1]
for k in self.dataset_title} for k in self.dataset_title}
try: try:
title = self.args.title.format(**title_values) title = self.args.title.format(**title_values)