mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-10 05:34:36 +00:00
base py: pep8ified dupeguru.directories (about time!).
--HG-- extra : convert_revision : svn%3Ac306627e-7827-47d3-bdf0-9a457c9553a1/trunk%4072
This commit is contained in:
parent
3ada0ff89c
commit
a7a76f2b40
@ -80,7 +80,7 @@ class DupeGuru(RegistrableApplication):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def _do_load(self, j):
|
def _do_load(self, j):
|
||||||
self.directories.LoadFromFile(op.join(self.appdata, 'last_directories.xml'))
|
self.directories.load_from_file(op.join(self.appdata, 'last_directories.xml'))
|
||||||
j = j.start_subjob([1, 9])
|
j = j.start_subjob([1, 9])
|
||||||
self.results.load_from_xml(op.join(self.appdata, 'last_results.xml'), self._get_file, j)
|
self.results.load_from_xml(op.join(self.appdata, 'last_results.xml'), self._get_file, j)
|
||||||
files = flatten(g[:] for g in self.results.groups)
|
files = flatten(g[:] for g in self.results.groups)
|
||||||
@ -194,7 +194,7 @@ class DupeGuru(RegistrableApplication):
|
|||||||
changed_groups.add(g)
|
changed_groups.add(g)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
self.directories.SaveToFile(op.join(self.appdata, 'last_directories.xml'))
|
self.directories.save_to_file(op.join(self.appdata, 'last_directories.xml'))
|
||||||
self.results.save_to_xml(op.join(self.appdata, 'last_results.xml'))
|
self.results.save_to_xml(op.join(self.appdata, 'last_results.xml'))
|
||||||
|
|
||||||
def save_ignore_list(self):
|
def save_ignore_list(self):
|
||||||
|
@ -226,7 +226,7 @@ class DupeGuru(app.DupeGuru):
|
|||||||
|
|
||||||
def SetDirectoryState(self,node_path,state):
|
def SetDirectoryState(self,node_path,state):
|
||||||
d = self.GetDirectory(node_path)
|
d = self.GetDirectory(node_path)
|
||||||
self.directories.SetState(d.path,state)
|
self.directories.set_state(d.path,state)
|
||||||
|
|
||||||
def sort_dupes(self,key,asc):
|
def sort_dupes(self,key,asc):
|
||||||
self.results.sort_dupes(key,asc,self.display_delta_values)
|
self.results.sort_dupes(key,asc,self.display_delta_values)
|
||||||
@ -279,7 +279,7 @@ class DupeGuru(app.DupeGuru):
|
|||||||
d = self.GetDirectory(node_path)
|
d = self.GetDirectory(node_path)
|
||||||
return [
|
return [
|
||||||
d.name,
|
d.name,
|
||||||
self.directories.GetState(d.path)
|
self.directories.get_state(d.path)
|
||||||
]
|
]
|
||||||
|
|
||||||
def GetOutlineViewMarked(self, tag, node_path):
|
def GetOutlineViewMarked(self, tag, node_path):
|
||||||
|
@ -169,7 +169,7 @@ class DupeGuruPE(app_cocoa.DupeGuru):
|
|||||||
return app_cocoa.DupeGuru._do_delete_dupe(self, dupe)
|
return app_cocoa.DupeGuru._do_delete_dupe(self, dupe)
|
||||||
|
|
||||||
def _do_load(self, j):
|
def _do_load(self, j):
|
||||||
self.directories.LoadFromFile(op.join(self.appdata, 'last_directories.xml'))
|
self.directories.load_from_file(op.join(self.appdata, 'last_directories.xml'))
|
||||||
for d in self.directories:
|
for d in self.directories:
|
||||||
if isinstance(d, IPhotoLibrary):
|
if isinstance(d, IPhotoLibrary):
|
||||||
d.update()
|
d.update()
|
||||||
@ -201,7 +201,7 @@ class DupeGuruPE(app_cocoa.DupeGuru):
|
|||||||
def start_scanning(self):
|
def start_scanning(self):
|
||||||
for directory in self.directories:
|
for directory in self.directories:
|
||||||
if isinstance(directory, IPhotoLibrary):
|
if isinstance(directory, IPhotoLibrary):
|
||||||
self.directories.SetState(directory.refpath, directories.STATE_EXCLUDED)
|
self.directories.set_state(directory.refpath, directories.STATE_EXCLUDED)
|
||||||
return app_cocoa.DupeGuru.start_scanning(self)
|
return app_cocoa.DupeGuru.start_scanning(self)
|
||||||
|
|
||||||
def selected_dupe_path(self):
|
def selected_dupe_path(self):
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
#!/usr/bin/env python
|
# Unit Name: dupeguru.directories
|
||||||
"""
|
# Created By: Virgil Dupras
|
||||||
Unit Name: dupeguru.directories
|
# Created On: 2006/02/27
|
||||||
Created By: Virgil Dupras
|
# $Id$
|
||||||
Created On: 2006/02/27
|
# Copyright 2009 Hardcoded Software (http://www.hardcoded.net)
|
||||||
Last modified by:$Author: virgil $
|
|
||||||
Last modified on:$Date: 2009-05-28 16:02:48 +0200 (Thu, 28 May 2009) $
|
|
||||||
$Revision: 4388 $
|
|
||||||
Copyright 2004-2006 Hardcoded Software (http://www.hardcoded.net)
|
|
||||||
"""
|
|
||||||
import xml.dom.minidom
|
import xml.dom.minidom
|
||||||
|
|
||||||
from hsfs import phys
|
from hsfs import phys
|
||||||
@ -56,7 +52,7 @@ class Directories(object):
|
|||||||
|
|
||||||
def _get_files(self, from_dir):
|
def _get_files(self, from_dir):
|
||||||
from_path = from_dir.path
|
from_path = from_dir.path
|
||||||
state = self.GetState(from_path)
|
state = self.get_state(from_path)
|
||||||
if state == STATE_EXCLUDED:
|
if state == STATE_EXCLUDED:
|
||||||
# Recursively get files from folders with lots of subfolder is expensive. However, there
|
# Recursively get files from folders with lots of subfolder is expensive. However, there
|
||||||
# might be a subfolder in this path that is not excluded. What we want to do is to skim
|
# might be a subfolder in this path that is not excluded. What we want to do is to skim
|
||||||
@ -90,7 +86,7 @@ class Directories(object):
|
|||||||
self._dirs.append(d)
|
self._dirs.append(d)
|
||||||
return d
|
return d
|
||||||
except fs.InvalidPath:
|
except fs.InvalidPath:
|
||||||
raise InvalidPathError
|
raise InvalidPathError()
|
||||||
|
|
||||||
def get_files(self):
|
def get_files(self):
|
||||||
"""Returns a list of all files that are not excluded.
|
"""Returns a list of all files that are not excluded.
|
||||||
@ -105,22 +101,21 @@ class Directories(object):
|
|||||||
except fs.InvalidPath:
|
except fs.InvalidPath:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def GetState(self, path):
|
def get_state(self, path):
|
||||||
"""Returns the state of 'path' (One of the STATE_* const.)
|
"""Returns the state of 'path' (One of the STATE_* const.)
|
||||||
"""
|
"""
|
||||||
try:
|
if path in self.states:
|
||||||
return self.states[path]
|
return self.states[path]
|
||||||
except KeyError:
|
|
||||||
default_state = self._default_state_for_path(path)
|
default_state = self._default_state_for_path(path)
|
||||||
if default_state is not None:
|
if default_state is not None:
|
||||||
return default_state
|
return default_state
|
||||||
parent = path[:-1]
|
parent = path[:-1]
|
||||||
if parent in self:
|
if parent in self:
|
||||||
return self.GetState(parent)
|
return self.get_state(parent)
|
||||||
else:
|
else:
|
||||||
return STATE_NORMAL
|
return STATE_NORMAL
|
||||||
|
|
||||||
def LoadFromFile(self,infile):
|
def load_from_file(self, infile):
|
||||||
try:
|
try:
|
||||||
doc = xml.dom.minidom.parse(infile)
|
doc = xml.dom.minidom.parse(infile)
|
||||||
except:
|
except:
|
||||||
@ -140,12 +135,9 @@ class Directories(object):
|
|||||||
continue
|
continue
|
||||||
path = sn.getAttributeNode('path').nodeValue
|
path = sn.getAttributeNode('path').nodeValue
|
||||||
state = sn.getAttributeNode('value').nodeValue
|
state = sn.getAttributeNode('value').nodeValue
|
||||||
self.SetState(Path(path), int(state))
|
self.set_state(Path(path), int(state))
|
||||||
|
|
||||||
def Remove(self,directory):
|
def save_to_file(self,outfile):
|
||||||
self._dirs.remove(directory)
|
|
||||||
|
|
||||||
def SaveToFile(self,outfile):
|
|
||||||
with FileOrPath(outfile, 'wb') as fp:
|
with FileOrPath(outfile, 'wb') as fp:
|
||||||
doc = xml.dom.minidom.Document()
|
doc = xml.dom.minidom.Document()
|
||||||
root = doc.appendChild(doc.createElement('directories'))
|
root = doc.appendChild(doc.createElement('directories'))
|
||||||
@ -158,14 +150,14 @@ class Directories(object):
|
|||||||
state_node.setAttribute('value', str(state))
|
state_node.setAttribute('value', str(state))
|
||||||
doc.writexml(fp, '\t', '\t', '\n', encoding='utf-8')
|
doc.writexml(fp, '\t', '\t', '\n', encoding='utf-8')
|
||||||
|
|
||||||
def SetState(self,path,state):
|
def set_state(self, path, state):
|
||||||
if self.GetState(path) == state:
|
if self.get_state(path) == state:
|
||||||
return
|
return
|
||||||
# we don't want to needlessly fill self.states. if GetState returns the same thing
|
# we don't want to needlessly fill self.states. if get_state returns the same thing
|
||||||
# without an explicit entry, remove that entry
|
# without an explicit entry, remove that entry
|
||||||
if path in self.states:
|
if path in self.states:
|
||||||
del self.states[path]
|
del self.states[path]
|
||||||
if self.GetState(path) == state: # no need for an entry
|
if self.get_state(path) == state: # no need for an entry
|
||||||
return
|
return
|
||||||
self.states[path] = state
|
self.states[path] = state
|
||||||
|
|
||||||
|
@ -84,52 +84,52 @@ class TCDirectories(TestCase):
|
|||||||
d = Directories()
|
d = Directories()
|
||||||
p = testpath + 'utils'
|
p = testpath + 'utils'
|
||||||
d.add_path(p)
|
d.add_path(p)
|
||||||
self.assertEqual(STATE_NORMAL,d.GetState(p))
|
self.assertEqual(STATE_NORMAL,d.get_state(p))
|
||||||
d.SetState(p,STATE_REFERENCE)
|
d.set_state(p,STATE_REFERENCE)
|
||||||
self.assertEqual(STATE_REFERENCE,d.GetState(p))
|
self.assertEqual(STATE_REFERENCE,d.get_state(p))
|
||||||
self.assertEqual(STATE_REFERENCE,d.GetState(p + 'dir1'))
|
self.assertEqual(STATE_REFERENCE,d.get_state(p + 'dir1'))
|
||||||
self.assertEqual(1,len(d.states))
|
self.assertEqual(1,len(d.states))
|
||||||
self.assertEqual(p,d.states.keys()[0])
|
self.assertEqual(p,d.states.keys()[0])
|
||||||
self.assertEqual(STATE_REFERENCE,d.states[p])
|
self.assertEqual(STATE_REFERENCE,d.states[p])
|
||||||
|
|
||||||
def test_GetState_with_path_not_there(self):
|
def test_get_state_with_path_not_there(self):
|
||||||
# When the path's not there, just return STATE_NORMAL
|
# When the path's not there, just return STATE_NORMAL
|
||||||
d = Directories()
|
d = Directories()
|
||||||
d.add_path(testpath + 'utils')
|
d.add_path(testpath + 'utils')
|
||||||
eq_(d.GetState(testpath), STATE_NORMAL)
|
eq_(d.get_state(testpath), STATE_NORMAL)
|
||||||
|
|
||||||
def test_states_remain_when_larger_directory_eat_smaller_ones(self):
|
def test_states_remain_when_larger_directory_eat_smaller_ones(self):
|
||||||
d = Directories()
|
d = Directories()
|
||||||
p = testpath + 'utils'
|
p = testpath + 'utils'
|
||||||
d.add_path(p)
|
d.add_path(p)
|
||||||
d.SetState(p,STATE_EXCLUDED)
|
d.set_state(p,STATE_EXCLUDED)
|
||||||
d.add_path(testpath)
|
d.add_path(testpath)
|
||||||
d.SetState(testpath,STATE_REFERENCE)
|
d.set_state(testpath,STATE_REFERENCE)
|
||||||
self.assertEqual(STATE_EXCLUDED,d.GetState(p))
|
self.assertEqual(STATE_EXCLUDED,d.get_state(p))
|
||||||
self.assertEqual(STATE_EXCLUDED,d.GetState(p + 'dir1'))
|
self.assertEqual(STATE_EXCLUDED,d.get_state(p + 'dir1'))
|
||||||
self.assertEqual(STATE_REFERENCE,d.GetState(testpath))
|
self.assertEqual(STATE_REFERENCE,d.get_state(testpath))
|
||||||
|
|
||||||
def test_SetState_keep_state_dict_size_to_minimum(self):
|
def test_set_state_keep_state_dict_size_to_minimum(self):
|
||||||
d = Directories()
|
d = Directories()
|
||||||
p = Path(phys_test.create_fake_fs(self.tmpdir()))
|
p = Path(phys_test.create_fake_fs(self.tmpdir()))
|
||||||
d.add_path(p)
|
d.add_path(p)
|
||||||
d.SetState(p,STATE_REFERENCE)
|
d.set_state(p,STATE_REFERENCE)
|
||||||
d.SetState(p + 'dir1',STATE_REFERENCE)
|
d.set_state(p + 'dir1',STATE_REFERENCE)
|
||||||
self.assertEqual(1,len(d.states))
|
self.assertEqual(1,len(d.states))
|
||||||
self.assertEqual(STATE_REFERENCE,d.GetState(p + 'dir1'))
|
self.assertEqual(STATE_REFERENCE,d.get_state(p + 'dir1'))
|
||||||
d.SetState(p + 'dir1',STATE_NORMAL)
|
d.set_state(p + 'dir1',STATE_NORMAL)
|
||||||
self.assertEqual(2,len(d.states))
|
self.assertEqual(2,len(d.states))
|
||||||
self.assertEqual(STATE_NORMAL,d.GetState(p + 'dir1'))
|
self.assertEqual(STATE_NORMAL,d.get_state(p + 'dir1'))
|
||||||
d.SetState(p + 'dir1',STATE_REFERENCE)
|
d.set_state(p + 'dir1',STATE_REFERENCE)
|
||||||
self.assertEqual(1,len(d.states))
|
self.assertEqual(1,len(d.states))
|
||||||
self.assertEqual(STATE_REFERENCE,d.GetState(p + 'dir1'))
|
self.assertEqual(STATE_REFERENCE,d.get_state(p + 'dir1'))
|
||||||
|
|
||||||
def test_get_files(self):
|
def test_get_files(self):
|
||||||
d = Directories()
|
d = Directories()
|
||||||
p = Path(phys_test.create_fake_fs(self.tmpdir()))
|
p = Path(phys_test.create_fake_fs(self.tmpdir()))
|
||||||
d.add_path(p)
|
d.add_path(p)
|
||||||
d.SetState(p + 'dir1',STATE_REFERENCE)
|
d.set_state(p + 'dir1',STATE_REFERENCE)
|
||||||
d.SetState(p + 'dir2',STATE_EXCLUDED)
|
d.set_state(p + 'dir2',STATE_EXCLUDED)
|
||||||
files = d.get_files()
|
files = d.get_files()
|
||||||
self.assertEqual(5, len(list(files)))
|
self.assertEqual(5, len(list(files)))
|
||||||
for f in files:
|
for f in files:
|
||||||
@ -142,7 +142,7 @@ class TCDirectories(TestCase):
|
|||||||
d = Directories()
|
d = Directories()
|
||||||
p = testpath + 'utils'
|
p = testpath + 'utils'
|
||||||
d.add_path(p)
|
d.add_path(p)
|
||||||
d.SetState(p,STATE_EXCLUDED)
|
d.set_state(p,STATE_EXCLUDED)
|
||||||
self.assertEqual([], list(d.get_files()))
|
self.assertEqual([], list(d.get_files()))
|
||||||
|
|
||||||
def test_save_and_load(self):
|
def test_save_and_load(self):
|
||||||
@ -152,14 +152,14 @@ class TCDirectories(TestCase):
|
|||||||
p2 = self.tmppath()
|
p2 = self.tmppath()
|
||||||
d1.add_path(p1)
|
d1.add_path(p1)
|
||||||
d1.add_path(p2)
|
d1.add_path(p2)
|
||||||
d1.SetState(p1, STATE_REFERENCE)
|
d1.set_state(p1, STATE_REFERENCE)
|
||||||
d1.SetState(p1 + 'dir1',STATE_EXCLUDED)
|
d1.set_state(p1 + 'dir1',STATE_EXCLUDED)
|
||||||
tmpxml = op.join(self.tmpdir(), 'directories_testunit.xml')
|
tmpxml = op.join(self.tmpdir(), 'directories_testunit.xml')
|
||||||
d1.SaveToFile(tmpxml)
|
d1.save_to_file(tmpxml)
|
||||||
d2.LoadFromFile(tmpxml)
|
d2.load_from_file(tmpxml)
|
||||||
self.assertEqual(2, len(d2))
|
self.assertEqual(2, len(d2))
|
||||||
self.assertEqual(STATE_REFERENCE,d2.GetState(p1))
|
self.assertEqual(STATE_REFERENCE,d2.get_state(p1))
|
||||||
self.assertEqual(STATE_EXCLUDED,d2.GetState(p1 + 'dir1'))
|
self.assertEqual(STATE_EXCLUDED,d2.get_state(p1 + 'dir1'))
|
||||||
|
|
||||||
def test_invalid_path(self):
|
def test_invalid_path(self):
|
||||||
d = Directories()
|
d = Directories()
|
||||||
@ -167,10 +167,10 @@ class TCDirectories(TestCase):
|
|||||||
self.assertRaises(InvalidPathError, d.add_path, p)
|
self.assertRaises(InvalidPathError, d.add_path, p)
|
||||||
self.assertEqual(0, len(d))
|
self.assertEqual(0, len(d))
|
||||||
|
|
||||||
def test_SetState_on_invalid_path(self):
|
def test_set_state_on_invalid_path(self):
|
||||||
d = Directories()
|
d = Directories()
|
||||||
try:
|
try:
|
||||||
d.SetState(Path('foobar',),STATE_NORMAL)
|
d.set_state(Path('foobar',),STATE_NORMAL)
|
||||||
except LookupError:
|
except LookupError:
|
||||||
self.fail()
|
self.fail()
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ class TCDirectories(TestCase):
|
|||||||
d.add_path(testpath)
|
d.add_path(testpath)
|
||||||
self.assert_(isinstance(d[0], MySpecialDirclass))
|
self.assert_(isinstance(d[0], MySpecialDirclass))
|
||||||
|
|
||||||
def test_LoadFromFile_with_invalid_path(self):
|
def test_load_from_file_with_invalid_path(self):
|
||||||
#This test simulates a load from file resulting in a
|
#This test simulates a load from file resulting in a
|
||||||
#InvalidPath raise. Other directories must be loaded.
|
#InvalidPath raise. Other directories must be loaded.
|
||||||
d1 = Directories()
|
d1 = Directories()
|
||||||
@ -192,12 +192,12 @@ class TCDirectories(TestCase):
|
|||||||
#Will raise InvalidPath upon loading
|
#Will raise InvalidPath upon loading
|
||||||
d1.add_path(self.tmppath()).name = 'does_not_exist'
|
d1.add_path(self.tmppath()).name = 'does_not_exist'
|
||||||
tmpxml = op.join(self.tmpdir(), 'directories_testunit.xml')
|
tmpxml = op.join(self.tmpdir(), 'directories_testunit.xml')
|
||||||
d1.SaveToFile(tmpxml)
|
d1.save_to_file(tmpxml)
|
||||||
d2 = Directories()
|
d2 = Directories()
|
||||||
d2.LoadFromFile(tmpxml)
|
d2.load_from_file(tmpxml)
|
||||||
self.assertEqual(1, len(d2))
|
self.assertEqual(1, len(d2))
|
||||||
|
|
||||||
def test_LoadFromFile_with_same_paths(self):
|
def test_load_from_file_with_same_paths(self):
|
||||||
#This test simulates a load from file resulting in a
|
#This test simulates a load from file resulting in a
|
||||||
#AlreadyExists raise. Other directories must be loaded.
|
#AlreadyExists raise. Other directories must be loaded.
|
||||||
d1 = Directories()
|
d1 = Directories()
|
||||||
@ -208,29 +208,21 @@ class TCDirectories(TestCase):
|
|||||||
#Will raise AlreadyExists upon loading
|
#Will raise AlreadyExists upon loading
|
||||||
d1.add_path(self.tmppath()).name = unicode(p1)
|
d1.add_path(self.tmppath()).name = unicode(p1)
|
||||||
tmpxml = op.join(self.tmpdir(), 'directories_testunit.xml')
|
tmpxml = op.join(self.tmpdir(), 'directories_testunit.xml')
|
||||||
d1.SaveToFile(tmpxml)
|
d1.save_to_file(tmpxml)
|
||||||
d2 = Directories()
|
d2 = Directories()
|
||||||
d2.LoadFromFile(tmpxml)
|
d2.load_from_file(tmpxml)
|
||||||
self.assertEqual(2, len(d2))
|
self.assertEqual(2, len(d2))
|
||||||
|
|
||||||
def test_Remove(self):
|
|
||||||
d = Directories()
|
|
||||||
d1 = d.add_path(self.tmppath())
|
|
||||||
d2 = d.add_path(self.tmppath())
|
|
||||||
d.Remove(d1)
|
|
||||||
self.assertEqual(1, len(d))
|
|
||||||
self.assert_(d[0] is d2)
|
|
||||||
|
|
||||||
def test_unicode_save(self):
|
def test_unicode_save(self):
|
||||||
d = Directories()
|
d = Directories()
|
||||||
p1 = self.tmppath() + u'hello\xe9'
|
p1 = self.tmppath() + u'hello\xe9'
|
||||||
io.mkdir(p1)
|
io.mkdir(p1)
|
||||||
io.mkdir(p1 + u'foo\xe9')
|
io.mkdir(p1 + u'foo\xe9')
|
||||||
d.add_path(p1)
|
d.add_path(p1)
|
||||||
d.SetState(d[0][0].path, STATE_EXCLUDED)
|
d.set_state(d[0][0].path, STATE_EXCLUDED)
|
||||||
tmpxml = op.join(self.tmpdir(), 'directories_testunit.xml')
|
tmpxml = op.join(self.tmpdir(), 'directories_testunit.xml')
|
||||||
try:
|
try:
|
||||||
d.SaveToFile(tmpxml)
|
d.save_to_file(tmpxml)
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
self.fail()
|
self.fail()
|
||||||
|
|
||||||
@ -252,16 +244,16 @@ class TCDirectories(TestCase):
|
|||||||
io.rmtree(p)
|
io.rmtree(p)
|
||||||
self.assertEqual([], list(d.get_files()))
|
self.assertEqual([], list(d.get_files()))
|
||||||
|
|
||||||
def test_GetState_returns_excluded_by_default_for_hidden_directories(self):
|
def test_get_state_returns_excluded_by_default_for_hidden_directories(self):
|
||||||
d = Directories()
|
d = Directories()
|
||||||
p = Path(self.tmpdir())
|
p = Path(self.tmpdir())
|
||||||
hidden_dir_path = p + '.foo'
|
hidden_dir_path = p + '.foo'
|
||||||
io.mkdir(p + '.foo')
|
io.mkdir(p + '.foo')
|
||||||
d.add_path(p)
|
d.add_path(p)
|
||||||
self.assertEqual(d.GetState(hidden_dir_path), STATE_EXCLUDED)
|
self.assertEqual(d.get_state(hidden_dir_path), STATE_EXCLUDED)
|
||||||
# But it can be overriden
|
# But it can be overriden
|
||||||
d.SetState(hidden_dir_path, STATE_NORMAL)
|
d.set_state(hidden_dir_path, STATE_NORMAL)
|
||||||
self.assertEqual(d.GetState(hidden_dir_path), STATE_NORMAL)
|
self.assertEqual(d.get_state(hidden_dir_path), STATE_NORMAL)
|
||||||
|
|
||||||
def test_special_dirclasses(self):
|
def test_special_dirclasses(self):
|
||||||
# if a path is in special_dirclasses, use this class instead
|
# if a path is in special_dirclasses, use this class instead
|
||||||
@ -287,11 +279,11 @@ class TCDirectories(TestCase):
|
|||||||
io.mkdir(p1 + 'foobaz')
|
io.mkdir(p1 + 'foobaz')
|
||||||
io.open(p1 + 'foobaz/somefile', 'w').close()
|
io.open(p1 + 'foobaz/somefile', 'w').close()
|
||||||
d.add_path(p1)
|
d.add_path(p1)
|
||||||
eq_(d.GetState(p1 + 'foobaz'), STATE_NORMAL)
|
eq_(d.get_state(p1 + 'foobaz'), STATE_NORMAL)
|
||||||
eq_(d.GetState(p1 + 'foobar'), STATE_EXCLUDED)
|
eq_(d.get_state(p1 + 'foobar'), STATE_EXCLUDED)
|
||||||
eq_(len(list(d.get_files())), 1) # only the 'foobaz' file is there
|
eq_(len(list(d.get_files())), 1) # only the 'foobaz' file is there
|
||||||
# However, the default state can be changed
|
# However, the default state can be changed
|
||||||
d.SetState(p1 + 'foobar', STATE_NORMAL)
|
d.set_state(p1 + 'foobar', STATE_NORMAL)
|
||||||
eq_(d.GetState(p1 + 'foobar'), STATE_NORMAL)
|
eq_(d.get_state(p1 + 'foobar'), STATE_NORMAL)
|
||||||
eq_(len(list(d.get_files())), 2)
|
eq_(len(list(d.get_files())), 2)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user