3 from my_thread
import Thread
9 INTERFACE
= 'py.chans.dbus'
11 class WakabaThread(Thread
):
13 def __init__(self
, bus_name
, obj_path
, board
, id):
14 Thread
.__init
__(self
, bus_name
, obj_path
, board
, id)
16 #TODO: _normal_ parsing needs
17 @dbus.service
.method(dbus_interface
=INTERFACE
, in_signature
='', out_signature
='')
19 def get_posts_dicts():
20 def parse_msg_table(post_data
):
22 post
['id'] = re
.findall('<a name="([0-9]+)">', post_data
)[0]
27 img_src
= re
.findall('<a target="_blank" href="(.*?)">', post_data
)
29 post
['img_src'] = img_src
[0]
32 post
['text'] = re
.findall('<blockquote>(.*?)</blockquote>', post_data
)[0]
35 def get_msg_tables(data
):
36 return re
.findall('<table><tbody><tr><td class="doubledash">(.*?)</td></tr></tbody></table>', data
)
38 data
= urllib
.urlopen('%s/%s/res/%s.html' %(self
.board
.base_uri
, self
.board
.name
, self
.id)).read()
40 first_post
= re
.findall('(<div id="thread-.*?</blockquote>)', data
)[0]
41 posts
= [parse_msg_table(first_post
)]
42 for msg_table
in get_msg_tables(data
):
43 posts
.append(parse_msg_table(msg_table
))
47 posts_dicts
= get_posts_dicts()
48 for post_dict
in posts_dicts
:
49 self
.posts
.append( Post(bus_name
=self
.bus_name
, obj_path
=self
.obj_path
+'/'+ post_dict
['id'], post
=post_dict
) )