small tweet adjustments
@@ -385,7 +385,7 @@ def prepare_tweet(counts, lab_collection):
("New sequences from ", " can be seen on ")
]
- the = ["United Kingdom", "USA"]
+ the = ["United Kingdom", "USA", "Democratic Republic of the Congo"]
total = 0
tweet_collection = {}
@@ -404,7 +404,9 @@ def prepare_tweet(counts, lab_collection):
s += country + " (" + str(number) + ")"
labs = lab_collection[region][country]
countries.append(s)
- handles = handles + labs
+ for l in labs:
+ if l not in handles:
+ handles.append(l)
tweet_collection[region] = (countries, handles)
if len(countries) > 1:
@@ -448,10 +450,11 @@ def prepare_tweet(counts, lab_collection):
while len(lengths) > 0:
current_region = min(lengths, key=lengths.get)
best_partner = ""
+ current_length = lengths[current_region]
for region, length in sorted(lengths.items(), key=lambda x: x[1]):
if region == current_region:
continue
- if lengths[current_region] + length > char_available:
+ if current_length + length > char_available:
break
best_partner = region
@@ -461,17 +464,21 @@ def prepare_tweet(counts, lab_collection):
p = "[pic_" + current_region.replace(" ", "") + "]"
l = links[current_region]
if best_partner != "":
+ current_length += lengths(best_partner)
lengths.pop(best_partner)
c += tweet_collection[best_partner][0]
h += tweet_collection[best_partner][1]
l += " and " + links[best_partner]
p += " " + "[pic_" + best_partner.replace(" ", "") + "]"
-
if len(c) > 1:
c = ", ".join(c[:-1]) + " and " + c[-1]
else:
c = c[0]
+
+ if current_length > char_available:
+ h = " ".join(h)
+ else:
h = ", ".join(h)
starter = random.choice(starters)
