1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-09-20 01:06:17 +02:00

Always import at the toplevel

This commit is contained in:
Daniel Mach 2022-09-09 11:46:28 +02:00
parent 6d891d7488
commit b511be20ff
30 changed files with 68 additions and 152 deletions

View File

@ -3,6 +3,7 @@
# and distributed under the terms of the GNU General Public Licence, # and distributed under the terms of the GNU General Public Licence,
# either version 2, or (at your option) any later version. # either version 2, or (at your option) any later version.
import glob
import os import os
import re import re
import shutil import shutil
@ -22,7 +23,9 @@ from .core import get_buildinfo, store_read_project, store_read_package, meta_ex
from .core import get_binarylist, get_binary_file, run_external, return_external, raw_input from .core import get_binarylist, get_binary_file, run_external, return_external, raw_input
from .fetch import Fetcher, OscFileGrabber, verify_pacs from .fetch import Fetcher, OscFileGrabber, verify_pacs
from .meter import create_text_meter from .meter import create_text_meter
from .util import rpmquery, debquery, archquery from .util import cpio
from .util import archquery, debquery, packagequery, rpmquery
from .util import repodata
from .util.helper import decode_it from .util.helper import decode_it
@ -466,8 +469,6 @@ def get_repo(path):
return repositoryDirectory return repositoryDirectory
def get_prefer_pkgs(dirs, wanted_arch, type, cpio): def get_prefer_pkgs(dirs, wanted_arch, type, cpio):
import glob
from .util import repodata, packagequery
paths = [] paths = []
repositories = [] repositories = []
@ -888,13 +889,11 @@ def main(apiurl, opts, argv):
else: else:
print('Using local buildenv file: %s' % os.path.basename(buildenvfile)) print('Using local buildenv file: %s' % os.path.basename(buildenvfile))
if buildenvfile or servicefile: if buildenvfile or servicefile:
from .util import cpio
if not cpiodata: if not cpiodata:
cpiodata = cpio.CpioWrite() cpiodata = cpio.CpioWrite()
if opts.prefer_pkgs: if opts.prefer_pkgs:
print('Scanning the following dirs for local packages: %s' % ', '.join(opts.prefer_pkgs)) print('Scanning the following dirs for local packages: %s' % ', '.join(opts.prefer_pkgs))
from .util import cpio
if not cpiodata: if not cpiodata:
cpiodata = cpio.CpioWrite() cpiodata = cpio.CpioWrite()
prefer_pkgs = get_prefer_pkgs(opts.prefer_pkgs, arch, build_type, cpiodata) prefer_pkgs = get_prefer_pkgs(opts.prefer_pkgs, arch, build_type, cpiodata)
@ -1329,7 +1328,6 @@ def main(apiurl, opts, argv):
if i.hdrmd5: if i.hdrmd5:
if not i.name.startswith('container:') and i.pacsuffix != 'rpm': if not i.name.startswith('container:') and i.pacsuffix != 'rpm':
continue continue
from .util import packagequery
if i.name.startswith('container:'): if i.name.startswith('container:'):
hdrmd5 = dgst(i.fullfilename) hdrmd5 = dgst(i.fullfilename)
else: else:

View File

