當前位置: 首頁>>代碼示例>>Python>>正文


Python pywikibot.Page方法代碼示例

本文整理匯總了Python中pywikibot.Page方法的典型用法代碼示例。如果您正苦於以下問題:Python pywikibot.Page方法的具體用法?Python pywikibot.Page怎麽用?Python pywikibot.Page使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pywikibot的用法示例。


在下文中一共展示了pywikibot.Page方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import pywikibot [as 別名]
# 或者: from pywikibot import Page [as 別名]
def __init__(self, dictGenerator):
        """
        Arguments:
            * generator    - A generator that yields Dict objects.

        """
        self.generator = dictGenerator
        self.repo = pywikibot.Site().data_repository()

        self.progressPage = pywikibot.Page(self.repo, title=u'User:Multichill/Rijksmuseum creators')
        self.progressPage.get()

        self.creators = self.fillCache()
        self.missingCreators = self.getMissingCreators()
        
        #self.paintingIdProperty = paintingIdProperty
        #self.paintingIds = self.fillCache(self.paintingIdProperty) 
開發者ID:multichill,項目名稱:toollabs,代碼行數:19,代碼來源:rijksmuseum_schilders.py

示例2: _get_wikipage

# 需要導入模塊: import pywikibot [as 別名]
# 或者: from pywikibot import Page [as 別名]
def _get_wikipage(self, page_title):
        """"""
        if page_title in self.title_to_ctitle_table:
            page_title = self.title_to_ctitle_table[page_title]

        if page_title in self.ctitle_to_cpage_table:
            return self.ctitle_to_cpage_table[page_title]

        page = pywikibot.Page(self._wiki_site, page_title)

        # if not canonical page
        if page.isRedirectPage():
            page = page.getRedirectTarget()

        # canonical title
        ctitle = page.title()

        # set canonical title to canonical wiki page
        self.ctitle_to_cpage_table[ctitle] = page

        # set title (alias) to canonical title
        self.title_to_ctitle_table[page_title] = ctitle

        return page 
開發者ID:rodricios,項目名稱:wikicrawl,代碼行數:26,代碼來源:multithreadedwikicrawler.py

示例3: getCreatorItem

# 需要導入模塊: import pywikibot [as 別名]
# 或者: from pywikibot import Page [as 別名]
def getCreatorItem(self, creator):
        '''
        '''
        try:
            site=pywikibot.Site('commons', 'commons')
            creatorPage = pywikibot.Page(site, title=creator, ns=100)

            if creatorPage.exists():
                if creatorPage.isRedirectPage():
                    creatorPage = creatorPage.getRedirectTarget()
                pywikibot.output(u'Got a creator page %s' % (creatorPage.title(),))
            
                regex = u'\|\s*[wW]ikidata\s*=\s*(Q\d+)\s*'
                match = re.search(regex, creatorPage.get())
                if match:
                    creatorItem = pywikibot.ItemPage(self.repo, title=match.group(1))
                    return creatorItem
        except pywikibot.exceptions.InvalidTitle:
            pywikibot.output(u'Found an invalid title')
            pass
        return None 
開發者ID:multichill,項目名稱:toollabs,代碼行數:23,代碼來源:walters_import.py

示例4: makeRijksReport

# 需要導入模塊: import pywikibot [as 別名]
# 或者: from pywikibot import Page [as 別名]
def makeRijksReport(rijksworks):
    text = u'List of %s Rijksmuseum paintings to match. Find the right painting, add the inventory number qualified with {{Q|18600731}} \n\n' % (len(rijksworks),)
    text = text + u'{| class="wikitable"\n! Title !! Creator !! Search !! Inventory number !! Source\n'

    for work in rijksworks:
        text = text + u'|-\n | %s || %s || [//www.wikidata.org/w/index.php?search=&search={{urlencode:%s %s}}] || %s || [%s]\n' % (work.get('title').get(u'nl'),
                                                                                                                               work.get('creatorname'),
                                                                                                                               work.get('title').get(u'nl'),
                                                                                                                               work.get('creatorname'),
                                                                                                                               work.get('id'),
                                                                                                                               work.get('url'),
                                                                                                                               )
    text = text + u'|}\n\n[[Category:User:Multichill]]\n'
    repo = pywikibot.Site().data_repository()
    summary = u'Update Rijksmuseum report with %s paintings' % (len(rijksworks),)
    pageTitle = u'User:Multichill/Zandbak'
    page = pywikibot.Page(repo, title=pageTitle)
    page.put(text, summary=summary) 
