当前位置: 首页>>代码示例>>Python>>正文


Python atom.Title方法代码示例

本文整理汇总了Python中atom.Title方法的典型用法代码示例。如果您正苦于以下问题:Python atom.Title方法的具体用法?Python atom.Title怎么用?Python atom.Title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在atom的用法示例。


在下文中一共展示了atom.Title方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: PrintAllPosts

# 需要导入模块: import atom [as 别名]
# 或者: from atom import Title [as 别名]
def PrintAllPosts(self):
    """This method displays the titles of all the posts in a blog.  First it
    requests the posts feed for the blogs and then it prints the results.
    """

    # Request the feed.
    feed = self.service.GetFeed('/feeds/' + self.blog_id + '/posts/default')

    # Print the results.
    print feed.title.text
    for entry in feed.entry:
      if not entry.title.text:
        print "\tNo Title"
      else:
        print "\t" + entry.title.text
    print 
开发者ID:ActiveState,项目名称:code,代码行数:18,代码来源:recipe-576441.py

示例2: UpdatePostTitle

# 需要导入模块: import atom [as 别名]
# 或者: from atom import Title [as 别名]
def UpdatePostTitle(self, entry_to_update, new_title):
    """This method updates the title of the given post.  The GDataEntry object
    is updated with the new title, then a request is sent to the GDataService.
    If the insertion is successful, the updated post will be returned.

    Note that other characteristics of the post can also be modified by
    updating the values of the entry object before submitting the request.

    The entry_to_update is a GDatEntry containing the post to update.
    The new_title is the text to use for the post's new title.  Returns: a
    GDataEntry containing the newly-updated post.
    """
    
    # Set the new title in the Entry object
    entry_to_update.title = atom.Title('xhtml', new_title)
    
    # Grab the edit URI
    edit_uri = entry_to_update.GetEditLink().href  

    return self.service.Put(entry_to_update, edit_uri) 
开发者ID:ActiveState,项目名称:code,代码行数:22,代码来源:recipe-576441.py

示例3: copy2google

# 需要导入模块: import atom [as 别名]
# 或者: from atom import Title [as 别名]
def copy2google(pair,gd_client):
    
    album_g = strip_album_name(pair.album)
    try:        
        gd_client.GetFeed('/data/feed/api/user/default/album/' + album_g)
    except gdata.photos.service.GooglePhotosException as GPE:
        if GPE.body == 'No album found.':
            gd_client.InsertAlbum(title=pair.album,summary='')            
        else:
            raise
            
    album_url           = '/data/feed/api/user/default/album/' + album_g
    local_full_path     = os.path.join(pair.local_path,pair.local_fn)
    mimetype            = mimetypes.guess_type(local_full_path, strict=True)[0]
    photoentry          = gdata.photos.PhotoEntry()
    photoentry.title    = atom.Title(text=pair.local_fn)
    photoentry.summary  = atom.Summary(text='',summary_type='text')    
    photo               = gd_client.InsertPhoto(album_url,photoentry,local_full_path,mimetype)     

    return photo 
开发者ID:wavemaking,项目名称:GooglePhotosSync,代码行数:22,代码来源:operations.py

示例4: testCreateUpdateDeleteGroup

# 需要导入模块: import atom [as 别名]
# 或者: from atom import Title [as 别名]
def testCreateUpdateDeleteGroup(self):
    if not conf.settings.RUN_LIVE_TESTS:
      return
    conf.configure_service_cache(self.gd_client, 
                                 'testCreateUpdateDeleteGroup')

    test_group = gdata.contacts.GroupEntry(title=atom.Title(
        text='test group py'))
    new_group = self.gd_client.CreateGroup(test_group)
    self.assert_(isinstance(new_group, gdata.contacts.GroupEntry))
    self.assertEquals(new_group.title.text, 'test group py')

    # Change the group's title
    new_group.title.text = 'new group name py'
    updated_group = self.gd_client.UpdateGroup(new_group.GetEditLink().href, 
        new_group)
    self.assertEquals(updated_group.title.text, new_group.title.text)

    # Remove the group
    self.gd_client.DeleteGroup(updated_group.GetEditLink().href)


