[rhel6-branch 18/30] Remove python-six dependency.
mulkieran
installerbot-noreply at redhat.com
Thu May 28 21:04:23 UTC 2015
From: Anne Mulhern <amulhern at redhat.com>
Signed-off-by: Anne Mulhern <amulhern at redhat.com>
---
blivet/devicelibs/raid.py | 8 ++------
blivet/devices/container.py | 4 +---
blivet/devices/lvm.py | 4 ++--
blivet/devices/raid.py | 4 +---
blivet/formats/fslabel.py | 4 +---
blivet/formats/fslabeling.py | 4 +---
blivet/i18n.py | 10 ++--------
blivet/size.py | 33 ++++++++++-----------------------
blivet/util.py | 16 ++++------------
python-blivet.spec | 1 -
10 files changed, 24 insertions(+), 64 deletions(-)
diff --git a/blivet/devicelibs/raid.py b/blivet/devicelibs/raid.py
index 0f0f1b4..292c356 100644
--- a/blivet/devicelibs/raid.py
+++ b/blivet/devicelibs/raid.py
@@ -23,8 +23,6 @@
import abc
-from six import add_metaclass
-
from ..errors import RaidError
from ..size import Size
@@ -36,7 +34,6 @@ def div_up(a,b):
"""
return (a + (b - 1))//b
- at add_metaclass(abc.ABCMeta)
class RAIDLevel(object):
"""An abstract class which is the parent of all classes which represent
a RAID level.
@@ -44,6 +41,7 @@ class RAIDLevel(object):
It ensures that RAIDLevel objects will really be singleton objects
by overriding copy methods.
"""
+ __metaclass__ = abc.ABCMeta
name = abc.abstractproperty(doc="The canonical name for this level")
names = abc.abstractproperty(doc="List of recognized names for this level.")
@@ -74,8 +72,6 @@ def __deepcopy__(self, memo):
# pylint: disable=unused-argument
return self
-
- at add_metaclass(abc.ABCMeta)
class RAIDn(RAIDLevel):
"""An abstract class which is the parent of classes which represent a
@@ -101,7 +97,7 @@ class RAIDn(RAIDLevel):
it is defined and using the same name, effectively yielding a
singleton object of the class.
"""
-
+ __metaclass__ = abc.ABCMeta
# ABSTRACT PROPERTIES
level = abc.abstractproperty(doc="A code representing the level")
diff --git a/blivet/devices/container.py b/blivet/devices/container.py
index 612b9fc..4d3d47d 100644
--- a/blivet/devices/container.py
+++ b/blivet/devices/container.py
@@ -21,8 +21,6 @@
import abc
-from six import add_metaclass
-
from .. import errors
from ..storage_log import log_method_call
from ..formats import get_device_format_class
@@ -32,7 +30,6 @@
from .storage import StorageDevice
- at add_metaclass(abc.ABCMeta)
class ContainerDevice(StorageDevice):
""" A device that aggregates a set of member devices.
@@ -49,6 +46,7 @@ class ContainerDevice(StorageDevice):
within :meth:`.deviceaction.ActionAddMember.execute` and
:meth:`.deviceaction.ActionRemoveMember.execute`.
"""
+ __metaclass__ = abc.ABCMeta
_formatClassName = abc.abstractproperty(lambda s: None,
doc="The type of member devices' required format")
diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py
index 1c72c86..53dc6cf 100644
--- a/blivet/devices/lvm.py
+++ b/blivet/devices/lvm.py
@@ -20,7 +20,6 @@
#
from decimal import Decimal
-from six import add_metaclass
import abc
import pprint
import re
@@ -789,7 +788,6 @@ def isNameValid(cls, name):
return True
- at add_metaclass(abc.ABCMeta)
class LVMSnapShotBase(object):
""" Abstract base class for lvm snapshots
@@ -806,6 +804,8 @@ class LVMSnapShotBase(object):
It is also impossible to set the format for a snapshot explicitly as it
always has the same format as its origin.
"""
+ __metaclass__ = abc.ABCMeta
+
_type = "lvmsnapshotbase"
def __init__(self, origin=None, vorigin=False, exists=False):
diff --git a/blivet/devices/raid.py b/blivet/devices/raid.py
index 60fb5a2..27b65ac 100644
--- a/blivet/devices/raid.py
+++ b/blivet/devices/raid.py
@@ -21,16 +21,14 @@
import abc
-from six import add_metaclass
-
from .. import errors
from ..i18n import _, P_
from .storage import StorageDevice
- at add_metaclass(abc.ABCMeta)
class RaidDevice(StorageDevice):
""" Metaclass for devices that support RAID in some form. """
+ __metaclass__ = abc.ABCMeta
def _validateRaidLevel(self, level, parent_diff=0):
""" Returns an error message if the RAID level is invalid for this
diff --git a/blivet/formats/fslabel.py b/blivet/formats/fslabel.py
index 81c18e6..38ddb98 100644
--- a/blivet/formats/fslabel.py
+++ b/blivet/formats/fslabel.py
@@ -22,15 +22,13 @@
import abc
import re
-from six import add_metaclass
-
from .. import errors
- at add_metaclass(abc.ABCMeta)
class FSLabelApp(object):
"""An abstract class that represents actions associated with a
filesystem's labeling application.
"""
+ __metaclass__ = abc.ABCMeta
name = abc.abstractproperty(
doc="The name of the filesystem labeling application.")
diff --git a/blivet/formats/fslabeling.py b/blivet/formats/fslabeling.py
index 2a99c69..da9aeb9 100644
--- a/blivet/formats/fslabeling.py
+++ b/blivet/formats/fslabeling.py
@@ -21,14 +21,12 @@
import abc
-from six import add_metaclass
-
from . import fslabel
- at add_metaclass(abc.ABCMeta)
class FSLabeling(object):
"""An abstract class that represents filesystem labeling actions.
"""
+ __metaclass__ = abc.ABCMeta
default_label = abc.abstractproperty(
doc="Default label set on this filesystem at creation.")
diff --git a/blivet/i18n.py b/blivet/i18n.py
index 1042688..0e01dd0 100644
--- a/blivet/i18n.py
+++ b/blivet/i18n.py
@@ -22,8 +22,6 @@
__all__ = ["_", "N_", "P_"]
import gettext, locale
-import six
-
# Create and cache a translations object for the current LC_MESSAGES value
_cached_translations = {}
def _get_translations():
@@ -44,9 +42,5 @@ def _get_translations():
# yes, pylint, the lambdas are necessary, because I want _get_translations()
# evaluated on every call.
# pylint: disable=unnecessary-lambda
-if six.PY2:
- _ = lambda x: _get_translations().ugettext(x) if x != "" else u""
- P_ = lambda x, y, z: _get_translations().ungettext(x, y, z)
-else:
- _ = lambda x: _get_translations().gettext(x) if x != "" else ""
- P_ = lambda x, y, z: _get_translations().ngettext(x, y, z)
+_ = lambda x: _get_translations().ugettext(x) if x != "" else u""
+P_ = lambda x, y, z: _get_translations().ungettext(x, y, z)
diff --git a/blivet/size.py b/blivet/size.py
index 3261ea5..4263662 100644
--- a/blivet/size.py
+++ b/blivet/size.py
@@ -27,7 +27,6 @@
from decimal import Decimal
from decimal import InvalidOperation
from decimal import ROUND_DOWN, ROUND_UP, ROUND_HALF_UP
-import six
from .errors import SizePlacesError
from .i18n import _, N_
@@ -70,10 +69,7 @@
_BINARY_PREFIXES = [KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB]
_EMPTY_PREFIX = B
-if six.PY2:
- _ASCIIlower_table = string.maketrans(string.ascii_uppercase, string.ascii_lowercase) # pylint: disable=no-member
-else:
- _ASCIIlower_table = str.maketrans(string.ascii_uppercase, string.ascii_lowercase) # pylint: disable=no-member
+_ASCIIlower_table = string.maketrans(string.ascii_uppercase, string.ascii_lowercase) # pylint: disable=no-member
def _lowerASCII(s):
"""Convert a string to lowercase using only ASCII character definitions.
@@ -82,10 +78,7 @@ def _lowerASCII(s):
:returns: lower-cased string
:rtype: str
"""
- if six.PY2:
- return string.translate(s, _ASCIIlower_table) # pylint: disable=no-member
- else:
- return str.translate(s, _ASCIIlower_table) # pylint: disable=no-member
+ return string.translate(s, _ASCIIlower_table) # pylint: disable=no-member
def _makeSpec(prefix, suffix, xlate, lowercase=True):
""" Synthesizes a whole word from prefix and suffix.
@@ -189,10 +182,7 @@ def _parseSpec(spec):
# First try to parse as English.
try:
- if six.PY2:
- spec_ascii = str(specifier.decode("ascii"))
- else:
- spec_ascii = bytes(specifier, 'ascii')
+ spec_ascii = str(specifier.decode("ascii"))
except (UnicodeDecodeError, UnicodeEncodeError):
# String contains non-ascii characters, so can not be English.
pass
@@ -202,13 +192,10 @@ def _parseSpec(spec):
return size * unit.factor
# No English match found, try localized size specs.
- if six.PY2:
- if isinstance(specifier, unicode):
- spec_local = specifier
- else:
- spec_local = specifier.decode("utf-8")
- else:
+ if isinstance(specifier, unicode):
spec_local = specifier
+ else:
+ spec_local = specifier.decode("utf-8")
unit = parseUnits(spec_local, True)
if unit is not None:
@@ -242,11 +229,11 @@ def __new__(cls, value=0, context=None):
If you want to use a spec value to represent a bytes value,
you can use the letter 'b' or 'B' or omit the size specifier.
"""
- if isinstance(value, (six.string_types, bytes)):
+ if isinstance(value, (basestring, bytes)):
size = _parseSpec(value)
elif isinstance(value, float):
size = Decimal(str(value))
- elif isinstance(value, (six.integer_types, Decimal)):
+ elif isinstance(value, (int, long, Decimal)):
size = Decimal(value)
elif isinstance(value, Size):
size = Decimal(value.convertTo())
@@ -342,10 +329,10 @@ def humanReadable(self, max_places=2, strip=True, min_value=1, xlate=True):
if n.humanReadable() == x U and b is the number of bytes in 1 U,
and e = 1/2 * 1/(10^max_places) * b, then x - e < n < x + e.
"""
- if max_places is not None and (max_places < 0 or not isinstance(max_places, six.integer_types)):
+ if max_places is not None and (max_places < 0 or not isinstance(max_places, (int, long))):
raise SizePlacesError("max_places must be None or an non-negative integer value")
- if min_value < 0 or not isinstance(min_value, (six.integer_types, Decimal)):
+ if min_value < 0 or not isinstance(min_value, (int, long, Decimal)):
raise ValueError("min_value must be a precise positive numeric value.")
# Find the smallest prefix which will allow a number less than
diff --git a/blivet/util.py b/blivet/util.py
index 73f2edc..f846543 100644
--- a/blivet/util.py
+++ b/blivet/util.py
@@ -12,8 +12,6 @@
from decimal import Decimal
from contextlib import contextmanager
-import six
-
import logging
log = logging.getLogger("blivet")
program_log = logging.getLogger("program")
@@ -340,7 +338,7 @@ def numeric_type(num):
if num is None:
num = 0
- elif not isinstance(num, (six.integer_types, float, Size, Decimal)):
+ elif not isinstance(num, (int, long, float, Size, Decimal)):
raise ValueError("value (%s) must be either a number or None" % num)
return num
@@ -413,14 +411,11 @@ def stringize(inputstr):
Python 2, it converts unicode into str. The returned str in python 2 is
encoded using utf-8.
"""
- if six.PY2:
- if isinstance(inputstr, unicode):
- inputstr = inputstr.encode('utf-8')
+ if isinstance(inputstr, unicode):
+ inputstr = inputstr.encode('utf-8')
return str(inputstr)
-# Like six.u, but without the part where it raises an exception on unicode
-# objects
def unicodeize(inputstr):
""" Convert strings to a format compatible with Python 2's unicode.
@@ -434,10 +429,7 @@ def unicodeize(inputstr):
in str parameters, but non-ASCII characters in unicode parameters will
be correctly passed through.
"""
- if six.PY2:
- return unicode(inputstr)
- else:
- return str(inputstr)
+ return unicode(inputstr)
##
## Convenience functions for examples and tests
diff --git a/python-blivet.spec b/python-blivet.spec
index 3c2c8aa..20c7be7 100644
--- a/python-blivet.spec
+++ b/python-blivet.spec
@@ -25,7 +25,6 @@ BuildRequires: gettext
BuildRequires: python-setuptools
Requires: python
-Requires: python-six
Requires: util-linux-ng >= %{utillinuxver}
Requires: python-pyudev
Requires: parted >= %{partedver}
--
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/88c454453355ecb760ab720f22302e7e60fa2fb7
More information about the anaconda-patches
mailing list