def load_pseudonyms(): global GENERATE_NEW dirs = [os.path.abspath(os.path.dirname(fn)) for fn in sys.argv] dirs = list(set(dirs)) for dir_ in dirs: fn = os.path.join(dir_, "pseudonyms.csv") try: reader = csv.reader(open(fn, 'r')) except IOError: continue print("Reading pseudonyms from %s" % fn) for line in reader: if len(line) > 0: try: LOOKUP[int(line[0])] = int(line[1]) except ValueError: pass num_loaded = len(LOOKUP) if num_loaded == 0: print("I haven't loaded any pseudonyms, should I just generate a " "pseudonym for every NHS number I encounter?") if raw_input("Type y or n: ") == 'y': GENERATE_NEW = True else: print("Loaded %d pseudonyms NHS numbers." % num_loaded) GENERATE_NEW = False