Port to Python 2.4: remove with statement and relative imports.

This commit is contained in:
Bastian Kleineidam 2010-03-04 14:57:55 +01:00
parent a91aade7fd
commit 76ede8c91d
13 changed files with 16 additions and 14 deletions

View File

@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import shutil
from . import util
from patoolib import util
# Supported archive commands
ArchiveCommands = ('list', 'extract', 'test', 'create')

View File

@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Archive commands for the bzip2 program."""
from .. import util
from patoolib import util
def extract_bzip2 (archive, encoding, cmd, **kwargs):

View File

@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Archive commands for the uncompress.real program."""
from .. import util
from patoolib import util
def create_compress (archive, encoding, cmd, *args, **kwargs):

View File

@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Archive commands for the cpio program."""
from .. import util
from patoolib import util
def extract_cpio (archive, encoding, cmd, **kwargs):
"""Extract a CPIO archive."""

View File

@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Archive commands for the echo program."""
from .. import util
from patoolib import util
def list_bzip2 (archive, encoding, cmd, **kwargs):

View File

@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Archive commands for the gzip program."""
from .. import util
from patoolib import util
def extract_gzip (archive, encoding, cmd, **kwargs):

View File

@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Archive commands for the lzma program."""
from .. import util
from patoolib import util
def extract_lzma (archive, encoding, cmd, **kwargs):

View File

@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Archive commands for the lzop program."""
from .. import util
from patoolib import util
def extract_lzop (archive, encoding, cmd, **kwargs):

View File

@ -15,4 +15,4 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Archive commands for the pbzip2 program."""
# bzip2 and pbzip2 are compatible
from .bzip2 import extract_bzip2, test_bzip2, create_bzip2
from patoolib.programs.bzip2 import extract_bzip2, test_bzip2, create_bzip2

View File

@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Archive commands for the rpm2cpio program."""
import os
from .. import util
from patoolib import util
def extract_rpm (archive, encoding, cmd, **kwargs):
"""Extract a DEB archive."""

View File

@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Archive commands for the uncompress.real program."""
from .. import util
from patoolib import util
def extract_compress (archive, encoding, cmd, **kwargs):

View File

@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Archive commands for the xz program."""
from .. import util
from patoolib import util
def extract_xz (archive, encoding, cmd, **kwargs):

View File

@ -14,7 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Utility functions."""
from __future__ import with_statement
import os
import sys
import subprocess
@ -277,8 +276,11 @@ def get_nt_7z_dir ():
"""Return 7-Zip directory from registry, or an empty string."""
try:
import _winreg
with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\7-Zip") as key:
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\7-Zip")
try:
return _winreg.QueryValueEx(key, "Path")[0]
finally:
_winreg.CloseKey(key)
except WindowsError:
return ""