Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _read_campaign_type(c, v):
if not v:
return []
campaign_type = v
c.campaign.CampaignType = [campaign_type]
if campaign_type.lower() == 'shopping':
c.campaign.Settings = _CAMPAIGN_OBJECT_FACTORY_V10.create('ArrayOfSetting')
shopping_setting = _CAMPAIGN_OBJECT_FACTORY_V10.create('ShoppingSetting')
shopping_setting.Type = 'ShoppingSetting'
c.campaign.Settings.Setting = [shopping_setting]
def process_mappings_from_row_values(self, row_values):
self.dynamic_search_ad = _CAMPAIGN_OBJECT_FACTORY_V10.create('DynamicSearchAd')
self.dynamic_search_ad.Type = 'DynamicSearch'
super(BulkDynamicSearchAd, self).process_mappings_from_row_values(row_values)
row_values.convert_to_entity(self, BulkDynamicSearchAd._MAPPINGS)
def process_mappings_from_row_values(self, row_values):
self._remarketing_list = _CAMPAIGN_OBJECT_FACTORY_V10.create('RemarketingList')
row_values.convert_to_entity(self, BulkRemarketingList._MAPPINGS)
:param entity: entity which has BiddingScheme attribute
:param value: the content in csv
:return:
"""
if value is None or value == '':
return
elif value == 'EnhancedCpc':
entity.BiddingScheme = _CAMPAIGN_OBJECT_FACTORY_V10.create('ns0:EnhancedCpcBiddingScheme')
elif value == 'InheritFromParent':
entity.BiddingScheme = _CAMPAIGN_OBJECT_FACTORY_V10.create('ns0:InheritFromParentBiddingScheme')
elif value == 'MaxConversions':
entity.BiddingScheme = _CAMPAIGN_OBJECT_FACTORY_V10.create('ns0:MaxConversionsBiddingScheme')
elif value == 'ManualCpc':
entity.BiddingScheme = _CAMPAIGN_OBJECT_FACTORY_V10.create('ns0:ManualCpcBiddingScheme')
elif value == 'TargetCpa':
entity.BiddingScheme = _CAMPAIGN_OBJECT_FACTORY_V10.create('ns0:TargetCpaBiddingScheme')
elif value == 'MaxClicks':
entity.BiddingScheme = _CAMPAIGN_OBJECT_FACTORY_V10.create('ns0:MaxClicksBiddingScheme')
else:
raise ValueError('Unknown Bid Strategy Type')
entity.BiddingScheme.Type = value
def csv_to_entity_DSAWebpageParameter(row_values, entity):
"""
convert Campaign/Ad Group Criterion (WebpagePage) Web page parameters to bulk row values
:param row_values: bulk row values
:param entity: campaign/ad group criterion entity
"""
MAX_NUMBER_OF_CONDITIONS = 3
condition_prefix = _StringTable.DynamicAdTargetCondition1[:-1]
value_prefix = _StringTable.DynamicAdTargetValue1[:-1]
conditions = []
for i in range(0, MAX_NUMBER_OF_CONDITIONS):
condition_success, webpage_condition = row_values.try_get_value(condition_prefix + str(i + 1))
value_success, webpage_value = row_values.try_get_value(value_prefix + str(i + 1))
if condition_success and value_success and webpage_condition is not None and webpage_condition != '':
condition = _CAMPAIGN_OBJECT_FACTORY_V10.create('ns0:WebpageCondition')
if webpage_condition.lower() == 'url':
condition.Operand = WebpageConditionOperand.Url
elif webpage_condition.lower() == "category":
condition.Operand = WebpageConditionOperand.Category
elif webpage_condition.lower() == 'pagetitle':
condition.Operand = WebpageConditionOperand.PageTitle
elif webpage_condition.lower() == 'pagecontent':
condition.Operand = WebpageConditionOperand.PageContent
else:
# TODO wait bug 54825 to be fixed
if webpage_condition.lower() == 'none':
continue
raise ValueError("Unknown WebpageConditionOperand value: {0}".format(webpage_condition))
condition.Argument = webpage_value
conditions.append(condition)
def csv_to_field_BidStrategyType(entity, value):
"""
set BiddingScheme
:param entity: entity which has BiddingScheme attribute
:param value: the content in csv
:return:
"""
if value is None or value == '':
return
elif value == 'EnhancedCpc':
entity.BiddingScheme = _CAMPAIGN_OBJECT_FACTORY_V10.create('ns0:EnhancedCpcBiddingScheme')
elif value == 'InheritFromParent':
entity.BiddingScheme = _CAMPAIGN_OBJECT_FACTORY_V10.create('ns0:InheritFromParentBiddingScheme')
elif value == 'MaxConversions':
entity.BiddingScheme = _CAMPAIGN_OBJECT_FACTORY_V10.create('ns0:MaxConversionsBiddingScheme')
elif value == 'ManualCpc':
entity.BiddingScheme = _CAMPAIGN_OBJECT_FACTORY_V10.create('ns0:ManualCpcBiddingScheme')
elif value == 'TargetCpa':
entity.BiddingScheme = _CAMPAIGN_OBJECT_FACTORY_V10.create('ns0:TargetCpaBiddingScheme')
elif value == 'MaxClicks':
entity.BiddingScheme = _CAMPAIGN_OBJECT_FACTORY_V10.create('ns0:MaxClicksBiddingScheme')
else:
raise ValueError('Unknown Bid Strategy Type')
entity.BiddingScheme.Type = value
_BULK_DATETIME_FORMAT = '%m/%d/%Y %H:%M:%S'
_BULK_DATETIME_FORMAT_2 = '%m/%d/%Y %H:%M:%S.%f'
_BULK_DATE_FORMAT = "%m/%d/%Y"
url_splitter = ";\\s*(?=https?://)"
custom_param_splitter = "(?
url_splitter = ";\\s*(?=https?://)"
custom_param_splitter = "(?