mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-24 10:54:02 +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)
|
||||
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
Block a user