#!/usr/local/bin/python # Encode the set of fixed keys as a colon-separated user/key pairs. This also # includes a command line utility to manipulate the DB. def read_key_db(file): """ Read the set of fixed keys fom the file """ keys = set() f = open(file, "r") for line in f: u, k = line.rstrip().split(':', 2) keys.add((u, k)) f.close() return keys def write_key_db(file, keys): """ Write the set of keys to the given file """ f = open(file, 'w') for t in keys: print >>f, "%s:%s" % t f.close() def read_project_db(file): """ Read the set of fixed keys fom the file """ projects = set() f = open(file, "r") for line in f: projects.add(line.rstrip()) f.close() return projects def write_project_db(file, projects): """ Write the set of keys to the given file """ f = open(file, 'w') for p in projects: print >>f, "%s" % p f.close()