<s> from flask import g <EOL> from models import Product <EOL> from bson . objectid import ObjectId <EOL> import re <EOL> def utility_processor ( ) : <EOL> def unslug ( string ) : <EOL> return re . sub ( '<STR_LIT>' , '<STR_LIT:U+0020>' , string ) <EOL> def parse_field_data ( value ) : <EOL> choices = re . sub ( '<STR_LIT:\r\n>' , '<STR_LIT:U+002C>' , value ) <EOL> return choices . split ( '<STR_LIT:U+002C>' ) <EOL> def slugify ( data ) : <EOL> temp_string = re . sub ( '<STR_LIT>' , '<STR_LIT:U+0020>' , str ( data . strip ( ) ) ) <EOL> return re . sub ( '<STR_LIT:U+0020>' , '<STR_LIT:_>' , temp_string ) <EOL> def get_product_for_call ( product ) : <EOL> temp_product = g . db . api_settings . find_one ( ) <EOL> if temp_product and temp_product . get ( product ) : <EOL> return Product ( temp_product . get ( product ) ) <EOL> return { } <EOL> def get_product_call ( call_id , db_name ) : <EOL> if call_id : <EOL> return getattr ( g . db , db_name ) . find_one ( <EOL> { '<STR_LIT>' : ObjectId ( str ( call_id ) ) } <EOL> ) <EOL> return dict ( <EOL> parse_field_data = parse_field_data , <EOL> unslug = unslug , <EOL> slugify = slugify , <EOL> get_product_for_call = get_product_for_call , <EOL> get_product_call = get_product_call <EOL> ) </s>
