From de4dd49e336b5faaa4bf1224f44c4259032afa23 Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Sun, 21 Feb 2010 15:56:45 +0100 Subject: [PATCH] Move program handlers into own python module package. --- doc/todo.txt | 2 -- patoolib/__init__.py | 4 ++-- patoolib/programs/__init__.py | 15 +++++++++++++++ patoolib/{ => programs}/arj.py | 0 patoolib/{ => programs}/bzip2.py | 2 +- patoolib/{ => programs}/cabextract.py | 0 patoolib/{ => programs}/compress.py | 2 +- patoolib/{ => programs}/cpio.py | 2 +- patoolib/{ => programs}/dpkg.py | 0 patoolib/{ => programs}/echo.py | 2 +- patoolib/{ => programs}/gzip.py | 2 +- patoolib/{ => programs}/lzop.py | 0 patoolib/{ => programs}/p7zip.py | 0 patoolib/{ => programs}/pbzip2.py | 0 patoolib/{ => programs}/rar.py | 0 patoolib/{ => programs}/rpm.py | 0 patoolib/{ => programs}/rpm2cpio.py | 2 +- patoolib/{ => programs}/star.py | 0 patoolib/{ => programs}/tar.py | 0 patoolib/{ => programs}/uncompress.py | 2 +- patoolib/{ => programs}/unrar.py | 0 patoolib/{ => programs}/unzip.py | 0 22 files changed, 24 insertions(+), 11 deletions(-) delete mode 100644 doc/todo.txt create mode 100644 patoolib/programs/__init__.py rename patoolib/{ => programs}/arj.py (100%) rename patoolib/{ => programs}/bzip2.py (98%) rename patoolib/{ => programs}/cabextract.py (100%) rename patoolib/{ => programs}/compress.py (98%) rename patoolib/{ => programs}/cpio.py (99%) rename patoolib/{ => programs}/dpkg.py (100%) rename patoolib/{ => programs}/echo.py (98%) rename patoolib/{ => programs}/gzip.py (99%) rename patoolib/{ => programs}/lzop.py (100%) rename patoolib/{ => programs}/p7zip.py (100%) rename patoolib/{ => programs}/pbzip2.py (100%) rename patoolib/{ => programs}/rar.py (100%) rename patoolib/{ => programs}/rpm.py (100%) rename patoolib/{ => programs}/rpm2cpio.py (98%) rename patoolib/{ => programs}/star.py (100%) rename patoolib/{ => programs}/tar.py (100%) rename patoolib/{ => programs}/uncompress.py (98%) rename patoolib/{ => programs}/unrar.py (100%) rename patoolib/{ => programs}/unzip.py (100%) diff --git a/doc/todo.txt b/doc/todo.txt deleted file mode 100644 index a7306e5..0000000 --- a/doc/todo.txt +++ /dev/null @@ -1,2 +0,0 @@ -- add create command -- move all program modules into subpackage diff --git a/patoolib/__init__.py b/patoolib/__init__.py index b8b94b9..3b4c772 100644 --- a/patoolib/__init__.py +++ b/patoolib/__init__.py @@ -286,8 +286,8 @@ def _handle_archive (archive, command, *args, **kwargs): # get python module for given archive program key = os.path.basename(program).lower() module = ProgramModules.get(key, key) - # import archive handler (eg. patoolib.star.extract_tar()) - exec "from patoolib.%s import %s_%s as func" % (module, command, format) + # import archive handler (eg. patoolib.programs.star.extract_tar()) + exec "from patoolib.programs.%s import %s_%s as func" % (module, command, format) get_archive_cmdlist = locals()['func'] # prepare func() call arguments kwargs = dict(verbose=config['verbose']) diff --git a/patoolib/programs/__init__.py b/patoolib/programs/__init__.py new file mode 100644 index 0000000..27a8694 --- /dev/null +++ b/patoolib/programs/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2010 Bastian Kleineidam +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . diff --git a/patoolib/arj.py b/patoolib/programs/arj.py similarity index 100% rename from patoolib/arj.py rename to patoolib/programs/arj.py diff --git a/patoolib/bzip2.py b/patoolib/programs/bzip2.py similarity index 98% rename from patoolib/bzip2.py rename to patoolib/programs/bzip2.py index e8caac6..0bbf31c 100644 --- a/patoolib/bzip2.py +++ b/patoolib/programs/bzip2.py @@ -15,7 +15,7 @@ # along with this program. If not, see . """Archive commands for the bzip2 program.""" import os -from . import util +from .. import util def extract_bzip2 (archive, encoding, cmd, **kwargs): diff --git a/patoolib/cabextract.py b/patoolib/programs/cabextract.py similarity index 100% rename from patoolib/cabextract.py rename to patoolib/programs/cabextract.py diff --git a/patoolib/compress.py b/patoolib/programs/compress.py similarity index 98% rename from patoolib/compress.py rename to patoolib/programs/compress.py index 88dcca4..e4bd9ca 100644 --- a/patoolib/compress.py +++ b/patoolib/programs/compress.py @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the uncompress.real program.""" -from . import util +from .. import util def create_compress (archive, encoding, cmd, *args, **kwargs): diff --git a/patoolib/cpio.py b/patoolib/programs/cpio.py similarity index 99% rename from patoolib/cpio.py rename to patoolib/programs/cpio.py index 513f9d4..c2850ac 100644 --- a/patoolib/cpio.py +++ b/patoolib/programs/cpio.py @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the cpio program.""" -from . import util +from .. import util def extract_cpio (archive, encoding, cmd, **kwargs): """Extract a CPIO archive.""" diff --git a/patoolib/dpkg.py b/patoolib/programs/dpkg.py similarity index 100% rename from patoolib/dpkg.py rename to patoolib/programs/dpkg.py diff --git a/patoolib/echo.py b/patoolib/programs/echo.py similarity index 98% rename from patoolib/echo.py rename to patoolib/programs/echo.py index 15bb96e..b21e35f 100644 --- a/patoolib/echo.py +++ b/patoolib/programs/echo.py @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . """Archive commands for the echo program.""" -from . import util +from .. import util def list_bzip2 (archive, encoding, cmd, **kwargs): diff --git a/patoolib/gzip.py b/patoolib/programs/gzip.py similarity index 99% rename from patoolib/gzip.py rename to patoolib/programs/gzip.py index 9c8a010..ff8fffa 100644 --- a/patoolib/gzip.py +++ b/patoolib/programs/gzip.py @@ -15,7 +15,7 @@ # along with this program. If not, see . """Archive commands for the gzip program.""" import os -from . import util +from .. import util def extract_gzip (archive, encoding, cmd, **kwargs): diff --git a/patoolib/lzop.py b/patoolib/programs/lzop.py similarity index 100% rename from patoolib/lzop.py rename to patoolib/programs/lzop.py diff --git a/patoolib/p7zip.py b/patoolib/programs/p7zip.py similarity index 100% rename from patoolib/p7zip.py rename to patoolib/programs/p7zip.py diff --git a/patoolib/pbzip2.py b/patoolib/programs/pbzip2.py similarity index 100% rename from patoolib/pbzip2.py rename to patoolib/programs/pbzip2.py diff --git a/patoolib/rar.py b/patoolib/programs/rar.py similarity index 100% rename from patoolib/rar.py rename to patoolib/programs/rar.py diff --git a/patoolib/rpm.py b/patoolib/programs/rpm.py similarity index 100% rename from patoolib/rpm.py rename to patoolib/programs/rpm.py diff --git a/patoolib/rpm2cpio.py b/patoolib/programs/rpm2cpio.py similarity index 98% rename from patoolib/rpm2cpio.py rename to patoolib/programs/rpm2cpio.py index f95c174..b241bea 100644 --- a/patoolib/rpm2cpio.py +++ b/patoolib/programs/rpm2cpio.py @@ -15,7 +15,7 @@ # along with this program. If not, see . """Archive commands for the rpm2cpio program.""" import os -from . import util +from .. import util def extract_rpm (archive, encoding, cmd, **kwargs): """Extract a DEB archive.""" diff --git a/patoolib/star.py b/patoolib/programs/star.py similarity index 100% rename from patoolib/star.py rename to patoolib/programs/star.py diff --git a/patoolib/tar.py b/patoolib/programs/tar.py similarity index 100% rename from patoolib/tar.py rename to patoolib/programs/tar.py diff --git a/patoolib/uncompress.py b/patoolib/programs/uncompress.py similarity index 98% rename from patoolib/uncompress.py rename to patoolib/programs/uncompress.py index 5f8762d..2e4c9a3 100644 --- a/patoolib/uncompress.py +++ b/patoolib/programs/uncompress.py @@ -15,7 +15,7 @@ # along with this program. If not, see . """Archive commands for the uncompress.real program.""" import os -from . import util +from .. import util def extract_compress (archive, encoding, cmd, **kwargs): diff --git a/patoolib/unrar.py b/patoolib/programs/unrar.py similarity index 100% rename from patoolib/unrar.py rename to patoolib/programs/unrar.py diff --git a/patoolib/unzip.py b/patoolib/programs/unzip.py similarity index 100% rename from patoolib/unzip.py rename to patoolib/programs/unzip.py