45def __getattr__(name):
46 """Return a constructor for the named CP tool type.
47
48 Called when code accesses ``atlascp.<ToolTypeName>``. Returns a callable
49 that creates and initializes a ``Tool`` subclass instance.
50
51 Parameters
52 ----------
53 name:
54 Tool type name without namespace, e.g. "MuonEfficiencyScaleFactors".
55
56 Returns
57 -------
58 callable
59 A constructor with signature
60 ``(instance_name=None, /, *, namespace="CP", properties=None, rename_containers=None)``.
61 ``instance_name`` is positional-only and optional; all other arguments are keyword-only.
62 When omitted, an auto-generated unique name is used.
63 """
64 def constructor(instance_name=None, /, *, namespace="CP", properties=None, rename_containers=None):
65 if instance_name is None:
66 instance_name = f"unique{uuid.uuid4().hex[:12]}"
67 type_and_name = f"{namespace}::{name}/{instance_name}"
68 cls = _make_tool_class(name)
69 instance = cls.__new__(cls)
70 Tool.__init__(instance, type_and_name, properties=properties, rename_containers=rename_containers)
71 return instance
72 constructor.__name__ = name
73 constructor.__qualname__ = name
74 return constructor
75
76