From c612e8d47ef20b70ba10508ac3e75714f7b1bacc Mon Sep 17 00:00:00 2001 From: Michal Vyskocil Date: Tue, 9 Apr 2013 11:35:53 +0200 Subject: [PATCH] python3 compatibility: use relative imports Use relative imports when using module's own modules - this makes a clear distinction between already developed copy and installed package. --- osc/babysitter.py | 2 +- osc/build.py | 6 +++--- osc/commandline.py | 16 ++++++++-------- osc/conf.py | 6 +++--- osc/core.py | 6 +++--- osc/fetch.py | 12 ++++++------ osc/util/archquery.py | 2 +- osc/util/debquery.py | 4 ++-- osc/util/packagequery.py | 6 +++--- osc/util/rpmquery.py | 2 +- 10 files changed, 31 insertions(+), 31 deletions(-) diff --git a/osc/babysitter.py b/osc/babysitter.py index 25b5093b..d1cbdc3f 100644 --- a/osc/babysitter.py +++ b/osc/babysitter.py @@ -11,7 +11,7 @@ import signal import traceback from osc import oscerr -from oscsslexcp import NoSecureSSLError +from .oscsslexcp import NoSecureSSLError from osc.util.cpio import CpioError from osc.util.packagequery import PackageError diff --git a/osc/build.py b/osc/build.py index c8336f0a..0cba1e04 100644 --- a/osc/build.py +++ b/osc/build.py @@ -16,14 +16,14 @@ from osc.core import get_buildinfo, store_read_apiurl, store_read_project, store from osc.core import get_binarylist, get_binary_file, run_external from osc.util import rpmquery, debquery, archquery import osc.conf -import oscerr +from . import oscerr import subprocess try: from xml.etree import cElementTree as ET except ImportError: import cElementTree as ET -from conf import config, cookiejar +from .conf import config, cookiejar change_personality = { 'i686': 'linux32', @@ -298,7 +298,7 @@ def get_repo(path): def get_prefer_pkgs(dirs, wanted_arch, type): import glob - from util import repodata, packagequery, cpio + from .util import repodata, packagequery, cpio paths = [] repositories = [] diff --git a/osc/commandline.py b/osc/commandline.py index 2ad5dbf0..4523adfa 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -4,17 +4,17 @@ # either version 2, or version 3 (at your option). -import cmdln -import conf -import oscerr +from . import cmdln +from . import conf +from . import oscerr import sys import time import urlparse from optparse import SUPPRESS_HELP -from core import * -from util import safewriter +from .core import * +from .util import safewriter MAN_HEADER = r""".TH %(ucname)s "1" "%(date)s" "%(name)s %(version)s" "User Commands" .SH NAME @@ -148,7 +148,7 @@ class Osc(cmdln.Cmdln): self.options.verbose = conf.config['verbose'] self.download_progress = None if conf.config.get('show_download_progress', False): - from meter import TextMeter + from .meter import TextMeter self.download_progress = TextMeter(hide_finished=True) @@ -4990,7 +4990,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. if opts.prefer_pkgs and build_descr_data is None: raise oscerr.WrongArgs('error: a build description is needed if \'--prefer-pkgs\' is used') elif opts.prefer_pkgs: - from build import get_prefer_pkgs + from .build import get_prefer_pkgs print 'Scanning the following dirs for local packages: %s' % ', '.join(opts.prefer_pkgs) prefer_pkgs, cpio = get_prefer_pkgs(opts.prefer_pkgs, arch, os.path.splitext(args[2])[1]) cpio.add(os.path.basename(args[2]), build_descr_data) @@ -6598,7 +6598,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. ${cmd_option_list} """ import glob - from util import rpmquery + from .util import rpmquery if opts.delete_old_files and conf.config['do_package_tracking']: # IMHO the --delete-old-files option doesn't really fit into our diff --git a/osc/conf.py b/osc/conf.py index 3595b0d0..902e0acf 100644 --- a/osc/conf.py +++ b/osc/conf.py @@ -45,9 +45,9 @@ import urllib import urllib2 import urlparse -import OscConfigParser +from . import OscConfigParser from osc import oscerr -from oscsslexcp import NoSecureSSLError +from .oscsslexcp import NoSecureSSLError GENERIC_KEYRING = False GNOME_KEYRING = False @@ -480,7 +480,7 @@ def _build_opener(url): if options['sslcertck']: try: - import oscssl + from . import oscssl from M2Crypto import m2urllib2 except ImportError as e: print e diff --git a/osc/core.py b/osc/core.py index 1544c2f3..8564595d 100644 --- a/osc/core.py +++ b/osc/core.py @@ -19,8 +19,8 @@ from urllib import pathname2url, quote_plus, urlencode, unquote from urlparse import urlsplit, urlunsplit from cStringIO import StringIO import shutil -import oscerr -import conf +from . import oscerr +from . import conf import subprocess import re import socket @@ -3960,7 +3960,7 @@ def get_binary_file(apiurl, prj, repo, arch, progress_meter = False): progress_obj = None if progress_meter: - from meter import TextMeter + from .meter import TextMeter progress_obj = TextMeter() target_filename = target_filename or filename diff --git a/osc/fetch.py b/osc/fetch.py index 582b4200..dc4826cc 100644 --- a/osc/fetch.py +++ b/osc/fetch.py @@ -9,14 +9,14 @@ from urllib import quote_plus from urlgrabber.grabber import URLGrabError from urlgrabber.mirror import MirrorGroup -from core import makeurl, streamfile -from util import packagequery, cpio -import conf -import oscerr +from .core import makeurl, streamfile +from .util import packagequery, cpio +from . import conf +from . import oscerr import tempfile import re try: - from meter import TextMeter + from .meter import TextMeter except: TextMeter = None @@ -372,7 +372,7 @@ def verify_pacs(bi): print "using keys from", ', '.join(bi.prjkeys) - import checker + from . import checker failed = False checker = checker.Checker() try: diff --git a/osc/util/archquery.py b/osc/util/archquery.py index fbe4dc88..e83d24e6 100644 --- a/osc/util/archquery.py +++ b/osc/util/archquery.py @@ -1,7 +1,7 @@ import os.path import re import tarfile -import packagequery +from . import packagequery import subprocess class ArchError(packagequery.PackageError): diff --git a/osc/util/debquery.py b/osc/util/debquery.py index 30e1ec97..c7d8b325 100644 --- a/osc/util/debquery.py +++ b/osc/util/debquery.py @@ -1,8 +1,8 @@ -import ar +from . import ar import os.path import re import tarfile -import packagequery +from . import packagequery class DebError(packagequery.PackageError): pass diff --git a/osc/util/packagequery.py b/osc/util/packagequery.py index 872b7d07..b0978269 100644 --- a/osc/util/packagequery.py +++ b/osc/util/packagequery.py @@ -91,18 +91,18 @@ class PackageQuery: extra_tags = () pkgquery = None if magic[:4] == '\xed\xab\xee\xdb': - import rpmquery + from . import rpmquery pkgquery = rpmquery.RpmQuery(f) extra_tags = extra_rpmtags elif magic == '!': - import debquery + from . import debquery pkgquery = debquery.DebQuery(f) extra_tags = extra_debtags elif magic[:5] == '