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


Python PlaceRef.set_date_object方法代码示例

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


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

示例1: __get_places

# 需要导入模块: from gramps.gen.lib import PlaceRef [as 别名]
# 或者: from gramps.gen.lib.PlaceRef import set_date_object [as 别名]
    def __get_places(self, obj):
        gov_id = self.entry.get_text()
        to_do = [gov_id]
        try:
            preferred_lang = config.get('preferences.place-lang')
        except AttributeError:
            fmt = config.get('preferences.place-format')
            pf = _pd.get_formats()[fmt]
            preferred_lang = pf.language
        if len(preferred_lang) != 2:
            preferred_lang = 'de'
        visited = {}

        type_dic = dict()
        type_url = 'http://gov.genealogy.net/types.owl/'
        response = urlopen(type_url)
        data = response.read()
        dom = parseString(data)
        for group in dom.getElementsByTagName('owl:Class') :
            url_value = group.attributes['rdf:about'].value
            group_number = 'j.0:' + url_value.split('#')[1]
            for element in dom.getElementsByTagName(group_number):
                type_number = element.attributes['rdf:about'].value.split('#')[1]
                for pname in element.getElementsByTagName('rdfs:label'):
                    type_lang = pname.attributes['xml:lang'].value
                    type_text = pname.childNodes[0].data
                    type_dic[type_number,type_lang] = type_text

        with DbTxn(_('Add GOV-id place %s') % gov_id, self.dbstate.db) as trans:
            while to_do:
                gov_id = to_do.pop()
                place = self.dbstate.db.get_place_from_gramps_id(gov_id)
                if place is not None:
                    visited[gov_id] = (place, [])
                else:
                    place, ref_list = self.__get_place(gov_id, type_dic, preferred_lang)
                    if place.get_name().get_value is not '':
                        self.dbstate.db.add_place(place, trans)
                        visited[gov_id] = (place, ref_list)
                        for ref, date in ref_list:
                            if (ref not in to_do) and (ref not in visited):
                                to_do.append(ref)

            for place, ref_list in visited.values():
                if len(ref_list) > 0:
                    for ref, date in ref_list:
                        handle = visited[ref][0].handle
                        place_ref = PlaceRef()
                        place_ref.ref = handle
                        place_ref.set_date_object(date)
                        place.add_placeref(place_ref)
                    self.dbstate.db.commit_place(place, trans)
开发者ID:daleathan,项目名称:addons-source,代码行数:54,代码来源:getgov.py

示例2: __get_places

# 需要导入模块: from gramps.gen.lib import PlaceRef [as 别名]
# 或者: from gramps.gen.lib.PlaceRef import set_date_object [as 别名]
    def __get_places(self, _obj):
        gov_id = self.entry.get_text()
        to_do = [gov_id]
        try:
            preferred_lang = config.get('preferences.place-lang')
        except AttributeError:
            fmt = config.get('preferences.place-format')
            pf = _pd.get_formats()[fmt]
            preferred_lang = pf.language
        if len(preferred_lang) != 2:
            preferred_lang = glocale.lang
        visited = {}

        if not self.type_dic:
            self.__get_types()

        with DbTxn(_('Add GOV-id place %s') % gov_id,
                   self.dbstate.db) as trans:
            while to_do:
                gov_id = to_do.pop()
                place = self.dbstate.db.get_place_from_gramps_id(gov_id)
                if place is not None:
                    visited[gov_id] = (place, [])
                else:
                    place, ref_list = self.__get_place(gov_id, self.type_dic,
                                                       preferred_lang)
                    if place.get_name().get_value is not '':
                        self.dbstate.db.add_place(place, trans)
                        visited[gov_id] = (place, ref_list)
                        for ref, date in ref_list:
                            if (ref not in to_do) and (ref not in visited):
                                to_do.append(ref)

            for place, ref_list in visited.values():
                if len(ref_list) > 0:
                    for ref, date in ref_list:
                        handle = visited[ref][0].handle
                        place_ref = PlaceRef()
                        place_ref.ref = handle
                        place_ref.set_date_object(date)
                        place.add_placeref(place_ref)
                    self.dbstate.db.commit_place(place, trans)
        self.dbstate.db.save_place_types()
开发者ID:gramps-project,项目名称:addons-source,代码行数:45,代码来源:getgov.py


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