Esempio n. 1
0
 def test_accessors(self):
     t = PrefTree()
     urls = ['arxiv.org/abs/1410.1454','arxiv.org/pdf/1410.1454v2']
     for u in urls:
         t.add_url(u, True)
     self.assertEqual(t['arxiv.org/'], t[hashable_list('arxiv.org/')])
     t['biorxiv.org/'] = PrefTree()
     t[hashable_list('sciencedirect.com/')] = PrefTree()
     del t[hashable_list('biorxiv.org/')]
     del t['sciencedirect.com/']
Esempio n. 2
0
 def __delitem__(self, key):
     """
     Shorthand for `del children[key]`.
     """
     if isinstance(key, hashable.hashable_list):
         del self.children[key]
     else:
         del self.children[hashable.hashable_list(key)]
Esempio n. 3
0
 def __setitem__(self, key, value):
     """
     Shorthand for `children[key] = value`
     """
     if isinstance(key, hashable.hashable_list):
         self.children[key] = value
     else:
         self.children[hashable.hashable_list(key)] = value
Esempio n. 4
0
 def __getitem__(self, key):
     """
     Shorthand for `children[key]`
     """
     if isinstance(key, hashable.hashable_list):
         return self.children[key]
     else:
         return self.children[hashable.hashable_list(key)]