diff options
| author | Tobin Ehlis <tobine@google.com> | 2016-10-19 15:32:35 -0600 |
|---|---|---|
| committer | Tobin Ehlis <tobine@google.com> | 2016-10-25 11:15:51 -0600 |
| commit | 095539c22ec93baf8bc991331c59359c04a6cf7f (patch) | |
| tree | 23fa6378c7c163a0848331602d8c39fd355833a3 | |
| parent | 473451e71fd0953f40d1a6780d5b5c91879be40b (diff) | |
| download | usermoji-095539c22ec93baf8bc991331c59359c04a6cf7f.tar.xz | |
scripts:Skip repeat error strings
When generating unique error enums, detect and flag identical error
strings and then skip them. The error strings should be unique so this
recognizes cases when they aren't and recommends spec review and filing
a spec bug as appropriate.
| -rw-r--r-- | layers/spec.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/layers/spec.py b/layers/spec.py index 9239c059..ec266c53 100644 --- a/layers/spec.py +++ b/layers/spec.py @@ -119,6 +119,7 @@ class Specification: #print "ROOT: %s" % self.root prev_heading = '' # Last seen section heading or sub-heading prev_link = '' # Last seen link id within the spec + error_strings = set() # Flag any exact duplicate error strings and skip them for tag in self.root.iter(): # iterate down tree # Grab most recent section heading and link if tag.tag in ['{http://www.w3.org/1999/xhtml}h2', '{http://www.w3.org/1999/xhtml}h3']: @@ -145,10 +146,14 @@ class Specification: error_msg_str = "%s '%s' which states '%s' (%s#%s)" % (error_msg_prefix, prev_heading, "".join(elem.itertext()).replace('\n', ''), spec_url, prev_link) # Some txt has multiple spaces so split on whitespace and join w/ single space error_msg_str = " ".join(error_msg_str.split()) - enum_str = "%s%05d" % (validation_error_enum_name, unique_enum_id) - # TODO : '\' chars in spec error messages are most likely bad spec txt that needs to be updated - self.val_error_dict[enum_str] = error_msg_str.encode("ascii", "ignore").replace("\\", "/") - unique_enum_id = unique_enum_id + 1 + if error_msg_str in error_strings: + print "WARNING: SKIPPING adding repeat entry for string. Please review spec and file issue as appropriate. Repeat string is: %s" % (error_msg_str) + else: + error_strings.add(error_msg_str) + enum_str = "%s%05d" % (validation_error_enum_name, unique_enum_id) + # TODO : '\' chars in spec error messages are most likely bad spec txt that needs to be updated + self.val_error_dict[enum_str] = error_msg_str.encode("ascii", "ignore").replace("\\", "/") + unique_enum_id = unique_enum_id + 1 #print "Validation Error Dict has a total of %d unique errors and contents are:\n%s" % (unique_enum_id, self.val_error_dict) def genHeader(self, header_file): """Generate a header file based on the contents of a parsed spec""" |
