forked from M-Labs/artiq
master,artiq_run: simplify unit autodetection
This commit is contained in:
parent
387de11e56
commit
4267e0deab
|
@ -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")
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in New Issue