示例#1
0
文件: poll.py 项目: clugg/pspaw
def get(id):
    """
    Fetch an existing poll by querying the API with its ID.

    Args:
        id (int): ID of the poll.

    Returns:
        Poll: A new Poll instance with the poll's information.
    """

    return Poll(**request.get("http://strawpoll.me/api/v2/polls/{}".format(id)))
示例#2
0
文件: poll.py 项目: clugg/pspaw
    def refresh(self):
        """
        Fetch new data from the API and update the poll's results and total votes.

        Returns:
            None.
        """

        req = request.get("http://strawpoll.me/api/v2/polls/{}".format(self.id))
        options = req["options"] if "options" in req else []
        votes = req["votes"] if "votes" in req else []
        self._update_results(options, votes)