pychecker fixes

svn: r1750
This commit is contained in:
Don Allingham
2003-06-16 04:57:25 +00:00
parent e6e150b63f
commit cf54cbc309
26 changed files with 106 additions and 73 deletions

View File

@ -50,7 +50,6 @@ import const
import Utils import Utils
import GrampsCfg import GrampsCfg
import ListModel import ListModel
import Date
_titles = [(_('Name'),3,200),(_('ID'),1,50),(_('Birth date'),4,50),('',0,50),('',0,0)] _titles = [(_('Name'),3,200),(_('ID'),1,50),(_('Birth date'),4,50),('',0,50),('',0,0)]

View File

@ -72,7 +72,7 @@ pycode_tgts = [('url', 0, 0),
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class EditPerson: class EditPerson:
def __init__(self,person,db,callback=None,gender=RelLib.Person.female): def __init__(self,person,db,callback=None):
"""Creates an edit window. Associates a person with the window.""" """Creates an edit window. Associates a person with the window."""
self.person = person self.person = person
self.original_id = person.getId() self.original_id = person.getId()

View File

@ -202,6 +202,16 @@ class ListModel:
self.sel_iter = iter self.sel_iter = iter
return iter return iter
def set(self,iter,data,info=None,select=0):
col = 0
for object in data:
self.model.set_value(iter,col,object)
col = col + 1
self.model.set_value(iter,col,info)
if select:
self.sel_iter = iter
return iter
def add_and_select(self,data,info=None): def add_and_select(self,data,info=None):
self.count = self.count + 1 self.count = self.count + 1
iter = self.model.append() iter = self.model.append()

View File

@ -97,7 +97,6 @@ pkgpython_PYTHON = \
# If not using GNU make, then list all files individually # If not using GNU make, then list all files individually
# The latter is more portable and POSIX-friendly :) # The latter is more portable and POSIX-friendly :)
GLADEFILES = \ GLADEFILES = \
config.glade\
dialog.glade\ dialog.glade\
edit_person.glade\ edit_person.glade\
errdialogs.glade\ errdialogs.glade\

View File

@ -207,7 +207,6 @@ pkgpython_PYTHON = \
# If not using GNU make, then list all files individually # If not using GNU make, then list all files individually
# The latter is more portable and POSIX-friendly :) # The latter is more portable and POSIX-friendly :)
GLADEFILES = \ GLADEFILES = \
config.glade\
dialog.glade\ dialog.glade\
edit_person.glade\ edit_person.glade\
errdialogs.glade\ errdialogs.glade\
@ -260,7 +259,7 @@ RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \
install-exec-recursive installdirs-recursive install-recursive \ install-exec-recursive installdirs-recursive install-recursive \
uninstall-recursive check-recursive installcheck-recursive uninstall-recursive check-recursive installcheck-recursive
DIST_COMMON = README $(dist_pkgdata_DATA) $(pkgpython_PYTHON) AUTHORS \ DIST_COMMON = README $(dist_pkgdata_DATA) $(pkgpython_PYTHON) AUTHORS \
ChangeLog Makefile.am Makefile.in NEWS TODO const.py.in ChangeLog Makefile.am Makefile.in NEWS const.py.in
DIST_SUBDIRS = $(SUBDIRS) DIST_SUBDIRS = $(SUBDIRS)
all: all-recursive all: all-recursive

View File

@ -505,7 +505,6 @@ def register_draw_doc(name,classref,paper,style, ext):
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def register_relcalc(func, languages): def register_relcalc(func, languages):
"""Register a relationshp calculator""" """Register a relationshp calculator"""
import sys
global _relcalc_task global _relcalc_task
try: try:

View File

@ -206,7 +206,6 @@ def importData(database, filename, callback,cl=0):
for OldMediaID in parser.MediaFileMap.keys(): for OldMediaID in parser.MediaFileMap.keys():
NewMediaID = parser.MediaFileMap[OldMediaID] NewMediaID = parser.MediaFileMap[OldMediaID]
oldfile = ObjectMap[NewMediaID].getPath() oldfile = ObjectMap[NewMediaID].getPath()
oldpath = os.path.dirname(oldfile)
(junk,oldext) = os.path.splitext(os.path.basename(oldfile)) (junk,oldext) = os.path.splitext(os.path.basename(oldfile))
oldfile = os.path.join(basefile,OldMediaID+oldext) oldfile = os.path.join(basefile,OldMediaID+oldext)
newfile = os.path.join(newpath,NewMediaID+oldext) newfile = os.path.join(newpath,NewMediaID+oldext)

View File

@ -176,7 +176,7 @@ def get_nephew(level):
return _nephew_level[level] return _nephew_level[level]
def get_niece(level): def get_niece(level):
return _niece_level[level],f return _niece_level[level]
def is_spouse(orig,other): def is_spouse(orig,other):
for f in orig.getFamilyList(): for f in orig.getFamilyList():
@ -199,9 +199,6 @@ def get_relationship(orig_person,other_person):
if orig_person == None: if orig_person == None:
return ("undefined",[]) return ("undefined",[])
firstName = orig_person.getPrimaryName().getRegularName()
secondName = other_person.getPrimaryName().getRegularName()
if orig_person == other_person: if orig_person == other_person:
return ('', []) return ('', [])
if is_spouse(orig_person,other_person): if is_spouse(orig_person,other_person):

View File

@ -787,8 +787,8 @@ class ReportDialog(BareReportDialog):
def get_default_basename(self): def get_default_basename(self):
"""What should the default name be? """What should the default name be?
""" """
path = self.get_stylesheet_savefile() spath = self.get_stylesheet_savefile()
return path.split('.')[0] return spath.split('.')[0]
def get_print_pagecount_map(self): def get_print_pagecount_map(self):
"""Return the data used to fill out the 'pagecount' option """Return the data used to fill out the 'pagecount' option
@ -859,11 +859,11 @@ class ReportDialog(BareReportDialog):
if not self.get_target_is_directory(): if not self.get_target_is_directory():
fname = self.target_fileentry.get_full_path(0) fname = self.target_fileentry.get_full_path(0)
(path,ext) = os.path.splitext(fname) (spath,ext) = os.path.splitext(fname)
ext_val = obj.get_data('ext') ext_val = obj.get_data('ext')
if ext_val: if ext_val:
fname = path + ext_val fname = spath + ext_val
self.target_fileentry.set_filename(fname) self.target_fileentry.set_filename(fname)
# Does this report format use styles? # Does this report format use styles?
@ -909,8 +909,8 @@ class ReportDialog(BareReportDialog):
self.tbl.attach(self.target_fileentry,2,4,self.col,self.col+1) self.tbl.attach(self.target_fileentry,2,4,self.col,self.col+1)
self.col += 1 self.col += 1
path = self.get_default_directory() spath = self.get_default_directory()
self.target_fileentry.set_default_path(path) self.target_fileentry.set_default_path(spath)
def setup_format_frame(self): def setup_format_frame(self):
@ -931,13 +931,13 @@ class ReportDialog(BareReportDialog):
if ext == None: if ext == None:
ext = "" ext = ""
if type: if type:
path = self.get_default_directory() spath = self.get_default_directory()
if self.get_target_is_directory(): if self.get_target_is_directory():
self.target_fileentry.set_filename(path) self.target_fileentry.set_filename(spath)
else: else:
base = self.get_default_basename() base = self.get_default_basename()
path = os.path.normpath("%s/%s%s" % (path,base,ext)) spath = os.path.normpath("%s/%s%s" % (spath,base,ext))
self.target_fileentry.set_filename(path) self.target_fileentry.set_filename(spath)
def setup_output_notebook(self): def setup_output_notebook(self):
@ -1310,12 +1310,12 @@ class TemplateParser(handler.ContentHandler):
try: try:
parser = make_parser() parser = make_parser()
path = const.template_dir apath = const.template_dir
parser.setContentHandler(TemplateParser(_template_map,path)) parser.setContentHandler(TemplateParser(_template_map,spath))
parser.parse("file://%s/templates.xml" % path) parser.parse("file://%s/templates.xml" % spath)
parser = make_parser() parser = make_parser()
path = os.path.expanduser("~/.gramps/templates") spath = os.path.expanduser("~/.gramps/templates")
parser.setContentHandler(TemplateParser(_template_map,path)) parser.setContentHandler(TemplateParser(_template_map,spath))
parser.parse("file://%s/templates.xml" % path) parser.parse("file://%s/templates.xml" % spath)
except (IOError,OSError,SAXParseException): except (IOError,OSError,SAXParseException):
pass pass

View File

@ -23,7 +23,6 @@ import gtk.glade
import gnome import gnome
import gnome.ui import gnome.ui
import gconf import gconf
import Utils
from intl import gettext as _ from intl import gettext as _

View File

@ -89,14 +89,12 @@ class StyleListDisplay:
"""Redraws the list of styles that are current available""" """Redraws the list of styles that are current available"""
self.list.model.clear() self.list.model.clear()
sheet = self.sheetlist.get_style_sheet("default")
self.list.add(["default"]) self.list.add(["default"])
index = 1 index = 1
for style in self.sheetlist.get_style_names(): for style in self.sheetlist.get_style_names():
if style == "default": if style == "default":
continue continue
sheet = self.sheetlist.get_style_sheet(style)
self.list.add([style]) self.list.add([style])
index = index + 1 index = index + 1

View File

@ -119,12 +119,11 @@ class RevisionSelect:
self.model = ListModel.ListModel(self.revlist,titles) self.model = ListModel.ListModel(self.revlist,titles)
index = 0
for f in l: for f in l:
a = f[0].split('.') a = f[0].split('.')
revsort = '' revsort = ''
for v in a: for v in a:
revsort = "%s.%06d" % (revsort,int(a[0])) revsort = "%s.%06d" % (revsort,int(v))
self.model.add([f[0],f[1],f[3],f[2],revsort],f[0]) self.model.add([f[0],f[1],f[3],f[2],revsort],f[0])
def on_cancel_clicked(self,obj): def on_cancel_clicked(self,obj):

View File

@ -26,14 +26,14 @@ Provides a TextDoc based interface to the AbiWord document format.
# Imported Modules # Imported Modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import os
import base64 import base64
import TextDoc import TextDoc
from latin_utf8 import latin_to_utf8 import Errors
import string
import Plugins import Plugins
import ImgManip import ImgManip
from latin_utf8 import latin_to_utf8
from intl import gettext as _ from intl import gettext as _
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -194,7 +194,6 @@ class AbiWordDoc(TextDoc.TextDoc):
self.icount += 1 self.icount += 1
def start_superscript(self): def start_superscript(self):
fsize = self.my_para.get_font().get_size()
self.text = self.text + '<c props="text-position:superscript">' self.text = self.text + '<c props="text-position:superscript">'
def end_superscript(self): def end_superscript(self):

View File

@ -34,6 +34,7 @@ from latin_utf8 import latin_to_utf8
import string import string
import Plugins import Plugins
import ImgManip import ImgManip
import Errors
from intl import gettext as _ from intl import gettext as _
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -140,7 +141,6 @@ class AbiWordDoc(TextDoc.TextDoc):
self.f.write('height:%.3fin"/>' % act_height) self.f.write('height:%.3fin"/>' % act_height)
def start_superscript(self): def start_superscript(self):
fsize = self.my_para.get_font().get_size()
self.text = self.text + '<c props="text-position:superscript">' self.text = self.text + '<c props="text-position:superscript">'
def end_superscript(self): def end_superscript(self):

View File

@ -28,7 +28,7 @@ import Plugins
import ImgManip import ImgManip
import TarFile import TarFile
import const import const
import Errors
import TextDoc import TextDoc
from intl import gettext as _ from intl import gettext as _

View File

@ -22,8 +22,7 @@ import TextDoc
from latin_utf8 import latin_to_utf8 from latin_utf8 import latin_to_utf8
import time import time
import StringIO import cStringIO
import string
import gzip import gzip
import Errors import Errors
@ -51,8 +50,8 @@ class KwordDoc(TextDoc.TextDoc):
else: else:
self.filename = filename self.filename = filename
self.f = StringIO.StringIO() self.f = cStringIO.StringIO()
self.m = StringIO.StringIO() self.m = cStringIO.StringIO()
self.m.write('<?xml version="1.0" encoding="UTF-8"?>') self.m.write('<?xml version="1.0" encoding="UTF-8"?>')
self.m.write('<!DOCTYPE document-info ><document-info>\n') self.m.write('<!DOCTYPE document-info ><document-info>\n')

View File

@ -38,6 +38,8 @@ import string
import TextDoc import TextDoc
import Plugins import Plugins
import ImgManip import ImgManip
import Errors
from intl import gettext as _ from intl import gettext as _
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -206,15 +208,12 @@ class LaTeXDoc(TextDoc.TextDoc):
thisstyle.font_end = thisstyle.font_end + " " thisstyle.font_end = thisstyle.font_end + " "
left = style.get_left_margin() left = style.get_left_margin()
right = style.get_right_margin()
first = style.get_first_indent() + left first = style.get_first_indent() + left
thisstyle.leftIndent = left thisstyle.leftIndent = left
thisstyle.firstLineIndent = first thisstyle.firstLineIndent = first
self.latexstyle[style_name] = thisstyle self.latexstyle[style_name] = thisstyle
def close(self): def close(self):
"""Clean up and close the document""" """Clean up and close the document"""

View File

@ -18,19 +18,40 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
#-------------------------------------------------------------------------
#
# python modules
#
#-------------------------------------------------------------------------
import string import string
from math import pi, cos, sin from math import pi, cos, sin
import cStringIO #-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
import Plugins import Plugins
from intl import gettext as _ import Errors
import TextDoc import TextDoc
import DrawDoc import DrawDoc
from intl import gettext as _
#-------------------------------------------------------------------------
#
# pt2cm - points to cm conversion
#
#-------------------------------------------------------------------------
def pt2cm(val): def pt2cm(val):
return (float(val)/72.0)*2.54 return (float(val)/72.0)*2.54
#-------------------------------------------------------------------------
#
# PSDrawDoc
#
#-------------------------------------------------------------------------
class PSDrawDoc(DrawDoc.DrawDoc): class PSDrawDoc(DrawDoc.DrawDoc):
def __init__(self,styles,type,orientation): def __init__(self,styles,type,orientation):
@ -129,7 +150,6 @@ class PSDrawDoc(DrawDoc.DrawDoc):
stype = self.draw_styles[style] stype = self.draw_styles[style]
pname = stype.get_paragraph_style() pname = stype.get_paragraph_style()
p = self.style_list[pname] p = self.style_list[pname]
font = p.get_font()
self.f.write('gsave\n') self.f.write('gsave\n')
self.f.write('%.4f %.4f %.4f setrgbcolor\n' % rgb_color(stype.get_color())) self.f.write('%.4f %.4f %.4f setrgbcolor\n' % rgb_color(stype.get_color()))

View File

@ -231,11 +231,11 @@ class PdfDrawDoc(DrawDoc.DrawDoc):
self.f.setFillColor(make_color(font.get_color())) self.f.setFillColor(make_color(font.get_color()))
val = len(text) val = len(text)
y = ((-font.get_size() * val)/2.0) + font.get_size() y = ((-size * val)/2.0) + size
for line in text: for line in text:
self.f.drawCentredString(0,y,line.encode('iso-8859-1')) self.f.drawCentredString(0,y,line.encode('iso-8859-1'))
y += font.get_size() y += size
self.f.restoreState() self.f.restoreState()
@ -276,17 +276,14 @@ class PdfDrawDoc(DrawDoc.DrawDoc):
self.f.restoreState() self.f.restoreState()
def left_print(self,text,font,x,y): def left_print(self,text,font,x,y):
size = font.get_size()
self.f.saveState() self.f.saveState()
self.f.setStrokeColor(make_color(font.get_color())) self.f.setStrokeColor(make_color(font.get_color()))
self.pdf_set_font(font) self.pdf_set_font(font)
self.f.drawString(start_x,start_y,text.encode('iso-8859-1')) self.f.drawString(x,y,text.encode('iso-8859-1'))
self.f.restoreState() self.f.restoreState()
def make_color(c): def make_color(c):
return Color(float(c[0])/255.0, float(c[1])/255.0, float(c[2])/255.0) return Color(float(c[0])/255.0, float(c[1])/255.0, float(c[2])/255.0)

View File

@ -26,6 +26,7 @@
import TextDoc import TextDoc
import Plugins import Plugins
import ImgManip import ImgManip
import Errors
from intl import gettext as _ from intl import gettext as _

View File

@ -99,13 +99,11 @@ class SvgDrawDoc(DrawDoc.DrawDoc):
font = p.get_font() font = p.get_font()
size = font.get_size() size = font.get_size()
height = size*(len(text))
width = 0 width = 0
for line in text: for line in text:
width = max(width,FontScale.string_width(font,line)) width = max(width,FontScale.string_width(font,line))
rangle = -((pi/180.0) * angle) # rangle = -((pi/180.0) * angle)
centerx,centery = units((x+self.lmargin,y+self.tmargin)) centerx,centery = units((x+self.lmargin,y+self.tmargin))
yh = 0 yh = 0
@ -116,15 +114,13 @@ class SvgDrawDoc(DrawDoc.DrawDoc):
ypos = (centery) ypos = (centery)
xd = 0 xd = 0
yd = yh yd = yh
# xd = yh * sin(-rangle) # xd = yh * sin(-rangle)
# yd = yh * cos(-rangle) # yd = yh * cos(-rangle)
print centerx, centery, xpos, ypos, angle, line
self.f.write('<text ') self.f.write('<text ')
self.f.write('x="%4.2f" y="%4.2f" ' % (xpos+xd,ypos+yd)) self.f.write('x="%4.2f" y="%4.2f" ' % (xpos+xd,ypos+yd))
# self.f.write('transform="rotate(%d) ' % angle) # self.f.write('transform="rotate(%d) ' % angle)
# self.f.write(' translate(%.8f,%.8f)" ' % (-xpos,-ypos)) # self.f.write(' translate(%.8f,%.8f)" ' % (-xpos,-ypos))
self.f.write('style="fill:#%02x%02x%02x; '% font.get_color()) self.f.write('style="fill:#%02x%02x%02x; '% font.get_color())
if font.get_bold(): if font.get_bold():
self.f.write('font-weight:"bold";') self.f.write('font-weight:"bold";')

View File

@ -216,7 +216,7 @@ class Gramps:
os.mkdir(self.impdir_path,0700) os.mkdir(self.impdir_path,0700)
except: except:
print "Could not create import directory %s. Exiting." \ print "Could not create import directory %s. Exiting." \
% impdir_path % self.impdir_path
os._exit(1) os._exit(1)
elif not os.access(self.impdir_path,os.W_OK): elif not os.access(self.impdir_path,os.W_OK):
print "Import directory %s is not writable. Exiting." \ print "Import directory %s is not writable. Exiting." \
@ -737,9 +737,11 @@ class Gramps:
def clear_person_tabs(self): def clear_person_tabs(self):
self.ptabs.hide()
for i in range(0,len(self.tab_list)): for i in range(0,len(self.tab_list)):
self.ptabs.remove_page(0) self.ptabs.remove_page(0)
self.ptabs.set_show_tabs(0) self.ptabs.set_show_tabs(0)
self.ptabs.show()
self.id2col = {} self.id2col = {}
self.tab_list = [] self.tab_list = []
self.alpha_page = {} self.alpha_page = {}

View File

@ -20,20 +20,37 @@
"Database Processing/Check and repair database" "Database Processing/Check and repair database"
import RelLib #-------------------------------------------------------------------------
import Utils #
from intl import gettext as _ # python modules
#
#-------------------------------------------------------------------------
import os import os
import cStringIO import cStringIO
import gtk
import gtk.glade
from QuestionDialog import OkDialog, MissingMediaDialog
import shutil import shutil
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# gtk modules
# #
#-------------------------------------------------------------------------
import gtk
import gtk.glade
#-------------------------------------------------------------------------
#
# gtk modules
#
#-------------------------------------------------------------------------
import RelLib
import Utils
from intl import gettext as _
from QuestionDialog import OkDialog, MissingMediaDialog
#-------------------------------------------------------------------------
#
# runTool
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def runTool(database,active_person,callback): def runTool(database,active_person,callback):

View File

@ -44,6 +44,8 @@ import Utils
import Report import Report
import TextDoc import TextDoc
import GenericFilter import GenericFilter
import Errors
from intl import gettext as _ from intl import gettext as _
from latin_utf8 import utf8_to_latin from latin_utf8 import utf8_to_latin
@ -271,6 +273,7 @@ class GraphVizDialog(Report.ReportDialog):
try: try:
ind_list = self.filter.apply(self.db, self.db.getPersonMap().values()) ind_list = self.filter.apply(self.db, self.db.getPersonMap().values())
except Errors.FilterError, msg: except Errors.FilterError, msg:
from QuestionDialog import ErrorDialog
(m1,m2) = msg.messages() (m1,m2) = msg.messages()
ErrorDialog(m1,m2) ErrorDialog(m1,m2)

View File

@ -117,6 +117,7 @@ pythondir = @pythondir@
pkgpython_PYTHON = \ pkgpython_PYTHON = \
AncestorChart.py\ AncestorChart.py\
AncestorReport.py\ AncestorReport.py\
Ancestors.py\
ChangeTypes.py\ ChangeTypes.py\
Check.py\ Check.py\
count_anc.py\ count_anc.py\

View File

@ -40,6 +40,7 @@ def runTool(db,active_person,callback):
class ReorderIds: class ReorderIds:
def __init__(self,db,callback): def __init__(self,db,callback):
self.db = db self.db = db
self.reorder(db.getPersonMap(),db.iprefix,db.buildPersonDisplay) self.reorder(db.getPersonMap(),db.iprefix,db.buildPersonDisplay)
@ -49,7 +50,7 @@ class ReorderIds:
self.reorder(db.getPlaceMap(),db.pprefix,db.buildPlaceDisplay) self.reorder(db.getPlaceMap(),db.pprefix,db.buildPlaceDisplay)
Utils.modified() Utils.modified()
callback(1) callback(1)
def reorder(self,data_map,prefix,update): def reorder(self,data_map,prefix,update):
"""Try to extract the old integer out of the id, and reuse it """Try to extract the old integer out of the id, and reuse it
if possible. Otherwise, blindly renumber those that can't.""" if possible. Otherwise, blindly renumber those that can't."""