avoid using import in methods
diff --git a/reclass/values/compitem.py b/reclass/values/compitem.py
index ddde683..8a22376 100644
--- a/reclass/values/compitem.py
+++ b/reclass/values/compitem.py
@@ -9,6 +9,7 @@
class CompItem(Item):
def __init__(self, items):
+ self.type = Item.COMPOSITE
self._items = items
self._refs = []
self._allRefs = False
diff --git a/reclass/values/dictitem.py b/reclass/values/dictitem.py
index 7bd4da1..1689aed 100644
--- a/reclass/values/dictitem.py
+++ b/reclass/values/dictitem.py
@@ -9,6 +9,7 @@
class DictItem(Item):
def __init__(self, item):
+ self.type = Item.DICTIONARY
self._dict = item
def contents(self):
@@ -18,9 +19,7 @@
return True
def merge_over(self, item, options):
- from scaitem import ScaItem
-
- if isinstance(item, ScaItem):
+ if item.type == Item.SCALAR:
if item.contents() is None or options.allow_dict_over_scalar:
return self
else:
diff --git a/reclass/values/expitem.py b/reclass/values/expitem.py
index 7641441..85253c7 100644
--- a/reclass/values/expitem.py
+++ b/reclass/values/expitem.py
@@ -74,6 +74,7 @@
_parser = _get_parser()
def __init__(self, item, delimiter):
+ self.type = Item.EXPORT
self._delimiter = delimiter
self._type = None
self._refs = []
diff --git a/reclass/values/item.py b/reclass/values/item.py
index 9c2fabf..19d1d34 100644
--- a/reclass/values/item.py
+++ b/reclass/values/item.py
@@ -9,8 +9,12 @@
class Item(object):
- def __init__(self):
- return
+ COMPOSITE = 1
+ DICTIONARY = 2
+ EXPORT = 3
+ LIST = 4
+ REFERENCE = 5
+ SCALAR = 6
def allRefs(self):
return True
diff --git a/reclass/values/listitem.py b/reclass/values/listitem.py
index 57d5fdf..06f1e10 100644
--- a/reclass/values/listitem.py
+++ b/reclass/values/listitem.py
@@ -9,6 +9,7 @@
class ListItem(Item):
def __init__(self, item):
+ self.type = Item.LIST
self._list = item
def contents(self):
@@ -21,13 +22,10 @@
return self._list
def merge_over(self, item, options):
- from scaitem import ScaItem
-
- if isinstance(item, ListItem):
- for i in self._list:
- item._list.append(i)
+ if item.type == Item.LIST:
+ item._list.extend(self._list)
return item
- elif isinstance(item, ScaItem):
+ elif item.type == Item.SCALAR:
if item.contents() is None:
return self
elif options.allow_list_over_scalar:
diff --git a/reclass/values/refitem.py b/reclass/values/refitem.py
index d2a12b5..e841468 100644
--- a/reclass/values/refitem.py
+++ b/reclass/values/refitem.py
@@ -11,6 +11,7 @@
class RefItem(Item):
def __init__(self, items, delimiter):
+ self.type = Item.REFERENCE
self._delimiter = delimiter
self._items = items
self._refs = []
diff --git a/reclass/values/scaitem.py b/reclass/values/scaitem.py
index 941e61b..a1a5a21 100644
--- a/reclass/values/scaitem.py
+++ b/reclass/values/scaitem.py
@@ -9,23 +9,21 @@
class ScaItem(Item):
def __init__(self, value):
+ self.type = Item.SCALAR
self._value = value
def contents(self):
return self._value
def merge_over(self, item, options):
- from dictitem import DictItem
- from listitem import ListItem
-
- if isinstance(item, ScaItem):
+ if item.type == Item.SCALAR:
return self
- elif isinstance(item, ListItem):
+ elif item.type == Item.LIST:
if options.allow_scalar_over_list:
return self
else:
raise TypeError('allow scalar over list = False: cannot merge %s over %s' % (repr(self), repr(item)))
- elif isinstance(item, DictItem):
+ elif item.type == Item.DICTIONARY:
if options.allow_scalar_over_dict:
return self
else: