handle things if no document generators are available
svn: r800
This commit is contained in:
parent
588fbbb7e5
commit
952d0758a2
@ -29,6 +29,8 @@ import Utils
|
|||||||
import gtk
|
import gtk
|
||||||
import const
|
import const
|
||||||
import GrampsCfg
|
import GrampsCfg
|
||||||
|
import intl
|
||||||
|
_ = intl.gettext
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
@ -72,6 +72,7 @@ _textdoc = []
|
|||||||
_drawdoc = []
|
_drawdoc = []
|
||||||
_failmsg = []
|
_failmsg = []
|
||||||
|
|
||||||
|
_unavailable = _("No description was provided"),
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Constants
|
# Constants
|
||||||
@ -186,7 +187,14 @@ class ToolPlugins:
|
|||||||
self.run_tool = obj.get_data(TASK)
|
self.run_tool = obj.get_data(TASK)
|
||||||
|
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# PluginStatus
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
class PluginStatus:
|
class PluginStatus:
|
||||||
|
"""Displays a dialog showing the status of loaded plugins"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
import cStringIO
|
import cStringIO
|
||||||
|
|
||||||
@ -195,6 +203,9 @@ class PluginStatus:
|
|||||||
window = self.glade.get_widget("text")
|
window = self.glade.get_widget("text")
|
||||||
|
|
||||||
info = cStringIO.StringIO()
|
info = cStringIO.StringIO()
|
||||||
|
info.write(_("The following modules could not be loaded:"))
|
||||||
|
info.write("\n\n")
|
||||||
|
|
||||||
for (file,msgs) in _failmsg:
|
for (file,msgs) in _failmsg:
|
||||||
error = str(msgs[0])
|
error = str(msgs[0])
|
||||||
if error[0:11] == "exceptions.":
|
if error[0:11] == "exceptions.":
|
||||||
@ -260,7 +271,7 @@ def build_tree(tree,list,task):
|
|||||||
# load_plugins
|
# load_plugins
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
def load_plugins(dir):
|
def load_plugins(direct):
|
||||||
"""Searches the specified directory, and attempts to load any python
|
"""Searches the specified directory, and attempts to load any python
|
||||||
modules that it finds, adding name to the _attempts list. If the module
|
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
|
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
|
global _success,_failed,_attempt,_loaddir
|
||||||
|
|
||||||
# if the directory does not exist, do nothing
|
# if the directory does not exist, do nothing
|
||||||
if not os.path.isdir(dir):
|
if not os.path.isdir(direct):
|
||||||
return
|
return
|
||||||
|
|
||||||
# if the path has not already been loaded, save it in the _loaddir
|
# if the path has not already been loaded, save it in the _loaddir
|
||||||
# list for use on reloading
|
# list for use on reloading
|
||||||
|
|
||||||
if dir not in _loaddir:
|
if direct not in _loaddir:
|
||||||
_loaddir.append(dir)
|
_loaddir.append(direct)
|
||||||
|
|
||||||
# add the directory to the python search path
|
# add the directory to the python search path
|
||||||
sys.path.append(dir)
|
sys.path.append(direct)
|
||||||
|
|
||||||
pymod = compile(r"^(.*)\.py$")
|
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
|
# add it to the _success list. If it fails, add it to the _failure
|
||||||
# list
|
# list
|
||||||
|
|
||||||
for file in os.listdir(dir):
|
for file in os.listdir(direct):
|
||||||
name = os.path.split(file)
|
name = os.path.split(file)
|
||||||
match = pymod.match(name[1])
|
match = pymod.match(name[1])
|
||||||
if not match:
|
if not match:
|
||||||
@ -361,7 +372,7 @@ def register_import(task, name):
|
|||||||
|
|
||||||
def register_report(task, name,
|
def register_report(task, name,
|
||||||
category=_("Uncategorized"),
|
category=_("Uncategorized"),
|
||||||
description=_("No description was provided"),
|
description=_unavailable,
|
||||||
xpm=None,
|
xpm=None,
|
||||||
status=_("Unknown")):
|
status=_("Unknown")):
|
||||||
"""Register a report with the plugin system"""
|
"""Register a report with the plugin system"""
|
||||||
@ -372,7 +383,7 @@ def register_report(task, name,
|
|||||||
|
|
||||||
def register_tool(task, name,
|
def register_tool(task, name,
|
||||||
category=_("Uncategorized"),
|
category=_("Uncategorized"),
|
||||||
description=_("No description was provided"),
|
description=_unavailable,
|
||||||
xpm=None,
|
xpm=None,
|
||||||
status=_("Unknown")):
|
status=_("Unknown")):
|
||||||
"""Register a tool with the plugin system"""
|
"""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():
|
def get_text_doc_list():
|
||||||
|
|
||||||
l = []
|
l = []
|
||||||
_textdoc.sort()
|
_textdoc.sort()
|
||||||
for item in _textdoc:
|
for item in _textdoc:
|
||||||
|
@ -305,6 +305,7 @@ personalConstantAttributes = {
|
|||||||
"Caste" : "CAST",
|
"Caste" : "CAST",
|
||||||
"Description" : "DSCR",
|
"Description" : "DSCR",
|
||||||
"Identification Number" : "IDNO",
|
"Identification Number" : "IDNO",
|
||||||
|
"Reference Number" : "REFN",
|
||||||
"National Origin" : "NATI",
|
"National Origin" : "NATI",
|
||||||
"Social Security Number": "SSN"
|
"Social Security Number": "SSN"
|
||||||
}
|
}
|
||||||
@ -312,6 +313,7 @@ personalConstantAttributes = {
|
|||||||
_pa_e2l = {
|
_pa_e2l = {
|
||||||
"Caste" : _("Caste"),
|
"Caste" : _("Caste"),
|
||||||
"Description" : _("Description"),
|
"Description" : _("Description"),
|
||||||
|
"Reference Number" : _("Reference Number"),
|
||||||
"Identification Number" : _("Identification Number"),
|
"Identification Number" : _("Identification Number"),
|
||||||
"National Origin" : _("National Origin"),
|
"National Origin" : _("National Origin"),
|
||||||
"Social Security Number": _("Social Security Number")
|
"Social Security Number": _("Social Security Number")
|
||||||
|
@ -231,12 +231,14 @@ class OpenOfficeDoc(TextDoc):
|
|||||||
(x,y) = image.size()
|
(x,y) = image.size()
|
||||||
aspect_ratio = float(x)/float(y)
|
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_width = x_cm
|
||||||
act_height = y_cm/aspect_ratio
|
act_height = y_cm*ratio
|
||||||
else:
|
else:
|
||||||
act_height = y_cm
|
act_height = y_cm
|
||||||
act_width = x_cm*aspect_ratio
|
act_width = x_cm/ratio
|
||||||
|
|
||||||
self.photo_list.append((name,act_width,act_height))
|
self.photo_list.append((name,act_width,act_height))
|
||||||
|
|
||||||
|
@ -34,12 +34,16 @@ _ = intl.gettext
|
|||||||
# ReportLab python/PDF modules
|
# ReportLab python/PDF modules
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
import reportlab.platypus.tables
|
|
||||||
from reportlab.platypus import *
|
try:
|
||||||
from reportlab.lib.units import cm
|
import reportlab.platypus.tables
|
||||||
from reportlab.lib.colors import Color
|
from reportlab.platypus import *
|
||||||
from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
|
from reportlab.lib.units import cm
|
||||||
import reportlab.lib.styles
|
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):
|
def add_photo(self,name,pos,x,y):
|
||||||
img = ImgManip.ImgManip(name)
|
img = ImgManip.ImgManip(name)
|
||||||
nx,ny = img.size()
|
nx,ny = img.size()
|
||||||
scale = float(nx)/float(ny)
|
|
||||||
if scale > 1.0:
|
ratio = float(x_cm)*float(y)/(float(y_cm)*float(x))
|
||||||
scale = 1.0/scale
|
|
||||||
act_width = x
|
if ratio < 1:
|
||||||
act_height = y * scale
|
act_width = x_cm
|
||||||
|
act_height = y_cm*ratio
|
||||||
else:
|
else:
|
||||||
act_width = x * scale
|
act_height = y_cm
|
||||||
act_height = y
|
act_width = x_cm/ratio
|
||||||
|
|
||||||
self.story.append(Image(name,act_width*cm,act_height*cm))
|
self.story.append(Image(name,act_width*cm,act_height*cm))
|
||||||
self.story.append(Spacer(1,0.5*cm))
|
self.story.append(Spacer(1,0.5*cm))
|
||||||
|
@ -27,9 +27,12 @@ import Plugins
|
|||||||
import intl
|
import intl
|
||||||
_ = intl.gettext
|
_ = intl.gettext
|
||||||
|
|
||||||
from reportlab.pdfgen import canvas
|
try:
|
||||||
from reportlab.lib.units import cm
|
from reportlab.pdfgen import canvas
|
||||||
from reportlab.lib.colors import Color
|
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):
|
def make_color(color):
|
||||||
return Color(float(color[0])/255.0, float(color[1])/255.0,
|
return Color(float(color[0])/255.0, float(color[1])/255.0,
|
||||||
|
@ -324,11 +324,18 @@ class RTFDoc(TextDoc):
|
|||||||
nx,ny = im.size()
|
nx,ny = im.size()
|
||||||
buf = im.jpg_data()
|
buf = im.jpg_data()
|
||||||
|
|
||||||
scale = float(ny)/float(nx)
|
ratio = float(x_cm)*float(y)/(float(y_cm)*float(x))
|
||||||
if scale > 1:
|
|
||||||
scale = 1.0/scale
|
if ratio < 1:
|
||||||
act_width = twips(x_cm * scale)
|
act_width = x_cm
|
||||||
act_height = twips(y_cm * scale)
|
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)))
|
im.thumbnail((int(act_width*40),int(act_height*40)))
|
||||||
|
|
||||||
self.f.write('{\*\shppict{\\pict\\jpegblip')
|
self.f.write('{\*\shppict{\\pict\\jpegblip')
|
||||||
|
@ -700,6 +700,11 @@ class GedcomParser:
|
|||||||
source_ref.setBase(self.db.findSource(matches[2],self.smap))
|
source_ref.setBase(self.db.findSource(matches[2],self.smap))
|
||||||
self.parse_source_reference(source_ref,2)
|
self.parse_source_reference(source_ref,2)
|
||||||
self.person.getPrimaryName().addSourceRef(source_ref)
|
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"]:
|
elif matches[1] in ["AFN","CHAN","REFN","ASSO"]:
|
||||||
self.ignore_sub_junk(2)
|
self.ignore_sub_junk(2)
|
||||||
elif matches[1] in ["ANCI","DESI","RIN","RFN"]:
|
elif matches[1] in ["ANCI","DESI","RIN","RFN"]:
|
||||||
|
Loading…
Reference in New Issue
Block a user