- Restore the previous printout format in the immxml tools, which
happened to be changed by ticket #2664 for better readability, in order
to maintain backward-compatibility for any user scripts/tools that have
been depending their check on the former printout.
- Some other minor updates regarding formatting.
---
src/imm/tools/baseimm.py | 32 +++++++++++++++++---------------
src/imm/tools/immxml-merge | 32 ++++++++++++++++----------------
src/imm/tools/immxml-validate | 16 ++++++++--------
3 files changed, 41 insertions(+), 39 deletions(-)
diff --git a/src/imm/tools/baseimm.py b/src/imm/tools/baseimm.py
index fe1c3ce..17e85eb 100644
--- a/src/imm/tools/baseimm.py
+++ b/src/imm/tools/baseimm.py
@@ -84,7 +84,8 @@ class BaseImmDocument(object):
@staticmethod
def format_xml_file_with_xmllint(in_file_name, out_file_name):
""" Format xml file with xmllint """
- trace("formatXmlFileWithXmlLint() prettify xml file:%s", in_file_name)
+ trace("format_xml_file_with_xmllint() prettify xml file: %s",
+ in_file_name)
# "prettify" the result file with xmllint
# (due to inadequate python/minidom prettify functionality)
@@ -123,7 +124,7 @@ class BaseImmDocument(object):
doc = open(file_name)
str_list = []
imm_contents_tag_found = False
- # imm_contents_tag_replaced = False
+ imm_contents_tag_replaced = False
for _line in doc:
line = _line
if not imm_contents_tag_found:
@@ -140,18 +141,19 @@ class BaseImmDocument(object):
xml_str = ' '.join(str_list)
- # if Options.schemaFilename is not None:
- # if imm_contents_tag_replaced:
- # print_info_stderr("Cannot validate input file '%s' with "
- # "schema file because of missing namespace "
- # "specification in element "
- # "<imm:IMM-contents>. \nProceeding with "
- # "processing of modified input data!",
- # file_name)
- # else:
- # if self.validate_xml_file(file_name) != 0:
- # abort_script("Failed to validate the input file: %s",
- # file_name)
+ if Options.schemaFilename is not None:
+ if imm_contents_tag_replaced:
+ print_info_stderr("Cannot validate input file '%s' with "
+ "schema file because of missing namespace "
+ "specification in element "
+ "<imm:IMM-contents>. \nProceeding with "
+ "processing of modified input data!",
+ file_name)
+ else:
+ if self.validate_xml_file(file_name) != 0:
+ abort_script("Failed to validate the input file: %s",
+ file_name)
+
return xml.dom.minidom.parseString(xml_str)
@staticmethod
@@ -188,7 +190,7 @@ def trace(*args):
def retrieve_file_names(args):
""" Retrieve file names """
- trace("Before glob args:%s", args)
+ trace("Before glob args: %s", args)
# Wildcard expansion for WIN support, however not tested....
file_list = glob.glob(args[0])
trace("After glob file list: %s length: %d", file_list, len(file_list))
diff --git a/src/imm/tools/immxml-merge b/src/imm/tools/immxml-merge
index 7489da3..3a9edda 100755
--- a/src/imm/tools/immxml-merge
+++ b/src/imm/tools/immxml-merge
@@ -113,7 +113,7 @@ class MergedImmDocument(BaseImmDocument):
""" Add classes matching pattern """
class_name = class_element.getAttribute("name")
self.classes_parsed = self.classes_parsed + 1
- trace("className: %s nodeType:%d nodeName:%s", class_name,
+ trace("className:%s nodeType:%d nodeName:%s", class_name,
class_element.nodeType, class_element.nodeName)
if self.regexpObj is not None:
@@ -129,7 +129,7 @@ class MergedImmDocument(BaseImmDocument):
Options.grep_class)
return
- trace("match ok :%s", class_name)
+ trace("match ok: %s", class_name)
# Check if class exists in dictionary map
if class_name in self.classDict:
@@ -146,7 +146,7 @@ class MergedImmDocument(BaseImmDocument):
def add_object(self, object_element, other_nodes):
""" Add objects matching pattern """
class_name = object_element.getAttribute("class")
- trace("DUMPING Object with className: %s \n %s", class_name,
+ trace("DUMPING Object with className: %s\n %s", class_name,
object_element.toxml())
self.objects_parsed = self.objects_parsed + 1
@@ -160,7 +160,7 @@ class MergedImmDocument(BaseImmDocument):
if object_dn_element is None or class_name is None \
or object_dn_element.firstChild is None:
abort_script("Failed to find class name or the dn child node in "
- "object:%s. ", object_element.toxml())
+ "object: %s", object_element.toxml())
# object_dn_name = object_dn_element.nodeValue
# NOTE: dn name should be the nodeValue of object_dn_name
@@ -176,10 +176,10 @@ class MergedImmDocument(BaseImmDocument):
if not Options.ignoreMissingClass:
if Options.grep_class is not None:
trace("Ignoring object with class not matching pattern "
- "className:%s", class_name)
+ "className: %s", class_name)
return
else:
- abort_script("Failed to find class referred in: \n %s",
+ abort_script("Failed to find class referred in: %s",
object_element.toxml())
trace("zzz")
else:
@@ -199,7 +199,7 @@ class MergedImmDocument(BaseImmDocument):
object_dn_name, Options.grep_dn)
return
- trace("match ok :%s", object_dn_name)
+ trace("match ok: %s", object_dn_name)
if object_dn_name in self.objectDnNameDict:
if self.check_object_clash_acceptable(object_dn_name):
@@ -219,7 +219,7 @@ class MergedImmDocument(BaseImmDocument):
object_list_key_list = [self.get_dn_sort_prefix(object_dn_name),
class_name, object_dn_name]
object_list_key = ''.join(object_list_key_list)
- # objectListKey = self.get_dn_sort_prefix(objectDnName)+className
+ # objectListKey = self.get_dn_sort_prefix(objectDnName) + className
trace("Object sort order key: %s", object_list_key)
self.objectList.append((object_list_key,
@@ -277,12 +277,12 @@ class MergedImmDocument(BaseImmDocument):
def process_input_file(self, file_name):
""" Process input file """
trace("")
- trace("process_input_file in file: %s", file_name)
+ trace("process_input_file for file: %s", file_name)
if Options.isXmlLintFound and Options.schemaFilename is not None:
if self.validate_xml_file_with_schema(file_name,
Options.schemaFilename) !=
0:
- abort_script("Failed to validate input file %s:", file_name)
+ abort_script("Failed to validate input file: %s", file_name)
else:
self.verify_input_xml_document_file_is_parsable(file_name)
@@ -297,7 +297,7 @@ class MergedImmDocument(BaseImmDocument):
other_nodes = []
if element.nodeName == self.imm_content_element_name:
for child_element in element.childNodes:
- trace("imm:contents loop.....nodeName: %s nodeValue: %s",
+ trace("imm:contents loop.....nodeName:%s nodeValue:%s",
child_element.nodeName, child_element.nodeValue)
if child_element.nodeName == "class":
self.add_class(child_element, other_nodes)
@@ -354,7 +354,7 @@ class MergedImmDocument(BaseImmDocument):
print_info_stderr("encoding in first source xml document: %s",
self.firstSourceDoc.encoding)
- tmp_output_file_name = Options.outputFilename+".tmp"
+ tmp_output_file_name = Options.outputFilename + ".tmp"
file_object = open(tmp_output_file_name, "w")
if self.firstSourceDoc.encoding is not None \
@@ -367,7 +367,7 @@ class MergedImmDocument(BaseImmDocument):
file_object.write(heading)
file_object.write(
- self.imm_content_element.toxml(encoding).replace("/>", ">")+"\n")
+ self.imm_content_element.toxml(encoding).replace("/>", ">") + "\n")
for class_element_tuple in self.classList:
if Options.keepCommentElements:
for textNode in class_element_tuple[1][0]:
@@ -409,10 +409,10 @@ class MergedImmDocument(BaseImmDocument):
diff_classes = self.classes_parsed - len(self.classList)
diff_objects = self.objects_parsed - len(self.objectList)
print_info_stderr("Note! Merge ignored %d classes "
- "(parsed: %d stored: %d)", diff_classes,
+ "(parsed:%d stored:%d)", diff_classes,
self.classes_parsed, len(self.classList))
print_info_stderr("Note! Merge ignored %d objects "
- "(parsed: %d stored: %d)", diff_objects,
+ "(parsed:%d stored:%d)", diff_objects,
self.objects_parsed, len(self.objectList))
trace("Stored formatted xml document in file: %s",
@@ -588,7 +588,7 @@ def main(argv):
"Exiting!")
file_list = retrieve_file_names(args)
- trace("Starting to process files::\n")
+ trace("Starting to process files\n")
# Create an Object to store classes and objects during process of
# input files
merged_doc = MergedImmDocument()
diff --git a/src/imm/tools/immxml-validate b/src/imm/tools/immxml-validate
index e36ece0..787ebb9 100755
--- a/src/imm/tools/immxml-validate
+++ b/src/imm/tools/immxml-validate
@@ -73,7 +73,7 @@ class ImmDocument(BaseImmDocument):
def add_class(self, class_element, other_nodes):
""" Add class to the list of classes to validate """
class_name = class_element.getAttribute("name")
- trace("className: %s nodeType: %d nodeName: %s", class_name,
+ trace("className:%s nodeType:%d nodeName:%s", class_name,
class_element.nodeType, class_element.nodeName)
# Check if class exists in dictionary map
@@ -81,7 +81,7 @@ class ImmDocument(BaseImmDocument):
# Check if class clash is "acceptable"
# i.e. should we bail out or not??
if self.check_class_clash_acceptable(class_element, class_name):
- self.validate_failed("Found duplicate class : %s", class_name)
+ self.validate_failed("Found duplicate class: %s", class_name)
else:
attr_list = []
attribute_dict = {}
@@ -144,7 +144,7 @@ class ImmDocument(BaseImmDocument):
if object_dn_element is None or class_name is None \
or object_dn_element.firstChild is None:
self.validate_failed("Failed to find class name or the dn child "
- "node in object: %s. ",
+ "node in object: %s",
object_element.toxml())
# object_dn_name = object_dn_element.nodeValue
@@ -321,7 +321,7 @@ class ImmDocument(BaseImmDocument):
object_owner_part = object_dn_name[comma_index + 1:]
object_part = object_dn_name[:comma_index]
- trace("ObjectDN: %s objectOwner: %s objectPart: %s", object_dn_name,
+ trace("ObjectDN:%s objectOwner:%s objectPart:%s", object_dn_name,
object_owner_part, object_part)
# Owner should exist for both SA_NAME_T and SA_STRING_T
@@ -386,7 +386,7 @@ class ImmDocument(BaseImmDocument):
other_nodes = []
if element.nodeName == self.imm_content_element_name:
for child_element in element.childNodes:
- trace("imm:contents loop.....NodeName: %s NodeValue: %s",
+ trace("imm:contents loop.....NodeName:%s NodeValue:%s",
child_element.nodeName, child_element.nodeValue)
if child_element.nodeName == "class":
self.add_class(child_element, other_nodes)
@@ -474,9 +474,9 @@ def main(argv):
sys.exit(0)
# Cannot trace these until -t, Options.traceOn is effective (or not)
- trace("opts:%s", opts)
- trace("args:%s", args)
- trace("sys.path:%s", sys.path)
+ trace("opts: %s", opts)
+ trace("args: %s", args)
+ trace("sys.path: %s", sys.path)
if not args:
print_usage()