renamed source file trust/trustedroot.py into trust/trustedroots.py
[sfa.git] / sfa / trust / trustedroots.py
1 import os.path
2 import glob
3
4 from sfa.trust.gid import GID
5
6 class TrustedRootList:
7     def __init__(self, dir):
8         self.basedir = dir
9         # create the directory to hold the files, if not existing
10         if not os.path.isdir (self.basedir):
11             os.makedirs(self.basedir)
12
13     def add_gid(self, gid):
14         fn = os.path.join(self.basedir, gid.get_hrn() + ".gid")
15         gid.save_to_file(fn)
16
17     def get_list(self):
18         gid_list = [GID(filename=cert_file) for cert_file in self.get_file_list()]
19         return gid_list
20
21     def get_file_list(self):
22         file_list  = []
23         pattern=os.path.join(self.basedir,"*.gid")
24         for cert_file in glob.glob(pattern):
25             if os.path.isfile(cert_file):
26                 file_list.append(cert_file) 
27         return file_list