<s> """<STR_LIT>""" <EOL> from googleads import dfp <EOL> CUSTOM_FIELD_ID = '<STR_LIT>' <EOL> DROP_DOWN_CUSTOM_FIELD_ID = '<STR_LIT>' <EOL> CUSTOM_FIELD_OPTION_ID = '<STR_LIT>' <EOL> LINE_ITEM_ID = '<STR_LIT>' <EOL> def main ( client , custom_field_id , drop_down_custom_field_id , <EOL> custom_field_option_id , line_item_id ) : <EOL> custom_field_service = client . GetService ( <EOL> '<STR_LIT>' , version = '<STR_LIT>' ) <EOL> line_item_service = client . GetService ( '<STR_LIT>' , version = '<STR_LIT>' ) <EOL> custom_field_values = [ { <EOL> '<STR_LIT:key>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : custom_field_id <EOL> } <EOL> } ] <EOL> custom_field_query = '<STR_LIT>' <EOL> custom_field_statement = dfp . FilterStatement ( <EOL> custom_field_query , custom_field_values , <NUM_LIT:1> ) <EOL> custom_field = custom_field_service . getCustomFieldsByStatement ( <EOL> custom_field_statement . ToStatement ( ) ) [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> drop_down_custom_field_values = [ { <EOL> '<STR_LIT:key>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : drop_down_custom_field_id <EOL> } <EOL> } ] <EOL> drop_down_custom_field_query = '<STR_LIT>' <EOL> drop_down_custom_field_statement = dfp . FilterStatement ( <EOL> drop_down_custom_field_query , drop_down_custom_field_values , <NUM_LIT:1> ) <EOL> drop_down_custom_field = custom_field_service . getCustomFieldsByStatement ( <EOL> drop_down_custom_field_statement . ToStatement ( ) ) [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> line_item_values = [ { <EOL> '<STR_LIT:key>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : line_item_id <EOL> } <EOL> } ] <EOL> line_item_query = '<STR_LIT>' <EOL> line_item_statement = dfp . FilterStatement ( <EOL> line_item_query , line_item_values , <NUM_LIT:1> ) <EOL> line_item = line_item_service . getLineItemsByStatement ( <EOL> line_item_statement . ToStatement ( ) ) [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> if custom_field and line_item : <EOL> custom_field_value = { <EOL> '<STR_LIT>' : custom_field [ '<STR_LIT:id>' ] , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:value>' : '<STR_LIT>' <EOL> } <EOL> } <EOL> drop_down_custom_field_value = { <EOL> '<STR_LIT>' : drop_down_custom_field [ '<STR_LIT:id>' ] , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : custom_field_option_id , <EOL> } <EOL> custom_field_values = [ custom_field_value , drop_down_custom_field_value ] <EOL> old_custom_field_values = [ ] <EOL> if '<STR_LIT>' in line_item : <EOL> old_custom_field_values = line_item [ '<STR_LIT>' ] <EOL> for old_custom_field_value in old_custom_field_values : <EOL> if ( old_custom_field_value [ '<STR_LIT>' ] != <EOL> custom_field_value [ '<STR_LIT>' ] <EOL> and old_custom_field_value [ '<STR_LIT>' ] != <EOL> drop_down_custom_field_value [ '<STR_LIT>' ] ) : <EOL> custom_field_values . append ( old_custom_field_value ) <EOL> line_item [ '<STR_LIT>' ] = custom_field_values <EOL> line_items = line_item_service . updateLineItems ( [ line_item ] ) <EOL> for line_item in line_items : <EOL> custom_field_value_strings = [ ] <EOL> for value in line_item [ '<STR_LIT>' ] : <EOL> if dfp . DfpClassType ( value ) == '<STR_LIT>' : <EOL> custom_field_value_string = ( <EOL> '<STR_LIT>' <EOL> % ( value [ '<STR_LIT>' ] , value [ '<STR_LIT:value>' ] [ '<STR_LIT:value>' ] ) ) <EOL> elif dfp . DfpClassType ( value ) == '<STR_LIT>' : <EOL> custom_field_value_string = ( <EOL> '<STR_LIT>' <EOL> % ( value [ '<STR_LIT>' ] , value [ '<STR_LIT>' ] ) ) <EOL> custom_field_value_strings . append ( custom_field_value_string ) <EOL> print ( '<STR_LIT>' <EOL> % ( line_item [ '<STR_LIT:id>' ] , '<STR_LIT:U+002C>' . join ( custom_field_value_strings ) ) ) <EOL> else : <EOL> print '<STR_LIT>' <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> dfp_client = dfp . DfpClient . LoadFromStorage ( ) <EOL> main ( dfp_client , CUSTOM_FIELD_ID , DROP_DOWN_CUSTOM_FIELD_ID , <EOL> CUSTOM_FIELD_OPTION_ID , LINE_ITEM_ID ) </s>
