ATLAS Offline Software
Loading...
Searching...
No Matches
python.PoolFile.DiffFiles Class Reference
Inheritance diagram for python.PoolFile.DiffFiles:
Collaboration diagram for python.PoolFile.DiffFiles:

Public Types

typedef HLT::TypeInformation::for_each_type_c< typenameEDMLIST::map, my_functor, my_result<>, my_arg< HLT::TypeInformation::get_cont, CONTAINER > >::type result

Public Member Functions

 __init__ (self, refFileName, chkFileName, verbose=False, ignoreList=None, strict=False)
 status (self)
 printSummary (self, out=sys.stdout)

Public Attributes

 verbose = verbose
 strict = strict
 refFile = PoolFile( refFileName )
 chkFile = PoolFile( chkFileName )
 ignList = sorted( ignoreList )
bool allGood = True
 final decision
list summary = []

Private Member Functions

 __checkDiff (self)

Detailed Description

A helper class to compare 2 POOL files and check that they match, both in
terms of containers' content and containers' sizes

Definition at line 962 of file PoolFile.py.

Member Typedef Documentation

◆ result

Definition at line 90 of file EDM_MasterSearch.h.

Constructor & Destructor Documentation

◆ __init__()

python.PoolFile.DiffFiles.__init__ ( self,
refFileName,
chkFileName,
verbose = False,
ignoreList = None,
strict = False )

Definition at line 968 of file PoolFile.py.

968 def __init__(self, refFileName, chkFileName, verbose = False, ignoreList = None, strict = False):
969 object.__init__(self)
970
971 self.verbose = verbose
972 self.strict = strict
973 refFileName = os.path.expandvars( os.path.expanduser( refFileName ) )
974 chkFileName = os.path.expandvars( os.path.expanduser( chkFileName ) )
975
976 if ignoreList is None:
977 ignoreList = []
978
979 try:
980 self.refFile = PoolFile( refFileName )
981 self.chkFile = PoolFile( chkFileName )
982 self.ignList = sorted( ignoreList )
983 except Exception as err:
984 print("## Caught exception [%s] !!" % str(err.__class__))
985 print("## What:",err)
986 print(sys.exc_info()[0])
987 print(sys.exc_info()[1])
988 err = "Error while opening POOL files !"
989 err += " chk : %s%s" % ( chkFileName, os.linesep )
990 err += " ref : %s%s" % ( refFileName, os.linesep )
991 raise Exception(err)
992
993 self.allGood = True
994 self.summary = []
995
996 self.__checkDiff()
997 return
998
void print(char *figname, TCanvas *c1)

Member Function Documentation

◆ __checkDiff()

python.PoolFile.DiffFiles.__checkDiff ( self)
private

Definition at line 999 of file PoolFile.py.

999 def __checkDiff(self):
1000
1001 self.summary += [
1002 "=" * 80,
1003 "::: Comparing POOL files...",
1004 " ref : %s" % self.refFile._fileInfos['name'],
1005 " chk : %s" % self.chkFile._fileInfos['name'],
1006 "-" * 80,
1007 ]
1008
1009 if self.chkFile.dataHeader.nEntries != \
1010 self.refFile.dataHeader.nEntries :
1011 self.summary += [
1012 "## WARNING: files don't have the same number of entries !!",
1013 " ref : %r" % self.refFile.dataHeader.nEntries,
1014 " chk : %r" % self.chkFile.dataHeader.nEntries,
1015 ]
1016
1017 refNames = sorted( [d.name for d in self.refFile.data] )
1018 chkNames = sorted( [d.name for d in self.chkFile.data] )
1019
1020 if chkNames != refNames:
1021 self.summary += [
1022 "## ERROR: files don't have the same content !!",
1023 ]
1024 addNames = [ n for n in chkNames if n not in refNames ]
1025 if len( addNames ) > 0:
1026 self.summary += [ "## collections in 'chk' and not in 'ref'" ]
1027 for n in addNames:
1028 self.summary += [ " + %s" % n ]
1029 subNames = [ n for n in refNames if n not in chkNames ]
1030 if len( subNames ) > 0:
1031 self.summary += [ "## collections in 'ref' and not in 'chk'" ]
1032 for n in subNames:
1033 self.summary += [ " - %s" % n ]
1034 self.allGood = False
1035 pass
1036
1037 if len(self.ignList) > 0:
1038 self.summary += [ "## Ignoring the following:" ]
1039 for n in self.ignList:
1040 self.summary += [ " %s" % n ]
1041
1042 commonContent = [ d for d in chkNames if (d in refNames and d not in self.ignList)]
1043
1044 if not self.allGood:
1045 self.summary += [ "=" * 80 ]
1046 self.summary += [ "::: comparing common content (mem-size / disk-size)..." ]
1047
1048 for name in commonContent:
1049 chkMemSize = self.chkFile.poolRecord(name).memSize
1050 refMemSize = self.refFile.poolRecord(name).memSize
1051 chkDiskSize = self.chkFile.poolRecord(name).diskSize
1052 refDiskSize = self.refFile.poolRecord(name).diskSize
1053
1054 if chkMemSize != refMemSize or (self.strict and chkDiskSize != refDiskSize):
1055 self.summary += [
1056 "[ERR] %12.3f / %12.3f kb (ref) ==> %12.3f / %12.3f kb (chk) | %s" % \
1057 ( refMemSize,refDiskSize,chkMemSize,chkDiskSize, name )
1058 ]
1059 self.allGood = False
1060 elif self.verbose:
1061 self.summary += [
1062 " [OK] %12.3f/%12.3f kb | %s" % \
1063 ( chkMemSize, chkDiskSize, name )
1064 ]
1065
1066 self.summary += [ "=" * 80 ]
1067
1068
1069 if self.allGood: self.summary += [ "## Comparison : [OK]" ]
1070 else: self.summary += [ "## Comparison : [ERR]" ]
1071
1072 return self.allGood
1073

◆ printSummary()

python.PoolFile.DiffFiles.printSummary ( self,
out = sys.stdout )

Definition at line 1078 of file PoolFile.py.

1078 def printSummary(self, out = sys.stdout):
1079 for i in self.summary:
1080 out.writelines( i + os.linesep )
1081 pass
1082 return

◆ status()

python.PoolFile.DiffFiles.status ( self)

Definition at line 1074 of file PoolFile.py.

1074 def status(self):
1075 if self.allGood: return 0
1076 else: return 1
1077

Member Data Documentation

◆ allGood

bool python.PoolFile.DiffFiles.allGood = True

final decision

Definition at line 993 of file PoolFile.py.

◆ chkFile

python.PoolFile.DiffFiles.chkFile = PoolFile( chkFileName )

Definition at line 981 of file PoolFile.py.

◆ ignList

python.PoolFile.DiffFiles.ignList = sorted( ignoreList )

Definition at line 982 of file PoolFile.py.

◆ refFile

python.PoolFile.DiffFiles.refFile = PoolFile( refFileName )

Definition at line 980 of file PoolFile.py.

◆ strict

python.PoolFile.DiffFiles.strict = strict

Definition at line 972 of file PoolFile.py.

◆ summary

list python.PoolFile.DiffFiles.summary = []

Definition at line 994 of file PoolFile.py.

◆ verbose

python.PoolFile.DiffFiles.verbose = verbose

Definition at line 971 of file PoolFile.py.


The documentation for this class was generated from the following file: