~rosco2/ubuntu/wily/gramps/bug-1492304

« back to all changes in this revision

Viewing changes to gramps/gen/simple/_simpleaccess.py

  • Committer: Package Import Robot
  • Author(s): Ross Gammon
  • Date: 2015-08-11 23:03:11 UTC
  • mfrom: (1.4.3)
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: package-import@ubuntu.com-20150811230311-acjr8gcfe8isx7ij
* New upstream release
* Drop patches applied upstream or cherry-picked from there
* Add version constraints for gtk and pygobject
* Add goocanvas dependency - available soon
* Drop webkit dpendency as HTML view has been removed
* Force removal of upstream packages when installing Debian one
  (LP: #1464845)
* Drop fixperm override as permissions fixed upstream
* Fix spelling error in changelog
* Switch to nose for unit tests
* Add build dependencies for the nose tests
* Update copyright file
* Add uversionmangle to watch file to deal with alpha/beta versions
* Add manual test cases
* Drop FAQ URL from upstream metadata - changes every release
* Add patch to fix transparent windows in Ubuntu.
  Thanks to Lance Orner (LP: #1451259)

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
"""
24
24
Provide a simplified database access interface to the Gramps database.
25
25
"""
26
 
from __future__ import with_statement, unicode_literals
27
 
 
28
26
from ..lib import (Person, Family, Event, Source, Place, Citation, 
29
27
                   MediaObject, Repository, Note, Date, Tag)
30
28
from ..lib.handle import Handle
38
36
from ..config import config
39
37
from ..const import GRAMPS_LOCALE as glocale
40
38
_ = glocale.translation.gettext
41
 
from ..constfunc import STRTYPE
42
39
 
43
40
#-------------------------------------------------------------------------
44
41
#
125
122
        :return: Returns the name of the person based of the program preferences
126
123
        :rtype: unicode
127
124
        """
128
 
        if isinstance(person, STRTYPE):
 
125
        if isinstance(person, str):
129
126
            person = self.dbase.get_person_from_handle(person)
130
127
        assert(person is None or isinstance(person, Person))     
131
128
        if person:
142
139
        :return: Returns the name of the person based of the program preferences
143
140
        :rtype: unicode
144
141
        """
145
 
        if isinstance(person, STRTYPE): 
 
142
        if isinstance(person, str): 
146
143
            person = self.dbase.get_person_from_handle(person)
147
144
        assert(person is None or isinstance(person, Person))     
148
145
        if person:
162
159
                 preferences
163
160
        :rtype: unicode
164
161
        """
165
 
        if isinstance(person, STRTYPE): 
 
162
        if isinstance(person, str): 
166
163
            person = self.dbase.get_person_from_handle(person)
167
164
        assert(person is None or isinstance(person, Person))
168
165
        if person:
193
190
        :return: Returns a string indentifying the person's gender
194
191
        :rtype: unicode
195
192
        """
196
 
        if isinstance(person, STRTYPE): 
 
193
        if isinstance(person, str): 
197
194
            person = self.dbase.get_person_from_handle(person)
198
195
        assert(person is None or isinstance(person, Person))
199
196
        if person:
321
318
        :return: The spouse identified as the person's primary spouse
322
319
        :rtype: :py:class:`.Person`
323
320
        """
324
 
        if isinstance(person, STRTYPE): 
 
321
        if isinstance(person, str): 
325
322
            person = self.dbase.get_person_from_handle(person)
326
323
        assert(person is None or isinstance(person, Person))
327
324
 
349
346
                 person and his/per primary spouse.
350
347
        :rtype: unicode
351
348
        """
352
 
        if isinstance(person, STRTYPE): 
 
349
        if isinstance(person, str): 
353
350
            person = self.dbase.get_person_from_handle(person)
354
351
        assert(person is None or isinstance(person, Person))
355
352
 
373
370
                 his/her spouse where married.
374
371
        :rtype: unicode
375
372
        """
376
 
        if isinstance(person, STRTYPE): 
 
373
        if isinstance(person, str): 
377
374
            person = self.dbase.get_person_from_handle(person)
378
375
        assert(person is None or isinstance(person, Person))
379
376
 
404
401
                 his/her spouse where married.
405
402
        :rtype: unicode
406
403
        """
407
 
        if isinstance(person, STRTYPE): 
 
404
        if isinstance(person, str): 
408
405
            person = self.dbase.get_person_from_handle(person)
409
406
        assert(person is None or isinstance(person, Person))
410
407
 
496
493
        :return: Returns a string indicating the date when the person's birth.
497
494
        :rtype: unicode
498
495
        """
499
 
        if isinstance(person, STRTYPE): 
 
496
        if isinstance(person, str): 
500
497
            person = self.dbase.get_person_from_handle(person)
501
498
        return self.__event_date(person, Person.get_birth_ref)
502
499
 
509
506
        :return: Returns the date when the person's birth.
510
507
        :rtype: :py:class:`.Date`
511
508
        """
512
 
        if isinstance(person, STRTYPE): 
 
509
        if isinstance(person, str): 
513
510
            person = self.dbase.get_person_from_handle(person)
514
511
        return self.__event_date_obj(person, Person.get_birth_ref)
515
512
 
523
520
        :return: Returns the date when the person's birth or fallback.
524
521
        :rtype: :py:class:`.Date`
525
522
        """
526
 
        if isinstance(person, STRTYPE): 
 
523
        if isinstance(person, str): 
527
524
            person = self.dbase.get_person_from_handle(person)
528
525
        event = get_birth_or_fallback(self.dbase, person, "<i>%s</i>")
529
526
        if get_event:
542
539
        :return: Returns a string indicating the place of the person's birth.
543
540
        :rtype: unicode
544
541
        """
545
 
        if isinstance(person, STRTYPE): 
 
542
        if isinstance(person, str): 
546
543
            person = self.dbase.get_person_from_handle(person)
547
544
        return self.__event_place(person, Person.get_birth_ref)
548
545
 
555
552
        :return: Returns a string indicating the date when the person's death.
556
553
        :rtype: unicode
557
554
        """
558
 
        if isinstance(person, STRTYPE):
 
555
        if isinstance(person, str):
559
556
            person = self.dbase.get_person_from_handle(person)
560
557
        return self.__event_date(person, Person.get_death_ref)
561
558
 
568
565
        :return: Returns the date when the person's death.
569
566
        :rtype: :py:class:`.Date`
570
567
        """
571
 
        if isinstance(person, STRTYPE): 
 
568
        if isinstance(person, str): 
572
569
            person = self.dbase.get_person_from_handle(person)
573
570
        return self.__event_date_obj(person, Person.get_death_ref)
574
571
 
581
578
        :return: Returns the date of the person's death or fallback.
582
579
        :rtype: :py:class:`.Date`
583
580
        """
584
 
        if isinstance(person, STRTYPE): 
 
581
        if isinstance(person, str): 
585
582
            person = self.dbase.get_person_from_handle(person)
586
583
        event = get_death_or_fallback(self.dbase, person, "<i>%s</i>")
587
584
        if get_event:
600
597
        :return: Returns a string indicating the place of the person's death.
601
598
        :rtype: unicode
602
599
        """
603
 
        if isinstance(person, STRTYPE): 
 
600
        if isinstance(person, str): 
604
601
            person = self.dbase.get_person_from_handle(person)
605
602
        return self.__event_place(person, Person.get_death_ref)
606
603
 
734
731
                 listed as a parent.
735
732
        :rtype: list
736
733
        """
737
 
        if isinstance(person, STRTYPE):
 
734
        if isinstance(person, str):
738
735
            person = self.dbase.get_person_from_handle(person)
739
736
        assert(person is None or isinstance(person, Person))     
740
737
        
753
750
                 listed as a child.
754
751
        :rtype: list
755
752
        """
756
 
        if isinstance(person, STRTYPE):
 
753
        if isinstance(person, str):
757
754
            person = self.dbase.get_person_from_handle(person)
758
755
        assert(person is None or isinstance(person, Person))
759
756
        
788
785
        """
789
786
        
790
787
        with self.dbase.get_person_cursor() as cursor:
791
 
            slist = sorted((data[3][3], key) for key, data in cursor)
 
788
            # data[3] is primary_name; data[3][5][0][0] is surname
 
789
            slist = sorted((data[3][5][0][0], key) for key, data in cursor)
792
790
 
793
791
        for info in slist:
794
792
            obj = self.dbase.get_person_from_handle(info[1])
852
850
        :return: list of repositories in the database
853
851
        :rtype: list
854
852
        """
855
 
        return self.__all_objects(self.dbase.get_repsoitory_cursor, 
 
853
        return self.__all_objects(self.dbase.get_repository_cursor, 
856
854
                                  self.dbase.get_repository_from_handle)
857
855
 
858
856
    def all_media(self):
942
940
        return ''
943
941
 
944
942
    def person(self, handle):
945
 
        assert(isinstance(handle, STRTYPE))
 
943
        assert(isinstance(handle, str))
946
944
        return self.dbase.get_person_from_handle(handle)
947
945
 
948
946
    def event(self, handle):
949
 
        assert(isinstance(handle, STRTYPE))
 
947
        assert(isinstance(handle, str))
950
948
        return self.dbase.get_event_from_handle(handle)
951
949
 
952
950
    def family(self, handle):
953
 
        assert(isinstance(handle, STRTYPE))
 
951
        assert(isinstance(handle, str))
954
952
        return self.dbase.get_family_from_handle(handle)
955
953
 
956
954
    def display(self, object_class, prop, value):