Small edit in order to test the git repo. NT.
[sfa.git] / sfa / trust / trustedroot.py
1 ### $Id$
2 ### $URL$
3
4 import os
5
6 from sfa.trust.gid import *
7
8 class TrustedRootList:
9     def __init__(self, dir):
10         self.basedir = dir
11         
12         # create the directory to hold the files
13         try:
14             os.makedirs(self.basedir)
15         # if the path already exists then pass
16         except OSError, (errno, strerr):
17             if errno == 17:
18                 pass
19
20     def add_gid(self, gid):
21         fn = os.path.join(self.basedir, gid.get_hrn() + ".gid")
22
23         gid.save_to_file(fn)
24
25     def get_list(self):
26         gid_list = []
27         file_list = os.listdir(self.basedir)
28         for gid_file in file_list:
29             fn = os.path.join(self.basedir, gid_file)
30             if os.path.isfile(fn):
31                 gid = GID(filename = fn)
32                 gid_list.append(gid)
33         return gid_list
34
35     def get_file_list(self):
36         gid_file_list = []
37         
38         file_list = os.listdir(self.basedir)
39         for gid_file in file_list:
40             fn = os.path.join(self.basedir, gid_file)
41             if os.path.isfile(fn):
42                 gid_file_list.append(fn)
43
44         return gid_file_list