示例#1
0
def loadLibrary(name):
    ## 	if len(LOADED_LIBS) == 0:
    ## 		import PhysicsTools.TheNtupleMaker.AutoLoader
    ## 		LOADED_LIBS[name] = 1
    ## 		return
    name = fixName(name)  # remove unnecessary spaces

    if not ClassToHeaderMap.has_key(name): return

    # construct library name from header:
    # lib<subsystem><package>

    library = "lib%s%s" % tuple(split(ClassToHeaderMap[name], '/')[:2])

    if LOADED_LIBS.has_key(library): return

    LOADED_LIBS[library] = 0

    try:
        gSystem.Load(library)
    except:
        print "** failed to load %s for %s" % (library, name)
示例#2
0
def loadLibrary(name):
## 	if len(LOADED_LIBS) == 0:
## 		import PhysicsTools.TheNtupleMaker.AutoLoader
## 		LOADED_LIBS[name] = 1
## 		return
	name = fixName(name) # remove unnecessary spaces

	if not ClassToHeaderMap.has_key(name): return

	# construct library name from header:
	# lib<subsystem><package>
	
	library = "lib%s%s" % tuple(split(ClassToHeaderMap[name],'/')[:2])
	
	if LOADED_LIBS.has_key(library): return
	
	LOADED_LIBS[library] = 0

	try:
		gSystem.Load(library)
	except:
		print "** failed to load %s for %s" % (library, name)
示例#3
0
	def loadData(self, filename):

		# List root file

		self.statusBar.SetText("Listing file ...", 0)
		self.statusBar.SetText(filename, 1)

		self.progTimer.Start()
		
		stream = itreestream(filename, "Events")
		record = stream.str()
		stream.close()
		
		stream = itreestream(filename, "Runs")
		record += stream.str()
		stream.close()
		sleep(2)
		
		self.progTimer.Stop()
		self.progressBar.Reset()

		# Get branches
		recs = getbranch.findall(record)
		if len(recs) == 0:
			self.statusBar.SetText("** Error", 0)
			self.statusBar.SetText("No branches found", 1)
			return
		self.statusBar.SetText("Done!", 0)

		records = []
		for x in recs:
			t = split(x, '/')
			
			c = strip(t[1]) # Wrapped class name
			cname = fixName(strip(getclass.findall(c)[0]))
			cname = stripstd.sub('',cname)

			# Display class only if it is in classlist.txt
			if not CLASSMAP.has_key(cname):
				#print "\t==> IGNORING: %s" % cname
				continue
			cname = CLASSMAP[cname]
			
			# Get label name
			t = split(t[0], '_')
			label = "%s" % (t[0])
			if t[1] != '': label += "_%s" % t[1]
			
			records.append((label, cname))

		# Creat a map to keep track of selections
		
		self.cmap = {}
		self.previousID = -1

		for record in records:
			label, cname = record
			
			s = isSimpleType.findall(cname)
			v = isSimpleVectorType.findall(cname)
			simpleType = len(s) > 0 or len(v) > 0

			if len(v) > 0:
				v = joinfields(split(v[0]),'')
				fname = "%s/vector_%s.txt" % (self.methodDir, v)
				open(fname, "w").write("%s value()\n" % v)
			
			elif len(s) > 0:
				s = joinfields(split(s[0]),'')
				fname = "%s/simple_%s.txt" % (self.methodDir, s)
				open(fname, "w").write("%s value()\n" % s)

			else:
				fname = "%s/%s.txt" % (self.methodDir,
									   stripname.sub("", cname))

			if not os.path.exists(fname):
				print "** file %s not found" % fname
				continue
			
			# methods file found, so read methods

			if not self.cmap.has_key(cname):
				methods = sortMethods(filter(lambda x: x != "",
											 map(strip,
												 open(fname).readlines())))
				
				# keep only first method for simple types
			
				if simpleType:
					methods = methods[:1]

				#open("test.log","a").writelines(joinfields(methods,'\n'))
				mmap = {}
				for method in methods: mmap[method] = False
				self.cmap[cname] = {'selected': False,
									'labels': {},
									'methods': mmap,
									'sortedmethods': methods}

			self.statusBar.SetText(fname, 1)
			self.cmap[cname]['labels'][label] = False

		# Fill classBox on Methods page

		self.statusBar.SetText("Number of classes", 0)
		cnames = self.cmap.keys()
		self.statusBar.SetText("%d" % len(cnames), 1)
		cnames.sort()

		for id in [P_METHODS, P_SELECTED]:
			self.classBox[id].RemoveAll()
			self.labelBox[id].RemoveAll()
			self.methodBox[id].RemoveAll()
		
		for index, entry in enumerate(cnames):
			self.classBox[P_METHODS].AddEntry(entry, index)
		self.classBox[P_METHODS].Layout()
