Version `0.3.1` (2013-07-12):
* __upd__: `diaspy.people.sephandle()` raises `InvalidHandleError` instead of `UserError`
+* __upd__: `models.Post()._fetch()` renamed to `_fetchdata()` (because of new `_fetchcomments()` method)
* __new__: `models.Comment()` object: wrapper for comments, not to be created manually
* __new__: `comments` parameter in `models.Post`: defines whether to fetch post's commets
* __new__: `connection.Connection` has new parameter in `__init__()`: it's `schema`
"""
_who_regexp = re.compile(r'/people/[0-9a-z]+" class=\'hovercardable')
_when_regexp = re.compile(r'[0-9]{4,4}(-[0-9]{2,2}){2,2} [0-9]{2,2}(:[0-9]{2,2}){2,2} UTC')
+ _aboutid_regexp = re.compile(r'/posts/[0-9]+')
def __init__(self, connection, data):
self._connection = connection
def __str__(self):
"""Returns notification note.
"""
- print(self.data['note_html'])
- string = re.sub('</?[a-z]+( *[a-z_-]+=["\'][\w():.,!?#/\- ]*["\'])* */?>', '', self.data['note_html'])
+ string = re.sub('</?[a-z]+( *[a-z_-]+=["\'][\w():.,!?#@=/\- ]*["\'])* */?>', '', self.data['note_html'])
string = string.strip().split('\n')[0]
while ' ' in string: string = string.replace(' ', ' ')
return string
"""
return '{0}: {1}'.format(self.when(), str(self))
+ def about(self):
+ """Returns id of post about which the notification is informing.
+ """
+ about = self._aboutid_regexp.search(self.data['note_html'])
+ if about is None: about = self.who()
+ else: about = int(about.group(0)[7:])
+ return about
+
def who(self):
"""Returns list of guids of the users who caused you to get the notification.
"""
"""Object representing generic stream.
"""
_location = 'stream.json'
- _stream = []
- # since epoch
- max_time = int(time.mktime(time.gmtime()))
def __init__(self, connection, location=''):
"""
"""
self._connection = connection
if location: self._location = location
+ self._stream = []
+ # since epoch
+ self.max_time = int(time.mktime(time.gmtime()))
self.fill()
def __contains__(self, post):
"""
if type(post) == str: self._delid(post)
elif type(post) == Post: post.delete()
- else:
- raise TypeError('this method accepts str or Post types: {0} given')
+ else: raise TypeError('this method accepts str or Post types: {0} given')
self.fill()