source: fedd/federation/fixed_resource.py @ 227f558

axis_examplecompt_changesinfo-opsversion-1.30version-2.00version-3.01version-3.02
Last change on this file since 227f558 was 5d3f239, checked in by Ted Faber <faber@…>, 16 years ago

change package name to avoid conflicts with fedd on install

  • Property mode set to 100644
File size: 960 bytes
RevLine 
[afa43a8]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
[159a447]6def read_key_db(file):
[afa43a8]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
[159a447]19def write_key_db(file, keys):
[afa43a8]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
[159a447]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()
Note: See TracBrowser for help on using the repository browser.