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 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