check in missing files
[sfa.git] / util / trustedroot.py
1 import os
2
3 from gid import *
4
5 class TrustedRootList():
6     def __init__(self, basedir="."):
7         self.basedir = os.path.join(basedir, "trusted_roots")
8
9         # create the directory to hold the files
10         try:
11             os.makedirs(self.basedir)\r
12         # if the path already exists then pass\r
13         except OSError, (errno, strerr):\r
14             if errno == 17:\r
15                 pass
16
17     def add_gid(self, gid):
18         fn = os.path.join(self.basedir, gid.get_hrn() + ".gid")
19
20         gid.save_to_file(fn)
21
22     def get_list(self):
23         gid_list = []
24
25         file_list = os.listdir(self.basedir)
26         for gid_file in file_list:
27             fn = os.path.join(self.basedir, gid_file)
28             if os.path.isfile(fn):
29                 gid = GID(filename = fn)
30                 gid_list.append(gid)
31
32         return gid_list
33