예제 #1
0
    def loadcontent(self, identification, *props):
        """
        Fetch the current content of a Wikibase item.

        This is called loadcontent since
        wbgetentities does not support fetching old
        revisions. Eventually this will get replaced by
        an actual loadrevisions.

        :param identification: Parameters used to identify the page(s)
        :type identification: dict
        :param props: the optional properties to fetch.
        """
        params = merge_unique_dicts(
            identification,
            action='wbgetentities',
            # TODO: When props is empty it results in
            # an empty string ('&props=') but it should
            # result in a missing entry.
            props=props if props else False)
        req = self._simple_request(**params)
        data = req.submit()
        if 'success' not in data:
            raise APIError(data['errors'], '')
        return data['entities']
예제 #2
0
    def thank_post(self, post):
        """Corresponding method to the 'action=flowthank' API action.

        :param post: The post to be thanked for.
        :type post: Post
        :raise APIError: On thanking oneself or other API errors.
        :return: The API response.
        """
        post_id = post.uuid
        token = self.tokens['csrf']
        req = self._simple_request(action='flowthank',
                                   postid=post_id,
                                   token=token)
        data = req.submit()
        if data['result']['success'] != 1:
            raise APIError('Thanking unsuccessful', '')
        return data
예제 #3
0
    def thank_revision(self, revid, source=None):
        """Corresponding method to the 'action=thank' API action.

        :param revid: Revision ID for the revision to be thanked.
        :type revid: int
        :param source: A source for the thanking operation.
        :type source: str
        :raise APIError: On thanking oneself or other API errors.
        :return: The API response.
        """
        token = self.tokens['csrf']
        req = self._simple_request(action='thank',
                                   rev=revid,
                                   token=token,
                                   source=source)
        data = req.submit()
        if data['result']['success'] != 1:
            raise APIError('Thanking unsuccessful', '')
        return data