[PATCH 11/13] Remove python-six dependency.
David Lehman
dlehman at redhat.com
Wed May 27 18:16:12 UTC 2015
---
blivet/devicelibs/raid.py | 7 ++-----
blivet/devices/container.py | 4 +---
blivet/devices/lvm.py | 3 +--
blivet/formats/fs.py | 5 -----
blivet/formats/fslabel.py | 4 +---
blivet/formats/fslabeling.py | 4 +---
blivet/size.py | 22 ++++++----------------
blivet/util.py | 4 +---
python-blivet.spec | 1 -
tests/formats_test/fslabeling.py | 4 +---
tests/size_test.py | 5 -----
11 files changed, 14 insertions(+), 49 deletions(-)
diff --git a/blivet/devicelibs/raid.py b/blivet/devicelibs/raid.py
index 50d19dc..2277669 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
def div_up(a,b):
@@ -35,7 +33,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.
@@ -43,6 +40,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.")
@@ -65,7 +63,6 @@ class RAIDLevel(object):
return self
- at add_metaclass(abc.ABCMeta)
class RAIDn(RAIDLevel):
"""An abstract class which is the parent of classes which represent a
@@ -91,7 +88,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 df759e7..d8a1379 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 @@ log = logging.getLogger("blivet")
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 3b4cd36..61e8e26 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
@@ -803,7 +802,6 @@ class LVMLogicalVolumeDevice(DMDevice):
return True
- at add_metaclass(abc.ABCMeta)
class LVMSnapShotBase(object):
""" Abstract base class for lvm snapshots
@@ -820,6 +818,7 @@ 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/formats/fs.py b/blivet/formats/fs.py
index 9c17470..5c3d81a 100644
--- a/blivet/formats/fs.py
+++ b/blivet/formats/fs.py
@@ -25,7 +25,6 @@
from decimal import Decimal
import os
import tempfile
-import six
from . import fslabeling
from ..errors import FormatCreateError, FSError, FSResizeError
@@ -43,10 +42,6 @@ from .. import udev
import logging
log = logging.getLogger("blivet")
-if six.PY3:
- long = int # pylint: disable=redefined-builtin
-
-
fs_configs = {}
kernel_filesystems = []
diff --git a/blivet/formats/fslabel.py b/blivet/formats/fslabel.py
index 2c6fce2..2d35f61 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 ef5b4ae..b9d8cf3 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/size.py b/blivet/size.py
index e010a00..f313a98 100644
--- a/blivet/size.py
+++ b/blivet/size.py
@@ -27,7 +27,6 @@ from collections import namedtuple
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 _, P_, N_
@@ -136,14 +135,9 @@ def _parseSpec(spec):
try:
# This will raise UnicodeDecodeError if specifier contains non-ascii
# characters
- if six.PY2:
- spec_ascii = specifier.decode("ascii")
- # Convert back to a str type to match the _bytes and _prefixes arrays
- spec_ascii = str(spec_ascii)
- else:
- # This will raise UnicodeEncodeError if specifier contains any non-ascii
- # in Python3 `bytes` are new Python2 `str`
- spec_ascii = bytes(specifier, 'ascii')
+ spec_ascii = specifier.decode("ascii")
+ # Convert back to a str type to match the _bytes and _prefixes arrays
+ spec_ascii = str(spec_ascii)
# Use the ASCII-only lowercase mapping
spec_ascii = _lowerASCII(spec_ascii)
@@ -164,11 +158,7 @@ def _parseSpec(spec):
# No English match found, try localized size specs. Accept any utf-8
# character and leave the result as a (unicode object.
- if six.PY2:
- spec_local = specifier.decode("utf-8")
- else:
- # str = unicode in Python3
- spec_local = specifier
+ spec_local = specifier.decode("utf-8")
# Use the locale-specific lowercasing
spec_local = spec_local.lower()
@@ -210,9 +200,9 @@ class Size(Decimal):
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, str):
size = _parseSpec(value)
- elif isinstance(value, (six.integer_types, float, Decimal)):
+ elif isinstance(value, (int, long, float, Decimal)):
size = Decimal(value)
elif isinstance(value, Size):
size = Decimal(value.convertTo("b"))
diff --git a/blivet/util.py b/blivet/util.py
index 90b8515..8c75e6f 100644
--- a/blivet/util.py
+++ b/blivet/util.py
@@ -12,8 +12,6 @@ import uuid
from decimal import Decimal
from contextlib import contextmanager
-import six
-
from .size import Size
import logging
@@ -326,7 +324,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
diff --git a/python-blivet.spec b/python-blivet.spec
index f14b6ef..fb57f06 100644
--- a/python-blivet.spec
+++ b/python-blivet.spec
@@ -26,7 +26,6 @@ BuildRequires: gettext
BuildRequires: python-setuptools
Requires: python
-Requires: python-six
Requires: pykickstart >= %{pykickstartver}
Requires: util-linux >= %{utillinuxver}
Requires: python-pyudev
diff --git a/tests/formats_test/fslabeling.py b/tests/formats_test/fslabeling.py
index 22d74ee..f7386b7 100644
--- a/tests/formats_test/fslabeling.py
+++ b/tests/formats_test/fslabeling.py
@@ -1,18 +1,16 @@
#!/usr/bin/python
import abc
-from six import add_metaclass
from tests import loopbackedtestcase
from blivet.errors import FSError
- at add_metaclass(abc.ABCMeta)
class LabelingAsRoot(loopbackedtestcase.LoopBackedTestCase):
"""Tests various aspects of labeling a filesystem where there
is no easy way to read the filesystem's label once it has been
set and where the filesystem can not be relabeled.
"""
-
+ __metaclass__ = abc.ABCMeta
_fs_class = abc.abstractproperty(
doc="The class of the filesystem being tested on.")
diff --git a/tests/size_test.py b/tests/size_test.py
index 0f2a733..c600083 100644
--- a/tests/size_test.py
+++ b/tests/size_test.py
@@ -23,14 +23,9 @@
import unittest
-import six
-
from blivet.errors import SizePlacesError
from blivet.size import Size, _prefixes, ROUND_UP, ROUND_DOWN, ROUND_DEFAULT, ROUND_HALF_UP
-if six.PY3:
- long = int # pylint: disable=redefined-builtin
-
class SizeTestCase(unittest.TestCase):
def testExceptions(self):
zero = Size(0)
--
2.1.0
More information about the anaconda-patches
mailing list