handle things if no document generators are available

svn: r800
This commit is contained in:
Don Allingham 2002-02-26 05:16:38 +00:00
parent 588fbbb7e5
commit 952d0758a2
8 changed files with 70 additions and 34 deletions

View File

@ -29,6 +29,8 @@ import Utils
import gtk
import const
import GrampsCfg
import intl
_ = intl.gettext
#-------------------------------------------------------------------------
#

View File

@ -72,6 +72,7 @@ _textdoc = []
_drawdoc = []
_failmsg = []
_unavailable = _("No description was provided"),
#-------------------------------------------------------------------------
#
# Constants
@ -186,7 +187,14 @@ class ToolPlugins:
self.run_tool = obj.get_data(TASK)
#-------------------------------------------------------------------------
#
# PluginStatus
#
#-------------------------------------------------------------------------
class PluginStatus:
"""Displays a dialog showing the status of loaded plugins"""
def __init__(self):
import cStringIO
@ -195,6 +203,9 @@ class PluginStatus:
window = self.glade.get_widget("text")
info = cStringIO.StringIO()
info.write(_("The following modules could not be loaded:"))
info.write("\n\n")
for (file,msgs) in _failmsg:
error = str(msgs[0])
if error[0:11] == "exceptions.":
@ -260,7 +271,7 @@ def build_tree(tree,list,task):
# load_plugins
#
#-------------------------------------------------------------------------
def load_plugins(dir):
def load_plugins(direct):
"""Searches the specified directory, and attempts to load any python
modules that it finds, adding name to the _attempts list. If the module
successfully loads, it is added to the _success list. Each plugin is
@ -270,17 +281,17 @@ def load_plugins(dir):
global _success,_failed,_attempt,_loaddir
# if the directory does not exist, do nothing
if not os.path.isdir(dir):
if not os.path.isdir(direct):
return
# if the path has not already been loaded, save it in the _loaddir
# list for use on reloading
if dir not in _loaddir:
_loaddir.append(dir)
if direct not in _loaddir:
_loaddir.append(direct)
# add the directory to the python search path
sys.path.append(dir)
sys.path.append(direct)
pymod = compile(r"^(.*)\.py$")
@ -289,7 +300,7 @@ def load_plugins(dir):
# add it to the _success list. If it fails, add it to the _failure
# list
for file in os.listdir(dir):
for file in os.listdir(direct):
name = os.path.split(file)
match = pymod.match(name[1])
if not match:
@ -361,7 +372,7 @@ def register_import(task, name):
def register_report(task, name,
category=_("Uncategorized"),
description=_("No description was provided"),
description=_unavailable,
xpm=None,
status=_("Unknown")):
"""Register a report with the plugin system"""
@ -372,7 +383,7 @@ def register_report(task, name,
def register_tool(task, name,
category=_("Uncategorized"),
description=_("No description was provided"),
description=_unavailable,
xpm=None,
status=_("Unknown")):
"""Register a tool with the plugin system"""
@ -519,11 +530,10 @@ def get_text_doc_menu(main_menu,tables,callback,obj=None):
#-------------------------------------------------------------------------
#
# get_text_doc_menu
# get_text_doc_list
#
#-------------------------------------------------------------------------
def get_text_doc_list():
l = []
_textdoc.sort()
for item in _textdoc:

View File

@ -305,6 +305,7 @@ personalConstantAttributes = {
"Caste" : "CAST",
"Description" : "DSCR",
"Identification Number" : "IDNO",
"Reference Number" : "REFN",
"National Origin" : "NATI",
"Social Security Number": "SSN"
}
@ -312,6 +313,7 @@ personalConstantAttributes = {
_pa_e2l = {
"Caste" : _("Caste"),
"Description" : _("Description"),
"Reference Number" : _("Reference Number"),
"Identification Number" : _("Identification Number"),
"National Origin" : _("National Origin"),
"Social Security Number": _("Social Security Number")

View File

@ -231,12 +231,14 @@ class OpenOfficeDoc(TextDoc):
(x,y) = image.size()
aspect_ratio = float(x)/float(y)
if aspect_ratio > x_cm/y_cm:
ratio = float(x_cm)*float(y)/(float(y_cm)*float(x))
if ratio < 1:
act_width = x_cm
act_height = y_cm/aspect_ratio
act_height = y_cm*ratio
else:
act_height = y_cm
act_width = x_cm*aspect_ratio
act_width = x_cm/ratio
self.photo_list.append((name,act_width,act_height))

View File

@ -34,12 +34,16 @@ _ = intl.gettext
# ReportLab python/PDF modules
#
#------------------------------------------------------------------------
try:
import reportlab.platypus.tables
from reportlab.platypus import *
from reportlab.lib.units import cm
from reportlab.lib.colors import Color
from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
import reportlab.lib.styles
except:
raise "Missing Libraries", "The ReportLab modules are not installed"
#------------------------------------------------------------------------
#
@ -259,14 +263,15 @@ class PdfDoc(TextDoc):
def add_photo(self,name,pos,x,y):
img = ImgManip.ImgManip(name)
nx,ny = img.size()
scale = float(nx)/float(ny)
if scale > 1.0:
scale = 1.0/scale
act_width = x
act_height = y * scale
ratio = float(x_cm)*float(y)/(float(y_cm)*float(x))
if ratio < 1:
act_width = x_cm
act_height = y_cm*ratio
else:
act_width = x * scale
act_height = y
act_height = y_cm
act_width = x_cm/ratio
self.story.append(Image(name,act_width*cm,act_height*cm))
self.story.append(Spacer(1,0.5*cm))

View File

@ -27,9 +27,12 @@ import Plugins
import intl
_ = intl.gettext
try:
from reportlab.pdfgen import canvas
from reportlab.lib.units import cm
from reportlab.lib.colors import Color
except:
raise "Missing Libraries", "The ReportLab modules are not installed"
def make_color(color):
return Color(float(color[0])/255.0, float(color[1])/255.0,

View File

@ -324,11 +324,18 @@ class RTFDoc(TextDoc):
nx,ny = im.size()
buf = im.jpg_data()
scale = float(ny)/float(nx)
if scale > 1:
scale = 1.0/scale
act_width = twips(x_cm * scale)
act_height = twips(y_cm * scale)
ratio = float(x_cm)*float(y)/(float(y_cm)*float(x))
if ratio < 1:
act_width = x_cm
act_height = y_cm*ratio
else:
act_height = y_cm
act_width = x_cm/ratio
act_width = twips(act_width)
act_height = twips(act_height)
im.thumbnail((int(act_width*40),int(act_height*40)))
self.f.write('{\*\shppict{\\pict\\jpegblip')

View File

@ -700,6 +700,11 @@ class GedcomParser:
source_ref.setBase(self.db.findSource(matches[2],self.smap))
self.parse_source_reference(source_ref,2)
self.person.getPrimaryName().addSourceRef(source_ref)
elif matches[1] == "REFN":
attr = Attribute()
attr.setType("Reference Number")
attr.setValue(matches[2])
self.person.addAttribute(attr)
elif matches[1] in ["AFN","CHAN","REFN","ASSO"]:
self.ignore_sub_junk(2)
elif matches[1] in ["ANCI","DESI","RIN","RFN"]: