summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Albert <albertj@us.ibm.com>2015-03-11 16:29:37 -0500
committerJason Albert <albertj@us.ibm.com>2015-03-11 16:29:37 -0500
commit0dbbc99fa048d872fabf83c36b1f1d2112d4e66b (patch)
tree508e45cc963c03301bdd9ab94e27d22e6712a8f9
parent737305a6cfd39cfe2f424a78992e36cd79459ddd (diff)
downloadvpdtools-0dbbc99fa048d872fabf83c36b1f1d2112d4e66b.tar.gz
vpdtools-0dbbc99fa048d872fabf83c36b1f1d2112d4e66b.zip
Removed now redundant check in stage 2. More cleanup of error checking in parseVpd stage 1
-rwxr-xr-xcreateVpd.py54
1 files changed, 22 insertions, 32 deletions
diff --git a/createVpd.py b/createVpd.py
index 8f8b235..32e7da1 100755
--- a/createVpd.py
+++ b/createVpd.py
@@ -114,7 +114,6 @@ def parseTvpd(tvpdFile, topLevel):
errorsFound +=1
# We continue here because we don't want to parse down this hierarcy path when we don't know what it is
continue
-
# It was a supported tag
else:
vpdTags[vpd.tag] +=1
@@ -136,6 +135,9 @@ def parseTvpd(tvpdFile, topLevel):
if record.tag not in recordTags:
out.error("Unsupported tag <%s> found while parsing the <record> level for record %s" % (record.tag, recordName))
errorsFound +=1
+ # We continue here because we don't want to parse down this hierarcy path when we don't know what it is
+ continue
+ # It was a supported tag
else:
recordTags[record.tag] +=1
@@ -156,6 +158,9 @@ def parseTvpd(tvpdFile, topLevel):
if keyword.tag not in keywordTags:
out.error("Unsupported tag <%s> found while parsing the <keyword> level for keyword %s" % (keyword.tag, keywordName))
errorsFound +=1
+ # We continue here because we don't want to parse down this hierarcy path when we don't know what it is
+ continue
+ # It was a supported tag
else:
keywordTags[keyword.tag] +=1
@@ -194,6 +199,12 @@ def parseTvpd(tvpdFile, topLevel):
out.error("At least one <record> must be defined for the file to be valid!")
errorsFound+=1
+ # If this is an included tvpd, it can only have 1 record in it
+ if (topLevel == False):
+ if (vpdTags["record"] > 1):
+ out.error("More than 1 record entry found in %s. Only 1 record is allowed!" % (tvpdFile))
+ errorsFound+=1
+
######
# All done, vary our return based upon the errorsFound
if (errorsFound):
@@ -409,22 +420,13 @@ for record in manifest.iter("record"):
# The below code will insert the refrenced record from the file in the list above the current record location
# Then remove the original record, preserving order
- # --------
- # Make sure the rtvpd only has 1 record in it
- rcount = 0
- for whocares in recordTvpd.iter("record"):
- rcount+=1
- if (rcount > 1):
- out.error("More than 1 record entry found in rtvpdfile %s. Only 1 record is allowed!" % (rtvpd.text))
- errorsFound+=1
- break
-
# Since the referenced file also starts with <vpd> tag, you need to get one level down and find the start of the record element, hence the find
subRecord = recordTvpd.find("record")
- subRecordName = subRecord.attrib.get("name")
# --------
# Make sure the record found in rtvpd is the same as the record in the manifiest
+ # We have to do this error check here because the recordName doesn't exist in parseTvpd
+ subRecordName = subRecord.attrib.get("name")
if (subRecordName != recordName):
out.error("The record (%s) found in %s doesn't match the record name in the manifest (%s)" % (subRecordName, rtvpd.text, recordName))
errorsFound+=1
@@ -456,6 +458,7 @@ for record in manifest.iter("record"):
recordName = record.attrib.get("name")
out.msg("Checking record %s" % recordName)
+ out.setIndent(4)
# --------
# Make sure we aren't finding a record we haven't already seen
@@ -472,28 +475,10 @@ for record in manifest.iter("record"):
errorsFound+=1
# --------
- # Determine if they gave a list of keyword descriptions to convert to binary data of if they gave a binary data record
- keywordTagFound = False
- rbinfileTagFound = False
- if (record.find("keyword") != None):
- keywordTagFound = True
- if (record.find("rbinfile") != None):
- rbinfileTagFound = True
- # Both given
- if (keywordTagFound and rbinfileTagFound):
- out.error("Both <keyword> and <rbinfile> tags were found in record %s. Only one or the other is supported!" % (recordName))
- errorsFound+=1
- break
-
- # Neither given
- if (not keywordTagFound and not rbinfileTagFound):
- out.error("Neither the <keyword> or <rbinfile> tags were found in record %s. One must be given!" % (recordName))
- errorsFound+=1
-
# Do very basic checking on the rbinfile if found
# It is assumed that this file was generated by this tool at an earlier date, so it should be format correct
# We'll simply ensure it is actually a record that goes with this record name
- if (rbinfileTagFound):
+ if (record.find("rbinfile") != None):
# Get the name
rbinfile = record.find("rbinfile").text
@@ -505,6 +490,7 @@ for record in manifest.iter("record"):
break
# It does, read it in so we can check the record name
+ out.msg("Reading rbinfile %s" % (rbinfile))
rbinfileContents = open(rbinfile, mode='rb').read()
# --------
@@ -514,8 +500,9 @@ for record in manifest.iter("record"):
out.error("The record name found %s in %s, does not match the name of the record %s in the tvpd" % (rbinfileContents[6:10].decode(), rbinfile, recordName))
clErrors+=1
+ # --------
# For the keyword tags we'll do much more extensive checking
- if (keywordTagFound):
+ if (record.find("keyword") != None):
# Track the keywords we come across so we can find duplicate
keywordNames = dict()
# Loop through the keywords and verify them
@@ -629,6 +616,9 @@ for record in manifest.iter("record"):
out.error("Unknown keyword format \"%s\" given for keyword %s in record %s" % (kwformat, keywordName, recordName))
errorsFound+=1
+ # Done with the record, reset the output
+ out.setIndent(2)
+
# All done with error checks, bailout if we hit something
if (errorsFound):
out.msg("")
OpenPOWER on IntegriCloud