mirror of
https://expo.survex.com/repositories/expoweb/.git/
synced 2024-11-23 07:41:56 +00:00
[svn r8160]
This commit is contained in:
parent
8edaff3045
commit
f3bd6169ab
@ -1,24 +0,0 @@
|
||||
import troggle.settings as settings
|
||||
from django import forms
|
||||
from expo.models import LogbookEntry
|
||||
import random
|
||||
import re
|
||||
|
||||
def weighted_choice(lst):
|
||||
n = random.uniform(0,1)
|
||||
for item, weight in lst:
|
||||
if n < weight:
|
||||
break
|
||||
n = n - weight
|
||||
return item
|
||||
|
||||
def randomLogbookSentence():
|
||||
#Choose a random logbook entry
|
||||
randSent={}
|
||||
randSent['entry']=LogbookEntry.objects.order_by('?')[0]
|
||||
|
||||
#Choose a random sentence from that entry. Store the sentence as randSent['sentence'], and the number of that sentence in the entry as randSent['number']
|
||||
sentenceList=re.findall('[A-Z].*?\.',randSent['entry'].text)
|
||||
randSent['number']=random.randrange(0,len(sentenceList))
|
||||
randSent['sentence']=sentenceList[randSent['number']]
|
||||
return randSent
|
Loading…
Reference in New Issue
Block a user