From 3c0b0158cba9a8050594ae8d2d7e1871c0ba8673 Mon Sep 17 00:00:00 2001 From: Beojan Stanislaus Date: Tue, 5 May 2020 15:34:57 +0100 Subject: [PATCH 1/2] Add TParameter class --- uproot_methods/classes/TParameter.py | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 uproot_methods/classes/TParameter.py diff --git a/uproot_methods/classes/TParameter.py b/uproot_methods/classes/TParameter.py new file mode 100644 index 0000000..5ceb568 --- /dev/null +++ b/uproot_methods/classes/TParameter.py @@ -0,0 +1,29 @@ +import uproot_methods.base + + +def _decode(seq): + if isinstance(seq, bytes): + return seq.decode("UTF-8") + else: + return seq + + +class Methods(uproot_methods.base.ROOTMethods): + def __repr__(self): + if self._fName is None: + return "<{0} at 0x{1:012x}>".format(_decode(self._classname), id(self)) + else: + return "<{0} {1} 0x{2:012x}>".format( + _decode(self._classname), _decode(self._fName), id(self) + ) + + def __str__(self): + return str(self._fVal) + + @property + def name(self): + return _decode(self._fName) + + @property + def value(self): + return self._fVal From ee56b7f0c939e39bc82b0a4ce226ed074b771ac0 Mon Sep 17 00:00:00 2001 From: Beojan Stanislaus Date: Thu, 7 May 2020 16:09:50 +0100 Subject: [PATCH 2/2] Let uproot_methods find single class implementations for templates --- uproot_methods/classes/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/uproot_methods/classes/__init__.py b/uproot_methods/classes/__init__.py index 64d3d57..fcdbfb5 100644 --- a/uproot_methods/classes/__init__.py +++ b/uproot_methods/classes/__init__.py @@ -3,8 +3,14 @@ # BSD 3-Clause License; see https://github.com/scikit-hep/uproot-methods/blob/master/LICENSE def hasmethods(name): - if name not in globals() and name in hasmethods.loaders: - globals()[name] = hasmethods.loaders[name].load_module(name) + if name not in globals(): + if name in hasmethods.loaders: + globals()[name] = hasmethods.loaders[name].load_module(name) + elif '_3c_' in name and '_3e_' in name: + bare_name = name.split('_3c_')[0] + if bare_name in hasmethods.loaders: + globals()[name] = hasmethods.loaders[bare_name].load_module(bare_name) + return name in globals() and isinstance(getattr(globals()[name], "Methods", None), type) import pkgutil