当前位置: 首页>>代码示例>>Python>>正文


Python Person.set_gender方法代码示例

本文整理汇总了Python中gramps.gen.lib.Person.set_gender方法的典型用法代码示例。如果您正苦于以下问题:Python Person.set_gender方法的具体用法?Python Person.set_gender怎么用?Python Person.set_gender使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gramps.gen.lib.Person的用法示例。


在下文中一共展示了Person.set_gender方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_mother_clicked

# 需要导入模块: from gramps.gen.lib import Person [as 别名]
# 或者: from gramps.gen.lib.Person import set_gender [as 别名]
 def add_mother_clicked(self, obj):
     person = Person()
     person.set_gender(Person.FEMALE)
     autoname = config.get("behavior.surname-guessing")
     # _("Father's surname"),
     # _("None"),
     # _("Combination of mother's and father's surname"),
     # _("Icelandic style"),
     if autoname == 2:
         name = self.latin_american_child("mother")
     else:
         name = self.no_name()
     person.set_primary_name(name)
     EditPerson(self.dbstate, self.uistate, self.track, person, self.new_mother_added)
开发者ID:radoeka,项目名称:gramps,代码行数:16,代码来源:editfamily.py

示例2: name_value_split

# 需要导入模块: from gramps.gen.lib import Person [as 别名]
# 或者: from gramps.gen.lib.Person import set_gender [as 别名]

#.........这里部分代码省略.........
            set_func = ['add_street', 'add_street', 'add_street', 'set_city',
                        'set_state', 'set_postal_code', 'set_country']
            for i, data in enumerate(data_fields):
                if i >= len(set_func):
                    break
                getattr(addr, set_func[i])(data)
            self.person.add_address(addr)

    def add_phone(self, fields, data):
        """Read the TEL property of a VCard."""
        tel = data.strip()
        if tel:
            addr = Address()
            addr.set_phone(self.unesc(tel))
            self.person.add_address(addr)

    def add_birthday(self, fields, data):
        """Read the BDAY property of a VCard."""
        date_str = data.strip()
        date_match = VCardParser.DATE_RE.match(date_str)
        date = Date()
        if date_match:
            if date_match.group(2):
                date_str = "%s-%s-%s" % (date_match.group(2),
                                       date_match.group(3), date_match.group(4))
            else:
                date_str = date_match.group(1)
            y, m, d = [int(x, 10) for x in date_str.split('-')]
            try:
                date.set(value=(d, m, y, False))
            except DateError:
                # TRANSLATORS: leave the {vcard_snippet} untranslated
                # in the format string, but you may re-order it if needed.
                self.__add_msg(_(
                    "Invalid date in BDAY {vcard_snippet}, "
                    "preserving date as text."
                    ).format(vcard_snippet=data), self.line_num - 1)
                date.set(modifier=Date.MOD_TEXTONLY, text=data)
        else:
            if date_str:
                # TRANSLATORS: leave the {vcard_snippet} untranslated.
                self.__add_msg(_(
                    "Date {vcard_snippet} not in appropriate format "
                    "yyyy-mm-dd, preserving date as text."
                    ).format(vcard_snippet=date_str), self.line_num - 1)
                date.set(modifier=Date.MOD_TEXTONLY, text=date_str)
            else:  # silently ignore an empty BDAY record
                return
        event = Event()
        event.set_type(EventType(EventType.BIRTH))
        event.set_date_object(date)
        self.database.add_event(event, self.trans)

        event_ref = EventRef()
        event_ref.set_reference_handle(event.get_handle())
        self.person.set_birth_ref(event_ref)

    def add_occupation(self, fields, data):
        """Read the ROLE property of a VCard."""
        occupation = data.strip()
        if occupation:
            event = Event()
            event.set_type(EventType(EventType.OCCUPATION))
            event.set_description(self.unesc(occupation))
            self.database.add_event(event, self.trans)

            event_ref = EventRef()
            event_ref.set_reference_handle(event.get_handle())
            self.person.add_event_ref(event_ref)

    def add_url(self, fields, data):
        """Read the URL property of a VCard."""
        href = data.strip()
        if href:
            url = Url()
            url.set_path(self.unesc(href))
            self.person.add_url(url)

    def add_email(self, fields, data):
        """Read the EMAIL property of a VCard."""
        email = data.strip()
        if email:
            url = Url()
            url.set_type(UrlType(UrlType.EMAIL))
            url.set_path(self.unesc(email))
            self.person.add_url(url)

    def add_gender(self, fields, data):
        """Read the GENDER property of a VCard."""
        gender_value = data.strip()
        if gender_value:
            gender_value = gender_value.upper()
            gender_value = gender_value[0]
            if gender_value == 'M':
                gender = Person.MALE
            elif gender_value == 'F':
                gender = Person.FEMALE
            else:
                return
            self.person.set_gender(gender)
开发者ID:SNoiraud,项目名称:gramps,代码行数:104,代码来源:importvcard.py


注:本文中的gramps.gen.lib.Person.set_gender方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。