def GetSitelinksFromFeed(client, feed):
 feed_mappings = GetFeedMapping(client, feed, PLACEHOLDER_TYPE_SITELINKS)
 feed_items = {}
 for feed_item in GetFeedItems(client, feed):
  site_link_from_feed = {}
  for attribute_value in feed_item['attributeValues']:
   if (attribute_value['feedAttributeId'] in feed_mappings):
    for field_id in feed_mappings[attribute_value['feedAttributeId']]:
     if (field_id == SITE_LINK_FIELDS['TEXT']):
      site_link_from_feed['text'] = attribute_value['stringValue']
     elif (field_id == SITE_LINK_FIELDS['URL']):
      site_link_from_feed['url'] = attribute_value['stringValue']
     elif (field_id == SITE_LINK_FIELDS['FINAL_URLS']):
      site_link_from_feed['finalUrls'] = attribute_value['stringValues']
     elif (field_id == SITE_LINK_FIELDS['FINAL_MOBILE_URLS']):
      site_link_from_feed['finalMobileUrls'] = attribute_value['stringValues']
     elif (field_id == SITE_LINK_FIELDS['TRACKING_URL_TEMPLATE']):
      site_link_from_feed['trackingUrlTemplate'] = attribute_value['stringValue']
     elif (field_id == SITE_LINK_FIELDS['LINE2']):
      site_link_from_feed['line2'] = attribute_value['stringValue']
     elif (field_id == SITE_LINK_FIELDS['LINE3']):
      site_link_from_feed['line3'] = attribute_value['stringValue']
     else:
      print ('No applicable Site Link Field found for Id: %s' % field_id)
  if ('scheduling' in feed_item):
   site_link_from_feed['scheduling'] = feed_item['scheduling']
  feed_items[feed_item['feedItemId']] = site_link_from_feed
 return feed_items

def GetSitelinksFromFeed ( client , feed ) : feed_mappings = GetFeedMapping ( client , feed , PLACEHOLDER_TYPE_SITELINKS ) feed_items = { } for feed_item in GetFeedItems ( client , feed ) : site_link_from_feed = { } for attribute_value in feed_item [ 'attributeValues' ] : if ( attribute_value [ 'feedAttributeId' ] in feed_mappings ) : for field_id in feed_mappings [ attribute_value [ 'feedAttributeId' ] ] : if ( field_id == SITE_LINK_FIELDS [ 'TEXT' ] ) : site_link_from_feed [ 'text' ] = attribute_value [ 'stringValue' ] elif ( field_id == SITE_LINK_FIELDS [ 'URL' ] ) : site_link_from_feed [ 'url' ] = attribute_value [ 'stringValue' ] elif ( field_id == SITE_LINK_FIELDS [ 'FINAL_URLS' ] ) : site_link_from_feed [ 'finalUrls' ] = attribute_value [ 'stringValues' ] elif ( field_id == SITE_LINK_FIELDS [ 'FINAL_MOBILE_URLS' ] ) : site_link_from_feed [ 'finalMobileUrls' ] = attribute_value [ 'stringValues' ] elif ( field_id == SITE_LINK_FIELDS [ 'TRACKING_URL_TEMPLATE' ] ) : site_link_from_feed [ 'trackingUrlTemplate' ] = attribute_value [ 'stringValue' ] elif ( field_id == SITE_LINK_FIELDS [ 'LINE2' ] ) : site_link_from_feed [ 'line2' ] = attribute_value [ 'stringValue' ] elif ( field_id == SITE_LINK_FIELDS [ 'LINE3' ] ) : site_link_from_feed [ 'line3' ] = attribute_value [ 'stringValue' ] else : print ( 'No applicable Site Link Field found for Id: %s' % field_id ) if ( 'scheduling' in feed_item ) : site_link_from_feed [ 'scheduling' ] = feed_item [ 'scheduling' ] feed_items [ feed_item [ 'feedItemId' ] ] = site_link_from_feed return feed_items
gets the sitelinks from a feed .