@ -4,22 +4,32 @@
# either version 2, or version 3 (at your option). # either version 2, or version 3 (at your option).
import argparse import argparse
import getpass
import glob
import importlib.util import importlib.util
import inspect import inspect
import os import os
import re
import subprocess
import sys import sys
import textwrap
import tempfile
import time import time
import traceback
from functools import cmp_to_key from functools import cmp_to_key
from operator import itemgetter from operator import itemgetter
from optparse import SUPPRESS_HELP from optparse import SUPPRESS_HELP
from urllib.parse import urlsplit from urllib.parse import urlsplit
from urllib.error import HTTPError from urllib.error import HTTPError
from . import build as osc_build
from . import cmdln from . import cmdln
from . import conf from . import conf
from . import oscerr from . import oscerr
from .core import * from .core import *
from .util import safewriter from .grabber import OscFileGrabber
from .meter import create_text_meter
from .util import cpio, rpmquery, safewriter
from .util.helper import _html_escape, format_table from .util.helper import _html_escape, format_table
@ -188,7 +198,6 @@ class Osc(cmdln.Cmdln):
self.options.verbose = conf.config['verbose'] self.options.verbose = conf.config['verbose']
self.download_progress = None self.download_progress = None
if conf.config.get('show_download_progress', False): if conf.config.get('show_download_progress', False):
from .meter import create_text_meter
self.download_progress = create_text_meter() self.download_progress = create_text_meter()
def get_api_url(self): def get_api_url(self):
@ -2079,7 +2088,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
repository = opts.repository repository = opts.repository
if not opts.message: if not opts.message:
import textwrap
if package is not None: if package is not None:
footer = textwrap.TextWrapper(width = 66).fill( footer = textwrap.TextWrapper(width = 66).fill(
'please explain why you like to delete package %s of project %s' 'please explain why you like to delete package %s of project %s'
@ -2132,7 +2140,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
devel_package = args[3] devel_package = args[3]
if not opts.message: if not opts.message:
import textwrap
footer = textwrap.TextWrapper(width = 66).fill( footer = textwrap.TextWrapper(width = 66).fill(
'please explain why you like to change the devel project of %s/%s to %s/%s' 'please explain why you like to change the devel project of %s/%s to %s/%s'
% (project, package, devel_project, devel_package)) % (project, package, devel_project, devel_package))
@ -4353,8 +4360,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
usage: usage:
osc repourls [PROJECT] osc repourls [PROJECT]
""" """
import tempfile
def _repo_type(apiurl, project, repo): def _repo_type(apiurl, project, repo):
if not os.path.exists('/usr/lib/build/queryconfig'): if not os.path.exists('/usr/lib/build/queryconfig'):
return None return None
@ -5480,8 +5485,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
buildlog [REPOSITORY ARCH | BUILDLOGURL] buildlog [REPOSITORY ARCH | BUILDLOGURL]
""" """
import osc.build
project = package = repository = arch = None project = package = repository = arch = None
apiurl = self.get_api_url() apiurl = self.get_api_url()
@ -5497,7 +5500,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
# no local build with this repo was done # no local build with this repo was done
print('failed to guess arch, using hostarch') print('failed to guess arch, using hostarch')
repository = args[0] repository = args[0]
arch = osc.build.hostarch arch = osc_build.hostarch
elif len(args) < 2: elif len(args) < 2:
self.print_repos() self.print_repos()
elif len(args) > 2: elif len(args) > 2:
@ -5627,7 +5630,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
print_buildlog(apiurl, quote_plus(project), quote_plus(package), quote_plus(repository), quote_plus(arch), offset, strip_time, opts.last, opts.lastsucceeded) print_buildlog(apiurl, quote_plus(project), quote_plus(package), quote_plus(repository), quote_plus(arch), offset, strip_time, opts.last, opts.lastsucceeded)
def _find_last_repo_arch(self, repo=None, fatal=True): def _find_last_repo_arch(self, repo=None, fatal=True):
import glob
files = glob.glob(os.path.join(os.getcwd(), store, "_buildinfo-*")) files = glob.glob(os.path.join(os.getcwd(), store, "_buildinfo-*"))
if repo is not None: if repo is not None:
files = [f for f in files files = [f for f in files
@ -5930,11 +5932,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if opts.prefer_pkgs and build_descr_data is None: if opts.prefer_pkgs and build_descr_data is None:
raise oscerr.WrongArgs('error: a build description is needed if \'--prefer-pkgs\' is used') raise oscerr.WrongArgs('error: a build description is needed if \'--prefer-pkgs\' is used')
elif opts.prefer_pkgs: elif opts.prefer_pkgs:
from .build import get_prefer_pkgs
from .util import cpio
print('Scanning the following dirs for local packages: %s' % ', '.join(opts.prefer_pkgs)) print('Scanning the following dirs for local packages: %s' % ', '.join(opts.prefer_pkgs))
cpiodata = cpio.CpioWrite() cpiodata = cpio.CpioWrite()
prefer_pkgs = get_prefer_pkgs(opts.prefer_pkgs, arch, prefer_pkgs = osc_build.get_prefer_pkgs(opts.prefer_pkgs, arch,
os.path.splitext(build_descr)[1], os.path.splitext(build_descr)[1],
cpiodata) cpiodata)
cpiodata.add(os.path.basename(build_descr.encode()), build_descr_data) cpiodata.add(os.path.basename(build_descr.encode()), build_descr_data)
@ -6132,16 +6132,13 @@ Please submit there instead, or use --nodevelproject to force direct submission.
def parse_repoarchdescr(self, args, noinit = False, alternative_project = None, ignore_descr = False, vm_type = None, multibuild_package = None): def parse_repoarchdescr(self, args, noinit = False, alternative_project = None, ignore_descr = False, vm_type = None, multibuild_package = None):
"""helper to parse the repo, arch and build description from args""" """helper to parse the repo, arch and build description from args"""
import osc.build
import glob
import tempfile
arg_arch = arg_repository = arg_descr = None arg_arch = arg_repository = arg_descr = None
if len(args) < 3: if len(args) < 3:
# some magic, works only sometimes, but people seem to like it :/ # some magic, works only sometimes, but people seem to like it :/
all_archs = [] all_archs = []
for mainarch in osc.build.can_also_build: for mainarch in osc_build.can_also_build:
all_archs.append(mainarch) all_archs.append(mainarch)
for subarch in osc.build.can_also_build.get(mainarch): for subarch in osc_build.can_also_build.get(mainarch):
all_archs.append(subarch) all_archs.append(subarch)
for arg in args: for arg in args:
if (arg.endswith('.spec') or arg.endswith('.dsc') or if (arg.endswith('.spec') or arg.endswith('.dsc') or
@ -6152,10 +6149,10 @@ Please submit there instead, or use --nodevelproject to force direct submission.
'fissile.yml', 'appimage.yml', '_preinstallimage')): 'fissile.yml', 'appimage.yml', '_preinstallimage')):
arg_descr = arg arg_descr = arg
else: else:
if (arg == osc.build.hostarch or arg in all_archs) and arg_arch is None: if (arg == osc_build.hostarch or arg in all_archs) and arg_arch is None:
# it seems to be an architecture in general # it seems to be an architecture in general
arg_arch = arg arg_arch = arg
if not (arg == osc.build.hostarch or arg in osc.build.can_also_build.get(osc.build.hostarch, [])): if not (arg == osc_build.hostarch or arg in osc_build.can_also_build.get(osc_build.hostarch, [])):
if not (vm_type == 'qemu' or vm_type == 'emulator'): if not (vm_type == 'qemu' or vm_type == 'emulator'):
print("WARNING: native compile is not possible, a emulator via binfmt misc handler must be configured!") print("WARNING: native compile is not possible, a emulator via binfmt misc handler must be configured!")
elif not arg_repository: elif not arg_repository:
@ -6168,15 +6165,15 @@ Please submit there instead, or use --nodevelproject to force direct submission.
else: else:
arg_repository, arg_arch, arg_descr = args arg_repository, arg_arch, arg_descr = args
arg_arch = arg_arch or osc.build.hostarch arg_arch = arg_arch or osc_build.hostarch
self._debug("hostarch: ", osc.build.hostarch) self._debug("hostarch: ", osc_build.hostarch)
self._debug("arg_arch: ", arg_arch) self._debug("arg_arch: ", arg_arch)
self._debug("arg_repository: ", arg_repository) self._debug("arg_repository: ", arg_repository)
self._debug("arg_descr: ", arg_descr) self._debug("arg_descr: ", arg_descr)
repositories = [] repositories = []
# store list of repos for potential offline use # store list of repos for potential offline use
repolistfile = os.path.join(os.getcwd(), osc.core.store, "_build_repositories") repolistfile = os.path.join(os.getcwd(), store, "_build_repositories")
if noinit: if noinit:
repositories = Repo.fromfile(repolistfile) repositories = Repo.fromfile(repolistfile)
else: else:
@ -6239,7 +6236,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if noinit: if noinit:
bc_filename = '_buildconfig-%s-%s' % (arg_repository, arg_arch) bc_filename = '_buildconfig-%s-%s' % (arg_repository, arg_arch)
if is_package_dir('.'): if is_package_dir('.'):
bc_filename = os.path.join(os.getcwd(), osc.core.store, bc_filename) bc_filename = os.path.join(os.getcwd(), store, bc_filename)
else: else:
bc_filename = os.path.abspath(bc_filename) bc_filename = os.path.abspath(bc_filename)
if not os.path.isfile(bc_filename): if not os.path.isfile(bc_filename):
@ -6475,9 +6472,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
# OSC_BUILD_ROOT overrides the setting of build-root. # OSC_BUILD_ROOT overrides the setting of build-root.
# OSC_PACKAGECACHEDIR overrides the setting of packagecachedir. # OSC_PACKAGECACHEDIR overrides the setting of packagecachedir.
""" """
import osc.build
if which(conf.config['build-cmd']) is None: if which(conf.config['build-cmd']) is None:
print('Error: build (\'%s\') command not found' % conf.config['build-cmd'], file=sys.stderr) print('Error: build (\'%s\') command not found' % conf.config['build-cmd'], file=sys.stderr)
print('Install the build package from http://download.opensuse.org/repositories/openSUSE:/Tools/', file=sys.stderr) print('Install the build package from http://download.opensuse.org/repositories/openSUSE:/Tools/', file=sys.stderr)
@ -6519,9 +6513,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
else: else:
args = self.parse_repoarchdescr(args, opts.noinit or opts.offline, opts.alternative_project, False, opts.vm_type, opts.multibuild_package) args = self.parse_repoarchdescr(args, opts.noinit or opts.offline, opts.alternative_project, False, opts.vm_type, opts.multibuild_package)
repo, arch, build_descr = args repo, arch, build_descr = args
prj, pac = osc.build.calculate_prj_pac(opts, build_descr) prj, pac = osc_build.calculate_prj_pac(opts, build_descr)
apihost = urlsplit(self.get_api_url())[1] apihost = urlsplit(self.get_api_url())[1]
build_root = osc.build.calculate_build_root(apihost, prj, pac, repo, build_root = osc_build.calculate_build_root(apihost, prj, pac, repo,
arch) arch)
if opts.wipe and not opts.force: if opts.wipe and not opts.force:
# Confirm delete # Confirm delete
@ -6533,7 +6527,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
build_args = ['--root=' + build_root, '--noinit', '--shell'] build_args = ['--root=' + build_root, '--noinit', '--shell']
if opts.wipe: if opts.wipe:
build_args.append('--wipe') build_args.append('--wipe')
sys.exit(osc.build.run_build(opts, *build_args)) sys.exit(osc_build.run_build(opts, *build_args))
elif subcmd in ('shell', 'chroot') or opts.shell: elif subcmd in ('shell', 'chroot') or opts.shell:
print('--shell in combination with build-type %s is experimental.' % vm_chroot) print('--shell in combination with build-type %s is experimental.' % vm_chroot)
print('The semantics may change at any time!') print('The semantics may change at any time!')
@ -6577,7 +6571,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
print('Building %s for %s/%s' % (args[2], args[0], args[1])) print('Building %s for %s/%s' % (args[2], args[0], args[1]))
if not opts.host: if not opts.host:
return osc.build.main(self.get_api_url(), opts, args) return osc_build.main(self.get_api_url(), opts, args)
else: else:
return self._do_rbuild(subcmd, opts, *args) return self._do_rbuild(subcmd, opts, *args)
@ -7902,9 +7896,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
SRPM is the path of the src.rpm in the local filesystem, SRPM is the path of the src.rpm in the local filesystem,
or an URL. or an URL.
""" """
import glob
from .util import rpmquery
if opts.delete_old_files and conf.config['do_package_tracking']: if opts.delete_old_files and conf.config['do_package_tracking']:
# IMHO the --delete-old-files option doesn't really fit into our # IMHO the --delete-old-files option doesn't really fit into our
# package tracking strategy # package tracking strategy
@ -7917,7 +7908,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
print('%s is not a valid link. It must not end with /' % srpm) print('%s is not a valid link. It must not end with /' % srpm)
sys.exit(1) sys.exit(1)
print('trying to fetch', srpm) print('trying to fetch', srpm)
from .grabber import OscFileGrabber
OscFileGrabber().urlgrab(srpm) OscFileGrabber().urlgrab(srpm)
srpm = os.path.basename(srpm) srpm = os.path.basename(srpm)
@ -8922,8 +8912,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
or can be specified via mailaddr environment variable. or can be specified via mailaddr environment variable.
""" """
from subprocess import Popen
if opts.message and opts.file: if opts.message and opts.file:
raise oscerr.WrongOptions('\'--message\' and \'--file\' are mutually exclusive') raise oscerr.WrongOptions('\'--message\' and \'--file\' are mutually exclusive')
elif opts.message and opts.just_edit: elif opts.message and opts.just_edit:
@ -8932,7 +8920,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
raise oscerr.WrongOptions('\'--file\' and \'--just-edit\' are mutually exclusive') raise oscerr.WrongOptions('\'--file\' and \'--just-edit\' are mutually exclusive')
meego_style = False meego_style = False
if not args: if not args:
import glob, re
try: try:
fn_changelog = glob.glob('*.changes')[0] fn_changelog = glob.glob('*.changes')[0]
fp = open(fn_changelog) fp = open(fn_changelog)
@ -8982,7 +8969,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
cmd_list.extend(args) cmd_list.extend(args)
vc_export_env(apiurl) vc_export_env(apiurl)
vc = Popen(cmd_list) vc = subprocess.Popen(cmd_list)
vc.wait() vc.wait()
sys.exit(vc.returncode) sys.exit(vc.returncode)
@ -9088,7 +9075,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
raise oscerr.WrongArgs('error: read empty value from stdin') raise oscerr.WrongArgs('error: read empty value from stdin')
elif opts.no_echo or opts.prompt: elif opts.no_echo or opts.prompt:
if opts.no_echo: if opts.no_echo:
import getpass
inp = getpass.getpass(prompt_value).strip() inp = getpass.getpass(prompt_value).strip()
else: else:
inp = raw_input(prompt_value).strip() inp = raw_input(prompt_value).strip()
@ -9330,7 +9316,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if os.environ.get('OSC_PLUGIN_FAIL_IGNORE'): if os.environ.get('OSC_PLUGIN_FAIL_IGNORE'):
print("%s: %s\n" % (os.path.join(plugin_dir, extfile), e), file=sys.stderr) print("%s: %s\n" % (os.path.join(plugin_dir, extfile), e), file=sys.stderr)
else: else:
import traceback
traceback.print_exc(file=sys.stderr) traceback.print_exc(file=sys.stderr)
print('\n%s: %s' % (os.path.join(plugin_dir, extfile), e), file=sys.stderr) print('\n%s: %s' % (os.path.join(plugin_dir, extfile), e), file=sys.stderr)
print("\n Try 'env OSC_PLUGIN_FAIL_IGNORE=1 osc ...'", file=sys.stderr) print("\n Try 'env OSC_PLUGIN_FAIL_IGNORE=1 osc ...'", file=sys.stderr)

View File

@ -36,7 +36,6 @@ The configuration dictionary could look like this:
""" """
import bz2
import errno import errno
import getpass import getpass
import os import os

View File

@ -97,9 +97,6 @@ def get_proxy_manager(env):
else: else:
proxy_url = f"{proxy_purl.scheme}://{proxy_purl.host}" proxy_url = f"{proxy_purl.scheme}://{proxy_purl.host}"
# import osc.core here to avoid cyclic imports
from . import core
proxy_headers = urllib3.make_headers( proxy_headers = urllib3.make_headers(
proxy_basic_auth=proxy_purl.auth, proxy_basic_auth=proxy_purl.auth,
user_agent=f"osc/{__version__}", user_agent=f"osc/{__version__}",
@ -167,9 +164,6 @@ def http_request(method, url, headers=None, data=None, file=None):
:param file: Path to a file to send as data in the request body (conflicts with `data`). :param file: Path to a file to send as data in the request body (conflicts with `data`).
""" """
# import osc.core here to avoid cyclic imports
from . import core
purl = urllib3.util.parse_url(url) purl = urllib3.util.parse_url(url)
apiurl = conf.extract_known_apiurl(url) apiurl = conf.extract_known_apiurl(url)
headers = urllib3.response.HTTPHeaderDict(headers or {}) headers = urllib3.response.HTTPHeaderDict(headers or {})

View File

@ -10,7 +10,12 @@
__store_version__ = '1.0' __store_version__ = '1.0'
import codecs
import datetime
import difflib
import errno import errno
import fnmatch
import glob
import hashlib import hashlib
import locale import locale
import os import os
@ -20,6 +25,8 @@ import shlex
import shutil import shutil
import subprocess import subprocess
import sys import sys
import tempfile
import textwrap
import time import time
from functools import cmp_to_key from functools import cmp_to_key
from http.client import IncompleteRead from http.client import IncompleteRead
@ -36,6 +43,7 @@ except ImportError:
from . import __version__ from . import __version__
from . import conf from . import conf
from . import meter
from . import oscerr from . import oscerr
from .connection import http_request, http_GET, http_POST, http_PUT, http_DELETE from .connection import http_request, http_GET, http_POST, http_PUT, http_DELETE
from .util.helper import decode_list, decode_it, raw_input, _html_escape from .util.helper import decode_list, decode_it, raw_input, _html_escape
@ -315,8 +323,6 @@ class Serviceinfo:
raise e raise e
def addVerifyFile(self, serviceinfo_node, filename): def addVerifyFile(self, serviceinfo_node, filename):
import hashlib
f = open(filename, 'rb') f = open(filename, 'rb')
digest = hashlib.sha256(f.read()).hexdigest() digest = hashlib.sha256(f.read()).hexdigest()
f.close() f.close()
@ -396,8 +402,6 @@ class Serviceinfo:
def _execute(self, dir, old_dir, callmode=None, singleservice=None, def _execute(self, dir, old_dir, callmode=None, singleservice=None,
verbose=None): verbose=None):
import tempfile
# cleanup existing generated files # cleanup existing generated files
for filename in os.listdir(dir): for filename in os.listdir(dir):
if filename.startswith('_service:') or filename.startswith('_service_'): if filename.startswith('_service:') or filename.startswith('_service_'):
@ -651,7 +655,6 @@ class Project:
`wc_check` : bool `wc_check` : bool
""" """
import fnmatch
self.dir = dir self.dir = dir
self.absdir = os.path.abspath(dir) self.absdir = os.path.abspath(dir)
self.progress_obj = progress_obj self.progress_obj = progress_obj
@ -839,7 +842,6 @@ class Project:
store_write_string(self.absdir, '_packages', ET.tostring(self.pac_root, encoding=ET_ENCODING)) store_write_string(self.absdir, '_packages', ET.tostring(self.pac_root, encoding=ET_ENCODING))
def addPackage(self, pac): def addPackage(self, pac):
import fnmatch
for i in conf.config['exclude_glob']: for i in conf.config['exclude_glob']:
if fnmatch.fnmatch(pac, i): if fnmatch.fnmatch(pac, i):
msg = 'invalid package name: \'%s\' (see \'exclude_glob\' config option)' % pac msg = 'invalid package name: \'%s\' (see \'exclude_glob\' config option)' % pac
@ -1759,7 +1761,6 @@ class Package:
file has changed (e.g. update_local_filesmeta() has been file has changed (e.g. update_local_filesmeta() has been
called). called).
""" """
import fnmatch
if self.scm_url: if self.scm_url:
self.filenamelist = [] self.filenamelist = []
self.filelist = [] self.filelist = []
@ -1984,7 +1985,6 @@ class Package:
return state return state
def get_diff(self, revision=None, ignoreUnversioned=False): def get_diff(self, revision=None, ignoreUnversioned=False):
import tempfile
diff_hdr = b'Index: %s\n' diff_hdr = b'Index: %s\n'
diff_hdr += b'===================================================================\n' diff_hdr += b'===================================================================\n'
kept = [] kept = []
@ -2127,7 +2127,6 @@ rev: %s
def read_meta_from_spec(self, spec = None): def read_meta_from_spec(self, spec = None):
import glob
if spec: if spec:
specfile = spec specfile = spec
else: else:
@ -2303,7 +2302,6 @@ rev: %s
return sinfo.get('srcmd5') != self.srcmd5 return sinfo.get('srcmd5') != self.srcmd5
def update(self, rev = None, service_files = False, size_limit = None): def update(self, rev = None, service_files = False, size_limit = None):
import tempfile
rfiles = [] rfiles = []
# size_limit is only temporary for this update # size_limit is only temporary for this update
old_size_limit = self.size_limit old_size_limit = self.size_limit
@ -2893,8 +2891,6 @@ class Request:
def accept_at_in_hours(self, hours): def accept_at_in_hours(self, hours):
"""set auto accept_at time""" """set auto accept_at time"""
import datetime
now = datetime.datetime.utcnow() now = datetime.datetime.utcnow()
now = now + datetime.timedelta(hours=hours) now = now + datetime.timedelta(hours=hours)
self.accept_at = now.isoformat() + '+00:00' self.accept_at = now.isoformat() + '+00:00'
@ -3005,7 +3001,6 @@ class Request:
def list_view(self): def list_view(self):
"""return "list view" format""" """return "list view" format"""
import textwrap
status = self.state.name status = self.state.name
if self.state.name == 'review' and self.state.approver: if self.state.name == 'review' and self.state.approver:
status += "(approved)" status += "(approved)"
@ -3103,8 +3098,6 @@ def shorttime(t):
or Apr 02 2005 or Apr 02 2005
depending on whether it is in the current year depending on whether it is in the current year
""" """
import time
if time.gmtime()[0] == time.gmtime(t)[0]: if time.gmtime()[0] == time.gmtime(t)[0]:
# same year # same year
return time.strftime('%b %d %H:%M', time.gmtime(t)) return time.strftime('%b %d %H:%M', time.gmtime(t))
@ -3647,8 +3640,6 @@ class metafile:
return self._delegate(**kwargs) return self._delegate(**kwargs)
def __init__(self, url, input, change_is_required=False, file_ext='.xml'): def __init__(self, url, input, change_is_required=False, file_ext='.xml'):
import tempfile
if isinstance(url, self._URLFactory): if isinstance(url, self._URLFactory):
self._url_factory = url self._url_factory = url
else: else:
@ -3976,7 +3967,6 @@ def show_upstream_rev(apiurl, prj, pac, revision=None, expand=False, linkrev=Non
def read_meta_from_spec(specfile, *args): def read_meta_from_spec(specfile, *args):
import codecs, re
""" """
Read tags and sections from spec file. To read out Read tags and sections from spec file. To read out
a tag the passed argument mustn't end with a colon. To a tag the passed argument mustn't end with a colon. To
@ -4053,8 +4043,6 @@ def get_default_pager():
return 'more' return 'more'
def run_pager(message, tmp_suffix=''): def run_pager(message, tmp_suffix=''):
import tempfile, sys
if not message: if not message:
return return
@ -4091,8 +4079,6 @@ def _editor_command():
return cmd return cmd
def _edit_message_open_editor(filename, data, orig_mtime): def _edit_message_open_editor(filename, data, orig_mtime):
# FIXME: import modules globally
import tempfile
editor = _editor_command() editor = _editor_command()
mtime = os.stat(filename).st_mtime mtime = os.stat(filename).st_mtime
if isinstance(data, str): if isinstance(data, str):
@ -4127,7 +4113,6 @@ def edit_message(footer='', template='', templatelen=30):
return edit_text(data, delim, suffix='.diff', template=template) return edit_text(data, delim, suffix='.diff', template=template)
def edit_text(data='', delim=None, suffix='.txt', template=''): def edit_text(data='', delim=None, suffix='.txt', template=''):
import tempfile
try: try:
(fd, filename) = tempfile.mkstemp(prefix='osc-editor', suffix=suffix) (fd, filename) = tempfile.mkstemp(prefix='osc-editor', suffix=suffix)
os.close(fd) os.close(fd)
@ -4639,7 +4624,6 @@ def get_group_data(apiurl, group, *tags):
def download(url, filename, progress_obj = None, mtime = None): def download(url, filename, progress_obj = None, mtime = None):
import tempfile, shutil
global BUFSIZE global BUFSIZE
o = None o = None
@ -4685,8 +4669,7 @@ def get_binary_file(apiurl, prj, repo, arch,
progress_meter = False): progress_meter = False):
progress_obj = None progress_obj = None
if progress_meter: if progress_meter:
from .meter import create_text_meter progress_obj = meter.create_text_meter()
progress_obj = create_text_meter()
target_filename = target_filename or filename target_filename = target_filename or filename
@ -4711,14 +4694,7 @@ def dgst(file):
#return None #return None
global BUFSIZE global BUFSIZE
s = hashlib.md5()
try:
import hashlib
md5 = hashlib
except ImportError:
import md5
md5 = md5
s = md5.md5()
f = open(file, 'rb') f = open(file, 'rb')
while True: while True:
buf = f.read(BUFSIZE) buf = f.read(BUFSIZE)
@ -4760,9 +4736,6 @@ def get_source_file_diff(dir, filename, rev, oldfilename = None, olddir = None,
The variable origfilename is used if filename and oldfilename differ The variable origfilename is used if filename and oldfilename differ
in their names (for instance if a tempfile is used for filename etc.) in their names (for instance if a tempfile is used for filename etc.)
""" """
import difflib
global store global store
if not oldfilename: if not oldfilename:
@ -5523,7 +5496,6 @@ def copy_pac(src_apiurl, src_project, src_package,
else: else:
# copy one file after the other # copy one file after the other
import tempfile
query = {'rev': 'upload'} query = {'rev': 'upload'}
xml = show_files_meta(src_apiurl, src_project, src_package, xml = show_files_meta(src_apiurl, src_project, src_package,
expand=expand, revision=revision) expand=expand, revision=revision)
@ -6187,7 +6159,6 @@ def print_buildlog(apiurl, prj, package, repository, arch, offset=0, strip_time=
sys.stdout.write(decode_it(data.translate(all_bytes, remove_bytes))) sys.stdout.write(decode_it(data.translate(all_bytes, remove_bytes)))
# to protect us against control characters # to protect us against control characters
import string
all_bytes = bytes.maketrans(b'', b'') all_bytes = bytes.maketrans(b'', b'')
remove_bytes = all_bytes[:8] + all_bytes[14:32] # accept tabs and newlines remove_bytes = all_bytes[:8] + all_bytes[14:32] # accept tabs and newlines
@ -6306,7 +6277,6 @@ def get_source_rev(apiurl, project, package, revision=None):
return e return e
def get_buildhistory(apiurl, prj, package, repository, arch, format = 'text', limit = None): def get_buildhistory(apiurl, prj, package, repository, arch, format = 'text', limit = None):
import time
query = {} query = {}
if limit is not None and int(limit) > 0: if limit is not None and int(limit) > 0:
query['limit'] = int(limit) query['limit'] = int(limit)
@ -6338,7 +6308,6 @@ def get_buildhistory(apiurl, prj, package, repository, arch, format = 'text', li
return r return r
def print_jobhistory(apiurl, prj, current_package, repository, arch, format = 'text', limit=20): def print_jobhistory(apiurl, prj, current_package, repository, arch, format = 'text', limit=20):
import time
query = {} query = {}
if current_package: if current_package:
query['package'] = current_package query['package'] = current_package
@ -6375,8 +6344,6 @@ def print_jobhistory(apiurl, prj, current_package, repository, arch, format = 't
def get_commitlog(apiurl, prj, package, revision, format = 'text', meta = False, deleted = False, revision_upper=None): def get_commitlog(apiurl, prj, package, revision, format = 'text', meta = False, deleted = False, revision_upper=None):
import time
query = {} query = {}
if deleted: if deleted:
query['deleted'] = 1 query['deleted'] = 1
@ -7443,8 +7410,6 @@ def print_request_list(apiurl, project, package = None, states = ('new', 'review
def request_interactive_review(apiurl, request, initial_cmd='', group=None, def request_interactive_review(apiurl, request, initial_cmd='', group=None,
ignore_reviews=False, source_buildstatus=False): ignore_reviews=False, source_buildstatus=False):
"""review the request interactively""" """review the request interactively"""
import tempfile, re
tmpfile = None tmpfile = None
def safe_change_request_state(*args, **kwargs): def safe_change_request_state(*args, **kwargs):
@ -7688,7 +7653,6 @@ def request_interactive_review(apiurl, request, initial_cmd='', group=None,
def edit_submitrequest(apiurl, project, orequest, new_request=None): def edit_submitrequest(apiurl, project, orequest, new_request=None):
"""edit a submit action from orequest/new_request""" """edit a submit action from orequest/new_request"""
import tempfile, shutil
actions = orequest.get_actions('submit') actions = orequest.get_actions('submit')
oactions = actions oactions = actions
if new_request is not None: if new_request is not None:
@ -8088,7 +8052,6 @@ class MultibuildFlavorResolver:
break break
if use_globs: if use_globs:
import fnmatch
multibuild_xml = self.get_multibuild_data() multibuild_xml = self.get_multibuild_data()
all_flavors = self.parse_multibuild_data(multibuild_xml) all_flavors = self.parse_multibuild_data(multibuild_xml)
flavors = set() flavors = set()

View File

@ -6,14 +6,17 @@
import os import os
import re import re
import shutil
import subprocess
import sys import sys
import tempfile import tempfile
from urllib.parse import quote_plus from urllib.parse import quote_plus
from urllib.request import HTTPError from urllib.request import HTTPError
from . import checker as osc_checker
from . import conf from . import conf
from . import oscerr from . import oscerr
from .core import makeurl, streamfile, dgst from .core import makeurl, dgst
from .grabber import OscFileGrabber, OscMirrorGroup from .grabber import OscFileGrabber, OscMirrorGroup
from .meter import create_text_meter from .meter import create_text_meter
from .util import packagequery, cpio from .util import packagequery, cpio
@ -155,7 +158,6 @@ class Fetcher:
os.unlink(tmpfile.name) os.unlink(tmpfile.name)
def move_package(self, tmpfile, destdir, pac_obj=None): def move_package(self, tmpfile, destdir, pac_obj=None):
import shutil
canonname = None canonname = None
if pac_obj and pac_obj.name.startswith('container:'): if pac_obj and pac_obj.name.startswith('container:'):
canonname = pac_obj.canonname canonname = pac_obj.canonname
@ -324,8 +326,6 @@ def verify_pacs_old(pac_list):
Check all packages in one go, since this takes only 6 seconds on my Athlon 700 Check all packages in one go, since this takes only 6 seconds on my Athlon 700
instead of 20 when calling 'rpm -K' for each of them. instead of 20 when calling 'rpm -K' for each of them.
""" """
import subprocess
if not pac_list: if not pac_list:
return return
@ -403,9 +403,8 @@ def verify_pacs(bi):
print("using keys from", ', '.join(bi.prjkeys)) print("using keys from", ', '.join(bi.prjkeys))
from . import checker
failed = False failed = False
checker = checker.Checker() checker = osc_checker.Checker()
try: try:
checker.readkeys(bi.keys) checker.readkeys(bi.keys)
for pkg in pac_list: for pkg in pac_list:

View File

@ -5,7 +5,6 @@
import os import os
import sys
from urllib.request import HTTPError from urllib.request import HTTPError
from urllib.parse import urlparse from urllib.parse import urlparse
from urllib.parse import unquote from urllib.parse import unquote

View File

@ -1,14 +1,10 @@
import binascii import binascii
import datetime
import errno
import os import os
import socket import socket
import ssl import ssl
import sys
import tempfile import tempfile
import typing import typing
import urllib3.connection
from cryptography import x509 from cryptography import x509
from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives import serialization

View File

@ -1,7 +1,7 @@
import os import os
import re import re
import subprocess import subprocess
import tarfile import sys
from . import packagequery from . import packagequery
@ -207,7 +207,6 @@ class ArchQuery(packagequery.PackageQuery, packagequery.PackageQueryResult):
if __name__ == '__main__': if __name__ == '__main__':
import sys
archq = ArchQuery.query(sys.argv[1]) archq = ArchQuery.query(sys.argv[1])
print(archq.name(), archq.version(), archq.release(), archq.arch()) print(archq.name(), archq.version(), archq.release(), archq.arch())
try: try:

View File

@ -14,7 +14,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
import mmap
import os import os
import stat import stat
import struct import struct

View File

@ -1,6 +1,7 @@
import itertools import itertools
import os import os
import re import re
import sys
import tarfile import tarfile
from io import BytesIO from io import BytesIO
@ -249,7 +250,6 @@ class DebQuery(packagequery.PackageQuery, packagequery.PackageQueryResult):
return b'%s_%s_%s.deb' % (name, version, arch) return b'%s_%s_%s.deb' % (name, version, arch)
if __name__ == '__main__': if __name__ == '__main__':
import sys
try: try:
debq = DebQuery.query(sys.argv[1]) debq = DebQuery.query(sys.argv[1])
except DebError as e: except DebError as e:

View File

@ -4,6 +4,7 @@
# either version 2, or (at your option) any later version. # either version 2, or (at your option) any later version.
import builtins
import html import html
from .. import oscerr from .. import oscerr
@ -39,7 +40,6 @@ def decode_it(obj):
def raw_input(*args): def raw_input(*args):
import builtins
func = builtins.input func = builtins.input
try: try:

View File

@ -1,3 +1,5 @@
import sys
from .helper import decode_it from .helper import decode_it
@ -166,7 +168,6 @@ def cmp(a, b):
if __name__ == '__main__': if __name__ == '__main__':
import sys
try: try:
pkgq = PackageQuery.query(sys.argv[1]) pkgq = PackageQuery.query(sys.argv[1])
except PackageError as e: except PackageError as e:

View File

@ -1,6 +1,7 @@
import os import os
import re import re
import struct import struct
import sys
from . import packagequery from . import packagequery
from .helper import decode_it from .helper import decode_it
@ -385,7 +386,6 @@ def unpack_string(data, encoding=None):
return data return data
if __name__ == '__main__': if __name__ == '__main__':
import sys
try: try:
rpmq = RpmQuery.query(sys.argv[1]) rpmq = RpmQuery.query(sys.argv[1])
except RpmError as e: except RpmError as e:

View File

@ -1,5 +1,6 @@
import os import os
import sys import sys
import unittest
import osc.core import osc.core
import osc.oscerr import osc.oscerr
@ -10,7 +11,6 @@ from .common import OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'addfile_fixtures') FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'addfile_fixtures')
def suite(): def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestAddFiles) return unittest.defaultTestLoader.loadTestsFromTestCase(TestAddFiles)
class TestAddFiles(OscTestCase): class TestAddFiles(OscTestCase):
@ -84,5 +84,4 @@ class TestAddFiles(OscTestCase):
self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_added'))) self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_added')))
if __name__ == '__main__': if __name__ == '__main__':
import unittest
unittest.main() unittest.main()

View File

@ -1,5 +1,6 @@
import os import os
import sys import sys
import unittest
from urllib.error import HTTPError from urllib.error import HTTPError
from xml.etree import ElementTree as ET from xml.etree import ElementTree as ET
@ -12,7 +13,6 @@ from .common import GET, PUT, POST, DELETE, OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'commit_fixtures') FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'commit_fixtures')
def suite(): def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestCommit) return unittest.defaultTestLoader.loadTestsFromTestCase(TestCommit)
rev_dummy = '<revision rev="repository">\n <srcmd5>empty</srcmd5>\n</revision>' rev_dummy = '<revision rev="repository">\n <srcmd5>empty</srcmd5>\n</revision>'
@ -369,5 +369,4 @@ class TestCommit(OscTestCase):
self._check_status(p, 'bar', ' ') self._check_status(p, 'bar', ' ')
if __name__ == '__main__': if __name__ == '__main__':
import unittest
unittest.main() unittest.main()

View File

@ -48,5 +48,4 @@ class TestParseRevisionOption(unittest.TestCase):
if __name__ == "__main__": if __name__ == "__main__":
import unittest
unittest.main() unittest.main()

View File

@ -1,4 +1,5 @@
import os import os
import unittest
import osc.core import osc.core
import osc.oscerr import osc.oscerr
@ -9,7 +10,6 @@ from .common import OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'deletefile_fixtures') FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'deletefile_fixtures')
def suite(): def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestDeleteFiles) return unittest.defaultTestLoader.loadTestsFromTestCase(TestDeleteFiles)
class TestDeleteFiles(OscTestCase): class TestDeleteFiles(OscTestCase):
@ -206,5 +206,4 @@ class TestDeleteFiles(OscTestCase):
self.assertTrue(ret[1] == exp2) self.assertTrue(ret[1] == exp2)
if __name__ == '__main__': if __name__ == '__main__':
import unittest
unittest.main() unittest.main()

