def buildRandom(creatives_number, country=None): """build a list of creatives with given length, but with random number of advertizers and also random number of cratives for an advertizer""" result = [] adv_num = random.randint(1, creatives_number / 2) counter = creatives_number slots = creatives_number global countriesList countriesList = countries.loadCountries() for i in range(0, adv_num): a = random.randint(1, (slots - (adv_num - i))) if i == adv_num - 1: a = slots else: slots -= a #print "advertizer: " + str(i) + " expected num: " + str(a) #if country is not None: # local_country = country #else: # local_country = countriesList[random.randint(0, 243)].code tmp = buildForAdvertizer(a, i) result.extend(tmp) return result
def prepareCreatives(): creatives = [] global cList cList = countries.loadCountries()