def _htraverse(self, pathlist, **kwargs): curr = self if isinstance(pathlist, basestring): pathlist = gnrstring.smartsplit(pathlist.replace('../', '#^.'), '.') pathlist = [x for x in pathlist if x] if not pathlist: return curr, '' label = pathlist.pop(0) while label == '#^' and pathlist: curr = curr.parent label = pathlist.pop(0) if not pathlist: return curr, label newcurr = curr.get(label) isbag = hasattr(newcurr, '_htraverse') if isbag: return newcurr._htraverse(pathlist) else: return newcurr, '.'.join(pathlist)
def test_smartsplit(): """docstring for smartsplit""" assert gnrstring.smartsplit('Hello\\, dog,you,are,yellow', ',') == ['Hello, dog', 'you', 'are', 'yellow']
def test_smartsplit(): """docstring for smartsplit""" assert gnrstring.smartsplit('Hello\\, dog,you,are,yellow', ',') == ['Hello\\, dog', 'you', 'are', 'yellow']