From 3e1e203d35d2929bc7af20fa1f56617db6a40258 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Fran=C3=A7ois=20Nguyen?= Date: Mon, 28 Jun 2021 19:49:27 +0200 Subject: [PATCH] soc.base: add socproperty(weak=True) for optional properties. --- lambdasoc/soc/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lambdasoc/soc/base.py b/lambdasoc/soc/base.py index 79cb6c2..ceb3663 100644 --- a/lambdasoc/soc/base.py +++ b/lambdasoc/soc/base.py @@ -14,14 +14,14 @@ from ..periph import Peripheral __all__ = ["socproperty", "SoC", "ConfigBuilder"] -def socproperty(cls, src_loc_at=0): +def socproperty(cls, *, weak=False, src_loc_at=0): name = tracer.get_var_name(depth=2 + src_loc_at) __name = "__{}".format(name) def getter(self): assert isinstance(self, SoC) attr = getattr(self, __name, None) - if attr is None: + if attr is None and not weak: raise NotImplementedError("SoC {!r} does not have a {}" .format(self, name)) return attr -- 2.30.2