コード例 #1
0
 def testToAndFromString(self):
     entry = webmastertools.SitesEntry(
         indexed=webmastertools.Indexed(text='true'),
         crawled=webmastertools.Crawled(text='2008-09-14T08:59:28.000'),
         geolocation=webmastertools.GeoLocation(text='US'),
         preferred_domain=webmastertools.PreferredDomain(text='none'),
         crawl_rate=webmastertools.CrawlRate(text='normal'),
         enhanced_image_search=webmastertools.EnhancedImageSearch(
             text='true'),
         verified=webmastertools.Verified(text='false'),
     )
     self.assert_(entry.indexed.text == 'true')
     self.assert_(entry.crawled.text == '2008-09-14T08:59:28.000')
     self.assert_(entry.geolocation.text == 'US')
     self.assert_(entry.preferred_domain.text == 'none')
     self.assert_(entry.crawl_rate.text == 'normal')
     self.assert_(entry.enhanced_image_search.text == 'true')
     self.assert_(entry.verified.text == 'false')
     new_entry = webmastertools.SitesEntryFromString(entry.ToString())
     self.assert_(new_entry.indexed.text == 'true')
     self.assert_(new_entry.crawled.text == '2008-09-14T08:59:28.000')
     self.assert_(new_entry.geolocation.text == 'US')
     self.assert_(new_entry.preferred_domain.text == 'none')
     self.assert_(new_entry.crawl_rate.text == 'normal')
     self.assert_(new_entry.enhanced_image_search.text == 'true')
     self.assert_(new_entry.verified.text == 'false')
コード例 #2
0
ファイル: service.py プロジェクト: hyeonukbhin/youtube-cli
    def UpdatePreferredDomain(self,
                              site_uri,
                              preferred_domain,
                              uri=SITE_TEMPLATE,
                              url_params=None,
                              escape_params=True,
                              converter=None):
        """Updates preferred domain setting of a site.

        Note that if using 'preferwww', will also need www.example.com in account to
        take effect.

        Args:
          site_uri: str URI of which site to add sitemap for.
          preferred_domain: str The preferred domain for a site. Valid values are 'none',
                            'preferwww', and 'prefernowww'.
          uri: str (optional) URI template to update a site.
               Default SITE_TEMPLATE.
          url_params: dict (optional) Additional URL parameters to be included
                      in the insertion request.
          escape_params: boolean (optional) If true, the url_parameters will be
                         escaped before they are included in the request.
          converter: func (optional) Function which is executed on the server's
              response before it is returned. Usually this is a function like
              SitemapsEntryFromString which will parse the response and turn it into
              an object.

        Returns:
          If converter is defined, the results of running converter on the server's
          response. Otherwise, it will be a SitesEntry object.
        """

        site_entry = webmastertools.SitesEntry(
            atom_id=atom.Id(text=site_uri),
            category=atom.Category(
                scheme='http://schemas.google.com/g/2005#kind',
                term=
                'http://schemas.google.com/webmasters/tools/2007#sites-info'),
            preferred_domain=webmastertools.PreferredDomain(
                text=preferred_domain))
        response = self.Put(site_entry,
                            uri % urllib.quote_plus(site_uri),
                            url_params=url_params,
                            escape_params=escape_params,
                            converter=converter)
        if not converter and isinstance(response, atom.Entry):
            return webmastertools.SitesEntryFromString(response.ToString())
        return response
コード例 #3
0
 def setUp(self):
     self.preferred_domain = webmastertools.PreferredDomain()