Remove unneeded line continuations and tidy up

svn: r16472
This commit is contained in:
Gerald Britton 2011-01-25 18:47:12 +00:00
parent 891b3d66c1
commit adf976821f
13 changed files with 219 additions and 175 deletions

View File

@ -445,8 +445,9 @@ class BookList(object):
escape(option_name),
len(options[option_name]) ) )
for list_index in range(len(option_value)):
option_type = \
Utils.type_name(option_value[list_index])
option_type = Utils.type_name(
option_value[list_index]
)
value = escape(unicode(option_value[list_index]))
value = value.replace('"', '"')
f.write(' <listitem number="%d" type="%s" '
@ -482,7 +483,7 @@ class BookList(object):
the_file = open(self.file)
p.parse(the_file)
the_file.close()
except (IOError, OSError, ValueError, SAXParseException, KeyError, \
except (IOError, OSError, ValueError, SAXParseException, KeyError,
AttributeError):
pass

View File

@ -36,8 +36,8 @@ from gen.ggettext import gettext as _
#
#------------------------------------------------------------------------
from gui.utils import open_file_with_default_application
from gen.plug.docgen import BaseDoc, TextDoc,\
PARA_ALIGN_RIGHT, PARA_ALIGN_CENTER
from gen.plug.docgen import (BaseDoc, TextDoc,
PARA_ALIGN_RIGHT, PARA_ALIGN_CENTER)
import Errors
import Utils
@ -247,8 +247,10 @@ class AsciiDoc(BaseDoc,TextDoc):
start_at = regular_indent + min(len(self.leader)+first_indent,0)
this_text = reformat_para(self.text,regular_indent,right,fmt,
right_pad)
this_text = ' '*(regular_indent+first_indent) + \
self.leader + this_text[start_at:]
this_text = (' '*(regular_indent+first_indent) +
self.leader +
this_text[start_at:]
)
else:
this_text = self.text
else:
@ -270,8 +272,7 @@ class AsciiDoc(BaseDoc,TextDoc):
this_text += '\n' + the_pad + '\n'
if self.in_cell:
self.cellpars[self.cellnum] = self.cellpars[self.cellnum] + \
this_text
self.cellpars[self.cellnum] += this_text
else:
self.f.write(this_text)
@ -310,8 +311,8 @@ class AsciiDoc(BaseDoc,TextDoc):
self.maxlines = 0
table_width = self.get_usable_width() * self.tbl_style.get_width() / 100.0
for cell in range(self.ncols):
self.cell_widths[cell] = int( table_width * \
self.tbl_style.get_column_width(cell) / 100.0 )
self.cell_widths[cell] = int(table_width *
self.tbl_style.get_column_width(cell) / 100.0)
#--------------------------------------------------------------------
#
@ -326,8 +327,9 @@ class AsciiDoc(BaseDoc,TextDoc):
if self.cell_widths[cell]:
blanks = ' '*self.cell_widths[cell] + '\n'
if self.cell_lines[cell] < self.maxlines:
self.cellpars[cell] = self.cellpars[cell] \
+ blanks * (self.maxlines-self.cell_lines[cell])
self.cellpars[cell] += blanks * (
self.maxlines - self.cell_lines[cell]
)
cell_text[cell] = self.cellpars[cell].split('\n')
for line in range(self.maxlines):
for cell in range(self.ncols):
@ -345,8 +347,9 @@ class AsciiDoc(BaseDoc,TextDoc):
self.cellnum = self.cellnum + span
span -= 1
while span:
self.cell_widths[self.cellnum] += \
self.cell_widths[self.cellnum] += (
self.cell_widths[self.cellnum-span]
)
self.cell_widths[self.cellnum-span] = 0
span -= 1
@ -366,7 +369,7 @@ class AsciiDoc(BaseDoc,TextDoc):
def add_media_object(self, name, align, w_cm, h_cm, alt=''):
this_text = '(photo)'
if self.in_cell:
self.cellpars[self.cellnum] = self.cellpars[self.cellnum] + this_text
self.cellpars[self.cellnum] += this_text
else:
self.f.write(this_text)

View File

@ -368,10 +368,10 @@ class Calendar(Report):
'person' : short_name,
'nyears' : nyears})
alive1 = probably_alive(person, self.database, \
prob_alive_date)
alive2 = probably_alive(spouse, self.database, \
prob_alive_date)
alive1 = probably_alive(person, self.database,
prob_alive_date)
alive2 = probably_alive(spouse, self.database,
prob_alive_date)
if ((self.alive and alive1 and alive2) or not self.alive):
self.add_day_item(text, month, day)

View File

