├── Makefile ├── README.md └── test.py /Makefile: -------------------------------------------------------------------------------- 1 | main: 2 | echo "Its python, why are you runnning make????" 3 | 4 | clean: 5 | rm *.pyc 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | what_is_the_date 2 | ================ 3 | 4 | This very important repository allows you to tell you what the date is! 5 | 6 | In test.py there is a line that begins with `today =` this is the line that 7 | includes the date. 8 | 9 | The date will also have a time after this, this is open to implementation and 10 | is not defined as any specific value. 11 | -------------------------------------------------------------------------------- /test.py: -------------------------------------------------------------------------------- 1 | import shutil 2 | import re 3 | import subprocess 4 | from datetime import datetime, timedelta 5 | 6 | #debug=False 7 | 8 | tomorrow = "Mar 15 2018 09:51PM" 9 | today = "Mar 14 2018 09:50PM" 10 | 11 | #STOP DO NOT USE ABOVE VARIABLES IN YOUR LOOP 12 | #YOU WILL MAKE KITTENS SAD 13 | 14 | this_script = open("test.py") 15 | new_script = open("test_new.py", "w") 16 | 17 | debug = False 18 | for line in this_script: 19 | if line.startswith("#debug"): 20 | debug = bool(re.search(r'#debug=(.*)', line).group(1) == 'True') 21 | break 22 | 23 | this_script.close() 24 | this_script = open("test.py") 25 | 26 | #YOUR CODE STARTS HERE 27 | today_today = '' 28 | new_file = [] 29 | 30 | for line in this_script: 31 | has_tomorrow = re.search(r'^tomorrow = "([^"]*)"', line) 32 | if has_tomorrow: 33 | today_today = has_tomorrow.group(1) 34 | today_today_datetime = datetime.strptime(today_today,'%b %d %Y %I:%M%p') + timedelta(days=1, minutes=1) 35 | 36 | tomorrow_tomorrow = datetime.strftime(today_today_datetime, 37 | '%b %d %Y %I:%M%p') 38 | 39 | new_line = 'tomorrow = "<<>>"\n' 40 | elif re.search(r'^today = "[^"]*"', line): 41 | new_line = 'today = "<<>>"\n' 42 | else: 43 | new_line = line 44 | new_file.append(new_line) 45 | 46 | lines = '' 47 | for line in new_file: 48 | if re.search(r'^tomorrow = "([^"]*)"', line): 49 | lines += 'tomorrow = "' + tomorrow_tomorrow + '"\n' 50 | elif re.search(r'^today = "[^"]*"', line): 51 | lines += 'today = "' + today_today + '"\n' 52 | else: 53 | lines += line 54 | 55 | #YOUR CODE ENDS HERE 56 | new_script.write(lines) 57 | this_script.close() 58 | new_script.close() 59 | 60 | if not debug: 61 | shutil.move("test_new.py", "test.py") 62 | 63 | subprocess.call("git add test.py", shell=True) 64 | subprocess.call("git commit -m 'Fixed the time'", shell=True) 65 | subprocess.call("git push", shell=True) 66 | 67 | print today_today 68 | print tomorrow_tomorrow 69 | 70 | print "actual today " + datetime.strftime(datetime.now(), '%b %d %Y %I:%M%p') 71 | --------------------------------------------------------------------------------