mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-09 22:36:14 +01:00
Clean imports up, drop python 2 fallbacks
This commit is contained in:
parent
e16e196fa1
commit
229913a77f
@ -13,19 +13,9 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info >= ( 3, ):
|
||||
import configparser
|
||||
ConfigParser = configparser.ConfigParser
|
||||
else:
|
||||
#python 2.x
|
||||
import ConfigParser as configparser
|
||||
ConfigParser = configparser.SafeConfigParser
|
||||
|
||||
import re
|
||||
|
||||
# inspired from http://code.google.com/p/iniparse/ - although their implementation is
|
||||
# quite different
|
||||
@ -192,7 +182,7 @@ class OptionLine(Line):
|
||||
self.format(line)
|
||||
|
||||
def format(self, line):
|
||||
mo = ConfigParser.OPTCRE.match(line.strip())
|
||||
mo = configparser.ConfigParser.OPTCRE.match(line.strip())
|
||||
key, val = mo.group('option', 'value')
|
||||
self.frmt = line.replace(key.strip(), '%s', 1)
|
||||
pos = val.find(' ;')
|
||||
@ -205,7 +195,7 @@ class OptionLine(Line):
|
||||
return self.value
|
||||
|
||||
|
||||
class OscConfigParser(ConfigParser):
|
||||
class OscConfigParser(configparser.ConfigParser):
|
||||
"""
|
||||
OscConfigParser() behaves like a normal ConfigParser() object. The
|
||||
only differences is that it preserves the order+format of configuration entries
|
||||
@ -214,7 +204,7 @@ class OscConfigParser(ConfigParser):
|
||||
class.
|
||||
"""
|
||||
def __init__(self, defaults={}):
|
||||
ConfigParser.__init__(self, defaults)
|
||||
super().__init__(defaults)
|
||||
self._sections = ConfigLineOrder()
|
||||
|
||||
# XXX: unfortunately we have to override the _read() method from the ConfigParser()
|
||||
@ -323,7 +313,7 @@ class OscConfigParser(ConfigParser):
|
||||
fp.write(str(self))
|
||||
fp.write('\n')
|
||||
else:
|
||||
ConfigParser.write(self, fp)
|
||||
super().write(fp)
|
||||
|
||||
def has_option(self, section, option, proper=False, **kwargs):
|
||||
"""
|
||||
@ -333,7 +323,7 @@ class OscConfigParser(ConfigParser):
|
||||
"""
|
||||
if proper:
|
||||
return self.optionxform(option) in self._sections[section].keys()
|
||||
return ConfigParser.has_option(self, section, option, **kwargs)
|
||||
return super().has_option(section, option, **kwargs)
|
||||
|
||||
# XXX: simplify!
|
||||
def __str__(self):
|
||||
|
@ -3,23 +3,26 @@
|
||||
# and distributed under the terms of the GNU General Public Licence,
|
||||
# either version 2, or (at your option) any later version.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import errno
|
||||
import os.path
|
||||
import os
|
||||
import pdb
|
||||
import signal
|
||||
import ssl
|
||||
import sys
|
||||
import signal
|
||||
import traceback
|
||||
from http.client import HTTPException, BadStatusLine
|
||||
from urllib.error import URLError, HTTPError
|
||||
|
||||
from osc import commandline
|
||||
from osc import oscerr
|
||||
import urllib3.exceptions
|
||||
|
||||
from . import commandline
|
||||
from . import oscerr
|
||||
from .OscConfigParser import configparser
|
||||
from .oscssl import CertVerificationError
|
||||
from osc.util.cpio import CpioError
|
||||
from osc.util.packagequery import PackageError
|
||||
from osc.util.helper import decode_it
|
||||
from osc.OscConfigParser import configparser
|
||||
from .util.cpio import CpioError
|
||||
from .util.helper import decode_it
|
||||
from .util.packagequery import PackageError
|
||||
|
||||
try:
|
||||
# import as RPMError because the class "error" is too generic
|
||||
@ -29,9 +32,6 @@ except:
|
||||
class RPMError(Exception):
|
||||
pass
|
||||
|
||||
import urllib3.exceptions
|
||||
from http.client import HTTPException, BadStatusLine
|
||||
from urllib.error import URLError, HTTPError
|
||||
|
||||
# the good things are stolen from Matt Mackall's mercurial
|
||||
|
||||
|
51
osc/build.py
51
osc/build.py
@ -3,42 +3,27 @@
|
||||
# and distributed under the terms of the GNU General Public Licence,
|
||||
# either version 2, or (at your option) any later version.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import shutil
|
||||
|
||||
try:
|
||||
import subprocess
|
||||
import sys
|
||||
from tempfile import NamedTemporaryFile, mkdtemp
|
||||
from urllib.parse import urlsplit
|
||||
from urllib.request import URLError, HTTPError
|
||||
except ImportError:
|
||||
#python 2.x
|
||||
from urlparse import urlsplit
|
||||
from urllib2 import URLError, HTTPError
|
||||
|
||||
from tempfile import NamedTemporaryFile, mkdtemp
|
||||
from osc.fetch import *
|
||||
from osc.core import get_buildinfo, store_read_apiurl, store_read_project, store_read_package, meta_exists, quote_plus, get_buildconfig, is_package_dir, dgst
|
||||
from osc.core import get_binarylist, get_binary_file, run_external, return_external, raw_input
|
||||
from osc.util import rpmquery, debquery, archquery
|
||||
from osc.util.helper import decode_it
|
||||
import osc.conf
|
||||
from . import oscerr
|
||||
import subprocess
|
||||
try:
|
||||
# Works up to Python 3.8, needed for Python < 3.3 (inc 2.7)
|
||||
from xml.etree import cElementTree as ET
|
||||
except ImportError:
|
||||
# will import a fast implementation from 3.3 onwards, needed
|
||||
# for 3.9+
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
from . import conf
|
||||
from . import connection
|
||||
from . import oscerr
|
||||
from .conf import config
|
||||
|
||||
from .core import get_buildinfo, store_read_project, store_read_package, meta_exists, quote_plus, get_buildconfig, is_package_dir, dgst
|
||||
from .core import get_binarylist, get_binary_file, run_external, return_external, raw_input
|
||||
from .fetch import Fetcher, verify_pacs
|
||||
from .meter import create_text_meter
|
||||
from .util import rpmquery, debquery, archquery
|
||||
from .util.helper import decode_it
|
||||
|
||||
|
||||
change_personality = {
|
||||
'i686': 'linux32',
|
||||
@ -819,9 +804,9 @@ def main(apiurl, opts, argv):
|
||||
bc_file = None
|
||||
bi_filename = '_buildinfo-%s-%s.xml' % (repo, arch)
|
||||
bc_filename = '_buildconfig-%s-%s' % (repo, arch)
|
||||
if is_package_dir('.') and os.access(osc.core.store, os.W_OK):
|
||||
bi_filename = os.path.join(os.getcwd(), osc.core.store, bi_filename)
|
||||
bc_filename = os.path.join(os.getcwd(), osc.core.store, bc_filename)
|
||||
if is_package_dir('.') and os.access(core.store, os.W_OK):
|
||||
bi_filename = os.path.join(os.getcwd(), core.store, bi_filename)
|
||||
bc_filename = os.path.join(os.getcwd(), core.store, bc_filename)
|
||||
elif not os.access('.', os.W_OK):
|
||||
bi_file = NamedTemporaryFile(prefix=bi_filename)
|
||||
bi_filename = bi_file.name
|
||||
@ -849,7 +834,7 @@ def main(apiurl, opts, argv):
|
||||
|
||||
# check for source services
|
||||
if not opts.offline and not opts.noservice:
|
||||
p = osc.core.Package(os.curdir)
|
||||
p = core.Package(os.curdir)
|
||||
r = p.run_source_services(verbose=True)
|
||||
if r:
|
||||
raise oscerr.ServiceRuntimeError('Source service run failed!')
|
||||
@ -1132,12 +1117,12 @@ def main(apiurl, opts, argv):
|
||||
if not old_pkg_dir.startswith('/') and not opts.offline:
|
||||
data = [ prj, pacname, repo, arch]
|
||||
if old_pkg_dir == '_link':
|
||||
p = osc.core.findpacs(os.curdir)[0]
|
||||
p = core.findpacs(os.curdir)[0]
|
||||
if not p.islink():
|
||||
raise oscerr.WrongOptions('package is not a link')
|
||||
data[0] = p.linkinfo.project
|
||||
data[1] = p.linkinfo.package
|
||||
repos = osc.core.get_repositories_of_project(apiurl, data[0])
|
||||
repos = core.get_repositories_of_project(apiurl, data[0])
|
||||
# hack for links to e.g. Factory
|
||||
if not data[2] in repos and 'standard' in repos:
|
||||
data[2] = 'standard'
|
||||
@ -1455,7 +1440,7 @@ def main(apiurl, opts, argv):
|
||||
|
||||
# record our settings for later builds
|
||||
if is_package_dir(os.curdir):
|
||||
osc.core.store_write_last_buildroot(os.curdir, repo, arch, vm_type)
|
||||
core.store_write_last_buildroot(os.curdir, repo, arch, vm_type)
|
||||
|
||||
try:
|
||||
rc = run_external(cmd[0], *cmd[1:])
|
||||
|
@ -1,10 +1,10 @@
|
||||
from __future__ import print_function
|
||||
|
||||
from tempfile import mkdtemp
|
||||
import os
|
||||
from shutil import rmtree
|
||||
import rpm
|
||||
import base64
|
||||
import os
|
||||
from tempfile import mkdtemp
|
||||
from shutil import rmtree
|
||||
|
||||
import rpm
|
||||
|
||||
|
||||
class KeyError(Exception):
|
||||
def __init__(self, key, *args):
|
||||
|
@ -3,39 +3,24 @@
|
||||
# and distributed under the terms of the GNU General Public Licence,
|
||||
# either version 2, or version 3 (at your option).
|
||||
|
||||
from __future__ import print_function
|
||||
import imp
|
||||
import inspect
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
from functools import cmp_to_key
|
||||
from operator import itemgetter
|
||||
from optparse import SUPPRESS_HELP
|
||||
from urllib.parse import urlsplit
|
||||
from urllib.error import HTTPError
|
||||
|
||||
from . import cmdln
|
||||
from . import conf
|
||||
from . import oscerr
|
||||
import sys
|
||||
import time
|
||||
import imp
|
||||
import inspect
|
||||
import os
|
||||
try:
|
||||
from urllib.parse import urlsplit
|
||||
from urllib.error import HTTPError
|
||||
ET_ENCODING = "unicode"
|
||||
except ImportError:
|
||||
#python 2.x
|
||||
from urlparse import urlsplit
|
||||
from urllib2 import HTTPError
|
||||
ET_ENCODING = "utf-8"
|
||||
|
||||
from optparse import SUPPRESS_HELP
|
||||
|
||||
from .core import *
|
||||
from .util import safewriter
|
||||
|
||||
try:
|
||||
from functools import cmp_to_key
|
||||
except ImportError:
|
||||
from .util.helper import cmp_to_key
|
||||
|
||||
from .util.helper import _html_escape
|
||||
|
||||
from operator import itemgetter
|
||||
|
||||
MAN_HEADER = r""".TH %(ucname)s "1" "%(date)s" "%(name)s %(version)s" "User Commands"
|
||||
.SH NAME
|
||||
@ -8224,7 +8209,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
data.find('title').text = ''.join(title)
|
||||
data.find('description').text = ''.join(descr)
|
||||
data.find('url').text = url
|
||||
data = ET.tostring(data, encoding=ET_ENCODING)
|
||||
data = ET.tostring(data, encoding="unicode")
|
||||
else:
|
||||
print('error - cannot get meta data', file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
12
osc/conf.py
12
osc/conf.py
@ -3,7 +3,6 @@
|
||||
# and distributed under the terms of the GNU General Public Licence,
|
||||
# either version 2, or version 3 (at your option).
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
"""Read osc configuration and store it in a dictionary
|
||||
|
||||
@ -36,20 +35,21 @@ The configuration dictionary could look like this:
|
||||
|
||||
"""
|
||||
|
||||
|
||||
import bz2
|
||||
import errno
|
||||
import getpass
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import getpass
|
||||
|
||||
from io import StringIO
|
||||
from urllib.parse import urlsplit
|
||||
|
||||
from . import credentials
|
||||
from . import OscConfigParser
|
||||
from osc import oscerr
|
||||
from osc.util.helper import raw_input
|
||||
from osc import credentials
|
||||
from . import oscerr
|
||||
from .util.helper import raw_input
|
||||
|
||||
|
||||
GENERIC_KEYRING = False
|
||||
GNOME_KEYRING = False
|
||||
|
70
osc/core.py
70
osc/core.py
@ -3,8 +3,6 @@
|
||||
# and distributed under the terms of the GNU General Public Licence,
|
||||
# either version 2, or version 3 (at your option).
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
from .util import git_version
|
||||
__version__ = git_version.get_version('1.0.0~b0')
|
||||
@ -15,61 +13,36 @@ __version__ = git_version.get_version('1.0.0~b0')
|
||||
# functionality to check_store_version().
|
||||
__store_version__ = '1.0'
|
||||
|
||||
|
||||
import errno
|
||||
import hashlib
|
||||
import locale
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
import platform
|
||||
import re
|
||||
import shlex
|
||||
import shutil
|
||||
import subprocess
|
||||
import re
|
||||
import socket
|
||||
import errno
|
||||
import shlex
|
||||
import hashlib
|
||||
import platform
|
||||
|
||||
import sys
|
||||
from functools import cmp_to_key
|
||||
from http.client import IncompleteRead
|
||||
from io import StringIO
|
||||
from urllib.parse import urlsplit, urlunsplit, urlparse, quote_plus, urlencode, unquote
|
||||
from urllib.error import HTTPError
|
||||
from urllib.request import pathname2url
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
try:
|
||||
import distro
|
||||
except ImportError:
|
||||
distro = None
|
||||
|
||||
from urllib.parse import urlsplit, urlunsplit, urlparse, quote_plus, urlencode, unquote
|
||||
from urllib.error import HTTPError
|
||||
from urllib.request import pathname2url
|
||||
from io import StringIO
|
||||
from http.client import IncompleteRead
|
||||
|
||||
try:
|
||||
# Works up to Python 3.8, needed for Python < 3.3 (inc 2.7)
|
||||
from xml.etree import cElementTree as ET
|
||||
except ImportError:
|
||||
# will import a fast implementation from 3.3 onwards, needed
|
||||
# for 3.9+
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
from . import oscerr
|
||||
from . import conf
|
||||
from . import oscerr
|
||||
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
|
||||
|
||||
try:
|
||||
from functools import cmp_to_key
|
||||
except ImportError:
|
||||
from .util.helper import cmp_to_key
|
||||
|
||||
from osc.util.helper import decode_list, decode_it, raw_input, _html_escape
|
||||
|
||||
try:
|
||||
# python 2.6 and python 2.7
|
||||
unicode
|
||||
ET_ENCODING = "utf-8"
|
||||
# python 2.6 does not have bytes and python 2.7 reimplements it as alias to
|
||||
# str, but in incompatible way as it does not accept the same arguments
|
||||
bytes = lambda x, *args: x
|
||||
except:
|
||||
#python3 does not have unicode, so lets reimplement it
|
||||
#as void function as it already gets unicode strings
|
||||
unicode = lambda x, *args: x
|
||||
ET_ENCODING = "unicode"
|
||||
|
||||
def compare(a, b): return cmp(a[1:], b[1:])
|
||||
@ -4200,8 +4173,7 @@ def create_release_request(apiurl, src_project, message=''):
|
||||
r = Request()
|
||||
# api will complete the request
|
||||
r.add_action('maintenance_release', src_project=src_project)
|
||||
# XXX: clarify why we need the unicode(...) stuff
|
||||
r.description = unicode(message, 'utf8')
|
||||
r.description = message
|
||||
r.create(apiurl)
|
||||
return r
|
||||
|
||||
@ -4213,8 +4185,7 @@ def create_maintenance_request(apiurl, src_project, src_packages, tgt_project, t
|
||||
r.add_action('maintenance_incident', src_project=src_project, src_package=p, src_rev=rev, tgt_project=tgt_project, tgt_releaseproject=tgt_releaseproject, opt_sourceupdate = opt_sourceupdate)
|
||||
else:
|
||||
r.add_action('maintenance_incident', src_project=src_project, tgt_project=tgt_project, tgt_releaseproject=tgt_releaseproject, opt_sourceupdate = opt_sourceupdate)
|
||||
# XXX: clarify why we need the unicode(...) stuff
|
||||
r.description = unicode(message, 'utf8')
|
||||
r.description = message
|
||||
r.create(apiurl, addrevision=True, enforce_branching=enforce_branching)
|
||||
return r
|
||||
|
||||
@ -4259,11 +4230,6 @@ def create_submit_request(apiurl,
|
||||
options_block,
|
||||
_html_escape(message))
|
||||
|
||||
# Don't do _html_escape(unicode(message, "utf8"))) above.
|
||||
# Promoting the string to utf8, causes the post to explode with:
|
||||
# uncaught exception: Fatal error: Start tag expected, '<' not found at :1.
|
||||
# I guess, my original workaround was not that bad.
|
||||
|
||||
u = makeurl(apiurl, ['request'], query='cmd=create')
|
||||
r = None
|
||||
try:
|
||||
|
@ -1,13 +1,9 @@
|
||||
import importlib
|
||||
import bz2
|
||||
import base64
|
||||
import bz2
|
||||
import getpass
|
||||
import importlib
|
||||
import sys
|
||||
|
||||
try:
|
||||
from urllib.parse import urlsplit
|
||||
except ImportError:
|
||||
from urlparse import urlsplit
|
||||
|
||||
try:
|
||||
import keyring
|
||||
|
24
osc/fetch.py
24
osc/fetch.py
@ -3,28 +3,22 @@
|
||||
# and distributed under the terms of the GNU General Public Licence,
|
||||
# either version 2, or (at your option) any later version.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import sys, os
|
||||
|
||||
try:
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
from urllib.parse import quote_plus
|
||||
from urllib.request import HTTPError
|
||||
except ImportError:
|
||||
#python 2.x
|
||||
from urllib import quote_plus
|
||||
from urllib2 import HTTPError
|
||||
|
||||
from .core import makeurl, streamfile, dgst
|
||||
from .grabber import OscFileGrabber, OscMirrorGroup
|
||||
from .util import packagequery, cpio
|
||||
from . import conf
|
||||
from . import oscerr
|
||||
import tempfile
|
||||
import re
|
||||
|
||||
from osc.util.helper import decode_it
|
||||
from .core import makeurl, streamfile, dgst
|
||||
from .grabber import OscFileGrabber, OscMirrorGroup
|
||||
from .meter import create_text_meter
|
||||
from .util import packagequery, cpio
|
||||
from .util.helper import decode_it
|
||||
|
||||
|
||||
class Fetcher:
|
||||
def __init__(self, cachedir='/tmp', api_host_options={}, urllist=[],
|
||||
|
@ -3,20 +3,15 @@
|
||||
# and distributed under the terms of the GNU General Public Licence,
|
||||
# either version 2, or (at your option) any later version.
|
||||
|
||||
import sys
|
||||
import os.path
|
||||
from .core import streamfile
|
||||
|
||||
try:
|
||||
import os
|
||||
import sys
|
||||
from urllib.request import HTTPError
|
||||
from urllib.parse import urlparse
|
||||
from urllib.parse import unquote
|
||||
from urllib.error import URLError
|
||||
except ImportError:
|
||||
from urllib2 import HTTPError
|
||||
from urlparse import urlparse
|
||||
from urllib import unquote
|
||||
from urllib2 import URLError
|
||||
|
||||
from .core import streamfile
|
||||
|
||||
|
||||
class OscFileGrabber(object):
|
||||
|
@ -13,13 +13,11 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import stat
|
||||
|
||||
import sys
|
||||
from io import BytesIO
|
||||
|
||||
|
||||
|
@ -1,11 +1,10 @@
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os.path
|
||||
import os
|
||||
import re
|
||||
import tarfile
|
||||
from . import packagequery
|
||||
import subprocess
|
||||
import tarfile
|
||||
|
||||
from . import packagequery
|
||||
|
||||
|
||||
class ArchError(packagequery.PackageError):
|
||||
pass
|
||||
|
@ -13,7 +13,6 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import mmap
|
||||
import os
|
||||
@ -21,6 +20,7 @@ import stat
|
||||
import struct
|
||||
import sys
|
||||
|
||||
|
||||
# workaround for python24
|
||||
if not hasattr(os, 'SEEK_SET'):
|
||||
os.SEEK_SET = 0
|
||||
|
@ -1,13 +1,11 @@
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from . import ar
|
||||
import os.path
|
||||
import itertools
|
||||
import os
|
||||
import re
|
||||
import tarfile
|
||||
from io import BytesIO
|
||||
|
||||
from . import ar
|
||||
from . import packagequery
|
||||
import itertools
|
||||
|
||||
|
||||
HAVE_LZMA = True
|
||||
|
@ -3,43 +3,10 @@
|
||||
# and distributed under the terms of the GNU General Public Licence,
|
||||
# either version 2, or (at your option) any later version.
|
||||
|
||||
try:
|
||||
|
||||
import html
|
||||
except ImportError:
|
||||
import cgi as html
|
||||
|
||||
from osc import oscerr
|
||||
|
||||
def cmp_to_key(mycmp):
|
||||
""" Converts a cmp= function into a key= function.
|
||||
"""
|
||||
|
||||
class K(object):
|
||||
def __init__(self, obj, *args):
|
||||
self.obj = obj
|
||||
|
||||
def __lt__(self, other):
|
||||
return mycmp(self.obj, other.obj) < 0
|
||||
|
||||
def __gt__(self, other):
|
||||
return mycmp(self.obj, other.obj) > 0
|
||||
|
||||
def __eq__(self, other):
|
||||
return mycmp(self.obj, other.obj) == 0
|
||||
|
||||
def __le__(self, other):
|
||||
return mycmp(self.obj, other.obj) <= 0
|
||||
|
||||
def __ge__(self, other):
|
||||
return mycmp(self.obj, other.obj) >= 0
|
||||
|
||||
def __ne__(self, other):
|
||||
return mycmp(self.obj, other.obj) != 0
|
||||
|
||||
def __hash__(self):
|
||||
raise TypeError('hash not implemented')
|
||||
|
||||
return K
|
||||
from .. import oscerr
|
||||
|
||||
|
||||
def decode_list(ilist):
|
||||
@ -72,13 +39,8 @@ def decode_it(obj):
|
||||
|
||||
|
||||
def raw_input(*args):
|
||||
try:
|
||||
import builtins
|
||||
func = builtins.input
|
||||
except ImportError:
|
||||
#python 2.7
|
||||
import __builtin__
|
||||
func = __builtin__.raw_input
|
||||
|
||||
try:
|
||||
return func(*args)
|
||||
|
@ -1,6 +1,5 @@
|
||||
from .helper import decode_it
|
||||
|
||||
from __future__ import print_function
|
||||
from osc.util.helper import decode_it
|
||||
|
||||
class PackageError(Exception):
|
||||
"""base class for all package related errors"""
|
||||
|
@ -1,21 +1,14 @@
|
||||
"""Module for reading repodata directory (created with createrepo) for package
|
||||
information instead of scanning individual rpms."""
|
||||
|
||||
# standard modules
|
||||
import gzip
|
||||
import os.path
|
||||
|
||||
try:
|
||||
# Works up to Python 3.8, needed for Python < 3.3 (inc 2.7)
|
||||
from xml.etree import cElementTree as ET
|
||||
except ImportError:
|
||||
# will import a fast implementation from 3.3 onwards, needed
|
||||
# for 3.9+
|
||||
import gzip
|
||||
import os
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
# project modules
|
||||
import osc.util.rpmquery
|
||||
import osc.util.packagequery
|
||||
from . import rpmquery
|
||||
from . import packagequery
|
||||
|
||||
|
||||
def namespace(name):
|
||||
return "{http://linux.duke.edu/metadata/%s}" % name
|
||||
@ -92,7 +85,7 @@ def _to_bytes_list(method):
|
||||
return _method
|
||||
|
||||
|
||||
class RepoDataQueryResult(osc.util.packagequery.PackageQueryResult):
|
||||
class RepoDataQueryResult(packagequery.PackageQueryResult):
|
||||
"""PackageQueryResult that reads in data from the repodata directory files."""
|
||||
|
||||
def __init__(self, directory, element):
|
||||
@ -206,7 +199,7 @@ class RepoDataQueryResult(osc.util.packagequery.PackageQueryResult):
|
||||
release = None
|
||||
else:
|
||||
release = self.release()
|
||||
return osc.util.rpmquery.RpmQuery.filename(self.name(), None,
|
||||
return rpmquery.RpmQuery.filename(self.name(), None,
|
||||
self.version(), release, self.arch())
|
||||
|
||||
def gettag(self, tag):
|
||||
@ -217,13 +210,13 @@ class RepoDataQueryResult(osc.util.packagequery.PackageQueryResult):
|
||||
# if either self.epoch() or other.epoch() is None, the vercmp will do
|
||||
# the correct thing because one is transformed into b'None' and the
|
||||
# other one into b"b'<epoch>'" (and 'b' is greater than 'N')
|
||||
res = osc.util.rpmquery.RpmQuery.rpmvercmp(str(self.epoch()).encode(), str(other.epoch()).encode())
|
||||
res = rpmquery.RpmQuery.rpmvercmp(str(self.epoch()).encode(), str(other.epoch()).encode())
|
||||
if res != 0:
|
||||
return res
|
||||
res = osc.util.rpmquery.RpmQuery.rpmvercmp(self.version(), other.version())
|
||||
res = rpmquery.RpmQuery.rpmvercmp(self.version(), other.version())
|
||||
if res != 0:
|
||||
return res
|
||||
res = osc.util.rpmquery.RpmQuery.rpmvercmp(self.release(), other.release())
|
||||
res = rpmquery.RpmQuery.rpmvercmp(self.release(), other.release())
|
||||
return res
|
||||
|
||||
@_to_bytes_or_None
|
||||
|
@ -1,11 +1,10 @@
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import re
|
||||
import struct
|
||||
from . import packagequery
|
||||
from osc.util.helper import decode_it
|
||||
|
||||
from .helper import decode_it
|
||||
|
||||
|
||||
def cmp(a, b):
|
||||
return (a > b) - (a < b)
|
||||
|
13
setup.py
13
setup.py
@ -1,15 +1,14 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from distutils.core import setup
|
||||
|
||||
import distutils.core
|
||||
from distutils.command import build, install_data
|
||||
import gzip
|
||||
import os.path
|
||||
|
||||
import os
|
||||
import setuptools
|
||||
from distutils.command import build, install_data
|
||||
|
||||
import osc.commandline
|
||||
import osc.core
|
||||
from osc import commandline
|
||||
|
||||
|
||||
class build_osc(build.build, object):
|
||||
@ -23,7 +22,7 @@ class build_osc(build.build, object):
|
||||
man_path = os.path.join(self.build_base, 'osc.1.gz')
|
||||
distutils.log.info('generating %s' % man_path)
|
||||
outfile = gzip.open(man_path, 'wt')
|
||||
osccli = commandline.Osc(stdout=outfile)
|
||||
osccli = osc.commandline.Osc(stdout=outfile)
|
||||
# FIXME: we cannot call the main method because osc expects an ~/.oscrc
|
||||
# file (this would break builds in environments like the obs)
|
||||
# osccli.main(argv = ['osc','man'])
|
||||
@ -119,9 +118,7 @@ setuptools.setup(
|
||||
"Operating System :: POSIX :: BSD :: FreeBSD",
|
||||
"Operating System :: POSIX :: Linux",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 2.7",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.5",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
|
@ -1,9 +1,12 @@
|
||||
import osc.core
|
||||
import osc.oscerr
|
||||
import os
|
||||
import sys
|
||||
|
||||
import osc.core
|
||||
import osc.oscerr
|
||||
|
||||
from .common import OscTestCase
|
||||
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'addfile_fixtures')
|
||||
|
||||
def suite():
|
||||
|
@ -1,20 +1,13 @@
|
||||
import osc.core
|
||||
import osc.oscerr
|
||||
import os
|
||||
import sys
|
||||
from .common import GET, PUT, POST, DELETE, OscTestCase
|
||||
try:
|
||||
# Works up to Python 3.8, needed for Python < 3.3 (inc 2.7)
|
||||
from xml.etree import cElementTree as ET
|
||||
except ImportError:
|
||||
# will import a fast implementation from 3.3 onwards, needed
|
||||
# for 3.9+
|
||||
from xml.etree import ElementTree as ET
|
||||
try:
|
||||
from urllib.error import HTTPError
|
||||
except ImportError:
|
||||
#python 2.x
|
||||
from urllib2 import HTTPError
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
import osc.core
|
||||
import osc.oscerr
|
||||
|
||||
from .common import GET, PUT, POST, DELETE, OscTestCase
|
||||
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'commit_fixtures')
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
import unittest
|
||||
|
||||
from osc.core import parseRevisionOption
|
||||
from osc.oscerr import OscInvalidRevision
|
||||
|
||||
import unittest
|
||||
|
||||
|
||||
class TestParseRevisionOption(unittest.TestCase):
|
||||
def test_empty(self):
|
||||
|
@ -1,8 +1,11 @@
|
||||
import os
|
||||
|
||||
import osc.core
|
||||
import osc.oscerr
|
||||
import os
|
||||
|
||||
from .common import OscTestCase
|
||||
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'deletefile_fixtures')
|
||||
|
||||
def suite():
|
||||
|
@ -1,10 +1,13 @@
|
||||
import os
|
||||
import re
|
||||
|
||||
import osc.core
|
||||
import osc.oscerr
|
||||
from osc.util.helper import decode_list
|
||||
import os
|
||||
import re
|
||||
|
||||
from .common import GET, OscTestCase
|
||||
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'difffile_fixtures')
|
||||
|
||||
def suite():
|
||||
|
@ -1,6 +1,8 @@
|
||||
import unittest
|
||||
|
||||
from osc.util.helper import decode_it, decode_list
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.makeSuite(TestResults)
|
||||
|
||||
|
@ -1,7 +1,11 @@
|
||||
import os
|
||||
|
||||
import osc.core
|
||||
import osc.oscerr
|
||||
import os
|
||||
|
||||
from .common import OscTestCase
|
||||
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'init_package_fixtures')
|
||||
|
||||
def suite():
|
||||
|
@ -1,7 +1,11 @@
|
||||
import os
|
||||
|
||||
import osc.core
|
||||
import osc.oscerr
|
||||
import os
|
||||
|
||||
from .common import GET, OscTestCase
|
||||
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'init_project_fixtures')
|
||||
|
||||
def suite():
|
||||
|
@ -1,8 +1,11 @@
|
||||
import os
|
||||
|
||||
import osc.core
|
||||
import osc.oscerr
|
||||
import os
|
||||
|
||||
from .common import OscTestCase
|
||||
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'project_package_status_fixtures')
|
||||
|
||||
def suite():
|
||||
|
@ -1,9 +1,11 @@
|
||||
import osc.commandline
|
||||
import osc.core
|
||||
import osc.oscerr
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
import osc.commandline
|
||||
import osc.core
|
||||
import osc.oscerr
|
||||
|
||||
from .common import GET, POST, OscTestCase, EXPECTED_REQUESTS
|
||||
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
import os
|
||||
|
||||
import osc.core
|
||||
import osc.oscerr
|
||||
import os
|
||||
|
||||
from .common import OscTestCase
|
||||
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'project_package_status_fixtures')
|
||||
|
||||
def suite():
|
||||
|
@ -1,15 +1,13 @@
|
||||
import osc.core
|
||||
import osc.oscerr
|
||||
import os
|
||||
import sys
|
||||
from .common import GET, PUT, POST, DELETE, OscTestCase
|
||||
try:
|
||||
# Works up to Python 3.8, needed for Python < 3.3 (inc 2.7)
|
||||
from xml.etree import cElementTree as ET
|
||||
except ImportError:
|
||||
# will import a fast implementation from 3.3 onwards, needed
|
||||
# for 3.9+
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
import osc.core
|
||||
import osc.oscerr
|
||||
|
||||
from .common import GET, PUT, POST, DELETE, OscTestCase
|
||||
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'repairwc_fixtures')
|
||||
|
||||
def suite():
|
||||
|
@ -1,16 +1,12 @@
|
||||
try:
|
||||
# Works up to Python 3.8, needed for Python < 3.3 (inc 2.7)
|
||||
from xml.etree import cElementTree as ET
|
||||
except ImportError:
|
||||
# will import a fast implementation from 3.3 onwards, needed
|
||||
# for 3.9+
|
||||
import os
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
import osc.core
|
||||
import osc.oscerr
|
||||
import os
|
||||
|
||||
from .common import OscTestCase
|
||||
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'request_fixtures')
|
||||
|
||||
def suite():
|
||||
|
@ -1,8 +1,11 @@
|
||||
import osc.commandline
|
||||
from .common import GET, OscTestCase
|
||||
import os
|
||||
import sys
|
||||
|
||||
import osc.commandline
|
||||
|
||||
from .common import GET, OscTestCase
|
||||
|
||||
|
||||
def suite():
|
||||
import unittest
|
||||
return unittest.makeSuite(TestResults)
|
||||
|
@ -1,8 +1,11 @@
|
||||
import os
|
||||
|
||||
import osc.core
|
||||
import osc.oscerr
|
||||
import os
|
||||
|
||||
from .common import OscTestCase
|
||||
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'revertfile_fixtures')
|
||||
|
||||
def suite():
|
||||
|
@ -1,7 +1,11 @@
|
||||
import os
|
||||
|
||||
import osc.core
|
||||
import osc.oscerr
|
||||
import os
|
||||
|
||||
from .common import GET, PUT, OscTestCase
|
||||
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'setlinkrev_fixtures')
|
||||
|
||||
def suite():
|
||||
@ -60,10 +64,7 @@ class TestSetLinkRev(OscTestCase):
|
||||
@GET('http://localhost/source/srcprj/srcpkg?rev=latest&expand=1', text='conflict in file merge', code=400)
|
||||
def test_linkerror(self):
|
||||
"""link is broken"""
|
||||
try:
|
||||
from urllib.error import HTTPError
|
||||
except ImportError:
|
||||
from urllib2 import HTTPError
|
||||
# the backend returns status 400 if we try to expand a broken _link
|
||||
self.assertRaises(HTTPError, osc.core.set_link_rev, 'http://localhost', 'osctest', 'simple', expand=True)
|
||||
|
||||
|
@ -1,8 +1,12 @@
|
||||
import osc.core
|
||||
import osc.oscerr
|
||||
import os
|
||||
import sys
|
||||
|
||||
import osc.core
|
||||
import osc.oscerr
|
||||
|
||||
from .common import GET, OscTestCase
|
||||
|
||||
|
||||
FIXTURES_DIR = os.path.join(os.path.dirname(__file__), 'update_fixtures')
|
||||
|
||||
def suite():
|
||||
|
Loading…
Reference in New Issue
Block a user