開發者ID:multichill,項目名稱:toollabs,代碼行數:20,代碼來源:rce_collection_import.py

示例5: main

# 需要導入模塊: import pywikibot [as 別名]
# 或者: from pywikibot import Page [as 別名]
def main():
    repo = pywikibot.Site().data_repository()
    configpage = pywikibot.Page(repo, title=u'User:BotMultichillT/heritage images.js')
    (comments, sep, jsondata) = configpage.get().partition(u'[')
    jsondata = u'[' + jsondata
    configjson = json.loads(jsondata)
    for workitem in configjson:
        print workitem
    
        query = u"""SELECT ?item WHERE {
  ?item wdt:P1435 wd:%s .
  MINUS { ?item wdt:P18 ?image.} .
}""" % (workitem.get('item'),)
        generator = pagegenerators.PreloadingItemGenerator(pagegenerators.WikidataSPARQLPageGenerator(query, site=repo))

        monumentsImageBot = MonumentsImageBot(generator,
                                              lang=workitem.get('lang'),
                                              country=workitem.get('country'),
                                              wdproperty=workitem.get('property'),
                                              )
        monumentsImageBot.run() 
開發者ID:multichill,項目名稱:toollabs,代碼行數:23,代碼來源:heritage_image_import.py

示例6: __init__

# 需要導入模塊: import pywikibot [as 別名]
# 或者: from pywikibot import Page [as 別名]
def __init__(self, institution, invId=217):
        """
        Arguments:
            * institution    - Name of the institution to work on
            * invId          - Property id of the inventory id

        """
        self.site = pywikibot.Site('commons', 'commons')
        self.repo = pywikibot.Site().data_repository()
        
        self.institution = institution
        self.invId = invId
        self.institutionPage = pywikibot.Page(self.site, title=institution, ns=106)
        self.institutionItem = self.getInstitutionItem(self.institutionPage)
                 
        self.generator = pagegenerators.ImageGenerator(pagegenerators.PreloadingGenerator(self.institutionPage.getReferences(onlyTemplateInclusion=True, namespaces=[6])))

        self.withoutImage = self.withoutImage(self.institutionItem)
        self.withImage = self.withImage(self.institutionItem)

        #print self.withoutImage
        #print self.withImage
        
        #self.paintingIdProperty = paintingIdProperty
        #self.paintingIds = self.fillCache(self.paintingIdProperty) 
開發者ID:multichill,項目名稱:toollabs,代碼行數:27,代碼來源:image_import.py

示例7: addMissingCommonsWikidataLinks

# 需要導入模塊: import pywikibot [as 別名]
# 或者: from pywikibot import Page [as 別名]
def addMissingCommonsWikidataLinks(self):
        '''
        Add missing links from Commons to Wikidata and report for which files it didn't work
        '''
        pageTitle = u'User:Multichill/Unable to add Wikidata link'
        page = pywikibot.Page(self.commons, title=pageTitle)
        text = u'{{/header}}\n'

        missingCommonsLinks = set(self.wikidataImages.keys()) & set(self.commonsNoLink)
        for filename in missingCommonsLinks:
            wikidataitem = self.wikidataImages.get(filename).get('item')
            success = self.addMissingCommonsWikidataLink(filename, wikidataitem)
            if success:
                # This prevents these files from showing up in the suggestions and missing link reports
                self.commonsLink[filename]=wikidataitem
            else:
                text = text + u'* [[:File:%s]] - <nowiki>|</nowiki> wikidata = %s\n' % (filename, wikidataitem)


        text = text + u'\n[[Category:User:Multichill]]\n'

        summary = u'Updating list of images to which to bot was unable to add a link'
        pywikibot.output(summary)
        page.put(text, summary) 