示例#4
0
CLASSMAP = {}
if os.path.exists(CLASSLISTFILE):
	records = map(split, open(CLASSLISTFILE).readlines())
	recs = map(lambda x: (x[0], joinfields(x[1:],' ')), records)
	for ctype, name in recs:
		fullname = getFullname(name)
		name = stripstd.sub('',name)
		fullname = stripstd.sub('',fullname)
		
		if ctype == "collection":
			if name[-1] == ">": name += " "
			if fullname[-1] == ">": fullname += " "
			name = "vector<%s>" % name
			fullname = "vector<%s>" % fullname
		name = fixName(name)
		fullname = fixName(fullname)
		
		CLASSMAP[name] = name
		CLASSMAP[fullname] = name

	for x in ["double", "float", "long", "int", "short", "bool",
			  "unsigned long", "unsigned int", "unsigned short"]:		
		CLASSMAP[x] = x
		x = "vector<%s>" % x
		CLASSMAP[x] = x
#-----------------------------------------------------------------------------
WIDTH          = 750            # Width of GUI in pixels
HEIGHT         = 500            # Height of GUI in pixels
# StatusBar components
STATUS_PARTS   = array('i')     # Status bar division in percentage
示例#5
0
    def loadData(self, filename):

        # List root file

        self.statusBar.SetText("Listing file ...", 0)
        self.statusBar.SetText(filename, 1)

        self.progTimer.Start()

        stream = itreestream(filename, "Events")
        record = stream.str()
        stream.close()

        stream = itreestream(filename, "Runs")
        record += stream.str()
        stream.close()
        sleep(2)

        self.progTimer.Stop()
        self.progressBar.Reset()

        # Get branches
        recs = getbranch.findall(record)
        if len(recs) == 0:
            self.statusBar.SetText("** Error", 0)
            self.statusBar.SetText("No branches found", 1)
            return
        self.statusBar.SetText("Done!", 0)

        records = []
        for x in recs:
            t = split(x, '/')

            c = strip(t[1])  # Wrapped class name
            cname = fixName(strip(getclass.findall(c)[0]))
            cname = stripstd.sub('', cname)

            # Display class only if it is in classlist.txt
            if not CLASSMAP.has_key(cname):
                #print "\t==> IGNORING: %s" % cname
                continue
            cname = CLASSMAP[cname]

            # Get label name
            t = split(t[0], '_')
            label = "%s" % (t[0])
            if t[1] != '': label += "_%s" % t[1]

            records.append((label, cname))

        # Creat a map to keep track of selections

        self.cmap = {}
        self.previousID = -1

        for record in records:
            label, cname = record

            s = isSimpleType.findall(cname)
            v = isSimpleVectorType.findall(cname)
            simpleType = len(s) > 0 or len(v) > 0

            if len(v) > 0:
                v = joinfields(split(v[0]), '')
                fname = "%s/vector_%s.txt" % (self.methodDir, v)
                open(fname, "w").write("%s value()\n" % v)

            elif len(s) > 0:
                s = joinfields(split(s[0]), '')
                fname = "%s/simple_%s.txt" % (self.methodDir, s)
                open(fname, "w").write("%s value()\n" % s)

            else:
                fname = "%s/%s.txt" % (self.methodDir, stripname.sub(
                    "", cname))

            if not os.path.exists(fname):
                print "** file %s not found" % fname
                continue

            # methods file found, so read methods

            if not self.cmap.has_key(cname):
                methods = sortMethods(
                    filter(lambda x: x != "",
                           map(strip,
                               open(fname).readlines())))

                # keep only first method for simple types

                if simpleType:
                    methods = methods[:1]

                #open("test.log","a").writelines(joinfields(methods,'\n'))
                mmap = {}
                for method in methods:
                    mmap[method] = False
                self.cmap[cname] = {
                    'selected': False,
                    'labels': {},
                    'methods': mmap,
                    'sortedmethods': methods
                }

            self.statusBar.SetText(fname, 1)
            self.cmap[cname]['labels'][label] = False

        # Fill classBox on Methods page

        self.statusBar.SetText("Number of classes", 0)
        cnames = self.cmap.keys()
        self.statusBar.SetText("%d" % len(cnames), 1)
        cnames.sort()

        for id in [P_METHODS, P_SELECTED]:
            self.classBox[id].RemoveAll()
            self.labelBox[id].RemoveAll()
            self.methodBox[id].RemoveAll()

        for index, entry in enumerate(cnames):
            self.classBox[P_METHODS].AddEntry(entry, index)
        self.classBox[P_METHODS].Layout()