@ -207,8 +207,9 @@ class GrampsXmlWriter(UpdateCallback):
note_len = self.db.get_number_of_notes()
tag_len = self.db.get_number_of_tags()
total_steps = person_len + family_len + event_len + source_len \
+ place_len + repo_len + obj_len + note_len + tag_len
total_steps = (person_len + family_len + event_len + source_len +
place_len + repo_len + obj_len + note_len + tag_len
)
self.set_total(total_steps)
@ -359,9 +360,10 @@ class GrampsXmlWriter(UpdateCallback):
bm_obj_len = len(self.db.media_bookmarks.get())
bm_note_len = len(self.db.note_bookmarks.get())
bm_len = bm_person_len + bm_family_len + bm_event_len \
+ bm_source_len + bm_place_len + bm_repo_len \
+ bm_obj_len + bm_note_len
bm_len = (bm_person_len + bm_family_len + bm_event_len +
bm_source_len + bm_place_len + bm_repo_len +
bm_obj_len + bm_note_len
)
if bm_len > 0:
self.g.write(" <bookmarks>\n")
@ -732,13 +734,18 @@ class GrampsXmlWriter(UpdateCallback):
priv = conf_priv(source_ref)
if p == "" and n == [] and d.is_empty() and q == 2:
self.g.write('<sourceref hlink="%s"%s/>\n' % ("_"+source.get_handle(), priv))
self.g.write('<sourceref hlink="%s"%s/>\n'
% ("_"+source.get_handle(), priv)
)
else:
if q == 2:
self.g.write('<sourceref hlink="%s"%s>\n' % ("_"+source.get_handle(), priv))
self.g.write('<sourceref hlink="%s"%s>\n'
% ("_"+source.get_handle(), priv)
)
else:
self.g.write('<sourceref hlink="%s" conf="%d"%s>\n' % (
"_"+source.get_handle(),q, priv))
self.g.write('<sourceref hlink="%s" conf="%d"%s>\n'
% ("_"+source.get_handle(), q, priv)
)
self.write_line("spage",p,index+1)
self.write_note_list(n,index+1)
self.write_date(d,index+1)
@ -775,7 +782,7 @@ class GrampsXmlWriter(UpdateCallback):
if not obj:
return
sp = " " * index
change_text = ' change="%d"' % obj.get_change_time()
change_text = ' change="%d"' % obj.get_change_time()
handle_text = ' handle="_%s"' % obj.get_handle()
obj_text = '%s<%s' % (sp, tagname)
@ -1022,9 +1029,10 @@ class GrampsXmlWriter(UpdateCallback):
def write_attribute_list(self, list, indent=3):
sp = ' ' * indent
for attr in list:
self.g.write('%s<attribute%s type="%s" value="%s"' % \
self.g.write('%s<attribute%s type="%s" value="%s"' %
(sp,conf_priv(attr),escxml(attr.get_type().xml_str()),
self.fix(attr.get_value())))
self.fix(attr.get_value()))
)
slist = attr.get_source_references()
nlist = attr.get_note_list()
if (len(nlist)+len(slist)) == 0:
@ -1057,19 +1065,25 @@ class GrampsXmlWriter(UpdateCallback):
if corner2_x is None : corner2_x = 100
if corner2_y is None : corner2_y = 100
#don't output not set rectangle
if (corner1_x == corner1_y == corner2_x == corner2_y == 0) or \
(corner1_x == corner1_y == 0 and corner2_x == corner2_y == 100
):
if (corner1_x == corner1_y == corner2_x == corner2_y == 0 or
corner1_x == corner1_y == 0 and
corner2_x == corner2_y == 100):
rect = None
if (len(proplist) + len(nreflist) + len(refslist)) == 0 \
and rect is None:
if (len(proplist) + len(nreflist) + len(refslist) == 0 and
rect is None):
self.g.write("/>\n")
else:
self.g.write(">\n")
if rect is not None :
self.g.write(' %s<region corner1_x="%d" corner1_y="%d" '
'corner2_x="%d" corner2_y="%d"/>\n' %
(sp,corner1_x,corner1_y,corner2_x,corner2_y))
'corner2_x="%d" corner2_y="%d"/>\n' % (
sp,
corner1_x,
corner1_y,
corner2_x,
corner2_y
)
)
self.write_attribute_list(proplist,indent+1)
for ref in refslist:
self.dump_source_ref(ref, indent+1)
@ -1132,8 +1146,14 @@ class GrampsXmlWriter(UpdateCallback):
else:
desc_text = ''
path_text = ' href="%s"' % self.fix(url.get_path())
self.g.write('%s<url%s%s%s%s/>\n' % \
(sp, priv_text, path_text, type_text, desc_text))
self.g.write('%s<url%s%s%s%s/>\n' % (
sp,
priv_text,
path_text,
type_text,
desc_text
)
)
def write_place_obj(self, place, index=1):
self.write_primary_tag("placeobj", place, index)
@ -1142,10 +1162,11 @@ class GrampsXmlWriter(UpdateCallback):
longitude = self.fix(place.get_longitude())
lat = self.fix(place.get_latitude())
main_loc = place.get_main_location()
llen = len(place.get_alternate_locations()) \
+ len(place.get_url_list()) + \
len(place.get_media_list()) + \
len(place.get_source_references())
llen = (len(place.get_alternate_locations()) +
len(place.get_url_list()) +
len(place.get_media_list()) +
len(place.get_source_references())
)
ml_empty = main_loc.is_empty()

