def strOfList(self, tinfo, cinfo=None): cl = self.List(tinfo, cinfo) if cl is None: return '错误:无法向 QQ 服务器获取联系人资料' if cinfo is None: cinfoStr = '' else: cinfoStr = '("%s")' % cinfo head = '%s%s:' % (rName(tinfo), cinfoStr) if not cl: return head + '空' result = [head] result.append('=' * 100) result.append('\t'.join(('类型', ) + CHSTAGS + EXCHSTAGS)) result.append('=' * 100) for c in cl: l = [CTYPES[c.ctype]] + \ [(getattr(c, tag[:-1], '') or '#') for tag in (TAGS+EXTAGS)] result.append('\t'.join(l)) result.append('=' * 100) return '\n'.join(result)
def Fetch(self, tinfo): rname, ttype = rName(tinfo), tType(tinfo) INFO('正在获取 %s ...', rname) try: if ttype == 'buddy': table = fetchBuddyTable(self) elif ttype == 'group': table = fetchGroupTable(self) elif ttype == 'discuss': table = fetchDiscussTable(self) elif ttype == 'group-member': table = fetchGroupMemberTable(self, tinfo) else: table = fetchDiscussMemberTable(self, tinfo) except RequestError: table = None except: ERROR('', exc_info=True) table = None if table is None: ERROR('获取 %s 失败', rname) return table
def Fetch(self, tinfo): rname, ttype = rName(tinfo), tType(tinfo) INFO('##正在获取 %s ...', rname) try: if ttype == 'buddy': table = fetchBuddyTable(self) elif ttype == 'group': table = fetchGroupTable(self) elif ttype == 'discuss': table = fetchDiscussTable(self) elif ttype == 'group-member': table = fetchGroupMemberTable(self, tinfo) else: table = fetchDiscussMemberTable(self, tinfo) except RequestError: table = None except: ERROR('', exc_info=True) table = None if table is None: ERROR('##获取 %s 失败', rname) return table
def strOfList(self, tinfo, cinfo=None): cl = self.List(tinfo, cinfo) if cl is None: return '错误:无法向 QQ 服务器获取联系人资料' if cinfo is None: cinfoStr = '' else: cinfoStr = '("%s")' % cinfo head = '%s%s:' % (rName(tinfo), cinfoStr) if not cl: return head + '空' pt = PrettyTable(('类型', ) + CHSTAGS + EXCHSTAGS) for c in cl: pt.addRow( [CTYPES[c.ctype]] + \ [(getattr(c, tag[:-1], '') or '') for tag in (TAGS+EXTAGS)] ) return head + '\n' + str(pt)
def strOfList(self, tinfo, cinfo=None): cl = self.List(tinfo, cinfo) if cl is None: return '错误:无法向 QQ 服务器获取联系人资料' if cinfo is None: cinfoStr = '' else: cinfoStr = '("%s")' % cinfo head = '%s%s:' % (rName(tinfo), cinfoStr) if not cl: return head + '空' pt = PrettyTable( ('类型',) + CHSTAGS + EXCHSTAGS ) for c in cl: pt.addRow( [CTYPES[c.ctype]] + \ [(getattr(c, tag[:-1], '') or '') for tag in (TAGS+EXTAGS)] ) return head + '\n' + str(pt)