コード例 #1
0
 def add_main_subject(self,
                      itemWD: ItemPage,
                      target_id: str = None,
                      target: ItemPage = None):
     """ создать ссылку на элемент темы """
     claim_topic_subject = self.claim_instance.claim_main_subject()
     # pwb.Claim(self.WD, props.topic_subject)
     if target_id:
         wditem_subject = pwb.ItemPage(self.WD, target_id)
     elif target:
         wditem_subject = target
     else:
         return
     # target = wd_item_ids[0]
     claim_topic_subject.setTarget(wditem_subject)
     if self.test_run:
         return
     itemWD.addClaim(claim_topic_subject,
                     bot=self.as_bot,
                     summary='moved from ruwikisource')
     pwb.stdout(f'added main subject in item')
コード例 #2
0
 def add_article_in_subjectitem(self, p, subject_item: ItemPage,
                                target_item: ItemPage):
     """ создать "описывается в источниках" в элементе темы """
     # s = get_item_from_listdict(other_sources, 'argument', m_item_id)
     # [i.target for i in self.wd_item.claims.get(self.main_subject, [])]
     claim_described_by = self.claim_instance.claim_described_by_source()
     rootpagename = p.rootpagename
     if p.rootpagename == 'Лентапедия' and p.title.endswith(
             '/Полная версия'):
         rootpagename = 'Лентапедия2'
     target = p.enc_meta['wditem']
     claim_described_by.setTarget(target)
     qualifier = self.claim_instance.claim_dedicated_article()
     # qualifier_target = pwb.ItemPage(self.WD, m_item_id)
     qualifier.setTarget(target_item)
     claim_described_by.addQualifier(qualifier)
     if self.test_run:
         return
     subject_item.addClaim(claim_described_by,
                           bot=self.as_bot,
                           summary='moved from ruwikisource')
     pwb.stdout(f'added item of article in subject item')