Mercurial > hg > horiscopes
view V4/synastry.py @ 13:b253748dbb11
developing V4 - Class based structure, with self calcuation of all aspects
author | DaveM |
---|---|
date | Sun, 04 Mar 2018 14:51:43 +0000 |
parents | |
children | 50a95089414d |
line wrap: on
line source
import random class Person: url = 'https://horoscopes.astro-seek.com/calculate-love-compatibility/' def __init__(self,personDict): # self. = planetPositions() self.id = personDict['ID'] self.dob = personDict['DOB'] self.tob = personDict['TOB'] self.cob = personDict['COB'] self.p_dob = personDict['pDOB'] self.p_tob = personDict['pTOB'] self.p_cob = personDict['pCOB'] self.horiscope = None def makePayload(self): if type(self.cob) is str: cob_0 = float(self.cob.split(',')[0][1:]) cob_1 = float(self.cob.split(',')[1]) self.cob = (cob_0,cob_1) if type(self.p_cob) is str: pcob_0 = float(self.p_cob.split(',')[0][1:]) pcob_1 = float(self.p_cob.split(',')[1]) self.p_cob = (pcob_0,pcob_1) if type(self.dob) is str: self.dob = self.dob[1:-1].split(',') if type(self.p_dob) is str: self.p_dob = self.p_dob[1:-1].split(',') if type(self.tob) is str: self.tob = self.tob[1:-1].split(',') if type(self.p_tob) is str: self.p_tob = self.p_tob[1:-1].split(',') # pdb.set_trace() # print dataDict['pDOB'] self.payload = {'send_calculation':'1', #Req 'muz_narozeni_den':self.dob[0], 'muz_narozeni_mesic':self.dob[1], 'muz_narozeni_rok':self.dob[2], 'muz_narozeni_hodina':self.tob[0], 'muz_narozeni_minuta':self.tob[1], 'muz_narozeni_city':'', 'muz_narozeni_mesto_hidden':'Manually+place%3A+%C2%B0%27N%2C+%C2%B0%27E',#auto 'muz_narozeni_stat_hidden':'XX', 'muz_narozeni_podstat_kratky_hidden':'', 'muz_narozeni_podstat_hidden':'', 'muz_narozeni_podstat2_kratky_hidden':'', 'muz_narozeni_podstat3_kratky_hidden':'', 'muz_narozeni_input_hidden':'', 'muz_narozeni_sirka_stupne':str(abs(self.cob[0])).split('.')[0], 'muz_narozeni_sirka_minuty':str(float('0.'+str(self.cob[0]).split('.')[1])*60).split('.')[0], 'muz_narozeni_sirka_smer': '1' if self.cob[0]<0 else '0', #address N Dir (0':'N',1':'S) 'muz_narozeni_delka_stupne':str(abs(self.cob[1])).split('.')[0], #address E - Main 'muz_narozeni_delka_minuty':str(float('0.'+str(self.cob[1]).split('.')[1])*60).split('.')[0], 'muz_narozeni_delka_smer': '1' if self.cob[1]<0 else '0', #address E Dir (0':'E',1':'W) 'muz_narozeni_timezone_form':'auto', 'muz_narozeni_timezone_dst_form':'auto', 'send_calculation':'1', 'zena_narozeni_den':self.p_dob[0], 'zena_narozeni_mesic':self.p_dob[1], 'zena_narozeni_rok':self.p_dob[2], 'zena_narozeni_hodina':self.p_tob[0], 'zena_narozeni_minuta':self.p_tob[1], 'zena_narozeni_city':'', 'zena_narozeni_mesto_hidden':'Manually+place%3A+%C2%B0%27N%2C+%C2%B0%27E', 'zena_narozeni_stat_hidden':'XX', 'zena_narozeni_podstat_kratky_hidden':'', 'zena_narozeni_podstat_hidden':'', 'zena_narozeni_podstat2_kratky_hidden':'', 'zena_narozeni_podstat3_kratky_hidden':'', 'zena_narozeni_input_hidden':'', 'zena_narozeni_sirka_stupne':str(abs(self.p_cob[0])).split('.')[0], 'zena_narozeni_sirka_minuty':str(float('0.'+str(self.p_cob[0]).split('.')[1])*60).split('.')[0], 'zena_narozeni_sirka_smer': '1' if self.p_cob[0]<0 else '0', 'zena_narozeni_delka_stupne':str(abs(self.p_cob[1])).split('.')[0], 'zena_narozeni_delka_minuty':str(float('0.'+str(self.p_cob[1]).split('.')[1])*60).split('.')[0], 'zena_narozeni_delka_smer': '1' if self.p_cob[1]<0 else '0', 'zena_narozeni_timezone_form':'auto', 'zena_narozeni_timezone_dst_form':'auto', 'switch_interpretations':'0', 'house_system':'placidus', 'uhel_orbis':'#tabs_redraw'} # return R class planetRelation: def __init__(self,planetName): self.name = planetName self.angleA = None self.angleB = None def setLocation(self,A,B): self.angleA = '.'.join(A.encode('ascii','replace').split('?'))[:-1] self.angleB = '.'.join(B.encode('ascii','replace').split('?'))[:-1] def test_random(self): self.angleA = random.random()*360 self.angleB = random.random()*360 class planetPositions: aspectDict = {'conjunct':0,'semi-square':45,'sextile':60,'square':90,'trine':120,'opposite':180} planetNames = ['sun','moon','mercury','venus','mars','jupiter','saturn','uranus','neptune','pluto','node','lilith','chiron','asc','ic','dsc','mc','asc_mc','sun_moon'] def __init__(self): self.planets = {} for i in range(len(planetPositions.planetNames)): self.planets[planetPositions.planetNames[i]] = planetRelation(planetPositions.planetNames[i]) self.aspect = {} def test_random(self): for planet in self.planets: self.planets[planet].test_random() def calcAngle(self,componentA,componentB): self.angle = max(self.planets[componentA].angleA,self.planets[componentB].angleB) - min(self.planets[componentA].angleA,self.planets[componentB].angleB) self.angleRange = self.angle-10,self.angle+10 def calcAspect(self,componentA,componentB): self.calcAngle(componentA,componentB) for aspect in planetPositions.aspectDict: if self.angleRange[0] < planetPositions.aspectDict[aspect] and self.angleRange[1] > planetPositions.aspectDict[aspect]: self.aspect[componentA,componentB] = aspect return aspect