1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2024-11-16 12:19:03 +00:00

[#38 state:fixed] Removed those LookupErrors. They were useless anyway.

--HG--
extra : convert_revision : svn%3Ac306627e-7827-47d3-bdf0-9a457c9553a1/trunk%4071
This commit is contained in:
hsoft 2009-06-18 18:13:45 +00:00
parent ede178b3ff
commit 3ada0ff89c
2 changed files with 10 additions and 16 deletions

View File

@ -107,11 +107,7 @@ class Directories(object):
def GetState(self, path): def GetState(self, path):
"""Returns the state of 'path' (One of the STATE_* const.) """Returns the state of 'path' (One of the STATE_* const.)
Raises LookupError if 'path' is not in self.
""" """
if path not in self:
raise LookupError("The path '%s' is not in the directory list." % str(path))
try: try:
return self.states[path] return self.states[path]
except KeyError: except KeyError:
@ -163,7 +159,6 @@ class Directories(object):
doc.writexml(fp,'\t','\t','\n',encoding='utf-8') doc.writexml(fp,'\t','\t','\n',encoding='utf-8')
def SetState(self,path,state): def SetState(self,path,state):
try:
if self.GetState(path) == state: if self.GetState(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 GetState returns the same thing
@ -173,6 +168,4 @@ class Directories(object):
if self.GetState(path) == state: # no need for an entry if self.GetState(path) == state: # no need for an entry
return return
self.states[path] = state self.states[path] = state
except LookupError:
pass

View File

@ -93,9 +93,10 @@ class TCDirectories(TestCase):
self.assertEqual(STATE_REFERENCE,d.states[p]) self.assertEqual(STATE_REFERENCE,d.states[p])
def test_GetState_with_path_not_there(self): def test_GetState_with_path_not_there(self):
# When the path's not there, just return STATE_NORMAL
d = Directories() d = Directories()
d.add_path(testpath + 'utils') d.add_path(testpath + 'utils')
self.assertRaises(LookupError,d.GetState,testpath) eq_(d.GetState(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()