Repository: sotetsuk/memozo

Issue:
implement pickle
```py
@m.pickle()
```

Discussion:

Patch:
diff --git a/memozo/memozo.py b/memozo/memozo.py
index a67bbe5..e4e3311 100644
--- a/memozo/memozo.py
+++ b/memozo/memozo.py
@@ -76,3 +76,32 @@ class Memozo(object):
             return _wrapper
 
         return wrapper
+
+    def pickle(self, name=None, ext='pickle', protocol=None):
+
+        def wrapper(func):
+            _name = func.__name__ if name is None else name
+
+            @functools.wraps(func)
+            def _wrapper(*args, **kwargs):
+                args = utils.get_bound_args(func, *args, **kwargs)
+                args_str = utils.get_args_str(args)
+                sha1 = utils.get_hash(_name, func.__name__, args_str)
+                file_path = os.path.join(self.base_path, "{}_{}.{}".format(_name, sha1, ext))
+
+                if utils.log_exisits(self.base_path, _name, func.__name__, args_str) and os.path.exists(file_path):
+                    with open(file_path, 'rb') as f:
+                        obj = pickle.load(f)
+                    return obj
+
+                obj = func(*args, **kwargs)
+
+                with open(file_path, 'wb') as f:
+                    pickle.dump(obj, f, protocol=protocol)
+                utils.write(self.base_path, _name, func.__name__, args_str)
+
+                return obj
+
+            return _wrapper
+
+        return wrapper


Test patch:
diff --git a/tests/test_memozo.py b/tests/test_memozo.py
index e224e0a..4c39e59 100644
--- a/tests/test_memozo.py
+++ b/tests/test_memozo.py
@@ -1,6 +1,7 @@
 import os
 import unittest
 import codecs
+import pickle
 
 from memozo import Memozo, utils
 
@@ -115,3 +116,30 @@ class TestMemozoGenerator(unittest.TestCase):
     def test_load_data_from_cache(self):
         # TODO(sotetsuk): WRITE THIS TEST
         pass
+
+
+class TestMemozoPickle(unittest.TestCase):
+
+    def test_no_cache_output(self):
+        base_path = './tests/resources'
+        m = Memozo(base_path)
+
+        @m.pickle('pickle_test', protocol=pickle.HIGHEST_PROTOCOL)
+        def pickle_test_func():
+            return {'a': 3, 'b': 5}
+
+        expected = {'a': 3, 'b': 5}
+        actual = pickle_test_func()
+        self.assertTrue(actual == expected)
+
+        sha1 = utils.get_hash('pickle_test', 'pickle_test_func', '')
+        file_path = os.path.join(base_path, "{}_{}.{}".format('pickle_test', sha1, 'pickle'))
+        os.remove(file_path)
+
+    def test_data_cached_collectly(self):
+        # TODO(sotetsuk): WRITE THIS TEST
+        pass
+
+    def test_load_data_from_cache(self):
+        # TODO(sotetsuk): WRITE THIS TEST
+        pass