示例#6
0
CLASSMAP = {}
if os.path.exists(CLASSLISTFILE):
    records = map(split, open(CLASSLISTFILE).readlines())
    recs = map(lambda x: (x[0], joinfields(x[1:], ' ')), records)
    for ctype, name in recs:
        fullname = getFullname(name)
        name = stripstd.sub('', name)
        fullname = stripstd.sub('', fullname)

        if ctype == "collection":
            if name[-1] == ">": name += " "
            if fullname[-1] == ">": fullname += " "
            name = "vector<%s>" % name
            fullname = "vector<%s>" % fullname
        name = fixName(name)
        fullname = fixName(fullname)

        CLASSMAP[name] = name
        CLASSMAP[fullname] = name

    for x in [
            "double", "float", "long", "int", "short", "bool", "unsigned long",
            "unsigned int", "unsigned short"
    ]:
        CLASSMAP[x] = x
        x = "vector<%s>" % x
        CLASSMAP[x] = x
#-----------------------------------------------------------------------------
WIDTH = 750  # Width of GUI in pixels
HEIGHT = 500  # Height of GUI in pixels
示例#7
0
def main():

    print "mkclassmap.py\n"

    subpackagelist = SUBPACKAGELIST
    filelist = []
    if Update:
        for subpackage in subpackagelist:
            print "scan package: %s" % subpackage
            file = "%s/interface/*.h" % subpackage
            hlist = glob(file)
            hlist.sort()
            filelist += hlist
    else:

        for subpackage in subpackagelist:
            package, subpkg = split(subpackage, '/')
            if subpkg == "*":
                cmd = "%s%s" % (BASE, subpackage)
                subsystems = filter(lambda x: os.path.isdir(x), glob(cmd))
                if len(subsystems) == 0:
                    cmd = "%s%s" % (PKGBASE, subpackage)
                    subsystems = filter(lambda x: os.path.isdir(x), glob(cmd))

                subsystems = map(lambda x: split(x, '/').pop(), subsystems)
            else:
                subsystems = [split(subpackage, '/').pop()]

            for subsystem in subsystems:
                if skipsubsystem.match(subsystem) != None: continue

                dirpath = "%s%s/%s" % (PKGBASE, package, subsystem)
                if not os.path.exists(dirpath):
                    dirpath = "%s%s/%s" % (LOCALBASE, package, subsystem)
                    if not os.path.exists(dirpath):
                        "** directory %s not found" % dirpath
                        continue
                print "scan package: %s/%s" % (package, subsystem)
                file = "%s/interface/*.h" % dirpath
                hlist = glob(file)
                hlist.sort()
                filelist += hlist

    # Filter headers
    filelist = filter(lambda x: skipheader.search(x) == None, filelist)
    print
    print "scan %d headers for potentially useful classes" % len(filelist)

    #-------------------------------------------------
    # Loop over header files to be scanned
    #-------------------------------------------------
    cmap = {}
    count = 0
    for index, file in enumerate(filelist):
        if not os.path.exists(file):
            print "** file %s not found" % file
            continue

        file = os.path.abspath(file)
        if index % 100 == 0: print index

        # Scan header and parse it for classes

        record, items = parseHeader(file)

        if record == '':
            print "** failed on %s" % file
            continue
        records = splitHeader(record)
        if len(records) == 0: continue

        # Now strip away path up to "/src/" in pathname of header

        header = file
        k = rfind(header, "/src/")  # search from right
        if k > 0: header = header[k + 5:]

        cache = []
        names = []
        for irecord, (record, group, start, end) in enumerate(records):
            #print "GROUP(%s)" % group

            # Get actual record from items map

            key = strip(record)
            if items.has_key(key):
                record = items[key]
                if type(record) == type(()):
                    record, extraRecord = record
            record = stripBlanklines(record)

            if group == "namespace":
                name = strip(namespaceName(record))
                if name != '': names.append(name)

            elif group == "endnamespace":
                if len(names) > 0: names.pop()

            elif group in ["endclass", "endstructclass"]:

                fullname = joinfields(names, "::")

                # Check for uninstantiated templates and
                # create keys

                if find(fullname, '<') > -1:
                    tplate = True
                    fullkey = split(fullname, '<')[0]
                else:
                    tplate = False
                    fullkey = fullname

                cache.append((fullkey, header))

                count += 1
                print "%5d\t%s" % (count, fullkey)

                # remember to reset
                names.pop()

            elif group in ["class", "structclass"]:
                classname, basenames, template = getClassname(record)
                names.append(classname)

        # Update map

        for fullkey, header in cache:
            if Update:
                addToMap(fullkey, header, ClassToHeaderMap)
            else:
                addToMap(fullkey, header, cmap)

    # Write out class to header map

    if Update:
        print "updating classmap.py..."
        hmap = ClassToHeaderMap
    else:
        print "creating classmap.py..."
        hmap = cmap

