Exemple #1
0
    def dput(self, uri, value=None):
        data = self.get(uri)
        uri_values = ''
        if value is None:
            uri = uri.split('#')
            uri_values = uri[-1]
            uri = uri[0]
        if data is None or data == '':
            data = {}
        else:
            data = json.loads(data)

        if value is None:
            uri_values = uri_values.split('&')
            for tokens in uri_values:
                v = tokens.split('=')[-1]
                k = tokens.split('=')[0]
                d = self.dot2dict(k, v)
                data = self.data_merge(data, d)
        else:
            jvalues = json.loads(value)
            data = self.data_merge(data, jvalues)
        value = json.dumps(data)

        return self.workspace.put(Path(uri), Value(value))
Exemple #2
0
 def __init__(self, api, root_path, home_path, cachesize):
     self.yaks = api
     self.root = root_path
     self.home = home_path
     self.cachesize = cachesize
     self.workspace = self.yaks.workspace(Path(root_path))
     self.subscriptions = []
Exemple #3
0
 def test_create_delete_workspace(self):
     y = Yaks.login(YSERVER)
     admin = y.admin()
     stid = '123'
     admin.add_storage(stid, {'selector': '/myyaks/**'})
     time.sleep(1)  # TODO remove
     workspace = y.workspace('/myyaks')
     self.assertEqual(workspace.path, Path('/myyaks'))
     admin.remove_storage(stid)
     y.logout()
Exemple #4
0
 def test_path_len(self):
     s = '/this/is/a/path'
     p1 = Path('/this/is/a/path')
     self.assertEqual(len(s), len(p1))
Exemple #5
0
 def test_path_repr(self):
     p1 = Path('/this/is/a/path')
     self.assertEqual(repr(p1), '/this/is/a/path')
Exemple #6
0
 def test_path_hash(self):
     p1 = Path('/this/is/a/path')
     self.assertEqual(hash(p1), hash('/this/is/a/path'))
Exemple #7
0
 def test_path_not_equal(self):
     p1 = Path('/this/is/a/path')
     p2 = '/this/is/not/a/path'
     self.assertNotEqual(p1, p2)
Exemple #8
0
 def test_path_equal(self):
     p1 = Path('/this/is/a/path')
     p2 = Path('/this/is/a/path')
     self.assertEqual(p1, p2)
Exemple #9
0
 def test_to_path(self):
     p = '/yaks'
     p2 = Path('/yaks')
     self.assertEqual(Path.to_path(p), Path('/yaks'))
     self.assertEqual(Path.to_path(p2), Path('/yaks'))
Exemple #10
0
 def test_path_remove_prefix_no_prefix(self):
     p = Path('/this/is/a/path/with/a/prefix')
     p.remove_prefix('/that/is/a/path')
     self.assertEqual(p.to_string(), '/this/is/a/path/with/a/prefix')
Exemple #11
0
 def test_path_prefix(self):
     p = Path('/this/is/a/path/with/a/prefix')
     self.assertTrue(p.is_prefix('/this/is/a/path'))
     self.assertFalse(p.is_prefix('/that/is/a/path'))
Exemple #12
0
 def test_path_check_absolute_ko(self):
     path = Path('this/is/a/relative/path')
     self.assertFalse(path.is_absolute())
Exemple #13
0
 def test_path_check_absolute_ok(self):
     p = Path('/this/is/a/absoliute/path')
     self.assertTrue(p.is_absolute())
Exemple #14
0
 def test_path_check_ok(self):
     p = Path('/this/is/a/path')
     self.assertEqual('/this/is/a/path', p.to_string())
Exemple #15
0
 def put(self, k, v):
     return self.workspace.put(Path(k), Value(v))
Exemple #16
0
 def remove(self, k):
     return self.workspace.remove(Path(k))