import os

from gid import *
from geni.util.config import Config

class TrustedRootList():
    def __init__(self, dir=None):
        if not dir:
            config = Config()
            self.basedir = config.path + os.sep + 'trusted_roots'
        else:
            self.basedir = dir
        # create the directory to hold the files
        try:
            os.makedirs(self.basedir)
        # if the path already exists then pass
        except OSError, (errno, strerr):
            if errno == 17:
                pass

    def add_gid(self, gid):
        fn = os.path.join(self.basedir, gid.get_hrn() + ".gid")

        gid.save_to_file(fn)

    def get_list(self):
        gid_list = []

        file_list = os.listdir(self.basedir)
        for gid_file in file_list:
            fn = os.path.join(self.basedir, gid_file)
            if os.path.isfile(fn):
                gid = GID(filename = fn)
                gid_list.append(gid)

        return gid_list


@@ -176,33 +176,24 @@
             
-self.base
 dir = config
@@ -193,16 +193,20 @@
  config.
+base
 path + o
@@ -233,26 +233,8 @@
 ts'%0A
-        else:%0A    
     
@@ -256,16 +256,25 @@
 r = dir%0A
+        %0A
         

fix trusted_roots path