def save_token(self, user, token):
        """Save the token on the config file."""
        self.config.set('auth', 'user', user)
        self.config.set('auth', 'token', token)
        # allow_no_value=True is used to keep the comments on the config file.
        new_config = ConfigParser(allow_no_value=True)

        # Parse the config file. If no config file was found, then create some
        # default sections on the config variable.
        new_config.read(self.config_file)
        self.check_sections(new_config)

        new_config.set('auth', 'user', user)
        new_config.set('auth', 'token', token)
        filename = os.path.expanduser(self.config_file)
        with open(filename, 'w') as out_file:
            os.chmod(filename, 0o0600)
            new_config.write(out_file)
def save_token ( self , user , token ) : self . config . set ( 'auth' , 'user' , user ) self . config . set ( 'auth' , 'token' , token ) new_config = ConfigParser ( allow_no_value = True ) new_config . read ( self . config_file ) self . check_sections ( new_config ) new_config . set ( 'auth' , 'user' , user ) new_config . set ( 'auth' , 'token' , token ) filename = os . path . expanduser ( self . config_file ) with open ( filename , 'w' ) as out_file : os . chmod ( filename , 0o0600 ) new_config . write ( out_file )
Save the token on the config file.