開發者ID:multichill,項目名稱:toollabs,代碼行數:26,代碼來源:find_painting_images.py

示例8: publishCommonsNoTracker

# 需要導入模塊: import pywikibot [as 別名]
# 或者: from pywikibot import Page [as 別名]
def publishCommonsNoTracker(self):
        """
        Publish a list of files that are in use on Wikidata, but don't have a tracker category
        Files that are in use on Wikidata, but not in the without Wikikidata category and also not in the with Wikidata category
        """
        nottracked = set(self.wikidataImages.keys()) - (set(self.commonsNoLink) | set(self.commonsLink.keys()))

        pageTitle = u'User:Multichill/Painting images no artwork template'

        page = pywikibot.Page(self.commons, title=pageTitle)

        text = u'{{/header}}\n'
        for filename in nottracked:
            text = text + u'* [[:File:%s]]\n' % filename
        text = text + u'\n[[Category:User:Multichill]]\n'

        summary = u'Updating list of %s painting images with no artwork template' % (len(nottracked),)
        pywikibot.output(summary)
        page.put(text, summary) 
開發者ID:multichill,項目名稱:toollabs,代碼行數:21,代碼來源:find_painting_images.py

示例9: __init__

# 需要導入模塊: import pywikibot [as 別名]
# 或者: from pywikibot import Page [as 別名]
def __init__(self, generator):
        """
        Arguments:
            * generator    - A generator that yields Dict objects.

        """
        
        self.repo = pywikibot.Site().data_repository()
        self.generator = generator
        
        self.progressPage = pywikibot.Page(self.repo, title=u'User:Multichill/SMAK creators')
        #self.progressPage.get()

        self.rkditems = self.getRKD()
        #print self.rkditems
        self.viafitems = self.getVIAF()

        self.museumitem = pywikibot.ItemPage(self.repo, title=u'Q1540707') 
開發者ID:multichill,項目名稱:toollabs,代碼行數:20,代碼來源:smak_artists.py

示例10: __init__

# 需要導入模塊: import pywikibot [as 別名]
# 或者: from pywikibot import Page [as 別名]
def __init__(self):
        """
        Arguments:
            * generator    - A generator that yields Dict objects.

        """
        
        self.repo = pywikibot.Site().data_repository()

        self.progressPage = pywikibot.Page(self.repo, title=u'User:Multichill/Rijksmuseum creators RKD')
        #self.progressPage.get()

        self.creators = self.getCreators()
        self.rkditems = self.getRKD()

        #self.creators = self.fillCache()
        #self.missingCreators = self.getMissingCreators()
        
        #self.paintingIdProperty = paintingIdProperty
        #self.paintingIds = self.fillCache(self.paintingIdProperty) 
開發者ID:multichill,項目名稱:toollabs,代碼行數:22,代碼來源:rijksmuseum_rkd.py

示例11: __init__

# 需要導入模塊: import pywikibot [as 別名]
# 或者: from pywikibot import Page [as 別名]
def __init__(self, generator):
        """
        Arguments:
            * generator    - A generator that yields Dict objects.

        """
        
        self.repo = pywikibot.Site().data_repository()
        self.generator = generator
        
        self.progressPage = pywikibot.Page(self.repo, title=u'User:Multichill/CVG creators')
        #self.progressPage.get()

        self.rkditems = self.getRKD()
        #print self.rkditems
        self.viafitems = self.getVIAF()

        self.museumitem = pywikibot.ItemPage(self.repo, title=u'Q1540707') 
開發者ID:multichill,項目名稱:toollabs,代碼行數:20,代碼來源:cvg_artists.py

示例12: getTemplateClaims