View File

@ -1,5 +1,6 @@
import os import os
import re import re
import unittest
import osc.core import osc.core
import osc.oscerr import osc.oscerr
@ -11,7 +12,6 @@ from .common import GET, OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'difffile_fixtures') FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'difffile_fixtures')
def suite(): def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestDiffFiles) return unittest.defaultTestLoader.loadTestsFromTestCase(TestDiffFiles)
class TestDiffFiles(OscTestCase): class TestDiffFiles(OscTestCase):
@ -336,5 +336,4 @@ Binary file 'binary' has changed.
self.assertEqualMultiline(got, exp) self.assertEqualMultiline(got, exp)
if __name__ == '__main__': if __name__ == '__main__':
import unittest
unittest.main() unittest.main()

View File

@ -1,4 +1,5 @@
import os import os
import unittest
import osc.core import osc.core
import osc.oscerr import osc.oscerr
@ -9,7 +10,6 @@ from .common import OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'init_package_fixtures') FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'init_package_fixtures')
def suite(): def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestInitPackage) return unittest.defaultTestLoader.loadTestsFromTestCase(TestInitPackage)
class TestInitPackage(OscTestCase): class TestInitPackage(OscTestCase):
@ -89,5 +89,4 @@ class TestInitPackage(OscTestCase):
self.assertRaises(osc.oscerr.OscIOError, osc.core.Package.init_package, 'http://localhost', 'osctest', 'testpkg', pac_dir) self.assertRaises(osc.oscerr.OscIOError, osc.core.Package.init_package, 'http://localhost', 'osctest', 'testpkg', pac_dir)
if __name__ == '__main__': if __name__ == '__main__':
import unittest
unittest.main() unittest.main()

