Skip to content

Commit 85af2a4

Browse files
author
Nick Groenen
committed
Sprinkle in a few more docstrings
1 parent 65c1889 commit 85af2a4

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

err-secondlife.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def get_configuration_template(self):
4040

4141
@botcmd(split_args_with=None)
4242
def secondlife_friends(self, mess, args):
43+
"""Tells you which of your friends are currently online"""
4344
friends = self.mysl.friends_online()
4445
return str("You currently have {} friends online:\n{}".format(len(friends),
4546
"\n".join(friends).encode('utf-8', 'ignore')))

secondlife.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ class SigninError(MySecondLifeError):
2626

2727

2828
class MySecondLife(object):
29+
"""A wrapper around the SecondLife account pages (https://secondlife.com/my/account/)
30+
31+
Because SecondLife offers no API to a lot of the account-related data, we have
32+
to make do with ugly html scraping that's bound to break horribly whenever
33+
Linden Lab changes something.
34+
"""
2935
username = None
3036
password = None
3137

@@ -37,7 +43,9 @@ def __init__(self, username, password):
3743
self._request_page('http://secondlife.com/my/account/') # Ensures we're logged in
3844

3945
def _request_page(self, url):
40-
"""Requests an account-protected page"""
46+
"""Requests an account-protected page
47+
48+
Will perform a sign in if not yet signed in"""
4149
br = self.br
4250
br.open(url)
4351
if br.title() == "OpenId transaction in progress":
@@ -64,6 +72,7 @@ def _request_page(self, url):
6472
return BeautifulSoup(br.response().read())
6573

6674
def _extract_friends_from_html_soup(self, soup):
75+
"""Extract online friends from the html of the friends-online page"""
6776
friends = []
6877
friendsoup = soup.find_all("div", class_="main-content-body")
6978
assert len(friendsoup) == 1
@@ -75,6 +84,7 @@ def _extract_friends_from_html_soup(self, soup):
7584
return friends
7685

7786
def friends_online(self):
87+
"""Return a list of online friends"""
7888
html = self._request_page("https://secondlife.com/my/account/friends.php?")
7989
assert html.title.string == "Friends Online | Second Life"
8090
return self._extract_friends_from_html_soup(html)

0 commit comments

Comments
 (0)