Purge mergers hierarchy

The rewrite of all the datatypes made the mergers unnecessary, i.e. they
are now integrated with the datatypes.

Signed-off-by: martin f. krafft <madduck@madduck.net>
diff --git a/reclass/mergers/__init__.py b/reclass/mergers/__init__.py
deleted file mode 100644
index 6329757..0000000
--- a/reclass/mergers/__init__.py
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# -*- coding: utf-8 -*-
-#
-# This file is part of reclass (http://github.com/madduck/reclass)
-#
-# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
diff --git a/reclass/mergers/base.py b/reclass/mergers/base.py
deleted file mode 100644
index b9a23dc..0000000
--- a/reclass/mergers/base.py
+++ /dev/null
@@ -1,12 +0,0 @@
-#
-# -*- coding: utf-8 -*-
-#
-# This file is part of reclass (http://github.com/madduck/reclass)
-#
-# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-class BaseMerger(object):
-
-    def merge(self, first, second):
-        raise NotImplementedError
diff --git a/reclass/mergers/dict/__init__.py b/reclass/mergers/dict/__init__.py
deleted file mode 100644
index 8346017..0000000
--- a/reclass/mergers/dict/__init__.py
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# -*- coding: utf-8 -*-
-#
-# This file is part of reclass (http://github.com/madduck/reclass)
-#
-# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-from update import DictUpdate
-from recursive_update import DictRecursiveUpdate
-from recursive_policy_update import DictRecursivePolicyUpdate
diff --git a/reclass/mergers/dict/base.py b/reclass/mergers/dict/base.py
deleted file mode 100644
index ddf764d..0000000
--- a/reclass/mergers/dict/base.py
+++ /dev/null
@@ -1,12 +0,0 @@
-#
-# -*- coding: utf-8 -*-
-#
-# This file is part of reclass (http://github.com/madduck/reclass)
-#
-# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-from reclass.mergers.base import BaseMerger
-
-class BaseDictMerger(BaseMerger):
-    pass
diff --git a/reclass/mergers/dict/recursive_policy_update.py b/reclass/mergers/dict/recursive_policy_update.py
deleted file mode 100644
index e280889..0000000
--- a/reclass/mergers/dict/recursive_policy_update.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# -*- coding: utf-8 -*-
-#
-# This file is part of reclass (http://github.com/madduck/reclass)
-#
-# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-from base import BaseDictMerger
-
-class DictRecursivePolicyUpdate(BaseDictMerger):
-
-    def __init__(self, policy=None):
-        super(DictRecursivePolicyUpdate, self).__init__()
-        if policy is None:
-            first = lambda first, second: first
-            second = lambda first, second: second
-
-            policy = {(dict,dict)       : self.merge,
-                      (list,list)       : lambda x,y: x+y,
-                      (dict,list)       : lambda x,y: self.merge(x, dict(y)),
-                      (dict,type(None)) : first,
-                      (list,type(None)) : first,
-                      None              : second
-                     }
-        self._policy = policy
-
-    def merge(self, first, second):
-        if second is None:
-            return first
-
-        ret = first.copy()
-        for k,v in second.iteritems():
-            if k in ret:
-                lookup = (type(ret[k]), type(v))
-                pfn = self._policy.get(lookup, self._policy.get(None))
-                ret[k] = pfn(ret[k], v)
-            else:
-                ret[k] = v
-        return ret
diff --git a/reclass/mergers/dict/recursive_update.py b/reclass/mergers/dict/recursive_update.py
deleted file mode 100644
index fc1d425..0000000
--- a/reclass/mergers/dict/recursive_update.py
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# -*- coding: utf-8 -*-
-#
-# This file is part of reclass (http://github.com/madduck/reclass)
-#
-# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-from base import BaseDictMerger
-
-class DictRecursiveUpdate(BaseDictMerger):
-
-    def merge(self, first, second):
-        if second is None:
-            return first
-
-        ret = first.copy()
-        for k,v in second.iteritems():
-            if k in ret:
-                if isinstance(ret[k], dict):
-                    if isinstance(v, (list, tuple)):
-                        v = dict(v)
-                    ret[k] = self.merge(ret[k], v)
-                else:
-                    ret[k] = v
-            else:
-                ret[k] = v
-        return ret
diff --git a/reclass/mergers/dict/tests/test_recursive_policy_update.py b/reclass/mergers/dict/tests/test_recursive_policy_update.py
deleted file mode 100644
index e9e1f31..0000000
--- a/reclass/mergers/dict/tests/test_recursive_policy_update.py
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# -*- coding: utf-8 -*-
-#
-# This file is part of reclass (http://github.com/madduck/reclass)
-#
-# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-from test_recursive_update import TestDictRecursiveUpdate
-from reclass.mergers.dict import DictRecursivePolicyUpdate
-
-class TestDictRecursivePolicyUpdate(TestDictRecursiveUpdate):
-
-    def setUp(self):
-        self.merger = DictRecursivePolicyUpdate()
-
-    def test_nested_lists_extend(self):
-        first = {'one': [1,2],
-                 'two': {'one': [1,2]}}
-        second = {'one': [3,4], 
-                  'two': {'one': [3,4]}}
-        ret = self.merger.merge(first, second)
-        assert len(ret['one']) == 4
-        assert ret['one'][2] == 3
-        assert len(ret['two']['one']) == 4
-        assert ret['two']['one'][3] == 4
-
-    def test_merge_with_none(self):
-        first = {1:2,3:4}
-        ret = self.merger.merge(first, None)
-        assert ret == first
diff --git a/reclass/mergers/dict/tests/test_recursive_update.py b/reclass/mergers/dict/tests/test_recursive_update.py
deleted file mode 100644
index 12d2348..0000000
--- a/reclass/mergers/dict/tests/test_recursive_update.py
+++ /dev/null
@@ -1,50 +0,0 @@
-#
-# -*- coding: utf-8 -*-
-#
-# This file is part of reclass (http://github.com/madduck/reclass)
-#
-# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-from test_update import TestDictUpdate
-from reclass.mergers.dict import DictRecursiveUpdate
-
-class TestDictRecursiveUpdate(TestDictUpdate):
-
-    def setUp(self):
-        self.merger = DictRecursiveUpdate()
-
-    def test_simple_recursive_dict_update(self):
-        first = {'one':{1:1,2:3,3:2}}
-        second = {'one':{2:2,3:3,4:4}}
-        ret = self.merger.merge(first, second)
-        assert len(ret) == 1
-        for k,v in ret['one'].iteritems():
-            assert k == v
-
-    def test_complex_recursive_dict_update(self):
-        first = {'one': 1,
-                 'two': {'a':92,'b':94},
-                 'three': {'third':0.33,'two thirds':0.67},
-                 'four': {1:{1:1},2:{2:2},3:{3:4}}
-                }
-        second = {'five': 5,
-                  'one': 1,
-                  'two': {'b':93,'c':94},
-                  'four': {4:{4:4}, 3:{3:3}},
-                 }
-        ret = self.merger.merge(first, second)
-        assert ret['one'] == 1
-        assert len(ret['two']) == 3
-        assert ret['two']['b'] == 93
-        assert len(ret['three']) == 2
-        assert len(ret['four']) == 4
-        for i in range(1,4):
-            assert len(ret['four'][i]) == 1
-            for k,v in ret['four'][i].iteritems():
-                assert k == v
-
-    def test_merge_with_none(self):
-        first = {1:2,3:4}
-        ret = self.merger.merge(first, None)
-        assert ret == first
diff --git a/reclass/mergers/dict/tests/test_update.py b/reclass/mergers/dict/tests/test_update.py
deleted file mode 100644
index 3dcbfd9..0000000
--- a/reclass/mergers/dict/tests/test_update.py
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# -*- coding: utf-8 -*-
-#
-# This file is part of reclass (http://github.com/madduck/reclass)
-#
-# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-from reclass.mergers.dict import DictUpdate
-
-class TestDictUpdate:
-
-    def setUp(self):
-        self.merger = DictUpdate()
-
-    def test_dict_update(self):
-        first = {1:1,2:3,3:2}
-        second = {2:2,3:3,4:4}
-        ret = self.merger.merge(first, second)
-        assert len(ret) == 4
-        for k,v in ret.iteritems():
-            assert k == v
-
-    def test_merge_with_none(self):
-        first = {1:2,3:4}
-        ret = self.merger.merge(first, None)
-        assert ret == first
diff --git a/reclass/mergers/dict/update.py b/reclass/mergers/dict/update.py
deleted file mode 100644
index 69e849d..0000000
--- a/reclass/mergers/dict/update.py
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# -*- coding: utf-8 -*-
-#
-# This file is part of reclass (http://github.com/madduck/reclass)
-#
-# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-from base import BaseDictMerger
-
-class DictUpdate(BaseDictMerger):
-
-    def merge(self, first, second):
-        if second is None:
-            return first
-
-        ret = first.copy()
-        ret.update(second)
-        return ret
diff --git a/reclass/mergers/list/__init__.py b/reclass/mergers/list/__init__.py
deleted file mode 100644
index 51ee818..0000000
--- a/reclass/mergers/list/__init__.py
+++ /dev/null
@@ -1,10 +0,0 @@
-#
-# -*- coding: utf-8 -*-
-#
-# This file is part of reclass (http://github.com/madduck/reclass)
-#
-# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-from extend import ListExtend
-from set import SetExtend
diff --git a/reclass/mergers/list/base.py b/reclass/mergers/list/base.py
deleted file mode 100644
index 9b2388c..0000000
--- a/reclass/mergers/list/base.py
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# -*- coding: utf-8 -*-
-#
-# This file is part of reclass (http://github.com/madduck/reclass)
-#
-# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-from reclass.mergers.base import BaseMerger
-
-class BaseListMerger(BaseMerger):
-
-    def merge(self, first, second):
-        first = [first] if not isinstance(first, list) else first[:]
-        if second is None:
-            return first
-        second = [second] if not isinstance(second, list) else second[:]
-        return self._combine(first, second)
diff --git a/reclass/mergers/list/extend.py b/reclass/mergers/list/extend.py
deleted file mode 100644
index 5c44ac5..0000000
--- a/reclass/mergers/list/extend.py
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# -*- coding: utf-8 -*-
-#
-# This file is part of reclass (http://github.com/madduck/reclass)
-#
-# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-from base import BaseListMerger
-
-class ListExtend(BaseListMerger):
-
-    def _combine(self, first, second):
-        if second is not None:
-            if isinstance(second, list):
-                first.extend(second)
-            else:
-                first.append(second)
-        return first
diff --git a/reclass/mergers/list/set.py b/reclass/mergers/list/set.py
deleted file mode 100644
index 54770a3..0000000
--- a/reclass/mergers/list/set.py
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# -*- coding: utf-8 -*-
-#
-# This file is part of reclass (http://github.com/madduck/reclass)
-#
-# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-from extend import BaseListMerger
-
-class SetExtend(BaseListMerger):
-
-    def _combine(self, first, second):
-        if second is not None:
-            for i in second:
-                if i not in first:
-                    first.append(i)
-        return first
diff --git a/reclass/mergers/list/tests/test_extend.py b/reclass/mergers/list/tests/test_extend.py
deleted file mode 100644
index e65f77a..0000000
--- a/reclass/mergers/list/tests/test_extend.py
+++ /dev/null
@@ -1,71 +0,0 @@
-#
-# -*- coding: utf-8 -*-
-#
-# This file is part of reclass (http://github.com/madduck/reclass)
-#
-# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-from reclass.mergers.list import ListExtend
-
-class TestListExtend:
-
-    def setUp(self):
-        self.merger = ListExtend()
-
-    def _test_merge(self, one, two, target):
-        res = self.merger.merge(one, two)
-        print res, target
-        return res == target
-
-    def test_merge_scalars(self):
-        assert self._test_merge(1, 2, [1,2])
-
-    def test_merge_tuples(self):
-        t1 = (1,2,3)
-        t2 = (6,5,4)
-        target = [t1, t2]
-        assert self._test_merge(t1, t2, target)
-
-    def test_merge_lists(self):
-        l1 = [1,2,3]
-        l2 = [6,5,4]
-        target = l1 + l2
-        assert self._test_merge(l1, l2, target)
-
-    def test_merge_scalar_tuple(self):
-        s = 'one'
-        t = (2,3)
-        target = [s, t]
-        assert self._test_merge(s, t, target)
-
-    def test_merge_scalar_list(self):
-        s = 'foo'
-        l = [1,2,3]
-        target = [s]
-        target.extend(l)
-        assert self._test_merge(s, l, target)
-
-    def test_merge_list_scalar(self):
-        l = [1,2,3]
-        s = 'bar'
-        target = l[:]
-        target.append(s)
-        assert self._test_merge(l, s, target)
-
-    def test_merge_duplicates_scalar(self):
-        s1 = 2
-        s2 = 2
-        target = [2,2]
-        assert self._test_merge(s1, s2, target)
-
-    def test_merge_duplicates_list(self):
-        l1 = [1,2,3]
-        l2 = [3,2,1]
-        target = l1 + l2
-        assert self._test_merge(l1, l2, target)
-
-    def test_merge_with_none(self):
-        first = [1,2,3]
-        ret = self.merger.merge(first, None)
-        assert ret == first
diff --git a/reclass/mergers/list/tests/test_set.py b/reclass/mergers/list/tests/test_set.py
deleted file mode 100644
index 0dc965a..0000000
--- a/reclass/mergers/list/tests/test_set.py
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# -*- coding: utf-8 -*-
-#
-# This file is part of reclass (http://github.com/madduck/reclass)
-#
-# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-from test_extend import TestListExtend
-from reclass.mergers.list import SetExtend
-
-class TestSetExtend(TestListExtend):
-
-    def setUp(self):
-        self.merger = SetExtend()
-
-    def test_merge_duplicates_scalar(self):
-        s1 = 2
-        s2 = 2
-        target = [2]
-        assert self._test_merge(s1, s2, target)
-
-    def test_merge_duplicates_list(self):
-        l1 = [1,2,3]
-        l2 = [3,2,1]
-        target = l1
-        assert self._test_merge(l1, l2, target)
-
-    def test_merge_with_none(self):
-        first = [1,2,3]
-        ret = self.merger.merge(first, None)
-        assert ret == first