diff --git a/osc-cycle.py b/osc-cycle.py index d62a6b86e..751083894 100644 --- a/osc-cycle.py +++ b/osc-cycle.py @@ -1,7 +1,4 @@ -from osc.core import get_dependson -from lxml import etree as ET from osc import cmdln -from urllib.error import HTTPError @cmdln.option('-p', '--project', metavar='PROJECT', dest='project', default='openSUSE:Factory') @@ -15,6 +12,9 @@ def do_cycle(self, subcmd, opts, *args): ${cmd_option_list} """ + from osc.core import get_dependson # pylint: disable=import-outside-toplevel + from lxml import etree as ET # pylint: disable=import-outside-toplevel + from urllib.error import HTTPError # pylint: disable=import-outside-toplevel if len(args) == 0: print("No packages were specified, no chain to draw") diff --git a/osc-origin.py b/osc-origin.py index fe77bce6d..d220869a4 100644 --- a/osc-origin.py +++ b/osc-origin.py @@ -3,33 +3,14 @@ import logging import os import os.path -from osc import cmdln -from osc import core -from osc import oscerr -from osc.core import get_request_list -from osclib.cache import Cache -from osclib.cache_manager import CacheManager -from osclib.core import entity_exists -from osclib.core import package_kind -from osclib.core import package_list -from osclib.core import package_list_kind_filtered -from osclib.core import project_attribute_list -from osclib.core import project_locked -from osclib.origin import config_load -from osclib.origin import config_origin_list -from osclib.origin import origin_find -from osclib.origin import origin_history -from osclib.origin import origin_potentials -from osclib.origin import origin_revision_state -from osclib.origin import origin_updatable -from osclib.origin import origin_updatable_initial -from osclib.origin import origin_update -from osclib.util import mail_send from shutil import copyfile import sys import time import yaml +from osc import cmdln + + OSRT_ORIGIN_LOOKUP_TTL = 60 * 60 * 24 * 7 @@ -69,6 +50,10 @@ def do_origin(self, subcmd, opts, *args): osc origin report [--diff] [--force-refresh] [--mail] osc origin update [--listen] [--listen-seconds] [PACKAGE...] """ + from osclib.cache import Cache # pylint: disable=import-outside-toplevel + from osclib.origin import config_load # pylint: disable=import-outside-toplevel + from osc import core # pylint: disable=import-outside-toplevel + from osc import oscerr # pylint: disable=import-outside-toplevel if len(args) == 0: raise oscerr.WrongArgs('A command must be indicated.') @@ -100,6 +85,9 @@ def do_origin(self, subcmd, opts, *args): def osrt_origin_config(apiurl, opts, *args): + from osclib.origin import config_load # pylint: disable=import-outside-toplevel + from osclib.origin import config_origin_list # pylint: disable=import-outside-toplevel + config = config_load(apiurl, opts.project) if opts.origins_only: @@ -110,6 +98,9 @@ def osrt_origin_config(apiurl, opts, *args): def osrt_origin_cron(apiurl, opts, *args): + from osclib.core import project_attribute_list # pylint: disable=import-outside-toplevel + from osclib.core import project_locked # pylint: disable=import-outside-toplevel + projects = project_attribute_list(apiurl, 'OSRT:OriginConfig') for project in projects: # Preserve cache for locked projects, but create if missing. @@ -139,6 +130,9 @@ def osrt_origin_dump(format, data): def osrt_origin_history(apiurl, opts, *packages): + from osclib.origin import config_load # pylint: disable=import-outside-toplevel + from osclib.origin import origin_history # pylint: disable=import-outside-toplevel + config = config_load(apiurl, opts.project) history = origin_history(apiurl, opts.project, packages[0], config['review-user']) @@ -153,6 +147,8 @@ def osrt_origin_history(apiurl, opts, *packages): def osrt_origin_lookup_file(project, previous=False): + from osclib.cache import CacheManager # pylint: disable=import-outside-toplevel + parts = [project, 'yaml'] if previous: parts.insert(1, 'previous') @@ -162,6 +158,11 @@ def osrt_origin_lookup_file(project, previous=False): def osrt_origin_lookup(apiurl, project, force_refresh=False, previous=False, quiet=False): + from osclib.core import package_list_kind_filtered # pylint: disable=import-outside-toplevel + from osclib.core import project_locked # pylint: disable=import-outside-toplevel + from osclib.origin import origin_find # pylint: disable=import-outside-toplevel + from osclib.origin import origin_revision_state # pylint: disable=import-outside-toplevel + locked = project_locked(apiurl, project) if locked: force_refresh = False @@ -213,6 +214,8 @@ def osrt_origin_max_key(dictionary, minimum): def osrt_origin_list(apiurl, opts, *args): + from osc.core import get_request_list # pylint: disable=import-outside-toplevel + lookup = osrt_origin_lookup(apiurl, opts.project, opts.force_refresh, quiet=opts.format != 'plain') if opts.format != 'plain': @@ -246,11 +249,15 @@ def osrt_origin_list(apiurl, opts, *args): def osrt_origin_package(apiurl, opts, *packages): + from osclib.origin import origin_find # pylint: disable=import-outside-toplevel + origin_info = origin_find(apiurl, opts.project, packages[0]) print(origin_info) def osrt_origin_potentials(apiurl, opts, *packages): + from osclib.origin import origin_potentials # pylint: disable=import-outside-toplevel + potentials = origin_potentials(apiurl, opts.project, packages[0]) if opts.format != 'plain': @@ -269,6 +276,8 @@ def osrt_origin_potentials(apiurl, opts, *packages): def osrt_origin_projects(apiurl, opts, *args): + from osclib.core import project_attribute_list # pylint: disable=import-outside-toplevel + projects = list(project_attribute_list(apiurl, 'OSRT:OriginConfig')) if osrt_origin_dump(opts.format, projects): @@ -308,6 +317,8 @@ def osrt_origin_report_diff(lookup, lookup_previous): def osrt_origin_report(apiurl, opts, *args): + from osclib.util import mail_send # pylint: disable=import-outside-toplevel + lookup = osrt_origin_lookup(apiurl, opts.project, opts.force_refresh) origin_count = osrt_origin_report_count(lookup) @@ -358,6 +369,9 @@ def osrt_origin_report(apiurl, opts, *args): def osrt_origin_update(apiurl, opts, *packages): + from osclib.origin import origin_update # pylint: disable=import-outside-toplevel + from osclib.origin import origin_updatable # pylint: disable=import-outside-toplevel + if not opts.project: for project in origin_updatable(apiurl): opts.project = project @@ -377,6 +391,12 @@ def osrt_origin_update(apiurl, opts, *packages): def osrt_origin_update_packages(apiurl, project): + from osclib.core import entity_exists # pylint: disable=import-outside-toplevel + from osclib.core import package_kind # pylint: disable=import-outside-toplevel + from osclib.core import package_list # pylint: disable=import-outside-toplevel + from osclib.core import package_list_kind_filtered # pylint: disable=import-outside-toplevel + from osclib.origin import origin_updatable_initial # pylint: disable=import-outside-toplevel + packages = set(package_list_kind_filtered(apiurl, project)) # Include packages from origins with initial update enabled to allow for diff --git a/osc-pcheck.py b/osc-pcheck.py index 3a6dbe9cd..006722711 100644 --- a/osc-pcheck.py +++ b/osc-pcheck.py @@ -14,8 +14,8 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + from osc import cmdln -import osc.core @cmdln.option('--push', action='store_true', @@ -32,6 +32,8 @@ def do_pcheck(self, subcmd, opts, project): -m Specify submit message (defaut: "Scripted push of project ") """ + import osc.core # pylint: disable=import-outside-toplevel + apiurl = self.get_api_url() sinfos = osc.core.get_project_sourceinfo(apiurl, project, True) todo = {} @@ -99,6 +101,8 @@ def __init__(self, apiurl): self.apiurl = apiurl def sr_for_package(self, project, package): + import osc.core # pylint: disable=import-outside-toplevel + query = "(state/@name='new' or state/@name='review') and " \ "(action/source/@project='{project}' or submit/source/@project='{project}') and " \ "(action/source/@package='{package}' or submit/source/@package='Packafe')".format(project=project, package=package) @@ -109,6 +113,8 @@ def sr_for_package(self, project, package): return 0 def create(self, project, package, target, message): + import osc.core # pylint: disable=import-outside-toplevel + currev = osc.core.get_source_rev(self.apiurl, project, package)['rev'] print(f"Creating a request from {project}/{package}") query = {'cmd': 'create'} diff --git a/osc-staging.py b/osc-staging.py index e9cab5363..0c9ab6ef4 100644 --- a/osc-staging.py +++ b/osc-staging.py @@ -5,42 +5,14 @@ import warnings import yaml -import colorama -from colorama import Fore -from colorama import ansi - -from osc import cmdln -from osc import conf -from osc import core -from osc import oscerr - -from osclib.accept_command import AcceptCommand -from osclib.adi_command import AdiCommand -from osclib.check_command import CheckCommand -from osclib.check_duplicate_binaries_command import CheckDuplicateBinariesCommand -from osclib.cleanup_rings import CleanupRings -from osclib.conf import Config -from osclib.freeze_command import FreezeCommand -from osclib.ignore_command import IgnoreCommand -from osclib.unignore_command import UnignoreCommand -from osclib.list_command import ListCommand -from osclib.obslock import OBSLock -from osclib.select_command import SelectCommand -from osclib.stagingapi import StagingAPI -from osclib.cache import Cache -from osclib.unselect_command import UnselectCommand -from osclib.repair_command import RepairCommand -from osclib.rebuild_command import RebuildCommand -from osclib.request_splitter import RequestSplitter -from osclib.supersede_command import SupersedeCommand -from osclib.prio_command import PrioCommand - try: import __builtin__ input = getattr(__builtin__, 'raw_input') except (ImportError, AttributeError): pass +from osc import cmdln + def _print_version(self): from osclib.common import VERSION @@ -322,6 +294,35 @@ def do_staging(self, subcmd, opts, *args): osc staging setprio [STAGING...] [priority] osc staging supersede [REQUEST...] """ + import colorama # pylint: disable=import-outside-toplevel + from colorama import Fore # pylint: disable=import-outside-toplevel + from colorama import ansi # pylint: disable=import-outside-toplevel + + from osc import conf # pylint: disable=import-outside-toplevel + from osc import core # pylint: disable=import-outside-toplevel + from osc import oscerr # pylint: disable=import-outside-toplevel + + from osclib.accept_command import AcceptCommand # pylint: disable=import-outside-toplevel + from osclib.adi_command import AdiCommand # pylint: disable=import-outside-toplevel + from osclib.check_command import CheckCommand # pylint: disable=import-outside-toplevel + from osclib.check_duplicate_binaries_command import CheckDuplicateBinariesCommand # pylint: disable=import-outside-toplevel + from osclib.cleanup_rings import CleanupRings # pylint: disable=import-outside-toplevel + from osclib.conf import Config # pylint: disable=import-outside-toplevel + from osclib.freeze_command import FreezeCommand # pylint: disable=import-outside-toplevel + from osclib.ignore_command import IgnoreCommand # pylint: disable=import-outside-toplevel + from osclib.unignore_command import UnignoreCommand # pylint: disable=import-outside-toplevel + from osclib.list_command import ListCommand # pylint: disable=import-outside-toplevel + from osclib.obslock import OBSLock # pylint: disable=import-outside-toplevel + from osclib.select_command import SelectCommand # pylint: disable=import-outside-toplevel + from osclib.stagingapi import StagingAPI # pylint: disable=import-outside-toplevel + from osclib.cache import Cache # pylint: disable=import-outside-toplevel + from osclib.unselect_command import UnselectCommand # pylint: disable=import-outside-toplevel + from osclib.repair_command import RepairCommand # pylint: disable=import-outside-toplevel + from osclib.rebuild_command import RebuildCommand # pylint: disable=import-outside-toplevel + from osclib.request_splitter import RequestSplitter # pylint: disable=import-outside-toplevel + from osclib.supersede_command import SupersedeCommand # pylint: disable=import-outside-toplevel + from osclib.prio_command import PrioCommand # pylint: disable=import-outside-toplevel + if opts.version: self._print_version()