1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2026-01-22 14:41:39 +00:00

Overwrite subfolders' state when setting states in folder dialog

Fixes #248
This commit is contained in:
Virgil Dupras
2014-03-15 17:31:33 -04:00
parent 8193bbae6e
commit 781f13ae1a
4 changed files with 27 additions and 26 deletions

View File

@@ -117,6 +117,17 @@ class Path(tuple):
first = self[0]
return (len(first) == 2) and (first[1] == ':')
def is_parent_of(self, other):
"""Whether ``other`` is a subpath of ``self``.
Almost the same as ``other in self``, but it's a bit more self-explicative and when
``other == self``, returns False.
"""
if other == self:
return False
else:
return other in self
def remove_drive_letter(self):
if self.has_drive_letter():
return self[1:]

View File

@@ -163,6 +163,11 @@ def test_contains(force_ossep):
assert 'bleh' not in p
assert Path('foo') not in p
def test_is_parent_of(force_ossep):
assert Path(('foo','bar')).is_parent_of(Path(('foo','bar','bleh')))
assert not Path(('foo','bar')).is_parent_of(Path(('foo','baz')))
assert not Path(('foo','bar')).is_parent_of(Path(('foo','bar')))
def test_windows_drive_letter(force_ossep):
p = Path(('c:',))
eq_('c:\\',str(p))