Skip to content
Snippets Groups Projects
Commit adde0b33 authored by scott snyder's avatar scott snyder
Browse files

AthenaPython: Update CORAL attribute access for python 3.

Update the handling of CORAL attributes to work with both py3 and py2.
Can simplify it now using a pyroot template proxy.
parent 4f2dc43e
No related branches found
No related tags found
No related merge requests found
Pipeline #1307259 failed
......@@ -15,22 +15,6 @@ __doc__ = "provide components to peek into pool files"
import AthenaPython.PyAthena as PyAthena
StatusCode = PyAthena.StatusCode
# MN/sss: make Coral.AttributeList work in Coral3/ROOT6/gcc5
from PyCool import coral
_attribute_methods = dir(coral.Attribute)
_methnames = ['data<std::__cxx11::basic_string<char> >',
'data<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >',
'data<std::basic_string<char> >',
'data<std::string>']
for _m in _methnames:
if _m in _attribute_methods:
_attribute_getdata = _m
break
else:
raise Exception("Can't find data method in Attribute")
def attr_str_data(attr):
return getattr(attr, _attribute_getdata) ()
### helper functions ----------------------------------------------------------
def _import_ROOT():
......@@ -245,14 +229,14 @@ class FilePeeker(PyAthena.Alg):
spec = a.specification()
a_type = spec.typeName()
if a_type.find('string') >= 0:
a_data = attr_str_data(a)
a_data = a.data('string')()
try:
a_data = eval(a_data,{},{})
except Exception:
# swallow and keep as a string
pass
else:
a_data = getattr(a,'data<%s>'%a_type)()
a_data = a.data(a_type)()
#msg.info("%s: %s %s", spec.name(), a_data, type(a_data) )
attr_data.append( (spec.name(), a_data) )
attrs.append(dict(attr_data))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment