api/scholar.py
def apply_settings(self, settings):
        """
        Applies settings as provided by a ScholarSettings instance.
        """
        if settings is None or not settings.is_configured():
            return True

        self.settings = settings

        # This is a bit of work. We need to actually retrieve the
        # contents of the Settings pane HTML in order to extract
        # hidden fields before we can compose the query for updating
        # the settings.
        html = self._get_http_response(url=self.GET_SETTINGS_URL,
                                       log_msg='dump of settings form HTML',
                                       err_msg='requesting settings failed')
        if html is None:
            return False

        # Now parse the required stuff out of the form. We require the
        # "scisig" token to make the upload of our settings acceptable
        # to Google.
        soup = BeautifulSoup(html)

        tag = soup.find(name='form', attrs={'id': 'gs_settings_form'})
        if tag is None:
            ScholarUtils.log('info', 'parsing settings failed: no form')
            return False

        tag = tag.find('input', attrs={'type':'hidden', 'name':'scisig'})
        if tag is None:
            ScholarUtils.log('info', 'parsing settings failed: scisig')
            return False

        urlargs = {'scisig': tag['value'],
                   'num': settings.per_page_results,
                   'scis': 'no',
                   'scisf': ''}

        if settings.citform != 0:
            urlargs['scis'] = 'yes'
            urlargs['scisf'] = '&scisf=%d' % settings.citform

        html = self._get_http_response(url=self.SET_SETTINGS_URL % urlargs,
                                       log_msg='dump of settings result HTML',
                                       err_msg='applying setttings failed')
        if html is None:
            return False

        ScholarUtils.log('info', 'settings applied')
        return True

        Applies settings as provided by a ScholarSettings instance.
        
Applies settings as provided by a ScholarSettings instance.
Applies settings as provided by a ScholarSettings instance .
def apply_settings(self, settings):
        if settings is None or not settings.is_configured():
            return True
        self.settings = settings
        html = self._get_http_response(url=self.GET_SETTINGS_URL,
                                       log_msg='dump of settings form HTML',
                                       err_msg='requesting settings failed')
        if html is None:
            return False
        soup = BeautifulSoup(html)
        tag = soup.find(name='form', attrs={'id': 'gs_settings_form'})
        if tag is None:
            ScholarUtils.log('info', 'parsing settings failed: no form')
            return False
        tag = tag.find('input', attrs={'type':'hidden', 'name':'scisig'})
        if tag is None:
            ScholarUtils.log('info', 'parsing settings failed: scisig')
            return False
        urlargs = {'scisig': tag['value'],
                   'num': settings.per_page_results,
                   'scis': 'no',
                   'scisf': ''}
        if settings.citform != 0:
            urlargs['scis'] = 'yes'
            urlargs['scisf'] = '&scisf=%d' % settings.citform
        html = self._get_http_response(url=self.SET_SETTINGS_URL % urlargs,
                                       log_msg='dump of settings result HTML',
                                       err_msg='applying setttings failed')
        if html is None:
            return False
        ScholarUtils.log('info', 'settings applied')
        return True
def apply_settings ( self , settings ) : if settings is None or not settings . is_configured ( ) : return True self . settings = settings html = self . _get_http_response ( url = self . GET_SETTINGS_URL , log_msg = 'dump of settings form HTML' , err_msg = 'requesting settings failed' ) if html is None : return False soup = BeautifulSoup ( html ) tag = soup . find ( name = 'form' , attrs = { 'id' : 'gs_settings_form' } ) if tag is None : ScholarUtils . log ( 'info' , 'parsing settings failed: no form' ) return False tag = tag . find ( 'input' , attrs = { 'type' : 'hidden' , 'name' : 'scisig' } ) if tag is None : ScholarUtils . log ( 'info' , 'parsing settings failed: scisig' ) return False urlargs = { 'scisig' : tag [ 'value' ] , 'num' : settings . per_page_results , 'scis' : 'no' , 'scisf' : '' } if settings . citform != 0 : urlargs [ 'scis' ] = 'yes' urlargs [ 'scisf' ] = '&scisf=%d' % settings . citform html = self . _get_http_response ( url = self . SET_SETTINGS_URL % urlargs , log_msg = 'dump of settings result HTML' , err_msg = 'applying setttings failed' ) if html is None : return False ScholarUtils . log ( 'info' , 'settings applied' ) return True
Applies settings as provided by a ScholarSettings instance.
Applies settings as provided by a ScholarSettings instance .
"""
        Applies settings as provided by a ScholarSettings instance.
        """ # This is a bit of work. We need to actually retrieve the # contents of the Settings pane HTML in order to extract # hidden fields before we can compose the query for updating # the settings. # Now parse the required stuff out of the form. We require the # "scisig" token to make the upload of our settings acceptable # to Google.
self
settings