From 63a936c593c63c34d60420982c9c366aff338ecd Mon Sep 17 00:00:00 2001
From: Kees Bakker
Date: Thu, 17 Jul 2008 11:54:33 +0000
Subject: [PATCH] Several fixes. "styles" directory was not present before
copying files into. Correction of filename in copyright part. Eliminate
store_file and replaced by copy_file (takes care of directory creation and
error message.) * src/plugins/NarrativeWeb.py
svn: r10870
---
src/plugins/NarrativeWeb.py | 97 ++++++++++++-------------------------
1 file changed, 31 insertions(+), 66 deletions(-)
diff --git a/src/plugins/NarrativeWeb.py b/src/plugins/NarrativeWeb.py
index fed29b0b7..a604134b9 100644
--- a/src/plugins/NarrativeWeb.py
+++ b/src/plugins/NarrativeWeb.py
@@ -301,7 +301,7 @@ class BasePage:
of.write('%s' % cright)
elif 0 < copy_nr < 7:
text = _CC[copy_nr]
- fname = build_url_fname("somerights20.gif", 'images', self.up)
+ fname = self.build_url_fname("somerights20.gif", 'images', self.up)
text = text % {'gif_fname' : fname}
of.write(text)
of.write('
\n')
@@ -461,7 +461,7 @@ class BasePage:
try:
lnkref = (self.report.cur_fname, self.page_title, self.gid)
self.report.add_lnkref_to_photo(photo, lnkref)
- (real_path, newpath) = self.report.copy_media(photo)
+ real_path, newpath = self.report.prepare_copy_media(photo)
of.write('\t\n')
# TODO. Check if build_url_fname can be used.
newpath = '/'.join(['..']*3 + [newpath])
@@ -507,7 +507,7 @@ class BasePage:
try:
lnkref = (self.report.cur_fname, self.page_title, self.gid)
self.report.add_lnkref_to_photo(photo, lnkref)
- (real_path, newpath) = self.report.copy_media(photo)
+ real_path, newpath = self.report.prepare_copy_media(photo)
descr = " ".join(wrapper.wrap(title))
# TODO. Check if build_url_fname can be used.
newpath = '/'.join(['..']*3 + [newpath])
@@ -1200,7 +1200,7 @@ class MediaPage(BasePage):
thmb_path, 320):
try:
path = self.report.build_path('preview', photo.handle)
- self.report.store_file(thmb_path, os.path.join(path, photo.handle) + '.png')
+ self.report.copy_file(thmb_path, os.path.join(path, photo.handle) + '.png')
os.unlink(thmb_path)
except IOError:
path = os.path.join('images', 'document.png')
@@ -1323,18 +1323,7 @@ class MediaPage(BasePage):
else:
from_path = os.path.join(const.IMAGE_DIR, "document.png")
- # FIXME. Why not use store_file()?
- if self.report.archive:
- self.report.archive.add(from_path, to_path)
- else:
- to_dir = os.path.join(self.html_dir, to_dir)
- dest = os.path.join(self.html_dir, to_path)
- if not os.path.isdir(to_dir):
- os.makedirs(to_dir)
- try:
- shutil.copyfile(from_path, dest)
- except IOError:
- print "Could not copy file"
+ self.report.copy_file(from_path, to_path)
class SurnameListPage(BasePage):
ORDER_BY_NAME = 0
@@ -2312,11 +2301,11 @@ class IndividualPage(BasePage):
family = db.get_family_from_handle(family_handle)
for step_child_ref in family.get_child_ref_list():
step_child_handle = step_child_ref.ref
- if step_child_handle not in sibling and \
- step_child_handle not in half_siblings and \
- step_child_handle != self.person.handle:
- # we have a new step sibling
- step_siblings.add(step_child_handle)
+ if step_child_handle not in sibling and \
+ step_child_handle not in half_siblings and \
+ step_child_handle != self.person.handle:
+ # we have a new step sibling
+ step_siblings.add(step_child_handle)
# now that we have all of the step-siblings, print them out
if len(step_siblings) > 0:
@@ -2716,8 +2705,7 @@ class NavWebReport(Report):
for f in imgs:
from_path = os.path.join(const.IMAGE_DIR, f)
- to_path = os.path.join("images", f)
- self.store_file(from_path, to_path)
+ self.copy_file(from_path, f, "images")
place_list = {}
source_list = {}
@@ -2751,16 +2739,10 @@ class NavWebReport(Report):
Copy the CSS files to the target directory.
"""
- if self.archive:
- fname = os.path.join(const.DATA_DIR, css_file)
- self.archive.add(fname, _NARRATIVESCREEN)
- fname = os.path.join(const.DATA_DIR, "Web_Print-Default.css")
- self.archive.add(fname, _NARRATIVEPRINT)
- else:
- shutil.copyfile(os.path.join(const.DATA_DIR, css_file),
- os.path.join(self.html_dir, "styles", _NARRATIVESCREEN))
- shutil.copyfile(os.path.join(const.DATA_DIR, "Web_Print-Default.css"),
- os.path.join(self.html_dir, "styles", _NARRATIVEPRINT))
+ fname = os.path.join(const.DATA_DIR, css_file)
+ self.copy_file(fname, _NARRATIVESCREEN, "styles")
+ fname = os.path.join(const.DATA_DIR, "Web_Print-Default.css")
+ self.copy_file(fname, _NARRATIVEPRINT, "styles")
def person_pages(self, ind_list, place_list, source_list):
@@ -2864,8 +2846,8 @@ class NavWebReport(Report):
mime_type = obj.get_mime_type()
if mime_type and mime_type.startswith("image"):
try:
- (newpath, thumb_path) = self.copy_media(obj)
- self.store_file(Utils.media_path_full(db, obj.get_path()),
+ newpath, thumb_path = self.prepare_copy_media(obj)
+ self.copy_file(Utils.media_path_full(db, obj.get_path()),
newpath)
of.write('\t
![]()