## 	# define lib areas

## 	LOCALLIBAREA = "%s/lib/%s/" % (LOCALBASE[:-5], SCRAM_ARCH)
## 	LIBAREA = "%s/lib/%s/" % (BASE[:-5], SCRAM_ARCH)

    getmodule = re.compile('(?<=src/).*(?=/interface)')
    ## 	librecs = []
    recs = []
    keys = hmap.keys()
    keys.sort()
    for key in keys:
        key = fixName(key)  # remove unnecessary spaces

        value = hmap[key]
        if type(value) == type(""):
            recs.append("'%s': '%s'" % (key, value))
        else:
            recs.append("'%s': %s" % (key, value))

## 		# find the shared library in which the class typeinfo resides

## 		module = split(value,'/interface/')[0]
## 		library = "lib%s" % replace(module, '/', '')

## 		found = False
## 		filename = "%s%s.so" % (LOCALLIBAREA, library)

## 		if not os.path.exists(filename):
## 			filename = "%s%s.so" % (LIBAREA, library)
## 			if not os.path.exists(filename):
## 				print "\twarning: library %s not found"
## 				continue

# add lib to list
## 		librecs.append("'%s': '%s'" % (key, library))

    record = joinfields(recs, ',\n')
    outfile = CLASSMAPFILE
    out = open(outfile, 'w')
    out.write('# Created: %s\n' % ctime(time()))
    out.write('# Version: %s\n' % VERSION)
    out.write("ClassToHeaderMap = {\\\n")
    out.write(record + '\n')
    out.write("}\n\n")

    ## 	record = joinfields(librecs,',\n')
    ## 	out.write("ClassToLibraryMap = {\\\n")
    ## 	out.write(record+'\n')
    ## 	out.write("}\n")
    out.close()