View File

@ -1,5 +1,7 @@
import os import os
import unittest
import osc.conf
import osc.core import osc.core
import osc.oscerr import osc.oscerr
@ -9,7 +11,6 @@ from .common import GET, OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'init_project_fixtures') FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'init_project_fixtures')
def suite(): def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestInitProject) return unittest.defaultTestLoader.loadTestsFromTestCase(TestInitProject)
class TestInitProject(OscTestCase): class TestInitProject(OscTestCase):
@ -58,7 +59,6 @@ class TestInitProject(OscTestCase):
disable wc_check (because we didn't disable the package tracking before the Project class disable wc_check (because we didn't disable the package tracking before the Project class
was imported therefore REQ_STOREFILES contains '_packages') was imported therefore REQ_STOREFILES contains '_packages')
""" """
import osc.conf
# disable package tracking # disable package tracking
osc.conf.config['do_package_tracking'] = False osc.conf.config['do_package_tracking'] = False
prj_dir = os.path.join(self.tmpdir, 'testprj') prj_dir = os.path.join(self.tmpdir, 'testprj')
@ -71,5 +71,4 @@ class TestInitProject(OscTestCase):
self.assertFalse(os.path.exists(os.path.join(storedir, '_packages'))) self.assertFalse(os.path.exists(os.path.join(storedir, '_packages')))
if __name__ == '__main__': if __name__ == '__main__':
import unittest
unittest.main() unittest.main()

