From 1d1307c0e8a83a18b832851dace15ff0af8929c4 Mon Sep 17 00:00:00 2001 From: Alasdair Colley Date: Tue, 1 Nov 2011 18:11:25 +0000 Subject: change probability function to generate numbers with a more bell-like probability-density function --- perc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/perc b/perc index cf8aa3f..8ea71d8 100755 --- a/perc +++ b/perc @@ -194,9 +194,16 @@ def getDayOfWeek(day): def parseTemporalEvent(event, user): start, finish = None, None - if event == "LATER": - start = NOW - timedelta(minutes=random.randint(1, 400)) - finish = NOW + timedelta(minutes=random.randint(1, 400)) + if event in CONFIG["CUSTOM_EVENTS"]: + start = datetime.strptime(CONFIG["CUSTOM_EVENTS"][event]["start"], EVENT_DATETIME_FORMAT) + finish = datetime.strptime(CONFIG["CUSTOM_EVENTS"][event]["finish"], EVENT_DATETIME_FORMAT) + format = CONFIG["CUSTOM_EVENTS"][event]["format"] + + start_formatted = start.strftime(format).format(name=event) + finish_formatted = finish.strftime(format).format(name=event) + elif event == "LATER": + start = NOW - timedelta(minutes=(random.randint(1, 400) + random.randint(1, 400)) / 2) + finish = NOW + timedelta(minutes=(random.randint(1, 400) + random.randint(1, 400)) / 2) start_formatted = start.strftime("%H:%M") finish_formatted = finish.strftime("%H:%M") @@ -260,13 +267,6 @@ def parseTemporalEvent(event, user): finish_formatted = finish.strftime(user.format) start_formatted = start.strftime(user.format) - elif event in CONFIG["CUSTOM_EVENTS"]: - start = datetime.strptime(CONFIG["CUSTOM_EVENTS"][event]["start"], EVENT_DATETIME_FORMAT) - finish = datetime.strptime(CONFIG["CUSTOM_EVENTS"][event]["finish"], EVENT_DATETIME_FORMAT) - format = CONFIG["CUSTOM_EVENTS"][event]["format"] - - start_formatted = start.strftime(format).format(name=event) - finish_formatted = finish.strftime(format).format(name=event) return start, finish, start_formatted, finish_formatted -- cgit v1.2.3