Beispiel #1
0
 def is_child_of(self, path, strict=False):
     """Checks if the current object is a child of the passed object
     or path.
     """
     if isinstance(path, SourceObject):
         path = path.path
     if self.path is None or path is None:
         return False
     return is_path_child_of(self.path, path, strict=strict)
Beispiel #2
0
 def is_child_of(self, path, strict=False):
     """Checks if the current object is a child of the passed object
     or path.
     """
     if isinstance(path, SourceObject):
         path = path.path
     if self.path is None or path is None:
         return False
     return is_path_child_of(self.path, path, strict=strict)
Beispiel #3
0
def test_is_path_child_of():
    from lektor.utils import is_path_child_of

    assert not is_path_child_of('a/b', 'a/b')
    assert is_path_child_of('a/b', 'a/b', strict=False)
    assert is_path_child_of('a/b/c', 'a')
    assert not is_path_child_of('a/b/c', 'b')
    assert is_path_child_of('a/b@foo/bar', 'a/b@foo')
    assert is_path_child_of('a/b@foo', 'a/b@foo', strict=False)
    assert not is_path_child_of('a/b@foo/bar', 'a/c@foo')
    assert not is_path_child_of('a/b@foo/bar', 'a/c')
    assert is_path_child_of('a/b@foo', 'a/b')
    assert is_path_child_of('a/b@foo/bar', 'a/b@foo')
    assert not is_path_child_of('a/b@foo/bar', 'a/b@bar')
Beispiel #4
0
def test_is_path_child_of():
    from lektor.utils import is_path_child_of

    assert not is_path_child_of("a/b", "a/b")
    assert is_path_child_of("a/b", "a/b", strict=False)
    assert is_path_child_of("a/b/c", "a")
    assert not is_path_child_of("a/b/c", "b")
    assert is_path_child_of("a/b@foo/bar", "a/b@foo")
    assert is_path_child_of("a/b@foo", "a/b@foo", strict=False)
    assert not is_path_child_of("a/b@foo/bar", "a/c@foo")
    assert not is_path_child_of("a/b@foo/bar", "a/c")
    assert is_path_child_of("a/b@foo", "a/b")
    assert is_path_child_of("a/b@foo/bar", "a/b@foo")
    assert not is_path_child_of("a/b@foo/bar", "a/b@bar")
Beispiel #5
0
def test_is_path_child_of():

    assert not is_path_child_of("a/b", "a/b")
    assert is_path_child_of("a/b", "a/b", strict=False)
    assert is_path_child_of("a/b/c", "a")
    assert not is_path_child_of("a/b/c", "b")
    assert is_path_child_of("a/b@foo/bar", "a/b@foo")
    assert is_path_child_of("a/b@foo", "a/b@foo", strict=False)
    assert not is_path_child_of("a/b@foo/bar", "a/c@foo")
    assert not is_path_child_of("a/b@foo/bar", "a/c")
    assert is_path_child_of("a/b@foo", "a/b")
    assert is_path_child_of("a/b@foo/bar", "a/b@foo")
    assert not is_path_child_of("a/b@foo/bar", "a/b@bar")
Beispiel #6
0
def test_is_path_child_of():
    from lektor.utils import is_path_child_of

    assert not is_path_child_of('a/b', 'a/b')
    assert is_path_child_of('a/b', 'a/b', strict=False)
    assert is_path_child_of('a/b/c', 'a')
    assert not is_path_child_of('a/b/c', 'b')
    assert is_path_child_of('a/b@foo/bar', 'a/b@foo')
    assert is_path_child_of('a/b@foo', 'a/b@foo', strict=False)
    assert not is_path_child_of('a/b@foo/bar', 'a/c@foo')
    assert not is_path_child_of('a/b@foo/bar', 'a/c')
    assert is_path_child_of('a/b@foo', 'a/b')
    assert is_path_child_of('a/b@foo/bar', 'a/b@foo')
    assert not is_path_child_of('a/b@foo/bar', 'a/b@bar')