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 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 923 of file PoolFile.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 929 of file PoolFile.py.

929 def __init__(self, refFileName, chkFileName, verbose = False, ignoreList = None, strict = False):
930 object.__init__(self)
931
932 self.verbose = verbose
933 self.strict = strict
934 refFileName = os.path.expandvars( os.path.expanduser( refFileName ) )
935 chkFileName = os.path.expandvars( os.path.expanduser( chkFileName ) )
936
937 if ignoreList is None:
938 ignoreList = []
939
940 try:
941 self.refFile = PoolFile( refFileName )
942 self.chkFile = PoolFile( chkFileName )
943 self.ignList = sorted( ignoreList )
944 except Exception as err:
945 print("## Caught exception [%s] !!" % str(err.__class__))
946 print("## What:",err)
947 print(sys.exc_info()[0])
948 print(sys.exc_info()[1])
949 err = "Error while opening POOL files !"
950 err += " chk : %s%s" % ( chkFileName, os.linesep )
951 err += " ref : %s%s" % ( refFileName, os.linesep )
952 raise Exception(err)
953
954 self.allGood = True
955 self.summary = []
956
957 self.__checkDiff()
958 return
959
void print(char *figname, TCanvas *c1)

Member Function Documentation

◆ __checkDiff()

python.PoolFile.DiffFiles.__checkDiff ( self)
private

Definition at line 960 of file PoolFile.py.

960 def __checkDiff(self):
961
962 self.summary += [
963 "=" * 80,
964 "::: Comparing POOL files...",
965 " ref : %s" % self.refFile._fileInfos['name'],
966 " chk : %s" % self.chkFile._fileInfos['name'],
967 "-" * 80,
968 ]
969
970 if self.chkFile.dataHeader.nEntries != \
971 self.refFile.dataHeader.nEntries :
972 self.summary += [
973 "## WARNING: files don't have the same number of entries !!",
974 " ref : %r" % self.refFile.dataHeader.nEntries,
975 " chk : %r" % self.chkFile.dataHeader.nEntries,
976 ]
977
978 refNames = sorted( [d.name for d in self.refFile.data] )
979 chkNames = sorted( [d.name for d in self.chkFile.data] )
980
981 if chkNames != refNames:
982 self.summary += [
983 "## ERROR: files don't have the same content !!",
984 ]
985 addNames = [ n for n in chkNames if n not in refNames ]
986 if len( addNames ) > 0:
987 self.summary += [ "## collections in 'chk' and not in 'ref'" ]
988 for n in addNames:
989 self.summary += [ " + %s" % n ]
990 subNames = [ n for n in refNames if n not in chkNames ]
991 if len( subNames ) > 0:
992 self.summary += [ "## collections in 'ref' and not in 'chk'" ]
993 for n in subNames:
994 self.summary += [ " - %s" % n ]
995 self.allGood = False
996 pass
997
998 if len(self.ignList) > 0:
999 self.summary += [ "## Ignoring the following:" ]
1000 for n in self.ignList:
1001 self.summary += [ " %s" % n ]
1002
1003 commonContent = [ d for d in chkNames if (d in refNames and d not in self.ignList)]
1004
1005 if not self.allGood:
1006 self.summary += [ "=" * 80 ]
1007 self.summary += [ "::: comparing common content (mem-size / disk-size)..." ]
1008
1009 for name in commonContent:
1010 chkMemSize = self.chkFile.poolRecord(name).memSize
1011 refMemSize = self.refFile.poolRecord(name).memSize
1012 chkDiskSize = self.chkFile.poolRecord(name).diskSize
1013 refDiskSize = self.refFile.poolRecord(name).diskSize
1014
1015 if chkMemSize != refMemSize or (self.strict and chkDiskSize != refDiskSize):
1016 self.summary += [
1017 "[ERR] %12.3f / %12.3f kb (ref) ==> %12.3f / %12.3f kb (chk) | %s" % \
1018 ( refMemSize,refDiskSize,chkMemSize,chkDiskSize, name )
1019 ]
1020 self.allGood = False
1021 elif self.verbose:
1022 self.summary += [
1023 " [OK] %12.3f/%12.3f kb | %s" % \
1024 ( chkMemSize, chkDiskSize, name )
1025 ]
1026
1027 self.summary += [ "=" * 80 ]
1028
1029
1030 if self.allGood: self.summary += [ "## Comparison : [OK]" ]
1031 else: self.summary += [ "## Comparison : [ERR]" ]
1032
1033 return self.allGood
1034

◆ printSummary()

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

Definition at line 1039 of file PoolFile.py.

1039 def printSummary(self, out = sys.stdout):
1040 for i in self.summary:
1041 out.writelines( i + os.linesep )
1042 pass
1043 return

◆ status()

python.PoolFile.DiffFiles.status ( self)

Definition at line 1035 of file PoolFile.py.

1035 def status(self):
1036 if self.allGood: return 0
1037 else: return 1
1038

Member Data Documentation

◆ allGood

bool python.PoolFile.DiffFiles.allGood = True

final decision

Definition at line 954 of file PoolFile.py.

◆ chkFile

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

Definition at line 942 of file PoolFile.py.

◆ ignList

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

Definition at line 943 of file PoolFile.py.

◆ refFile

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

Definition at line 941 of file PoolFile.py.

◆ strict

python.PoolFile.DiffFiles.strict = strict

Definition at line 933 of file PoolFile.py.

◆ summary

list python.PoolFile.DiffFiles.summary = []

Definition at line 955 of file PoolFile.py.

◆ verbose

python.PoolFile.DiffFiles.verbose = verbose

Definition at line 932 of file PoolFile.py.


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