View File

@ -1,4 +1,5 @@
import os import os
import unittest
import osc.core import osc.core
import osc.oscerr import osc.oscerr
@ -9,7 +10,6 @@ from .common import OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'project_package_status_fixtures') FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'project_package_status_fixtures')
def suite(): def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestPackageStatus) return unittest.defaultTestLoader.loadTestsFromTestCase(TestPackageStatus)
class TestPackageStatus(OscTestCase): class TestPackageStatus(OscTestCase):
@ -85,5 +85,4 @@ class TestPackageStatus(OscTestCase):
self.assertEqual(exp_st, st) self.assertEqual(exp_st, st)
if __name__ == '__main__': if __name__ == '__main__':
import unittest
unittest.main() unittest.main()

View File

@ -1,6 +1,7 @@
import os import os
import re import re
import sys import sys
import unittest
import osc.commandline import osc.commandline
import osc.core import osc.core
@ -42,7 +43,6 @@ def POST_RDIFF(oldprj, newprj):
def suite(): def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestProjectDiff) return unittest.defaultTestLoader.loadTestsFromTestCase(TestProjectDiff)
class TestProjectDiff(OscTestCase): class TestProjectDiff(OscTestCase):
@ -262,5 +262,4 @@ identical: only-in-new
if __name__ == '__main__': if __name__ == '__main__':
import unittest
unittest.main() unittest.main()

