Changeset 827


Ignore:
Timestamp:
04/01/11 23:08:26 (7 years ago)
Author:
technomage
Message:

Patch by Technomage

  • Edited settings.py to expand any "~" (home directory) characters in configuration file paths;
  • Settings.read now raises an appropriate IOError when it cannot read a configuration file;
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/active/character_customization/game/parpg/settings.py

    r825 r827  
    168168            self.paths['system'], self.paths['user'] = self.platform_paths() 
    169169        else: 
    170             self.paths = {'system': system_path, 'user': user_path} 
     170            absolute_system_path = os.path.abspath( 
     171                os.path.expanduser(system_path) 
     172            ) 
     173            absolute_user_path = os.path.abspath( 
     174                os.path.expanduser(user_path) 
     175            ) 
     176            self.paths = {'system': absolute_system_path, 
     177                          'user': absolute_user_path} 
    171178 
    172179        self.read() 
     
    225232        for filename in filenames: 
    226233            section = None 
    227             try: 
    228                 self.settings_file = open(filename, 'r').readlines() 
    229             except IOError: 
    230                 pass 
    231  
     234            with open(filename, 'r') as settings_file: 
     235                self.settings_file = settings_file.readlines() 
    232236            for line in self.settings_file: 
    233237                if line.startswith('#') or line.strip() == '': 
Note: See TracChangeset for help on using the changeset viewer.