source: fedd/federation/fixed_resource.py @ 2ac63f7d

axis_examplecompt_changesinfo-opsversion-1.30version-2.00version-3.01version-3.02
Last change on this file since 2ac63f7d was 08329f4, checked in by Ted Faber <faber@…>, 16 years ago

dynamic projects and multiple keys

  • Property mode set to 100644
File size: 1.0 KB
Line 
1#!/usr/local/bin/python
2
3# Encode the set of fixed keys as a colon-separated user/key pairs.  This also
4# includes a command line utility to manipulate the DB.
5
6def read_key_db(file):
7    """
8    Read the set of fixed keys fom the file
9    """
10    keys = set()
11
12    f = open(file, "r")
13    for line in f:
14        u, k = line.rstrip().split(':', 2)
15        keys.add((u, k))
16    f.close()
17    return keys
18
19def write_key_db(file, keys):
20    """
21    Write the set of keys to the given file
22    """
23
24    f = open(file, 'w')
25    for t in keys:
26        print >>f, "%s:%s" % t
27    f.close()
28
29def read_project_db(file):
30    """
31    Read the set of fixed keys fom the file
32    """
33    projects = set()
34
35    f = open(file, "r")
36    for line in f:
37        projects.add(line.rstrip())
38    f.close()
39    return projects
40
41def write_project_db(file, projects):
42    """
43    Write the set of keys to the given file
44    """
45
46    f = open(file, 'w')
47    for p in projects:
48        print >>f, "%s" % p
49    f.close()
50
51read_user_db = read_project_db
52write_user_db = write_project_db
Note: See TracBrowser for help on using the repository browser.