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


Python Tag.set_name方法代码示例

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


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

示例1: create_tag

# 需要导入模块: from gramps.gen.lib import Tag [as 别名]
# 或者: from gramps.gen.lib.Tag import set_name [as 别名]
 def create_tag(self, tag_name, tag_color):
     """
     Create a tag if it doesn't already exist.
     """
     tag = self.db.get_tag_from_name(tag_name)
     if tag is None:
         tag = Tag()
         tag.set_name(tag_name)
         if tag_color is not None:
             tag.set_color(tag_color)
         tag.set_priority(self.db.get_number_of_tags())
         tag_handle = self.db.add_tag(tag, self.trans)
     else:
         tag_handle = tag.get_handle()
     return tag_handle
开发者ID:nblock,项目名称:gramps,代码行数:17,代码来源:dateparserdisplaytest.py

示例2: on_ok_clicked

# 需要导入模块: from gramps.gen.lib import Tag [as 别名]
# 或者: from gramps.gen.lib.Tag import set_name [as 别名]
    def on_ok_clicked(self, obj):

        clean = self.clear_button.get_active()
        copy = self.copy_button.get_active()
        tag = self.tag_button.get_active()
        if not (copy or clean or tag):
            return

        self.db.disable_signals()

        if tag:
            tag_name = _('Legacy place')
            # start the db transaction
            with DbTxn("Tag for place titles", self.db) as self.tag_trans:

                mark = self.db.get_tag_from_name(tag_name)
                if not mark:
                    # create the tag if it doesn't already exist
                    mark = Tag()
                    mark.set_name(tag_name)
                    mark.set_priority(self.db.get_number_of_tags())
                    tag_handle = self.db.add_tag(mark, self.tag_trans)
                else:
                    tag_handle = mark.get_handle()

        with DbTxn(_("Modify Place titles"), self.db, batch=True) as trans:
            for row in self.model:
                if row[1] == True:
                    place = self.db.get_place_from_handle(row[0])
                    if copy:
                        self.create_note(place, row[2], trans)
                    if clean:
                        place.set_title("")
                    if tag:
                        place.add_tag(tag_handle)
                    self.db.commit_place(place, trans)

        self.db.enable_signals()
        self.db.request_rebuild()
        self.close()
开发者ID:phejl,项目名称:addons-source,代码行数:42,代码来源:checkplacetitles.py

示例3: applyTagClicked

# 需要导入模块: from gramps.gen.lib import Tag [as 别名]
# 或者: from gramps.gen.lib.Tag import set_name [as 别名]
    def applyTagClicked(self, button) :
        progress    = None
        rows        = self.treeSelection.count_selected_rows()
        tag_name    = str(self.tagcombo.get_active_text())

        # start the db transaction
        with DbTxn("Tag not related", self.db) as transaction:

            tag = self.db.get_tag_from_name(tag_name)
            if not tag:
                # create the tag if it doesn't already exist
                tag = Tag()
                tag.set_name(tag_name)
                tag.set_priority(self.db.get_number_of_tags())
                tag_handle = self.db.add_tag(tag, transaction)
            else:
                tag_handle = tag.get_handle()

            # if more than 1 person is selected, use a progress indicator
            if rows > 1:
                progress = ProgressMeter(self.title,_('Starting'),
                                         parent=self.window)
                progress.set_pass(
                    # translators: leave all/any {...} untranslated
                    #TRANS: no singular form needed, as rows is always > 1
                    ngettext("Setting tag for {number_of} person",
                             "Setting tag for {number_of} people",
                             rows).format(number_of=rows),
                    rows)


            # iterate through all of the selected rows
            (model, paths) = self.treeSelection.get_selected_rows()

            for path in paths:
                if progress:
                    progress.step()

                # for the current row, get the GID and the person from the database
                iter        = self.model.get_iter(path)
                personGid   = self.model.get_value(iter, 1)
                person      = self.db.get_person_from_gramps_id(personGid)

                # add the tag to the person
                person.add_tag(tag_handle)

                # save this change
                self.db.commit_person(person, transaction)


        # refresh the tags column
        self.treeView.set_model(None)
        for path in paths:
            iter        = self.model.get_iter(path)
            personGid   = self.model.get_value(iter, 1)
            person      = self.db.get_person_from_gramps_id(personGid)
            self.model.set_value(iter, 3, self.get_tag_list(person))
        self.treeView.set_model(self.model)
        self.treeView.expand_all()

        if progress:
            progress.close()
开发者ID:geogeek1911,项目名称:gramps,代码行数:64,代码来源:notrelated.py

示例4: __init__

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

#.........这里部分代码省略.........
            "family": ("Family", _("Family"), "family", _("family")),
            # ----------------------------------
            "wife": ("Mother", _("Mother"), "Wife", _("Wife"), "Parent2",
                _("Parent2"), "mother", _("mother"), "wife", _("wife"),
                "parent2", _("parent2")),
            "husband": ("Father", _("Father"), "Husband", _("Husband"),
                "Parent1", _("Parent1"), "father", _("father"), "husband",
                _("husband"), "parent1", _("parent1")),
            "marriage": ("Marriage", _("Marriage"), "marriage", _("marriage")),
            "date": ("Date", _("Date"), "date", _("date")),
            "place": ("Place", _("Place"), "place", _("place")),
            "place_id": ("Placeid", "place id", "Place id", "place_id", "placeid"),
            "name": ("Name", _("Name"), "name", _("name")),
            "type": ("Type", _("Type"), "type", _("type")),
            "latitude": ("Latitude", _("latitude"), "latitude", _("latitude")),
            "longitude": ("Longitude", _("Longitude"), "longitude", _("longitude")),
            "code": ("Code", _("Code"), "code", _("code")),
            "enclosed_by": ("Enclosed by", _("Enclosed by"), "enclosed by", _("enclosed by"),
                            "enclosed_by", _("enclosed_by"), "Enclosed_by", _("Enclosed_by"),
                            "enclosedby")
        }
        lab2col_dict = []
        for key in list(column2label.keys()):
            for val in column2label[key]:
                lab2col_dict.append((val, key))
        self.label2column = dict(lab2col_dict)
        if default_tag_format:
            name = time.strftime(default_tag_format)
            tag = self.db.get_tag_from_name(name)
            if tag:
                self.default_tag = tag
            else:
                self.default_tag = Tag()
                self.default_tag.set_name(name)
        else:
            self.default_tag = None

    def cleanup_column_name(self, column):
        """Handle column aliases for CSV spreadsheet import and SQL."""
        return self.label2column.get(column, column)

    def read_csv(self, filehandle):
        "Read the data from the file and return it as a list."
        try:
            data = [[r.strip() for r in row] for row in csv.reader(filehandle)]
        except csv.Error as err:
            self.user.notify_error(_('format error: line %(line)d: %(zero)s') % {
                        'line' : reader.line_num, 'zero' : err } )
            return None
        return data

    def lookup(self, type_, id_):
        """
        Return the object of type type_ with id id_ from db or previously
        stored value.
        """
        if id_ is None:
            return None
        if type_ == "family":
            if id_.startswith("[") and id_.endswith("]"):
                id_ = self.db.fid2user_format(id_[1:-1])
                db_lookup = self.db.get_family_from_gramps_id(id_)
                if db_lookup is None:
                    return self.lookup(type_, id_)
                else:
                    return db_lookup
开发者ID:tecknicaltom,项目名称:gramps,代码行数:70,代码来源:importcsv.py


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