From 6f5b4a7bee1cf86cf629ad2590a304d4308fb246 Mon Sep 17 00:00:00 2001
From: Nikos Skalkotos <skalkoto@grnet.gr>
Date: Mon, 3 Nov 2014 16:13:29 +0200
Subject: [PATCH] Rename **kargs to **kwargs
This complies better with the python conventions
---
image_creator/dialog_wizard.py | 33 ++++++++++++-----------
image_creator/disk.py | 4 +--
image_creator/image.py | 6 ++---
image_creator/os_type/__init__.py | 28 +++++++++----------
image_creator/os_type/linux.py | 4 +--
image_creator/os_type/unsupported.py | 4 +--
image_creator/os_type/windows/__init__.py | 4 +--
image_creator/os_type/windows/registry.py | 11 ++++----
8 files changed, 48 insertions(+), 46 deletions(-)
diff --git a/image_creator/dialog_wizard.py b/image_creator/dialog_wizard.py
index 2c4e5d6..6104c66 100644
--- a/image_creator/dialog_wizard.py
+++ b/image_creator/dialog_wizard.py
@@ -105,18 +105,19 @@ class WizardPage(object):
NEXT = 1
PREV = -1
- def __init__(self, name, text, **kargs):
+ def __init__(self, name, text, **kwargs):
self.name = name
self.answer = None
self.text = text
- self.print_name = kargs['print_name'] if 'print_name' in kargs \
+ self.print_name = kwargs['print_name'] if 'print_name' in kwargs \
else " ".join(re.findall('[A-Z][^A-Z]*', name))
- self.title = kargs['title'] if 'title' in kargs else self.print_name
- self.default = kargs['default'] if 'default' in kargs else ""
- self.extra = kargs['extra'] if 'extra' in kargs else None
+ self.title = kwargs['title'] if 'title' in kwargs else self.print_name
+ self.default = kwargs['default'] if 'default' in kwargs else ""
+ self.extra = kwargs['extra'] if 'extra' in kwargs else None
self.validate = \
- kargs['validate'] if 'validate' in kargs else lambda x: x
- self.display = kargs['display'] if 'display' in kargs else lambda x: x
+ kwargs['validate'] if 'validate' in kwargs else lambda x: x
+ self.display = \
+ kwargs['display'] if 'display' in kwargs else lambda x: x
self.dargs = {}
self.dargs['ok_label'] = 'Next'
@@ -124,10 +125,10 @@ class WizardPage(object):
self.dargs['width'] = PAGE_WIDTH
self.dargs['height'] = PAGE_HEIGHT
- if 'extra' in kargs:
+ if 'extra' in kwargs:
self.dargs['extra_button'] = 1
- self.extra_label = kargs['extra_label'] if 'extra_label' in kargs \
+ self.extra_label = kwargs['extra_label'] if 'extra_label' in kwargs \
else lambda: "extra"
def __str__(self):
@@ -167,9 +168,9 @@ class WizardInfoPage(WizardPage):
The user-defined information is created by the info function.
"""
- def __init__(self, name, text, info, **kargs):
+ def __init__(self, name, text, info, **kwargs):
"""Initialize the WizardInfoPage instance"""
- super(WizardInfoPage, self).__init__(name, text, **kargs)
+ super(WizardInfoPage, self).__init__(name, text, **kwargs)
self.info = info
def show(self, dialog, title):
@@ -194,9 +195,9 @@ class WizardInfoPage(WizardPage):
class WizardFormPage(WizardPage):
"""Represents a Form in a wizard"""
- def __init__(self, name, text, fields, **kargs):
+ def __init__(self, name, text, fields, **kwargs):
"""Initialize the WizardFormPage instance"""
- super(WizardFormPage, self).__init__(name, text, **kargs)
+ super(WizardFormPage, self).__init__(name, text, **kwargs)
self.fields = fields
def show(self, dialog, title):
@@ -227,11 +228,11 @@ class WizardPageWthChoices(WizardPage):
the choices variable. If the choices function returns an empty list, a
fallback function is executed if available.
"""
- def __init__(self, name, text, choices, **kargs):
+ def __init__(self, name, text, choices, **kwargs):
"""Initialize the WizardPageWthChoices instance"""
- super(WizardPageWthChoices, self).__init__(name, text, **kargs)
+ super(WizardPageWthChoices, self).__init__(name, text, **kwargs)
self.choices = choices
- self.fallback = kargs['fallback'] if 'fallback' in kargs else None
+ self.fallback = kwargs['fallback'] if 'fallback' in kwargs else None
class WizardRadioListPage(WizardPageWthChoices):
diff --git a/image_creator/disk.py b/image_creator/disk.py
index 0f1fdc4..39c8564 100644
--- a/image_creator/disk.py
+++ b/image_creator/disk.py
@@ -194,10 +194,10 @@ class Disk(object):
self.out.success('done')
return "/dev/mapper/%s" % snapshot
- def get_image(self, media, **kargs):
+ def get_image(self, media, **kwargs):
"""Returns a newly created Image instance."""
- image = Image(media, self.out, **kargs)
+ image = Image(media, self.out, **kwargs)
self._images.append(image)
image.enable()
return image
diff --git a/image_creator/image.py b/image_creator/image.py
index da3777d..364d12a 100644
--- a/image_creator/image.py
+++ b/image_creator/image.py
@@ -28,16 +28,16 @@ from sendfile import sendfile
class Image(object):
"""The instances of this class can create images out of block devices."""
- def __init__(self, device, output, **kargs):
+ def __init__(self, device, output, **kwargs):
"""Create a new Image instance"""
self.device = device
self.out = output
self.info = image_info(device)
- self.meta = kargs['meta'] if 'meta' in kargs else {}
+ self.meta = kwargs['meta'] if 'meta' in kwargs else {}
self.sysprep_params = \
- kargs['sysprep_params'] if 'sysprep_params' in kargs else {}
+ kwargs['sysprep_params'] if 'sysprep_params' in kwargs else {}
self.progress_bar = None
self.guestfs_device = None
diff --git a/image_creator/os_type/__init__.py b/image_creator/os_type/__init__.py
index 2af3d04..ea8a193 100644
--- a/image_creator/os_type/__init__.py
+++ b/image_creator/os_type/__init__.py
@@ -87,7 +87,7 @@ def sysprep(message, enabled=True, **kwargs):
class SysprepParam(object):
"""This class represents a system preparation parameter"""
- def __init__(self, type, default, description, **kargs):
+ def __init__(self, type, default, description, **kwargs):
assert hasattr(self, "_check_%s" % type), "Invalid type: %s" % type
@@ -96,8 +96,8 @@ class SysprepParam(object):
self.description = description
self.value = default
self.error = None
- self.check = kargs['check'] if 'check' in kargs else lambda x: x
- self.hidden = kargs['hidden'] if 'hidden' in kargs else False
+ self.check = kwargs['check'] if 'check' in kwargs else lambda x: x
+ self.hidden = kwargs['hidden'] if 'hidden' in kwargs else False
def set_value(self, value):
"""Update the value of the parameter"""
@@ -160,11 +160,11 @@ class SysprepParam(object):
raise ValueError("Invalid dirname")
-def add_sysprep_param(name, type, default, descr, **kargs):
+def add_sysprep_param(name, type, default, descr, **kwargs):
"""Decorator for __init__ that adds the definition for a system preparation
parameter in an instance of an os_type class
"""
- extra = kargs
+ extra = kwargs
def wrapper(init):
@wraps(init)
@@ -196,7 +196,7 @@ def del_sysprep_param(name):
class OSBase(object):
"""Basic operating system class"""
- def __init__(self, image, **kargs):
+ def __init__(self, image, **kwargs):
self.image = image
self.root = image.root
@@ -206,8 +206,8 @@ class OSBase(object):
if not hasattr(self, 'sysprep_params'):
self.sysprep_params = {}
- if 'sysprep_params' in kargs:
- for key, val in kargs['sysprep_params'].items():
+ if 'sysprep_params' in kwargs:
+ for key, val in kwargs['sysprep_params'].items():
if key not in self.sysprep_params:
self.out.warn("Ignoring invalid `%s' parameter." % key)
continue
@@ -504,7 +504,7 @@ class OSBase(object):
"""List the name of all files recursively under a directory"""
return self.image.g.find(directory)
- def _foreach_file(self, directory, action, **kargs):
+ def _foreach_file(self, directory, action, **kwargs):
"""Perform an action recursively on all files under a directory.
The following options are allowed:
@@ -522,16 +522,16 @@ class OSBase(object):
self.out.warn("Directory: `%s' does not exist!" % directory)
return
- maxdepth = None if 'maxdepth' not in kargs else kargs['maxdepth']
+ maxdepth = None if 'maxdepth' not in kwargs else kwargs['maxdepth']
if maxdepth == 0:
return
# maxdepth -= 1
maxdepth = None if maxdepth is None else maxdepth - 1
- kargs['maxdepth'] = maxdepth
+ kwargs['maxdepth'] = maxdepth
- exclude = None if 'exclude' not in kargs else kargs['exclude']
- ftype = None if 'ftype' not in kargs else kargs['ftype']
+ exclude = None if 'exclude' not in kwargs else kwargs['exclude']
+ ftype = None if 'ftype' not in kwargs else kwargs['ftype']
has_ftype = lambda x, y: y is None and True or x['ftyp'] == y
for f in self.image.g.readdir(directory):
@@ -544,7 +544,7 @@ class OSBase(object):
continue
if has_ftype(f, 'd'):
- self._foreach_file(full_path, action, **kargs)
+ self._foreach_file(full_path, action, **kwargs)
if has_ftype(f, ftype):
action(full_path)
diff --git a/image_creator/os_type/linux.py b/image_creator/os_type/linux.py
index c5b82a0..cfaa199 100644
--- a/image_creator/os_type/linux.py
+++ b/image_creator/os_type/linux.py
@@ -25,8 +25,8 @@ import time
class Linux(Unix):
"""OS class for Linux"""
- def __init__(self, image, **kargs):
- super(Linux, self).__init__(image, **kargs)
+ def __init__(self, image, **kwargs):
+ super(Linux, self).__init__(image, **kwargs)
self._uuid = dict()
self._persistent = re.compile('/dev/[hsv]d[a-z][1-9]*')
diff --git a/image_creator/os_type/unsupported.py b/image_creator/os_type/unsupported.py
index 93b711f..6b8d9cb 100644
--- a/image_creator/os_type/unsupported.py
+++ b/image_creator/os_type/unsupported.py
@@ -22,8 +22,8 @@ from image_creator.os_type import OSBase
class Unsupported(OSBase):
"""OS class for unsupported OSs"""
- def __init__(self, image, **kargs):
- super(Unsupported, self).__init__(image, **kargs)
+ def __init__(self, image, **kwargs):
+ super(Unsupported, self).__init__(image, **kwargs)
def collect_metadata(self):
"""Collect metadata about the OS"""
diff --git a/image_creator/os_type/windows/__init__.py b/image_creator/os_type/windows/__init__.py
index 2117d8b..b73ec7f 100644
--- a/image_creator/os_type/windows/__init__.py
+++ b/image_creator/os_type/windows/__init__.py
@@ -241,8 +241,8 @@ class Windows(OSBase):
check=virtio_dir_check, hidden=True)
@add_sysprep_param(
'virtio_timeout', 'posint', 900, DESCR['virtio_timeout'])
- def __init__(self, image, **kargs):
- super(Windows, self).__init__(image, **kargs)
+ def __init__(self, image, **kwargs):
+ super(Windows, self).__init__(image, **kwargs)
# The commit with the following message was added in
# libguestfs 1.17.18 and was backported in version 1.16.11:
diff --git a/image_creator/os_type/windows/registry.py b/image_creator/os_type/windows/registry.py
index e8650c5..6b55927 100644
--- a/image_creator/os_type/windows/registry.py
+++ b/image_creator/os_type/windows/registry.py
@@ -483,7 +483,7 @@ class Registry(object):
return old
- def _foreach_account(self, write=False, **kargs):
+ def _foreach_account(self, write=False, **kwargs):
"""Performs an action on the RID node of a user or a group in the
registry, for every user/group found in the userlist/grouplist.
If userlist/grouplist is empty, it performs the action on all
@@ -516,11 +516,12 @@ class Registry(object):
action(hive, name, rid_node)
- userlist = kargs['userlist'] if 'userlist' in kargs else None
- useraction = kargs['useraction'] if 'useraction' in kargs else None
+ userlist = kwargs['userlist'] if 'userlist' in kwargs else None
+ useraction = kwargs['useraction'] if 'useraction' in kwargs else None
- grouplist = kargs['grouplist'] if 'grouplist' in kargs else None
- groupaction = kargs['groupaction'] if 'groupaction' in kargs else None
+ grouplist = kwargs['grouplist'] if 'grouplist' in kwargs else None
+ groupaction = \
+ kwargs['groupaction'] if 'groupaction' in kwargs else None
if userlist is not None:
assert useraction is not None
--
GitLab