示例#8
0
def main():
	
	print "mkclassmap.py\n"

	subpackagelist = SUBPACKAGELIST
	filelist = []
	if Update:
		for subpackage in subpackagelist:
			print "scan package: %s" % subpackage
			file = "%s/interface/*.h" % subpackage
			hlist = glob(file)
			hlist.sort()
			filelist += hlist
	else:

		for subpackage in subpackagelist:
			package, subpkg = split(subpackage,'/')
			if subpkg == "*":
				cmd = "%s%s" % (BASE, subpackage)
				subsystems = filter(lambda x: os.path.isdir(x), glob(cmd))
				if len(subsystems) == 0:
					cmd = "%s%s" % (PKGBASE, subpackage)
					subsystems = filter(lambda x: os.path.isdir(x), glob(cmd))
					
				subsystems = map(lambda x: split(x, '/').pop(), subsystems)
			else:
				subsystems = [split(subpackage, '/').pop()]

			for subsystem in subsystems:
				if skipsubsystem.match(subsystem) != None: continue
				
				dirpath = "%s%s/%s" % (PKGBASE, package, subsystem)
				if not os.path.exists(dirpath):
					dirpath = "%s%s/%s" % (LOCALBASE, package, subsystem)
					if not os.path.exists(dirpath):
						"** directory %s not found" % dirpath
						continue
				print "scan package: %s/%s" % (package, subsystem)
				file = "%s/interface/*.h" % dirpath
				hlist = glob(file)
				hlist.sort()
				filelist += hlist

		
	# Filter headers
	filelist = filter(lambda x: skipheader.search(x) == None, filelist)
	print
	print "scan %d headers for potentially useful classes" % len(filelist)
	
	#-------------------------------------------------
	# Loop over header files to be scanned
	#-------------------------------------------------
	cmap = {}
	count = 0
	for index, file in enumerate(filelist):
		if not os.path.exists(file):
			print "** file %s not found" % file
			continue

		file = os.path.abspath(file)
		if index % 100 == 0: print index

		# Scan header and parse it for classes

		record, items = parseHeader(file)
	
		if record == '':
			print "** failed on %s" % file
			continue
		records = splitHeader(record)
		if len(records) == 0: continue

		# Now strip away path up to "/src/" in pathname of header
		
		header = file
		k = rfind(header, "/src/") # search from right
		if k > 0: header = header[k+5:]

		cache = []
		names = []
		for irecord, (record, group, start, end) in enumerate(records):
			#print "GROUP(%s)" % group
			
			# Get actual record from items map

			key = strip(record)
			if items.has_key(key):
				record = items[key]
				if type(record) == type(()):
					record, extraRecord = record
			record = stripBlanklines(record)
			
			if group == "namespace":
				name = strip(namespaceName(record))
				if name != '': names.append(name)

			elif group == "endnamespace":
				if len(names) > 0: names.pop()
				
			elif group in ["endclass", "endstructclass"]:
				
				fullname = joinfields(names, "::")

				# Check for uninstantiated templates and
				# create keys

				if find(fullname, '<') > -1:
					tplate = True
					fullkey = split(fullname, '<')[0]
				else:
					tplate = False
					fullkey = fullname					

				cache.append((fullkey, header))

				count += 1
				print "%5d\t%s" % (count, fullkey)

				# remember to reset
				names.pop()
				
			elif group in ["class", "structclass"]:
				classname, basenames, template = getClassname(record)
				names.append(classname)

		# Update map
		
		for fullkey, header in cache:
			if Update:
				addToMap(fullkey, header, ClassToHeaderMap)
			else:
				addToMap(fullkey, header, cmap)

	
	# Write out class to header map

	if Update:
		print "updating classmap.py..."
		hmap = ClassToHeaderMap
	else:
		print "creating classmap.py..."
		hmap = cmap


		
## 	# define lib areas

## 	LOCALLIBAREA = "%s/lib/%s/" % (LOCALBASE[:-5], SCRAM_ARCH)
## 	LIBAREA = "%s/lib/%s/" % (BASE[:-5], SCRAM_ARCH)

	getmodule = re.compile('(?<=src/).*(?=/interface)')
## 	librecs = []
	recs = []
	keys = hmap.keys()
	keys.sort()
	for key in keys:
		key = fixName(key) # remove unnecessary spaces
		
		value = hmap[key]
		if type(value) == type(""):
			recs.append("'%s': '%s'" % (key, value))
		else:
			recs.append("'%s': %s"   % (key, value))

## 		# find the shared library in which the class typeinfo resides

## 		module = split(value,'/interface/')[0]
## 		library = "lib%s" % replace(module, '/', '')

## 		found = False
## 		filename = "%s%s.so" % (LOCALLIBAREA, library)
		
## 		if not os.path.exists(filename):
## 			filename = "%s%s.so" % (LIBAREA, library)
## 			if not os.path.exists(filename):
## 				print "\twarning: library %s not found"
## 				continue

		# add lib to list
## 		librecs.append("'%s': '%s'" % (key, library))

	record = joinfields(recs,',\n')		
	outfile = CLASSMAPFILE
	out = open(outfile,'w')
	out.write('# Created: %s\n' % ctime(time()))
	out.write('# Version: %s\n' % VERSION)
	out.write("ClassToHeaderMap = {\\\n")
	out.write(record+'\n')
	out.write("}\n\n")

## 	record = joinfields(librecs,',\n')
## 	out.write("ClassToLibraryMap = {\\\n")
## 	out.write(record+'\n')
## 	out.write("}\n")
	out.close()