View File

@ -39,7 +39,7 @@ class PersonAttributes(Gramplet):
"""
Build the GUI interface.
"""
tip = _('Double-click on a row to view a quick report showing ' + \
tip = _('Double-click on a row to view a quick report showing '
'all people with the selected attribute.')
self.gui.tooltip = tip
top = gtk.TreeView()

View File

@ -38,7 +38,7 @@ class PersonGallery(Gramplet):
"""
Build the GUI interface.
"""
tip = _('Double-click on a picture to view it in the default image ' + \
tip = _('Double-click on a picture to view it in the default image '
'viewer application.')
self.gui.tooltip = tip
self.image_list = []

View File

@ -56,9 +56,9 @@ from DateHandler import displayer as _dd
from gen.plug.report import Report
from gen.plug.report import utils as ReportUtils
from gui.plug.report import MenuReportOptions
from gen.plug.menu import NumberOption, ColorOption, BooleanOption, \
EnumeratedListOption, PersonListOption, \
SurnameColorOption
from gen.plug.menu import (NumberOption, ColorOption, BooleanOption,
EnumeratedListOption, PersonListOption,
SurnameColorOption)
from gen.utils import get_birth_or_fallback, get_death_or_fallback
from gen.display.name import displayer as name_displayer
@ -111,27 +111,27 @@ class FamilyLinesOptions(MenuReportOptions):
# --------------------------------
person_list = PersonListOption(_('People of interest'))
person_list.set_help(_('People of interest are used as a starting ' \
person_list.set_help(_('People of interest are used as a starting '
'point when determining "family lines".'))
menu.add_option(category, 'gidlist', person_list)
followpar = BooleanOption(
_('Follow parents to determine family lines'), True)
followpar.set_help(_('Parents and their ancestors will be ' \
followpar.set_help(_('Parents and their ancestors will be '
'considered when determining "family lines".'))
menu.add_option(category, 'followpar', followpar)
followchild = BooleanOption(_('Follow children to determine ' \
followchild = BooleanOption(_('Follow children to determine '
'"family lines"'), True)
followchild.set_help(_('Children will be considered when ' \
followchild.set_help(_('Children will be considered when '
'determining "family lines".'))
menu.add_option(category, 'followchild', followchild)
remove_extra_people = BooleanOption(
_('Try to remove extra people and families'), True)
remove_extra_people.set_help(_('People and families not directly ' \
'related to people of interest will ' \
'be removed when determining ' \
remove_extra_people.set_help(_('People and families not directly '
'related to people of interest will '
'be removed when determining '
'"family lines".'))
menu.add_option(category, 'removeextra', remove_extra_people)
@ -156,8 +156,8 @@ class FamilyLinesOptions(MenuReportOptions):
menu.add_option(category, 'colorfemales', color_females)
color_unknown = ColorOption(_('Unknown'), '#e0e0e0')
color_unknown.set_help(_('The colour to use when the gender is ' \
'unknown.'))
color_unknown.set_help(
_('The colour to use when the gender is unknown.'))
menu.add_option(category, 'colorunknown', color_unknown)
color_family = ColorOption(_('Families'), '#ffffe0')
@ -225,7 +225,7 @@ class FamilyLinesOptions(MenuReportOptions):
menu.add_option(category, "useroundedcorners", use_roundedcorners)
self.include_dates = BooleanOption(_('Include dates'), True)
self.include_dates.set_help(_('Whether to include dates for people ' \
self.include_dates.set_help(_('Whether to include dates for people '
'and families.'))
menu.add_option(category, 'incdates', self.include_dates)
self.include_dates.connect('value-changed', self.include_dates_changed)
@ -237,19 +237,19 @@ class FamilyLinesOptions(MenuReportOptions):
menu.add_option(category, "justyears", self.justyears)
include_places = BooleanOption(_('Include places'), True)
include_places.set_help(_('Whether to include placenames for people ' \
include_places.set_help(_('Whether to include placenames for people '
'and families.'))
menu.add_option(category, 'incplaces', include_places)
include_num_children = BooleanOption(
_('Include the number of children'), True)
include_num_children.set_help(_('Whether to include the number of ' \
'children for families with more ' \
include_num_children.set_help(_('Whether to include the number of '
'children for families with more '
'than 1 child.'))
menu.add_option(category, 'incchildcnt', include_num_children)
include_private = BooleanOption(_('Include private records'), False)
include_private.set_help(_('Whether to include names, dates, and ' \
include_private.set_help(_('Whether to include names, dates, and '
'families that are marked as private.'))
menu.add_option(category, 'incprivate', include_private)
@ -507,16 +507,15 @@ class FamilyLinesReport(Report):
family = self._db.get_family_from_handle(family_handle)
spouse_handle = ReportUtils.find_spouse(person, family)
if spouse_handle:
if spouse_handle in self._people or \
spouse_handle in ancestorsNotYetProcessed:
if (spouse_handle in self._people or
spouse_handle in ancestorsNotYetProcessed):
self._families.add(family_handle)
# if we have a limit on the number of people, and we've
# reached that limit, then don't attempt to find any
# more ancestors
if self._limitparents and \
( self._maxparents < \
( len(ancestorsNotYetProcessed) + len(self._people) ) ):
if self._limitparents and (self._maxparents <
len(ancestorsNotYetProcessed) + len(self._people)):
# get back to the top of the while loop so we can finish
# processing the people queued up in the "not yet
# processed" list
@ -526,24 +525,20 @@ class FamilyLinesReport(Report):
for family_handle in person.get_parent_family_handle_list():
family = self._db.get_family_from_handle(family_handle)
if (family.private and self._incprivate) or \
not family.private:
if not family.private or self._incprivate:
father = self._db.get_person_from_handle(
family.get_father_handle())
family.get_father_handle())
mother = self._db.get_person_from_handle(
family.get_mother_handle())
family.get_mother_handle())
if father:
if (father.private and self._incprivate) or \
not father.private:
if not father.private or self._incprivate:
ancestorsNotYetProcessed.add(
family.get_father_handle())
family.get_father_handle())
self._families.add(family_handle)
if mother:
if (mother.private and self._incprivate) or \
not mother.private:
if not mother.private or self._incprivate:
ancestorsNotYetProcessed.add(
family.get_mother_handle())
family.get_mother_handle())
self._families.add(family_handle)
def removeUninterestingParents(self):
@ -597,16 +592,16 @@ class FamilyLinesReport(Report):
spouse = self._db.get_person_from_handle(handle)
spouse_handle = handle
spouse_surname = spouse.get_primary_name().get_surname()
spouse_surname = spouse_surname.encode('iso-8859-1',
'xmlcharrefreplace')
spouse_surname = spouse_surname.encode(
'iso-8859-1', 'xmlcharrefreplace'
)
# see if the spouse has parents
if spouse_father_handle is None and \
spouse_mother_handle is None:
if not spouse_father_handle and not spouse_mother_handle:
for family_handle in \
spouse.get_parent_family_handle_list():
family = self._db.get_family_from_handle(
family_handle)
family_handle)
handle = family.get_father_handle()
if handle in self._people:
spouse_father_handle = handle
@ -794,8 +789,7 @@ class FamilyLinesReport(Report):
# output the birth or fallback event
birthStr = None
if bth_event and self._incdates:
if (bth_event.private and self._incprivate) or \
not bth_event.private:
if not bth_event.private or self._incprivate:
date = bth_event.get_date_object()
if self._just_years and date.get_year_valid():
birthStr = '%i' % date.get_year()
@ -805,8 +799,7 @@ class FamilyLinesReport(Report):
# get birth place (one of: city, state, or country) we can use
birthplace = None
if bth_event and self._incplaces:
if (bth_event.private and self._incprivate) or \
not bth_event.private:
if not bth_event.private or self._incprivate:
place = self._db.get_place_from_handle(bth_event.get_place_handle())
if place:
location = place.get_main_location()
@ -820,8 +813,7 @@ class FamilyLinesReport(Report):
# see if we have a deceased date we can use
deathStr = None
if dth_event and self._incdates:
if (dth_event.private and self._incprivate) or \
not dth_event.private:
if not dth_event.private or self._incprivate:
date = dth_event.get_date_object()
if self._just_years and date.get_year_valid():
deathStr = '%i' % date.get_year()
@ -831,8 +823,7 @@ class FamilyLinesReport(Report):
# get death place (one of: city, state, or country) we can use
deathplace = None
if dth_event and self._incplaces:
if (dth_event.private and self._incprivate) or \
not dth_event.private:
if not dth_event.private or self._incprivate:
place = self._db.get_place_from_handle(dth_event.get_place_handle())
if place:
location = place.get_main_location()

View File

@ -263,12 +263,12 @@ class HourGlassOptions(MenuReportOptions):
menu.add_option(category_name, "pid", pid)
max_gen = NumberOption(_('Max Descendant Generations'), 10, 1, 15)
max_gen.set_help(_("The number of generations of descendants to " \
max_gen.set_help(_("The number of generations of descendants to "
"include in the graph"))
menu.add_option(category_name, "maxdescend", max_gen)
max_gen = NumberOption(_('Max Ancestor Generations'), 10, 1, 15)
max_gen.set_help(_("The number of generations of ancestors to " \
max_gen.set_help(_("The number of generations of ancestors to "
"include in the graph"))
menu.add_option(category_name, "maxascend", max_gen)

View File

@ -46,8 +46,8 @@ from gen.ggettext import sgettext as _
# GRAMPS modules
#
#------------------------------------------------------------------------
from gen.plug.menu import BooleanOption, EnumeratedListOption, FilterOption, \
PersonOption, ColorOption
from gen.plug.menu import (BooleanOption, EnumeratedListOption, FilterOption,
PersonOption, ColorOption)
from gen.plug.report import Report
from gen.plug.report import utils as ReportUtils
from gui.plug.report import MenuReportOptions
@ -164,8 +164,10 @@ class RelGraphReport(Report):
self.add_child_links_to_families()
def add_child_links_to_families(self):
"returns string of GraphViz edges linking parents to families or \
children"
"""
returns string of GraphViz edges linking parents to families or
children
"""
# Hash people in a dictionary for faster inclusion checking
person_dict = dict([handle, 1] for handle in self.person_handles)
@ -269,8 +271,8 @@ class RelGraphReport(Report):
for event_ref in fam.get_event_ref_list():
event = self.database.get_event_from_handle(event_ref.ref)
if event.type == gen.lib.EventType.MARRIAGE and \
(event_ref.get_role() == gen.lib.EventRoleType.FAMILY or
event_ref.get_role() == gen.lib.EventRoleType.PRIMARY ):
(event_ref.get_role() == gen.lib.EventRoleType.FAMILY or
event_ref.get_role() == gen.lib.EventRoleType.PRIMARY):
label = self.get_event_string(event)
break
if self.includeid:
@ -548,8 +550,9 @@ class RelGraphOptions(MenuReportOptions):
menu.add_option(category_name, 'colorfemales', color_females)
color_unknown = ColorOption(_('Unknown'), '#e0e0e0')
color_unknown.set_help(_('The colour to use when the gender is ' \
'unknown.'))
color_unknown.set_help(
_('The colour to use when the gender is unknown.')
)
menu.add_option(category_name, 'colorunknown', color_unknown)
color_family = ColorOption(_('Families'), '#ffffe0')

View File

@ -872,8 +872,9 @@ class GedLine(object):
self.data = data[2]
if self.level == 0:
if self.token_text and self.token_text[0] == '@' \
and self.token_text[-1] == '@':
if (self.token_text and self.token_text[0] == '@' and
self.token_text[-1] == '@'):
self.token = TOKEN_ID
self.token_text = self.token_text[1:-1]
self.data = self.data.strip()
@ -2630,8 +2631,8 @@ class GedcomParser(UpdateCallback):
self.__skip_subordinate_levels(1)
elif key in ("SOUR", "SOURCE"):
self.__parse_source(line.token_text, 1)
elif line.data.startswith("SOUR ") or \
line.data.startswith("SOURCE "):
elif (line.data.startswith("SOUR ") or
line.data.startswith("SOURCE ")):
# A source formatted in a single line, for example:
# 0 @S62@ SOUR This is the title of the source
source = self.__find_or_create_source(self.sid_map[line.data])
@ -3911,8 +3912,8 @@ class GedcomParser(UpdateCallback):
child = self.__find_or_create_person(self.pid_map[line.data])
reflist = [ ref for ref in state.family.get_child_ref_list() \
if ref.ref == child.handle ]
reflist = [ref for ref in state.family.get_child_ref_list()
if ref.ref == child.handle]
if reflist: # The child has been referenced already
ref = reflist[0]
@ -4437,8 +4438,8 @@ class GedcomParser(UpdateCallback):
if not line.data:
# empty: discard, with warning and skip subs
# Note: level+2
msg = _("Line %d: empty event note was ignored.")\
% line.line
msg = _("Line %d: empty event note was ignored.") % (
line.line)
self.__warn(msg)
self.__skip_subordinate_levels(state.level+2)
else:
@ -4620,8 +4621,8 @@ class GedcomParser(UpdateCallback):
state.person.set_main_parent_family_handle(None)
state.person.add_parent_family_handle(handle)
reflist = [ ref for ref in family.get_child_ref_list() \
if ref.ref == state.person.handle ]
reflist = [ref for ref in family.get_child_ref_list()
if ref.ref == state.person.handle]
if reflist:
ref = reflist[0]
ref.set_father_relation(sub_state.frel)
@ -4665,8 +4666,8 @@ class GedcomParser(UpdateCallback):
frel = mrel = gen.lib.ChildRefType.BIRTH
family, new = self.dbase.find_family_from_handle(handle, self.trans)
reflist = [ ref for ref in family.get_child_ref_list() \
if ref.ref == state.person.handle ]
reflist = [ref for ref in family.get_child_ref_list()
if ref.ref == state.person.handle]
if reflist:
ref = reflist[0]
ref.set_father_relation(frel)
@ -5338,8 +5339,8 @@ class GedcomParser(UpdateCallback):
self.__parse_level(sub_state, self.parse_addr_tbl, self.__ignore)
text = addr.get_street()
if not addr.get_city() and not addr.get_state() and \
not addr.get_postal_code() and not addr.get_country():
if not (addr.get_city() or addr.get_state() or
addr.get_postal_code() or addr.get_country()):
match = ADDR_RE.match(text)
if match:
@ -5585,8 +5586,12 @@ class GedcomParser(UpdateCallback):
if state.genby.upper() == "LEGACY":
fname = os.path.basename(self.filename)
WarningDialog(_("Import of GEDCOM file %s with DEST=%s, could cause errors in the resulting database!") % \
(fname, state.genby), _("Look for nameless events."))
WarningDialog(
_("Import of GEDCOM file %s with DEST=%s, "
"could cause errors in the resulting database!")
% (fname, state.genby),
_("Look for nameless events.")
)
def __header_plac(self, line, state):
"""

View File

@ -510,9 +510,13 @@ class GeoView(HtmlView):
Do we have a crosshair ?
"""
if self.javascript_ready:
_LOG.debug("crosshair : %d" % self._config.get("preferences.crosshair") )
self.renderer.execute_script("javascript:addcrosshair('%d','%s','geo-map')"
% (self._config.get("preferences.crosshair"), self.crosspath)
_LOG.debug("crosshair : %d" %
self._config.get("preferences.crosshair")
)
self.renderer.execute_script(
"javascript:addcrosshair('%d','%s','geo-map')" %
(self._config.get("preferences.crosshair"),
self.crosspath)
)
self._size_request_for_map(self.box, None)
pass
@ -634,21 +638,25 @@ class GeoView(HtmlView):
self.clear.set_alignment(1.0, 0.5)
self.savezoom.set_alignment(1.0, 0.5)
cell = gtk.CellRendererText()
self.placebox = gtk.ComboBoxEntry(self.plist)# pylint: disable-msg=W0201
self.placebox.pack_start(cell)
self.placebox.add_attribute(self.placebox.get_cells()[0], 'text', 0)
self.placebox.set_tooltip_text(
_("Select the place for which you want to see the info bubble."))
completion = gtk.EntryCompletion()
completion.set_model(self.plist)
completion.set_minimum_key_length(1)
completion.set_text_column(0)
completion.set_inline_completion(True)
completion.set_match_func(self._match_string)
self.placebox.child.connect('changed', self._entry_selected_place)
self.placebox.child.connect('key-press-event', self._entry_key_event)
self.clear.connect('clicked', self._erase_placebox_selection)
self.placebox.child.set_completion(completion)
box = gtk.HBox()
box.pack_start(self.clear, False, False, padding=2)
box.pack_start(self.placebox, True, True, padding=2)
@ -658,12 +666,14 @@ class GeoView(HtmlView):
box.pack_start(self.savezoom, False, False, padding=2)
box.pack_start(self.provider, False, False, padding=2)
box.show_all()
self.heading = gtk.Label('')
self.heading.set_single_line_mode(True)
font = pango.FontDescription("monospace")
font.set_weight(pango.WEIGHT_HEAVY)
font.set_style(pango.STYLE_NORMAL)
self.heading.modify_font(font)
self.box1.pack_start(box, True, True, padding=2)
self.box1.pack_start(self.heading, True, True, padding=2)
self.box1.show_all()
@ -759,10 +769,12 @@ class GeoView(HtmlView):
self.last_page = cpage
ftype = {"places":'P', "event":'E', "family":'F', "person":'I'}.get(
self.displaytype, 'X')
url = os.path.join(GEOVIEW_SUBPATH, "GeoV-%c-%05d.html" % (ftype,
cpage))
url = urlparse.urlunsplit( ('file', '', URL_SEP.join(url.split(os.sep)),
'', ''))
url = os.path.join(GEOVIEW_SUBPATH,
"GeoV-%c-%05d.html" % (ftype, cpage)
)
url = urlparse.urlunsplit(
('file', '', URL_SEP.join(url.split(os.sep)), '', '')
)
url += '?map=%s' % self.usedmap
url += '&zoom=%d' % int(self.realzoom)
url += '&lat=%s' % str(self.reallatitude)
@ -803,7 +815,7 @@ class GeoView(HtmlView):
"""
place = combobox.get_text()
for entry in self.placebox.get_model():
if ( entry[0] == place ):
if entry[0] == place:
# Is this entry in the current page ?
if self.last_page == int(entry[2]):
# Yes, we don't need to load another page.
@ -826,7 +838,9 @@ class GeoView(HtmlView):
url += '&zoom=%d' % int(self.realzoom)
url += '&lat=%s' % str(self.reallatitude)
url += '&lon=%s' % str(self.reallongitude)
url += '&cross=%s' % int(self._config.get("preferences.crosshair"))
url += '&cross=%s' % int(
self._config.get("preferences.crosshair")
)
self._openurl(url)
(current, maxp ) = self.pages[1].get_label().split('/', 1)
self._create_pages_selection(entry[2], int(maxp))
@ -900,25 +914,29 @@ class GeoView(HtmlView):
# We need to get the HPaned size and the VPaned size.
self.box1_size = self.box1.get_allocation()
self.header_size = self.box1_size.height
self.height = ( widget.parent.get_allocation().height - self.header_size -
widget.parent.get_child2().get_allocation().height - 30 )
self.width = ( widget.parent.parent.get_allocation().width -
widget.parent.parent.get_child2().get_allocation().width - 30 )
self.height = (widget.parent.get_allocation().height - self.header_size -
widget.parent.get_child2().get_allocation().height - 30)
self.width = (widget.parent.parent.get_allocation().width -
widget.parent.parent.get_child2().get_allocation().width - 30)
if not self.sidebar.is_visible():
if self.side is not None:
self.width = widget.parent.parent.get_allocation().width - 24
else:
self.side = widget
self.width = widget.parent.parent.get_allocation().width - 300
_LOG.debug("No sidebar : map width=%d" % self.width )
_LOG.debug("No sidebar : map width=%d" % self.width)
else:
_LOG.debug("Sidebar : map width=%d" % self.width )
_LOG.debug("Sidebar : map width=%d" % self.width)
if not self.bottombar.is_visible():
if self.bottom is not None:
self.height = ( widget.parent.get_allocation().height - self.header_size - 24 )
self.height = (widget.parent.get_allocation().height
- self.header_size - 24)
else:
self.bottom = widget
self.height = ( widget.parent.get_allocation().height - self.header_size - 400 )
self.height = (widget.parent.get_allocation().height
- self.header_size - 400)
_LOG.debug("No bottombar : map height=%d" % self.height )
else:
_LOG.debug("bottombar : map height=%d" % self.height )
@ -930,13 +948,15 @@ class GeoView(HtmlView):
self.box1.set_allocation(self.box1_size)
if self.javascript_ready:
_LOG.debug("New size : width=%d and height=%d" %
(self.width, self.height))
self.renderer.execute_script("javascript:mapstraction.resizeTo"
"('%dpx','%dpx');"
% (self.width, self.height) )
(self.width, self.height)
)
self.renderer.execute_script(
"javascript:setcenterandzoom(mapstraction,uzoom,"
"ulat,ulon)")
"javascript:mapstraction.resizeTo('%dpx','%dpx');" %
(self.width, self.height)
)
self.renderer.execute_script(
"javascript:setcenterandzoom(mapstraction,uzoom,ulat,ulon)"
)
self.frames.set_size_request(self.width+4, self.height+4)
if not self.uistate.get_active('Person'):
return
@ -1715,9 +1735,9 @@ class GeoView(HtmlView):
'preferences.timeperiod-after-range')
self.minyear -= ( self.minyear - adjust_before_min_year ) % 10
self.maxyear -= ( self.maxyear + adjust_after_max_year ) % 10
self.yearint = adjust_after_max_year + \
( self.maxyear - self.minyear ) / \
( self.maxbut - 1 )
self.yearint = (adjust_after_max_year +
(self.maxyear - self.minyear) / (self.maxbut - 1)
)
self.yearint -= self.yearint % 10
if self.yearint == 0:
self.yearint = 10

View File

@ -419,8 +419,8 @@ class PersonBoxWidget(_PersonWidgetBase):
self.get_colormap().alloc_color("#b9cfe7"))
self.border_gc.set_foreground(
self.get_colormap().alloc_color("#000000"))
elif self.alive and \
self.person.get_gender() == gen.lib.Person.FEMALE:
elif self.alive and (
self.person.get_gender() == gen.lib.Person.FEMALE):
self.bg_gc.set_foreground(
self.get_colormap().alloc_color("#ffcdf1"))
self.border_gc.set_foreground(
@ -923,8 +923,8 @@ class PedigreeView(NavigationView):
self.dirty = False
if self.tree_style == 1 and \
(self.force_size > 5 or self.force_size == 0):
if self.tree_style == 1 and (
self.force_size > 5 or self.force_size == 0):
self.force_size = 5
# A position definition is a tuple of nodes.
@ -1070,8 +1070,8 @@ class PedigreeView(NavigationView):
last_pbw = pbw
pbw = None
if not lst[i] and \
((self.tree_style in [0, 2] and self.show_unknown_people and
if not lst[i] and (
(self.tree_style in [0, 2] and self.show_unknown_people and
lst[((i+1)/2)-1]) or self.tree_style == 1):
#
# No person -> show empty box
@ -1099,8 +1099,8 @@ class PedigreeView(NavigationView):
# Person exists -> populate box
#
image = False
if self.show_images and height > 1 and \
(i < ((2**size-1)/2) or self.tree_style == 2):
if self.show_images and height > 1 and (
i < ((2**size-1)/2) or self.tree_style == 2):
image = True
if CAIRO_AVAILABLE:
@ -1128,8 +1128,8 @@ class PedigreeView(NavigationView):
####################################################################
# Connection lines
####################################################################
if self.tree_style == 1 and \
positions[i][1] and len(positions[i][1]) == 2:
if self.tree_style == 1 and (
positions[i][1] and len(positions[i][1]) == 2):
# separate boxes for father and mother
x_pos = positions[i][1][0][0]+1
y_pos = positions[i][1][0][1]+1
@ -1212,9 +1212,9 @@ class PedigreeView(NavigationView):
####################################################################
# Show marriage data
####################################################################
if self.show_marriage_data and \
((self.tree_style == 1 and positions[i][2]) or
(self.tree_style in [0, 2] and (level+1) < size)):
if self.show_marriage_data and (
self.tree_style == 1 and positions[i][2] or
(self.tree_style in [0, 2] and level+1 < size)):
if lst[i] and lst[i][2]:
text = self.format_helper.format_relation(lst[i][2], 1, True)
else:
@ -1506,7 +1506,7 @@ class PedigreeView(NavigationView):
def cb_bg_motion_notify_event(self, widget, event):
"""Function for motion notify events for drag and scroll mode."""
if self._in_move and (event.type == gtk.gdk.MOTION_NOTIFY or \
if self._in_move and (event.type == gtk.gdk.MOTION_NOTIFY or
event.type == gtk.gdk.BUTTON_RELEASE):
window = widget.get_parent()
hadjustment = window.get_hadjustment()
@ -1676,13 +1676,13 @@ class PedigreeView(NavigationView):
lst[index] = [person, val, family, alive, None]
father_handle = family.get_father_handle()
if father_handle:
father = self.dbstate.\
db.get_person_from_handle(father_handle)
father = self.dbstate.db.get_person_from_handle(
father_handle)
self.find_tree(father, (2*index)+1, depth+1, lst, frel)
mother_handle = family.get_mother_handle()
if mother_handle:
mother = self.dbstate.\
db.get_person_from_handle(mother_handle)
mother = self.dbstate.db.get_person_from_handle(
mother_handle)
self.find_tree(mother, (2*index)+2, depth+1, lst, mrel)
def add_nav_portion_to_menu(self, menu):
@ -1862,8 +1862,8 @@ class PedigreeView(NavigationView):
sib_menu = item.get_submenu()
if find_children(self.dbstate.db, sib):
label = gtk.Label('<b><i>%s</i></b>' % \
escape(name_displayer.display(sib)))
label = gtk.Label('<b><i>%s</i></b>'
% escape(name_displayer.display(sib)))
else:
label = gtk.Label(escape(name_displayer.display(sib)))
@ -1901,8 +1901,8 @@ class PedigreeView(NavigationView):
child_menu = item.get_submenu()
if find_children(self.dbstate.db, child):
label = gtk.Label('<b><i>%s</i></b>' % \
escape(name_displayer.display(child)))
label = gtk.Label('<b><i>%s</i></b>'
% escape(name_displayer.display(child)))
else:
label = gtk.Label(escape(name_displayer.display(child)))
@ -1941,8 +1941,8 @@ class PedigreeView(NavigationView):
par_menu = item.get_submenu()
if find_parents(self.dbstate.db, par):
label = gtk.Label('<b><i>%s</i></b>' % \
escape(name_displayer.display(par)))
label = gtk.Label('<b><i>%s</i></b>'
% escape(name_displayer.display(par)))
else:
label = gtk.Label(escape(name_displayer.display(par)))

View File

@ -859,7 +859,7 @@ class RelationshipView(NavigationView):
if count > 1 :
childmsg = ngettext(" (%d sibling)", " (%d siblings)", count) % count
elif count == 1 :
gender = self.dbstate.db.get_person_from_handle(\
gender = self.dbstate.db.get_person_from_handle(
child_list[0]).gender
if gender == gen.lib.Person.MALE :
childmsg = _(" (1 brother)")
@ -915,7 +915,7 @@ class RelationshipView(NavigationView):
if count > 1 :
childmsg = ngettext(" (%d sibling)"," (%d siblings)", count) % count
elif count == 1 :
gender = self.dbstate.db.get_person_from_handle(\
gender = self.dbstate.db.get_person_from_handle(
child_list[0]).gender
if gender == gen.lib.Person.MALE :
childmsg = _(" (1 brother)")
@ -1514,9 +1514,9 @@ class RelationshipView(NavigationView):
SelectPerson = SelectorFactory('Person')
family = self.dbstate.db.get_family_from_handle(handle)
# it only makes sense to skip those who are already in the family
skip_list = [family.get_father_handle(), \
family.get_mother_handle()] + \
[x.ref for x in family.get_child_ref_list() ]
skip_list = [family.get_father_handle(),
family.get_mother_handle()]
skip_list.extend(x.ref for x in family.get_child_ref_list())
sel = SelectPerson(self.dbstate, self.uistate, [],
_("Select Child"), skip=skip_list)
@ -1709,9 +1709,9 @@ def has_children(db,p):
return False
def button_activated(event, mouse_button):
if (event.type == gtk.gdk.BUTTON_PRESS and \
if (event.type == gtk.gdk.BUTTON_PRESS and
event.button == mouse_button) or \
(event.type == gtk.gdk.KEY_PRESS and \
(event.type == gtk.gdk.KEY_PRESS and
event.keyval in (_RETURN, _KP_ENTER, _SPACE)):
return True
else: