Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fw core util edm check class transient #11534

Merged
merged 4 commits into from Sep 29, 2015
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 17 additions & 10 deletions FWCore/Utilities/scripts/edmCheckClassTransients
Expand Up @@ -11,8 +11,8 @@ classtransients['edm::AssociationVector'].append('transientVector_')


class RMParser(object):
"""Parses the ${PackageName}_x*r.rootmap file(s) looking for class declarations of edm template classes
which contain member which must be labeled transient="true" in classes_def.xml
"""Parses the rootmap file(s) for a package looking for class declarations of edm template classes
which contain member(s) which must be labeled transient="true" in classes_def.xml
"""

def __init__(self,filelist):
Expand All @@ -34,25 +34,26 @@ class RMParser(object):
f.close()

def checkTrans(templname,name):
print "Checking "+name
c = ROOT.TClass.GetClass(name)
if not c:
print "failed to load dictionary for class '"+name+"'. Check for typedefs in the name."
return
print "Info: Could no load dictionary for class '"+name+"' because of typedef(s) in the name."
return 0
for trans in classtransients[templname]:
tdm = c.GetDataMember(trans)
retval = False
if tdm : retval = tdm.IsPersistent()
if retval == True : raise RuntimeError("Error: field '"+trans+"' must be labeled transient=\"true\" in classes_def.xml for '"+name+"'")

if retval == True :
print "Error: field='"+trans+"' must be labeled transient=\"true\" in classes_def.xml for "+name+" or the equivalent class name with typedefs."
return 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why return here? don't you want to keep looping for the other transients classes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot it was in a loop. I will change it.

return 0

#Setup the options
from optparse import OptionParser
oparser = OptionParser()
oparser.add_option("-l","--lib", dest="library",
help="specify the library to load. If not set classes are found using the PluginManager")
help="specify the library to load")
oparser.add_option("-f","--rootmap", dest="rmfiles", action="append", default=[],
help="the _xr.rootmap(s) file to read")
help="specify the rootmap file(s) to read")

(options,args)=oparser.parse_args()

Expand All @@ -68,6 +69,12 @@ else:

p = RMParser(options.rmfiles)

nerrs = 0
for key in p.cnames.keys():
for value in p.cnames[key]:
checkTrans(key,value)
nerrs += checkTrans(key,value)

if nerrs > 0 :
print "Error: edm template class member must be labeled transient=\"true\" in classes_def.xml. Check log for specific template and member name."
import sys
sys.exit(1)