mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-26 03:38:25 +08:00
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)
|
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")
|
||||||
|
@ -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]
|
||||||
|
Loading…
Reference in New Issue
Block a user