merge trunk from 19853 to 19947
svn: r19949
This commit is contained in:
commit
226a3eee2b
@ -90,11 +90,11 @@ po/Makefile.in
|
||||
m4/Makefile
|
||||
Makefile
|
||||
gramps.sh
|
||||
src/const.py
|
||||
src/Makefile
|
||||
src/cli/Makefile
|
||||
src/cli/plug/Makefile
|
||||
src/gen/Makefile
|
||||
src/gen/const.py
|
||||
src/gen/datehandler/Makefile
|
||||
src/gen/db/Makefile
|
||||
src/gen/display/Makefile
|
||||
@ -120,6 +120,7 @@ src/gen/plug/report/Makefile
|
||||
src/gen/proxy/Makefile
|
||||
src/gen/simple/Makefile
|
||||
src/gen/utils/Makefile
|
||||
src/gen/utils/docgen/Makefile
|
||||
src/gui/Makefile
|
||||
src/gui/editors/Makefile
|
||||
src/gui/editors/displaytabs/Makefile
|
||||
@ -136,7 +137,6 @@ src/gui/selectors/Makefile
|
||||
src/gui/views/Makefile
|
||||
src/gui/views/treemodels/Makefile
|
||||
src/gui/widgets/Makefile
|
||||
src/docgen/Makefile
|
||||
src/plugins/Makefile
|
||||
src/plugins/docgen/Makefile
|
||||
src/plugins/drawreport/Makefile
|
||||
|
249
po/POTFILES.in
249
po/POTFILES.in
@ -2,11 +2,7 @@
|
||||
#
|
||||
# Python files
|
||||
#
|
||||
src/const.py
|
||||
src/gramps.py
|
||||
src/LdsUtils.py
|
||||
src/TransUtils.py
|
||||
src/Utils.py
|
||||
|
||||
# cli
|
||||
src/cli/arghandler.py
|
||||
@ -16,6 +12,7 @@ src/cli/grampscli.py
|
||||
src/cli/plug/__init__.py
|
||||
|
||||
# gen
|
||||
src/gen/const.py
|
||||
src/gen/relationship.py
|
||||
|
||||
# gen db API
|
||||
@ -325,7 +322,12 @@ src/gen/simple/_simpletable.py
|
||||
|
||||
# gen.utils
|
||||
src/gen/utils/alive.py
|
||||
src/gen/utils/keyword.py
|
||||
src/gen/utils/lds.py
|
||||
src/gen/utils/place.py
|
||||
src/gen/utils/string.py
|
||||
src/gen/utils/trans.py
|
||||
src/gen/utils/unknown.py
|
||||
|
||||
# gui - GUI code
|
||||
src/gui/aboutdialog.py
|
||||
@ -489,92 +491,92 @@ src/docgen/ODSTab.py
|
||||
src/docgen/TextBufDoc.py
|
||||
|
||||
# plugins directory
|
||||
src/plugins/BookReport.py
|
||||
src/plugins/bookreport.py
|
||||
src/plugins/bookreport.gpr.py
|
||||
src/plugins/records.gpr.py
|
||||
src/plugins/Records.py
|
||||
src/plugins/records.py
|
||||
|
||||
# plugins/docgen directory
|
||||
src/plugins/docgen/AsciiDoc.py
|
||||
src/plugins/docgen/asciidoc.py
|
||||
src/plugins/docgen/docgen.gpr.py
|
||||
src/plugins/docgen/GtkPrint.py
|
||||
src/plugins/docgen/HtmlDoc.py
|
||||
src/plugins/docgen/LaTeXDoc.py
|
||||
src/plugins/docgen/ODFDoc.py
|
||||
src/plugins/docgen/PSDrawDoc.py
|
||||
src/plugins/docgen/RTFDoc.py
|
||||
src/plugins/docgen/SvgDrawDoc.py
|
||||
src/plugins/docgen/gtkprint.py
|
||||
src/plugins/docgen/htmldoc.py
|
||||
src/plugins/docgen/latexdoc.py
|
||||
src/plugins/docgen/odfdoc.py
|
||||
src/plugins/docgen/psdrawdoc.py
|
||||
src/plugins/docgen/rtfdoc.py
|
||||
src/plugins/docgen/svgdrawdoc.py
|
||||
|
||||
# plugins/drawreport directory
|
||||
src/plugins/drawreport/AncestorTree.py
|
||||
src/plugins/drawreport/Calendar.py
|
||||
src/plugins/drawreport/DescendTree.py
|
||||
src/plugins/drawreport/ancestortree.py
|
||||
src/plugins/drawreport/calendarreport.py
|
||||
src/plugins/drawreport/descendtree.py
|
||||
src/plugins/drawreport/drawplugins.gpr.py
|
||||
src/plugins/drawreport/FanChart.py
|
||||
src/plugins/drawreport/StatisticsChart.py
|
||||
src/plugins/drawreport/TimeLine.py
|
||||
src/plugins/drawreport/fanchart.py
|
||||
src/plugins/drawreport/statisticschart.py
|
||||
src/plugins/drawreport/timeline.py
|
||||
|
||||
# plugins/export directory
|
||||
src/plugins/export/export.gpr.py
|
||||
src/plugins/export/ExportCsv.py
|
||||
src/plugins/export/ExportFtree.py
|
||||
src/plugins/export/ExportGedcom.py
|
||||
src/plugins/export/ExportGeneWeb.py
|
||||
src/plugins/export/ExportPkg.py
|
||||
#src/plugins/export/ExportSql.py
|
||||
src/plugins/export/ExportVCalendar.py
|
||||
src/plugins/export/ExportVCard.py
|
||||
src/plugins/export/ExportXml.py
|
||||
src/plugins/export/exportcsv.py
|
||||
src/plugins/export/exportftree.py
|
||||
src/plugins/export/exportgedcom.py
|
||||
src/plugins/export/exportgeneweb.py
|
||||
src/plugins/export/exportpkg.py
|
||||
#src/plugins/export/exportsql.py
|
||||
src/plugins/export/exportvcalendar.py
|
||||
src/plugins/export/exportvcard.py
|
||||
src/plugins/export/exportxml.py
|
||||
|
||||
# plugins/gramplet directory
|
||||
src/plugins/gramplet/AgeOnDateGramplet.py
|
||||
src/plugins/gramplet/AgeStats.py
|
||||
src/plugins/gramplet/Attributes.py
|
||||
src/plugins/gramplet/AttributesGramplet.py
|
||||
src/plugins/gramplet/Backlinks.py
|
||||
src/plugins/gramplet/CalendarGramplet.py
|
||||
src/plugins/gramplet/Children.py
|
||||
src/plugins/gramplet/Citations.py
|
||||
src/plugins/gramplet/DescendGramplet.py
|
||||
src/plugins/gramplet/EditExifMetadata.py
|
||||
src/plugins/gramplet/Events.py
|
||||
src/plugins/gramplet/FanChartGramplet.py
|
||||
src/plugins/gramplet/FaqGramplet.py
|
||||
src/plugins/gramplet/GivenNameGramplet.py
|
||||
src/plugins/gramplet/ageondategramplet.py
|
||||
src/plugins/gramplet/agestats.py
|
||||
src/plugins/gramplet/attributes.py
|
||||
src/plugins/gramplet/attributesgramplet.py
|
||||
src/plugins/gramplet/backlinks.py
|
||||
src/plugins/gramplet/calendargramplet.py
|
||||
src/plugins/gramplet/children.py
|
||||
src/plugins/gramplet/citations.py
|
||||
src/plugins/gramplet/descendgramplet.py
|
||||
src/plugins/gramplet/editexifmetadata.py
|
||||
src/plugins/gramplet/events.py
|
||||
src/plugins/gramplet/fanchartgramplet.py
|
||||
src/plugins/gramplet/faqgramplet.py
|
||||
src/plugins/gramplet/givennamegramplet.py
|
||||
src/plugins/gramplet/gramplet.gpr.py
|
||||
#src/plugins/gramplet/MetadataViewer.py
|
||||
src/plugins/gramplet/Notes.py
|
||||
src/plugins/gramplet/PedigreeGramplet.py
|
||||
src/plugins/gramplet/PersonDetails.py
|
||||
src/plugins/gramplet/PersonResidence.py
|
||||
src/plugins/gramplet/PlaceDetails.py
|
||||
src/plugins/gramplet/QuickViewGramplet.py
|
||||
src/plugins/gramplet/RelativeGramplet.py
|
||||
src/plugins/gramplet/RepositoryDetails.py
|
||||
src/plugins/gramplet/SessionLogGramplet.py
|
||||
src/plugins/gramplet/StatsGramplet.py
|
||||
src/plugins/gramplet/SurnameCloudGramplet.py
|
||||
src/plugins/gramplet/ToDoGramplet.py
|
||||
src/plugins/gramplet/TopSurnamesGramplet.py
|
||||
src/plugins/gramplet/WelcomeGramplet.py
|
||||
src/plugins/gramplet/WhatsNext.py
|
||||
#src/plugins/gramplet/metadataviewer.py
|
||||
src/plugins/gramplet/notes.py
|
||||
src/plugins/gramplet/pedigreegramplet.py
|
||||
src/plugins/gramplet/persondetails.py
|
||||
src/plugins/gramplet/personresidence.py
|
||||
src/plugins/gramplet/placedetails.py
|
||||
src/plugins/gramplet/quickviewgramplet.py
|
||||
src/plugins/gramplet/relativegramplet.py
|
||||
src/plugins/gramplet/repositorydetails.py
|
||||
src/plugins/gramplet/sessionloggramplet.py
|
||||
src/plugins/gramplet/statsgramplet.py
|
||||
src/plugins/gramplet/surnamecloudgramplet.py
|
||||
src/plugins/gramplet/todogramplet.py
|
||||
src/plugins/gramplet/topsurnamesgramplet.py
|
||||
src/plugins/gramplet/welcomegramplet.py
|
||||
src/plugins/gramplet/whatsnext.py
|
||||
|
||||
# plugins/graph directory
|
||||
src/plugins/graph/graphplugins.gpr.py
|
||||
src/plugins/graph/GVFamilyLines.py
|
||||
src/plugins/graph/GVHourGlass.py
|
||||
src/plugins/graph/GVRelGraph.py
|
||||
src/plugins/graph/gvfamilylines.py
|
||||
src/plugins/graph/gvhourglass.py
|
||||
src/plugins/graph/gvrelgraph.py
|
||||
|
||||
# plugins/import directory
|
||||
src/plugins/import/import.gpr.py
|
||||
src/plugins/import/ImportCsv.py
|
||||
src/plugins/import/ImportGedcom.py
|
||||
src/plugins/import/ImportGeneWeb.py
|
||||
src/plugins/import/ImportGrdb.py
|
||||
src/plugins/import/ImportProGen.py
|
||||
src/plugins/import/ImportVCard.py
|
||||
src/plugins/import/ImportGpkg.py
|
||||
src/plugins/import/ImportXml.py
|
||||
src/plugins/import/importcsv.py
|
||||
src/plugins/import/importgedcom.py
|
||||
src/plugins/import/importgeneweb.py
|
||||
src/plugins/import/importgrdb.py
|
||||
src/plugins/import/importprogen.py
|
||||
src/plugins/import/importvcard.py
|
||||
src/plugins/import/importgpkg.py
|
||||
src/plugins/import/importxml.py
|
||||
|
||||
# plugins/lib directory
|
||||
src/plugins/lib/libcairodoc.py
|
||||
@ -591,7 +593,7 @@ src/plugins/lib/libtranslate.py
|
||||
src/plugins/lib/libtreebase.py
|
||||
src/plugins/lib/holidays.xml.in
|
||||
src/plugins/lib/maps/geography.py
|
||||
src/plugins/lib/maps/osmGps.py
|
||||
src/plugins/lib/maps/osmgps.py
|
||||
src/plugins/lib/maps/placeselection.py
|
||||
|
||||
# plugins/mapservices directory
|
||||
@ -601,19 +603,19 @@ src/plugins/mapservices/mapservice.gpr.py
|
||||
src/plugins/mapservices/openstreetmap.py
|
||||
|
||||
# plugins/quickview directory
|
||||
src/plugins/quickview/AgeOnDate.py
|
||||
src/plugins/quickview/ageondate.py
|
||||
src/plugins/quickview/all_events.py
|
||||
src/plugins/quickview/all_relations.py
|
||||
src/plugins/quickview/AttributeMatch.py
|
||||
src/plugins/quickview/FilterByName.py
|
||||
src/plugins/quickview/attributematch.py
|
||||
src/plugins/quickview/filterbyname.py
|
||||
src/plugins/quickview/lineage.py
|
||||
src/plugins/quickview/OnThisDay.py
|
||||
#src/plugins/quickview/Query.py
|
||||
src/plugins/quickview/onthisday.py
|
||||
#src/plugins/quickview/query.py
|
||||
src/plugins/quickview/quickview.gpr.py
|
||||
src/plugins/quickview/References.py
|
||||
src/plugins/quickview/LinkReferences.py
|
||||
src/plugins/quickview/Reporef.py
|
||||
src/plugins/quickview/SameSurnames.py
|
||||
src/plugins/quickview/references.py
|
||||
src/plugins/quickview/linkreferences.py
|
||||
src/plugins/quickview/reporef.py
|
||||
src/plugins/quickview/samesurnames.py
|
||||
src/plugins/quickview/siblings.py
|
||||
|
||||
# plugins/rel directory
|
||||
@ -623,50 +625,50 @@ src/plugins/rel/relplugins.gpr.py
|
||||
src/plugins/sidebar/sidebar.gpr.py
|
||||
|
||||
# plugins/textreport directory
|
||||
src/plugins/textreport/AlphabeticalIndex.py
|
||||
src/plugins/textreport/AncestorReport.py
|
||||
src/plugins/textreport/BirthdayReport.py
|
||||
src/plugins/textreport/CustomBookText.py
|
||||
src/plugins/textreport/DescendReport.py
|
||||
src/plugins/textreport/DetAncestralReport.py
|
||||
src/plugins/textreport/DetDescendantReport.py
|
||||
src/plugins/textreport/EndOfLineReport.py
|
||||
src/plugins/textreport/FamilyGroup.py
|
||||
src/plugins/textreport/IndivComplete.py
|
||||
src/plugins/textreport/KinshipReport.py
|
||||
src/plugins/textreport/NumberOfAncestorsReport.py
|
||||
src/plugins/textreport/PlaceReport.py
|
||||
src/plugins/textreport/SimpleBookTitle.py
|
||||
src/plugins/textreport/Summary.py
|
||||
src/plugins/textreport/TableOfContents.py
|
||||
src/plugins/textreport/TagReport.py
|
||||
src/plugins/textreport/alphabeticalindex.py
|
||||
src/plugins/textreport/ancestorreport.py
|
||||
src/plugins/textreport/birthdayreport.py
|
||||
src/plugins/textreport/custombooktext.py
|
||||
src/plugins/textreport/descendreport.py
|
||||
src/plugins/textreport/detancestralreport.py
|
||||
src/plugins/textreport/detdescendantreport.py
|
||||
src/plugins/textreport/endoflinereport.py
|
||||
src/plugins/textreport/familygroup.py
|
||||
src/plugins/textreport/indivcomplete.py
|
||||
src/plugins/textreport/kinshipreport.py
|
||||
src/plugins/textreport/numberofancestorsreport.py
|
||||
src/plugins/textreport/placereport.py
|
||||
src/plugins/textreport/simplebooktitle.py
|
||||
src/plugins/textreport/summary.py
|
||||
src/plugins/textreport/tableofcontents.py
|
||||
src/plugins/textreport/tagreport.py
|
||||
src/plugins/textreport/textplugins.gpr.py
|
||||
|
||||
# plugins/tool directory
|
||||
src/plugins/tool/ChangeNames.py
|
||||
src/plugins/tool/ChangeTypes.py
|
||||
src/plugins/tool/Check.py
|
||||
src/plugins/tool/Desbrowser.py
|
||||
src/plugins/tool/Eval.py
|
||||
src/plugins/tool/EventCmp.py
|
||||
src/plugins/tool/EventNames.py
|
||||
src/plugins/tool/ExtractCity.py
|
||||
src/plugins/tool/FindDupes.py
|
||||
src/plugins/tool/Leak.py
|
||||
src/plugins/tool/MediaManager.py
|
||||
src/plugins/tool/MergeCitations.py
|
||||
src/plugins/tool/NotRelated.py
|
||||
src/plugins/tool/OwnerEditor.py
|
||||
src/plugins/tool/PatchNames.py
|
||||
src/plugins/tool/Rebuild.py
|
||||
src/plugins/tool/RebuildRefMap.py
|
||||
src/plugins/tool/RelCalc.py
|
||||
src/plugins/tool/RemoveUnused.py
|
||||
src/plugins/tool/ReorderIds.py
|
||||
src/plugins/tool/SortEvents.py
|
||||
src/plugins/tool/SoundGen.py
|
||||
src/plugins/tool/changenames.py
|
||||
src/plugins/tool/changetypes.py
|
||||
src/plugins/tool/check.py
|
||||
src/plugins/tool/desbrowser.py
|
||||
src/plugins/tool/eval.py
|
||||
src/plugins/tool/eventcmp.py
|
||||
src/plugins/tool/eventnames.py
|
||||
src/plugins/tool/extractcity.py
|
||||
src/plugins/tool/finddupes.py
|
||||
src/plugins/tool/leak.py
|
||||
src/plugins/tool/mediamanager.py
|
||||
src/plugins/tool/mergecitations.py
|
||||
src/plugins/tool/notrelated.py
|
||||
src/plugins/tool/ownereditor.py
|
||||
src/plugins/tool/patchnames.py
|
||||
src/plugins/tool/rebuild.py
|
||||
src/plugins/tool/rebuildrefmap.py
|
||||
src/plugins/tool/relcalc.py
|
||||
src/plugins/tool/removeunused.py
|
||||
src/plugins/tool/reorderids.py
|
||||
src/plugins/tool/sortevents.py
|
||||
src/plugins/tool/soundgen.py
|
||||
src/plugins/tool/tools.gpr.py
|
||||
src/plugins/tool/Verify.py
|
||||
src/plugins/tool/verify.py
|
||||
|
||||
#plugins/view directory
|
||||
src/plugins/view/citationtreeview.py
|
||||
@ -696,17 +698,14 @@ src/plugins/view/sourceview.py
|
||||
src/plugins/view/view.gpr.py
|
||||
|
||||
# plugins/webreport directory
|
||||
src/plugins/webreport/NarrativeWeb.py
|
||||
src/plugins/webreport/WebCal.py
|
||||
src/plugins/webreport/narrativeweb.py
|
||||
src/plugins/webreport/webcal.py
|
||||
src/plugins/webreport/webplugins.gpr.py
|
||||
|
||||
# plugins/webstuff directory
|
||||
src/plugins/webstuff/webstuff.gpr.py
|
||||
src/plugins/webstuff/webstuff.py
|
||||
|
||||
# Simple API
|
||||
src/Simple/_SimpleAccess.py
|
||||
|
||||
#
|
||||
# Glade files
|
||||
#
|
||||
|
@ -3,9 +3,6 @@
|
||||
# Python files
|
||||
#
|
||||
|
||||
#src
|
||||
src/ImgManip.py
|
||||
|
||||
# cli
|
||||
src/cli/__init__.py
|
||||
src/cli/user.py
|
||||
@ -214,7 +211,19 @@ src/gen/simple/_simpledoc.py
|
||||
src/gen/utils/__init__.py
|
||||
src/gen/utils/callback.py
|
||||
src/gen/utils/callman.py
|
||||
src/gen/utils/referent.py
|
||||
src/gen/utils/cast.py
|
||||
src/gen/utils/config.py
|
||||
src/gen/utils/db.py
|
||||
src/gen/utils/debug.py
|
||||
src/gen/utils/file.py
|
||||
src/gen/utils/id.py
|
||||
src/gen/utils/image.py
|
||||
|
||||
# gen.utils.docgen
|
||||
src/gen/utils/docgen/__init__.py
|
||||
src/gen/utils/docgen/CSVTab.py
|
||||
src/gen/utils/docgen/ODSTab.py
|
||||
src/gen/utils/docgen/TabbedDoc.py
|
||||
|
||||
# gui - GUI code
|
||||
src/gui/__init__.py
|
||||
@ -304,7 +313,7 @@ src/guiQML/views/dbman.py
|
||||
src/plugins/sidebar/sidebar.gpr.py
|
||||
|
||||
# plugins/docgen directory
|
||||
src/plugins/docgen/PdfDoc.py
|
||||
src/plugins/docgen/pdfdoc.py
|
||||
|
||||
# plugins/lib directory
|
||||
src/plugins/lib/libformatting.py
|
||||
@ -316,32 +325,32 @@ src/plugins/lib/libodfbackend.py
|
||||
src/plugins/lib/libsubstkeyword.py
|
||||
|
||||
# plugins/import directory
|
||||
src/plugins/import/ImportSql.py
|
||||
src/plugins/import/importsql.py
|
||||
|
||||
# plugins/tool directory
|
||||
src/plugins/tool/CalculateEstimatedDates.py
|
||||
src/plugins/tool/DateParserDisplayTest.py
|
||||
src/plugins/tool/DumpGenderStats.py
|
||||
src/plugins/tool/PHPGedViewConnector.py
|
||||
src/plugins/tool/TestcaseGenerator.py
|
||||
src/plugins/tool/calculateestimateddates.py
|
||||
src/plugins/tool/dateparserdisplaytest.py
|
||||
src/plugins/tool/dumpgenderstats.py
|
||||
src/plugins/tool/phpgedviewconnector.py
|
||||
src/plugins/tool/testcasegenerator.py
|
||||
src/plugins/tool/phpgedview.glade
|
||||
src/plugins/tool/toolsdebug.gpr.py
|
||||
|
||||
# plugins/gramplet directory
|
||||
src/plugins/gramplet/DeepConnections.py
|
||||
src/plugins/gramplet/Gallery.py
|
||||
src/plugins/gramplet/HeadlineNewsGramplet.py
|
||||
src/plugins/gramplet/MediaPreview.py
|
||||
src/plugins/gramplet/MetadataViewer.py
|
||||
src/plugins/gramplet/NoteGramplet.py
|
||||
src/plugins/gramplet/PluginManagerGramplet.py
|
||||
src/plugins/gramplet/PopulateGramplet.py
|
||||
src/plugins/gramplet/PopulateGramplet.gpr.py
|
||||
src/plugins/gramplet/PythonGramplet.py
|
||||
src/plugins/gramplet/deepconnections.py
|
||||
src/plugins/gramplet/gallery.py
|
||||
src/plugins/gramplet/headlinenewsgramplet.py
|
||||
src/plugins/gramplet/mediapreview.py
|
||||
src/plugins/gramplet/metadataviewer.py
|
||||
src/plugins/gramplet/notegramplet.py
|
||||
src/plugins/gramplet/pluginmanagergramplet.py
|
||||
src/plugins/gramplet/populategramplet.py
|
||||
src/plugins/gramplet/populategramplet.gpr.py
|
||||
src/plugins/gramplet/pythongramplet.py
|
||||
|
||||
# plugins/quickview directory
|
||||
src/plugins/quickview/AllNames.py
|
||||
src/plugins/quickview/Query.py
|
||||
src/plugins/quickview/allnames.py
|
||||
src/plugins/quickview/query.py
|
||||
|
||||
# plugins/rel directory
|
||||
src/plugins/rel/rel_cs.py
|
||||
|
@ -4,7 +4,6 @@
|
||||
SUBDIRS = \
|
||||
cli \
|
||||
data \
|
||||
docgen \
|
||||
gen \
|
||||
gui \
|
||||
images \
|
||||
@ -12,14 +11,7 @@ SUBDIRS = \
|
||||
|
||||
gdirdir=$(prefix)/share/gramps
|
||||
|
||||
gdir_PYTHON = \
|
||||
const.py\
|
||||
gramps.py\
|
||||
ImgManip.py\
|
||||
LdsUtils.py \
|
||||
MacTransUtils.py\
|
||||
TransUtils.py\
|
||||
Utils.py
|
||||
gdir_PYTHON = gramps.py
|
||||
|
||||
# Clean up all the byte-compiled files
|
||||
MOSTLYCLEANFILES = *pyc *pyo
|
||||
|
1140
src/Utils.py
1140
src/Utils.py
File diff suppressed because it is too large
Load Diff
@ -46,7 +46,8 @@ from gen.ggettext import gettext as _
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.recentfiles import recent_files
|
||||
import Utils
|
||||
from gen.utils.file import (rm_tempdir, get_empty_tempdir,
|
||||
get_unicode_path_from_env_var)
|
||||
import gen
|
||||
from clidbman import CLIDbManager, NAME_FILE, find_locker_name
|
||||
|
||||
@ -207,7 +208,7 @@ class ArgHandler(object):
|
||||
"""
|
||||
if value is None:
|
||||
return None
|
||||
value = Utils.get_unicode_path_from_env_var(value)
|
||||
value = get_unicode_path_from_env_var(value)
|
||||
db_path = self.__deduce_db_path(value)
|
||||
|
||||
if db_path:
|
||||
@ -237,7 +238,7 @@ class ArgHandler(object):
|
||||
"""
|
||||
# Need to convert path/filename to unicode before opening
|
||||
# For non latin characters in Windows path/file/user names
|
||||
value = Utils.get_unicode_path_from_env_var(value)
|
||||
value = get_unicode_path_from_env_var(value)
|
||||
fname = value
|
||||
fullpath = os.path.abspath(os.path.expanduser(fname))
|
||||
if fname != '-' and not os.path.exists(fullpath):
|
||||
@ -274,7 +275,7 @@ class ArgHandler(object):
|
||||
return
|
||||
# Need to convert path/filename to unicode before opening
|
||||
# For non latin characters in Windows path/file/user names
|
||||
value = Utils.get_unicode_path_from_env_var(value)
|
||||
value = get_unicode_path_from_env_var(value)
|
||||
fname = value
|
||||
if fname == '-':
|
||||
fullpath = '-'
|
||||
@ -450,7 +451,7 @@ class ArgHandler(object):
|
||||
# remove files in import db subdir after use
|
||||
self.dbstate.db.close()
|
||||
if self.imp_db_path:
|
||||
Utils.rm_tempdir(self.imp_db_path)
|
||||
rm_tempdir(self.imp_db_path)
|
||||
|
||||
def __import_action(self):
|
||||
"""
|
||||
@ -469,7 +470,7 @@ class ArgHandler(object):
|
||||
if self.gui:
|
||||
self.imp_db_path, title = self.dbman.create_new_db_cli()
|
||||
else:
|
||||
self.imp_db_path = Utils.get_empty_tempdir("import_dbdir") \
|
||||
self.imp_db_path = get_empty_tempdir("import_dbdir") \
|
||||
.encode(sys.getfilesystemencoding())
|
||||
newdb = gen.db.DbBsddb()
|
||||
newdb.write_version(self.imp_db_path)
|
||||
|
@ -46,10 +46,10 @@ import logging
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import const
|
||||
from gen.const import LONGOPTS, SHORTOPTS
|
||||
from gen.config import config
|
||||
from gen.utils.configmanager import safe_eval
|
||||
import Utils
|
||||
from gen.utils.file import get_unicode_path_from_env_var
|
||||
|
||||
# Note: Make sure to edit const.py.in POPT_TABLE too!
|
||||
_HELP = _("""
|
||||
@ -216,9 +216,9 @@ class ArgParser(object):
|
||||
# -Ärik is '-\xc3\x84rik' and getopt will respond :
|
||||
# option -\xc3 not recognized
|
||||
for arg in range(len(self.args) - 1):
|
||||
self.args[arg+1] = Utils.get_unicode_path_from_env_var(self.args[arg + 1])
|
||||
self.args[arg+1] = get_unicode_path_from_env_var(self.args[arg + 1])
|
||||
options, leftargs = getopt.getopt(self.args[1:],
|
||||
const.SHORTOPTS, const.LONGOPTS)
|
||||
SHORTOPTS, LONGOPTS)
|
||||
except getopt.GetoptError, msg:
|
||||
# Extract the arguments in the list.
|
||||
# The % operator replaces the list elements with repr() of the list elemements
|
||||
@ -291,12 +291,12 @@ class ArgParser(object):
|
||||
self.list_more = True
|
||||
elif option in ('-s','--show'):
|
||||
print "Gramps config settings from %s:" % \
|
||||
config.config.filename.encode(sys.getfilesystemencoding())
|
||||
for section in config.config.data:
|
||||
for setting in config.config.data[section]:
|
||||
config.filename.encode(sys.getfilesystemencoding())
|
||||
for section in config.data:
|
||||
for setting in config.data[section]:
|
||||
print "%s.%s=%s" % (
|
||||
section, setting,
|
||||
repr(config.config.data[section][setting]))
|
||||
repr(config.data[section][setting]))
|
||||
print
|
||||
sys.exit(0)
|
||||
elif option in ('-c', '--config'):
|
||||
@ -350,7 +350,7 @@ class ArgParser(object):
|
||||
# but not for non-latin characters in list elements
|
||||
cliargs = "[ "
|
||||
for arg in range(len(self.args) - 1):
|
||||
cliargs += Utils.get_unicode_path_from_env_var(self.args[arg + 1]) + " "
|
||||
cliargs += get_unicode_path_from_env_var(self.args[arg + 1]) + " "
|
||||
cliargs += "]"
|
||||
self.errors += [(_('Error parsing the arguments'),
|
||||
_("Error parsing the arguments: %s \n"
|
||||
|
@ -47,13 +47,13 @@ LOG = logging.getLogger(".grampscli")
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.display.name import displayer as name_displayer
|
||||
from gen.config import config
|
||||
import const
|
||||
from gen.const import PLUGINS_DIR, USER_PLUGINS
|
||||
from gen.errors import DbError
|
||||
from gen.dbstate import DbState
|
||||
from gen.db import DbBsddb
|
||||
import gen.db.exceptions
|
||||
from gen.plug import BasePluginManager
|
||||
from Utils import get_researcher
|
||||
from gen.utils.config import get_researcher
|
||||
from gen.recentfiles import recent_files
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -280,8 +280,8 @@ class CLIManager(object):
|
||||
"""
|
||||
Register the plugins at initialization time.
|
||||
"""
|
||||
self._pmgr.reg_plugins(const.PLUGINS_DIR, dbstate, uistate)
|
||||
self._pmgr.reg_plugins(const.USER_PLUGINS, dbstate, uistate,
|
||||
self._pmgr.reg_plugins(PLUGINS_DIR, dbstate, uistate)
|
||||
self._pmgr.reg_plugins(USER_PLUGINS, dbstate, uistate,
|
||||
append=False, load_on_reg=True)
|
||||
|
||||
def startcli(errors, argparser):
|
||||
|
@ -46,7 +46,6 @@ log = logging.getLogger(".")
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Utils
|
||||
from gen.plug import BasePluginManager
|
||||
from gen.plug.docgen import (StyleSheet, StyleSheetList, PaperStyle,
|
||||
PAPER_PORTRAIT, PAPER_LANDSCAPE, graphdoc)
|
||||
@ -59,7 +58,7 @@ from gen.errors import ReportError
|
||||
from gen.plug.report import (CATEGORY_TEXT, CATEGORY_DRAW, CATEGORY_BOOK,
|
||||
CATEGORY_GRAPHVIZ, CATEGORY_CODE)
|
||||
from gen.plug.report._paper import paper_sizes
|
||||
import const
|
||||
from gen.const import USER_HOME
|
||||
from gen.dbstate import DbState
|
||||
from cli.grampscli import CLIManager
|
||||
import cli.user
|
||||
@ -275,7 +274,7 @@ class CommandLineReport(object):
|
||||
if noopt:
|
||||
return
|
||||
|
||||
self.options_help['of'][2] = os.path.join(const.USER_HOME,
|
||||
self.options_help['of'][2] = os.path.join(USER_HOME,
|
||||
"whatever_name")
|
||||
|
||||
if self.category == CATEGORY_TEXT:
|
||||
@ -305,7 +304,7 @@ class CommandLineReport(object):
|
||||
"%d\tPortrait" % PAPER_PORTRAIT,
|
||||
"%d\tLandscape" % PAPER_LANDSCAPE ]
|
||||
|
||||
self.options_help['css'][2] = os.path.join(const.USER_HOME,
|
||||
self.options_help['css'][2] = os.path.join(USER_HOME,
|
||||
"whatever_name.css")
|
||||
|
||||
if self.category in (CATEGORY_TEXT, CATEGORY_DRAW):
|
||||
|
@ -15,7 +15,8 @@
|
||||
<link media="print" href="/styles/css/Web_Print-Default.css" type="text/css" rel="stylesheet" />
|
||||
<script type="text/javascript" src="/styles/javascript/jquery-1.3.2.min.js"></script>
|
||||
<script type="text/javascript" src="/styles/javascript/jquery-ui-1.7.2.custom.min.js"></script>
|
||||
|
||||
<script type="text/javascript" src="/styles/jhtmlarea/scripts/jHtmlArea-0.7.0.js"></script>
|
||||
<link rel="Stylesheet" type="text/css" href="/styles/jhtmlarea/style/jHtmlArea.css" />
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@ -27,7 +28,6 @@
|
||||
background: none;
|
||||
}
|
||||
.content {
|
||||
border: 1px solid;
|
||||
padding: 0px 0px 10px;
|
||||
}
|
||||
.browsecell {
|
||||
@ -69,7 +69,7 @@
|
||||
border: 1px solid #7D5925;
|
||||
color: #7D5925;
|
||||
float: left;
|
||||
width: 97%;
|
||||
width: 98%;
|
||||
}
|
||||
.ui-widget-content a {
|
||||
color: #7D5925;
|
||||
|
@ -10,6 +10,11 @@
|
||||
document.location.hash = ui.panel.id;
|
||||
}
|
||||
});
|
||||
$('#shared-tabs').tabs({
|
||||
'select': function(event, ui){
|
||||
document.location.hash = ui.panel.id;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -36,6 +41,7 @@
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-media">Media</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-data">Data</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-references">References</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-history">History</a></li>
|
||||
</ul>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tab-general">
|
||||
|
||||
@ -73,6 +79,9 @@
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-references">
|
||||
{% citation_reference_table citation user action %}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-history">
|
||||
{% history_table citation user action %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>Note: Any changes in the shared citation information will be reflected
|
||||
@ -82,13 +91,14 @@
|
||||
<hr>
|
||||
|
||||
<h2>Shared source information</h2>
|
||||
<div class="ui-tabs ui-widget ui-widget-content ui-corner-all" id="general-tabs">
|
||||
<div class="ui-tabs ui-widget ui-widget-content ui-corner-all" id="shared-tabs">
|
||||
<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
|
||||
<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#tab-shared-general">General</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-shared-notes">Notes</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-shared-media">Media</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-shared-repositories">Repositories</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-shared-references">References</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-shared-history">History</a></li>
|
||||
</ul>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tab-shared-general">
|
||||
|
||||
@ -130,6 +140,9 @@
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-shared-references">
|
||||
{% citation_reference_table source user action %}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-shared-history">
|
||||
{% history_table source user action %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>Note: Any changes in the shared source information will be reflected
|
||||
|
@ -57,6 +57,7 @@
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-media">Media</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-attributes">Attributes</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-references">References</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-history">History</a></li>
|
||||
</ul>
|
||||
<div class="ui-tab-panel ui-widget-content ui-corner-bottom" id="tab-sources">
|
||||
{% citation_table event user action "/citation/$act/event/%s" event.handle %}
|
||||
@ -73,6 +74,9 @@
|
||||
<div class="ui-tab-panel ui-widget-content ui-corner-bottom ui-tab-hide" id="tab-references">
|
||||
{% event_reference_table event user action %}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-history">
|
||||
{% history_table event user action %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if user.is_superuser %}
|
||||
|
@ -103,6 +103,7 @@
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-notes">Notes</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-media">Media</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-lds">LDS</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-history">History</a></li>
|
||||
</ul>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tab-children">
|
||||
<!-- Events -->
|
||||
@ -126,6 +127,9 @@
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-lds">
|
||||
{% lds_table family user action "/lds/add/family/%s" family.handle %}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-history">
|
||||
{% history_table family user action %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if user.is_superuser %}
|
||||
|
@ -31,6 +31,7 @@
|
||||
<tr>
|
||||
<td class="ColumnAttribute">{{mediaform.desc.label}}:</td>
|
||||
<td class="ColumnValue" id="data" colspan="3">{% render mediaform.desc user action %}</td>
|
||||
<td rowspan="5">{% media_link media.handle user action %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="ColumnAttribute">{{mediaform.gramps_id.label}}:</td>
|
||||
@ -60,6 +61,7 @@
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-attributes">Attributes</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-notes">Notes</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-references">References</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-history">History</a></li>
|
||||
</ul>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-sources">
|
||||
{% citation_table media user action "/citation/$act/media/%s" media.handle %}
|
||||
@ -73,6 +75,9 @@
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tab-references">
|
||||
{% media_reference_table media user action %}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-history">
|
||||
{% history_table media user action %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if user.is_superuser %}
|
||||
|
@ -75,10 +75,14 @@
|
||||
<div class="ui-tabs ui-widget ui-widget-content ui-corner-all" id="tabs">
|
||||
<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-references">References</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-history">History</a></li>
|
||||
</ul>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-references">
|
||||
{% note_reference_table note user action %}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-history">
|
||||
{% history_table note user action %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -94,6 +94,7 @@
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-association">Associations</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-lds">LDS</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-references">References</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-history">History</a></li>
|
||||
</ul>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tab-events">
|
||||
<!-- Events -->
|
||||
@ -130,6 +131,9 @@
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-references">
|
||||
{% person_reference_table person user action %}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-history">
|
||||
{% history_table person user action %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if logform %}
|
||||
|
@ -57,6 +57,7 @@
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-media">Media</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-internet">Internet</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-references">References</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-history">History</a></li>
|
||||
</ul>
|
||||
<div class="ui-tab-panel ui-widget-content ui-corner-bottom" id="tab-locations">
|
||||
<!-- place.location_set -->
|
||||
@ -79,6 +80,9 @@
|
||||
<div class="ui-tab-panel ui-widget-content ui-corner-bottom ui-tab-hide" id="tab-references">
|
||||
{% place_reference_table place user action %}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-history">
|
||||
{% history_table place user action %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -52,6 +52,7 @@
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-internet">Internet</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-notes">Notes</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-references">References</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-history">History</a></li>
|
||||
</ul>
|
||||
<div class="ui-tab-panel ui-widget-content ui-corner-bottom" id="tab-addresses">
|
||||
{% address_table repository user action "/address/add/repository/%s" repository.handle %}
|
||||
@ -65,6 +66,9 @@
|
||||
<div class="ui-tab-panel ui-widget-content ui-corner-bottom ui-tab-hide" id="tab-references">
|
||||
{% repository_reference_table repository user action %}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-history">
|
||||
{% history_table repository user action %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if user.is_superuser %}
|
||||
|
@ -58,6 +58,7 @@
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-data">Data</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-repositories">Repositories</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-references">References</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-history">History</a></li>
|
||||
</ul>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tab-notes">
|
||||
{% note_table source user action "/note/$act/source/%s" source.handle %}
|
||||
@ -74,6 +75,9 @@
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-references">
|
||||
{% source_reference_table source user action %}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-history">
|
||||
{% history_table source user action %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if user.is_superuser %}
|
||||
|
@ -22,6 +22,7 @@ pkgpythondir = $(datadir)/@PACKAGE@/gen
|
||||
pkgpython_PYTHON = \
|
||||
__init__.py \
|
||||
config.py \
|
||||
const.py \
|
||||
constfunc.py \
|
||||
dbstate.py \
|
||||
errors.py \
|
||||
|
@ -41,15 +41,15 @@ from gen.ggettext import gettext as _
|
||||
# Gramps imports
|
||||
#
|
||||
#---------------------------------------------------------------
|
||||
import const
|
||||
from gen.utils import ConfigManager
|
||||
from gen.const import HOME_DIR, USER_HOME, VERSION_DIR
|
||||
from gen.utils.configmanager import ConfigManager
|
||||
|
||||
#---------------------------------------------------------------
|
||||
#
|
||||
# Constants
|
||||
#
|
||||
#---------------------------------------------------------------
|
||||
INIFILE = os.path.join(const.VERSION_DIR, "gramps.ini")
|
||||
INIFILE = os.path.join(VERSION_DIR, "gramps.ini")
|
||||
|
||||
#---------------------------------------------------------------
|
||||
#
|
||||
@ -133,7 +133,7 @@ register('behavior.check-for-update-types', ["new"])
|
||||
register('behavior.last-check-for-updates', "1970/01/01")
|
||||
register('behavior.previously-seen-updates', [])
|
||||
register('behavior.do-not-show-previously-seen-updates', True)
|
||||
register('behavior.database-path', os.path.join( const.HOME_DIR, 'grampsdb'))
|
||||
register('behavior.database-path', os.path.join( HOME_DIR, 'grampsdb'))
|
||||
register('behavior.date-about-range', 50)
|
||||
register('behavior.date-after-range', 50)
|
||||
register('behavior.date-before-range', 50)
|
||||
@ -267,9 +267,9 @@ register('interface.surname-box-height', 150)
|
||||
register('paths.recent-export-dir', '')
|
||||
register('paths.recent-file', '')
|
||||
register('paths.recent-import-dir', '')
|
||||
register('paths.report-directory', const.USER_HOME)
|
||||
register('paths.website-directory', const.USER_HOME)
|
||||
register('paths.quick-backup-directory', const.USER_HOME)
|
||||
register('paths.report-directory', USER_HOME)
|
||||
register('paths.website-directory', USER_HOME)
|
||||
register('paths.quick-backup-directory', USER_HOME)
|
||||
register('paths.quick-backup-filename',
|
||||
"%(filename)s_%(year)d-%(month)02d-%(day)02d.%(extension)s")
|
||||
|
||||
@ -329,10 +329,10 @@ register('plugin.addonplugins', [])
|
||||
# we can tell by seeing if there is a key file for this version:
|
||||
if not os.path.exists(CONFIGMAN.filename):
|
||||
# If not, let's read old if there:
|
||||
if os.path.exists(os.path.join(const.HOME_DIR, "keys.ini")):
|
||||
if os.path.exists(os.path.join(HOME_DIR, "keys.ini")):
|
||||
# read it in old style:
|
||||
print >> sys.stderr, "Importing old key file 'keys.ini'..."
|
||||
CONFIGMAN.load(os.path.join(const.HOME_DIR, "keys.ini"),
|
||||
CONFIGMAN.load(os.path.join(HOME_DIR, "keys.ini"),
|
||||
oldstyle=True)
|
||||
print >> sys.stderr, "Done importing old key file 'keys.ini'"
|
||||
# other version upgrades here...
|
||||
|
@ -86,7 +86,7 @@ if sys.platform == "win32":
|
||||
PREFIXDIR = sys.prefix
|
||||
SYSCONFDIR = os.path.join(sys.prefix, "etc")
|
||||
else:
|
||||
PREFIXDIR = os.path.dirname(__file__)
|
||||
PREFIXDIR = os.path.join(os.path.dirname(__file__), os.pardir)
|
||||
SYSCONFDIR = os.path.join(PREFIXDIR, "etc")
|
||||
elif sys.platform == "darwin" and sys.prefix != sys.exec_prefix:
|
||||
PREFIXDIR = sys.prefix
|
||||
@ -142,8 +142,8 @@ if hasattr(sys, "frozen"):
|
||||
ROOT_DIR = os.path.abspath(os.path.dirname(
|
||||
unicode(sys.executable, sys.getfilesystemencoding())))
|
||||
else:
|
||||
ROOT_DIR = os.path.abspath(os.path.dirname(
|
||||
unicode(__file__, sys.getfilesystemencoding())))
|
||||
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(
|
||||
unicode(__file__, sys.getfilesystemencoding())), os.pardir))
|
||||
|
||||
IMAGE_DIR = os.path.join(ROOT_DIR, "images")
|
||||
VERSION_DIR = os.path.join(
|
@ -40,7 +40,7 @@ import sys
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from const import WINDOWS, MACOS, LINUX
|
||||
from gen.const import WINDOWS, MACOS, LINUX
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -24,6 +24,14 @@
|
||||
Class handling language-specific selection for date parser and displayer.
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import time
|
||||
from gen.lib import Date
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
@ -80,3 +88,12 @@ def get_date(date_base) :
|
||||
def get_date_valid(date_base):
|
||||
date_obj = date_base.get_date_object()
|
||||
return date_obj.get_valid()
|
||||
|
||||
def format_time(secs):
|
||||
"""
|
||||
Format a time in seconds as a date in the preferred date format and a
|
||||
24 hour time as hh:mm:ss.
|
||||
"""
|
||||
t = time.localtime(secs)
|
||||
d = Date(t.tm_year, t.tm_mon, t.tm_mday)
|
||||
return displayer.display(d) + time.strftime(' %X', t)
|
||||
|
807
src/gen/db/dictionary.py
Normal file
807
src/gen/db/dictionary.py
Normal file
@ -0,0 +1,807 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2012 Douglas S. Blank <doug.blank@gmail.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
# $Id: dbdictionary.py $
|
||||
#
|
||||
|
||||
""" Implements a Db interface as a Dictionary """
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps Modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import cPickle
|
||||
import base64
|
||||
import time
|
||||
import gen
|
||||
import re
|
||||
from gen.db import DbReadBase, DbWriteBase, DbTxn
|
||||
from gen.db import (PERSON_KEY,
|
||||
FAMILY_KEY,
|
||||
CITATION_KEY,
|
||||
SOURCE_KEY,
|
||||
EVENT_KEY,
|
||||
MEDIA_KEY,
|
||||
PLACE_KEY,
|
||||
REPOSITORY_KEY,
|
||||
NOTE_KEY)
|
||||
from gen.utils.id import create_id
|
||||
|
||||
class Cursor(object):
|
||||
"""
|
||||
Iterates through model returning (handle, raw_data)...
|
||||
"""
|
||||
def __init__(self, model, func):
|
||||
self.model = model
|
||||
self.func = func
|
||||
def __enter__(self):
|
||||
return self
|
||||
def __iter__(self):
|
||||
return self.__next__()
|
||||
def __next__(self):
|
||||
for item in self.model.all():
|
||||
yield (item.handle, self.func(item.handle))
|
||||
def __exit__(self, *args, **kwargs):
|
||||
pass
|
||||
def iter(self):
|
||||
for item in self.model.all():
|
||||
yield (item.handle, self.func(item.handle))
|
||||
yield None
|
||||
|
||||
class Bookmarks:
|
||||
def get(self):
|
||||
return [] # handles
|
||||
def append(self, handle):
|
||||
pass
|
||||
|
||||
class DictionaryTxn(DbTxn):
|
||||
def __init__(self, message, db):
|
||||
DbTxn.__init__(self, message, db)
|
||||
|
||||
def get(self, key, default=None, txn=None, **kwargs):
|
||||
"""
|
||||
Returns the data object associated with key
|
||||
"""
|
||||
if txn and key in txn:
|
||||
return txn[key]
|
||||
else:
|
||||
return None
|
||||
|
||||
def put(self, handle, new_data, txn):
|
||||
"""
|
||||
"""
|
||||
txn[handle] = new_data
|
||||
|
||||
class DictionaryDb(DbWriteBase, DbReadBase):
|
||||
"""
|
||||
A Gramps Database Backend. This replicates the grampsdb functions.
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
DbReadBase.__init__(self)
|
||||
DbWriteBase.__init__(self)
|
||||
# skip GEDCOM cross-ref check for now:
|
||||
self.set_feature("skip-check-xref", True)
|
||||
self.readonly = False
|
||||
self.db_is_open = True
|
||||
self.name_formats = []
|
||||
self.bookmarks = Bookmarks()
|
||||
self.family_bookmarks = Bookmarks()
|
||||
self.event_bookmarks = Bookmarks()
|
||||
self.place_bookmarks = Bookmarks()
|
||||
self.citation_bookmarks = Bookmarks()
|
||||
self.source_bookmarks = Bookmarks()
|
||||
self.repo_bookmarks = Bookmarks()
|
||||
self.media_bookmarks = Bookmarks()
|
||||
self.note_bookmarks = Bookmarks()
|
||||
self.set_person_id_prefix('I%04d')
|
||||
self.set_object_id_prefix('O%04d')
|
||||
self.set_family_id_prefix('F%04d')
|
||||
self.set_citation_id_prefix('C%04d')
|
||||
self.set_source_id_prefix('S%04d')
|
||||
self.set_place_id_prefix('P%04d')
|
||||
self.set_event_id_prefix('E%04d')
|
||||
self.set_repository_id_prefix('R%04d')
|
||||
self.set_note_id_prefix('N%04d')
|
||||
# ----------------------------------
|
||||
self.id_trans = DictionaryTxn("ID Transaction", self)
|
||||
self.fid_trans = DictionaryTxn("FID Transaction", self)
|
||||
self.pid_trans = DictionaryTxn("PID Transaction", self)
|
||||
self.cid_trans = DictionaryTxn("CID Transaction", self)
|
||||
self.sid_trans = DictionaryTxn("SID Transaction", self)
|
||||
self.oid_trans = DictionaryTxn("OID Transaction", self)
|
||||
self.rid_trans = DictionaryTxn("RID Transaction", self)
|
||||
self.nid_trans = DictionaryTxn("NID Transaction", self)
|
||||
self.eid_trans = DictionaryTxn("EID Transaction", self)
|
||||
self.cmap_index = 0
|
||||
self.smap_index = 0
|
||||
self.emap_index = 0
|
||||
self.pmap_index = 0
|
||||
self.fmap_index = 0
|
||||
self.lmap_index = 0
|
||||
self.omap_index = 0
|
||||
self.rmap_index = 0
|
||||
self.nmap_index = 0
|
||||
self.env = None
|
||||
self.person_map = {}
|
||||
self.family_map = {}
|
||||
self.place_map = {}
|
||||
self.citation_map = {}
|
||||
self.source_map = {}
|
||||
self.repository_map = {}
|
||||
self.note_map = {}
|
||||
self.media_map = {}
|
||||
self.event_map = {}
|
||||
self.metadata = {}
|
||||
self.name_group = {}
|
||||
self.undo_callback = None
|
||||
self.redo_callback = None
|
||||
self.undo_history_callback = None
|
||||
self.modified = 0
|
||||
self.txn = DictionaryTxn("DbDictionary Transaction", self)
|
||||
self.transaction = None
|
||||
|
||||
def transaction_commit(self, txn):
|
||||
pass
|
||||
|
||||
def enable_signals(self):
|
||||
pass
|
||||
|
||||
def get_undodb(self):
|
||||
return None
|
||||
|
||||
def transaction_abort(self, txn):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def _validated_id_prefix(val, default):
|
||||
if isinstance(val, basestring) and val:
|
||||
try:
|
||||
str_ = val % 1
|
||||
except TypeError: # missing conversion specifier
|
||||
prefix_var = val + "%d"
|
||||
except ValueError: # incomplete format
|
||||
prefix_var = default+"%04d"
|
||||
else:
|
||||
prefix_var = val # OK as given
|
||||
else:
|
||||
prefix_var = default+"%04d" # not a string or empty string
|
||||
return prefix_var
|
||||
|
||||
@staticmethod
|
||||
def __id2user_format(id_pattern):
|
||||
"""
|
||||
Return a method that accepts a Gramps ID and adjusts it to the users
|
||||
format.
|
||||
"""
|
||||
pattern_match = re.match(r"(.*)%[0 ](\d+)[diu]$", id_pattern)
|
||||
if pattern_match:
|
||||
str_prefix = pattern_match.group(1)
|
||||
nr_width = pattern_match.group(2)
|
||||
def closure_func(gramps_id):
|
||||
if gramps_id and gramps_id.startswith(str_prefix):
|
||||
id_number = gramps_id[len(str_prefix):]
|
||||
if id_number.isdigit():
|
||||
id_value = int(id_number, 10)
|
||||
if len(str(id_value)) > nr_width:
|
||||
# The ID to be imported is too large to fit in the
|
||||
# users format. For now just create a new ID,
|
||||
# because that is also what happens with IDs that
|
||||
# are identical to IDs already in the database. If
|
||||
# the problem of colliding import and already
|
||||
# present IDs is solved the code here also needs
|
||||
# some solution.
|
||||
gramps_id = id_pattern % 1
|
||||
else:
|
||||
gramps_id = id_pattern % id_value
|
||||
return gramps_id
|
||||
else:
|
||||
def closure_func(gramps_id):
|
||||
return gramps_id
|
||||
return closure_func
|
||||
|
||||
def set_person_id_prefix(self, val):
|
||||
"""
|
||||
Set the naming template for GRAMPS Person ID values.
|
||||
|
||||
The string is expected to be in the form of a simple text string, or
|
||||
in a format that contains a C/Python style format string using %d,
|
||||
such as I%d or I%04d.
|
||||
"""
|
||||
self.person_prefix = self._validated_id_prefix(val, "I")
|
||||
self.id2user_format = self.__id2user_format(self.person_prefix)
|
||||
|
||||
def set_citation_id_prefix(self, val):
|
||||
"""
|
||||
Set the naming template for GRAMPS Citation ID values.
|
||||
|
||||
The string is expected to be in the form of a simple text string, or
|
||||
in a format that contains a C/Python style format string using %d,
|
||||
such as C%d or C%04d.
|
||||
"""
|
||||
self.citation_prefix = self._validated_id_prefix(val, "C")
|
||||
self.cid2user_format = self.__id2user_format(self.citation_prefix)
|
||||
|
||||
def set_source_id_prefix(self, val):
|
||||
"""
|
||||
Set the naming template for GRAMPS Source ID values.
|
||||
|
||||
The string is expected to be in the form of a simple text string, or
|
||||
in a format that contains a C/Python style format string using %d,
|
||||
such as S%d or S%04d.
|
||||
"""
|
||||
self.source_prefix = self._validated_id_prefix(val, "S")
|
||||
self.sid2user_format = self.__id2user_format(self.source_prefix)
|
||||
|
||||
def set_object_id_prefix(self, val):
|
||||
"""
|
||||
Set the naming template for GRAMPS MediaObject ID values.
|
||||
|
||||
The string is expected to be in the form of a simple text string, or
|
||||
in a format that contains a C/Python style format string using %d,
|
||||
such as O%d or O%04d.
|
||||
"""
|
||||
self.mediaobject_prefix = self._validated_id_prefix(val, "O")
|
||||
self.oid2user_format = self.__id2user_format(self.mediaobject_prefix)
|
||||
|
||||
def set_place_id_prefix(self, val):
|
||||
"""
|
||||
Set the naming template for GRAMPS Place ID values.
|
||||
|
||||
The string is expected to be in the form of a simple text string, or
|
||||
in a format that contains a C/Python style format string using %d,
|
||||
such as P%d or P%04d.
|
||||
"""
|
||||
self.place_prefix = self._validated_id_prefix(val, "P")
|
||||
self.pid2user_format = self.__id2user_format(self.place_prefix)
|
||||
|
||||
def set_family_id_prefix(self, val):
|
||||
"""
|
||||
Set the naming template for GRAMPS Family ID values. The string is
|
||||
expected to be in the form of a simple text string, or in a format
|
||||
that contains a C/Python style format string using %d, such as F%d
|
||||
or F%04d.
|
||||
"""
|
||||
self.family_prefix = self._validated_id_prefix(val, "F")
|
||||
self.fid2user_format = self.__id2user_format(self.family_prefix)
|
||||
|
||||
def set_event_id_prefix(self, val):
|
||||
"""
|
||||
Set the naming template for GRAMPS Event ID values.
|
||||
|
||||
The string is expected to be in the form of a simple text string, or
|
||||
in a format that contains a C/Python style format string using %d,
|
||||
such as E%d or E%04d.
|
||||
"""
|
||||
self.event_prefix = self._validated_id_prefix(val, "E")
|
||||
self.eid2user_format = self.__id2user_format(self.event_prefix)
|
||||
|
||||
def set_repository_id_prefix(self, val):
|
||||
"""
|
||||
Set the naming template for GRAMPS Repository ID values.
|
||||
|
||||
The string is expected to be in the form of a simple text string, or
|
||||
in a format that contains a C/Python style format string using %d,
|
||||
such as R%d or R%04d.
|
||||
"""
|
||||
self.repository_prefix = self._validated_id_prefix(val, "R")
|
||||
self.rid2user_format = self.__id2user_format(self.repository_prefix)
|
||||
|
||||
def set_note_id_prefix(self, val):
|
||||
"""
|
||||
Set the naming template for GRAMPS Note ID values.
|
||||
|
||||
The string is expected to be in the form of a simple text string, or
|
||||
in a format that contains a C/Python style format string using %d,
|
||||
such as N%d or N%04d.
|
||||
"""
|
||||
self.note_prefix = self._validated_id_prefix(val, "N")
|
||||
self.nid2user_format = self.__id2user_format(self.note_prefix)
|
||||
|
||||
def __find_next_gramps_id(self, prefix, map_index, trans):
|
||||
"""
|
||||
Helper function for find_next_<object>_gramps_id methods
|
||||
"""
|
||||
index = prefix % map_index
|
||||
while trans.get(str(index), txn=self.txn) is not None:
|
||||
map_index += 1
|
||||
index = prefix % map_index
|
||||
map_index += 1
|
||||
return (map_index, index)
|
||||
|
||||
def find_next_person_gramps_id(self):
|
||||
"""
|
||||
Return the next available GRAMPS' ID for a Person object based off the
|
||||
person ID prefix.
|
||||
"""
|
||||
self.pmap_index, gid = self.__find_next_gramps_id(self.person_prefix,
|
||||
self.pmap_index, self.id_trans)
|
||||
return gid
|
||||
|
||||
def find_next_place_gramps_id(self):
|
||||
"""
|
||||
Return the next available GRAMPS' ID for a Place object based off the
|
||||
place ID prefix.
|
||||
"""
|
||||
self.lmap_index, gid = self.__find_next_gramps_id(self.place_prefix,
|
||||
self.lmap_index, self.pid_trans)
|
||||
return gid
|
||||
|
||||
def find_next_event_gramps_id(self):
|
||||
"""
|
||||
Return the next available GRAMPS' ID for a Event object based off the
|
||||
event ID prefix.
|
||||
"""
|
||||
self.emap_index, gid = self.__find_next_gramps_id(self.event_prefix,
|
||||
self.emap_index, self.eid_trans)
|
||||
return gid
|
||||
|
||||
def find_next_object_gramps_id(self):
|
||||
"""
|
||||
Return the next available GRAMPS' ID for a MediaObject object based
|
||||
off the media object ID prefix.
|
||||
"""
|
||||
self.omap_index, gid = self.__find_next_gramps_id(self.mediaobject_prefix,
|
||||
self.omap_index, self.oid_trans)
|
||||
return gid
|
||||
|
||||
def find_next_citation_gramps_id(self):
|
||||
"""
|
||||
Return the next available GRAMPS' ID for a Citation object based off the
|
||||
citation ID prefix.
|
||||
"""
|
||||
self.cmap_index, gid = self.__find_next_gramps_id(self.citation_prefix,
|
||||
self.cmap_index, self.cid_trans)
|
||||
return gid
|
||||
|
||||
def find_next_source_gramps_id(self):
|
||||
"""
|
||||
Return the next available GRAMPS' ID for a Source object based off the
|
||||
source ID prefix.
|
||||
"""
|
||||
self.smap_index, gid = self.__find_next_gramps_id(self.source_prefix,
|
||||
self.smap_index, self.sid_trans)
|
||||
return gid
|
||||
|
||||
def find_next_family_gramps_id(self):
|
||||
"""
|
||||
Return the next available GRAMPS' ID for a Family object based off the
|
||||
family ID prefix.
|
||||
"""
|
||||
self.fmap_index, gid = self.__find_next_gramps_id(self.family_prefix,
|
||||
self.fmap_index, self.fid_trans)
|
||||
return gid
|
||||
|
||||
def find_next_repository_gramps_id(self):
|
||||
"""
|
||||
Return the next available GRAMPS' ID for a Respository object based
|
||||
off the repository ID prefix.
|
||||
"""
|
||||
self.rmap_index, gid = self.__find_next_gramps_id(self.repository_prefix,
|
||||
self.rmap_index, self.rid_trans)
|
||||
return gid
|
||||
|
||||
def find_next_note_gramps_id(self):
|
||||
"""
|
||||
Return the next available GRAMPS' ID for a Note object based off the
|
||||
note ID prefix.
|
||||
"""
|
||||
self.nmap_index, gid = self.__find_next_gramps_id(self.note_prefix,
|
||||
self.nmap_index, self.nid_trans)
|
||||
return gid
|
||||
|
||||
def get_mediapath(self):
|
||||
return None
|
||||
|
||||
def get_name_group_keys(self):
|
||||
return []
|
||||
|
||||
def get_name_group_mapping(self, key):
|
||||
return None
|
||||
|
||||
def get_researcher(self):
|
||||
obj = gen.lib.Researcher()
|
||||
return obj
|
||||
|
||||
def get_person_handles(self):
|
||||
return self.person_map.keys()
|
||||
|
||||
def get_family_handles(self):
|
||||
return self.family_map.keys()
|
||||
|
||||
def get_event_handles(self):
|
||||
return self.event_map.keys()
|
||||
|
||||
def get_citation_handles(self):
|
||||
return self.citation_map.keys()
|
||||
|
||||
def get_source_handles(self):
|
||||
return self.source_map.keys()
|
||||
|
||||
def get_place_handles(self):
|
||||
return self.place_map.keys()
|
||||
|
||||
def get_repository_handles(self):
|
||||
return self.repository_map.keys()
|
||||
|
||||
def get_media_object_handles(self):
|
||||
return self.media_map.keys()
|
||||
|
||||
def get_note_handles(self):
|
||||
return self.note_map.keys()
|
||||
|
||||
def get_tag_handles(self, sort_handles=False):
|
||||
return []
|
||||
|
||||
def get_event_from_handle(self, handle):
|
||||
return self.event_map[handle]
|
||||
|
||||
def get_family_from_handle(self, handle):
|
||||
return self.family_map[handle]
|
||||
|
||||
def get_repository_from_handle(self, handle):
|
||||
return self.repository_map[handle]
|
||||
|
||||
def get_person_from_handle(self, handle):
|
||||
return self.person_map[handle]
|
||||
|
||||
def get_place_from_handle(self, handle):
|
||||
place = self.person_map[handle]
|
||||
return place
|
||||
|
||||
def get_citation_from_handle(self, handle):
|
||||
citation = self.citation_map[handle]
|
||||
return citation
|
||||
|
||||
def get_source_from_handle(self, handle):
|
||||
source = self.source_map[handle]
|
||||
return source
|
||||
|
||||
def get_note_from_handle(self, handle):
|
||||
note = self.note_map[handle]
|
||||
return note
|
||||
|
||||
def get_object_from_handle(self, handle):
|
||||
media = self.media_map[handle]
|
||||
return media
|
||||
|
||||
def get_default_person(self):
|
||||
return None
|
||||
|
||||
def iter_people(self):
|
||||
return (person for person in self.person_map.values())
|
||||
|
||||
def iter_person_handles(self):
|
||||
return (handle for handle in self.person_map.keys())
|
||||
|
||||
def iter_families(self):
|
||||
return (family for family in self.family_map.values())
|
||||
|
||||
def iter_family_handles(self):
|
||||
return (handle for handle in self.family_map.keys())
|
||||
|
||||
def get_tag_from_name(self, name):
|
||||
for tag in self.tag_map.values():
|
||||
if tag.name == name:
|
||||
return tag
|
||||
return None
|
||||
|
||||
def get_family_from_gramps_id(self, gramps_id):
|
||||
for family in self.family_map.values():
|
||||
if family.gramps_id == gramps_id:
|
||||
return family
|
||||
return None
|
||||
|
||||
def get_person_from_gramps_id(self, gramps_id):
|
||||
for person in self.person_map.values():
|
||||
if person.gramps_id == gramps_id:
|
||||
return person
|
||||
return person
|
||||
|
||||
def get_number_of_people(self):
|
||||
return len(self.person_map)
|
||||
|
||||
def get_number_of_events(self):
|
||||
return len(self.event_map)
|
||||
|
||||
def get_number_of_places(self):
|
||||
return len(self.place_map)
|
||||
|
||||
def get_number_of_tags(self):
|
||||
return 0 # FIXME
|
||||
|
||||
def get_number_of_families(self):
|
||||
return len(self.family_map)
|
||||
|
||||
def get_number_of_notes(self):
|
||||
return len(self.note_map)
|
||||
|
||||
def get_number_of_citations(self):
|
||||
return len(self.citation_map)
|
||||
|
||||
def get_number_of_sources(self):
|
||||
return len(self.source_map)
|
||||
|
||||
def get_number_of_media_objects(self):
|
||||
return len(self.media_map)
|
||||
|
||||
def get_number_of_repositories(self):
|
||||
return len(self.repository_map)
|
||||
|
||||
def get_place_cursor(self):
|
||||
return Cursor(self.place_map, self.get_raw_place_data).iter()
|
||||
|
||||
def get_person_cursor(self):
|
||||
return Cursor(self.person_map, self.get_raw_person_data).iter()
|
||||
|
||||
def get_family_cursor(self):
|
||||
return Cursor(self.family_map, self.get_raw_family_data).iter()
|
||||
|
||||
def get_events_cursor(self):
|
||||
return Cursor(self.event_map, self.get_raw_event_data).iter()
|
||||
|
||||
def get_citation_cursor(self):
|
||||
return Cursor(self.citation_map, self.get_raw_citation_data).iter()
|
||||
|
||||
def get_source_cursor(self):
|
||||
return Cursor(self.source_map, self.get_raw_source_data).iter()
|
||||
|
||||
def has_gramps_id(self, obj_key, gramps_id):
|
||||
key2table = {
|
||||
PERSON_KEY: self.person_map,
|
||||
FAMILY_KEY: self.family_map,
|
||||
SOURCE_KEY: self.source_map,
|
||||
CITATION_KEY: self.citation_map,
|
||||
EVENT_KEY: self.event_map,
|
||||
MEDIA_KEY: self.media_map,
|
||||
PLACE_KEY: self.place_map,
|
||||
REPOSITORY_KEY: self.repository_map,
|
||||
NOTE_KEY: self.note_map,
|
||||
}
|
||||
map = key2table[obj_key]
|
||||
for item in map.values():
|
||||
if item.gramps_id == gramps_id:
|
||||
return True
|
||||
return False
|
||||
|
||||
def has_person_handle(self, handle):
|
||||
return handle in self.person_map
|
||||
|
||||
def has_family_handle(self, handle):
|
||||
return handle in self.family_map
|
||||
|
||||
def has_citation_handle(self, handle):
|
||||
return handle in self.citation_map
|
||||
|
||||
def has_source_handle(self, handle):
|
||||
return handle in self.source_map
|
||||
|
||||
def has_repository_handle(self, handle):
|
||||
return handle in self.repository_map
|
||||
|
||||
def has_note_handle(self, handle):
|
||||
return handle in self.note_map
|
||||
|
||||
def has_place_handle(self, handle):
|
||||
return handle in self.place_map
|
||||
|
||||
def has_event_handle(self, handle):
|
||||
return handle in self.event_map
|
||||
|
||||
def has_tag_handle(self, handle):
|
||||
return handle in self.tag_map
|
||||
|
||||
def has_object_handle(self, handle):
|
||||
return handle in self.media_map
|
||||
|
||||
def has_name_group_key(self, key):
|
||||
# FIXME:
|
||||
return False
|
||||
|
||||
def set_name_group_mapping(self, key, value):
|
||||
# FIXME:
|
||||
pass
|
||||
|
||||
def set_default_person_handle(self, handle):
|
||||
pass
|
||||
|
||||
def set_mediapath(self, mediapath):
|
||||
pass
|
||||
|
||||
def get_raw_person_data(self, handle):
|
||||
if handle in self.person_map:
|
||||
return self.person_map[handle].serialize()
|
||||
return None
|
||||
|
||||
def get_raw_family_data(self, handle):
|
||||
if handle in self.family_map:
|
||||
return self.family_map[handle].serialize()
|
||||
return None
|
||||
|
||||
def get_raw_citation_data(self, handle):
|
||||
if handle in self.citation_map:
|
||||
return self.citation_map[handle].serialize()
|
||||
return None
|
||||
|
||||
def get_raw_source_data(self, handle):
|
||||
if handle in self.source_map:
|
||||
return self.source_map[handle].serialize()
|
||||
return None
|
||||
|
||||
def get_raw_repository_data(self, handle):
|
||||
if handle in self.repository_map:
|
||||
return self.repository_map[handle].serialize()
|
||||
return None
|
||||
|
||||
def get_raw_note_data(self, handle):
|
||||
if handle in self.note_map:
|
||||
return self.note_map[handle].serialize()
|
||||
return None
|
||||
|
||||
def get_raw_place_data(self, handle):
|
||||
if handle in self.place_map:
|
||||
return self.place_map[handle].serialize()
|
||||
return None
|
||||
|
||||
def get_raw_object_data(self, handle):
|
||||
if handle in self.media_map:
|
||||
return self.media_map[handle].serialize()
|
||||
return None
|
||||
|
||||
def add_person(self, person, trans, set_gid=True):
|
||||
if not person.handle:
|
||||
person.handle = create_id()
|
||||
if not person.gramps_id or set_gid:
|
||||
person.gramps_id = self.find_next_person_gramps_id()
|
||||
self.commit_person(person, trans)
|
||||
return person.handle
|
||||
|
||||
def add_family(self, family, trans, set_gid=True):
|
||||
if not family.handle:
|
||||
family.handle = create_id()
|
||||
if not family.gramps_id or set_gid:
|
||||
family.gramps_id = self.find_next_family_gramps_id()
|
||||
self.commit_family(family, trans)
|
||||
return family.handle
|
||||
|
||||
def add_citation(self, citation, trans, set_gid=True):
|
||||
if not citation.handle:
|
||||
citation.handle = create_id()
|
||||
if not citation.gramps_id or set_gid:
|
||||
citation.gramps_id = self.find_next_citation_gramps_id()
|
||||
self.commit_citation(citation, trans)
|
||||
return citation.handle
|
||||
|
||||
def add_source(self, source, trans, set_gid=True):
|
||||
if not source.handle:
|
||||
source.handle = create_id()
|
||||
if not source.gramps_id or set_gid:
|
||||
source.gramps_id = self.find_next_source_gramps_id()
|
||||
self.commit_source(source, trans)
|
||||
return source.handle
|
||||
|
||||
def add_repository(self, repository, trans, set_gid=True):
|
||||
if not repository.handle:
|
||||
repository.handle = create_id()
|
||||
if not repository.gramps_id or set_gid:
|
||||
repository.gramps_id = self.find_next_repository_gramps_id()
|
||||
self.commit_repository(repository, trans)
|
||||
return repository.handle
|
||||
|
||||
def add_note(self, note, trans, set_gid=True):
|
||||
if not note.handle:
|
||||
note.handle = create_id()
|
||||
if not note.gramps_id or set_gid:
|
||||
note.gramps_id = self.find_next_note_gramps_id()
|
||||
self.commit_note(note, trans)
|
||||
return note.handle
|
||||
|
||||
def add_place(self, place, trans, set_gid=True):
|
||||
if not place.handle:
|
||||
place.handle = create_id()
|
||||
if not place.gramps_id or set_gid:
|
||||
place.gramps_id = self.find_next_place_gramps_id()
|
||||
self.commit_place(place, trans)
|
||||
return place.handle
|
||||
|
||||
def add_event(self, event, trans, set_gid=True):
|
||||
if not event.handle:
|
||||
event.handle = create_id()
|
||||
if not event.gramps_id or set_gid:
|
||||
event.gramps_id = self.find_next_event_gramps_id()
|
||||
self.commit_event(event, trans)
|
||||
return event.handle
|
||||
|
||||
def add_tag(self, tag, trans):
|
||||
if not tag.handle:
|
||||
tag.handle = create_id()
|
||||
self.commit_event(tag, trans)
|
||||
return tag.handle
|
||||
|
||||
def add_object(self, obj, transaction, set_gid=True):
|
||||
"""
|
||||
Add a MediaObject to the database, assigning internal IDs if they have
|
||||
not already been defined.
|
||||
|
||||
If not set_gid, then gramps_id is not set.
|
||||
"""
|
||||
if not obj.handle:
|
||||
obj.handle = create_id()
|
||||
if not obj.gramps_id or set_gid:
|
||||
obj.gramps_id = self.find_next_object_gramps_id()
|
||||
self.commit_media_object(obj, transaction)
|
||||
return obj.handle
|
||||
|
||||
def commit_person(self, person, trans, change_time=None):
|
||||
self.person_map[person.handle] = person
|
||||
|
||||
def commit_family(self, family, trans, change_time=None):
|
||||
self.family_map[family.handle] = family
|
||||
|
||||
def commit_citation(self, citation, trans, change_time=None):
|
||||
self.citation_map[citation.handle] = citation
|
||||
|
||||
def commit_source(self, source, trans, change_time=None):
|
||||
self.source_map[source.handle] = source
|
||||
|
||||
def commit_repository(self, repository, trans, change_time=None):
|
||||
self.repository_map[repository.handle] = repository
|
||||
|
||||
def commit_note(self, note, trans, change_time=None):
|
||||
self.note_map[note.handle] = note
|
||||
|
||||
def commit_place(self, place, trans, change_time=None):
|
||||
self.place_map[place.handle] = place
|
||||
|
||||
def commit_event(self, event, trans, change_time=None):
|
||||
self.event_map[event.handle] = event
|
||||
|
||||
def commit_tag(self, tag, trans, change_time=None):
|
||||
self.tag_map[tag.handle] = tag
|
||||
|
||||
def commit_media_object(self, obj, transaction, change_time=None):
|
||||
self.media_map[obj.handle] = obj
|
||||
|
||||
def get_gramps_ids(self, obj_key):
|
||||
key2table = {
|
||||
PERSON_KEY: self.person_map,
|
||||
FAMILY_KEY: self.family_map,
|
||||
CITATION_KEY: self.citation_map,
|
||||
SOURCE_KEY: self.source_map,
|
||||
EVENT_KEY: self.event_map,
|
||||
MEDIA_KEY: self.media_map,
|
||||
PLACE_KEY: self.place_map,
|
||||
REPOSITORY_KEY: self.repository_map,
|
||||
NOTE_KEY: self.note_map,
|
||||
}
|
||||
table = key2table[obj_key]
|
||||
return [item.gramps_id for item in table.values()]
|
||||
|
||||
def transaction_begin(self, transaction):
|
||||
return
|
||||
|
||||
def disable_signals(self):
|
||||
pass
|
||||
|
||||
def set_researcher(self, owner):
|
||||
pass
|
||||
|
||||
def request_rebuild(self):
|
||||
pass
|
||||
|
@ -59,7 +59,7 @@ from gen.lib import (MediaObject, Person, Family, Source, Citation, Event,
|
||||
from gen.db.dbconst import *
|
||||
from gen.utils.callback import Callback
|
||||
from gen.db import (BsddbBaseCursor, DbReadBase)
|
||||
from Utils import create_id
|
||||
from gen.utils.id import create_id
|
||||
from gen.errors import DbError
|
||||
|
||||
LOG = logging.getLogger(DBLOGNAME)
|
||||
|
@ -27,7 +27,7 @@ Provide the database state class
|
||||
|
||||
from gen.db import DbBsddbRead
|
||||
from gen.proxy.proxybase import ProxyDbBase
|
||||
from gen.utils import Callback
|
||||
from gen.utils.callback import Callback
|
||||
from gen.config import config
|
||||
|
||||
class DbState(Callback):
|
||||
|
@ -27,7 +27,7 @@ Package providing filtering framework for GRAMPS.
|
||||
#SystemFilters = None
|
||||
CustomFilters = None
|
||||
|
||||
from const import CUSTOM_FILTERS
|
||||
from gen.const import CUSTOM_FILTERS
|
||||
from _filterlist import FilterList
|
||||
from _genericfilter import GenericFilter, GenericFilterFactory
|
||||
from _paramfilter import ParamFilter
|
||||
|
@ -35,7 +35,7 @@ from gen.ggettext import gettext as _
|
||||
import gen.datehandler
|
||||
from gen.lib import EventType
|
||||
from gen.filters.rules import Rule
|
||||
from Utils import get_participant_from_event
|
||||
from gen.utils.db import get_participant_from_event
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -32,7 +32,7 @@ from gen.ggettext import gettext as _
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Utils import for_each_ancestor
|
||||
from gen.utils.db import for_each_ancestor
|
||||
from gen.filters.rules import Rule
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
@ -32,7 +32,7 @@ from gen.ggettext import gettext as _
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Utils import for_each_ancestor
|
||||
from gen.utils.db import for_each_ancestor
|
||||
from _hascommonancestorwith import HasCommonAncestorWith
|
||||
from _matchesfilter import MatchesFilter
|
||||
|
||||
|
@ -35,7 +35,7 @@ LOG = logging.getLogger(".citationfilter")
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.utils.referent import get_source_and_citation_referents
|
||||
from gen.utils.db import get_source_and_citation_referents
|
||||
from gen.filters.rules import Rule
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
@ -92,7 +92,6 @@ class Span(object):
|
||||
self.date2 = date2
|
||||
self.sort = (-9999, -9999)
|
||||
self.minmax = (9999, -9999)
|
||||
self.repr = None
|
||||
self.precision = 2
|
||||
self.negative = False
|
||||
if self.valid:
|
||||
@ -109,22 +108,18 @@ class Span(object):
|
||||
v = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (v, 0)
|
||||
self.minmax = (v, v)
|
||||
#self.repr = self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date2.get_modifier() == Date.MOD_BEFORE:
|
||||
v = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (v, -Span.BEFORE)
|
||||
self.minmax = (v - Span.BEFORE, v)
|
||||
#self.repr = "more than " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date2.get_modifier() == Date.MOD_AFTER:
|
||||
v = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (v, Span.AFTER)
|
||||
self.minmax = (v, v + Span.AFTER)
|
||||
#self.repr = "less than " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date2.get_modifier() == Date.MOD_ABOUT:
|
||||
v = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (v, -Span.ABOUT)
|
||||
self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
|
||||
#self.repr = "about " + self._format(self._diff(self.date1, self.date2))
|
||||
elif (self.date2.get_modifier() == Date.MOD_RANGE or
|
||||
self.date2.get_modifier() == Date.MOD_SPAN):
|
||||
start, stop = self.date2.get_start_stop_range()
|
||||
@ -134,89 +129,72 @@ class Span(object):
|
||||
v2 = self.date1.sortval - start.sortval # max
|
||||
self.sort = (v1, v2 - v1)
|
||||
self.minmax = (v1, v2)
|
||||
#self.repr = ("between " + self._format(self._diff(self.date1, stop)) +
|
||||
# " and " + self._format(self._diff(self.date1, start)))
|
||||
elif self.date1.get_modifier() == Date.MOD_BEFORE: # BEFORE----------------------------
|
||||
if self.date2.get_modifier() == Date.MOD_NONE:
|
||||
v = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (v, 0)
|
||||
self.minmax = (0, v)
|
||||
#self.repr = "less than " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date2.get_modifier() == Date.MOD_BEFORE:
|
||||
v = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (v, -Span.BEFORE)
|
||||
self.minmax = (v, v + Span.BEFORE)
|
||||
#self.repr = "more than " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date2.get_modifier() == Date.MOD_AFTER:
|
||||
v = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (v, -Span.AFTER)
|
||||
self.minmax = (0, v)
|
||||
#self.repr = "less than " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date2.get_modifier() == Date.MOD_ABOUT:
|
||||
v = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (v, -Span.ABOUT)
|
||||
self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
|
||||
#self.repr = "about " + self._format(self._diff(self.date1, self.date2))
|
||||
elif (self.date2.get_modifier() == Date.MOD_RANGE or
|
||||
self.date2.get_modifier() == Date.MOD_SPAN):
|
||||
v = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (v, -Span.ABOUT)
|
||||
self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
|
||||
#self.repr = "more than " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date1.get_modifier() == Date.MOD_AFTER: # AFTER----------------------------
|
||||
if self.date2.get_modifier() == Date.MOD_NONE:
|
||||
v = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (v, Span.AFTER)
|
||||
self.minmax = (v, v + Span.AFTER)
|
||||
#self.repr = "more than " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date2.get_modifier() == Date.MOD_BEFORE:
|
||||
v = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (v, Span.AFTER)
|
||||
self.minmax = (v - Span.BEFORE, v + Span.AFTER)
|
||||
#self.repr = "more than " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date2.get_modifier() == Date.MOD_AFTER:
|
||||
v = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (v, Span.AFTER)
|
||||
self.minmax = (v, v + Span.AFTER)
|
||||
#self.repr = "more than " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date2.get_modifier() == Date.MOD_ABOUT:
|
||||
v = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (v, -Span.ABOUT)
|
||||
self.minmax = (v - Span.ABOUT, v + Span.AFTER)
|
||||
#self.repr = "more than about " + self._format(self._diff(self.date1, self.date2))
|
||||
elif (self.date2.get_modifier() == Date.MOD_RANGE or
|
||||
self.date2.get_modifier() == Date.MOD_SPAN):
|
||||
v = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (v, -Span.ABOUT)
|
||||
self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
|
||||
#self.repr = "more than " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date1.get_modifier() == Date.MOD_ABOUT: # ABOUT----------------------------
|
||||
if self.date2.get_modifier() == Date.MOD_NONE:
|
||||
v = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (v, -Span.ABOUT)
|
||||
self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
|
||||
#self.repr = "about " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date2.get_modifier() == Date.MOD_BEFORE:
|
||||
v = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (v, -Span.BEFORE)
|
||||
self.minmax = (v - Span.BEFORE, v + Span.ABOUT)
|
||||
#self.repr = "more than " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date2.get_modifier() == Date.MOD_AFTER:
|
||||
v = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (v, Span.AFTER)
|
||||
self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
|
||||
#self.repr = "less than about " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date2.get_modifier() == Date.MOD_ABOUT:
|
||||
v = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (v, -Span.ABOUT)
|
||||
self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
|
||||
#self.repr = "about " + self._format(self._diff(self.date1, self.date2))
|
||||
elif (self.date2.get_modifier() == Date.MOD_RANGE or
|
||||
self.date2.get_modifier() == Date.MOD_SPAN):
|
||||
v = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (v, -Span.ABOUT)
|
||||
self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
|
||||
#self.repr = "about " + self._format(self._diff(self.date1, self.date2))
|
||||
elif (self.date1.get_modifier() == Date.MOD_RANGE or
|
||||
self.date1.get_modifier() == Date.MOD_SPAN): # SPAN----------------------------
|
||||
if self.date2.get_modifier() == Date.MOD_NONE:
|
||||
@ -227,23 +205,18 @@ class Span(object):
|
||||
v2 = self.date2.sortval - stop.sortval # max
|
||||
self.sort = (v1, v2 - v1)
|
||||
self.minmax = (v1, v2)
|
||||
#self.repr = ("between " + self._format(self._diff(start, self.date2)) +
|
||||
# " and " + self._format(self._diff(stop, self.date2)))
|
||||
elif self.date2.get_modifier() == Date.MOD_BEFORE:
|
||||
v = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (v, Span.BEFORE)
|
||||
self.minmax = (v - Span.BEFORE, v + Span.BEFORE)
|
||||
#self.repr = "more than " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date2.get_modifier() == Date.MOD_AFTER:
|
||||
v = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (v, -Span.AFTER)
|
||||
self.minmax = (v - Span.AFTER, v + Span.AFTER)
|
||||
#self.repr = "less than " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date2.get_modifier() == Date.MOD_ABOUT:
|
||||
v = self.date1.sortval - self.date2.sortval
|
||||
self.sort = (v, -Span.ABOUT)
|
||||
self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
|
||||
#self.repr = "about " + self._format(self._diff(self.date1, self.date2))
|
||||
elif (self.date2.get_modifier() == Date.MOD_RANGE or
|
||||
self.date2.get_modifier() == Date.MOD_SPAN):
|
||||
start1, stop1 = self.date1.get_start_stop_range()
|
||||
@ -256,8 +229,6 @@ class Span(object):
|
||||
v2 = stop1.sortval - start2.sortval # max
|
||||
self.sort = (v1, v2 - v1)
|
||||
self.minmax = (v1, v2)
|
||||
#self.repr = ("between " + self._format(self._diff(start1, stop2)) +
|
||||
# " and " + self._format(self._diff(stop1, start2)))
|
||||
|
||||
def is_valid(self):
|
||||
return self.valid
|
||||
@ -290,154 +261,99 @@ class Span(object):
|
||||
else:
|
||||
return cmp(int(self), int(other))
|
||||
|
||||
def as_age(self):
|
||||
"""
|
||||
Get Span as an age (will not return more than Span.ALIVE).
|
||||
"""
|
||||
return self.get_repr(as_age=True)
|
||||
|
||||
def as_time(self):
|
||||
"""
|
||||
Get Span as a time (can be greater than Span.ALIVE).
|
||||
"""
|
||||
return self.get_repr(as_age=False)
|
||||
|
||||
def __repr__(self):
|
||||
if self.repr is not None:
|
||||
return self.repr
|
||||
elif self.valid:
|
||||
# TO_REWRITE: bug #5293 !
|
||||
if self._diff(self.date1, self.date2)[0] > Span.ALIVE:
|
||||
return _("less than %s years") % Span.ALIVE
|
||||
if self.date1.get_modifier() == Date.MOD_NONE:
|
||||
"""
|
||||
Get the Span as an age. Use Span.as_time() to get as a textual
|
||||
description of time greater than Span.ALIVE.
|
||||
"""
|
||||
return self.get_repr(as_age=True)
|
||||
|
||||
def get_repr(self, as_age=False):
|
||||
"""
|
||||
Get the representation as a time or age.
|
||||
"""
|
||||
_repr = _("unknown")
|
||||
if self.valid:
|
||||
if as_age and self._diff(self.date1, self.date2)[0] > Span.ALIVE:
|
||||
_repr = _("less than %s years") % Span.ALIVE
|
||||
elif self.date1.get_modifier() == Date.MOD_NONE:
|
||||
if self.date2.get_modifier() == Date.MOD_NONE:
|
||||
#v = self.date1.sortval - self.date2.sortval
|
||||
#self.sort = (v, 0)
|
||||
#self.minmax = (v, v)
|
||||
self.repr = self._format(self._diff(self.date1, self.date2))
|
||||
_repr = self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date2.get_modifier() == Date.MOD_BEFORE:
|
||||
#v = self.date1.sortval - self.date2.sortval
|
||||
#self.sort = (v, -Span.BEFORE)
|
||||
#self.minmax = (v - Span.BEFORE, v)
|
||||
self.repr = _("more than") + " " + self._format(self._diff(self.date1, self.date2))
|
||||
_repr = _("more than") + " " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date2.get_modifier() == Date.MOD_AFTER:
|
||||
#v = self.date1.sortval - self.date2.sortval
|
||||
#self.sort = (v, Span.AFTER)
|
||||
#self.minmax = (v, v + Span.AFTER)
|
||||
self.repr = _("less than") + " " + self._format(self._diff(self.date1, self.date2))
|
||||
_repr = _("less than") + " " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date2.get_modifier() == Date.MOD_ABOUT:
|
||||
#v = self.date1.sortval - self.date2.sortval
|
||||
#self.sort = (v, -Span.ABOUT)
|
||||
#self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
|
||||
# TO_FIX: bug #5293 !
|
||||
self.repr = _("age|about") + " " + self._format(self._diff(self.date1, self.date2)).format(precision=1)
|
||||
_repr = _("age|about") + " " + self._format(self._diff(self.date1, self.date2)).format(precision=1)
|
||||
elif (self.date2.get_modifier() == Date.MOD_RANGE or
|
||||
self.date2.get_modifier() == Date.MOD_SPAN):
|
||||
start, stop = self.date2.get_start_stop_range()
|
||||
start = Date(*start)
|
||||
stop = Date(*stop)
|
||||
#v1 = self.date1.sortval - stop.sortval # min
|
||||
#v2 = self.date1.sortval - start.sortval # max
|
||||
#self.sort = (v1, v2 - v1)
|
||||
#self.minmax = (v1, v2)
|
||||
self.repr = (_("between") + " " + self._format(self._diff(self.date1, stop)) +
|
||||
_repr = (_("between") + " " + self._format(self._diff(self.date1, stop)) +
|
||||
" " + _("and") + " " + self._format(self._diff(self.date1, start)))
|
||||
elif self.date1.get_modifier() == Date.MOD_BEFORE: # BEFORE----------------------------
|
||||
if self.date2.get_modifier() == Date.MOD_NONE:
|
||||
#v = self.date1.sortval - self.date2.sortval
|
||||
#self.sort = (v, 0)
|
||||
#self.minmax = (0, v)
|
||||
self.repr = _("less than") + " " + self._format(self._diff(self.date1, self.date2))
|
||||
_repr = _("less than") + " " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date2.get_modifier() == Date.MOD_BEFORE:
|
||||
#v = self.date1.sortval - self.date2.sortval
|
||||
#self.sort = (v, -Span.BEFORE)
|
||||
#self.minmax = (v, v + Span.BEFORE)
|
||||
self.repr = self._format((-1, -1 , -1))
|
||||
_repr = self._format((-1, -1 , -1))
|
||||
elif self.date2.get_modifier() == Date.MOD_AFTER:
|
||||
#v = self.date1.sortval - self.date2.sortval
|
||||
#self.sort = (v, -Span.AFTER)
|
||||
#self.minmax = (0, v)
|
||||
self.repr = _("less than") + " " + self._format(self._diff(self.date1, self.date2))
|
||||
_repr = _("less than") + " " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date2.get_modifier() == Date.MOD_ABOUT:
|
||||
#v = self.date1.sortval - self.date2.sortval
|
||||
#self.sort = (v, -Span.ABOUT)
|
||||
#self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
|
||||
self.repr = _("less than about") + " " + self._format(self._diff(self.date1, self.date2))
|
||||
_repr = _("less than about") + " " + self._format(self._diff(self.date1, self.date2))
|
||||
elif (self.date2.get_modifier() == Date.MOD_RANGE or
|
||||
self.date2.get_modifier() == Date.MOD_SPAN):
|
||||
#v = self.date1.sortval - self.date2.sortval
|
||||
#self.sort = (v, -Span.ABOUT)
|
||||
#self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
|
||||
self.repr = _("less than") + " " + self._format(self._diff(self.date1, self.date2))
|
||||
_repr = _("less than") + " " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date1.get_modifier() == Date.MOD_AFTER: # AFTER----------------------------
|
||||
if self.date2.get_modifier() == Date.MOD_NONE:
|
||||
#v = self.date1.sortval - self.date2.sortval
|
||||
#self.sort = (v, Span.AFTER)
|
||||
#self.minmax = (v, v + Span.AFTER)
|
||||
self.repr = _("more than") + " " + self._format(self._diff(self.date1, self.date2))
|
||||
_repr = _("more than") + " " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date2.get_modifier() == Date.MOD_BEFORE:
|
||||
#v = self.date1.sortval - self.date2.sortval
|
||||
#self.sort = (v, Span.AFTER)
|
||||
#self.minmax = (v - Span.BEFORE, v + Span.AFTER)
|
||||
self.repr = _("more than") + " " + self._format(self._diff(self.date1, self.date2))
|
||||
_repr = _("more than") + " " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date2.get_modifier() == Date.MOD_AFTER:
|
||||
#v = self.date1.sortval - self.date2.sortval
|
||||
#self.sort = (v, Span.AFTER)
|
||||
#self.minmax = (v, v + Span.AFTER)
|
||||
self.repr = self._format((-1, -1 , -1))
|
||||
_repr = self._format((-1, -1 , -1))
|
||||
elif self.date2.get_modifier() == Date.MOD_ABOUT:
|
||||
#v = self.date1.sortval - self.date2.sortval
|
||||
#self.sort = (v, -Span.ABOUT)
|
||||
#self.minmax = (v - Span.ABOUT, v + Span.AFTER)
|
||||
self.repr = _("more than about") + " " + self._format(self._diff(self.date1, self.date2)).format(precision=1)
|
||||
_repr = _("more than about") + " " + self._format(self._diff(self.date1, self.date2)).format(precision=1)
|
||||
elif (self.date2.get_modifier() == Date.MOD_RANGE or
|
||||
self.date2.get_modifier() == Date.MOD_SPAN):
|
||||
#v = self.date1.sortval - self.date2.sortval
|
||||
#self.sort = (v, -Span.ABOUT)
|
||||
#self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
|
||||
self.repr = _("more than") + " " + self._format(self._diff(self.date1, self.date2))
|
||||
_repr = _("more than") + " " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date1.get_modifier() == Date.MOD_ABOUT: # ABOUT----------------------------
|
||||
if self.date2.get_modifier() == Date.MOD_NONE:
|
||||
#v = self.date1.sortval - self.date2.sortval
|
||||
#self.sort = (v, -Span.ABOUT)
|
||||
#self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
|
||||
self.repr = _("age|about") + " " + self._format(self._diff(self.date1, self.date2)).format(precision=1)
|
||||
_repr = _("age|about") + " " + self._format(self._diff(self.date1, self.date2)).format(precision=1)
|
||||
elif self.date2.get_modifier() == Date.MOD_BEFORE:
|
||||
#v = self.date1.sortval - self.date2.sortval
|
||||
#self.sort = (v, -Span.BEFORE)
|
||||
#self.minmax = (v - Span.BEFORE, v + Span.ABOUT)
|
||||
self.repr = _("more than about") + " " + self._format(self._diff(self.date1, self.date2)).format(precision=1)
|
||||
_repr = _("more than about") + " " + self._format(self._diff(self.date1, self.date2)).format(precision=1)
|
||||
elif self.date2.get_modifier() == Date.MOD_AFTER:
|
||||
#v = self.date1.sortval - self.date2.sortval
|
||||
#self.sort = (v, Span.AFTER)
|
||||
#self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
|
||||
self.repr = _("less than about") + " " + self._format(self._diff(self.date1, self.date2)).format(precision=1)
|
||||
_repr = _("less than about") + " " + self._format(self._diff(self.date1, self.date2)).format(precision=1)
|
||||
elif self.date2.get_modifier() == Date.MOD_ABOUT:
|
||||
#v = self.date1.sortval - self.date2.sortval
|
||||
#self.sort = (v, -Span.ABOUT)
|
||||
#self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
|
||||
self.repr = _("age|about") + " " + self._format(self._diff(self.date1, self.date2)).format(precision=1)
|
||||
_repr = _("age|about") + " " + self._format(self._diff(self.date1, self.date2)).format(precision=1)
|
||||
elif (self.date2.get_modifier() == Date.MOD_RANGE or
|
||||
self.date2.get_modifier() == Date.MOD_SPAN):
|
||||
#v = self.date1.sortval - self.date2.sortval
|
||||
#self.sort = (v, -Span.ABOUT)
|
||||
#self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
|
||||
self.repr = _("age|about") + " " + self._format(self._diff(self.date1, self.date2)).format(precision=1)
|
||||
_repr = _("age|about") + " " + self._format(self._diff(self.date1, self.date2)).format(precision=1)
|
||||
elif (self.date1.get_modifier() == Date.MOD_RANGE or
|
||||
self.date1.get_modifier() == Date.MOD_SPAN): # SPAN----------------------------
|
||||
if self.date2.get_modifier() == Date.MOD_NONE:
|
||||
start, stop = self.date1.get_start_stop_range()
|
||||
start = Date(*start)
|
||||
stop = Date(*stop)
|
||||
#v1 = self.date2.sortval - start.sortval # min
|
||||
#v2 = self.date2.sortval - stop.sortval # max
|
||||
#self.sort = (v1, v2 - v1)
|
||||
#self.minmax = (v1, v2)
|
||||
self.repr = (_("between") + " " + self._format(self._diff(start, self.date2)) +
|
||||
_repr = (_("between") + " " + self._format(self._diff(start, self.date2)) +
|
||||
" " + _("and") + " " + self._format(self._diff(stop, self.date2)))
|
||||
elif self.date2.get_modifier() == Date.MOD_BEFORE:
|
||||
#v = self.date1.sortval - self.date2.sortval
|
||||
#self.sort = (v, Span.BEFORE)
|
||||
#self.minmax = (v - Span.BEFORE, v + Span.BEFORE)
|
||||
self.repr = _("more than") + " " + self._format(self._diff(self.date1, self.date2))
|
||||
_repr = _("more than") + " " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date2.get_modifier() == Date.MOD_AFTER:
|
||||
#v = self.date1.sortval - self.date2.sortval
|
||||
#self.sort = (v, -Span.AFTER)
|
||||
#self.minmax = (v - Span.AFTER, v + Span.AFTER)
|
||||
self.repr = _("less than") + " " + self._format(self._diff(self.date1, self.date2))
|
||||
_repr = _("less than") + " " + self._format(self._diff(self.date1, self.date2))
|
||||
elif self.date2.get_modifier() == Date.MOD_ABOUT:
|
||||
#v = self.date1.sortval - self.date2.sortval
|
||||
#self.sort = (v, -Span.ABOUT)
|
||||
#self.minmax = (v - Span.ABOUT, v + Span.ABOUT)
|
||||
self.repr = _("age|about") + " " + self._format(self._diff(self.date1, self.date2)).format(precision=1)
|
||||
_repr = _("age|about") + " " + self._format(self._diff(self.date1, self.date2)).format(precision=1)
|
||||
elif (self.date2.get_modifier() == Date.MOD_RANGE or
|
||||
self.date2.get_modifier() == Date.MOD_SPAN):
|
||||
start1, stop1 = self.date1.get_start_stop_range()
|
||||
@ -446,15 +362,9 @@ class Span(object):
|
||||
start2 = Date(*start2)
|
||||
stop1 = Date(*stop1)
|
||||
stop2 = Date(*stop2)
|
||||
#v1 = start1.sortval - stop2.sortval # min
|
||||
#v2 = stop1.sortval - start2.sortval # max
|
||||
#self.sort = (v1, v2 - v1)
|
||||
#self.minmax = (v1, v2)
|
||||
self.repr = (_("between") + " " + self._format(self._diff(start1, stop2)) +
|
||||
_repr = (_("between") + " " + self._format(self._diff(start1, stop2)) +
|
||||
" " + _("and") + " " + self._format(self._diff(stop1, start2)))
|
||||
return self.repr
|
||||
else:
|
||||
return _("unknown")
|
||||
return _repr
|
||||
|
||||
def __eq__(self, other):
|
||||
"""
|
||||
@ -480,16 +390,15 @@ class Span(object):
|
||||
return True
|
||||
return int(self) > int(other)
|
||||
|
||||
def format(self, precision=2):
|
||||
def format(self, precision=2, as_age=True):
|
||||
"""
|
||||
Force a string representation at a level of precision.
|
||||
1 = only most significant level (year, month, day)
|
||||
2 = only most two significant levels (year, month, day)
|
||||
3 = at most three items of signifance (year, month, day)
|
||||
"""
|
||||
self.repr = None
|
||||
self.precision = precision
|
||||
return repr(self)
|
||||
return self.get_repr(as_age)
|
||||
|
||||
def _format(self, diff_tuple):
|
||||
if diff_tuple == (-1, -1, -1): return _("unknown")
|
||||
|
@ -36,7 +36,7 @@ import libxml2
|
||||
import libxslt
|
||||
|
||||
from libgrampsxml import GRAMPS_XML_VERSION
|
||||
from const import ROOT_DIR, VERSION, USER_PLUGINS
|
||||
from gen.const import ROOT_DIR, VERSION, USER_PLUGINS
|
||||
import gen.lib
|
||||
from gen.ggettext import sgettext as _
|
||||
|
||||
|
@ -37,10 +37,10 @@ from _pluginreg import (PluginData, PluginRegister, REPORT, TOOL,
|
||||
CATEGORY_QR_CITATION, CATEGORY_QR_SOURCE_OR_CITATION,
|
||||
START, END, make_environment,
|
||||
)
|
||||
from _manager import BasePluginManager
|
||||
from _import import ImportPlugin
|
||||
from _export import ExportPlugin
|
||||
from _docgenplugin import DocGenPlugin
|
||||
from _manager import BasePluginManager
|
||||
from _gramplet import Gramplet
|
||||
from utils import *
|
||||
from _options import (Options, OptionListCollection, OptionList,
|
||||
|
@ -46,8 +46,7 @@ from gen.ggettext import gettext as _
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.config import config
|
||||
import gen.utils
|
||||
from gen.plug import PluginRegister
|
||||
from gen.plug import PluginRegister, ImportPlugin, ExportPlugin, DocGenPlugin
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -476,7 +475,7 @@ class BasePluginManager(object):
|
||||
continue
|
||||
mod = self.load_plugin(pdata)
|
||||
if mod:
|
||||
imp = gen.plug.ImportPlugin(name=pdata.name,
|
||||
imp = ImportPlugin(name=pdata.name,
|
||||
description = pdata.description,
|
||||
import_function = getattr(mod, pdata.import_function),
|
||||
extension = pdata.extension)
|
||||
@ -503,7 +502,7 @@ class BasePluginManager(object):
|
||||
if (pdata.export_options and
|
||||
hasattr(mod, pdata.export_options)):
|
||||
options = getattr(mod, pdata.export_options)
|
||||
exp = gen.plug.ExportPlugin(name=pdata.name_accell,
|
||||
exp = ExportPlugin(name=pdata.name_accell,
|
||||
description = pdata.description,
|
||||
export_function = getattr(mod, pdata.export_function),
|
||||
extension = pdata.extension,
|
||||
@ -528,7 +527,7 @@ class BasePluginManager(object):
|
||||
continue
|
||||
mod = self.load_plugin(pdata)
|
||||
if mod:
|
||||
dgp = gen.plug.DocGenPlugin(name=pdata.name,
|
||||
dgp = DocGenPlugin(name=pdata.name,
|
||||
description = pdata.description,
|
||||
basedoc = getattr(mod, pdata.basedocclass),
|
||||
paper = pdata.paper,
|
||||
|
@ -51,7 +51,7 @@ except:
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Utils
|
||||
from gen.utils.cast import get_type_converter
|
||||
import gen
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -346,7 +346,7 @@ class OptionHandler(object):
|
||||
bad_opts.append(option_name)
|
||||
continue
|
||||
try:
|
||||
converter = Utils.get_type_converter(self.options_dict[option_name])
|
||||
converter = get_type_converter(self.options_dict[option_name])
|
||||
self.options_dict[option_name] = converter(option_data)
|
||||
except ValueError:
|
||||
pass
|
||||
|
@ -40,9 +40,9 @@ import traceback
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from const import VERSION as GRAMPSVERSION, VERSION_TUPLE
|
||||
from const import IMAGE_DIR
|
||||
from TransUtils import get_addon_translator
|
||||
from gen.const import VERSION as GRAMPSVERSION, VERSION_TUPLE
|
||||
from gen.const import IMAGE_DIR
|
||||
from gen.utils.trans import get_addon_translator
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
@ -43,7 +43,7 @@ import sys
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
from gen.ggettext import gettext as _
|
||||
import Utils
|
||||
from gen.utils.file import search_for
|
||||
from gen.plug.docgen import BaseDoc
|
||||
from gen.plug.menu import NumberOption, TextOption, EnumeratedListOption, \
|
||||
BooleanOption
|
||||
@ -88,18 +88,18 @@ _NOTELOC = [ { 'name' : _("Top"), 'value' : "t" },
|
||||
{ 'name' : _("Bottom"), 'value' : "b" }]
|
||||
|
||||
if win():
|
||||
_DOT_FOUND = Utils.search_for("dot.exe")
|
||||
_DOT_FOUND = search_for("dot.exe")
|
||||
|
||||
if Utils.search_for("gswin32c.exe") == 1:
|
||||
if search_for("gswin32c.exe") == 1:
|
||||
_GS_CMD = "gswin32c.exe"
|
||||
elif Utils.search_for("gswin32.exe") == 1:
|
||||
elif search_for("gswin32.exe") == 1:
|
||||
_GS_CMD = "gswin32.exe"
|
||||
else:
|
||||
_GS_CMD = ""
|
||||
else:
|
||||
_DOT_FOUND = Utils.search_for("dot")
|
||||
_DOT_FOUND = search_for("dot")
|
||||
|
||||
if Utils.search_for("gs") == 1:
|
||||
if search_for("gs") == 1:
|
||||
_GS_CMD = "gs"
|
||||
else:
|
||||
_GS_CMD = ""
|
||||
|
@ -163,6 +163,17 @@ class TableCellStyle(object):
|
||||
"Return the cell padding in centimeters"
|
||||
self.padding = val
|
||||
|
||||
def set_borders(self, val):
|
||||
"""
|
||||
Defines if a border is used
|
||||
|
||||
@param val: if True, a border is used, if False, it is not
|
||||
"""
|
||||
self.rborder = val
|
||||
self.lborder = val
|
||||
self.tborder = val
|
||||
self.bborder = val
|
||||
|
||||
def set_right_border(self, val):
|
||||
"""
|
||||
Defines if a right border in used
|
||||
|
@ -29,14 +29,14 @@ The base option class for all other option classes.
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gen.utils
|
||||
from gen.utils.callback import Callback
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Option class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class Option(gen.utils.Callback):
|
||||
class Option(Callback):
|
||||
"""
|
||||
This class serves as a base class for all options. All Options must
|
||||
minimally provide the services provided by this class. Options are allowed
|
||||
@ -56,7 +56,7 @@ class Option(gen.utils.Callback):
|
||||
@type value: The type will depend on the type of option.
|
||||
@return: nothing
|
||||
"""
|
||||
gen.utils.Callback.__init__(self)
|
||||
Callback.__init__(self)
|
||||
self.__value = value
|
||||
self.__label = label
|
||||
self.__help_str = ""
|
||||
|
@ -37,7 +37,6 @@ import os
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import const
|
||||
|
||||
# Report categories
|
||||
from gen.plug import CATEGORY_TEXT, CATEGORY_DRAW, CATEGORY_CODE, CATEGORY_WEB,\
|
||||
|
@ -57,7 +57,7 @@ except:
|
||||
# (do not import anything from 'gui' as this is in 'gen')
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import const
|
||||
from gen.const import HOME_DIR, REPORT_OPTIONS
|
||||
from gen.config import config
|
||||
from gen.plug.docgen import PAPER_PORTRAIT
|
||||
from gen.plug import _options
|
||||
@ -577,7 +577,7 @@ class OptionHandler(_options.OptionHandler):
|
||||
def init_subclass(self):
|
||||
self.collection_class = OptionListCollection
|
||||
self.list_class = OptionList
|
||||
self.filename = const.REPORT_OPTIONS
|
||||
self.filename = REPORT_OPTIONS
|
||||
|
||||
def init_common(self):
|
||||
"""
|
||||
@ -658,7 +658,7 @@ class OptionHandler(_options.OptionHandler):
|
||||
def get_stylesheet_savefile(self):
|
||||
"""Where to save user defined styles for this report."""
|
||||
filename = "%s.xml" % self.module_name
|
||||
return os.path.join(const.HOME_DIR, filename)
|
||||
return os.path.join(HOME_DIR, filename)
|
||||
|
||||
def get_default_stylesheet_name(self):
|
||||
return self.style_name
|
||||
|
@ -35,7 +35,7 @@ from gen.ggettext import sgettext as _
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.plug.utils import gfloat
|
||||
from gen.plug.docgen import PaperSize
|
||||
import const
|
||||
from gen.const import PAPERSIZE
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -85,7 +85,7 @@ class PageSizeParser(handler.ContentHandler):
|
||||
try:
|
||||
parser = make_parser()
|
||||
parser.setContentHandler(PageSizeParser(paper_sizes))
|
||||
the_file = open(const.PAPERSIZE)
|
||||
the_file = open(PAPERSIZE)
|
||||
parser.parse(the_file)
|
||||
the_file.close()
|
||||
paper_sizes.append(PaperSize(_("Custom Size"), -1, -1))
|
||||
|
@ -29,7 +29,7 @@ Provide utilities for printing endnotes in text reports.
|
||||
from gen.plug.docgen import FontStyle, ParagraphStyle, FONT_SANS_SERIF
|
||||
from gen.lib import NoteType, Citation
|
||||
from gen.ggettext import gettext as _
|
||||
from Utils import confidence
|
||||
from gen.utils.string import confidence
|
||||
from gen.datehandler import displayer
|
||||
|
||||
def add_endnote_styles(style_sheet):
|
||||
|
@ -42,7 +42,7 @@ from gen.ggettext import gettext as _
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import gen.datehandler
|
||||
from Utils import media_path_full
|
||||
from gen.utils.file import media_path_full
|
||||
from gen.plug.docgen import IndexMark, INDEX_TYPE_ALP
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
@ -39,8 +39,8 @@ import os
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.plug._pluginreg import make_environment
|
||||
import const
|
||||
import Utils
|
||||
from gen.const import USER_PLUGINS, VERSION_TUPLE
|
||||
from gen.utils.file import get_unicode_path_from_file_chooser
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -259,7 +259,7 @@ def load_addon_file(path, callback=None):
|
||||
if gramps_target_version:
|
||||
vtup = version_str_to_tup(gramps_target_version, 2)
|
||||
# Is it for the right version of gramps?
|
||||
if vtup == const.VERSION_TUPLE[0:2]:
|
||||
if vtup == VERSION_TUPLE[0:2]:
|
||||
# If this version is not installed, or > installed, install it
|
||||
good_gpr.add(gpr_file)
|
||||
if callback:
|
||||
@ -281,13 +281,13 @@ def load_addon_file(path, callback=None):
|
||||
callback(" " + (_("Error: missing gramps_target_version in '%s'...") % gpr_file) + "\n")
|
||||
if len(good_gpr) > 0:
|
||||
# Now, install the ok ones
|
||||
file_obj.extractall(const.USER_PLUGINS)
|
||||
file_obj.extractall(USER_PLUGINS)
|
||||
if callback:
|
||||
callback((_("Installing '%s'...") % path) + "\n")
|
||||
gpr_files = set([os.path.split(os.path.join(const.USER_PLUGINS, name))[0]
|
||||
gpr_files = set([os.path.split(os.path.join(USER_PLUGINS, name))[0]
|
||||
for name in good_gpr])
|
||||
for gpr_file in gpr_files:
|
||||
u_gpr_file = Utils.get_unicode_path_from_file_chooser(gpr_file)
|
||||
u_gpr_file = get_unicode_path_from_file_chooser(gpr_file)
|
||||
if callback:
|
||||
callback(" " + (_("Registered '%s'") % u_gpr_file) + "\n")
|
||||
file_obj.close()
|
||||
|
@ -37,14 +37,14 @@ try:
|
||||
except:
|
||||
use_lock = False
|
||||
|
||||
import const
|
||||
from gen.const import HOME_DIR
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
GRAMPS_FILENAME = os.path.join(const.HOME_DIR,"recent-files-gramps.xml")
|
||||
GRAMPS_FILENAME = os.path.join(HOME_DIR,"recent-files-gramps.xml")
|
||||
MAX_GRAMPS_ITEMS = 10
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
@ -30,8 +30,8 @@ from types import NoneType
|
||||
|
||||
import gen.lib
|
||||
import gen.datehandler
|
||||
import Utils
|
||||
import gen.utils
|
||||
from gen.utils.string import gender as gender_map
|
||||
from gen.utils.db import get_birth_or_fallback, get_death_or_fallback
|
||||
from gen.plug.report.utils import place_name
|
||||
|
||||
from gen.display.name import displayer as name_displayer
|
||||
@ -195,7 +195,7 @@ class SimpleAccess(object):
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
assert(isinstance(person, (gen.lib.Person, NoneType)))
|
||||
if person:
|
||||
return Utils.gender[person.get_gender()]
|
||||
return gender_map[person.get_gender()]
|
||||
return u''
|
||||
|
||||
def __parent(self, person, func):
|
||||
@ -524,8 +524,7 @@ class SimpleAccess(object):
|
||||
"""
|
||||
if type(person) in [str, unicode]:
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
event = gen.utils.get_birth_or_fallback(self.dbase,
|
||||
person, "<i>%s</i>")
|
||||
event = get_birth_or_fallback(self.dbase, person, "<i>%s</i>")
|
||||
if get_event:
|
||||
return event
|
||||
elif event:
|
||||
@ -583,8 +582,7 @@ class SimpleAccess(object):
|
||||
"""
|
||||
if type(person) in [str, unicode]:
|
||||
person = self.dbase.get_person_from_handle(person)
|
||||
event = gen.utils.get_death_or_fallback(self.dbase,
|
||||
person, "<i>%s</i>")
|
||||
event = get_death_or_fallback(self.dbase, person, "<i>%s</i>")
|
||||
if get_event:
|
||||
return event
|
||||
elif event:
|
||||
|
@ -40,7 +40,7 @@ import locale
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.lib import Date
|
||||
from gen.utils import get_birth_or_fallback
|
||||
from gen.utils.db import get_birth_or_fallback
|
||||
from gen.display.name import displayer as _nd
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
@ -4,6 +4,8 @@
|
||||
# but that is not necessarily portable.
|
||||
# If not using GNU make, then list all .py files individually
|
||||
|
||||
SUBDIRS = docgen
|
||||
|
||||
pkgpythondir = $(datadir)/@PACKAGE@/gen/utils
|
||||
|
||||
pkgpython_PYTHON = \
|
||||
@ -11,10 +13,21 @@ pkgpython_PYTHON = \
|
||||
alive.py \
|
||||
callback.py \
|
||||
callman.py \
|
||||
cast.py \
|
||||
config.py \
|
||||
configmanager.py \
|
||||
fallback.py \
|
||||
debug.py \
|
||||
db.py \
|
||||
file.py \
|
||||
id.py \
|
||||
image.py \
|
||||
keyword.py \
|
||||
lds.py \
|
||||
mactrans.py \
|
||||
place.py \
|
||||
referent.py
|
||||
string.py \
|
||||
trans.py \
|
||||
unknown.py
|
||||
|
||||
pkgpyexecdir = @pkgpyexecdir@/gen/utils
|
||||
|
||||
|
@ -24,7 +24,3 @@
|
||||
"""
|
||||
Generic utilities useful for users of the gen package
|
||||
"""
|
||||
|
||||
from callback import Callback
|
||||
from configmanager import ConfigManager
|
||||
from fallback import *
|
||||
|
83
src/gen/utils/cast.py
Normal file
83
src/gen/utils/cast.py
Normal file
@ -0,0 +1,83 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2009 Gary Burton
|
||||
# Copyright (C) 2011 Tim G L Lyons
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Utility functions to cast types
|
||||
"""
|
||||
|
||||
def cast_to_bool(val):
|
||||
if val == str(True):
|
||||
return True
|
||||
return False
|
||||
|
||||
def get_type_converter(val):
|
||||
"""
|
||||
Return function that converts strings into the type of val.
|
||||
"""
|
||||
val_type = type(val)
|
||||
if val_type in (str, unicode):
|
||||
return unicode
|
||||
elif val_type == int:
|
||||
return int
|
||||
elif val_type == float:
|
||||
return float
|
||||
elif val_type == bool:
|
||||
return cast_to_bool
|
||||
elif val_type in (list, tuple):
|
||||
return list
|
||||
|
||||
def type_name(val):
|
||||
"""
|
||||
Return the name the type of val.
|
||||
|
||||
Only numbers and strings are supported.
|
||||
The rest becomes strings (unicode).
|
||||
"""
|
||||
val_type = type(val)
|
||||
if val_type == int:
|
||||
return 'int'
|
||||
elif val_type == float:
|
||||
return 'float'
|
||||
elif val_type == bool:
|
||||
return 'bool'
|
||||
elif val_type in (str, unicode):
|
||||
return 'unicode'
|
||||
return 'unicode'
|
||||
|
||||
def get_type_converter_by_name(val_str):
|
||||
"""
|
||||
Return function that converts strings into the type given by val_str.
|
||||
|
||||
Only numbers and strings are supported.
|
||||
The rest becomes strings (unicode).
|
||||
"""
|
||||
if val_str == 'int':
|
||||
return int
|
||||
elif val_str == 'float':
|
||||
return float
|
||||
elif val_str == 'bool':
|
||||
return cast_to_bool
|
||||
elif val_str in ('str', 'unicode'):
|
||||
return unicode
|
||||
return unicode
|
67
src/gen/utils/config.py
Normal file
67
src/gen/utils/config.py
Normal file
@ -0,0 +1,67 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2009 Gary Burton
|
||||
# Copyright (C) 2011 Tim G L Lyons
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Configuration based utilities
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gen.lib
|
||||
from gen.config import config
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Configuration based utilities
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def get_researcher():
|
||||
"""
|
||||
Return a new database owner with the default values from the config file.
|
||||
"""
|
||||
name = config.get('researcher.researcher-name')
|
||||
address = config.get('researcher.researcher-addr')
|
||||
locality = config.get('researcher.researcher-locality')
|
||||
city = config.get('researcher.researcher-city')
|
||||
state = config.get('researcher.researcher-state')
|
||||
country = config.get('researcher.researcher-country')
|
||||
post_code = config.get('researcher.researcher-postal')
|
||||
phone = config.get('researcher.researcher-phone')
|
||||
email = config.get('researcher.researcher-email')
|
||||
|
||||
owner = gen.lib.Researcher()
|
||||
owner.set_name(name)
|
||||
owner.set_address(address)
|
||||
owner.set_locality(locality)
|
||||
owner.set_city(city)
|
||||
owner.set_state(state)
|
||||
owner.set_country(country)
|
||||
owner.set_postal_code(post_code)
|
||||
owner.set_phone(phone)
|
||||
owner.set_email(email)
|
||||
|
||||
return owner
|
580
src/gen/utils/db.py
Normal file
580
src/gen/utils/db.py
Normal file
@ -0,0 +1,580 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Utilities for getting information from the database.
|
||||
"""
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import logging
|
||||
LOG = logging.getLogger(".gui.utils.db")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gen.lib
|
||||
from gen.display.name import displayer as name_displayer
|
||||
from gen.ggettext import sgettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Fallback functions
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def get_birth_or_fallback(db, person, format=None):
|
||||
"""
|
||||
Get BIRTH event from a person, or fallback to an event around
|
||||
the time of birth.
|
||||
"""
|
||||
birth_ref = person.get_birth_ref()
|
||||
if birth_ref: # regular birth found
|
||||
event = db.get_event_from_handle(birth_ref.ref)
|
||||
if event:
|
||||
return event
|
||||
# now search the event list for fallbacks
|
||||
for event_ref in person.get_primary_event_ref_list():
|
||||
if event_ref:
|
||||
event = db.get_event_from_handle(event_ref.ref)
|
||||
if (event
|
||||
and event.type.is_birth_fallback()
|
||||
and event_ref.role.is_primary()):
|
||||
if format:
|
||||
event.date.format = format
|
||||
return event
|
||||
return None
|
||||
|
||||
def get_death_or_fallback(db, person, format=None):
|
||||
"""
|
||||
Get a DEATH event from a person, or fallback to an
|
||||
event around the time of death.
|
||||
"""
|
||||
death_ref = person.get_death_ref()
|
||||
if death_ref: # regular death found
|
||||
event = db.get_event_from_handle(death_ref.ref)
|
||||
if event:
|
||||
return event
|
||||
# now search the event list for fallbacks
|
||||
for event_ref in person.get_primary_event_ref_list():
|
||||
if event_ref:
|
||||
event = db.get_event_from_handle(event_ref.ref)
|
||||
if (event
|
||||
and event.type.is_death_fallback()
|
||||
and event_ref.role.is_primary()):
|
||||
if format:
|
||||
event.date.format = format
|
||||
return event
|
||||
return None
|
||||
|
||||
def get_event_ref(db, family, event_type):
|
||||
"""
|
||||
Return a reference to a primary family event of the given event type.
|
||||
"""
|
||||
from gen.lib import EventRoleType
|
||||
for event_ref in family.get_event_ref_list():
|
||||
event = db.get_event_from_handle(event_ref.ref)
|
||||
if (event and event.get_type() == event_type and
|
||||
(event_ref.get_role() == EventRoleType.FAMILY or
|
||||
event_ref.get_role() == EventRoleType.PRIMARY)):
|
||||
return event_ref
|
||||
return None
|
||||
|
||||
def get_primary_event_ref_list(db, family):
|
||||
"""
|
||||
Return a reference to the primary events of the family.
|
||||
"""
|
||||
from gen.lib import EventRoleType
|
||||
retval = []
|
||||
for event_ref in family.get_event_ref_list():
|
||||
event = db.get_event_from_handle(event_ref.ref)
|
||||
if (event and
|
||||
(event_ref.get_role() == EventRoleType.FAMILY or
|
||||
event_ref.get_role() == EventRoleType.PRIMARY)):
|
||||
retval.append(event_ref)
|
||||
return retval
|
||||
|
||||
def get_marriage_or_fallback(db, family, format=None):
|
||||
"""
|
||||
Get a MARRIAGE event from a family, or fallback to an
|
||||
alternative event type.
|
||||
"""
|
||||
from gen.lib import EventType, EventRoleType
|
||||
marriage_ref = get_event_ref(db, family, EventType.MARRIAGE)
|
||||
if marriage_ref: # regular marriage found
|
||||
event = db.get_event_from_handle(marriage_ref.ref)
|
||||
if event:
|
||||
return event
|
||||
# now search the event list for fallbacks
|
||||
for event_ref in get_primary_event_ref_list(db, family):
|
||||
if event_ref:
|
||||
event = db.get_event_from_handle(event_ref.ref)
|
||||
if (event
|
||||
and event.type.is_marriage_fallback()
|
||||
and (event_ref.role == EventRoleType.FAMILY or
|
||||
event_ref.role == EventRoleType.PRIMARY)):
|
||||
if format:
|
||||
event.date.format = format
|
||||
return event
|
||||
return None
|
||||
|
||||
def get_divorce_or_fallback(db, family, format=None):
|
||||
"""
|
||||
Get a DIVORCE event from a family, or fallback to an
|
||||
alternative event type.
|
||||
"""
|
||||
from gen.lib import EventType, EventRoleType
|
||||
divorce_ref = get_event_ref(db, family, EventType.DIVORCE)
|
||||
if divorce_ref: # regular marriage found
|
||||
event = db.get_event_from_handle(divorce_ref.ref)
|
||||
if event:
|
||||
return event
|
||||
# now search the event list for fallbacks
|
||||
for event_ref in get_primary_event_ref_list(db, family):
|
||||
if event_ref:
|
||||
event = db.get_event_from_handle(event_ref.ref)
|
||||
if (event
|
||||
and event.type.is_divorce_fallback()
|
||||
and (event_ref.role == EventRoleType.FAMILY or
|
||||
event_ref.role == EventRoleType.PRIMARY)):
|
||||
if format:
|
||||
event.date.format = format
|
||||
return event
|
||||
return None
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Function to return the name of the main participant of an event
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def get_participant_from_event(db, event_handle, all_=False):
|
||||
"""
|
||||
Obtain the first primary or family participant to an event we find in the
|
||||
database. Note that an event can have more than one primary or
|
||||
family participant, only one is returned, adding ellipses if there are
|
||||
more. If the all_ parameter is true a comma-space separated string with
|
||||
the names of all primary participants is returned and no ellipses is used.
|
||||
"""
|
||||
participant = ""
|
||||
ellipses = False
|
||||
result_list = list(db.find_backlink_handles(event_handle,
|
||||
include_classes=['Person', 'Family']))
|
||||
#obtain handles without duplicates
|
||||
people = set([x[1] for x in result_list if x[0] == 'Person'])
|
||||
families = set([x[1] for x in result_list if x[0] == 'Family'])
|
||||
for personhandle in people:
|
||||
person = db.get_person_from_handle(personhandle)
|
||||
if not person:
|
||||
continue
|
||||
for event_ref in person.get_event_ref_list():
|
||||
if event_handle == event_ref.ref and \
|
||||
event_ref.get_role().is_primary():
|
||||
if participant:
|
||||
if all_:
|
||||
participant += ', %s' % name_displayer.display(person)
|
||||
else:
|
||||
ellipses = True
|
||||
else:
|
||||
participant = name_displayer.display(person)
|
||||
break
|
||||
if ellipses:
|
||||
break
|
||||
if ellipses:
|
||||
return _('%s, ...') % participant
|
||||
|
||||
for familyhandle in families:
|
||||
family = db.get_family_from_handle(familyhandle)
|
||||
for event_ref in family.get_event_ref_list():
|
||||
if event_handle == event_ref.ref and \
|
||||
event_ref.get_role().is_family():
|
||||
if participant:
|
||||
if all_:
|
||||
participant += ', %s' % family_name(family, db)
|
||||
else:
|
||||
ellipses = True
|
||||
else:
|
||||
participant = family_name(family, db)
|
||||
break
|
||||
if ellipses:
|
||||
break
|
||||
|
||||
if ellipses:
|
||||
return _('%s, ...') % participant
|
||||
else:
|
||||
return participant
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Function to return a label to display the active object in the status bar
|
||||
# and to describe bookmarked objects.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def navigation_label(db, nav_type, handle):
|
||||
|
||||
label = None
|
||||
obj = None
|
||||
if nav_type == 'Person':
|
||||
obj = db.get_person_from_handle(handle)
|
||||
if obj:
|
||||
label = name_displayer.display(obj)
|
||||
elif nav_type == 'Family':
|
||||
obj = db.get_family_from_handle(handle)
|
||||
if obj:
|
||||
label = family_name(obj, db)
|
||||
elif nav_type == 'Event':
|
||||
obj = db.get_event_from_handle(handle)
|
||||
if obj:
|
||||
try:
|
||||
who = get_participant_from_event(db, handle)
|
||||
except:
|
||||
# get_participants_from_event fails when called during a magic
|
||||
# batch transaction because find_backlink_handles tries to
|
||||
# access the reference_map_referenced_map which doesn't exist
|
||||
# under those circumstances. Since setting the navigation_label
|
||||
# is inessential, just accept this and go on.
|
||||
who = ''
|
||||
desc = obj.get_description()
|
||||
label = obj.get_type()
|
||||
if desc:
|
||||
label = '%s - %s' % (label, desc)
|
||||
if who:
|
||||
label = '%s - %s' % (label, who)
|
||||
elif nav_type == 'Place':
|
||||
obj = db.get_place_from_handle(handle)
|
||||
if obj:
|
||||
label = obj.get_title()
|
||||
elif nav_type == 'Source':
|
||||
obj = db.get_source_from_handle(handle)
|
||||
if obj:
|
||||
label = obj.get_title()
|
||||
elif nav_type == 'Citation':
|
||||
obj = db.get_citation_from_handle(handle)
|
||||
if obj:
|
||||
label = obj.get_page()
|
||||
src = db.get_source_from_handle(obj.get_reference_handle())
|
||||
if src:
|
||||
label = src.get_title() + " " + label
|
||||
elif nav_type == 'Repository':
|
||||
obj = db.get_repository_from_handle(handle)
|
||||
if obj:
|
||||
label = obj.get_name()
|
||||
elif nav_type == 'Media' or nav_type == 'MediaObject':
|
||||
obj = db.get_object_from_handle(handle)
|
||||
if obj:
|
||||
label = obj.get_description()
|
||||
elif nav_type == 'Note':
|
||||
obj = db.get_note_from_handle(handle)
|
||||
if obj:
|
||||
label = obj.get()
|
||||
# When strings are cut, make sure they are unicode
|
||||
#otherwise you may end of with cutting within an utf-8 sequence
|
||||
label = unicode(label)
|
||||
label = " ".join(label.split())
|
||||
if len(label) > 40:
|
||||
label = label[:40] + "..."
|
||||
|
||||
if label and obj:
|
||||
label = '[%s] %s' % (obj.get_gramps_id(), label)
|
||||
|
||||
return (label, obj)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Function to return children's list of a person
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def find_children(db,p):
|
||||
"""
|
||||
Return the list of all children's IDs for a person.
|
||||
"""
|
||||
childlist = []
|
||||
for family_handle in p.get_family_handle_list():
|
||||
family = db.get_family_from_handle(family_handle)
|
||||
for child_ref in family.get_child_ref_list():
|
||||
childlist.append(child_ref.ref)
|
||||
return childlist
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Function to return parent's list of a person
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def find_parents(db,p):
|
||||
"""
|
||||
Return the unique list of all parents' IDs for a person.
|
||||
"""
|
||||
parentlist = []
|
||||
for f in p.get_parent_family_handle_list():
|
||||
family = db.get_family_from_handle(f)
|
||||
father_handle = family.get_father_handle()
|
||||
mother_handle = family.get_mother_handle()
|
||||
if father_handle not in parentlist:
|
||||
parentlist.append(father_handle)
|
||||
if mother_handle not in parentlist:
|
||||
parentlist.append(mother_handle)
|
||||
return parentlist
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Function to return persons, that share the same event.
|
||||
# This for example links witnesses to the tree
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def find_witnessed_people(db,p):
|
||||
people = []
|
||||
for event_ref in p.get_event_ref_list():
|
||||
for l in db.find_backlink_handles( event_ref.ref):
|
||||
if l[0] == 'Person' and l[1] != p.get_handle() and l[1] not in people:
|
||||
people.append(l[1])
|
||||
if l[0] == 'Family':
|
||||
fam = db.get_family_from_handle(l[1])
|
||||
if fam:
|
||||
father_handle = fam.get_father_handle()
|
||||
if father_handle and father_handle != p.get_handle() and father_handle not in people:
|
||||
people.append(father_handle)
|
||||
mother_handle = fam.get_mother_handle()
|
||||
if mother_handle and mother_handle != p.get_handle() and mother_handle not in people:
|
||||
people.append(mother_handle)
|
||||
for f in p.get_family_handle_list():
|
||||
family = db.get_family_from_handle(f)
|
||||
for event_ref in family.get_event_ref_list():
|
||||
for l in db.find_backlink_handles( event_ref.ref):
|
||||
if l[0] == 'Person' and l[1] != p.get_handle() and l[1] not in people:
|
||||
people.append(l[1])
|
||||
for pref in p.get_person_ref_list():
|
||||
if pref.ref != p.get_handle and pref.ref not in people:
|
||||
people.append(pref.ref)
|
||||
return people
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Iterate over ancestors.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def for_each_ancestor(db, start, func, data):
|
||||
"""
|
||||
Recursively iterate (breadth-first) over ancestors of
|
||||
people listed in start.
|
||||
Call func(data, pid) for the Id of each person encountered.
|
||||
Exit and return 1, as soon as func returns true.
|
||||
Return 0 otherwise.
|
||||
"""
|
||||
todo = start
|
||||
done_ids = set()
|
||||
while len(todo):
|
||||
p_handle = todo.pop()
|
||||
p = db.get_person_from_handle(p_handle)
|
||||
# Don't process the same handle twice. This can happen
|
||||
# if there is a cycle in the database, or if the
|
||||
# initial list contains X and some of X's ancestors.
|
||||
if p_handle in done_ids:
|
||||
continue
|
||||
done_ids.add(p_handle)
|
||||
if func(data, p_handle):
|
||||
return 1
|
||||
for fam_handle in p.get_parent_family_handle_list():
|
||||
fam = db.get_family_from_handle(fam_handle)
|
||||
if fam:
|
||||
f_handle = fam.get_father_handle()
|
||||
m_handle = fam.get_mother_handle()
|
||||
if f_handle: todo.append(f_handle)
|
||||
if m_handle: todo.append(m_handle)
|
||||
return 0
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Preset a name with a name of family member
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def preset_name(basepers, name, sibling=False):
|
||||
"""Fill up name with all family common names of basepers.
|
||||
If sibling=True, pa/matronymics are retained.
|
||||
"""
|
||||
surnlist = []
|
||||
primname = basepers.get_primary_name()
|
||||
prim = False
|
||||
for surn in primname.get_surname_list():
|
||||
if (not sibling) and (surn.get_origintype().value in
|
||||
[gen.lib.NameOriginType.PATRONYMIC,
|
||||
gen.lib.NameOriginType.MATRONYMIC]):
|
||||
continue
|
||||
surnlist.append(gen.lib.Surname(source=surn))
|
||||
if surn.primary:
|
||||
prim=True
|
||||
if not surnlist:
|
||||
surnlist = [gen.lib.Surname()]
|
||||
name.set_surname_list(surnlist)
|
||||
if not prim:
|
||||
name.set_primary_surname(0)
|
||||
name.set_family_nick_name(primname.get_family_nick_name())
|
||||
name.set_group_as(primname.get_group_as())
|
||||
name.set_sort_as(primname.get_sort_as())
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Short hand function to return either the person's name, or an empty
|
||||
# string if the person is None
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def family_name(family, db, noname=_("unknown")):
|
||||
"""Builds a name for the family from the parents names"""
|
||||
|
||||
father_handle = family.get_father_handle()
|
||||
mother_handle = family.get_mother_handle()
|
||||
father = db.get_person_from_handle(father_handle)
|
||||
mother = db.get_person_from_handle(mother_handle)
|
||||
if father and mother:
|
||||
fname = name_displayer.display(father)
|
||||
mname = name_displayer.display(mother)
|
||||
name = _("%(father)s and %(mother)s") % {
|
||||
"father" : fname,
|
||||
"mother" : mname}
|
||||
elif father:
|
||||
name = name_displayer.display(father)
|
||||
elif mother:
|
||||
name = name_displayer.display(mother)
|
||||
else:
|
||||
name = noname
|
||||
return name
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Referents functions
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def get_referents(handle, db, primary_objects):
|
||||
""" Find objects that refer to an object.
|
||||
|
||||
This function is the base for other get_<object>_referents functions.
|
||||
|
||||
"""
|
||||
# Use one pass through the reference map to grab all the references
|
||||
object_list = list(db.find_backlink_handles(handle))
|
||||
|
||||
# Then form the object-specific lists
|
||||
the_lists = ()
|
||||
|
||||
for primary in primary_objects:
|
||||
primary_list = [item[1] for item in object_list if item[0] == primary]
|
||||
the_lists = the_lists + (primary_list, )
|
||||
|
||||
return the_lists
|
||||
|
||||
def get_source_referents(source_handle, db):
|
||||
""" Find objects that refer the source.
|
||||
|
||||
This function finds all primary objects that refer (directly or through
|
||||
secondary child-objects) to a given source handle in a given database.
|
||||
|
||||
Only Citations can refer to sources, so that is all we need to check
|
||||
"""
|
||||
_primaries = ('Citation',)
|
||||
|
||||
return (get_referents(source_handle, db, _primaries))
|
||||
|
||||
def get_citation_referents(citation_handle, db):
|
||||
""" Find objects that refer the citation.
|
||||
|
||||
This function finds all primary objects that refer (directly or through
|
||||
secondary child-objects) to a given citation handle in a given database.
|
||||
|
||||
"""
|
||||
_primaries = ('Person', 'Family', 'Event', 'Place',
|
||||
'Source', 'MediaObject', 'Repository')
|
||||
|
||||
return (get_referents(citation_handle, db, _primaries))
|
||||
|
||||
def get_source_and_citation_referents(source_handle, db):
|
||||
"""
|
||||
Find all citations that refer to the sources, and recursively, all objects
|
||||
that refer to the sources.
|
||||
|
||||
This function finds all primary objects that refer (directly or through
|
||||
secondary child-objects) to a given source handle in a given database.
|
||||
|
||||
Objects -> Citations -> Source
|
||||
e.g.
|
||||
Media object M1 -> Citation C1 -> Source S1
|
||||
Media object M2 -> Citation C1 -> Source S1
|
||||
Person object P1 -> Citation C2 -> Source S1
|
||||
|
||||
The returned structure is rather ugly, but provides all the information in
|
||||
a way that is consistent with the other Util functions.
|
||||
(
|
||||
tuple of objects that refer to the source - only first element is present
|
||||
([C1, C2],),
|
||||
list of citations with objects that refer to them
|
||||
[
|
||||
(C1,
|
||||
tuple of reference lists
|
||||
P, F, E, Pl, S, M, R
|
||||
([], [], [], [], [], [M1, M2]. [])
|
||||
)
|
||||
(C2,
|
||||
tuple of reference lists
|
||||
P, F, E, Pl, S, M, R
|
||||
([P1], [], [], [], [], []. [])
|
||||
)
|
||||
]
|
||||
)
|
||||
"""
|
||||
the_lists = get_source_referents(source_handle, db)
|
||||
LOG.debug('source referents %s' % [the_lists])
|
||||
# now, for each citation, get the objects that refer to that citation
|
||||
citation_referents_list = []
|
||||
for citation in the_lists[0]:
|
||||
LOG.debug('citation %s' % citation)
|
||||
refs = get_citation_referents(citation, db)
|
||||
citation_referents_list += [(citation, refs)]
|
||||
LOG.debug('citation_referents_list %s' % [citation_referents_list])
|
||||
|
||||
(citation_list) = the_lists
|
||||
the_lists = (citation_list, citation_referents_list)
|
||||
|
||||
LOG.debug('the_lists %s' % [the_lists])
|
||||
return the_lists
|
||||
|
||||
def get_media_referents(media_handle, db):
|
||||
""" Find objects that refer the media object.
|
||||
|
||||
This function finds all primary objects that refer
|
||||
to a given media handle in a given database.
|
||||
|
||||
"""
|
||||
_primaries = ('Person', 'Family', 'Event', 'Place', 'Source', 'Citation')
|
||||
|
||||
return (get_referents(media_handle, db, _primaries))
|
||||
|
||||
def get_note_referents(note_handle, db):
|
||||
""" Find objects that refer a note object.
|
||||
|
||||
This function finds all primary objects that refer
|
||||
to a given note handle in a given database.
|
||||
|
||||
"""
|
||||
_primaries = ('Person', 'Family', 'Event', 'Place',
|
||||
'Source', 'Citation', 'MediaObject', 'Repository')
|
||||
|
||||
return (get_referents(note_handle, db, _primaries))
|
48
src/gen/utils/debug.py
Normal file
48
src/gen/utils/debug.py
Normal file
@ -0,0 +1,48 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2009 Gary Burton
|
||||
# Copyright (C) 2011 Tim G L Lyons
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Debugging utilities
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Debugging utilities
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def profile(func, *args):
|
||||
import hotshot.stats
|
||||
|
||||
prf = hotshot.Profile('mystats.profile')
|
||||
print "Start"
|
||||
prf.runcall(func, *args)
|
||||
print "Finished"
|
||||
prf.close()
|
||||
print "Loading profile"
|
||||
stats = hotshot.stats.load('mystats.profile')
|
||||
print "done"
|
||||
stats.strip_dirs()
|
||||
stats.sort_stats('time', 'calls')
|
||||
stats.print_stats(100)
|
||||
stats.print_callers(100)
|
@ -32,7 +32,7 @@ import csv
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from docgen import TabbedDoc
|
||||
from TabbedDoc import *
|
||||
|
||||
class CSVTab(TabbedDoc):
|
||||
|
@ -3,19 +3,21 @@
|
||||
# Use GNU make's ':=' syntax for nice wildcard use.
|
||||
# If not using GNU make, then list all .py files individually
|
||||
|
||||
docgendir=$(prefix)/share/gramps/docgen
|
||||
pkgpythondir = $(datadir)/@PACKAGE@/gen/utils/docgen
|
||||
|
||||
docgen_PYTHON = \
|
||||
pkgpython_PYTHON = \
|
||||
__init__.py \
|
||||
CSVTab.py \
|
||||
ODSTab.py \
|
||||
TabbedDoc.py
|
||||
|
||||
pkgpyexecdir = @pkgpyexecdir@/gen/utils/docgen
|
||||
|
||||
# Clean up all the byte-compiled files
|
||||
MOSTLYCLEANFILES = *pyc *pyo
|
||||
|
||||
GRAMPS_PY_MODPATH = "../"
|
||||
GRAMPS_PY_MODPATH = "../../../"
|
||||
|
||||
pycheck:
|
||||
(export PYTHONPATH=$(GRAMPS_PY_MODPATH); \
|
||||
pychecker $(docgen_PYTHON));
|
||||
pychecker $(pkgpython_PYTHON));
|
@ -37,7 +37,7 @@ from gen.ggettext import gettext as _
|
||||
#-------------------------------------------------------------------------
|
||||
from TabbedDoc import *
|
||||
|
||||
import const
|
||||
from gen.const import PROGRAM_NAME, VERSION
|
||||
|
||||
from gen.errors import ReportError
|
||||
|
||||
@ -485,8 +485,8 @@ class ODSTab(TabbedDoc):
|
||||
self.f = open(self.meta_xml,"w")
|
||||
|
||||
self.f.write(_META %
|
||||
{'program': const.PROGRAM_NAME,
|
||||
'version': const.VERSION,
|
||||
{'program': PROGRAM_NAME,
|
||||
'version': VERSION,
|
||||
'name' : self.name,
|
||||
'time' : self.time,
|
||||
}
|
@ -1,144 +0,0 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Functional database interface for getting events, or fallback events.
|
||||
"""
|
||||
|
||||
def get_birth_or_fallback(db, person, format=None):
|
||||
"""
|
||||
Get BIRTH event from a person, or fallback to an event around
|
||||
the time of birth.
|
||||
"""
|
||||
birth_ref = person.get_birth_ref()
|
||||
if birth_ref: # regular birth found
|
||||
event = db.get_event_from_handle(birth_ref.ref)
|
||||
if event:
|
||||
return event
|
||||
# now search the event list for fallbacks
|
||||
for event_ref in person.get_primary_event_ref_list():
|
||||
if event_ref:
|
||||
event = db.get_event_from_handle(event_ref.ref)
|
||||
if (event
|
||||
and event.type.is_birth_fallback()
|
||||
and event_ref.role.is_primary()):
|
||||
if format:
|
||||
event.date.format = format
|
||||
return event
|
||||
return None
|
||||
|
||||
def get_death_or_fallback(db, person, format=None):
|
||||
"""
|
||||
Get a DEATH event from a person, or fallback to an
|
||||
event around the time of death.
|
||||
"""
|
||||
death_ref = person.get_death_ref()
|
||||
if death_ref: # regular death found
|
||||
event = db.get_event_from_handle(death_ref.ref)
|
||||
if event:
|
||||
return event
|
||||
# now search the event list for fallbacks
|
||||
for event_ref in person.get_primary_event_ref_list():
|
||||
if event_ref:
|
||||
event = db.get_event_from_handle(event_ref.ref)
|
||||
if (event
|
||||
and event.type.is_death_fallback()
|
||||
and event_ref.role.is_primary()):
|
||||
if format:
|
||||
event.date.format = format
|
||||
return event
|
||||
return None
|
||||
|
||||
def get_event_ref(db, family, event_type):
|
||||
"""
|
||||
Return a reference to a primary family event of the given event type.
|
||||
"""
|
||||
from gen.lib import EventRoleType
|
||||
for event_ref in family.get_event_ref_list():
|
||||
event = db.get_event_from_handle(event_ref.ref)
|
||||
if (event and event.get_type() == event_type and
|
||||
(event_ref.get_role() == EventRoleType.FAMILY or
|
||||
event_ref.get_role() == EventRoleType.PRIMARY)):
|
||||
return event_ref
|
||||
return None
|
||||
|
||||
def get_primary_event_ref_list(db, family):
|
||||
"""
|
||||
Return a reference to the primary events of the family.
|
||||
"""
|
||||
from gen.lib import EventRoleType
|
||||
retval = []
|
||||
for event_ref in family.get_event_ref_list():
|
||||
event = db.get_event_from_handle(event_ref.ref)
|
||||
if (event and
|
||||
(event_ref.get_role() == EventRoleType.FAMILY or
|
||||
event_ref.get_role() == EventRoleType.PRIMARY)):
|
||||
retval.append(event_ref)
|
||||
return retval
|
||||
|
||||
def get_marriage_or_fallback(db, family, format=None):
|
||||
"""
|
||||
Get a MARRIAGE event from a family, or fallback to an
|
||||
alternative event type.
|
||||
"""
|
||||
from gen.lib import EventType, EventRoleType
|
||||
marriage_ref = get_event_ref(db, family, EventType.MARRIAGE)
|
||||
if marriage_ref: # regular marriage found
|
||||
event = db.get_event_from_handle(marriage_ref.ref)
|
||||
if event:
|
||||
return event
|
||||
# now search the event list for fallbacks
|
||||
for event_ref in get_primary_event_ref_list(db, family):
|
||||
if event_ref:
|
||||
event = db.get_event_from_handle(event_ref.ref)
|
||||
if (event
|
||||
and event.type.is_marriage_fallback()
|
||||
and (event_ref.role == EventRoleType.FAMILY or
|
||||
event_ref.role == EventRoleType.PRIMARY)):
|
||||
if format:
|
||||
event.date.format = format
|
||||
return event
|
||||
return None
|
||||
|
||||
def get_divorce_or_fallback(db, family, format=None):
|
||||
"""
|
||||
Get a DIVORCE event from a family, or fallback to an
|
||||
alternative event type.
|
||||
"""
|
||||
from gen.lib import EventType, EventRoleType
|
||||
divorce_ref = get_event_ref(db, family, EventType.DIVORCE)
|
||||
if divorce_ref: # regular marriage found
|
||||
event = db.get_event_from_handle(divorce_ref.ref)
|
||||
if event:
|
||||
return event
|
||||
# now search the event list for fallbacks
|
||||
for event_ref in get_primary_event_ref_list(db, family):
|
||||
if event_ref:
|
||||
event = db.get_event_from_handle(event_ref.ref)
|
||||
if (event
|
||||
and event.type.is_divorce_fallback()
|
||||
and (event_ref.role == EventRoleType.FAMILY or
|
||||
event_ref.role == EventRoleType.PRIMARY)):
|
||||
if format:
|
||||
event.date.format = format
|
||||
return event
|
||||
return None
|
302
src/gen/utils/file.py
Normal file
302
src/gen/utils/file.py
Normal file
@ -0,0 +1,302 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2009 Gary Burton
|
||||
# Copyright (C) 2011 Tim G L Lyons
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
File and folder related utility functions
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import os
|
||||
import sys
|
||||
import locale
|
||||
import shutil
|
||||
import logging
|
||||
LOG = logging.getLogger(".gen.utils.file")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.constfunc import win, mac
|
||||
from gen.const import TEMP_DIR, USER_HOME
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
_NEW_NAME_PATTERN = '%s%sUntitled_%d.%s'
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Functions
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def find_file( filename):
|
||||
# try the filename we got
|
||||
try:
|
||||
fname = filename
|
||||
if os.path.isfile( filename):
|
||||
return( filename)
|
||||
except:
|
||||
pass
|
||||
|
||||
# Build list of alternate encodings
|
||||
encodings = set()
|
||||
#Darwin returns "mac roman" for preferredencoding, but since it
|
||||
#returns "UTF-8" for filesystemencoding, and that's first, this
|
||||
#works.
|
||||
for enc in [sys.getfilesystemencoding, locale.getpreferredencoding]:
|
||||
try:
|
||||
encodings.add(enc)
|
||||
except:
|
||||
pass
|
||||
encodings.add('UTF-8')
|
||||
encodings.add('ISO-8859-1')
|
||||
|
||||
for enc in encodings:
|
||||
try:
|
||||
fname = filename.encode(enc)
|
||||
if os.path.isfile( fname):
|
||||
return fname
|
||||
except:
|
||||
pass
|
||||
|
||||
# not found
|
||||
return ''
|
||||
|
||||
def find_folder( filename):
|
||||
# try the filename we got
|
||||
try:
|
||||
fname = filename
|
||||
if os.path.isdir( filename):
|
||||
return( filename)
|
||||
except:
|
||||
pass
|
||||
|
||||
# Build list of alternate encodings
|
||||
try:
|
||||
encodings = [sys.getfilesystemencoding(),
|
||||
locale.getpreferredencoding(),
|
||||
'UTF-8', 'ISO-8859-1']
|
||||
except:
|
||||
encodings = [sys.getfilesystemencoding(), 'UTF-8', 'ISO-8859-1']
|
||||
encodings = list(set(encodings))
|
||||
for enc in encodings:
|
||||
try:
|
||||
fname = filename.encode(enc)
|
||||
if os.path.isdir( fname):
|
||||
return fname
|
||||
except:
|
||||
pass
|
||||
|
||||
# not found
|
||||
return ''
|
||||
|
||||
def get_unicode_path_from_file_chooser(path):
|
||||
"""
|
||||
Return the Unicode version of a path string.
|
||||
|
||||
:type path: str
|
||||
:param path: The path to be converted to Unicode
|
||||
:rtype: unicode
|
||||
:returns: The Unicode version of path.
|
||||
"""
|
||||
# make only unicode of path of type 'str'
|
||||
if not (isinstance(path, str)):
|
||||
return path
|
||||
|
||||
if win():
|
||||
# in windows filechooser returns officially utf-8, not filesystemencoding
|
||||
try:
|
||||
return unicode(path)
|
||||
except:
|
||||
LOG.warn("Problem encountered converting string: %s." % path)
|
||||
return unicode(path, sys.getfilesystemencoding(), errors='replace')
|
||||
else:
|
||||
try:
|
||||
return unicode(path, sys.getfilesystemencoding())
|
||||
except:
|
||||
LOG.warn("Problem encountered converting string: %s." % path)
|
||||
return unicode(path, sys.getfilesystemencoding(), errors='replace')
|
||||
|
||||
def get_unicode_path_from_env_var(path):
|
||||
"""
|
||||
Return the Unicode version of a path string.
|
||||
|
||||
:type path: str
|
||||
:param path: The path to be converted to Unicode
|
||||
:rtype: unicode
|
||||
:returns: The Unicode version of path.
|
||||
"""
|
||||
# make only unicode of path of type 'str'
|
||||
if not (isinstance(path, str)):
|
||||
return path
|
||||
|
||||
if win():
|
||||
# In Windows path/filename returned from a environment variable is in filesystemencoding
|
||||
try:
|
||||
new_path = unicode(path, sys.getfilesystemencoding())
|
||||
return new_path
|
||||
except:
|
||||
LOG.warn("Problem encountered converting string: %s." % path)
|
||||
return unicode(path, sys.getfilesystemencoding(), errors='replace')
|
||||
else:
|
||||
try:
|
||||
return unicode(path)
|
||||
except:
|
||||
LOG.warn("Problem encountered converting string: %s." % path)
|
||||
return unicode(path, sys.getfilesystemencoding(), errors='replace')
|
||||
|
||||
def get_new_filename(ext, folder='~/'):
|
||||
ix = 1
|
||||
while os.path.isfile(os.path.expanduser(_NEW_NAME_PATTERN %
|
||||
(folder, os.path.sep, ix, ext))):
|
||||
ix = ix + 1
|
||||
return os.path.expanduser(_NEW_NAME_PATTERN % (folder, os.path.sep, ix, ext))
|
||||
|
||||
def get_empty_tempdir(dirname):
|
||||
""" Return path to TEMP_DIR/dirname, a guaranteed empty directory
|
||||
|
||||
makes intervening directories if required
|
||||
fails if _file_ by that name already exists,
|
||||
or for inadequate permissions to delete dir/files or create dir(s)
|
||||
|
||||
"""
|
||||
dirpath = os.path.join(TEMP_DIR,dirname)
|
||||
if os.path.isdir(dirpath):
|
||||
shutil.rmtree(dirpath)
|
||||
os.makedirs(dirpath)
|
||||
dirpath = get_unicode_path_from_env_var(dirpath)
|
||||
return dirpath
|
||||
|
||||
def rm_tempdir(path):
|
||||
"""Remove a tempdir created with get_empty_tempdir"""
|
||||
if path.startswith(TEMP_DIR) and os.path.isdir(path):
|
||||
shutil.rmtree(path)
|
||||
|
||||
def relative_path(original, base):
|
||||
"""
|
||||
Calculate the relative path from base to original, with base a directory,
|
||||
and original an absolute path
|
||||
On problems, original is returned unchanged
|
||||
"""
|
||||
if not os.path.isdir(base):
|
||||
return original
|
||||
#original and base must be absolute paths
|
||||
if not os.path.isabs(base):
|
||||
return original
|
||||
if not os.path.isabs(original):
|
||||
return original
|
||||
original = os.path.normpath(original)
|
||||
base = os.path.normpath(base)
|
||||
|
||||
# If the db_dir and obj_dir are on different drives (win only)
|
||||
# then there cannot be a relative path. Return original obj_path
|
||||
(base_drive, base) = os.path.splitdrive(base)
|
||||
(orig_drive, orig_name) = os.path.splitdrive(original)
|
||||
if base_drive.upper() != orig_drive.upper():
|
||||
return original
|
||||
|
||||
# Starting from the filepath root, work out how much of the filepath is
|
||||
# shared by base and target.
|
||||
base_list = (base).split(os.sep)
|
||||
target_list = (orig_name).split(os.sep)
|
||||
# make sure '/home/person' and 'c:/home/person' both give
|
||||
# list ['home', 'person']
|
||||
base_list = filter(None, base_list)
|
||||
target_list = filter(None, target_list)
|
||||
i = -1
|
||||
for i in range(min(len(base_list), len(target_list))):
|
||||
if base_list[i] <> target_list[i]: break
|
||||
else:
|
||||
#if break did not happen we are here at end, and add 1.
|
||||
i += 1
|
||||
rel_list = [os.pardir] * (len(base_list)-i) + target_list[i:]
|
||||
return os.path.join(*rel_list)
|
||||
|
||||
def media_path(db):
|
||||
"""
|
||||
Given a database, return the mediapath to use as basedir for media
|
||||
"""
|
||||
mpath = db.get_mediapath()
|
||||
if mpath is None:
|
||||
#use home dir
|
||||
mpath = USER_HOME
|
||||
return mpath
|
||||
|
||||
def media_path_full(db, filename):
|
||||
"""
|
||||
Given a database and a filename of a media, return the media filename
|
||||
is full form, eg 'graves/tomb.png' becomes '/home/me/genea/graves/tomb.png
|
||||
"""
|
||||
if os.path.isabs(filename):
|
||||
return filename
|
||||
mpath = media_path(db)
|
||||
return os.path.join(mpath, filename)
|
||||
|
||||
def search_for(name):
|
||||
if name.startswith( '"' ):
|
||||
name = name.split('"')[1]
|
||||
else:
|
||||
name = name.split()[0]
|
||||
if win():
|
||||
for i in os.environ['PATH'].split(';'):
|
||||
fname = os.path.join(i, name)
|
||||
if os.access(fname, os.X_OK) and not os.path.isdir(fname):
|
||||
return 1
|
||||
if os.access(name, os.X_OK) and not os.path.isdir(name):
|
||||
return 1
|
||||
else:
|
||||
for i in os.environ['PATH'].split(':'):
|
||||
fname = os.path.join(i, name)
|
||||
if os.access(fname, os.X_OK) and not os.path.isdir(fname):
|
||||
return 1
|
||||
return 0
|
||||
|
||||
def fix_encoding(value, errors='strict'):
|
||||
# The errors argument specifies the response when the input string can't be
|
||||
# converted according to the encoding's rules. Legal values for this
|
||||
# argument are 'strict' (raise a UnicodeDecodeError exception), 'replace'
|
||||
# (add U+FFFD, 'REPLACEMENT CHARACTER'), or 'ignore' (just leave the
|
||||
# character out of the Unicode result).
|
||||
if not isinstance(value, unicode):
|
||||
try:
|
||||
return unicode(value)
|
||||
except:
|
||||
try:
|
||||
if mac():
|
||||
codeset = locale.getlocale()[1]
|
||||
else:
|
||||
codeset = locale.getpreferredencoding()
|
||||
except:
|
||||
codeset = "UTF-8"
|
||||
return unicode(value, codeset, errors)
|
||||
else:
|
||||
return value
|
63
src/gen/utils/id.py
Normal file
63
src/gen/utils/id.py
Normal file
@ -0,0 +1,63 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2009 Gary Burton
|
||||
# Copyright (C) 2011 Tim G L Lyons
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Utilities to create unique identifiers
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import sys
|
||||
import random
|
||||
import time
|
||||
import uuid
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.const import GRAMPS_UUID
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# create_id
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
rand = random.Random(time.time())
|
||||
|
||||
def create_id():
|
||||
return "%08x%08x" % (int(time.time()*10000),
|
||||
rand.randint(0, sys.maxint))
|
||||
|
||||
def create_uid(self, handle=None):
|
||||
if handle:
|
||||
uid = uuid.uuid5(GRAMPS_UUID, handle)
|
||||
else:
|
||||
uid = uuid.uuid4()
|
||||
return uid.hex.upper()
|
||||
|
@ -44,7 +44,7 @@ import tempfile
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Utils
|
||||
from gen.utils.file import get_unicode_path_from_env_va
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -257,7 +257,7 @@ def resize_to_jpeg_buffer(source, size, crop=None):
|
||||
|
||||
scaled = img.scale_simple(int(size[0]), int(size[1]), GdkPixbuf.InterpType.BILINEAR)
|
||||
os.close(filed)
|
||||
dest = Utils.get_unicode_path_from_env_var(dest)
|
||||
dest = get_unicode_path_from_env_var(dest)
|
||||
scaled.save(dest, 'jpeg')
|
||||
ofile = open(dest, mode='rb')
|
||||
data = ofile.read()
|
103
src/gen/utils/keyword.py
Normal file
103
src/gen/utils/keyword.py
Normal file
@ -0,0 +1,103 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2009 Gary Burton
|
||||
# Copyright (C) 2011 Tim G L Lyons
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Keyword translation interface
|
||||
"""
|
||||
|
||||
# keyword, code, translated standard, translated upper
|
||||
# in gen.display.name.py we find:
|
||||
# 't' : title = title
|
||||
# 'f' : given = given (first names)
|
||||
# 'l' : surname = full surname (lastname)
|
||||
# 'c' : call = callname
|
||||
# 'x' : common = nick name if existing, otherwise first first name (common name)
|
||||
# 'i' : initials = initials of the first names
|
||||
# 'm' : primary = primary surname (main)
|
||||
# '0m': primary[pre]= prefix primary surname (main)
|
||||
# '1m': primary[sur]= surname primary surname (main)
|
||||
# '2m': primary[con]= connector primary surname (main)
|
||||
# 'y' : patronymic = pa/matronymic surname (father/mother) - assumed unique
|
||||
# '0y': patronymic[pre] = prefix "
|
||||
# '1y': patronymic[sur] = surname "
|
||||
# '2y': patronymic[con] = connector "
|
||||
# 'o' : notpatronymic = surnames without pa/matronymic and primary
|
||||
# 'r' : rest = non primary surnames
|
||||
# 'p' : prefix = list of all prefixes
|
||||
# 'q' : rawsurnames = surnames without prefixes and connectors
|
||||
# 's' : suffix = suffix
|
||||
# 'n' : nickname = nick name
|
||||
# 'g' : familynick = family nick name
|
||||
|
||||
KEYWORDS = [("title", "t", _("Person|Title"), _("Person|TITLE")),
|
||||
("given", "f", _("Given"), _("GIVEN")),
|
||||
("surname", "l", _("Surname"), _("SURNAME")),
|
||||
("call", "c", _("Name|Call"), _("Name|CALL")),
|
||||
("common", "x", _("Name|Common"), _("Name|COMMON")),
|
||||
("initials", "i", _("Initials"), _("INITIALS")),
|
||||
("suffix", "s", _("Suffix"), _("SUFFIX")),
|
||||
("primary", "m", _("Name|Primary"), _("PRIMARY")),
|
||||
("primary[pre]", "0m", _("Primary[pre]"), _("PRIMARY[PRE]")),
|
||||
("primary[sur]", "1m", _("Primary[sur]"), _("PRIMARY[SUR]")),
|
||||
("primary[con]", "2m", _("Primary[con]"), _("PRIMARY[CON]")),
|
||||
("patronymic", "y", _("Patronymic"), _("PATRONYMIC")),
|
||||
("patronymic[pre]", "0y", _("Patronymic[pre]"), _("PATRONYMIC[PRE]")),
|
||||
("patronymic[sur]", "1y", _("Patronymic[sur]"), _("PATRONYMIC[SUR]")),
|
||||
("patronymic[con]", "2y", _("Patronymic[con]"), _("PATRONYMIC[CON]")),
|
||||
("rawsurnames", "q", _("Rawsurnames"), _("RAWSURNAMES")),
|
||||
("notpatronymic", "o", _("Notpatronymic"),_("NOTPATRONYMIC")),
|
||||
("prefix", "p", _("Prefix"), _("PREFIX")),
|
||||
("nickname", "n", _("Nickname"), _("NICKNAME")),
|
||||
("familynick", "g", _("Familynick"), _("FAMILYNICK")),
|
||||
]
|
||||
KEY_TO_TRANS = {}
|
||||
TRANS_TO_KEY = {}
|
||||
for (key, code, standard, upper) in KEYWORDS:
|
||||
KEY_TO_TRANS[key] = standard
|
||||
KEY_TO_TRANS[key.upper()] = upper
|
||||
KEY_TO_TRANS["%" + ("%s" % code)] = standard
|
||||
KEY_TO_TRANS["%" + ("%s" % code.upper())] = upper
|
||||
TRANS_TO_KEY[standard.lower()] = key
|
||||
TRANS_TO_KEY[standard] = key
|
||||
TRANS_TO_KEY[upper] = key.upper()
|
||||
|
||||
def get_translation_from_keyword(keyword):
|
||||
""" Return the translation of keyword """
|
||||
return KEY_TO_TRANS.get(keyword, keyword)
|
||||
|
||||
def get_keyword_from_translation(word):
|
||||
""" Return the keyword of translation """
|
||||
return TRANS_TO_KEY.get(word, word)
|
||||
|
||||
def get_keywords():
|
||||
""" Get all keywords, longest to shortest """
|
||||
keys = KEY_TO_TRANS.keys()
|
||||
keys.sort(lambda a,b: -cmp(len(a), len(b)))
|
||||
return keys
|
||||
|
||||
def get_translations():
|
||||
""" Get all translations, longest to shortest """
|
||||
trans = TRANS_TO_KEY.keys()
|
||||
trans.sort(lambda a,b: -cmp(len(a), len(b)))
|
||||
return trans
|
@ -24,7 +24,7 @@
|
||||
Parses the lds.xml file to build the temple/code maps
|
||||
"""
|
||||
|
||||
import const
|
||||
from gen.const import DATA_DIR
|
||||
import os
|
||||
import logging
|
||||
|
||||
@ -48,7 +48,7 @@ class LdsTemples(object):
|
||||
self.__current_temple = ""
|
||||
self.__tlist = []
|
||||
|
||||
lds_filename = os.path.join(const.DATA_DIR, "lds.xml")
|
||||
lds_filename = os.path.join(DATA_DIR, "lds.xml")
|
||||
|
||||
try:
|
||||
xml_file = open(os.path.expanduser(lds_filename))
|
@ -1,161 +0,0 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2009 Gary Burton
|
||||
# Copyright (C) 2011 Tim G L Lyons
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Functions to return referents of primary objects.
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import logging
|
||||
LOG = logging.getLogger(".gui.utils.referents")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Referents functions
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
def get_referents(handle, db, primary_objects):
|
||||
""" Find objects that refer to an object.
|
||||
|
||||
This function is the base for other get_<object>_referents functions.
|
||||
|
||||
"""
|
||||
# Use one pass through the reference map to grab all the references
|
||||
object_list = list(db.find_backlink_handles(handle))
|
||||
|
||||
# Then form the object-specific lists
|
||||
the_lists = ()
|
||||
|
||||
for primary in primary_objects:
|
||||
primary_list = [item[1] for item in object_list if item[0] == primary]
|
||||
the_lists = the_lists + (primary_list, )
|
||||
|
||||
return the_lists
|
||||
|
||||
def get_source_referents(source_handle, db):
|
||||
""" Find objects that refer the source.
|
||||
|
||||
This function finds all primary objects that refer (directly or through
|
||||
secondary child-objects) to a given source handle in a given database.
|
||||
|
||||
Only Citations can refer to sources, so that is all we need to check
|
||||
"""
|
||||
_primaries = ('Citation',)
|
||||
|
||||
return (get_referents(source_handle, db, _primaries))
|
||||
|
||||
def get_citation_referents(citation_handle, db):
|
||||
""" Find objects that refer the citation.
|
||||
|
||||
This function finds all primary objects that refer (directly or through
|
||||
secondary child-objects) to a given citation handle in a given database.
|
||||
|
||||
"""
|
||||
_primaries = ('Person', 'Family', 'Event', 'Place',
|
||||
'Source', 'MediaObject', 'Repository')
|
||||
|
||||
return (get_referents(citation_handle, db, _primaries))
|
||||
|
||||
def get_source_and_citation_referents(source_handle, db):
|
||||
"""
|
||||
Find all citations that refer to the sources, and recursively, all objects
|
||||
that refer to the sources.
|
||||
|
||||
This function finds all primary objects that refer (directly or through
|
||||
secondary child-objects) to a given source handle in a given database.
|
||||
|
||||
Objects -> Citations -> Source
|
||||
e.g.
|
||||
Media object M1 -> Citation C1 -> Source S1
|
||||
Media object M2 -> Citation C1 -> Source S1
|
||||
Person object P1 -> Citation C2 -> Source S1
|
||||
|
||||
The returned structure is rather ugly, but provides all the information in
|
||||
a way that is consistent with the other Util functions.
|
||||
(
|
||||
tuple of objects that refer to the source - only first element is present
|
||||
([C1, C2],),
|
||||
list of citations with objects that refer to them
|
||||
[
|
||||
(C1,
|
||||
tuple of reference lists
|
||||
P, F, E, Pl, S, M, R
|
||||
([], [], [], [], [], [M1, M2]. [])
|
||||
)
|
||||
(C2,
|
||||
tuple of reference lists
|
||||
P, F, E, Pl, S, M, R
|
||||
([P1], [], [], [], [], []. [])
|
||||
)
|
||||
]
|
||||
)
|
||||
#47738: DEBUG: citationtreeview.py: line 428: source referents [(['bfe59e90dbb555d0d87'],)]
|
||||
#47743: DEBUG: citationtreeview.py: line 432: citation bfe59e90dbb555d0d87
|
||||
#47825: DEBUG: citationtreeview.py: line 435: citation_referents_list [[('bfe59e90dbb555d0d87', ([], [], ['ba77932bf0b2d59eccb'], [], [], [], []))]]
|
||||
#47827: DEBUG: citationtreeview.py: line 440: the_lists [((['bfe59e90dbb555d0d87'],), [('bfe59e90dbb555d0d87', ([], [], ['ba77932bf0b2d59eccb'], [], [], [], []))])]
|
||||
|
||||
"""
|
||||
the_lists = get_source_referents(source_handle, db)
|
||||
LOG.debug('source referents %s' % [the_lists])
|
||||
# now, for each citation, get the objects that refer to that citation
|
||||
citation_referents_list = []
|
||||
for citation in the_lists[0]:
|
||||
LOG.debug('citation %s' % citation)
|
||||
refs = get_citation_referents(citation, db)
|
||||
citation_referents_list += [(citation, refs)]
|
||||
LOG.debug('citation_referents_list %s' % [citation_referents_list])
|
||||
|
||||
(citation_list) = the_lists
|
||||
the_lists = (citation_list, citation_referents_list)
|
||||
|
||||
LOG.debug('the_lists %s' % [the_lists])
|
||||
return the_lists
|
||||
|
||||
def get_media_referents(media_handle, db):
|
||||
""" Find objects that refer the media object.
|
||||
|
||||
This function finds all primary objects that refer
|
||||
to a given media handle in a given database.
|
||||
|
||||
"""
|
||||
_primaries = ('Person', 'Family', 'Event', 'Place', 'Source', 'Citation')
|
||||
|
||||
return (get_referents(media_handle, db, _primaries))
|
||||
|
||||
def get_note_referents(note_handle, db):
|
||||
""" Find objects that refer a note object.
|
||||
|
||||
This function finds all primary objects that refer
|
||||
to a given note handle in a given database.
|
||||
|
||||
"""
|
||||
_primaries = ('Person', 'Family', 'Event', 'Place',
|
||||
'Source', 'Citation', 'MediaObject', 'Repository')
|
||||
|
||||
return (get_referents(note_handle, db, _primaries))
|
73
src/gen/utils/string.py
Normal file
73
src/gen/utils/string.py
Normal file
@ -0,0 +1,73 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2009 Gary Burton
|
||||
# Copyright (C) 2011 Tim G L Lyons
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
String mappings for constants
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gen.lib
|
||||
from gen.ggettext import sgettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Integer to String mappings for constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
gender = {
|
||||
gen.lib.Person.MALE : _("male"),
|
||||
gen.lib.Person.FEMALE : _("female"),
|
||||
gen.lib.Person.UNKNOWN : _("gender|unknown"),
|
||||
}
|
||||
|
||||
def format_gender( type):
|
||||
return gender.get(type[0], _("Invalid"))
|
||||
|
||||
confidence = {
|
||||
gen.lib.Citation.CONF_VERY_HIGH : _("Very High"),
|
||||
gen.lib.Citation.CONF_HIGH : _("High"),
|
||||
gen.lib.Citation.CONF_NORMAL : _("Normal"),
|
||||
gen.lib.Citation.CONF_LOW : _("Low"),
|
||||
gen.lib.Citation.CONF_VERY_LOW : _("Very Low"),
|
||||
}
|
||||
|
||||
family_rel_descriptions = {
|
||||
gen.lib.FamilyRelType.MARRIED : _("A legal or common-law relationship "
|
||||
"between a husband and wife"),
|
||||
gen.lib.FamilyRelType.UNMARRIED : _("No legal or common-law relationship "
|
||||
"between man and woman"),
|
||||
gen.lib.FamilyRelType.CIVIL_UNION : _("An established relationship between "
|
||||
"members of the same sex"),
|
||||
gen.lib.FamilyRelType.UNKNOWN : _("Unknown relationship between a man "
|
||||
"and woman"),
|
||||
gen.lib.FamilyRelType.CUSTOM : _("An unspecified relationship between "
|
||||
"a man and woman"),
|
||||
}
|
||||
|
||||
data_recover_msg = _('The data can only be recovered by Undo operation '
|
||||
'or by quitting with abandoning changes.')
|
@ -26,7 +26,7 @@ import unittest
|
||||
from test import test_util as tu
|
||||
tu.path_append_parent()
|
||||
|
||||
from gen.utils import Callback
|
||||
from gen.utils.callback import Callback
|
||||
|
||||
try:
|
||||
log
|
||||
|
@ -40,7 +40,7 @@ import locale
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import const
|
||||
from gen.const import PREFIXDIR, ROOT_DIR
|
||||
from gen.constfunc import mac
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -49,24 +49,24 @@ from gen.constfunc import mac
|
||||
#-------------------------------------------------------------------------
|
||||
if "GRAMPSI18N" in os.environ:
|
||||
LOCALEDIR = os.environ["GRAMPSI18N"]
|
||||
elif os.path.exists( os.path.join(const.ROOT_DIR, "lang") ):
|
||||
LOCALEDIR = os.path.join(const.ROOT_DIR, "lang")
|
||||
elif os.path.exists(os.path.join(const.PREFIXDIR, "share/locale")):
|
||||
LOCALEDIR = os.path.join(const.PREFIXDIR, "share/locale")
|
||||
elif os.path.exists( os.path.join(ROOT_DIR, "lang") ):
|
||||
LOCALEDIR = os.path.join(ROOT_DIR, "lang")
|
||||
elif os.path.exists(os.path.join(PREFIXDIR, "share/locale")):
|
||||
LOCALEDIR = os.path.join(PREFIXDIR, "share/locale")
|
||||
else:
|
||||
lang = os.environ.get('LANG', 'en')
|
||||
if lang and lang[:2] == 'en':
|
||||
pass # No need to display warning, we're in English
|
||||
else:
|
||||
print 'Locale dir does not exist at ' + os.path.join(const.PREFIXDIR, "share/locale")
|
||||
print 'Locale dir does not exist at ' + os.path.join(PREFIXDIR, "share/locale")
|
||||
print 'Running ./configure --prefix=YourPrefixDir might fix the problem'
|
||||
LOCALEDIR = None
|
||||
|
||||
LOCALEDOMAIN = 'gramps'
|
||||
|
||||
if mac():
|
||||
import MacTransUtils
|
||||
MacTransUtils.mac_setup_localization(LOCALEDIR, LOCALEDOMAIN)
|
||||
import mactrans
|
||||
mactrans.mac_setup_localization(LOCALEDIR, LOCALEDOMAIN)
|
||||
else:
|
||||
lang = ' '
|
||||
try:
|
||||
@ -102,7 +102,7 @@ def setup_gettext():
|
||||
except ValueError:
|
||||
print 'Failed to bind text domain, Gtk.Builder() has no translation'
|
||||
|
||||
#following installs _ as a python function, we avoid this as TransUtils is
|
||||
#following installs _ as a python function, we avoid this as this module is
|
||||
#used sometimes:
|
||||
#gettext.install(LOCALEDOMAIN, LOCALEDIR, unicode=1)
|
||||
|
||||
@ -263,7 +263,7 @@ def get_addon_translator(filename=None, domain="addon", languages=None):
|
||||
# Check if path is of type str. Do import and conversion if so.
|
||||
# The import cannot be done at the top as that will conflict with the translation system.
|
||||
if type(path) == str:
|
||||
from Utils import get_unicode_path_from_env_var
|
||||
from gen.utils.file import get_unicode_path_from_env_var
|
||||
path = get_unicode_path_from_env_var(path)
|
||||
if languages:
|
||||
addon_translator = gettext.translation(domain, os.path.join(path,"locale"),
|
194
src/gen/utils/unknown.py
Normal file
194
src/gen/utils/unknown.py
Normal file
@ -0,0 +1,194 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2009 Gary Burton
|
||||
# Copyright (C) 2011 Tim G L Lyons
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Make an 'Unknown' primary object
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import time
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gen.lib
|
||||
from gen.utils.id import create_id
|
||||
from gen.const import IMAGE_DIR
|
||||
from gen.ggettext import sgettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# make_unknown
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def make_unknown(class_arg, explanation, class_func, commit_func, transaction,
|
||||
**argv):
|
||||
"""
|
||||
Make a primary object and set some property so that it qualifies as
|
||||
"Unknown".
|
||||
|
||||
Some object types need extra parameters:
|
||||
Family: db, Event: type (optional),
|
||||
Citation: methods to create/store source.
|
||||
|
||||
Some theoretical underpinning
|
||||
This function exploits the fact that all import methods basically do the
|
||||
same thing: Create an object of the right type, fill it with some
|
||||
attributes, store it in the database. This function does the same, so
|
||||
the observation is why not use the creation and storage methods that the
|
||||
import routines use themselves, that makes nice reuse of code. To do this
|
||||
formally correct we would need to specify a interface (in the OOP sence)
|
||||
which the import methods would need to implement. For now, that is deemed
|
||||
too restrictive and here we just slip through because of the similarity in
|
||||
code of both GEDCOM and XML import methods.
|
||||
|
||||
:param class_arg: The argument the class_func needs, typically a kind of id.
|
||||
:type class_arg: unspecified
|
||||
:param explanation: Handle of a note that explains the origin of primary obj
|
||||
:type explanation: str
|
||||
:param class_func: Method to create primary object.
|
||||
:type class_func: method
|
||||
:param commit_func: Method to store primary object in db.
|
||||
:type commit_func: method
|
||||
:param transactino: Database transaction handle
|
||||
:type transaction: str
|
||||
:param argv: Possible additional parameters
|
||||
:type param: unspecified
|
||||
:returns: List of newly created objects.
|
||||
:rtype: list
|
||||
"""
|
||||
retval = []
|
||||
obj = class_func(class_arg)
|
||||
if isinstance(obj, gen.lib.Person):
|
||||
surname = gen.lib.Surname()
|
||||
surname.set_surname('Unknown')
|
||||
name = gen.lib.Name()
|
||||
name.add_surname(surname)
|
||||
name.set_type(gen.lib.NameType.UNKNOWN)
|
||||
obj.set_primary_name(name)
|
||||
elif isinstance(obj, gen.lib.Family):
|
||||
obj.set_relationship(gen.lib.FamilyRelType.UNKNOWN)
|
||||
handle = obj.handle
|
||||
if getattr(argv['db'].transaction, 'no_magic', False):
|
||||
backlinks = argv['db'].find_backlink_handles(
|
||||
handle, [gen.lib.Person.__name__])
|
||||
for dummy, person_handle in backlinks:
|
||||
person = argv['db'].get_person_from_handle(person_handle)
|
||||
add_personref_to_family(obj, person)
|
||||
else:
|
||||
for person in argv['db'].iter_people():
|
||||
if person._has_handle_reference('Family', handle):
|
||||
add_personref_to_family(obj, person)
|
||||
elif isinstance(obj, gen.lib.Event):
|
||||
if 'type' in argv:
|
||||
obj.set_type(argv['type'])
|
||||
else:
|
||||
obj.set_type(gen.lib.EventType.UNKNOWN)
|
||||
elif isinstance(obj, gen.lib.Place):
|
||||
obj.set_title(_('Unknown'))
|
||||
elif isinstance(obj, gen.lib.Source):
|
||||
obj.set_title(_('Unknown'))
|
||||
elif isinstance(obj, gen.lib.Citation):
|
||||
#TODO create a new source for every citation?
|
||||
obj2 = argv['source_class_func'](argv['source_class_arg'])
|
||||
obj2.set_title(_('Unknown'))
|
||||
obj2.add_note(explanation)
|
||||
argv['source_commit_func'](obj2, transaction, time.time())
|
||||
retval.append(obj2)
|
||||
obj.set_reference_handle(obj2.handle)
|
||||
elif isinstance(obj, gen.lib.Repository):
|
||||
obj.set_name(_('Unknown'))
|
||||
obj.set_type(gen.lib.RepositoryType.UNKNOWN)
|
||||
elif isinstance(obj, gen.lib.MediaObject):
|
||||
obj.set_path(os.path.join(IMAGE_DIR, "image-missing.png"))
|
||||
obj.set_mime_type('image/png')
|
||||
obj.set_description(_('Unknown'))
|
||||
elif isinstance(obj, gen.lib.Note):
|
||||
obj.set_type(gen.lib.NoteType.UNKNOWN);
|
||||
text = _('Unknown, created to replace a missing note object.')
|
||||
link_start = text.index(',') + 2
|
||||
link_end = len(text) - 1
|
||||
tag = gen.lib.StyledTextTag(gen.lib.StyledTextTagType.LINK,
|
||||
'gramps://Note/handle/%s' % explanation,
|
||||
[(link_start, link_end)])
|
||||
obj.set_styledtext(gen.lib.StyledText(text, [tag]))
|
||||
elif isinstance(obj, gen.lib.Tag):
|
||||
if not hasattr(make_unknown, 'count'):
|
||||
make_unknown.count = 1 #primitive static variable
|
||||
obj.set_name(_("Unknown, was missing %(time)s (%(count)d)") % {
|
||||
'time': time.strftime('%x %X', time.localtime()),
|
||||
'count': make_unknown.count})
|
||||
make_unknown.count += 1
|
||||
else:
|
||||
raise TypeError("Object if of unsupported type")
|
||||
|
||||
if hasattr(obj, 'add_note'):
|
||||
obj.add_note(explanation)
|
||||
commit_func(obj, transaction, time.time())
|
||||
retval.append(obj)
|
||||
return retval
|
||||
|
||||
def create_explanation_note(dbase):
|
||||
"""
|
||||
When creating objects to fill missing primary objects in imported files,
|
||||
those objects of type "Unknown" need a explanatory note. This funcion
|
||||
provides such a note for import methods.
|
||||
"""
|
||||
note = gen.lib.Note( _('Objects referenced by this note '
|
||||
'were missing in a file imported on %s.') %
|
||||
time.strftime('%x %X', time.localtime()))
|
||||
note.set_handle(create_id())
|
||||
note.set_gramps_id(dbase.find_next_note_gramps_id())
|
||||
# Use defaults for privacy, format and type.
|
||||
return note
|
||||
|
||||
def add_personref_to_family(family, person):
|
||||
"""
|
||||
Given a family and person, set the parent/child references in the family,
|
||||
that match the person.
|
||||
"""
|
||||
handle = family.handle
|
||||
person_handle = person.handle
|
||||
if handle in person.get_family_handle_list():
|
||||
if ((person.get_gender() == gen.lib.Person.FEMALE) and
|
||||
(family.get_mother_handle() is None)):
|
||||
family.set_mother_handle(person_handle)
|
||||
else:
|
||||
# This includes cases of gen.lib.Person.UNKNOWN
|
||||
if family.get_father_handle() is None:
|
||||
family.set_father_handle(person_handle)
|
||||
else:
|
||||
family.set_mother_handle(person_handle)
|
||||
if handle in person.get_parent_family_handle_list():
|
||||
childref = gen.lib.ChildRef()
|
||||
childref.set_reference_handle(person_handle)
|
||||
childref.set_mother_relation(gen.lib.ChildRefType.UNKNOWN)
|
||||
childref.set_father_relation(gen.lib.ChildRefType.UNKNOWN)
|
||||
family.add_child_ref(childref)
|
@ -31,7 +31,7 @@
|
||||
#-------------------------------------------------------------------------
|
||||
import sys
|
||||
import os
|
||||
import const
|
||||
from gen.const import APP_GRAMPS, USER_DIRLIST
|
||||
import signal
|
||||
import gettext
|
||||
_ = gettext.gettext
|
||||
@ -48,7 +48,7 @@ from subprocess import Popen, PIPE
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.mime import mime_type_is_defined
|
||||
import TransUtils
|
||||
from gen.utils.trans import LOCALEDOMAIN, LOCALEDIR, setup_windows_gettext
|
||||
from gen.constfunc import win
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -59,8 +59,8 @@ from gen.constfunc import win
|
||||
#the order in which bindtextdomain on gettext and on locale is called
|
||||
#appears important, so we refrain from doing first all gettext.
|
||||
#
|
||||
#TransUtils.setup_gettext()
|
||||
gettext.bindtextdomain(TransUtils.LOCALEDOMAIN, TransUtils.LOCALEDIR)
|
||||
#setup_gettext()
|
||||
gettext.bindtextdomain(LOCALEDOMAIN, LOCALEDIR)
|
||||
try:
|
||||
locale.setlocale(locale.LC_ALL,'')
|
||||
except:
|
||||
@ -80,8 +80,8 @@ except:
|
||||
# if that doesn't break Gramps under Windows
|
||||
# raise
|
||||
|
||||
gettext.textdomain(TransUtils.LOCALEDOMAIN)
|
||||
gettext.install(TransUtils.LOCALEDOMAIN, localedir=None, unicode=1) #None is sys default locale
|
||||
gettext.textdomain(LOCALEDOMAIN)
|
||||
gettext.install(LOCALEDOMAIN, localedir=None, unicode=1) #None is sys default locale
|
||||
|
||||
if hasattr(os, "uname"):
|
||||
operating_system = os.uname()[0]
|
||||
@ -89,18 +89,18 @@ else:
|
||||
operating_system = sys.platform
|
||||
|
||||
if win(): # Windows
|
||||
TransUtils.setup_windows_gettext()
|
||||
setup_windows_gettext()
|
||||
elif operating_system == 'FreeBSD':
|
||||
try:
|
||||
gettext.bindtextdomain(TransUtils.LOCALEDOMAIN, TransUtils.LOCALEDIR)
|
||||
gettext.bindtextdomain(LOCALEDOMAIN, LOCALEDIR)
|
||||
except locale.Error:
|
||||
print 'No translation in some Gtk.Builder strings, '
|
||||
elif operating_system == 'OpenBSD':
|
||||
pass
|
||||
else: # normal case
|
||||
try:
|
||||
locale.bindtextdomain(TransUtils.LOCALEDOMAIN, TransUtils.LOCALEDIR)
|
||||
#locale.textdomain(TransUtils.LOCALEDOMAIN)
|
||||
locale.bindtextdomain(LOCALEDOMAIN, LOCALEDIR)
|
||||
#locale.textdomain(LOCALEDOMAIN)
|
||||
except locale.Error:
|
||||
print 'No translation in some Gtk.Builder strings, '
|
||||
|
||||
@ -166,7 +166,7 @@ def setup_logging():
|
||||
|
||||
def build_user_paths():
|
||||
""" check/make user-dirs on each Gramps session"""
|
||||
for path in const.USER_DIRLIST:
|
||||
for path in USER_DIRLIST:
|
||||
if os.path.islink(path):
|
||||
pass # ok
|
||||
elif not os.path.isdir(path):
|
||||
@ -245,8 +245,8 @@ def show_settings():
|
||||
bsddb_db_str = 'not found'
|
||||
|
||||
try:
|
||||
import const
|
||||
gramps_str = const.VERSION
|
||||
from gen.const import VERSION
|
||||
gramps_str = VERSION
|
||||
except:
|
||||
gramps_str = 'not found'
|
||||
|
||||
@ -336,13 +336,13 @@ def run():
|
||||
LOG.error("Error reading configuration.", exc_info=True)
|
||||
return [(_("Error reading configuration"), str(msg))]
|
||||
|
||||
if not mime_type_is_defined(const.APP_GRAMPS):
|
||||
if not mime_type_is_defined(APP_GRAMPS):
|
||||
error += [(_("Configuration error:"),
|
||||
_("A definition for the MIME-type %s could not "
|
||||
"be found \n\n Possibly the installation of Gramps "
|
||||
"was incomplete. Make sure the MIME-types "
|
||||
"of Gramps are properly installed.")
|
||||
% const.APP_GRAMPS)]
|
||||
% APP_GRAMPS)]
|
||||
|
||||
#we start with parsing the arguments to determine if we have a cli or a
|
||||
# gui session
|
||||
|
@ -53,7 +53,9 @@ from gi.repository import GdkPixbuf
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import const
|
||||
from gen.const import (AUTHORS, AUTHORS_FILE, COMMENTS, COPYRIGHT_MSG,
|
||||
DOCUMENTERS, LICENSE_FILE, PROGRAM_NAME, SPLASH,
|
||||
TRANSLATORS, URL_HOMEPAGE, VERSION)
|
||||
from gui.display import display_url
|
||||
from gen.config import config
|
||||
|
||||
@ -83,9 +85,9 @@ class GrampsAboutDialog(Gtk.AboutDialog):
|
||||
self.set_transient_for(parent)
|
||||
self.set_modal(True)
|
||||
|
||||
self.set_name(const.PROGRAM_NAME)
|
||||
self.set_version(const.VERSION)
|
||||
self.set_copyright(const.COPYRIGHT_MSG)
|
||||
self.set_name(PROGRAM_NAME)
|
||||
self.set_version(VERSION)
|
||||
self.set_copyright(COPYRIGHT_MSG)
|
||||
self.set_artists([
|
||||
_("Much of Gramps' artwork is either from\n"
|
||||
"the Tango Project or derived from the Tango\n"
|
||||
@ -95,25 +97,25 @@ class GrampsAboutDialog(Gtk.AboutDialog):
|
||||
])
|
||||
|
||||
try:
|
||||
ifile = open(const.LICENSE_FILE, "r")
|
||||
ifile = open(LICENSE_FILE, "r")
|
||||
self.set_license(ifile.read().replace('\x0c', ''))
|
||||
ifile.close()
|
||||
except IOError:
|
||||
self.set_license("License file is missing")
|
||||
|
||||
self.set_comments(_(const.COMMENTS) + self.get_versions())
|
||||
self.set_comments(_(COMMENTS) + self.get_versions())
|
||||
self.set_website_label(_('Gramps Homepage'))
|
||||
self.set_website(const.URL_HOMEPAGE)
|
||||
self.set_website(URL_HOMEPAGE)
|
||||
|
||||
self.set_authors(_get_authors())
|
||||
|
||||
# Only set translation credits if they are translated
|
||||
trans_credits = _(const.TRANSLATORS)
|
||||
if trans_credits != const.TRANSLATORS:
|
||||
trans_credits = _(TRANSLATORS)
|
||||
if trans_credits != TRANSLATORS:
|
||||
self.set_translator_credits(trans_credits)
|
||||
|
||||
self.set_documenters(const.DOCUMENTERS)
|
||||
self.set_logo(GdkPixbuf.Pixbuf.new_from_file(const.SPLASH))
|
||||
|
||||
self.set_documenters(DOCUMENTERS)
|
||||
self.set_logo(GdkPixbuf.Pixbuf.new_from_file(SPLASH))
|
||||
|
||||
def get_versions(self):
|
||||
"""
|
||||
@ -133,7 +135,7 @@ class GrampsAboutDialog(Gtk.AboutDialog):
|
||||
"LANG: %s\n" +
|
||||
"OS: %s\n" +
|
||||
"Distribution: %s")
|
||||
% (ellipses(str(const.VERSION)),
|
||||
% (ellipses(str(VERSION)),
|
||||
ellipses(str(sys.version).replace('\n','')),
|
||||
ellipses(str(bsddb.__version__) + " " + str(bsddb.db.version())),
|
||||
ellipses(os.environ.get('LANG','')),
|
||||
@ -222,7 +224,7 @@ def _get_authors():
|
||||
parser = make_parser()
|
||||
parser.setContentHandler(AuthorParser(authors, contributors))
|
||||
|
||||
authors_file = open(const.AUTHORS_FILE)
|
||||
authors_file = open(AUTHORS_FILE)
|
||||
parser.parse(authors_file)
|
||||
authors_file.close()
|
||||
|
||||
@ -230,7 +232,7 @@ def _get_authors():
|
||||
[CONTRIB_HEADER] + contributors)
|
||||
|
||||
except (IOError, OSError, SAXParseException):
|
||||
authors_text = const.AUTHORS
|
||||
authors_text = AUTHORS
|
||||
|
||||
return authors_text
|
||||
|
||||
|
@ -45,14 +45,14 @@ from gi.repository import GdkPixbuf
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import const
|
||||
from gen.const import IMAGE_DIR, URL_MANUAL_PAGE
|
||||
from gen.config import config
|
||||
import gen.lib
|
||||
import gen.datehandler
|
||||
from gui.display import display_help
|
||||
from gui.managedwindow import ManagedWindow
|
||||
from gen.ggettext import sgettext as _
|
||||
from TransUtils import trans_objclass
|
||||
from gen.utils.trans import trans_objclass
|
||||
from gen.constfunc import mac
|
||||
from gui.glade import Glade
|
||||
from gui.ddtargets import DdTargets
|
||||
@ -64,7 +64,7 @@ import gui.utils
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
WIKI_HELP_PAGE = '%s_-_Navigation' % const.URL_MANUAL_PAGE
|
||||
WIKI_HELP_PAGE = '%s_-_Navigation' % URL_MANUAL_PAGE
|
||||
WIKI_HELP_SEC = _('manual|Using_the_Clipboard')
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -73,7 +73,7 @@ WIKI_HELP_SEC = _('manual|Using_the_Clipboard')
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
_stock_image = os.path.join(const.IMAGE_DIR,'stock_link.png')
|
||||
_stock_image = os.path.join(IMAGE_DIR,'stock_link.png')
|
||||
LINK_PIC = GdkPixbuf.Pixbuf.new_from_file(_stock_image)
|
||||
ICONS = {}
|
||||
for (name, file) in (
|
||||
@ -94,7 +94,7 @@ for (name, file) in (
|
||||
('text', 'gramps-font.png'),
|
||||
('url', 'gramps-geo.png'),
|
||||
):
|
||||
_image = os.path.join(const.IMAGE_DIR, '16x16', file)
|
||||
_image = os.path.join(IMAGE_DIR, '16x16', file)
|
||||
ICONS[name] = GdkPixbuf.Pixbuf.new_from_file(_image)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
@ -48,7 +48,6 @@ from gi.repository import GObject
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import const
|
||||
from gui.managedwindow import ManagedWindow
|
||||
from gui.glade import Glade
|
||||
|
||||
|
@ -47,12 +47,14 @@ from gi.repository import GObject
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.config import config
|
||||
import const
|
||||
from gen.const import HOME_DIR
|
||||
import gen.datehandler
|
||||
from gen.display.name import displayer as _nd
|
||||
from gen.display.name import NameDisplayError
|
||||
import Utils
|
||||
from gen.utils.file import get_unicode_path_from_file_chooser
|
||||
from gen.utils.alive import update_constants
|
||||
from gen.utils.keyword import (get_keywords, get_translation_from_keyword,
|
||||
get_translations, get_keyword_from_translation)
|
||||
import gen.lib
|
||||
from gen.lib import Name, Surname, NameOriginType
|
||||
from gui.managedwindow import ManagedWindow
|
||||
@ -527,9 +529,9 @@ class GrampsPreferences(ConfigureDialog):
|
||||
the_index = 0
|
||||
for num, name, fmt_str, act in _nd.get_name_format():
|
||||
translation = fmt_str
|
||||
for key in Utils.get_keywords():
|
||||
for key in get_keywords():
|
||||
if key in translation:
|
||||
translation = translation.replace(key, Utils.get_translation_from_keyword(key))
|
||||
translation = translation.replace(key, get_translation_from_keyword(key))
|
||||
self.examplename.set_display_as(num)
|
||||
name_format_model.append(
|
||||
row=[num, translation, fmt_str, _nd.display_name(self.examplename)])
|
||||
@ -661,9 +663,9 @@ class GrampsPreferences(ConfigureDialog):
|
||||
new_text[-1] == '"'):
|
||||
pass
|
||||
else:
|
||||
for key in Utils.get_translations():
|
||||
for key in get_translations():
|
||||
if key in pattern:
|
||||
pattern = pattern.replace(key, Utils.get_keyword_from_translation(key))
|
||||
pattern = pattern.replace(key, get_keyword_from_translation(key))
|
||||
# now build up a proper translation:
|
||||
translation = pattern
|
||||
if (len(new_text) > 2 and
|
||||
@ -671,9 +673,9 @@ class GrampsPreferences(ConfigureDialog):
|
||||
new_text[-1] == '"'):
|
||||
pass
|
||||
else:
|
||||
for key in Utils.get_keywords():
|
||||
for key in get_keywords():
|
||||
if key in translation:
|
||||
translation = translation.replace(key, Utils.get_translation_from_keyword(key))
|
||||
translation = translation.replace(key, get_translation_from_keyword(key))
|
||||
num, name, fmt = self.selected_fmt[COL_NUM:COL_EXPL]
|
||||
node = self.fmt_model.get_iter(path)
|
||||
oldname = self.fmt_model.get_value(node, COL_NAME)
|
||||
@ -1189,12 +1191,12 @@ class GrampsPreferences(ConfigureDialog):
|
||||
Gtk.ResponseType.OK))
|
||||
mpath = self.dbstate.db.get_mediapath()
|
||||
if not mpath:
|
||||
mpath = const.HOME_DIR
|
||||
mpath = HOME_DIR
|
||||
f.set_current_folder(os.path.dirname(mpath))
|
||||
|
||||
status = f.run()
|
||||
if status == Gtk.ResponseType.OK:
|
||||
val = Utils.get_unicode_path_from_file_chooser(f.get_filename())
|
||||
val = get_unicode_path_from_file_chooser(f.get_filename())
|
||||
if val:
|
||||
self.path_entry.set_text(val)
|
||||
f.destroy()
|
||||
|
@ -57,7 +57,7 @@ from gi.repository import GObject
|
||||
from cli.grampscli import CLIDbLoader
|
||||
from gen.config import config
|
||||
import gen.db
|
||||
import Utils
|
||||
from gen.utils.file import get_unicode_path_from_file_chooser
|
||||
from gui.pluginmanager import GuiPluginManager
|
||||
from gui.dialog import (DBErrorDialog, ErrorDialog, QuestionDialog2,
|
||||
WarningDialog)
|
||||
@ -162,7 +162,7 @@ class DbLoader(CLIDbLoader):
|
||||
if response == Gtk.ResponseType.CANCEL:
|
||||
break
|
||||
elif response == Gtk.ResponseType.OK:
|
||||
filename = Utils.get_unicode_path_from_file_chooser(import_dialog.get_filename())
|
||||
filename = get_unicode_path_from_file_chooser(import_dialog.get_filename())
|
||||
if self.check_errors(filename):
|
||||
# displays errors if any
|
||||
continue
|
||||
|
@ -80,7 +80,7 @@ from gen.recentfiles import rename_filename, remove_filename
|
||||
from gui.glade import Glade
|
||||
from gen.db.backup import restore
|
||||
from gen.db.exceptions import DbException
|
||||
from Utils import get_unicode_path_from_env_var
|
||||
from gen.utils.file import get_unicode_path_from_env_var
|
||||
|
||||
|
||||
_RETURN = Gdk.keyval_from_name("Return")
|
||||
|
@ -41,13 +41,13 @@ from gi.repository import GdkPixbuf
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import const
|
||||
from gen.const import ICON
|
||||
from gen.config import config
|
||||
from gui.glade import Glade
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
try:
|
||||
ICON = GdkPixbuf.Pixbuf.new_from_file(const.ICON)
|
||||
ICON = GdkPixbuf.Pixbuf.new_from_file(ICON)
|
||||
except:
|
||||
ICON = None
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
# $Id$
|
||||
|
||||
import const
|
||||
from gen.const import URL_MANUAL_PAGE, URL_WIKISTRING
|
||||
from gen.constfunc import is_quartz
|
||||
from gen.config import config
|
||||
import locale
|
||||
@ -68,9 +68,9 @@ def display_help(webpage='', section=''):
|
||||
Display the specified webpage and section from the Gramps 3.0 wiki.
|
||||
"""
|
||||
if not webpage:
|
||||
link = const.URL_WIKISTRING + const.URL_MANUAL_PAGE + EXTENSION
|
||||
link = URL_WIKISTRING + URL_MANUAL_PAGE + EXTENSION
|
||||
else:
|
||||
link = const.URL_WIKISTRING + webpage + EXTENSION
|
||||
link = URL_WIKISTRING + webpage + EXTENSION
|
||||
if section:
|
||||
link = link + '#' + section
|
||||
display_url(link)
|
||||
|
@ -54,7 +54,7 @@ from gi.repository import GObject
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gen.utils
|
||||
from gen.utils.callback import Callback
|
||||
from gui.utils import process_pending_events
|
||||
from gui.views.navigationview import NavigationView
|
||||
from gen.config import config
|
||||
@ -62,7 +62,7 @@ from gen.display.name import displayer as name_displayer
|
||||
from gui.managedwindow import GrampsWindowManager
|
||||
from gen.relationship import get_relationship_calculator
|
||||
from gui.glade import Glade
|
||||
from Utils import navigation_label
|
||||
from gen.utils.db import navigation_label
|
||||
|
||||
DISABLED = -1
|
||||
|
||||
@ -71,7 +71,7 @@ DISABLED = -1
|
||||
# History manager
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class History(gen.utils.Callback):
|
||||
class History(Callback):
|
||||
""" History manages the objects of a certain type that have been viewed,
|
||||
with ability to go back, or forward.
|
||||
When accessing an object, it should be pushed on the History.
|
||||
@ -83,7 +83,7 @@ class History(gen.utils.Callback):
|
||||
}
|
||||
|
||||
def __init__(self, dbstate, nav_type):
|
||||
gen.utils.Callback.__init__(self)
|
||||
Callback.__init__(self)
|
||||
self.dbstate = dbstate
|
||||
self.nav_type = nav_type
|
||||
self.clear()
|
||||
@ -352,7 +352,7 @@ class WarnHandler(RotateHandler):
|
||||
top.run()
|
||||
top.destroy()
|
||||
|
||||
class DisplayState(gen.utils.Callback):
|
||||
class DisplayState(Callback):
|
||||
|
||||
__signals__ = {
|
||||
'filters-changed' : (str, ),
|
||||
@ -381,7 +381,7 @@ class DisplayState(gen.utils.Callback):
|
||||
self.uimanager = uimanager
|
||||
self.progress_monitor = progress_monitor
|
||||
self.window = window
|
||||
gen.utils.Callback.__init__(self)
|
||||
Callback.__init__(self)
|
||||
self.status = status
|
||||
self.status_id = status.get_context_id('GRAMPS')
|
||||
self.progress = progress
|
||||
|
@ -50,9 +50,10 @@ from gi.repository import GdkPixbuf
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import const
|
||||
from gen.const import ICON, THUMBSCALE, USER_HOME
|
||||
from gen.config import config
|
||||
import Utils
|
||||
from gen.utils.file import (media_path_full, media_path, relative_path,
|
||||
find_file, get_unicode_path_from_file_chooser)
|
||||
import gen.mime
|
||||
from gui.thumbnails import find_mime_type_pixbuf
|
||||
from gui.display import display_help
|
||||
@ -98,10 +99,10 @@ class AddMediaObject(ManagedWindow):
|
||||
self.image = self.glade.get_object("image")
|
||||
self.file_text = self.glade.get_object("fname")
|
||||
if not(self.last_directory and os.path.isdir(self.last_directory)):
|
||||
self.last_directory = const.USER_HOME
|
||||
self.last_directory = USER_HOME
|
||||
#if existing path, use dir of path
|
||||
if not self.obj.get_path() == "":
|
||||
fullname = Utils.media_path_full(self.dbase, self.obj.get_path())
|
||||
fullname = media_path_full(self.dbase, self.obj.get_path())
|
||||
dir = os.path.dirname(fullname)
|
||||
if os.path.isdir(dir):
|
||||
self.last_directory = dir
|
||||
@ -149,17 +150,17 @@ class AddMediaObject(ManagedWindow):
|
||||
ErrorDialog(msgstr, msgstr2)
|
||||
return
|
||||
|
||||
filename = Utils.get_unicode_path_from_file_chooser(self.file_text.get_filename())
|
||||
filename = get_unicode_path_from_file_chooser(self.file_text.get_filename())
|
||||
full_file = filename
|
||||
|
||||
if self.relpath.get_active():
|
||||
pname = unicode(Utils.media_path(self.dbase))
|
||||
pname = unicode(media_path(self.dbase))
|
||||
if not os.path.exists(pname):
|
||||
msgstr = _("Cannot import %s")
|
||||
msgstr2 = _("Directory specified in preferences: Base path for relative media paths: %s does not exist. Change preferences or do not use relative path when importing")
|
||||
ErrorDialog(msgstr % filename, msgstr2 % pname)
|
||||
return
|
||||
filename = Utils.relative_path(filename, pname)
|
||||
filename = relative_path(filename, pname)
|
||||
|
||||
|
||||
mtype = gen.mime.get_type(full_file)
|
||||
@ -186,7 +187,7 @@ class AddMediaObject(ManagedWindow):
|
||||
fname = self.file_text.get_filename()
|
||||
if not fname:
|
||||
return
|
||||
filename = Utils.get_unicode_path_from_file_chooser(fname)
|
||||
filename = get_unicode_path_from_file_chooser(fname)
|
||||
basename = os.path.basename(filename)
|
||||
(root, ext) = os.path.splitext(basename)
|
||||
old_title = unicode(self.description.get_text())
|
||||
@ -195,11 +196,11 @@ class AddMediaObject(ManagedWindow):
|
||||
self.description.set_text(root)
|
||||
self.temp_name = root
|
||||
|
||||
filename = Utils.find_file( filename)
|
||||
filename = find_file( filename)
|
||||
if filename:
|
||||
mtype = gen.mime.get_type(filename)
|
||||
if mtype and mtype.startswith("image"):
|
||||
image = scale_image(filename, const.THUMBSCALE)
|
||||
image = scale_image(filename, THUMBSCALE)
|
||||
else:
|
||||
image = find_mime_type_pixbuf(mtype)
|
||||
self.image.set_from_pixbuf(image)
|
||||
@ -233,5 +234,4 @@ def scale_image(path, size):
|
||||
GdkPixbuf.InterpType.BILINEAR)
|
||||
except:
|
||||
WarningDialog(title_msg, detail_msg)
|
||||
return GdkPixbuf.Pixbuf.new_from_file(const.ICON)
|
||||
|
||||
return GdkPixbuf.Pixbuf.new_from_file(ICON)
|
||||
|
@ -37,7 +37,7 @@ from gen.ggettext import gettext as _
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.display.name import displayer as name_displayer
|
||||
import Utils
|
||||
from gen.utils.db import family_name, get_participant_from_event
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -84,7 +84,7 @@ class BackRefModel(Gtk.ListStore):
|
||||
continue
|
||||
gid = p.gramps_id
|
||||
handle = p.handle
|
||||
name = Utils.family_name(p, self.db)
|
||||
name = family_name(p, self.db)
|
||||
elif dtype == 'Source':
|
||||
p = self.db.get_source_from_handle(ref[1])
|
||||
if not p:
|
||||
@ -111,7 +111,7 @@ class BackRefModel(Gtk.ListStore):
|
||||
'part2': name}
|
||||
else:
|
||||
name = str(p.get_type())
|
||||
part = Utils.get_participant_from_event(self.db, ref[1])
|
||||
part = get_participant_from_event(self.db, ref[1])
|
||||
if part :
|
||||
name = self.dispstr % {'part1': name,
|
||||
'part2': part}
|
||||
|
@ -35,9 +35,9 @@ import cgi
|
||||
#-------------------------------------------------------------------------
|
||||
import gen.datehandler
|
||||
from gen.display.name import displayer as name_displayer
|
||||
import Utils
|
||||
from gen.utils.string import gender as gender_map
|
||||
import gen.lib
|
||||
from gen.utils import get_birth_or_fallback, get_death_or_fallback
|
||||
from gen.utils.db import get_birth_or_fallback, get_death_or_fallback
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -57,7 +57,7 @@ class ChildModel(Gtk.ListStore):
|
||||
index + 1,
|
||||
child.get_gramps_id(),
|
||||
name_displayer.display(child),
|
||||
Utils.gender[child.get_gender()],
|
||||
gender_map[child.get_gender()],
|
||||
str(child_ref.get_father_relation()),
|
||||
str(child_ref.get_mother_relation()),
|
||||
self.column_birth_day(child),
|
||||
|
@ -54,14 +54,15 @@ from gui.dbguielement import DbGUIElement
|
||||
from gui.selectors import SelectorFactory
|
||||
import gen.lib
|
||||
from gen.db import DbTxn
|
||||
import Utils
|
||||
from gen.utils.file import (media_path_full, media_path, relative_path,
|
||||
fix_encoding)
|
||||
from gui.thumbnails import get_thumbnail_image
|
||||
from gen.errors import WindowActiveError
|
||||
import gen.mime
|
||||
from gui.ddtargets import DdTargets
|
||||
from buttontab import ButtonTab
|
||||
from gen.constfunc import win
|
||||
import const
|
||||
from gen.const import THUMBSCALE
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
@ -133,7 +134,7 @@ class GalleryTab(ButtonTab, DbGUIElement):
|
||||
menu = Gtk.Menu()
|
||||
|
||||
ref_obj = self.dbstate.db.get_object_from_handle(obj.ref)
|
||||
media_path = Utils.media_path_full(self.dbstate.db, ref_obj.get_path())
|
||||
media_path = media_path_full(self.dbstate.db, ref_obj.get_path())
|
||||
if media_path:
|
||||
item = Gtk.ImageMenuItem(_('View'))
|
||||
img = Gtk.Image()
|
||||
@ -193,11 +194,11 @@ class GalleryTab(ButtonTab, DbGUIElement):
|
||||
|
||||
# build the icon view
|
||||
self.iconlist.set_pixbuf_column(0)
|
||||
self.iconlist.set_item_width(int(const.THUMBSCALE) + padding * 2)
|
||||
self.iconlist.set_item_width(int(THUMBSCALE) + padding * 2)
|
||||
# set custom text cell renderer for better control
|
||||
text_renderer = Gtk.CellRendererText()
|
||||
text_renderer.set_property('wrap-mode', Pango.WrapMode.WORD_CHAR)
|
||||
text_renderer.set_property('wrap-width', const.THUMBSCALE)
|
||||
text_renderer.set_property('wrap-width', THUMBSCALE)
|
||||
text_renderer.set_property('alignment', Pango.Alignment.CENTER)
|
||||
self.iconlist.pack_end(text_renderer, True)
|
||||
self.iconlist.add_attribute(text_renderer, "text", 1)
|
||||
@ -253,7 +254,7 @@ class GalleryTab(ButtonTab, DbGUIElement):
|
||||
_('Non existing media found in the Gallery'))
|
||||
else :
|
||||
pixbuf = get_thumbnail_image(
|
||||
Utils.media_path_full(self.dbstate.db,
|
||||
media_path_full(self.dbstate.db,
|
||||
obj.get_path()),
|
||||
obj.get_mime_type(),
|
||||
ref.get_rectangle())
|
||||
@ -494,19 +495,19 @@ class GalleryTab(ButtonTab, DbGUIElement):
|
||||
else:
|
||||
files = sel_data.get_uris()
|
||||
for file in files:
|
||||
d = Utils.fix_encoding(file.replace('\0',' ').strip())
|
||||
d = fix_encoding(file.replace('\0',' ').strip())
|
||||
protocol, site, mfile, j, k, l = urlparse.urlparse(d)
|
||||
if protocol == "file":
|
||||
name = Utils.fix_encoding(mfile)
|
||||
name = fix_encoding(mfile)
|
||||
name = unicode(urllib.url2pathname(
|
||||
name.encode(sys.getfilesystemencoding())))
|
||||
mime = gen.mime.get_type(name)
|
||||
if not gen.mime.is_valid_type(mime):
|
||||
return
|
||||
photo = gen.lib.MediaObject()
|
||||
base_dir = unicode(Utils.media_path(self.dbstate.db))
|
||||
base_dir = unicode(media_path(self.dbstate.db))
|
||||
if os.path.exists(base_dir):
|
||||
name = Utils.relative_path(name, base_dir)
|
||||
name = relative_path(name, base_dir)
|
||||
photo.set_path(name)
|
||||
photo.set_mime_type(mime)
|
||||
basename = os.path.basename(name)
|
||||
|
@ -39,7 +39,7 @@ from gi.repository import Gtk
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gen.datehandler
|
||||
import LdsUtils
|
||||
from gen.utils.lds import TEMPLES
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -59,7 +59,7 @@ class LdsModel(Gtk.ListStore):
|
||||
lds_ord.type2str(),
|
||||
gen.datehandler.get_date(lds_ord),
|
||||
lds_ord.status2str(),
|
||||
LdsUtils.TEMPLES.name(lds_ord.get_temple()),
|
||||
TEMPLES.name(lds_ord.get_temple()),
|
||||
self.column_place(lds_ord),
|
||||
lds_ord,
|
||||
])
|
||||
|
@ -64,7 +64,7 @@ from gi.repository import Gtk
|
||||
from gen.ggettext import sgettext as _
|
||||
from gen.lib.date import Date
|
||||
import gen.datehandler
|
||||
import const
|
||||
from gen.const import URL_MANUAL_PAGE
|
||||
from gui.display import display_help
|
||||
from gui.managedwindow import ManagedWindow
|
||||
from gui.glade import Glade
|
||||
@ -97,7 +97,7 @@ CAL_TO_MONTHS_NAMES = {
|
||||
Date.CAL_ISLAMIC : gen.datehandler.displayer.islamic,
|
||||
Date.CAL_SWEDISH : gen.datehandler.displayer.swedish }
|
||||
|
||||
WIKI_HELP_PAGE = '%s_-_Entering_and_Editing_Data:_Detailed_-_part_1' % const.URL_MANUAL_PAGE
|
||||
WIKI_HELP_PAGE = '%s_-_Entering_and_Editing_Data:_Detailed_-_part_1' % URL_MANUAL_PAGE
|
||||
WIKI_HELP_SEC = _('manual|Editing_Dates')
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
@ -41,7 +41,7 @@ from gi.repository import Gtk
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import const
|
||||
from gen.const import URL_MANUAL_PAGE
|
||||
import gen.lib
|
||||
from gen.db import DbTxn
|
||||
from gui.display import display_help
|
||||
@ -53,14 +53,14 @@ from displaytabs import (CitationEmbedList, NoteTab, GalleryTab,
|
||||
EventBackRefList, AttrEmbedList)
|
||||
from gui.widgets import (MonitoredEntry, PrivacyButton,
|
||||
MonitoredDataType, MonitoredDate)
|
||||
from Utils import get_participant_from_event
|
||||
from gen.utils.db import get_participant_from_event
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
WIKI_HELP_PAGE = '%s_-_Entering_and_Editing_Data:_Detailed_-_part_2' % const.URL_MANUAL_PAGE
|
||||
WIKI_HELP_PAGE = '%s_-_Entering_and_Editing_Data:_Detailed_-_part_2' % URL_MANUAL_PAGE
|
||||
WIKI_HELP_SEC = _('manual|Editing_Information_About_Events')
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
@ -60,10 +60,8 @@ from gi.repository import GObject
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Utils
|
||||
from gen.config import config
|
||||
from gen.display.name import displayer as name_displayer
|
||||
from gen.utils import get_marriage_or_fallback
|
||||
import gen.lib
|
||||
from gen.db import DbTxn
|
||||
from gen.errors import WindowActiveError
|
||||
@ -81,9 +79,10 @@ from gui.widgets import (PrivacyButton, MonitoredEntry, MonitoredDataType,
|
||||
from gen.plug import CATEGORY_QR_FAMILY
|
||||
from gui.dialog import (ErrorDialog, RunDatabaseRepair, WarningDialog,
|
||||
MessageHideDialog)
|
||||
from gen.utils import get_birth_or_fallback, get_death_or_fallback
|
||||
from gen.utils.db import (get_birth_or_fallback, get_death_or_fallback,
|
||||
get_marriage_or_fallback, preset_name, family_name)
|
||||
from gui.selectors import SelectorFactory
|
||||
from Utils import preset_name
|
||||
from gen.utils.id import create_id
|
||||
|
||||
SelectPerson = SelectorFactory('Person')
|
||||
|
||||
@ -381,7 +380,7 @@ class EditFamily(EditPrimary):
|
||||
|
||||
self.added = self.obj.handle is None
|
||||
if self.added:
|
||||
self.obj.handle = Utils.create_id()
|
||||
self.obj.handle = create_id()
|
||||
|
||||
self.load_data()
|
||||
|
||||
@ -484,7 +483,7 @@ class EditFamily(EditPrimary):
|
||||
|
||||
def get_menu_title(self):
|
||||
if self.obj and self.obj.get_handle():
|
||||
dialog_title = Utils.family_name(self.obj, self.db, _("New Family"))
|
||||
dialog_title = family_name(self.obj, self.db, _("New Family"))
|
||||
dialog_title = _("Family") + ': ' + dialog_title
|
||||
else:
|
||||
dialog_title = _("New Family")
|
||||
|
@ -47,7 +47,7 @@ from gi.repository import Gtk
|
||||
#-------------------------------------------------------------------------
|
||||
import gen.lib
|
||||
from gen.display.name import displayer as name_displayer
|
||||
import LdsUtils
|
||||
from gen.utils.lds import TEMPLES
|
||||
from gui.glade import Glade
|
||||
from editsecondary import EditSecondary
|
||||
from objectentries import PlaceEntry
|
||||
@ -205,7 +205,7 @@ class EditLdsOrd(EditSecondary):
|
||||
self.top.get_object('temple'),
|
||||
self.obj.set_temple,
|
||||
self.obj.get_temple,
|
||||
LdsUtils.TEMPLES.name_code_data(),
|
||||
TEMPLES.name_code_data(),
|
||||
self.db.readonly)
|
||||
self.track_ref_for_deletion('temple_menu')
|
||||
|
||||
@ -391,7 +391,7 @@ class EditFamilyLdsOrd(EditSecondary):
|
||||
self.top.get_object('temple'),
|
||||
self.obj.set_temple,
|
||||
self.obj.get_temple,
|
||||
LdsUtils.TEMPLES.name_code_data(),
|
||||
TEMPLES.name_code_data(),
|
||||
self.db.readonly)
|
||||
self.track_ref_for_deletion('temple_menu')
|
||||
|
||||
|
@ -47,7 +47,8 @@ import gen.lib
|
||||
from gen.db import DbTxn
|
||||
import gen.mime
|
||||
from gui.thumbnails import get_thumbnail_image, find_mime_type_pixbuf
|
||||
import Utils
|
||||
from gen.utils.file import (media_path_full, find_file,
|
||||
get_unicode_path_from_file_chooser)
|
||||
from editprimary import EditPrimary
|
||||
from gui.widgets import (MonitoredDate, MonitoredEntry, PrivacyButton,
|
||||
MonitoredTagList)
|
||||
@ -156,10 +157,10 @@ class EditMedia(EditPrimary):
|
||||
self.mimetext.set_text(descr)
|
||||
|
||||
path = self.file_path.get_text()
|
||||
path_full = Utils.media_path_full(self.db, path)
|
||||
path_full = media_path_full(self.db, path)
|
||||
if path != self.obj.get_path() and path_full != self.obj.get_path():
|
||||
#redetermine mime
|
||||
mime = gen.mime.get_type(Utils.find_file(path_full))
|
||||
mime = gen.mime.get_type(find_file(path_full))
|
||||
self.obj.set_mime_type(mime)
|
||||
descr = gen.mime.get_description(mime)
|
||||
if descr:
|
||||
@ -174,7 +175,7 @@ class EditMedia(EditPrimary):
|
||||
mtype = self.obj.get_mime_type()
|
||||
if mtype:
|
||||
pb = get_thumbnail_image(
|
||||
Utils.media_path_full(self.db, self.obj.get_path()),
|
||||
media_path_full(self.db, self.obj.get_path()),
|
||||
mtype)
|
||||
self.pixmap.set_from_pixbuf(pb)
|
||||
else:
|
||||
@ -238,14 +239,14 @@ class EditMedia(EditPrimary):
|
||||
ref_obj = self.dbstate.db.get_object_from_handle(self.obj.handle)
|
||||
|
||||
if ref_obj:
|
||||
media_path = Utils.media_path_full(self.dbstate.db,
|
||||
media_path = media_path_full(self.dbstate.db,
|
||||
ref_obj.get_path())
|
||||
open_file_with_default_application(media_path)
|
||||
|
||||
def select_file(self, val):
|
||||
self.determine_mime()
|
||||
path = self.file_path.get_text()
|
||||
self.obj.set_path(Utils.get_unicode_path_from_file_chooser(path))
|
||||
self.obj.set_path(get_unicode_path_from_file_chooser(path))
|
||||
AddMediaObject(self.dbstate, self.uistate, self.track, self.obj,
|
||||
self._update_addmedia)
|
||||
|
||||
@ -289,7 +290,7 @@ class EditMedia(EditPrimary):
|
||||
path = self.file_path.get_text()
|
||||
self.determine_mime()
|
||||
|
||||
self.obj.set_path(Utils.get_unicode_path_from_file_chooser(path))
|
||||
self.obj.set_path(get_unicode_path_from_file_chooser(path))
|
||||
|
||||
with DbTxn('', self.db) as trans:
|
||||
if not self.obj.get_handle():
|
||||
|
@ -44,10 +44,11 @@ from gi.repository import GdkPixbuf
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gui.utils import open_file_with_default_application
|
||||
import const
|
||||
from gen.const import THUMBSCALE
|
||||
import gen.mime
|
||||
from gui.thumbnails import get_thumbnail_image, find_mime_type_pixbuf
|
||||
import Utils
|
||||
from gen.utils.file import (media_path_full, find_file,
|
||||
get_unicode_path_from_file_chooser)
|
||||
from gen.lib import NoteType
|
||||
from gen.db import DbTxn
|
||||
from gui.glade import Glade
|
||||
@ -118,10 +119,10 @@ class EditMediaRef(EditReference):
|
||||
self.mimetext.set_text(descr)
|
||||
|
||||
path = self.file_path.get_text()
|
||||
path_full = Utils.media_path_full(self.db, path)
|
||||
path_full = media_path_full(self.db, path)
|
||||
if path != self.source.get_path() and path_full != self.source.get_path():
|
||||
#redetermine mime
|
||||
mime = gen.mime.get_type(Utils.find_file(path_full))
|
||||
mime = gen.mime.get_type(find_file(path_full))
|
||||
self.source.set_mime_type(mime)
|
||||
descr = gen.mime.get_description(mime)
|
||||
if descr:
|
||||
@ -139,7 +140,7 @@ class EditMediaRef(EditReference):
|
||||
"""
|
||||
mtype = self.source.get_mime_type()
|
||||
if mtype:
|
||||
fullpath = Utils.media_path_full(self.db, self.source.get_path())
|
||||
fullpath = media_path_full(self.db, self.source.get_path())
|
||||
pb = get_thumbnail_image(fullpath, mtype)
|
||||
self.pixmap.set_from_pixbuf(pb)
|
||||
subpix = get_thumbnail_image(fullpath, mtype,
|
||||
@ -394,7 +395,7 @@ class EditMediaRef(EditReference):
|
||||
self.subpixmap.hide()
|
||||
else:
|
||||
try:
|
||||
fullpath = Utils.media_path_full(self.db, path)
|
||||
fullpath = media_path_full(self.db, path)
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(fullpath)
|
||||
width = pixbuf.get_width()
|
||||
height = pixbuf.get_height()
|
||||
@ -411,7 +412,7 @@ class EditMediaRef(EditReference):
|
||||
width = sub_width
|
||||
height = sub_height
|
||||
ratio = float(max(height, width))
|
||||
scale = const.THUMBSCALE / ratio
|
||||
scale = THUMBSCALE / ratio
|
||||
x = int(scale * width)
|
||||
y = int(scale * height)
|
||||
pixbuf = pixbuf.scale_simple(x, y, GdkPixbuf.InterpType.BILINEAR)
|
||||
@ -433,7 +434,7 @@ class EditMediaRef(EditReference):
|
||||
|
||||
def button_press_event(self, obj, event):
|
||||
if event.button==1 and event.type == Gdk.EventType._2BUTTON_PRESS:
|
||||
photo_path = Utils.media_path_full(self.db, self.source.get_path())
|
||||
photo_path = media_path_full(self.db, self.source.get_path())
|
||||
open_file_with_default_application(photo_path)
|
||||
|
||||
def button_press_event_ref(self, widget, event):
|
||||
@ -457,9 +458,9 @@ class EditMediaRef(EditReference):
|
||||
|
||||
def motion_notify_event_ref(self, widget, event):
|
||||
# get the image size and calculate the X and Y offsets
|
||||
# (image is centered *horizontally* when smaller than const.THUMBSCALE)
|
||||
# (image is centered *horizontally* when smaller than THUMBSCALE)
|
||||
w, h = self.rect_pixbuf.get_width(), self.rect_pixbuf.get_height()
|
||||
offset_x = (const.THUMBSCALE - w) / 2
|
||||
offset_x = (THUMBSCALE - w) / 2
|
||||
offset_y = 0
|
||||
|
||||
self.rect_pixmap.draw_pixbuf(self.rect_gc, self.rect_pixbuf, 0, 0, 0, 0)
|
||||
@ -511,10 +512,10 @@ class EditMediaRef(EditReference):
|
||||
if new_x2 - new_x1 >= 5 and new_y2 - new_y1 >= 5:
|
||||
|
||||
# get the image size and calculate the X and Y offsets
|
||||
# (image is centered *horizontally* when smaller than const.THUMBSCALE)
|
||||
# (image is centered *horizontally* when smaller than THUMBSCALE)
|
||||
w = self.rect_pixbuf.get_width()
|
||||
h = self.rect_pixbuf.get_height()
|
||||
x = (const.THUMBSCALE - w) / 2
|
||||
x = (THUMBSCALE - w) / 2
|
||||
y = 0
|
||||
|
||||
# if the click was outside of the image,
|
||||
@ -581,7 +582,7 @@ class EditMediaRef(EditReference):
|
||||
def select_file(self, val):
|
||||
self.determine_mime()
|
||||
path = self.file_path.get_text()
|
||||
self.source.set_path(Utils.get_unicode_path_from_file_chooser(path))
|
||||
self.source.set_path(get_unicode_path_from_file_chooser(path))
|
||||
AddMediaObject(self.dbstate, self.uistate, self.track, self.source,
|
||||
self._update_addmedia)
|
||||
|
||||
|
@ -48,7 +48,6 @@ from gi.repository import Pango
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.config import config
|
||||
import const
|
||||
from editprimary import EditPrimary
|
||||
from displaytabs import GrampsTab, NoteBackRefList
|
||||
from gui.widgets import (MonitoredDataType, MonitoredCheckbox,
|
||||
|
@ -49,10 +49,10 @@ from gi.repository import Pango
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Utils
|
||||
from gen.utils.file import media_path_full
|
||||
from gui.thumbnails import get_thumbnail_image
|
||||
import gui.utils
|
||||
from gen.utils import get_birth_or_fallback
|
||||
from gen.utils.db import get_birth_or_fallback
|
||||
import gen.lib
|
||||
from gen.db import DbTxn
|
||||
from gui import widgets
|
||||
@ -636,7 +636,7 @@ class EditPerson(EditPrimary):
|
||||
photo = media_list[0]
|
||||
object_handle = photo.get_reference_handle()
|
||||
ref_obj = self.db.get_object_from_handle(object_handle)
|
||||
photo_path = Utils.media_path_full(self.db, ref_obj.get_path())
|
||||
photo_path = media_path_full(self.db, ref_obj.get_path())
|
||||
gui.utils.open_file_with_default_application(photo_path)
|
||||
|
||||
def _popup_change_description(self, obj):
|
||||
@ -940,7 +940,7 @@ class EditPerson(EditPrimary):
|
||||
Load the person's main photo using the Thumbnailer.
|
||||
"""
|
||||
pixbuf = get_thumbnail_image(
|
||||
Utils.media_path_full(self.dbstate.db,
|
||||
media_path_full(self.dbstate.db,
|
||||
obj.get_path()),
|
||||
obj.get_mime_type(),
|
||||
ref.get_rectangle())
|
||||
|
@ -35,7 +35,7 @@ from gi.repository import Gtk
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.ggettext import sgettext as _
|
||||
from gui.managedwindow import ManagedWindow
|
||||
import const
|
||||
from gen.const import URL_MANUAL_PAGE
|
||||
from gui.display import display_help
|
||||
from gui.listmodel import ListModel, TOGGLE
|
||||
|
||||
@ -45,7 +45,7 @@ from gui.listmodel import ListModel, TOGGLE
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
WIKI_HELP_PAGE = '%s_-_Entering_and_Editing_Data:_Detailed_-_part_3' % \
|
||||
const.URL_MANUAL_PAGE
|
||||
URL_MANUAL_PAGE
|
||||
WIKI_HELP_SEC = _('manual|Tags')
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
@ -59,7 +59,7 @@ from gen.filters.rules._matchesfilterbase import MatchesFilterBase
|
||||
from gui.listmodel import ListModel
|
||||
from gui.managedwindow import ManagedWindow
|
||||
from gui.dialog import QuestionDialog
|
||||
import const
|
||||
from gen.const import RULE_GLADE, URL_MANUAL_PAGE
|
||||
from gui.display import display_help
|
||||
from gen.errors import WindowActiveError
|
||||
from gen.ggettext import sgettext as _
|
||||
@ -68,14 +68,15 @@ from gen.filters import rules
|
||||
from gui.autocomp import StandardCustomSelector, fill_entry
|
||||
from gui.selectors import SelectorFactory
|
||||
from gen.display.name import displayer as _nd
|
||||
import Utils
|
||||
from gen.utils.db import family_name
|
||||
from gen.utils.string import confidence
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
WIKI_HELP_PAGE = WIKI_HELP_PAGE = '%s_-_Filters' % const.URL_MANUAL_PAGE
|
||||
WIKI_HELP_PAGE = WIKI_HELP_PAGE = '%s_-_Filters' % URL_MANUAL_PAGE
|
||||
|
||||
# dictionary mapping FILTER_TYPE of views to Filter window name
|
||||
_TITLES = {
|
||||
@ -339,7 +340,7 @@ class MyID(Gtk.HBox):
|
||||
name = _nd.display_name(person.get_primary_name())
|
||||
elif self.namespace == 'Family':
|
||||
family = self.db.get_family_from_gramps_id(gramps_id)
|
||||
name = Utils.family_name(family, self.db)
|
||||
name = family_name(family, self.db)
|
||||
elif self.namespace == 'Event':
|
||||
event = self.db.get_event_from_gramps_id(gramps_id)
|
||||
name = str(event.get_type)
|
||||
@ -442,7 +443,7 @@ class EditRule(ManagedWindow):
|
||||
self.filter_name = filter_name
|
||||
|
||||
self.active_rule = val
|
||||
self.define_glade('rule_editor', const.RULE_GLADE)
|
||||
self.define_glade('rule_editor', RULE_GLADE)
|
||||
|
||||
self.set_window(self.get_widget('rule_editor'),
|
||||
self.get_widget('rule_editor_title'),label)
|
||||
@ -552,7 +553,7 @@ class EditRule(ManagedWindow):
|
||||
t = MyList(taglist, taglist)
|
||||
elif v == _('Confidence level:'):
|
||||
t = MyList(map(str, range(5)),
|
||||
[Utils.confidence[i] for i in range(5)])
|
||||
[confidence[i] for i in range(5)])
|
||||
else:
|
||||
t = MyEntry()
|
||||
tlist.append(t)
|
||||
@ -731,7 +732,7 @@ class EditFilter(ManagedWindow):
|
||||
self.filterdb = filterdb
|
||||
self.selection_callback = selection_callback
|
||||
|
||||
self.define_glade('define_filter', const.RULE_GLADE)
|
||||
self.define_glade('define_filter', RULE_GLADE)
|
||||
|
||||
self.set_window(
|
||||
self.get_widget('define_filter'),
|
||||
@ -881,7 +882,7 @@ class ShowResults(ManagedWindow):
|
||||
self.db = db
|
||||
self.filtname = filtname
|
||||
self.namespace = namespace
|
||||
self.define_glade('test', const.RULE_GLADE,)
|
||||
self.define_glade('test', RULE_GLADE,)
|
||||
self.set_window(
|
||||
self.get_widget('test'),
|
||||
self.get_widget('test_title'),
|
||||
@ -919,7 +920,7 @@ class ShowResults(ManagedWindow):
|
||||
gid = person.get_gramps_id()
|
||||
elif self.namespace == 'Family':
|
||||
family = self.db.get_family_from_handle(handle)
|
||||
name = Utils.family_name(family, self.db)
|
||||
name = family_name(family, self.db)
|
||||
gid = family.get_gramps_id()
|
||||
elif self.namespace == 'Event':
|
||||
event = self.db.get_event_from_handle(handle)
|
||||
@ -958,7 +959,7 @@ class ShowResults(ManagedWindow):
|
||||
name = self.db.get_person_from_handle(handle).get_primary_name()
|
||||
sortname = _nd.sort_string(name)
|
||||
elif self.namespace == 'Family':
|
||||
sortname = Utils.family_name(
|
||||
sortname = family_name(
|
||||
self.db.get_family_from_handle(handle),self.db)
|
||||
elif self.namespace == 'Event':
|
||||
sortname = self.db.get_event_from_handle(handle).get_description()
|
||||
@ -994,7 +995,7 @@ class FilterEditor(ManagedWindow):
|
||||
self.height_key = "interface.filter-editor-height"
|
||||
self.namespace = namespace
|
||||
|
||||
self.define_glade('filter_list', const.RULE_GLADE)
|
||||
self.define_glade('filter_list', RULE_GLADE)
|
||||
self.filter_list = self.get_widget('filters')
|
||||
self.edit = self.get_widget('filter_list_edit')
|
||||
self.clone = self.get_widget('filter_list_clone')
|
||||
|
@ -48,7 +48,7 @@ from gen.filters import GenericFilterFactory, rules
|
||||
from gen.filters.rules.citation import (RegExpIdOf, HasIdOf, HasCitation,
|
||||
HasNoteMatchingSubstringOf,
|
||||
HasNoteRegexp, MatchesFilter)
|
||||
from Utils import confidence
|
||||
from gen.utils.string import confidence
|
||||
GenericCitationFilter = GenericFilterFactory('Citation')
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -230,9 +230,9 @@ class SidebarFilter(DbGUIElement):
|
||||
"""
|
||||
from gui.editors import EditFilter
|
||||
from gen.filters import FilterList, GenericFilterFactory
|
||||
import const
|
||||
from gen.const import CUSTOM_FILTERS
|
||||
the_filter = None
|
||||
filterdb = FilterList(const.CUSTOM_FILTERS)
|
||||
filterdb = FilterList(CUSTOM_FILTERS)
|
||||
filterdb.load()
|
||||
if self.generic.get_active() != 0:
|
||||
model = self.generic.get_model()
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user