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

User super() instead of referencing parent classes explicitly

This commit is contained in:
Daniel Mach 2022-08-31 11:46:12 +02:00
parent 1442a55c96
commit 3296fd8d89
13 changed files with 34 additions and 34 deletions

View File

@ -93,7 +93,7 @@ class SectionLine(Line):
CommentLine() or OptionLine() instances.
"""
def __init__(self, sectname):
Line.__init__(self, sectname, 'section')
super().__init__(sectname, 'section')
self._lines = []
def _find(self, name):
@ -155,7 +155,7 @@ class SectionLine(Line):
class CommentLine(Line):
"""Store a commentline"""
def __init__(self, line):
Line.__init__(self, line.strip('\n'), 'comment')
super().__init__(line.strip('\n'), 'comment')
def __str__(self):
return self.name
@ -176,7 +176,7 @@ class OptionLine(Line):
"""
def __init__(self, optname, line):
Line.__init__(self, optname, 'option')
super().__init__(optname, 'option')
self.name = optname
self.format(line)

View File

@ -8,7 +8,7 @@ import rpm
class KeyError(Exception):
def __init__(self, key, *args):
Exception.__init__(self)
super().__init__()
self.args = args
self.key = key
def __str__(self):

View File

@ -2569,7 +2569,7 @@ class ReviewState(AbstractState):
if not review_node.get('state'):
raise oscerr.APIError('invalid review node (state attr expected): %s' % \
ET.tostring(review_node, encoding=ET_ENCODING))
AbstractState.__init__(self, review_node.tag)
super().__init__(review_node.tag)
self.state = review_node.get('state')
self.by_user = review_node.get('by_user')
self.by_group = review_node.get('by_group')
@ -2597,7 +2597,7 @@ class RequestHistory(AbstractState):
re_name = re.compile(r'^Request (?:got )?([^\s]+)$')
def __init__(self, history_node):
AbstractState.__init__(self, history_node.tag)
super().__init__(history_node.tag)
self.who = history_node.get('who')
self.when = history_node.get('when')
if not history_node.find('description') is None and \
@ -2639,7 +2639,7 @@ class RequestState(AbstractState):
if not state_node.get('name'):
raise oscerr.APIError('invalid request state node (name attr expected): %s' % \
ET.tostring(state_node, encoding=ET_ENCODING))
AbstractState.__init__(self, state_node.tag)
super().__init__(state_node.tag)
self.name = state_node.get('name')
self.who = state_node.get('who')
self.when = state_node.get('when')

View File

@ -7,7 +7,7 @@
class OscBaseError(Exception):
def __init__(self, args=()):
Exception.__init__(self)
super().__init__()
self.args = args
def __str__(self):
return ''.join(self.args)
@ -18,7 +18,7 @@ class UserAbort(OscBaseError):
class ConfigError(OscBaseError):
"""Exception raised when there is an error in the config file"""
def __init__(self, msg, fname):
OscBaseError.__init__(self)
super().__init__()
self.msg = msg
self.file = fname
@ -28,24 +28,24 @@ class ConfigError(OscBaseError):
class ConfigMissingApiurl(ConfigError):
"""Exception raised when a apiurl does not exist in the config file"""
def __init__(self, msg, fname, url):
ConfigError.__init__(self, msg, fname)
super().__init__(msg, fname)
self.url = url
class ConfigMissingCredentialsError(ConfigError):
def __init__(self, msg, fname, url):
ConfigError.__init__(self, msg, fname)
super().__init__(msg, fname)
self.url = url
class APIError(OscBaseError):
"""Exception raised when there is an error in the output from the API"""
def __init__(self, msg):
OscBaseError.__init__(self)
super().__init__()
self.msg = msg
class NoConfigfile(OscBaseError):
"""Exception raised when osc's configfile cannot be found"""
def __init__(self, fname, msg):
OscBaseError.__init__(self)
super().__init__()
self.file = fname
self.msg = msg
@ -55,14 +55,14 @@ class NoConfigfile(OscBaseError):
class ExtRuntimeError(OscBaseError):
"""Exception raised when there is a runtime error of an external tool"""
def __init__(self, msg, fname):
OscBaseError.__init__(self)
super().__init__()
self.msg = msg
self.file = fname
class ServiceRuntimeError(OscBaseError):
"""Exception raised when the execution of a source service failed"""
def __init__(self, msg):
OscBaseError.__init__(self)
super().__init__()
self.msg = msg
class WrongArgs(OscBaseError):
@ -98,26 +98,26 @@ class WorkingCopyOutdated(OscBaseError):
class PackageError(OscBaseError):
"""Base class for all Package related exceptions"""
def __init__(self, prj, pac):
OscBaseError.__init__(self)
super().__init__()
self.prj = prj
self.pac = pac
class WorkingCopyInconsistent(PackageError):
"""Exception raised when the working copy is in an inconsistent state"""
def __init__(self, prj, pac, dirty_files, msg):
PackageError.__init__(self, prj, pac)
super().__init__(prj, pac)
self.dirty_files = dirty_files
self.msg = msg
class LinkExpandError(PackageError):
"""Exception raised when source link expansion fails"""
def __init__(self, prj, pac, msg):
PackageError.__init__(self, prj, pac)
super().__init__(prj, pac)
self.msg = msg
class OscIOError(OscBaseError):
def __init__(self, e, msg):
OscBaseError.__init__(self)
super().__init__()
self.e = e
self.msg = msg
@ -142,7 +142,7 @@ class PackageNotInstalled(OscBaseError):
Exception raised when a package is not installed on local system
"""
def __init__(self, pkg):
OscBaseError.__init__(self, (pkg,))
super().__init__((pkg,))
def __str__(self):
return 'Package %s is required for this operation' % self.args
@ -155,7 +155,7 @@ class PackageExists(PackageError):
Exception raised when a local object already exists
"""
def __init__(self, prj, pac, msg):
PackageError.__init__(self, prj, pac)
super().__init__(prj, pac)
self.msg = msg
class PackageMissing(PackageError):
@ -163,7 +163,7 @@ class PackageMissing(PackageError):
Exception raised when a local object doesn't exist
"""
def __init__(self, prj, pac, msg):
PackageError.__init__(self, prj, pac)
super().__init__(prj, pac)
self.msg = msg
class PackageFileConflict(PackageError):
@ -172,12 +172,12 @@ class PackageFileConflict(PackageError):
Conflict doesn't mean an unsuccessfull merge in this context.
"""
def __init__(self, prj, pac, file, msg):
PackageError.__init__(self, prj, pac)
super().__init__(prj, pac)
self.file = file
self.msg = msg
class PackageInternalError(PackageError):
def __init__(self, prj, pac, msg):
PackageError.__init__(self, prj, pac)
super().__init__(prj, pac)
self.msg = msg
# vim: sw=4 et

