Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
def test_smartsplit():
    """docstring for smartsplit"""
    assert gnrstring.smartsplit('Hello\\, dog,you,are,yellow',
                                ',') == ['Hello, dog', 'you', 'are', 'yellow']
Ejemplo n.º 4
0
def test_smartsplit():
    """docstring for smartsplit"""
    assert gnrstring.smartsplit('Hello\\, dog,you,are,yellow', ',') == ['Hello\\, dog', 'you', 'are', 'yellow']