Merge pull request #49 from salt-formulas/maxarnold-salt20183-fix
Maxarnold salt20183 fix (WIP)
diff --git a/.travis.yml b/.travis.yml
index 2a41776..b060639 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -44,7 +44,7 @@
# To test example models with kitchen:
- export PYTHON_VERSION=$TRAVIS_PYTHON_VERSION
- kitchen list
-- if [ "$PYTHON_VERSION" = "2.7" ]; then kitchen test; fi
+- kitchen test
# NOTE: travis stage builds, below saved for future reference
#jobs:
diff --git a/reclass.py b/reclass.py
index a0d8eb8..9c71a10 100755
--- a/reclass.py
+++ b/reclass.py
@@ -6,6 +6,10 @@
# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
import reclass.cli
reclass.cli.main()
diff --git a/reclass/__init__.py b/reclass/__init__.py
index a79c8e1..3739b5e 100644
--- a/reclass/__init__.py
+++ b/reclass/__init__.py
@@ -6,11 +6,14 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
-from reclass.output import OutputLoader
-from reclass.storage.loader import StorageBackendLoader
-from reclass.storage.memcache_proxy import MemcacheProxy
-
+from .output import OutputLoader
+from .storage.loader import StorageBackendLoader
+from .storage.memcache_proxy import MemcacheProxy
def get_storage(storage_type, nodes_uri, classes_uri, **kwargs):
storage_class = StorageBackendLoader(storage_type).load()
diff --git a/reclass/adapters/__init__.py b/reclass/adapters/__init__.py
index 8a17572..06edb64 100755
--- a/reclass/adapters/__init__.py
+++ b/reclass/adapters/__init__.py
@@ -5,4 +5,8 @@
#
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
-#
+
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
diff --git a/reclass/adapters/ansible.py b/reclass/adapters/ansible.py
index f6e9af3..abf7df2 100755
--- a/reclass/adapters/ansible.py
+++ b/reclass/adapters/ansible.py
@@ -14,6 +14,11 @@
# The ansible adapter has received little testing and may not work at all now.
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
import os, sys, posix, optparse
from six import iteritems
@@ -89,9 +94,9 @@
data = groups
- print output(data, options.output, options.pretty_print, options.no_refs)
+ print(output(data, options.output, options.pretty_print, options.no_refs))
- except ReclassException, e:
+ except ReclassException as e:
e.exit_with_message(sys.stderr)
sys.exit(posix.EX_OK)
diff --git a/reclass/adapters/salt.py b/reclass/adapters/salt.py
index 31179ff..ce4e792 100755
--- a/reclass/adapters/salt.py
+++ b/reclass/adapters/salt.py
@@ -6,6 +6,10 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
import os, sys, posix
@@ -122,9 +126,9 @@
class_mappings=class_mappings,
**defaults)
- print output(data, options.output, options.pretty_print, options.no_refs)
+ print(output(data, options.output, options.pretty_print, options.no_refs))
- except ReclassException, e:
+ except ReclassException as e:
e.exit_with_message(sys.stderr)
sys.exit(posix.EX_OK)
diff --git a/reclass/cli.py b/reclass/cli.py
index f0b6069..44694c5 100644
--- a/reclass/cli.py
+++ b/reclass/cli.py
@@ -6,6 +6,10 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
import sys, os, posix
diff --git a/reclass/config.py b/reclass/config.py
index e9bb43b..1a6ba81 100644
--- a/reclass/config.py
+++ b/reclass/config.py
@@ -6,13 +6,17 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
import yaml, os, optparse, posix, sys
-import errors
-from defaults import *
-from constants import MODE_NODEINFO, MODE_INVENTORY
-from reclass import get_path_mangler
+from . import errors, get_path_mangler
+from .defaults import *
+from .constants import MODE_NODEINFO, MODE_INVENTORY
+
def make_db_options_group(parser, defaults={}):
ret = optparse.OptionGroup(parser, 'Database options',
@@ -171,7 +175,7 @@
def vvv(msg):
- #print >>sys.stderr, msg
+ #print(msg, file=sys.stderr)
pass
@@ -180,8 +184,8 @@
for d in dirs:
f = os.path.join(d, filename)
if os.access(f, os.R_OK):
- vvv('Using config file: {0}'.format(f))
- return yaml.safe_load(file(f))
+ vvv('Using config file: {0}'.format(str(f)))
+ return yaml.safe_load(open(f))
elif os.path.isfile(f):
raise PermissionsError('cannot read %s' % f)
return {}
diff --git a/reclass/constants.py b/reclass/constants.py
index f69fa8c..58f7769 100644
--- a/reclass/constants.py
+++ b/reclass/constants.py
@@ -6,6 +6,11 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
class _Constant(object):
diff --git a/reclass/core.py b/reclass/core.py
index 1a08db8..d3d6187 100644
--- a/reclass/core.py
+++ b/reclass/core.py
@@ -6,6 +6,10 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
import copy
import time
@@ -24,10 +28,6 @@
from reclass.errors import MappingFormatError, ClassNameResolveError, ClassNotFound, InvQueryClassNameResolveError, InvQueryClassNotFound, InvQueryError, InterpolationError, ResolveError
from reclass.values.parser import Parser
-try:
- basestring
-except NameError:
- basestring = str
class Core(object):
@@ -130,7 +130,7 @@
if self._cnf_r.match(klass):
if self._settings.ignore_class_notfound_warning:
# TODO, add logging handler
- print >>sys.stderr, "[WARNING] Reclass class not found: '%s'. Skipped!" % klass
+ print("[WARNING] Reclass class not found: '%s'. Skipped!" % klass, file=sys.stderr)
continue
e.nodename = nodename
e.uri = entity.uri
@@ -151,7 +151,7 @@
def _get_automatic_parameters(self, nodename, environment):
if self._settings.automatic_parameters:
- return Parameters({ '_reclass_': { 'name': { 'full': nodename, 'short': str.split(nodename, '.')[0] },
+ return Parameters({ '_reclass_': { 'name': { 'full': nodename, 'short': nodename.split('.')[0] },
'environment': environment } }, self._settings, '__auto__')
else:
return Parameters({}, self._settings, '')
diff --git a/reclass/datatypes/__init__.py b/reclass/datatypes/__init__.py
index 48c4a8b..78c110b 100644
--- a/reclass/datatypes/__init__.py
+++ b/reclass/datatypes/__init__.py
@@ -6,6 +6,11 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
from .applications import Applications
from .classes import Classes
from .entity import Entity
diff --git a/reclass/datatypes/applications.py b/reclass/datatypes/applications.py
index 3c7afce..8c6ed15 100644
--- a/reclass/datatypes/applications.py
+++ b/reclass/datatypes/applications.py
@@ -6,6 +6,11 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
from .classes import Classes
@@ -61,4 +66,4 @@
contents = self._items + \
['%s%s' % (self._negation_prefix, i) for i in self._negations]
return "%s(%r, %r)" % (self.__class__.__name__, contents,
- self._negation_prefix)
+ str(self._negation_prefix))
diff --git a/reclass/datatypes/classes.py b/reclass/datatypes/classes.py
index 090ed70..33d9b93 100644
--- a/reclass/datatypes/classes.py
+++ b/reclass/datatypes/classes.py
@@ -6,6 +6,15 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
+#try:
+# from types import StringTypes
+#except ImportError:
+# StringTypes = (str, )
import six
import os
@@ -52,6 +61,7 @@
self.append_if_new(i)
def _assert_is_string(self, item):
+ #if not isinstance(item, StringTypes):
if not isinstance(item, six.string_types):
raise TypeError('%s instances can only contain strings, '\
'not %s' % (self.__class__.__name__, type(item)))
diff --git a/reclass/datatypes/entity.py b/reclass/datatypes/entity.py
index b43ac72..38360b5 100644
--- a/reclass/datatypes/entity.py
+++ b/reclass/datatypes/entity.py
@@ -6,6 +6,11 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
from .classes import Classes
from .applications import Applications
from .exports import Exports
diff --git a/reclass/datatypes/exports.py b/reclass/datatypes/exports.py
index 971befa..7f21295 100644
--- a/reclass/datatypes/exports.py
+++ b/reclass/datatypes/exports.py
@@ -3,6 +3,10 @@
#
# This file is part of reclass (http://github.com/madduck/reclass)
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
import copy
diff --git a/reclass/datatypes/parameters.py b/reclass/datatypes/parameters.py
index 6ad0d27..e58a1b1 100644
--- a/reclass/datatypes/parameters.py
+++ b/reclass/datatypes/parameters.py
@@ -7,6 +7,16 @@
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
+#try:
+# from types import StringTypes
+#except ImportError:
+# StringTypes = (str, )
+
import copy
import sys
import types
diff --git a/reclass/datatypes/tests/__init__.py b/reclass/datatypes/tests/__init__.py
index e69de29..9aaaf25 100644
--- a/reclass/datatypes/tests/__init__.py
+++ b/reclass/datatypes/tests/__init__.py
@@ -0,0 +1,5 @@
+# -*- coding: utf-8
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
diff --git a/reclass/datatypes/tests/test_applications.py b/reclass/datatypes/tests/test_applications.py
index 6ae07cc..5c896f0 100644
--- a/reclass/datatypes/tests/test_applications.py
+++ b/reclass/datatypes/tests/test_applications.py
@@ -6,8 +6,14 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
from reclass.datatypes import Applications, Classes
import unittest
+
try:
import unittest.mock as mock
except ImportError:
diff --git a/reclass/datatypes/tests/test_classes.py b/reclass/datatypes/tests/test_classes.py
index 33d179f..8d396e0 100644
--- a/reclass/datatypes/tests/test_classes.py
+++ b/reclass/datatypes/tests/test_classes.py
@@ -6,9 +6,15 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
from reclass.datatypes import Classes
from reclass.datatypes.classes import INVALID_CHARACTERS_FOR_CLASSNAMES
import unittest
+
try:
import unittest.mock as mock
except ImportError:
diff --git a/reclass/datatypes/tests/test_entity.py b/reclass/datatypes/tests/test_entity.py
index f398d51..b09e904 100644
--- a/reclass/datatypes/tests/test_entity.py
+++ b/reclass/datatypes/tests/test_entity.py
@@ -6,11 +6,16 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
from reclass.settings import Settings
from reclass.datatypes import Entity, Classes, Parameters, Applications, Exports
from reclass.errors import ResolveError
import unittest
+
try:
import unittest.mock as mock
except ImportError:
diff --git a/reclass/datatypes/tests/test_exports.py b/reclass/datatypes/tests/test_exports.py
index 33eccbe..6a6dcde 100644
--- a/reclass/datatypes/tests/test_exports.py
+++ b/reclass/datatypes/tests/test_exports.py
@@ -3,6 +3,10 @@
#
# This file is part of reclass (http://github.com/madduck/reclass)
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
from reclass.settings import Settings
from reclass.datatypes import Exports, Parameters
diff --git a/reclass/datatypes/tests/test_parameters.py b/reclass/datatypes/tests/test_parameters.py
index 9b788dc..fb4a11b 100644
--- a/reclass/datatypes/tests/test_parameters.py
+++ b/reclass/datatypes/tests/test_parameters.py
@@ -6,6 +6,10 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
import copy
@@ -15,6 +19,7 @@
from reclass.datatypes import Parameters
from reclass.errors import InfiniteRecursionError, InterpolationError, ResolveError, ResolveErrorList
import unittest
+
try:
import unittest.mock as mock
except ImportError:
diff --git a/reclass/defaults.py b/reclass/defaults.py
index 408307d..5dbd94b 100644
--- a/reclass/defaults.py
+++ b/reclass/defaults.py
@@ -6,6 +6,11 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
import os, sys
from .version import RECLASS_NAME
diff --git a/reclass/errors.py b/reclass/errors.py
index 349e242..800a2f8 100644
--- a/reclass/errors.py
+++ b/reclass/errors.py
@@ -6,6 +6,10 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
import posix, sys
import traceback
@@ -39,14 +43,12 @@
def exit_with_message(self, out=sys.stderr):
if self._full_traceback:
t, v, tb = sys.exc_info()
- print >>out, 'Full Traceback:'
+ print('Full Traceback', file=out)
for l in traceback.format_tb(tb):
- print >>out, l,
- print >>out
+ print(l, file=out)
if self._traceback:
- print >>out, self._traceback
- print >>out, self.message
- print >>out
+ print(self._traceback, file=out)
+ print(self.message, file=out)
sys.exit(self.rc)
diff --git a/reclass/output/__init__.py b/reclass/output/__init__.py
index 42fdb0b..000952c 100644
--- a/reclass/output/__init__.py
+++ b/reclass/output/__init__.py
@@ -6,7 +6,10 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
-
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
class OutputterBase(object):
@@ -14,7 +17,7 @@
pass
def dump(self, data, pretty_print=False):
- raise NotImplementedError('dump() method not implemented.')
+ raise NotImplementedError("dump() method not implemented.")
class OutputLoader(object):
@@ -24,7 +27,7 @@
try:
self._module = __import__(self._name, globals(), locals(), self._name)
except ImportError:
- raise NotImplementedError
+ raise NotImplementedError()
def load(self, attr='Outputter'):
klass = getattr(self._module, attr, None)
diff --git a/reclass/output/json_outputter.py b/reclass/output/json_outputter.py
index 8c79039..5d4cfd4 100644
--- a/reclass/output/json_outputter.py
+++ b/reclass/output/json_outputter.py
@@ -6,9 +6,15 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
from reclass.output import OutputterBase
import json
+
class Outputter(OutputterBase):
def dump(self, data, pretty_print=False, no_refs=False):
diff --git a/reclass/output/yaml_outputter.py b/reclass/output/yaml_outputter.py
index ef62979..05519c6 100644
--- a/reclass/output/yaml_outputter.py
+++ b/reclass/output/yaml_outputter.py
@@ -6,11 +6,17 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
from reclass.output import OutputterBase
import yaml
_SafeDumper = yaml.CSafeDumper if yaml.__with_libyaml__ else yaml.SafeDumper
+
class Outputter(OutputterBase):
def dump(self, data, pretty_print=False, no_refs=False):
@@ -19,6 +25,7 @@
else:
return yaml.dump(data, default_flow_style=not pretty_print, Dumper=_SafeDumper)
+
class ExplicitDumper(_SafeDumper):
"""
A dumper that will never emit aliases.
diff --git a/reclass/settings.py b/reclass/settings.py
index e3fc26e..6e35dd2 100644
--- a/reclass/settings.py
+++ b/reclass/settings.py
@@ -1,11 +1,15 @@
+# -*- coding: utf-8
+
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
import copy
import reclass.values.parser_funcs
from reclass.defaults import *
-try:
- basestring
-except NameError:
- basestring = str
+from six import string_types
class Settings(object):
@@ -27,7 +31,7 @@
self.ignore_class_notfound = options.get('ignore_class_notfound', OPT_IGNORE_CLASS_NOTFOUND)
self.ignore_class_notfound_regexp = options.get('ignore_class_notfound_regexp', OPT_IGNORE_CLASS_NOTFOUND_REGEXP)
- if isinstance(self.ignore_class_notfound_regexp, basestring):
+ if isinstance(self.ignore_class_notfound_regexp, string_types):
self.ignore_class_notfound_regexp = [ self.ignore_class_notfound_regexp ]
self.ignore_class_notfound_warning = options.get('ignore_class_notfound_warning', OPT_IGNORE_CLASS_NOTFOUND_WARNING)
diff --git a/reclass/storage/__init__.py b/reclass/storage/__init__.py
index f49ac16..3b46a2a 100644
--- a/reclass/storage/__init__.py
+++ b/reclass/storage/__init__.py
@@ -6,6 +6,11 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
class NodeStorageBase(object):
diff --git a/reclass/storage/common.py b/reclass/storage/common.py
index 6a77fc8..7de71d0 100644
--- a/reclass/storage/common.py
+++ b/reclass/storage/common.py
@@ -1,3 +1,9 @@
+# -*- coding: utf-8
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
import os
class NameMangler:
diff --git a/reclass/storage/loader.py b/reclass/storage/loader.py
index 10ca74c..aab554a 100644
--- a/reclass/storage/loader.py
+++ b/reclass/storage/loader.py
@@ -6,16 +6,20 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
-import importlib
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+from importlib import import_module
class StorageBackendLoader(object):
def __init__(self, storage_name):
- self._name = 'reclass.storage.' + storage_name
+ self._name = str('reclass.storage.' + storage_name)
try:
- self._module = importlib.import_module(self._name)
- except ImportError:
+ self._module = import_module(self._name)
+ except ImportError as e:
raise NotImplementedError
def load(self, klassname='ExternalNodeStorage'):
diff --git a/reclass/storage/memcache_proxy.py b/reclass/storage/memcache_proxy.py
index 8c5e441..cd90fdd 100644
--- a/reclass/storage/memcache_proxy.py
+++ b/reclass/storage/memcache_proxy.py
@@ -6,6 +6,10 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
from reclass.storage import NodeStorageBase
diff --git a/reclass/storage/mixed/__init__.py b/reclass/storage/mixed/__init__.py
index 990c931..6324c74 100644
--- a/reclass/storage/mixed/__init__.py
+++ b/reclass/storage/mixed/__init__.py
@@ -2,6 +2,10 @@
# -*- coding: utf-8 -*-
#
# This file is part of reclass
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
import collections
import copy
diff --git a/reclass/storage/tests/__init__.py b/reclass/storage/tests/__init__.py
index e69de29..9aaaf25 100644
--- a/reclass/storage/tests/__init__.py
+++ b/reclass/storage/tests/__init__.py
@@ -0,0 +1,5 @@
+# -*- coding: utf-8
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
diff --git a/reclass/storage/tests/test_loader.py b/reclass/storage/tests/test_loader.py
index 6bef87f..12cdec3 100644
--- a/reclass/storage/tests/test_loader.py
+++ b/reclass/storage/tests/test_loader.py
@@ -6,10 +6,16 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
from reclass.storage.loader import StorageBackendLoader
import unittest
+
class TestLoader(unittest.TestCase):
def test_load(self):
diff --git a/reclass/storage/tests/test_memcache_proxy.py b/reclass/storage/tests/test_memcache_proxy.py
index a47c29d..24acf20 100644
--- a/reclass/storage/tests/test_memcache_proxy.py
+++ b/reclass/storage/tests/test_memcache_proxy.py
@@ -6,17 +6,23 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
from reclass.settings import Settings
from reclass.storage.memcache_proxy import MemcacheProxy
from reclass.storage import NodeStorageBase
import unittest
+
try:
import unittest.mock as mock
except ImportError:
import mock
+
class TestMemcacheProxy(unittest.TestCase):
def setUp(self):
diff --git a/reclass/storage/tests/test_yamldata.py b/reclass/storage/tests/test_yamldata.py
index d8129ce..5c48db6 100644
--- a/reclass/storage/tests/test_yamldata.py
+++ b/reclass/storage/tests/test_yamldata.py
@@ -3,6 +3,10 @@
#
# This file is part of reclass (http://github.com/madduck/reclass)
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
from reclass.storage.yamldata import YamlData
diff --git a/reclass/storage/yaml_fs/__init__.py b/reclass/storage/yaml_fs/__init__.py
index 83f3666..a102f31 100644
--- a/reclass/storage/yaml_fs/__init__.py
+++ b/reclass/storage/yaml_fs/__init__.py
@@ -6,6 +6,11 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
import os, sys
import fnmatch
import yaml
@@ -21,7 +26,7 @@
STORAGE_NAME = 'yaml_fs'
def vvv(msg):
- #print >>sys.stderr, msg
+ #print(msg, file=sys.stderr)
pass
def path_mangler(inventory_base_uri, nodes_uri, classes_uri):
diff --git a/reclass/storage/yaml_fs/directory.py b/reclass/storage/yaml_fs/directory.py
index 614e1c3..a8916b3 100644
--- a/reclass/storage/yaml_fs/directory.py
+++ b/reclass/storage/yaml_fs/directory.py
@@ -6,6 +6,11 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
import os
from reclass.errors import NotFoundError
@@ -13,7 +18,7 @@
FILE_EXTENSION = '.yml'
def vvv(msg):
- #print >>sys.stderr, msg
+ #print(msg, file=sys.stderr)
pass
diff --git a/reclass/storage/yaml_git/__init__.py b/reclass/storage/yaml_git/__init__.py
index 86c1247..c26ef77 100644
--- a/reclass/storage/yaml_git/__init__.py
+++ b/reclass/storage/yaml_git/__init__.py
@@ -2,6 +2,10 @@
# -*- coding: utf-8 -*-
#
# This file is part of reclass
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
import collections
import distutils.version
diff --git a/reclass/storage/yamldata.py b/reclass/storage/yamldata.py
index b11312e..a861154 100644
--- a/reclass/storage/yamldata.py
+++ b/reclass/storage/yamldata.py
@@ -6,6 +6,11 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
from reclass import datatypes
import yaml
import os
diff --git a/reclass/tests/__init__.py b/reclass/tests/__init__.py
index e69de29..9aaaf25 100644
--- a/reclass/tests/__init__.py
+++ b/reclass/tests/__init__.py
@@ -0,0 +1,5 @@
+# -*- coding: utf-8
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
diff --git a/reclass/tests/test_core.py b/reclass/tests/test_core.py
index 9225756..679d6ca 100644
--- a/reclass/tests/test_core.py
+++ b/reclass/tests/test_core.py
@@ -3,6 +3,10 @@
#
# This file is part of reclass (http://github.com/madduck/reclass)
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
import os
diff --git a/reclass/utils/__init__.py b/reclass/utils/__init__.py
index e69de29..9aaaf25 100644
--- a/reclass/utils/__init__.py
+++ b/reclass/utils/__init__.py
@@ -0,0 +1,5 @@
+# -*- coding: utf-8
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
diff --git a/reclass/utils/dictpath.py b/reclass/utils/dictpath.py
index dfb8b32..39b9572 100644
--- a/reclass/utils/dictpath.py
+++ b/reclass/utils/dictpath.py
@@ -6,6 +6,10 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
import six
import re
diff --git a/reclass/utils/tests/__init__.py b/reclass/utils/tests/__init__.py
index e69de29..9aaaf25 100644
--- a/reclass/utils/tests/__init__.py
+++ b/reclass/utils/tests/__init__.py
@@ -0,0 +1,5 @@
+# -*- coding: utf-8
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
diff --git a/reclass/utils/tests/test_dictpath.py b/reclass/utils/tests/test_dictpath.py
index 972dc91..6fbb6b7 100644
--- a/reclass/utils/tests/test_dictpath.py
+++ b/reclass/utils/tests/test_dictpath.py
@@ -6,6 +6,11 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
from reclass.utils.dictpath import DictPath
import unittest
@@ -64,7 +69,7 @@
delim = '%'
s = 'a:b\:b:c'
p = DictPath(delim, s)
- self.assertEqual('%r' % p, 'DictPath(%r, %r)' % (delim, s))
+ self.assertEqual('%r' % p, "DictPath(%r, %r)" % (delim, str(s)))
def test_str(self):
s = 'a:b\:b:c'
diff --git a/reclass/values/__init__.py b/reclass/values/__init__.py
index e69de29..9aaaf25 100644
--- a/reclass/values/__init__.py
+++ b/reclass/values/__init__.py
@@ -0,0 +1,5 @@
+# -*- coding: utf-8
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
diff --git a/reclass/values/compitem.py b/reclass/values/compitem.py
index c6e8863..7928e6f 100644
--- a/reclass/values/compitem.py
+++ b/reclass/values/compitem.py
@@ -3,6 +3,10 @@
#
# This file is part of reclass
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
from reclass.settings import Settings
from .item import Item
diff --git a/reclass/values/dictitem.py b/reclass/values/dictitem.py
index 555bd8f..76cefe2 100644
--- a/reclass/values/dictitem.py
+++ b/reclass/values/dictitem.py
@@ -3,6 +3,10 @@
#
# This file is part of reclass
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
from reclass.settings import Settings
from .item import Item
diff --git a/reclass/values/invitem.py b/reclass/values/invitem.py
index 970321b..37a35cf 100644
--- a/reclass/values/invitem.py
+++ b/reclass/values/invitem.py
@@ -3,11 +3,15 @@
#
# This file is part of reclass
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
import copy
import pyparsing as pp
-from six import iteritems
+from six import iteritems, string_types
from .item import Item
from reclass.settings import Settings
@@ -90,7 +94,7 @@
raise ResolveError(str(path))
def _get_vars(self, var, export, parameter, value):
- if isinstance(var, str):
+ if isinstance(var, string_types):
path = DictPath(self._delimiter, var)
if path.path[0].lower() == 'exports':
export = path
diff --git a/reclass/values/item.py b/reclass/values/item.py
index 57fd0e3..bc507f4 100644
--- a/reclass/values/item.py
+++ b/reclass/values/item.py
@@ -3,6 +3,10 @@
#
# This file is part of reclass
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
from reclass.utils.dictpath import DictPath
diff --git a/reclass/values/listitem.py b/reclass/values/listitem.py
index 1829e32..8f1a21d 100644
--- a/reclass/values/listitem.py
+++ b/reclass/values/listitem.py
@@ -3,6 +3,10 @@
#
# This file is part of reclass
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
from .item import Item
from reclass.settings import Settings
diff --git a/reclass/values/parser.py b/reclass/values/parser.py
index a8adcf0..914e825 100644
--- a/reclass/values/parser.py
+++ b/reclass/values/parser.py
@@ -3,6 +3,10 @@
#
# This file is part of reclass
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
import pyparsing as pp
diff --git a/reclass/values/parser_funcs.py b/reclass/values/parser_funcs.py
index bd5a1ba..46db7cc 100644
--- a/reclass/values/parser_funcs.py
+++ b/reclass/values/parser_funcs.py
@@ -3,6 +3,10 @@
#
# This file is part of reclass
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
import pyparsing as pp
diff --git a/reclass/values/refitem.py b/reclass/values/refitem.py
index 3e3341c..d24eeee 100644
--- a/reclass/values/refitem.py
+++ b/reclass/values/refitem.py
@@ -3,6 +3,10 @@
#
# This file is part of reclass
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
from .item import Item
from reclass.defaults import REFERENCE_SENTINELS
diff --git a/reclass/values/scaitem.py b/reclass/values/scaitem.py
index f4265b5..f3057cb 100644
--- a/reclass/values/scaitem.py
+++ b/reclass/values/scaitem.py
@@ -3,6 +3,10 @@
#
# This file is part of reclass
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
from reclass.settings import Settings
from .item import Item
diff --git a/reclass/values/tests/__init__.py b/reclass/values/tests/__init__.py
index e69de29..16d1248 100644
--- a/reclass/values/tests/__init__.py
+++ b/reclass/values/tests/__init__.py
@@ -0,0 +1,7 @@
+#
+# -*- coding: utf-8
+#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
diff --git a/reclass/values/tests/test_value.py b/reclass/values/tests/test_value.py
index 84403d3..4853340 100644
--- a/reclass/values/tests/test_value.py
+++ b/reclass/values/tests/test_value.py
@@ -6,6 +6,10 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
import pyparsing as pp
diff --git a/reclass/values/value.py b/reclass/values/value.py
index 1a5b450..f87a9b4 100644
--- a/reclass/values/value.py
+++ b/reclass/values/value.py
@@ -3,6 +3,10 @@
#
# This file is part of reclass
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
from .parser import Parser
from .dictitem import DictItem
@@ -10,6 +14,8 @@
from .scaitem import ScaItem
from reclass.errors import InterpolationError
+from six import string_types
+
class Value(object):
_parser = Parser()
@@ -18,7 +24,7 @@
self._settings = settings
self._uri = uri
self._overwrite = False
- if isinstance(value, str):
+ if isinstance(value, string_types):
if parse_string:
try:
self._item = self._parser.parse(value, self._settings)
diff --git a/reclass/values/valuelist.py b/reclass/values/valuelist.py
index bdfa01a..b24bed3 100644
--- a/reclass/values/valuelist.py
+++ b/reclass/values/valuelist.py
@@ -3,6 +3,10 @@
#
# This file is part of reclass
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
from __future__ import print_function
diff --git a/reclass/version.py b/reclass/version.py
index 664fd6f..2e8759c 100644
--- a/reclass/version.py
+++ b/reclass/version.py
@@ -6,6 +6,11 @@
# Copyright © 2007–14 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
RECLASS_NAME = 'reclass'
DESCRIPTION = 'merge data by recursive descent down an ancestry hierarchy (forked extended version)'
VERSION = '1.5.3'
diff --git a/run_tests.py b/run_tests.py
index 1506945..aeccb57 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -6,6 +6,10 @@
# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
import unittest
tests = unittest.TestLoader().discover('reclass')
diff --git a/setup.py b/setup.py
index 5b4b8b6..789b0fd 100644
--- a/setup.py
+++ b/setup.py
@@ -6,6 +6,10 @@
# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
# Released under the terms of the Artistic Licence 2.0
#
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
from reclass.version import *
from setuptools import setup, find_packages