# Utility methods. 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:25,代码来源:service_test.py

示例5: testPostDraftUpdateAndDelete

# 需要导入模块: import atom [as 别名]
# 或者: from atom import Title [as 别名]
def testPostDraftUpdateAndDelete(self):
    new_entry = gdata.blogger.BlogPostEntry(title=atom.Title(
        text='Unit Test Post'))
    new_entry.content = atom.Content('text', None, 'Hello World')
    # Make this post a draft so it will not appear publicly on the blog.
    new_entry.control = atom.Control(draft=atom.Draft(text='yes'))
    new_entry.AddLabel('test')

    posted = self.client.AddPost(new_entry, blog_id=test_blog_id)

    self.assertEquals(posted.title.text, new_entry.title.text)
    # Should be one category in the posted entry for the 'test' label.
    self.assertEquals(len(posted.category), 1)
    self.assert_(isinstance(posted, gdata.blogger.BlogPostEntry))

    # Change the title and add more labels.
    posted.title.text = 'Updated'
    posted.AddLabel('second')
    updated = self.client.UpdatePost(entry=posted)

    self.assertEquals(updated.title.text, 'Updated')
    self.assertEquals(len(updated.category), 2)

    # Cleanup and delete the draft blog post.
    self.client.DeletePost(entry=posted) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:27,代码来源:service_test.py

示例6: testAddComment

# 需要导入模块: import atom [as 别名]
# 或者: from atom import Title [as 别名]
def testAddComment(self):
    # Create a test post to add comments to.
    new_entry = gdata.blogger.BlogPostEntry(title=atom.Title(
            text='Comments Test Post'))
    new_entry.content = atom.Content('text', None, 'Hello Comments')
    target_post = self.client.AddPost(new_entry, blog_id=test_blog_id)

    blog_id = target_post.GetBlogId()
    post_id = target_post.GetPostId()

    new_comment = gdata.blogger.CommentEntry()
    new_comment.content = atom.Content(text='Test comment')
    posted = self.client.AddComment(new_comment, blog_id=blog_id, 
        post_id=post_id)
    self.assertEquals(posted.content.text, new_comment.content.text)

    # Cleanup and delete the comment test blog post.
    self.client.DeletePost(entry=target_post) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:20,代码来源:service_test.py

示例7: testTitle

# 需要导入模块: import atom [as 别名]
# 或者: from atom import Title [as 别名]
def testTitle(self):
    """Tests the existence of a <atom:title> in the feed and the entries 
    and verifies the value"""

    # Assert that the feed title element exists and is an atom.Title
    self.assert_(isinstance(self.calendar_event_feed.title, atom.Title), 
        "Calendar feed <atom:title> element must be an instance of " +
        "atom.Title: %s" % self.calendar_event_feed.title)

    # Assert that each entry has a title value which is an atom.Title
    for an_entry in self.calendar_event_feed.entry:
      self.assert_(isinstance(an_entry.title, atom.Title),
          "Calendar event entry <atom:title> element must be an instance of " +
          "atom.Title: %s" % an_entry.title)

    # Assert the feed title value is as expected
    self.assertEquals(self.calendar_event_feed.title.text, 'GData Ops Demo')

    # Assert one of the values for title 
    self.assertEquals(self.calendar_event_feed.entry[0].title.text, 
        'test deleted') 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:23,代码来源:calendar_test.py

示例8: setUp

# 需要导入模块: import atom [as 别名]
# 或者: from atom import Title [as 别名]
def setUp(self):
    self.gd_client = gdata.service.GDataService()
    self.gd_client.email = username
    self.gd_client.password = password
    self.gd_client.service = 'lh2'
    self.gd_client.source = 'GDataService Media "Unit" Tests'
    try:
      self.gd_client.ProgrammaticLogin()
    except gdata.service.CaptchaRequired:
      self.fail('Required Captcha')
    except gdata.service.BadAuthentication:
      self.fail('Bad Authentication')
    except gdata.service.Error:
      self.fail('Login Error')
    
    # create a test album
    gd_entry = gdata.GDataEntry()
    gd_entry.title = atom.Title(text='GData Test Album')
    gd_entry.category.append(atom.Category(
        scheme='http://schemas.google.com/g/2005#kind',
        term='http://schemas.google.com/photos/2007#album'))
    
    self.album_entry = self.gd_client.Post(gd_entry, 
        'http://picasaweb.google.com/data/feed/api/user/' + username) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:26,代码来源:service_test.py

