Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
[email protected] webmail now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!

Paste

Pasted as Diff by SergeyD ( 15 years ago )
diff -udrN comix-4.0.4.orig/src/about.py comix-4.0.4/src/about.py
--- comix-4.0.4.orig/src/about.py	2009-02-14 14:09:21.000000000 +0300
+++ comix-4.0.4/src/about.py	2009-06-12 00:29:19.888411009 +0400
@@ -55,7 +55,7 @@
         '</span></b></big></big></big></big>

' +
         _('Comix is an image viewer specifically designed to handle comic books.') +
         '
' +
-        _('It reads ZIP, RAR and tar archives, as well as plain image files.') +
+        _('It reads ZIP, RAR, 7-zip and tar archives, as well as plain image files.') +
         '

' +
         _('Comix is licensed under the GNU General Public License.') +
         '

' +
diff -udrN comix-4.0.4.orig/src/archive.py comix-4.0.4/src/archive.py
--- comix-4.0.4.orig/src/archive.py	2009-04-03 21:11:43.000000000 +0400
+++ comix-4.0.4/src/archive.py	2009-06-12 09:44:12.149403563 +0400
@@ -11,10 +11,11 @@
 
 import process
 
-ZIP, RAR, TAR, GZIP, BZIP2 = range(5)
+ZIP, RAR, TAR, GZIP, BZIP2, P7Z = range(6)
 
 _rar_exec = None
 
+_p7z_exec = None
 
 class Extractor:
 
@@ -74,6 +75,37 @@
             self._files = [name.rstrip(os.linesep) for name in fd.readlines()]
             fd.close()
             proc.wait()
+        elif self._type == P7Z:
+            global _p7z_exec
+            print('p7z: %s
' % _p7z_exec)
+            if _p7z_exec is None:
+                _p7z_exec = _get_p7z_exec()
+                if _p7z_exec is None:
+                    print '! Could not find 7-zip file extractor.'
+                    dialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_WARNING,
+                        gtk.BUTTONS_CLOSE,
+                        _("Could not find 7-zip file extractor!"))
+                    dialog.format_secondary_markup(
+                        _("You need either the <i>7zr</i> or the <i>7z</i> or the <i>7za</i> program installed in order to read 7-zip (.cb7) files."))
+                    dialog.run()
+                    dialog.destroy()
+                    return None
+            proc = process.Process([_p7z_exec, 'l', '-slt', src])
+            fd = proc.spawn()
+            #self._files = [name.rstrip(os.linesep).rsplit('               ')[-1] for name in fd.readlines()]
+            lastPath = None
+            lastAttr = None
+            self._files = []
+            for line in fd.readlines():
+                if line.startswith('Path ='):
+                    lastPath = line.replace('Path = ', '').rstrip(os.linesep)
+                    lastAttr = None
+                elif line.startswith('Attributes = '):
+                    lastAttr = line.replace('Attributes = ', '').rstrip(os.linesep)
+                    if not lastAttr.startswith('D') and lastPath:
+                        self._files.append(lastPath)
+            fd.close()
+            proc.wait()
         else:
             print '! Non-supported archive format:', src
             return None
@@ -179,6 +211,14 @@
                     proc.wait()
                 else:
                     print '! Could not find RAR file extractor.'
+            elif self._type == P7Z:
+                if _p7z_exec is not None:
+                    proc = process.Process([_p7z_exec, 'x', '-bd', '-o%s' % self._dst,
+                        self._src, name])
+                    proc.spawn()
+                    proc.wait()
+                else:
+                    print '! Could not find RAR file extractor.'
         except Exception:
             # Better to ignore any failed extractions (e.g. from a corrupt
             # archive) than to crash here and leave the main thread in a
@@ -296,6 +336,8 @@
                 return TAR
             if magic == 'Rar!':
                 return RAR
+            if magic.startswith('7z'):
+                return P7Z
     except Exception:
         print '! Error while reading', path
     return None
@@ -307,6 +349,7 @@
             TAR:   _('Tar archive'),
             GZIP:  _('Gzip compressed tar archive'),
             BZIP2: _('Bzip2 compressed tar archive'),
+            P7Z:   _('7-zip archive'),
             RAR:   _('RAR archive')}[archive_type]
 
 
@@ -335,3 +378,12 @@
         if process.Process([command]).spawn() is not None:
             return command
     return None
+
+def _get_p7z_exec():
+    """Return the name of the 7-zip file extractor executable, or None if
+    no such executable is found.
+    """
+    for command in ('7zr', '7z', '7za'):
+        if process.Process([command]).spawn() is not None:
+            return command
+    return None
diff -udrN comix-4.0.4.orig/src/filechooser.py comix-4.0.4/src/filechooser.py
--- comix-4.0.4.orig/src/filechooser.py	2009-04-03 21:06:13.000000000 +0400
+++ comix-4.0.4/src/filechooser.py	2009-06-12 09:46:58.209902230 +0400
@@ -81,11 +81,13 @@
         self.add_filter(_('All Archives'), ('application/x-zip',
             'application/zip', 'application/x-rar', 'application/x-tar',
             'application/x-gzip', 'application/x-bzip2', 'application/x-cbz',
-            'application/x-cbr', 'application/x-cbt'))
+            'application/x-cbr', 'application/x-cbt', 'application/x-7z-compressed', 'application/x-cb7'))
         self.add_filter(_('ZIP archives'),
             ('application/x-zip', 'application/zip', 'application/x-cbz'))
         self.add_filter(_('RAR archives'),
             ('application/x-rar', 'application/x-cbr'))
+        self.add_filter(_('7-zip archives'),
+            ('application/x-7z-compressed', 'application/x-cb7'))
         self.add_filter(_('Tar archives'),
             ('application/x-tar', 'application/x-gzip',
             'application/x-bzip2', 'application/x-cbt'))

 

Revise this Paste

Your Name: Code Language: