| Conditions | 4 |
| Total Lines | 29 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | #! /usr/bin/env python3 |
||
| 22 | 1 | def marvinMorning(row): |
|
| 23 | """ |
||
| 24 | Marvin says Good morning after someone else says it |
||
| 25 | """ |
||
| 26 | 1 | msg = None |
|
| 27 | 1 | phrases = [ |
|
| 28 | "morgon", |
||
| 29 | "godmorgon", |
||
| 30 | "god morgon", |
||
| 31 | "morrn", |
||
| 32 | "morn" |
||
| 33 | ] |
||
| 34 | |||
| 35 | 1 | morning_phrases = [ |
|
| 36 | "Godmorgon! :-)", |
||
| 37 | "Morgon allesammans", |
||
| 38 | "Morgon gott folk", |
||
| 39 | "Guten morgen", |
||
| 40 | "Morgon" |
||
| 41 | ] |
||
| 42 | |||
| 43 | global lastDateGreeted |
||
| 44 | |||
| 45 | 1 | for phrase in phrases: |
|
| 46 | 1 | if phrase in row: |
|
| 47 | 1 | if lastDateGreeted != datetime.date.today(): |
|
| 48 | 1 | lastDateGreeted = datetime.date.today() |
|
| 49 | 1 | msg = random.choice(morning_phrases) |
|
| 50 | return msg |
||
| 51 |