[diffoscope] 03/05: comparators.xml: Use 4-spaces, not 2-spaces for Python code.

Chris Lamb chris at chris-lamb.co.uk
Fri Jul 21 11:43:56 CEST 2017


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository diffoscope.

commit 9d89fdda0101915eedf931a4c9127918cdfea79c
Author: Chris Lamb <lamby at debian.org>
Date:   Fri Jul 21 10:32:51 2017 +0100

    comparators.xml: Use 4-spaces, not 2-spaces for Python code.
    
    Gbp-Dch: Ignore
---
 diffoscope/comparators/xml.py | 148 +++++++++++++++++++++---------------------
 1 file changed, 74 insertions(+), 74 deletions(-)

diff --git a/diffoscope/comparators/xml.py b/diffoscope/comparators/xml.py
index 70e0d46..6a5a6e9 100644
--- a/diffoscope/comparators/xml.py
+++ b/diffoscope/comparators/xml.py
@@ -25,96 +25,96 @@ from diffoscope.comparators.utils.file import File
 from xml.parsers.expat import ExpatError
 
 def _format(node):
-  """
-  Removes *inplace* spaces from minidom.Document
-
-  Args:
-    node -- A xml.dom.minidom.Document object
-
-  Returns:
-    void
-  """
-  for n in node.childNodes:
-    if n.nodeType == minidom.Node.TEXT_NODE:
-      if n.nodeValue: n.nodeValue = n.nodeValue.strip()
-    elif n.nodeType == minidom.Node.ELEMENT_NODE:
-      _format(n)
-
-def _parse(file):
-  """
-  Formats a minidom.Document file and returns XML as string.
-
-  Args:
-    file -- An io.TextIOWrapper object
-
-  Returns:
-    str: formated string object
-  """
-  xml = minidom.parse(file)
-  _format(xml)
-  xml.normalize()
-  return xml.toprettyxml(indent=2*' ')
-
-
-class XMLFile(File):
-  """
-  XML Files Comparison class
-
-  Attributes:
-    RE_FILE_EXTENSION (SRE_Pattern): xml file extension pattern
-  """
-  RE_FILE_EXTENSION = re.compile(r'\.xml$')
-
-  @staticmethod
-  def recognizes(file):
     """
-    Identifies if a given file has XML extension
+    Removes *inplace* spaces from minidom.Document
 
     Args:
-      file - a diffoscope.comparators.utils.file.File object
+        node -- A xml.dom.minidom.Document object
 
     Returns:
-      False if file is not a XML File, True otherwise
+        void
     """
-    if XMLFile.RE_FILE_EXTENSION.search(file.name) is None:
-      return False
-
-    with open(file.path) as f:
-      try:
-        file.parsed = _parse(f)
-      except ExpatError:
-        return False
-
-    return True
+    for n in node.childNodes:
+        if n.nodeType == minidom.Node.TEXT_NODE:
+            if n.nodeValue: n.nodeValue = n.nodeValue.strip()
+        elif n.nodeType == minidom.Node.ELEMENT_NODE:
+            _format(n)
 
-  def compare_details(self, other, source=None):
+def _parse(file):
     """
-    Compares self.object with another, returning a Difference object
+    Formats a minidom.Document file and returns XML as string.
 
     Args:
-      other  -- A XMLFile object
-      source
+        file -- An io.TextIOWrapper object
 
     Returns:
-      A diffoscope.difference.Difference object
-    """
-    return [ Difference.from_text(self.dumps(self), self.dumps(other),
-      self.path, other.path)]
-
-  def dumps(self, file):
+        str: formated string object
     """
-    Opens a XMLFile and returns its parsed content
+    xml = minidom.parse(file)
+    _format(xml)
+    xml.normalize()
+    return xml.toprettyxml(indent=2*' ')
 
-    Args:
-      file -- XMLFile object
 
-    Returns:
-      str -- Formatted XML content from file
+class XMLFile(File):
     """
-    if file.parsed:
-      return file.parsed
+    XML Files Comparison class
 
-    with open(file.path) as f:
-      return _parse(f)
+    Attributes:
+        RE_FILE_EXTENSION (SRE_Pattern): xml file extension pattern
+    """
+    RE_FILE_EXTENSION = re.compile(r'\.xml$')
+
+    @staticmethod
+    def recognizes(file):
+        """
+        Identifies if a given file has XML extension
+
+        Args:
+            file - a diffoscope.comparators.utils.file.File object
+
+        Returns:
+            False if file is not a XML File, True otherwise
+        """
+        if XMLFile.RE_FILE_EXTENSION.search(file.name) is None:
+            return False
+
+        with open(file.path) as f:
+            try:
+                file.parsed = _parse(f)
+            except ExpatError:
+                return False
+
+        return True
+
+    def compare_details(self, other, source=None):
+        """
+        Compares self.object with another, returning a Difference object
+
+        Args:
+            other    -- A XMLFile object
+            source
+
+        Returns:
+            A diffoscope.difference.Difference object
+        """
+        return [ Difference.from_text(self.dumps(self), self.dumps(other),
+            self.path, other.path)]
+
+    def dumps(self, file):
+        """
+        Opens a XMLFile and returns its parsed content
+
+        Args:
+            file -- XMLFile object
+
+        Returns:
+            str -- Formatted XML content from file
+        """
+        if file.parsed:
+            return file.parsed
+
+        with open(file.path) as f:
+            return _parse(f)
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list