[PATCH] Remove requirement on python-six.
David Lehman
dlehman at redhat.com
Fri Sep 5 14:16:49 UTC 2014
Related: rhbz#1075561
---
blivet/devicelibs/raid.py | 6 ++----
blivet/devices.py | 7 +++----
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 | 3 +--
tests/size_test.py | 5 -----
10 files changed, 15 insertions(+), 46 deletions(-)
diff --git a/blivet/devicelibs/raid.py b/blivet/devicelibs/raid.py
index 50d19dc..f2facec 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
@@ -92,6 +89,7 @@ class RAIDn(RAIDLevel):
singleton object of the class.
"""
+ __metaclass__ = abc.ABCMeta
# ABSTRACT PROPERTIES
level = abc.abstractproperty(doc="A code representing the level")
diff --git a/blivet/devices.py b/blivet/devices.py
index c3da7f6..d585023 100644
--- a/blivet/devices.py
+++ b/blivet/devices.py
@@ -28,8 +28,6 @@ import abc
from decimal import Decimal
import re
-from six import add_metaclass
-
# device backend modules
from .devicelibs import mdraid
from .devicelibs import lvm
@@ -2240,7 +2238,6 @@ class LUKSDevice(DMCryptDevice):
data.encrypted = True
super(LUKSDevice, self).populateKSData(data)
- at add_metaclass(abc.ABCMeta)
class ContainerDevice(StorageDevice):
""" A device that aggregates a set of member devices.
@@ -2257,6 +2254,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")
@@ -3131,7 +3129,6 @@ class LVMLogicalVolumeDevice(DMDevice):
return True
- at add_metaclass(abc.ABCMeta)
class LVMSnapShotBase(object):
""" Abstract base class for lvm snapshots
@@ -3148,6 +3145,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/formats/fs.py b/blivet/formats/fs.py
index 06d12d5..7305106 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 f8d7b42..bdd78d0 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 b9f0089..4dbe0ab 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
-import six
from .errors import SizePlacesError
from .i18n import _, P_, N_
@@ -135,14 +134,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)
@@ -163,11 +157,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()
@@ -209,9 +199,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, (unicode, 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 1e28ddc..52e798e 100644
--- a/blivet/util.py
+++ b/blivet/util.py
@@ -10,8 +10,6 @@ import sys
import tempfile
from decimal import Decimal
-import six
-
from .size import Size
import logging
@@ -324,7 +322,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 abbbb0f..c82aeba 100644
--- a/python-blivet.spec
+++ b/python-blivet.spec
@@ -25,7 +25,6 @@ BuildRequires: gettext
BuildRequires: python-setuptools
Requires: python
-Requires: python-six
Requires: pykickstart >= %{pykickstartver}
Requires: util-linux >= %{utillinuxver}
Requires: parted >= %{partedver}
diff --git a/tests/formats_test/fslabeling.py b/tests/formats_test/fslabeling.py
index 22d74ee..a878409 100644
--- a/tests/formats_test/fslabeling.py
+++ b/tests/formats_test/fslabeling.py
@@ -1,18 +1,17 @@
#!/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 e2288e0..289394d 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
-if six.PY3:
- long = int # pylint: disable=redefined-builtin
-
class SizeTestCase(unittest.TestCase):
def testExceptions(self):
zero = Size(0)
--
1.9.3
More information about the anaconda-patches
mailing list