How to use the apraw.utils.prepend_kind function in aPRAW

To help you get started, we’ve selected a few aPRAW examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Dan6erbond / aPRAW / tests / unit / utils / test_kind.py View on Github external
def test_prepend_kind(self):
        kind = "kind"
        uuid1 = str(uuid.uuid1())

        prepended_id = kind + "_" + uuid1

        assert prepend_kind(uuid1, kind) == prepended_id
        assert prepend_kind(prepended_id, kind) == prepended_id
github Dan6erbond / aPRAW / tests / unit / utils / test_kind.py View on Github external
def test_prepend_kind(self):
        kind = "kind"
        uuid1 = str(uuid.uuid1())

        prepended_id = kind + "_" + uuid1

        assert prepend_kind(uuid1, kind) == prepended_id
        assert prepend_kind(prepended_id, kind) == prepended_id
github Dan6erbond / aPRAW / apraw / models / helpers / apraw_base.py View on Github external
def fullname(self):
        return prepend_kind(self._data[self.ID_ATTRIBUTE], self.kind) if self.kind else self._data[self.ID_ATTRIBUTE]
github Dan6erbond / aPRAW / apraw / reddit.py View on Github external
Get a `Submission` object based on its ID or URL.

        Parameters
        ----------
        id: str
            The ID of a submission (with or without kind).
        url: str
            The URL of a submission.

        Returns
        -------
        submission: Submission
            The requested submission.
        """
        if id != "":
            async for link in self.info(prepend_kind(id, self.link_kind)):
                return link
        elif url != "":
            async for link in self.info(url=url):
                return link
        return None
github Dan6erbond / aPRAW / apraw / models / reddit / comment.py View on Github external
Returns
        -------
        self: Comment
            The ``Comment`` model with updated data.
        """
        if ("link_id" in self._data and "id" in self._data and "subreddit" in self._data) or "permalink" in self._data:
            permalink = self._data["permalink"] if "permalink" in self._data else API_PATH["comment"].format(
                sub=self._data["subreddit"], submission=self._data["link_id"].replace(self._reddit.link_kind + "_", ""),
                id=self._data["id"])
            resp = await self._reddit.get_request(permalink)
            from .submission import Submission
            self._submission = Submission(self._reddit, resp[0]["data"]["children"][0]["data"])
            return self._update(resp[1]["data"]["children"][0]["data"])
        elif "id" in self._data:
            resp = await self._reddit.get_request(API_PATH["info"],
                                                  id=prepend_kind(self._data["id"], self._reddit.comment_kind))
            return self._update(resp["data"]["children"][0]["data"])
        else:
            raise ValueError(f"No data available to make request URL: {self._data}")
github Dan6erbond / aPRAW / apraw / models / reddit / submission.py View on Github external
async def fetch(self):
        """
        Fetch this item's information from a suitable API endpoint.

        Returns
        -------
        self: Submission
            The updated model.
        """
        if "subreddit" in self._data and "id" in self._data:
            resp = await self._reddit.get_request(
                API_PATH["submission"].format(sub=self._data["subreddit"], id=self._data["id"]))
            self._update(resp)
        elif "id" in self._data:
            resp = await self._reddit.get_request(API_PATH["info"],
                                                  id=prepend_kind(self._data["id"], self._reddit.link_kind))
            self._update(resp["data"]["children"][0]["data"])
        return self