示例9: testConvertToAndFromString

# 需要导入模块: import atom [as 别名]
# 或者: from atom import Title [as 别名]
def testConvertToAndFromString(self):
    feed = atom.Feed()
    feed.author.append(atom.Author(name=atom.Name(text='js')))
    feed.title = atom.Title(text='my test source')
    feed.generator = atom.Generator(text='gen')
    feed.entry.append(atom.Entry(author=[atom.Author(name=atom.Name(
        text='entry author'))]))
    self.assert_(feed.author[0].name.text == 'js')
    self.assert_(feed.title.text == 'my test source')
    self.assert_(feed.generator.text == 'gen')
    self.assert_(feed.entry[0].author[0].name.text == 'entry author')
    new_feed = atom.FeedFromString(feed.ToString())
    self.assert_(new_feed.author[0].name.text == 'js')
    self.assert_(new_feed.title.text == 'my test source')
    self.assert_(new_feed.generator.text == 'gen')    
    self.assert_(new_feed.entry[0].author[0].name.text == 'entry author') 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:18,代码来源:atom_test.py

示例10: AddWorksheet

# 需要导入模块: import atom [as 别名]
# 或者: from atom import Title [as 别名]
def AddWorksheet(self, title, row_count, col_count, key):
    """Creates a new worksheet in the desired spreadsheet.

    The new worksheet is appended to the end of the list of worksheets. The
    new worksheet will only have the available number of columns and cells 
    specified.

    Args:
      title: str The title which will be displayed in the list of worksheets.
      row_count: int or str The number of rows in the new worksheet.
      col_count: int or str The number of columns in the new worksheet.
      key: str The spreadsheet key to the spreadsheet to which the new 
          worksheet should be added. 

    Returns:
      A SpreadsheetsWorksheet if the new worksheet was created succesfully.  
    """
    new_worksheet = gdata.spreadsheet.SpreadsheetsWorksheet(
        title=atom.Title(text=title), 
        row_count=gdata.spreadsheet.RowCount(text=str(row_count)), 
        col_count=gdata.spreadsheet.ColCount(text=str(col_count)))
    return self.Post(new_worksheet, 
        'http://%s/feeds/worksheets/%s/private/full' % (self.server, key),
        converter=gdata.spreadsheet.SpreadsheetsWorksheetFromString) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:26,代码来源:service.py

示例11: CreateMenu

# 需要导入模块: import atom [as 别名]
# 或者: from atom import Title [as 别名]
def CreateMenu(self):
    """Prompts that enable a user to create a contact."""
    name = raw_input('Enter contact\'s name: ')
    notes = raw_input('Enter notes for contact: ')
    primary_email = raw_input('Enter primary email address: ')

    new_contact = gdata.contacts.ContactEntry(title=atom.Title(text=name))
    new_contact.content = atom.Content(text=notes)
    # Create a work email address for the contact and use as primary. 
    new_contact.email.append(gdata.contacts.Email(address=primary_email, 
        primary='true', rel=gdata.contacts.REL_WORK))
    entry = self.gd_client.CreateContact(new_contact)

    if entry:
      print 'Creation successful!'
      print 'ID for the new contact:', entry.id.text
    else:
      print 'Upload error.' 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:20,代码来源:contacts_example.py

示例12: _InsertCalendar

# 需要导入模块: import atom [as 别名]
# 或者: from atom import Title [as 别名]
def _InsertCalendar(self, title='Little League Schedule',
      description='This calendar contains practice and game times',
      time_zone='America/Los_Angeles', hidden=False, location='Oakland',
      color='#2952A3'): 
    """Creates a new calendar using the specified data."""
    print 'Creating new calendar with title "%s"' % title
    calendar = gdata.calendar.CalendarListEntry()
    calendar.title = atom.Title(text=title)
    calendar.summary = atom.Summary(text=description)
    calendar.where = gdata.calendar.Where(value_string=location)
    calendar.color = gdata.calendar.Color(value=color)
    calendar.timezone = gdata.calendar.Timezone(value=time_zone)  

    if hidden:
      calendar.hidden = gdata.calendar.Hidden(value='true')
    else:
      calendar.hidden = gdata.calendar.Hidden(value='false')

    new_calendar = self.cal_client.InsertCalendar(new_calendar=calendar)
    return new_calendar 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:22,代码来源:calendarExample.py

