* 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>
|
2007-09-10 Don Allingham <don@gramps-project.org>
|
||||||
* src/plugins/WriteCD.py: don't generate thumbnails
|
* src/plugins/WriteCD.py: don't generate thumbnails
|
||||||
* src/Selectors/_SelectObject.py: new image sizing routines
|
* src/Selectors/_SelectObject.py: new image sizing routines
|
||||||
|
@ -79,8 +79,8 @@ def image_size(source):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
img = gtk.gdk.pixbuf_new_from_file(source)
|
img = gtk.gdk.pixbuf_new_from_file(source)
|
||||||
width = self.img.get_width()
|
width = img.get_width()
|
||||||
height = self.img.get_height()
|
height = img.get_height()
|
||||||
except gobject.GError:
|
except gobject.GError:
|
||||||
width = 0
|
width = 0
|
||||||
height = 0
|
height = 0
|
||||||
@ -105,13 +105,13 @@ def resize_to_jpeg_buffer(source, width, height):
|
|||||||
@rtype: buffer of data
|
@rtype: buffer of data
|
||||||
@returns: jpeg image as raw data
|
@returns: jpeg image as raw data
|
||||||
"""
|
"""
|
||||||
fd, dest = tempfile.mkstemp()
|
filed, dest = tempfile.mkstemp()
|
||||||
img = gtk.gdk.pixbuf_new_from_file(source)
|
img = gtk.gdk.pixbuf_new_from_file(source)
|
||||||
scaled = img.scale_simple(int(width), int(height), gtk.gdk.INTERP_BILINEAR)
|
scaled = img.scale_simple(int(width), int(height), gtk.gdk.INTERP_BILINEAR)
|
||||||
scaled.save(dest, 'jpeg')
|
scaled.save(dest, 'jpeg')
|
||||||
fh = open(dest, mode='rb')
|
ofile = open(dest, mode='rb')
|
||||||
data = fh.read()
|
data = ofile.read()
|
||||||
fh.close()
|
ofile.close()
|
||||||
try:
|
try:
|
||||||
os.unlink(dest)
|
os.unlink(dest)
|
||||||
except:
|
except:
|
||||||
|
@ -124,23 +124,27 @@ class SubstKeywords:
|
|||||||
if mplace_handle:
|
if mplace_handle:
|
||||||
self.M = database.get_place_from_handle(mplace_handle).get_title()
|
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):
|
def replace(self, line):
|
||||||
"""Returns a new line of text with the substitutions performed."""
|
"""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)
|
line = line.replace(key, value)
|
||||||
return line
|
return line
|
||||||
|
|
||||||
def replace_and_clean(self, lines):
|
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 = []
|
new = []
|
||||||
for line in lines:
|
for line in lines:
|
||||||
remove = False
|
remove = False
|
||||||
for (key, value) in self.array:
|
for (key, value) in array:
|
||||||
if line.find(key) != -1:
|
if line.find(key) != -1:
|
||||||
if value:
|
if value:
|
||||||
line = line.replace(key, value)
|
line = line.replace(key, value)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user