(self,program,defaults)
return
Find and load the preferences file
Find and load the preferences file
Find and load the preferences file
def __init__(self,program,defaults):

        """Find and load the preferences file"""

        filename='.'+program+'_preferences'
        dirs=self.get_dirs()
        self.noprefs = False
        try:
            for ldir in dirs:
                fn=os.path.join(ldir,filename)
                if os.path.isfile(fn):
                    self.load_prefs(fn)
                    #self.save_prefs()
                    return
                else:
                    self.noprefs = True
            if self.noprefs == True:
                raise
        except:
            # If we didn't find a file then set to default and save
            print ('Did not find preferences!!!')
            self.prefs=defaults.copy()
            self.pref_file=os.path.join(dirs[0],filename)
            self.prefs['_prefdir']=dirs[0]
            self.prefs['_preffile']=self.pref_file
            self.save_prefs()
            # Defaults savedir?
            if 'HOMEPATH' in os.environ:
                self.prefs['datadir']=os.environ['HOMEPATH']
            if 'HOME' in os.environ:
                self.prefs['datadir']=os.environ['HOME']
            if hasattr(self.prefs,'datadir'):
                mydocs=os.path.join(self.prefs['datadir'],'My Documents')
                if os.path.isdir(mydocs):
                    self.prefs['datadir']=mydocs
            self.save_prefs()
        return
def __init__ ( self , program , defaults ) : filename = '.' + program + '_preferences' dirs = self . get_dirs ( ) self . noprefs = False try : for ldir in dirs : fn = os . path . join ( ldir , filename ) if os . path . isfile ( fn ) : self . load_prefs ( fn ) #self.save_prefs() return else : self . noprefs = True if self . noprefs == True : raise except : # If we didn't find a file then set to default and save print ( 'Did not find preferences!!!' ) self . prefs = defaults . copy ( ) self . pref_file = os . path . join ( dirs [ 0 ] , filename ) self . prefs [ '_prefdir' ] = dirs [ 0 ] self . prefs [ '_preffile' ] = self . pref_file self . save_prefs ( ) # Defaults savedir? if 'HOMEPATH' in os . environ : self . prefs [ 'datadir' ] = os . environ [ 'HOMEPATH' ] if 'HOME' in os . environ : self . prefs [ 'datadir' ] = os . environ [ 'HOME' ] if hasattr ( self . prefs , 'datadir' ) : mydocs = os . path . join ( self . prefs [ 'datadir' ] , 'My Documents' ) if os . path . isdir ( mydocs ) : self . prefs [ 'datadir' ] = mydocs self . save_prefs ( ) return