View File

@ -1,4 +1,5 @@
import os import os
import unittest
import osc.core import osc.core
import osc.oscerr import osc.oscerr
@ -9,7 +10,6 @@ from .common import OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'project_package_status_fixtures') FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'project_package_status_fixtures')
def suite(): def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestProjectStatus) return unittest.defaultTestLoader.loadTestsFromTestCase(TestProjectStatus)
class TestProjectStatus(OscTestCase): class TestProjectStatus(OscTestCase):
@ -160,5 +160,4 @@ class TestProjectStatus(OscTestCase):
self.assertTrue(isinstance(p, type(None))) self.assertTrue(isinstance(p, type(None)))
if __name__ == '__main__': if __name__ == '__main__':
import unittest
unittest.main() unittest.main()

View File

@ -1,5 +1,7 @@
import os import os
import shutil
import sys import sys
import unittest
from xml.etree import ElementTree as ET from xml.etree import ElementTree as ET
import osc.core import osc.core
@ -11,7 +13,6 @@ from .common import GET, PUT, POST, DELETE, OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'repairwc_fixtures') FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'repairwc_fixtures')
def suite(): def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestRepairWC) return unittest.defaultTestLoader.loadTestsFromTestCase(TestRepairWC)
class TestRepairWC(OscTestCase): class TestRepairWC(OscTestCase):
@ -214,7 +215,6 @@ class TestRepairWC(OscTestCase):
def test_project_noapiurl(self): def test_project_noapiurl(self):
"""the project wc has no _apiurl file""" """the project wc has no _apiurl file"""
import shutil
prj_dir = os.path.join(self.tmpdir, 'prj_noapiurl') prj_dir = os.path.join(self.tmpdir, 'prj_noapiurl')
shutil.copytree(os.path.join(self._get_fixtures_dir(), 'prj_noapiurl'), prj_dir) shutil.copytree(os.path.join(self._get_fixtures_dir(), 'prj_noapiurl'), prj_dir)
storedir = os.path.join(prj_dir, osc.core.store) storedir = os.path.join(prj_dir, osc.core.store)
@ -227,5 +227,4 @@ class TestRepairWC(OscTestCase):
if __name__ == '__main__': if __name__ == '__main__':
import unittest
unittest.main() unittest.main()

