forked from M-Labs/artiq
1
0
Fork 0

master,artiq_run: simplify unit autodetection

This commit is contained in:
Sebastien Bourdeauducq 2015-02-21 20:26:58 -07:00
parent 387de11e56
commit 4267e0deab
2 changed files with 2 additions and 6 deletions

View File

@ -112,9 +112,7 @@ def main():
module = file_import(args.file) module = file_import(args.file)
if args.unit is None: if args.unit is None:
units = [(k, v) for k, v in module.__dict__.items() units = [(k, v) for k, v in module.__dict__.items()
if k[0] != "_" if isclass(v) and hasattr(v, "__artiq_unit__")]
and isclass(v)
and hasattr(v, "__artiq_unit__")]
l = len(units) l = len(units)
if l == 0: if l == 0:
print("No units found in module") print("No units found in module")

View File

@ -69,9 +69,7 @@ def get_unit(file, unit):
module = file_import(file) module = file_import(file)
if unit is None: if unit is None:
units = [v for k, v in module.__dict__.items() units = [v for k, v in module.__dict__.items()
if k[0] != "_" if isclass(v) and hasattr(v, "__artiq_unit__")]
and isclass(v)
and hasattr(v, "__artiq_unit__")]
if len(units) != 1: if len(units) != 1:
raise ValueError("Found {} units in module".format(len(units))) raise ValueError("Found {} units in module".format(len(units)))
return units[0] return units[0]