[diffoscope] 02/03: comparators/ppu: put code out of the context manager, it doesn't need to be within

Mattia Rizzolo mattia at debian.org
Tue Aug 30 16:43:10 CEST 2016


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

mattia pushed a commit to branch master
in repository diffoscope.

commit 5f3525ac00a4456c4f62837ed6fc6e418a8f7d6e
Author: Mattia Rizzolo <mattia at debian.org>
Date:   Tue Aug 30 14:02:55 2016 +0000

    comparators/ppu: put code out of the context manager, it doesn't need to be within
---
 diffoscope/comparators/ppu.py | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/diffoscope/comparators/ppu.py b/diffoscope/comparators/ppu.py
index 7b24311..8101762 100644
--- a/diffoscope/comparators/ppu.py
+++ b/diffoscope/comparators/ppu.py
@@ -64,25 +64,25 @@ class PpuFile(File):
             if magic != b"PPU":
                 return False
             ppu_version = f.read(3).decode('ascii', errors='ignore')
-            if not hasattr(PpuFile, 'ppu_version'):
+        if not hasattr(PpuFile, 'ppu_version'):
+            try:
+                subprocess.check_output(['ppudump', file.path], shell=False, stderr=subprocess.STDOUT)
+                PpuFile.ppu_version = ppu_version
+            except subprocess.CalledProcessError as e:
+                error = e.output.decode('utf-8', errors='ignore')
+                m = re.search('Expecting PPU version ([0-9]+)', error)
                 try:
-                    subprocess.check_output(['ppudump', file.path], shell=False, stderr=subprocess.STDOUT)
-                    PpuFile.ppu_version = ppu_version
-                except subprocess.CalledProcessError as e:
-                    error = e.output.decode('utf-8', errors='ignore')
-                    m = re.search('Expecting PPU version ([0-9]+)', error)
-                    try:
-                        PpuFile.ppu_version = m.group(1)
-                    except AttributeError:
-                        if m is None:
-                            PpuFile.ppu_version = None
-                            logger.debug('Unable to read PPU version')
-                        else:
-                            raise
-                except OSError:
-                    PpuFile.ppu_version = None
-                    logger.debug('Unable to read PPU version')
-            return PpuFile.ppu_version == ppu_version
+                    PpuFile.ppu_version = m.group(1)
+                except AttributeError:
+                    if m is None:
+                        PpuFile.ppu_version = None
+                        logger.debug('Unable to read PPU version')
+                    else:
+                        raise
+            except OSError:
+                PpuFile.ppu_version = None
+                logger.debug('Unable to read PPU version')
+        return PpuFile.ppu_version == ppu_version
 
     def compare_details(self, other, source=None):
         return [Difference.from_command(Ppudump, self.path, other.path)]

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


More information about the diffoscope mailing list