def get_languages(**kw):
    result = mw_call({
        'action': 'query',
        'meta': 'siteinfo',
        'siprop': 'languages',
    }, **kw)
    return result['languages']
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']
Esempio n. 6
0
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
Esempio n. 8
0
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
Esempio n. 9
0
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']
Esempio n. 10
0
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]
Esempio n. 11
0
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]
Esempio n. 12
0
def get_campaigns( campaigns ):
    #FIXME cache
    return mw_call( {
        'action': 'centralnoticequerycampaign',
        'campaign': '|'.join( campaigns ),
    } )
Esempio n. 13
0
def get_campaigns(campaigns):
    #FIXME cache
    return mw_call({
        'action': 'centralnoticequerycampaign',
        'campaign': '|'.join(campaigns),
    })