Преглед изворни кода

Finished docstrings in wikitools.

tags/v0.1^2
Ben Kurtovic пре 12 година
родитељ
комит
a7367856ee
2 измењених фајлова са 27 додато и 3 уклоњено
  1. +14
    -2
      wiki/tools/category.py
  2. +13
    -1
      wiki/tools/site.py

+ 14
- 2
wiki/tools/category.py Прегледај датотеку

@@ -5,11 +5,23 @@ from wiki.tools.page import Page
class Category(Page):
"""
EarwigBot's Wiki Toolset: Category Class

Represents a Category on a given Site, a subclass of Page. Provides
additional methods, but Page's own methods should work fine on Category
objects. Site.get_page() will return a Category instead of a Page if the
given title is in the category namespace; get_category() is shorthand,
because it accepts category names without the namespace prefix.

Public methods:
members -- returns a list of titles in the category
"""

def members(self, limit=50):
"""
Docstring needed
"""Returns a list of titles in the category.

If `limit` is provided, we will provide this many titles, or less if
the category is too small. `limit` defaults to 50; normal users can go
up to 500, and bots can go up to 5,000 on a single API query.
"""
params = {"action": "query", "list": "categorymembers",
"cmlimit": limit, "cmtitle": self.title}


+ 13
- 1
wiki/tools/site.py Прегледај датотеку

@@ -24,6 +24,18 @@ class Site(object):
won't need to call it directly, rather tools.get_site() for returning Site
instances, tools.add_site() for adding new ones to config, and
tools.del_site() for removing old ones from config, should suffice.

Public methods:
name -- returns our name (or "wikiid"), like "enwiki"
project -- returns our project name, like "wikipedia"
lang -- returns our language code, like "en"
domain -- returns our web domain, like "en.wikipedia.org"
api_query -- does an API query with the given kwargs as params
namespace_id_to_name -- given a namespace ID, returns associated name(s)
namespace_name_to_id -- given a namespace name, returns associated id
get_page -- returns a Page object for the given title
get_category -- returns a Category object for the given title
get_user -- returns a User object for the given username
"""

def __init__(self, name=None, project=None, lang=None, base_url=None,
@@ -351,7 +363,7 @@ class Site(object):
return self._project

def lang(self):
"""Returns the Site's language, like "en" or "es"."""
"""Returns the Site's language code, like "en" or "es"."""
return self._lang

def domain(self):


Loading…
Откажи
Сачувај