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 GrampsCfg
import ListModel
import Date
_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:
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."""
self.person = person
self.original_id = person.getId()

View File

@ -202,6 +202,16 @@ class ListModel:
self.sel_iter = 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):
self.count = self.count + 1
iter = self.model.append()

View File

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

View File

@ -207,7 +207,6 @@ pkgpython_PYTHON = \
# If not using GNU make, then list all files individually
# The latter is more portable and POSIX-friendly :)
GLADEFILES = \
config.glade\
dialog.glade\
edit_person.glade\
errdialogs.glade\
@ -260,7 +259,7 @@ RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \
install-exec-recursive installdirs-recursive install-recursive \
uninstall-recursive check-recursive installcheck-recursive
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)
all: all-recursive

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -119,12 +119,11 @@ class RevisionSelect:
self.model = ListModel.ListModel(self.revlist,titles)
index = 0
for f in l:
a = f[0].split('.')
revsort = ''
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])
def on_cancel_clicked(self,obj):

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -18,19 +18,40 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#-------------------------------------------------------------------------
#
# python modules
#
#-------------------------------------------------------------------------
import string
from math import pi, cos, sin
import cStringIO
#-------------------------------------------------------------------------
#
# Gramps modules
#
#-------------------------------------------------------------------------
import Plugins
from intl import gettext as _
import Errors
import TextDoc
import DrawDoc
from intl import gettext as _
#-------------------------------------------------------------------------
#
# pt2cm - points to cm conversion
#
#-------------------------------------------------------------------------
def pt2cm(val):
return (float(val)/72.0)*2.54
#-------------------------------------------------------------------------
#
# PSDrawDoc
#
#-------------------------------------------------------------------------
class PSDrawDoc(DrawDoc.DrawDoc):
def __init__(self,styles,type,orientation):
@ -129,7 +150,6 @@ class PSDrawDoc(DrawDoc.DrawDoc):
stype = self.draw_styles[style]
pname = stype.get_paragraph_style()
p = self.style_list[pname]
font = p.get_font()
self.f.write('gsave\n')
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()))
val = len(text)
y = ((-font.get_size() * val)/2.0) + font.get_size()
y = ((-size * val)/2.0) + size
for line in text:
self.f.drawCentredString(0,y,line.encode('iso-8859-1'))
y += font.get_size()
y += size
self.f.restoreState()
@ -276,17 +276,14 @@ class PdfDrawDoc(DrawDoc.DrawDoc):
self.f.restoreState()
def left_print(self,text,font,x,y):
size = font.get_size()
self.f.saveState()
self.f.setStrokeColor(make_color(font.get_color()))
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()
def make_color(c):
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 Plugins
import ImgManip
import Errors
from intl import gettext as _

View File

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

View File

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

View File

@ -20,20 +20,37 @@
"Database Processing/Check and repair database"
import RelLib
import Utils
from intl import gettext as _
#-------------------------------------------------------------------------
#
# python modules
#
#-------------------------------------------------------------------------
import os
import cStringIO
import gtk
import gtk.glade
from QuestionDialog import OkDialog, MissingMediaDialog
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):

View File

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

View File

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

View File

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