#115 Support for 7zip archives

open
nobody
None
5
2009-05-13
2009-05-13
Anonymous
No

It would be nice if Comix has support for image archives produced using the 7zip archiver (*.7z extension). I find it surprising that Comix has support for the proprietary RAR archive format and none for the free and open 7Z archive format. Even more surprising is the fact that the 7zip archiver is itself another SourceForge project!

Discussion

  • Nobody/Anonymous

    Actually, I've encountered files with the extension .cb7, which I suppose means C(omic)B(ook) in 7(z) format. Not that many at the moment I guess. But 7z is a damn fine format for rearchiving, often more efficient than rar.

     
  • Nobody/Anonymous

    +1

     
  • Sergey

    Sergey - 2009-06-12

    There was another patch, but this one is simple.
    Can't attach file here...

    diff -udrN comix-4.0.4/src/about.py comix-4.0.4-with-7z/src/about.py
    --- comix-4.0.4/src/about.py 2009-02-14 14:09:21.000000000 +0300
    +++ comix-4.0.4-with-7z/src/about.py 2009-06-12 00:29:19.888411009 +0400
    @@ -55,7 +55,7 @@
    '</span></b></big></big></big></big>\n\n' +
    _('Comix is an image viewer specifically designed to handle comic books.') +
    '\n' +
    - _('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.') +
    '\n\n' +
    _('Comix is licensed under the GNU General Public License.') +
    '\n\n' +
    diff -udrN comix-4.0.4/src/archive.py comix-4.0.4-with-7z/src/archive.py
    --- comix-4.0.4/src/archive.py 2009-04-03 21:11:43.000000000 +0400
    +++ comix-4.0.4-with-7z/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\n' % _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/src/filechooser.py comix-4.0.4-with-7z/src/filechooser.py
    --- comix-4.0.4/src/filechooser.py 2009-04-03 21:06:13.000000000 +0400
    +++ comix-4.0.4-with-7z/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'))

     
  • Sergey

    Sergey - 2009-06-12

    Doh...
    I sended patch to mantainer by email

     
  • Nobody/Anonymous

    How do I install that patch, sergey_d?

     
  • Nobody/Anonymous

    I hope you run it on Linux machine:

    1. unpack comix-4.0.4 sources
    2. put patch in sources directory, something like: /path/to/sources/comix-4.0.4/comix-4.0.4-add-7zip-support.patch
    3. change working directory to /path/to/sources/comix-4.0.4/
    4. run: patch -p1 < comix-4.0.4-add-7zip-support.patch
    5. run your new shiny comix: python src/comix.py

    If you use MS Windows (tm) (r) - look for GNUWin32 tools or CygWin project - they have patch tool

     
  • Sergey

    Sergey - 2009-06-21

    Previuos comment was from me...

     
  • Nobody/Anonymous

    patch: **** malformed patch at line 5: '</span></b></big></big></big></big>\n\n' +

    I get this error :|

     
  • Sergey

    Sergey - 2009-06-23

    Try use this patch from http://paste.org/8595

     
  • Nobody/Anonymous

    How do I install it with Ubuntu? Do I patch /usr/bin/comix ?

     
  • Nobody/Anonymous

    patching file src/about.py
    patch: **** malformed patch at line 7: ' +

    I tried the pastebin one :(

     
  • Sergey

    Sergey - 2009-06-27

    Damn... paste.org broke patch...

    Lets try another one...

    http://paste.org.ru/?785nku

     
  • PhoneixS

    PhoneixS - 2010-02-17

    I will like if it can open 7z files. Something about if it will be implemented by the programmer?

     
  • Kelly Clowers

    Kelly Clowers - 2010-03-11

    It is nice to see a patch, but it would be nicer if it was integrated.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks