* src/SubstKeywords.py (SubstKeywords.replace_and_clean): fix substitution
* src/ImgManip.py: fix typo 2007-09-10 Don Allingham <don@gramps-project.org> svn: r8960
This commit is contained in:
parent
643c75099c
commit
f32dcb087a
@ -1,3 +1,7 @@
|
||||
2007-09-10 Don Allingham <don@gramps-project.org>
|
||||
* src/SubstKeywords.py (SubstKeywords.replace_and_clean): fix substitution
|
||||
* src/ImgManip.py: fix typo
|
||||
|
||||
2007-09-10 Don Allingham <don@gramps-project.org>
|
||||
* src/plugins/WriteCD.py: don't generate thumbnails
|
||||
* src/Selectors/_SelectObject.py: new image sizing routines
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user