From d8495cf1f858af7016d582ca2b186644963ad42b Mon Sep 17 00:00:00 2001 From: liuyangc3 Date: Tue, 5 Dec 2017 18:20:24 +0800 Subject: [PATCH] delete --- zstack/newsdk.py | 54 --------------------------------------------- zstack/test_trie.py | 28 ----------------------- 2 files changed, 82 deletions(-) delete mode 100644 zstack/newsdk.py delete mode 100644 zstack/test_trie.py diff --git a/zstack/newsdk.py b/zstack/newsdk.py deleted file mode 100644 index bfeae74..0000000 --- a/zstack/newsdk.py +++ /dev/null @@ -1,54 +0,0 @@ - - -def find_variables_in_path(path): - """ - :type path: str - :return: variables list - """ - if not isinstance(path, str): - raise TypeError("path is not str") - - if path == '': - raise ValueError('empty path') - - if not path.startswith('/'): - raise ValueError("must startswith '/' in '{}'".format(path)) - - subs = path.split('/') - - result = [] - - for i, sub in enumerate(subs): # subs[1:] remove '' before / - if sub == '' and i != 0 and i != len(subs) - 1: - raise ValueError("empty char between slash in '{}'".format(path)) - - if '{' not in sub and '}' not in sub: - continue - - left_count, right_count = sub.count('{'), sub.count('}') - if left_count == 0 and right_count == 0: - continue - - if left_count != right_count: - raise ValueError("brace pair not match in '{}'".format(path)) - - elif left_count != 1: - raise ValueError("too many braces in '{}'".format(path)) - - variable = sub[sub.find('{') + 1: sub.find('}')] - - if len(variable) == 0: - raise ValueError("emtpy variable in '{}'".format(path)) - - result.append(variable) - - return result - - -class PathAttribute: - name = 'liu' - age = 28 - - def replace(self, path): - replaced_path = path - return replaced_path diff --git a/zstack/test_trie.py b/zstack/test_trie.py deleted file mode 100644 index af06ea5..0000000 --- a/zstack/test_trie.py +++ /dev/null @@ -1,28 +0,0 @@ -from pygtrie import StringTrie - -import unittest - - -def foo(): - print('foo') - - -def bar(): - print('bar') - - -class TestTrie(unittest.TestCase): - def setUp(self): - pass - - def test_(self): - tree = StringTrie() - tree['/foo'] = foo - tree['/bar'] = bar - tree['/foo/test'] = lambda x: print('test') - tree['/foo/txxt'] = lambda x: print('txxt') - tree['/foo/text'] = lambda x: print('text') - - # print(tree.keys()) - - print(tree.has_subtrie('/bar')) \ No newline at end of file