def test_readComponents(self): """ Test if reading components correctly """ cal = next(readComponents(self.simple_test_cal)) self.assertEqual(str(cal), "<VCALENDAR| [<VEVENT| [<SUMMARY{'BLAH': ['hi!']}Bastille Day Party>]>]>") self.assertEqual(str(cal.vevent.summary), "<SUMMARY{'BLAH': ['hi!']}Bastille Day Party>")
def vcard_find(tel): f = codecs.open(addresses, 'r', encoding='UTF-8') try: vcards = readComponents(f) tel = tel_normalize(tel) for vc in vcards: t = getattr(vc, 'tel_list', None) if t: for i in t: if tel == tel_normalize(i.value): return vc finally: f.close()