summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@gmail.com>2016-06-07 10:59:27 -0700
committerJoshua Harlow <harlowja@gmail.com>2016-06-07 10:59:27 -0700
commit6d0e6068f2692fd34c3c5cc93af7ec8ef5be4711 (patch)
tree40742ac517bd6f9b56724ef39fbe89d54ffbfc9c
parent600ce494084368c511848c00fff7220255b14e6b (diff)
downloadvyos-cloud-init-6d0e6068f2692fd34c3c5cc93af7ec8ef5be4711.tar.gz
vyos-cloud-init-6d0e6068f2692fd34c3c5cc93af7ec8ef5be4711.zip
For now just remove compat.py module
Let's reduce the size of this change for now.
-rw-r--r--cloudinit/net/cmdline.py10
-rw-r--r--cloudinit/net/compat.py51
-rw-r--r--cloudinit/net/network_state.py4
3 files changed, 9 insertions, 56 deletions
diff --git a/cloudinit/net/cmdline.py b/cloudinit/net/cmdline.py
index 187f7026..822a020b 100644
--- a/cloudinit/net/cmdline.py
+++ b/cloudinit/net/cmdline.py
@@ -21,16 +21,20 @@ import glob
import gzip
import io
import shlex
+import sys
+
+import six
-from . import compat
from . import get_devicelist
from . import sys_netdev_info
from cloudinit import util
+PY26 = sys.version_info[0:2] == (2, 6)
+
def _shlex_split(blob):
- if compat.PY26 and isinstance(blob, compat.text_type):
+ if PY26 and isinstance(blob, six.text_type):
# Older versions don't support unicode input
blob = blob.encode("utf8")
return shlex.split(blob)
@@ -42,7 +46,7 @@ def _load_shell_content(content, add_empty=False, empty_val=None):
then add entries in to the returned dictionary for 'VAR='
variables. Set their value to empty_val."""
data = {}
- for line in shlex.split(content):
+ for line in _shlex_split(content):
key, value = line.split("=", 1)
if not value:
value = empty_val
diff --git a/cloudinit/net/compat.py b/cloudinit/net/compat.py
deleted file mode 100644
index 8bf92ef5..00000000
--- a/cloudinit/net/compat.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# Curtin is free software: you can redistribute it and/or modify it under
-# the terms of the GNU Affero General Public License as published by the
-# Free Software Foundation, either version 3 of the License, or (at your
-# option) any later version.
-#
-# Curtin is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
-# more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with Curtin. If not, see <http://www.gnu.org/licenses/>.
-
-# Mini six like module (so that this code can be more easily extracted).
-
-import sys
-
-PY26 = sys.version_info[0:2] == (2, 6)
-PY27 = sys.version_info[0:2] == (2, 7)
-PY2 = PY26 or PY27
-PY3 = sys.version_info[0:2] >= (3, 0)
-
-if PY3:
- text_type = str
- binary_type = bytes
- string_types = (text_type, text_type)
- import io
- StringIO = io.StringIO
-else:
- text_type = unicode
- binary_type = bytes
- string_types = (binary_type, text_type)
- from StringIO import StringIO # noqa
-
-
-# Taken from six (remove when we can actually directly use six)
-
-def add_metaclass(metaclass):
- """Class decorator for creating a class with a metaclass."""
- def wrapper(cls):
- orig_vars = cls.__dict__.copy()
- slots = orig_vars.get('__slots__')
- if slots is not None:
- if isinstance(slots, str):
- slots = [slots]
- for slots_var in slots:
- orig_vars.pop(slots_var)
- orig_vars.pop('__dict__', None)
- orig_vars.pop('__weakref__', None)
- return metaclass(cls.__name__, cls.__bases__, orig_vars)
- return wrapper
diff --git a/cloudinit/net/network_state.py b/cloudinit/net/network_state.py
index 1e82e75d..a8be5e26 100644
--- a/cloudinit/net/network_state.py
+++ b/cloudinit/net/network_state.py
@@ -19,7 +19,7 @@ import copy
import functools
import logging
-from . import compat
+import six
from cloudinit import util
@@ -113,7 +113,7 @@ class CommandHandlerMeta(type):
parents, dct)
-@compat.add_metaclass(CommandHandlerMeta)
+@six.add_metaclass(CommandHandlerMeta)
class NetworkState(object):
initial_network_state = {