# 需要導入模塊: import pywikibot [as 別名]
# 或者: from pywikibot import Page [as 別名]
def getTemplateClaims(self, pageTitle):
        """
        Get a dictionary of templates and the statements to add
        """
        page = pywikibot.Page(self.site, title=pageTitle)
        text = page.get()
        regex = u'^\* \[\[(?P<title>%s:[^\]]+)\]\]\s*(?P<P1>P\d+)\s*(?P<Q1>Q\d+)\s*((?P<P2>P\d+)\s*(?P<Q2>Q\d+))?\s*((?P<P3>P\d+)?\s*(?P<Q3>Q\d+))?$' % (self.site.namespace(10),)
        result = {}

        for match in re.finditer(regex, text, flags=re.M):
            result[match.group('title')] = [(match.group('P1'), match.group('Q1'))]
            if match.group('Q2'):
                result[match.group('title')].append((match.group('P2'), match.group('Q2')))
            if match.group('Q3'):
                result[match.group('title')].append((match.group('P3'), match.group('Q3')))
        return result 
開發者ID:multichill,項目名稱:toollabs,代碼行數:18,代碼來源:claim_templates.py

示例13: __init__

# 需要導入模塊: import pywikibot [as 別名]
# 或者: from pywikibot import Page [as 別名]
def __init__(self, generator):
        """
        Arguments:
            * generator    - A generator that yields Dict objects.

        """
        
        self.repo = pywikibot.Site().data_repository()
        self.generator = generator
        
        self.progressPage = pywikibot.Page(self.repo, title=u'User:Multichill/Mu.ZEE creators')
        #self.progressPage.get()

        self.rkditems = self.getRKD()
        #print self.rkditems
        self.viafitems = self.getVIAF()

        self.museumitem = pywikibot.ItemPage(self.repo, title=u'Q1928672') 
開發者ID:multichill,項目名稱:toollabs,代碼行數:20,代碼來源:muzee_artists.py

示例14: __init__

# 需要導入模塊: import pywikibot [as 別名]
# 或者: from pywikibot import Page [as 別名]
def __init__(self, generator):
        """
        Arguments:
            * generator    - A generator that yields Dict objects.

        """
        
        self.repo = pywikibot.Site().data_repository()
        self.generator = generator
        
        self.progressPage = pywikibot.Page(self.repo, title=u'User:Multichill/KMSKA creators')
        #self.progressPage.get()

        #(self.paintings, self.creators) = self.getPaintersCreators()
        self.rkditems = self.getRKD()
        #print self.rkditems
        self.viafitems = self.getVIAF()

        self.kmskaitem = pywikibot.ItemPage(self.repo, title=u'Q1471477')

        #self.creators = self.fillCache()
        #self.missingCreators = self.getMissingCreators()
        
        #self.paintingIdProperty = paintingIdProperty
        #self.paintingIds = self.fillCache(self.paintingIdProperty) 
開發者ID:multichill,項目名稱:toollabs,代碼行數:27,代碼來源:KMSKA_artists.py

示例15: run

# 需要導入模塊: import pywikibot [as 別名]
# 或者: from pywikibot import Page [as 別名]
def run(self):
        """
        Starts the robot.
        """
        for bpnid in self.generator:
            if bpnid in self.completed:
                pywikibot.output(u'BPN id %s is already completed' % (bpnid,))
            elif bpnid in self.missingother:
                pywikibot.output(u'BPN id %s is used on an item, but other property is missing' % (bpnid,))
                self.addOtherProperty(bpnid)
            else:
                self.addBPNProperty(bpnid)

        self.missingtext = self.missingtext + u'\n\n[[Category:User:Multichill]]\n'
        if self.report:
            summary = u'Missing report'
            pywikibot.output(self.missingtext)

            reportpage = pywikibot.Page(self.repo, title=self.report)
            reportpage.put(self.missingtext , summary=summary) 
開發者ID:multichill,項目名稱:toollabs,代碼行數:22,代碼來源:biografisch_finder.py


注:本文中的pywikibot.Page方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。