Mercurial > hg > horiscopes
comparison V4/dParse.py @ 19:ae220e89cb3a
fixing parse bugs, and angle calculation bugs
author | DaveM |
---|---|
date | Tue, 06 Mar 2018 17:25:38 +0000 |
parents | 50a95089414d |
children | 0264a7888d54 |
comparison
equal
deleted
inserted
replaced
18:155126861c07 | 19:ae220e89cb3a |
---|---|
6 from geopy.geocoders import Nominatim | 6 from geopy.geocoders import Nominatim |
7 from geopy.exc import GeocoderTimedOut | 7 from geopy.exc import GeocoderTimedOut |
8 import random | 8 import random |
9 import pdb | 9 import pdb |
10 | 10 |
11 DEFAULT_TIME_H = None | 11 DEFAULT_TIME = None |
12 DEFAULT_TIME_M = None | 12 # DEFAULT_TIME_M = None |
13 DEAULT_LOCATION = None | 13 DEAULT_LOCATION = None |
14 | 14 |
15 def regulateData(dataDict): | 15 def regulateData(dataDict): |
16 print("Parse %s"%(str(dataDict['ID']))) | 16 print("Parse %s"%(str(dataDict['ID']))) |
17 p_DOBQ = "What is your partner's date of birth? Please use the format DD/MM/YYYY (for example, 29/03/1981)." | 17 p_DOBQ = "What is your partner's date of birth? Please use the format DD/MM/YYYY (for example, 29/03/1981)." |
188 print 'error with day month' | 188 print 'error with day month' |
189 print (r,d,m) | 189 print (r,d,m) |
190 return (d,m,y) | 190 return (d,m,y) |
191 | 191 |
192 def parseTOB(T): | 192 def parseTOB(T): |
193 # pdb.set_trace() | |
194 timeFlag = None | 193 timeFlag = None |
195 T_ = T.replace('.','').lower().strip() | 194 T_ = T.replace('.','').lower().strip() |
196 if 'am' in T_: | 195 if 'am' in T_: |
197 timeFlag = 0 | 196 timeFlag = 0 |
198 T = T_.replace('am','') | 197 T = T_.replace('am','') |
216 H = int(T) | 215 H = int(T) |
217 M = 0 | 216 M = 0 |
218 elif int(T) > 100: | 217 elif int(T) > 100: |
219 H = int(T)/100 | 218 H = int(T)/100 |
220 M = int(T)%100 | 219 M = int(T)%100 |
220 else: | |
221 return None | |
221 if timeFlag is not None: | 222 if timeFlag is not None: |
222 if timeFlag == 0: | 223 if timeFlag == 0: |
223 H = H%12 | 224 H = H%12 |
224 else: | 225 else: |
225 H = H%12 + 12 | 226 H = H%12 + 12 |
226 except ValueError: | 227 except ValueError: |
227 H = DEFAULT_TIME_H | 228 return None |
228 M = DEFAULT_TIME_M | |
229 return (H,M) | 229 return (H,M) |
230 | 230 |
231 | 231 |
232 |