View File

@ -28,7 +28,7 @@ if not hasattr(os, 'SEEK_SET'):
class ArError(Exception):
"""Base class for all ar related errors"""
def __init__(self, fn, msg):
Exception.__init__(self)
super().__init__()
self.file = fn
self.msg = msg
@ -57,7 +57,7 @@ class ArHdr:
class ArFile(BytesIO):
"""Represents a file which resides in the archive"""
def __init__(self, fn, uid, gid, mode, buf):
BytesIO.__init__(self, buf)
super().__init__(buf)
self.name = fn
self.uid = uid
self.gid = gid

View File

@ -30,7 +30,7 @@ if not hasattr(os, 'SEEK_SET'):
class CpioError(Exception):
"""base class for all cpio related errors"""
def __init__(self, fn, msg):
Exception.__init__(self)
super().__init__()
self.file = fn
self.msg = msg
def __str__(self):

View File

@ -4,7 +4,7 @@ from .helper import decode_it
class PackageError(Exception):
"""base class for all package related errors"""
def __init__(self, fname, msg):
Exception.__init__(self)
super().__init__()
self.fname = fname
self.msg = msg

View File

@ -65,7 +65,7 @@ def xml_equal(actual, exp):
class RequestWrongOrder(Exception):
"""raised if an unexpected request is issued to urllib2"""
def __init__(self, url, exp_url, method, exp_method):
Exception.__init__(self)
super().__init__()
self.url = url
self.exp_url = exp_url
self.method = method

View File

@ -22,7 +22,7 @@ class TestInitPackage(OscTestCase):
def tearDown(self):
if os.path.exists(os.path.join(FIXTURES_DIR, 'osctest')):
os.rmdir(os.path.join(FIXTURES_DIR, 'osctest'))
OscTestCase.tearDown(self)
super().tearDown()
def test_simple(self):
"""initialize a package dir"""

View File

@ -22,7 +22,7 @@ class TestInitProject(OscTestCase):
def tearDown(self):
if os.path.exists(os.path.join(FIXTURES_DIR, 'osctest')):
os.rmdir(os.path.join(FIXTURES_DIR, 'osctest'))
OscTestCase.tearDown(self)
super().tearDown()
def test_simple(self):
"""initialize a project dir"""

View File

@ -18,7 +18,7 @@ class TestRequest(OscTestCase):
return FIXTURES_DIR
def setUp(self):
OscTestCase.setUp(self, copytree=False)
super().setUp(copytree=False)
def test_createsr(self):
"""create a simple submitrequest"""

View File

@ -12,7 +12,7 @@ def suite():
class TestResults(OscTestCase):
def setUp(self):
OscTestCase.setUp(self, copytree=False)
super().setUp(copytree=False)
def _get_fixtures_name(self):
return 'results_fixtures'

View File

@ -14,7 +14,7 @@ def suite():
class TestSetLinkRev(OscTestCase):
def setUp(self):
OscTestCase.setUp(self, copytree=False)
super().setUp(copytree=False)
def _get_fixtures_dir(self):
return FIXTURES_DIR