Go to the documentation of this file.
4 Created on Thu Sep 29 12:19:06 2016
25 self.
lines.append(line)
28 for line
in self.
lines:
34 globalAttributeItems = {}
39 if item.kind ==
"start":
40 startItems[item.name] = item
41 if item.kind ==
"data":
42 dataItems[item.name] = item
43 elif item.kind ==
"globalAttribute":
44 globalAttributeItems[item.name] = item
49 parser = argparse.ArgumentParser(description=
'Compare two HDF4 files.')
51 parser.add_argument(
'-G',
'--globalExclude', help=
'Global Attrbutes to ignore')
52 parser.add_argument(
'-p',
'--relativeLimit', help=
'relative limit, criteria is |(b-a)/a| > relativeLimit')
53 parser.add_argument(
'file1', help=
'first HDF4 file to compare')
54 parser.add_argument(
'file2', help=
'second HDF4 file to compare')
56 args = parser.parse_args()
58 if args.relativeLimit ==
None:
59 proc = subprocess.Popen([
"hdiff",
"-e",
"10", args.file1, args.file2], stdout=subprocess.PIPE)
61 proc = subprocess.Popen([
"hdiff",
"-e",
"10",
"-p", args.relativeLimit, args.file1, args.file2], stdout=subprocess.PIPE)
63 out = proc.communicate()[0]
66 if(proc.returncode == 0):
69 if(proc.returncode != 1):
71 print(
"hdiff error return = ", proc.returncode)
78 lines = out.split(b
'\n')
84 if line.startswith(
"---------------------------"):
86 elif line.startswith(
"position"):
88 item =
DiffItem(
'data', line.split()[1])
90 elif line.startswith(
"Attr Name:"):
92 item =
DiffItem(
'globalAttribute', line.split(
None,2)[2])
101 if args.globalExclude !=
None:
102 excludes = args.globalExclude.split(
",")
103 for exclude
in excludes:
104 exclude = exclude.strip()
105 if exclude
in globalAttributeItems:
106 del globalAttributeItems[exclude]
112 if len(startItems) > 0:
113 for key,value
in startItems.items():
114 print(
'---------------------------')
117 if len(dataItems) > 0:
119 for key,value
in dataItems.items():
120 print(
'---------------------------')
123 if len(globalAttributeItems) > 0:
125 for key,value
in globalAttributeItems.items():
126 print(
"---------------------------")
def __init__(self, kind, name)