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


Python Person.add_url方法代码示例

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


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

示例1: name_value_split

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

#.........这里部分代码省略.........
            if line.find(":") == -1:
                continue
            line_parts = self.name_value_split(line)
            if not line_parts:
                continue

            # No check for escaped ; because only fields[0] is used.
            fields = line_parts[0].split(";")

            property_name = fields[0].upper()
            if property_name == "BEGIN":
                self.next_person()
            elif property_name == "END":
                self.finish_person()
            elif property_name == "VERSION":
                self.check_version(fields, line_parts[1])
            elif property_name == "FN":
                self.add_formatted_name(fields, line_parts[1])
            elif property_name == "N":
                self.add_name_parts(fields, line_parts[1])
            elif property_name == "NICKNAME":
                self.add_nicknames(fields, line_parts[1])
            elif property_name == "SORT-STRING":
                self.add_sortas(fields, line_parts[1])
            elif property_name == "ADR":
                self.add_address(fields, line_parts[1])
            elif property_name == "TEL":
                self.add_phone(fields, line_parts[1])
            elif property_name == "BDAY":
                self.add_birthday(fields, line_parts[1])
            elif property_name == "ROLE":
                self.add_occupation(fields, line_parts[1])
            elif property_name == "URL":
                self.add_url(fields, line_parts[1])
            elif property_name == "EMAIL":
                self.add_email(fields, line_parts[1])
            elif property_name == "X-GENDER" or property_name == "GENDER":
                # VCard 3.0 only has X-GENDER, GENDER is 4.0 syntax,
                # but we want to be robust here.
                self.add_gender(fields, line_parts[1])
            elif property_name == "PRODID":
                # Included cause VCards made by Gramps have this prop.
                pass
            else:
                self.__add_msg(_("Token >%(token)s< unknown. line skipped: %(line)s") %
                               {"token": (fields[0], line), "line": self.line_num - 1})

    def finish_person(self):
        """All info has been collected, write to database."""
        if self.person is not None:
            if self.add_name():
                self.database.add_person(self.person, self.trans)
        self.person = None

    def next_person(self):
        """A VCard for another person is started."""
        if self.person is not None:
            self.finish_person()
            self.__add_msg(_("BEGIN property not properly closed by END "
                           "property, Gramps can't cope with nested VCards."),
                           self.line_num - 1)
        self.person = Person()
        self.formatted_name = ''
        self.name_parts = ''

    def check_version(self, fields, data):
开发者ID:SNoiraud,项目名称:gramps,代码行数:70,代码来源:importvcard.py


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