def get_languages(**kw): result = mw_call({ 'action': 'query', 'meta': 'siteinfo', 'siprop': 'languages', }, **kw) return result['languages']
def get_content(title, **kw): result = mw_call({"action": "query", "prop": "revisions", "titles": title, "rvprop": "content"}, **kw) page = result["pages"].values().pop() if "revisions" in page: revision = page["revisions"].pop() return revision["*"] else: return None
def get_allocations( project=None, language=None, country=None, anonymous=True, bucket='0' ): result = mw_call( { 'action': 'centralnoticeallocations', 'project': project, 'language': language, 'country': country, 'anonymous': anonymous, 'bucket': bucket, 'minimal': 'false' } ) return result['banners']
def get_campaign_logs( since=None, limit=50, offset=0 ): params = { 'action': 'query', 'list': 'centralnoticelogs', 'limit': limit, 'offset': offset, } if since: params['start'] = since result = mw_call( params ) return result['logs']
def get_campaign_logs(since=None, limit=50, offset=0): params = { 'action': 'query', 'list': 'centralnoticelogs', 'limit': limit, 'offset': offset, } if since: params['start'] = since result = mw_call(params) return result['logs']
def get_content(title, **kw): result = mw_call({ 'action': 'query', 'prop': 'revisions', 'titles': title, 'rvprop': 'content', }, **kw) page = result['pages'].values().pop() if 'revisions' in page: revision = page['revisions'].pop() return revision['*'] else: return None
def get_content(title, **kw): result = mw_call( { 'action': 'query', 'prop': 'revisions', 'titles': title, 'rvprop': 'content', }, **kw) page = result['pages'].values().pop() if 'revisions' in page: revision = page['revisions'].pop() return revision['*'] else: return None
def get_allocations(project=None, language=None, country=None, anonymous=True, bucket='0'): result = mw_call({ 'action': 'centralnoticeallocations', 'project': project, 'language': language, 'country': country, 'anonymous': anonymous, 'bucket': bucket, 'minimal': 'false' }) return result['banners']
def get_campaign( campaign ): #TODO: push caching down into mediawiki.mw_call, with optional invalidation global cached_campaigns if campaign in cached_campaigns: return cached_campaigns[campaign] #if '__iter__' in campaign: return get_campaigns result = mw_call( { 'action': 'centralnoticequerycampaign', 'campaign': campaign, } ) if campaign in result: result[campaign]['name'] = campaign cached_campaigns[campaign] = result[campaign] return cached_campaigns[campaign]
def get_campaign(campaign): #TODO: push caching down into mediawiki.mw_call, with optional invalidation global cached_campaigns if campaign in cached_campaigns: return cached_campaigns[campaign] #if '__iter__' in campaign: return get_campaigns result = mw_call({ 'action': 'centralnoticequerycampaign', 'campaign': campaign, }) if campaign in result: result[campaign]['name'] = campaign cached_campaigns[campaign] = result[campaign] return cached_campaigns[campaign]
def get_campaigns( campaigns ): #FIXME cache return mw_call( { 'action': 'centralnoticequerycampaign', 'campaign': '|'.join( campaigns ), } )
def get_campaigns(campaigns): #FIXME cache return mw_call({ 'action': 'centralnoticequerycampaign', 'campaign': '|'.join(campaigns), })