[diffoscope] 02/02: comparators.xml: refactored to use File.recognizes logic

Juliana Oliveira R jwnx-guest at moszumanska.debian.org
Thu Jul 27 03:14:46 CEST 2017


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

jwnx-guest pushed a commit to branch master
in repository diffoscope.

commit bb329cd029f1b8d4821e8a0d449069441dd34cb2
Author: Juliana Oliveira Rodrigues <juliana.orod at gmail.com>
Date:   Wed Jul 26 22:07:13 2017 -0300

    comparators.xml: refactored to use File.recognizes logic
    
    Removes duplicated code from XMLFile comparator by using File.recognizes.
    
    Signed-off-by: Juliana Oliveira Rodrigues <juliana.orod at gmail.com>
---
 diffoscope/comparators/xml.py | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/diffoscope/comparators/xml.py b/diffoscope/comparators/xml.py
index 5ba5516..528dddd 100644
--- a/diffoscope/comparators/xml.py
+++ b/diffoscope/comparators/xml.py
@@ -17,8 +17,6 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.
 
-import re
-
 from xml.dom import minidom
 from xml.parsers.expat import ExpatError
 
@@ -68,12 +66,12 @@ class XMLFile(File):
     XML Files Comparison class
 
     Attributes:
-        RE_FILE_EXTENSION (SRE_Pattern): xml file extension pattern
+        FILE_EXTENSION_SUFFIX (str): xml file extension suffix
     """
-    RE_FILE_EXTENSION = re.compile(r'\.xml$')
+    FILE_EXTENSION_SUFFIX = '.xml'
 
-    @staticmethod
-    def recognizes(file):
+    @classmethod
+    def recognizes(cls, file):
         """
         Identifies if a given file has XML extension
 
@@ -83,8 +81,8 @@ class XMLFile(File):
         Returns:
             False if file is not a XML File, True otherwise
         """
-        if XMLFile.RE_FILE_EXTENSION.search(file.name) is None:
-            return False
+        if not super().recognizes(file):
+          return False
 
         with open(file.path) as f:
             try:

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


More information about the diffoscope mailing list