From 33107c6a0163d917cbd7b5f4e33bf4532b08e376 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Thu, 20 Nov 2014 20:41:46 -0600 Subject: [PATCH] Add a lastrevid property to pages. --- earwigbot/wiki/page.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/earwigbot/wiki/page.py b/earwigbot/wiki/page.py index e314853..8167db2 100644 --- a/earwigbot/wiki/page.py +++ b/earwigbot/wiki/page.py @@ -50,6 +50,7 @@ class Page(CopyvioMixIn): - :py:attr:`pageid`: an integer ID representing the page - :py:attr:`url`: the page's URL - :py:attr:`namespace`: the page's namespace as an integer + - :py:attr:`lastrevid`: the ID of the page's most recent revision - :py:attr:`protection`: the page's current protection status - :py:attr:`is_talkpage`: ``True`` if this is a talkpage, else ``False`` - :py:attr:`is_redirect`: ``True`` if this is a redirect, else ``False`` @@ -464,6 +465,19 @@ class Page(CopyvioMixIn): return self._namespace @property + def lastrevid(self): + """The ID of the page's most recent revision. + + Raises :py:exc:`~earwigbot.exceptions.InvalidPageError` or + :py:exc:`~earwigbot.exceptions.PageNotFoundError` if the page name is + invalid or the page does not exist, respectively. + """ + if self._exists == self.PAGE_UNKNOWN: + self._load() + self._assert_existence() # Missing pages don't have revisions + return self._lastrevid + + @property def protection(self): """The page's current protection status.