本文整理汇总了Python中weboob.capabilities.messages.Thread.title方法的典型用法代码示例。如果您正苦于以下问题:Python Thread.title方法的具体用法?Python Thread.title怎么用?Python Thread.title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weboob.capabilities.messages.Thread
的用法示例。
在下文中一共展示了Thread.title方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: iter_threads
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import title [as 别名]
def iter_threads(self):
table = self.parser.select(self.document.getroot(), "table#listeMessages", 1)
for tr in table.xpath("./tr"):
if tr.attrib.get("class", "") not in ("msgLu", "msgNonLu"):
continue
author = unicode(self.parser.select(tr, "td.colEmetteur", 1).text)
link = self.parser.select(tr, "td.colObjet a", 1)
date_raw = self.parser.select(tr, "td.colDate1", 1).attrib["data"]
jsparams = re.search("\((.+)\)", link.attrib["onclick"]).groups()[0]
jsparams = [i.strip("'\" ") for i in jsparams.split(",")]
page_id, _id, unread = jsparams
# this means unread on the website
unread = False if unread == "false" else True
# 2012/02/29:01h30min45sec
dt_match = re.match("(\d+)/(\d+)/(\d+):(\d+)h(\d+)min(\d+)sec", date_raw).groups()
dt_match = [int(d) for d in dt_match]
thread = Thread(_id)
thread._link_id = (page_id, unread)
thread.date = datetime(*dt_match)
thread.title = unicode(link.text)
message = Message(thread, 0)
message.set_empty_fields(None)
message.flags = message.IS_HTML
message.title = thread.title
message.date = thread.date
message.sender = author
message.content = NotLoaded # This is the only thing we are missing
thread.root = message
yield thread
示例2: get_thread
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import title [as 别名]
def get_thread(self, id):
thr = Thread(id=id)
self.fill_thread(thr)
thr.date = thr.root.date
thr.title = thr.root.title
thr.url = thr.root.url
return thr
示例3: iter_threads
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import title [as 别名]
def iter_threads(self):
with self.browser:
for story in self.browser.iter_stories():
thread = Thread(story.id)
thread.title = story.title
thread.date = story.date
yield thread
示例4: get_thread
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import title [as 别名]
def get_thread(self, id, entry=None):
if isinstance(id, Thread):
thread = id
id = thread.id
else:
thread = Thread(id)
if entry is None:
entry = Newsfeed(self.config['url'].get()).get_entry(id)
if entry is None:
return None
flags = Message.IS_HTML
if not thread.id in self.storage.get('seen', default=[]):
flags |= Message.IS_UNREAD
if len(entry.content) > 0:
content = u"<p>Link %s</p> %s" % (entry.link, entry.content[0])
else:
content = entry.link
thread.title = entry.title
thread.root = Message(thread=thread,
id=0,
title=entry.title,
sender=entry.author,
receivers=None,
date=entry.datetime,
parent=None,
content=content,
children=[],
flags=flags)
return thread
示例5: iter_threads
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import title [as 别名]
def iter_threads(self):
for thread in self.browser.get_threads():
t = Thread(thread['id'])
t.flags = Thread.IS_DISCUSSION
t.title = u'Discussion with %s' % thread['name']
t.date = local2utc(datetime.datetime.fromtimestamp(thread['last_message']['utc_timestamp']))
yield t
示例6: get_thread
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import title [as 别名]
def get_thread(self, id):
if isinstance(id, Thread):
thread = id
id = thread.id
else:
thread = Thread(id)
entry = Newsfeed(self.config["url"]).get_entry(id)
flags = Message.IS_HTML
if not thread.id in self.storage.get('seen', default=[]):
flags |= Message.IS_UNREAD
if len(entry.content):
content = entry.content[0]
else:
content = None
thread.title = entry.title
thread.root = Message(thread=thread,
id=0,
title=entry.title,
sender=entry.author,
receivers=None,
date=entry.datetime,
parent=None,
content=content,
children=[],
flags=flags)
return thread
示例7: get_thread
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import title [as 别名]
def get_thread(self, id):
thread = None
parent = None
if isinstance(id, Thread):
thread = id
id = thread.id
thread_id = url2id(id, nopost=True) or id
try:
last_seen_id = self.storage.get('seen', default={})[id2topic(thread_id)]
except KeyError:
last_seen_id = 0
with self.browser:
for post in self.browser.iter_posts(id):
if not thread:
thread = Thread(thread_id)
thread.title = post.title
m = self._post2message(thread, post)
m.parent = parent
if last_seen_id < post.id:
m.flags |= Message.IS_UNREAD
if parent:
parent.children = [m]
else:
thread.root = m
parent = m
return thread
示例8: get_thread
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import title [as 别名]
def get_thread(self, _id):
thread = Thread(_id)
thread.title = 'Mail for %s' % _id
thread.flags = thread.IS_DISCUSSION
self._get_messages_thread(_id, thread)
return thread
示例9: iter_unread_messages
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import title [as 别名]
def iter_unread_messages(self):
try:
contacts = {}
with self.browser:
threads = self.browser.get_threads_list()
for thread in threads:
#if thread['member'].get('isBan', thread['member'].get('dead', False)):
# with self.browser:
# self.browser.delete_thread(int(thread['member']['id']))
# continue
if self.antispam and not self.antispam.check_thread(thread):
self.logger.info('Skipped a spam-unread-thread from %s' % thread['who']['pseudo'])
self.report_spam(thread['member']['id'])
continue
slut = self._get_slut(thread['who']['id'])
if parse_dt(thread['date']) > slut['lastmsg'] or thread['status'] != slut['status']:
t = self.get_thread(thread['who']['id'], contacts, get_profiles=True)
for m in t.iter_all_messages():
if m.flags & m.IS_UNREAD:
yield m
if not self.config['baskets'].get():
return
# Send mail when someone added me in her basket.
# XXX possibly race condition if a slut adds me in her basket
# between the aum.nb_new_baskets() and aum.get_baskets().
with self.browser:
slut = self._get_slut(-self.MAGIC_ID_BASKET)
new_baskets = self.browser.nb_new_baskets()
if new_baskets > 0:
baskets = self.browser.get_baskets()
my_name = self.browser.get_my_name()
for basket in baskets:
if parse_dt(basket['date']) <= slut['lastmsg']:
continue
contact = self.get_contact(basket['who']['id'])
if self.antispam and not self.antispam.check_contact(contact):
self.logger.info('Skipped a spam-basket from %s' % contact.name)
self.report_spam(basket['who']['id'])
continue
thread = Thread(int(basket['who']['id']))
thread.title = 'Basket of %s' % contact.name
thread.root = Message(thread=thread,
id=self.MAGIC_ID_BASKET,
title=thread.title,
sender=contact.name,
receivers=[my_name],
date=parse_dt(basket['date']),
content='You are taken in her basket!',
signature=contact.get_text(),
children=[],
flags=Message.IS_UNREAD)
yield thread.root
except BrowserUnavailable as e:
self.logger.debug('No messages, browser is unavailable: %s' % e)
pass # don't care about waiting
示例10: _build_thread
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import title [as 别名]
def _build_thread(self, data):
thread = Thread("%s.%s" % (data["commentable_id"], data["id"]))
thread.title = data["title"]
thread.date = dateutil.parser.parse(data["created_at"])
thread.url = self.browser.thread.build(course=self.browser.course, topic=data["commentable_id"], id=data["id"])
thread.root = self._build_message(data, thread)
thread._messages_count = data["comments_count"] + 1
return thread
示例11: iter_threads
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import title [as 别名]
def iter_threads(self):
for msg in self.browser.iter_dates():
thread = Thread(msg.id)
thread.title = msg.title
thread.date = msg.date
thread.root = msg
msg.thread = thread
yield thread
示例12: iter_threads
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import title [as 别名]
def iter_threads(self):
for thread in self.browser.get_threads():
if not "person" in thread:
# The account has been removed, probably because it was a
# spammer.
continue
t = Thread(thread["_id"])
t.flags = Thread.IS_DISCUSSION
t.title = u"Discussion with %s" % thread["person"]["name"]
contact = self.storage.get("contacts", t.id, default={"lastmsg": 0})
birthday = parse_date(thread["person"]["birth_date"]).date()
signature = u"Age: %d (%s)" % ((datetime.date.today() - birthday).days / 365.25, birthday)
signature += u"\nLast ping: %s" % parse_date(thread["person"]["ping_time"]).strftime("%Y-%m-%d %H:%M:%S")
signature += u"\nPhotos:\n\t%s" % "\n\t".join([photo["url"] for photo in thread["person"]["photos"]])
signature += u"\n\n%s" % thread["person"]["bio"]
t.root = Message(
thread=t,
id=1,
title=t.title,
sender=unicode(thread["person"]["name"]),
receivers=[self.browser.my_name],
date=parse_date(thread["created_date"]),
content=u"Match!",
children=[],
signature=signature,
flags=Message.IS_UNREAD if int(contact["lastmsg"]) < 1 else 0,
)
parent = t.root
for msg in thread["messages"]:
flags = 0
if int(contact["lastmsg"]) < msg["timestamp"]:
flags = Message.IS_UNREAD
msg = Message(
thread=t,
id=msg["timestamp"],
title=t.title,
sender=unicode(
self.browser.my_name if msg["from"] == self.browser.my_id else thread["person"]["name"]
),
receivers=[
unicode(self.browser.my_name if msg["to"] == self.browser.my_id else thread["person"]["name"])
],
date=parse_date(msg["sent_date"]),
content=unicode(msg["message"]),
children=[],
parent=parent,
signature=signature if msg["to"] == self.browser.my_id else u"",
flags=flags,
)
parent.children.append(msg)
parent = msg
yield t
示例13: iter_threads
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import title [as 别名]
def iter_threads(self):
threads = self.browser.get_threads_list()
for thread in threads:
t = Thread(thread['userid'])
t.flags = Thread.IS_DISCUSSION
t.title = u'Discussion with %s' % thread['user']['username']
t.date = datetime.fromtimestamp(thread['timestamp'])
yield t
示例14: get_thread
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import title [as 别名]
def get_thread(self, thread):
if not isinstance(thread, Thread):
thread = Thread(thread)
thread.flags = Thread.IS_DISCUSSION
info = self.browser.get_thread(thread.id)
for user in info['participants']:
if user['user']['fb_id'] is not None:
user['user']['fb'] = self.browser.get_facebook(user['user']['fb_id'])
if user['user']['id'] == self.browser.my_id:
me = HappnContact(user['user'])
else:
other = HappnContact(user['user'])
thread.title = u'Discussion with %s' % other.name
contact = self.storage.get('contacts', thread.id, default={'lastmsg_date': '1970-01-01T01:01:01+00:00'})
child = None
for msg in info['messages']:
flags = 0
if parse_date(contact['lastmsg_date']) < parse_date(msg['creation_date']):
flags = Message.IS_UNREAD
if msg['sender']['id'] == me.id:
sender = me
receiver = other
else:
sender = other
receiver = me
msg = Message(thread=thread,
id=msg['id'],
title=thread.title,
sender=sender.name,
receivers=[receiver.name],
date=parse_date(msg['creation_date']),
content=msg['message'],
children=[],
parent=None,
signature=sender.get_text(),
flags=flags)
if child:
msg.children.append(child)
child.parent = msg
child = msg
thread.root = child
return thread
示例15: get_thread
# 需要导入模块: from weboob.capabilities.messages import Thread [as 别名]
# 或者: from weboob.capabilities.messages.Thread import title [as 别名]
def get_thread(self, id, getseen=True):
if not isinstance(id, Thread):
thread = None
else:
thread = id
id = thread.id
# Check if we have seen all comments of this thread.
oldhash = self.storage.get('hash', id, default="")
newhash = self.browser.get_hash(thread._rsscomment)
if not getseen and oldhash == newhash:
return None
self.storage.set('hash', id, newhash)
if thread.date:
self.storage.set('date', id, thread.date)
self.storage.save()
with self.browser:
content = self.browser.get_content(id)
if not content:
return None
if not thread:
thread = Thread(content.id)
flags = Message.IS_HTML
if not thread.id in self.storage.get('seen', default={}):
flags |= Message.IS_UNREAD
thread.title = content.title
if not thread.date:
thread.date = content.date
thread.root = Message(thread=thread,
id='0', # root message
title=content.title,
sender=content.author or u'',
receivers=None,
date=thread.date,
parent=None,
content=content.body,
signature='URL: %s' % self.browser.absurl(id2url(content.id)),
children=[],
flags=flags)
for com in content.comments:
self._insert_comment(com, thread.root, getseen)
return thread