View File

@ -1,4 +1,5 @@
import os import os
import unittest
from xml.etree import ElementTree as ET from xml.etree import ElementTree as ET
import osc.core import osc.core
@ -10,7 +11,6 @@ from .common import OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'request_fixtures') FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'request_fixtures')
def suite(): def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestRequest) return unittest.defaultTestLoader.loadTestsFromTestCase(TestRequest)
class TestRequest(OscTestCase): class TestRequest(OscTestCase):
@ -566,5 +566,4 @@ Comment: <no comment>"""
self.assertTrue(len(r.get_actions()) == 8) self.assertTrue(len(r.get_actions()) == 8)
if __name__ == '__main__': if __name__ == '__main__':
import unittest
unittest.main() unittest.main()

View File

@ -1,5 +1,6 @@
import os import os
import sys import sys
import unittest
import osc.commandline import osc.commandline
@ -7,7 +8,6 @@ from .common import GET, OscTestCase
def suite(): def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestResults) return unittest.defaultTestLoader.loadTestsFromTestCase(TestResults)
class TestResults(OscTestCase): class TestResults(OscTestCase):
@ -51,6 +51,5 @@ class TestResults(OscTestCase):
self.assertEqualMultiline(out, self._get_fixture('result-dirty.xml')+self._get_fixture('result.xml')) self.assertEqualMultiline(out, self._get_fixture('result-dirty.xml')+self._get_fixture('result.xml'))
if __name__ == '__main__': if __name__ == '__main__':
import unittest
unittest.main() unittest.main()

View File

@ -1,4 +1,5 @@
import os import os
import unittest
import osc.core import osc.core
import osc.oscerr import osc.oscerr
@ -9,7 +10,6 @@ from .common import OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'revertfile_fixtures') FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'revertfile_fixtures')
def suite(): def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestRevertFiles) return unittest.defaultTestLoader.loadTestsFromTestCase(TestRevertFiles)
class TestRevertFiles(OscTestCase): class TestRevertFiles(OscTestCase):
@ -96,5 +96,4 @@ class TestRevertFiles(OscTestCase):
self.assertFilesEqual(fname, storefile) self.assertFilesEqual(fname, storefile)
if __name__ == '__main__': if __name__ == '__main__':
import unittest
unittest.main() unittest.main()

View File

@ -1,4 +1,5 @@
import os import os
import unittest
import osc.core import osc.core
import osc.oscerr import osc.oscerr
@ -9,7 +10,6 @@ from .common import GET, PUT, OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'setlinkrev_fixtures') FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'setlinkrev_fixtures')
def suite(): def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestSetLinkRev) return unittest.defaultTestLoader.loadTestsFromTestCase(TestSetLinkRev)
class TestSetLinkRev(OscTestCase): class TestSetLinkRev(OscTestCase):
@ -90,5 +90,4 @@ class TestSetLinkRev(OscTestCase):
osc.core.set_link_rev('http://localhost', 'osctest', 'simple', revision=None) osc.core.set_link_rev('http://localhost', 'osctest', 'simple', revision=None)
if __name__ == '__main__': if __name__ == '__main__':
import unittest
unittest.main() unittest.main()

View File

@ -1,5 +1,6 @@
import os import os
import sys import sys
import unittest
import osc.core import osc.core
import osc.oscerr import osc.oscerr
@ -10,7 +11,6 @@ from .common import GET, OscTestCase
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'update_fixtures') FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'update_fixtures')
def suite(): def suite():
import unittest
return unittest.defaultTestLoader.loadTestsFromTestCase(TestUpdate) return unittest.defaultTestLoader.loadTestsFromTestCase(TestUpdate)
class TestUpdate(OscTestCase): class TestUpdate(OscTestCase):
@ -286,5 +286,4 @@ class TestUpdate(OscTestCase):
self._check_digests('testUpdateResumeDeletedFile_files') self._check_digests('testUpdateResumeDeletedFile_files')
if __name__ == '__main__': if __name__ == '__main__':
import unittest
unittest.main() unittest.main()