* morituri/common/common.py:

* morituri/common/renamer.py:
	  Pychecker fixes.
This commit is contained in:
Thomas Vander Stichele
2009-05-22 20:29:09 +00:00
parent 3b0dfc663c
commit 713a5d14fd
3 changed files with 17 additions and 11 deletions

View File

@@ -1,3 +1,9 @@
2009-05-22 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/common/common.py:
* morituri/common/renamer.py:
Pychecker fixes.
2009-05-22 Thomas Vander Stichele <thomas at apestaart dot org>
* RELEASE:

View File

@@ -90,7 +90,7 @@ class Persister(object):
self._unpickle(default)
def persist(self, object=None):
def persist(self, obj=None):
"""
Persist the given object, if we have a persistence path and the
object changed.
@@ -99,27 +99,27 @@ class Persister(object):
If object is given, only persist if it was changed.
"""
# don't pickle if it's already ok
if object and object == self.object:
if obj and obj == self.object:
return
# store the object on ourselves if not None
if object is not None:
self.object = object
if obj is not None:
self.object = obj
# don't pickle if there is no path
if not self._path:
return
# default to pickling our object again
if object is None:
object = self.object
if obj is None:
obj = self.object
# pickle
self.object = object
self.object = obj
(fd, path) = tempfile.mkstemp(suffix='.morituri.pickle')
handle = os.fdopen(fd, 'wb')
import pickle
pickle.dump(object, handle, 2)
pickle.dump(obj, handle, 2)
handle.close()
# do an atomic move
shutil.move(path, self._path)

View File

@@ -200,13 +200,13 @@ class RenameInFile(Operation):
# check if the source exists in the given file
def do(self):
input = open(self._path)
handle = open(self._path)
(fd, name) = tempfile.mkstemp(suffix='.morituri')
for s in input:
for s in handle:
os.write(fd, s.replace(self._source, self._destination))
input.close()
handle.close()
os.close(fd)
os.rename(name, self._path)