示例13: CreatePost

# 需要导入模块: import atom [as 别名]
# 或者: from atom import Title [as 别名]
def CreatePost(self, title, content, author_name, is_draft):
    """This method creates a new post on a blog.  The new post can be stored as
    a draft or published based on the value of the is_draft parameter.  The
    method creates an GDataEntry for the new post using the title, content,
    author_name and is_draft parameters.  With is_draft, True saves the post as
    a draft, while False publishes the post.  Then it uses the given
    GDataService to insert the new post.  If the insertion is successful, the
    added post (GDataEntry) will be returned.
    """

    # Create the entry to insert.
    entry = gdata.GDataEntry()
    entry.author.append(atom.Author(atom.Name(text=author_name)))
    entry.title = atom.Title(title_type='xhtml', text=title)
    entry.content = atom.Content(content_type='html', text=content)
    if is_draft:
      control = atom.Control()
      control.draft = atom.Draft(text='yes')
      entry.control = control

    # Ask the service to insert the new entry.
    return self.service.Post(entry, 
      '/feeds/' + self.blog_id + '/posts/default') 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:25,代码来源:BloggerExampleV1.py

示例14: AddWorksheet

# 需要导入模块: import atom [as 别名]
# 或者: from atom import Title [as 别名]
def AddWorksheet(self, title, row_count, col_count, key):
        """Creates a new worksheet in the desired spreadsheet.

        The new worksheet is appended to the end of the list of worksheets. The
        new worksheet will only have the available number of columns and cells
        specified.

        Args:
          title: str The title which will be displayed in the list of worksheets.
          row_count: int or str The number of rows in the new worksheet.
          col_count: int or str The number of columns in the new worksheet.
          key: str The spreadsheet key to the spreadsheet to which the new
              worksheet should be added.

        Returns:
          A SpreadsheetsWorksheet if the new worksheet was created succesfully.
        """
        new_worksheet = gdata.spreadsheet.SpreadsheetsWorksheet(
            title=atom.Title(text=title),
            row_count=gdata.spreadsheet.RowCount(text=str(row_count)),
            col_count=gdata.spreadsheet.ColCount(text=str(col_count)))
        return self.Post(new_worksheet,
                         'https://%s/feeds/worksheets/%s/private/full' % (self.server, key),
                         converter=gdata.spreadsheet.SpreadsheetsWorksheetFromString) 
开发者ID:dvska,项目名称:gdata-python3,代码行数:26,代码来源:service.py

示例15: testCreateUpdateDeleteGroup

# 需要导入模块: import atom [as 别名]
# 或者: from atom import Title [as 别名]
def testCreateUpdateDeleteGroup(self):
        if not conf.options.get_value('runlive') == 'true':
            return
        conf.configure_service_cache(self.gd_client,
                                     'testCreateUpdateDeleteGroup')

        test_group = gdata.contacts.GroupEntry(title=atom.Title(
            text='test group py'))
        new_group = self.gd_client.CreateGroup(test_group)
        self.assertTrue(isinstance(new_group, gdata.contacts.GroupEntry))
        self.assertEqual(new_group.title.text, 'test group py')

        # Change the group's title
        new_group.title.text = 'new group name py'
        updated_group = self.gd_client.UpdateGroup(new_group.GetEditLink().href,
                                                   new_group)
        self.assertEqual(updated_group.title.text, new_group.title.text)

        # Remove the group
        self.gd_client.DeleteGroup(updated_group.GetEditLink().href)


# Utility methods. 
开发者ID:dvska,项目名称:gdata-python3,代码行数:25,代码来源:service_test.py


注:本文中的atom.Title方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。