diff --git a/ChangeLog b/ChangeLog index 56705bd62..842a9ec32 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-09-10 Don Allingham + * src/SubstKeywords.py (SubstKeywords.replace_and_clean): fix substitution + * src/ImgManip.py: fix typo + 2007-09-10 Don Allingham * src/plugins/WriteCD.py: don't generate thumbnails * src/Selectors/_SelectObject.py: new image sizing routines diff --git a/src/ImgManip.py b/src/ImgManip.py index 711633cc5..4cdeef425 100644 --- a/src/ImgManip.py +++ b/src/ImgManip.py @@ -79,8 +79,8 @@ def image_size(source): """ try: img = gtk.gdk.pixbuf_new_from_file(source) - width = self.img.get_width() - height = self.img.get_height() + width = img.get_width() + height = img.get_height() except gobject.GError: width = 0 height = 0 @@ -105,13 +105,13 @@ def resize_to_jpeg_buffer(source, width, height): @rtype: buffer of data @returns: jpeg image as raw data """ - fd, dest = tempfile.mkstemp() + filed, dest = tempfile.mkstemp() img = gtk.gdk.pixbuf_new_from_file(source) scaled = img.scale_simple(int(width), int(height), gtk.gdk.INTERP_BILINEAR) scaled.save(dest, 'jpeg') - fh = open(dest, mode='rb') - data = fh.read() - fh.close() + ofile = open(dest, mode='rb') + data = ofile.read() + ofile.close() try: os.unlink(dest) except: diff --git a/src/SubstKeywords.py b/src/SubstKeywords.py index 02f7530eb..7c46f3937 100644 --- a/src/SubstKeywords.py +++ b/src/SubstKeywords.py @@ -124,23 +124,27 @@ class SubstKeywords: if mplace_handle: self.M = database.get_place_from_handle(mplace_handle).get_title() - self.array = [ ("%n", self.n), ("%N", self.N), ("%b", self.b), - ("%B", self.B), ("%d", self.d), ("%D", self.D), - ("%i", self.i), ("%S", self.S), ("%s", self.s), - ("%m", self.m), ("%M", self.M), ("$$", "$") ] - def replace(self, line): """Returns a new line of text with the substitutions performed.""" - for (key, value) in self.array: + array = [ ("$n", self.n), ("$N", self.N), ("$b", self.b), + ("$B", self.B), ("$d", self.d), ("$D", self.D), + ("$i", self.i), ("$S", self.S), ("$s", self.s), + ("$m", self.m), ("$M", self.M), ("$$", "$") ] + + for (key, value) in array: line = line.replace(key, value) return line def replace_and_clean(self, lines): + array = [ ("%n", self.n), ("%N", self.N), ("%b", self.b), + ("%B", self.B), ("%d", self.d), ("%D", self.D), + ("%i", self.i), ("%S", self.S), ("%s", self.s), + ("%m", self.m), ("%M", self.M) ] new = [] for line in lines: remove = False - for (key, value) in self.array: + for (key, value) in array: if line.find(key) != -1: if value: line = line.replace(key, value)