import os import json from src.address_book import AddressBook class Boss: def __init__(self): self.full_name = '' self.aliases = [] self.contact = None class Bosses: def __init__(self, data_folder): filename = os.path.join(data_folder, 'bosses.json') with open(filename, 'r') as f: data = json.load(f) self.bosses = [] addrs = AddressBook(data_folder) for b in data: boss = Boss() for k, val in b.items(): setattr(boss, k, val) boss.contact = addrs.find(boss.full_name) self.bosses.append(boss) def is_boss(self, name): for boss in self.bosses: if boss.full_name in name: return True for m in boss.contact.emails: if m in name: return True for a in boss.aliases: if a in name: return True return False