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)
if args.unit is None:
units = [(k, v) for k, v in module.__dict__.items()
if k[0] != "_"
and isclass(v)
and hasattr(v, "__artiq_unit__")]
if isclass(v) and hasattr(v, "__artiq_unit__")]
l = len(units)
if l == 0:
print("No units found in module")

View File

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