(self, file_name)
Replace all the default values with one from a file.
Replace all the default values with one from a file.
Replace all the default values with one from a file .
def _update_from_file(self, file_name):
        """Replace all the default values with one from a file."""
        with TextFile(file_name, 'r') as f:
            config_lines = f.readlines(as_unicode=PYTHON_VERSION > 2)

        for line in config_lines:
            line = line.split('//')[0].strip()
            if not line:
                continue
                
            if line[0] == '[' and line[-1] == ']':
                heading = line[1:-1]
            else:
                try:
                    variable, value = (i.strip() for i in line.split('=', 1))
                except ValueError:
                    continue

                #Make sure it's a valid config item
                try:
                    self[heading][variable] = value
                except UnboundLocalError:
                    raise RuntimeError('error parsing ini file, current line = {}'.format(line))
                except KeyError:
                    pass
                else:
                    self._backup[heading][variable] = value
def _update_from_file ( self , file_name ) : with TextFile ( file_name , 'r' ) as f : config_lines = f . readlines ( as_unicode = PYTHON_VERSION > 2 ) for line in config_lines : line = line . split ( '//' ) [ 0 ] . strip ( ) if not line : continue if line [ 0 ] == '[' and line [ - 1 ] == ']' : heading = line [ 1 : - 1 ] else : try : variable , value = ( i . strip ( ) for i in line . split ( '=' , 1 ) ) except ValueError : continue #Make sure it's a valid config item try : self [ heading ] [ variable ] = value except UnboundLocalError : raise RuntimeError ( 'error parsing ini file, current line = {}' . format ( line ) ) except KeyError : pass else : self . _backup [ heading ] [ variable ] = value