Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.13 KB | None | 0 0
  1. import math
  2. import datetime
  3.  
  4. #generate string for date
  5. date=datetime.datetime.now().strftime("%Y-%m-%d")
  6. print(date)
  7.  
  8. #attributes collected
  9. total_score=0
  10.  
  11. attributes={
  12.     'Become less apathetic':{
  13.         'Waking up properly':0, #10, wake up instantly
  14.         'Not overwhelmed by negative emotion':0, #assuming u wake up prop thats fine
  15.         'Interest in becoming less apathetic':0, #lack of resent towards waking up
  16.         'Time used with purpose':0,#didnt waste any time, did stuff i enjoyed or had to do all day
  17.     },
  18.     'Done school work':{
  19.         'Present in school ':0, #go to school, focus/no school
  20.         'No homework related trouble':0, #do homework well
  21.         'Did revision (followed schedule?)':0, #revise, follow schedule
  22.         'Interest in doing school work':0 #interest doing the grind
  23.     },
  24.     'Work harder for GoodByte':{
  25.         'Make gun system for RvB':0, #finish gun system
  26.         'Game progress':0, # do all tasks listed
  27.         #'Goodbyte progress':0, # goodbyte improves as group, find way to measure
  28.         'Interest in work':0 #fascinated by work
  29.     },
  30.     'Become closer to people':{
  31.         'Spoke to people':0, #find time to speak to people, see someone irl
  32.         'Social satisfaction':0, #be happy with people ur talking to
  33.         'Interest in being socially active':0 #wanting to pursue
  34.     },
  35.     'Pursued creative endevaours':0, #write about oli/music/read/design
  36.     'Maintained my physical health':0, #do intense circuit training, go outside
  37.     'Acted brave, confident and confront my issues':0 #cold shower, do something new
  38. }
  39.  
  40. comments={}
  41.  
  42. final_analysis={}
  43.  
  44. #collect userdata
  45. def parse_attribute(att):
  46.     for attribute in att:
  47.         value=att[attribute]
  48.         if value != 0:
  49.             parse_attribute(value)
  50.         else:
  51.             user_input=input(attribute+" out of 10")
  52.             userdata={'score':int(user_input[0:2])}
  53.  
  54.             #if len(user_input) >2:
  55.             comments[attribute]= user_input[2:len(user_input)]
  56.  
  57.             att[attribute]=userdata
  58.  
  59. #converts attributes into flat dict with data
  60. def get_final_analysis(index,value,ancestor):
  61.     final_analysis[index]={'score':0,'maxm':0,'ancs':len(ancestor)-2}
  62.  
  63.     ancestor = ancestor.copy()
  64.     ancestor.append(index)
  65.    
  66.     #if is end node of recursive tree
  67.     if 'score' in value:
  68.         score=value['score']
  69.         for i in range(1,len(ancestor)):
  70.             key=ancestor[i]
  71.             new_score=final_analysis[key]['score']+score
  72.             new_max=final_analysis[key]['maxm']+10
  73.             ancs=final_analysis[key]['ancs']
  74.             final_analysis[key]={'score':new_score,'maxm':new_max,'ancs':ancs}
  75.     elif isinstance(value,dict):
  76.         #call recursive function to find end node
  77.         for index,attribute in value.items():
  78.             get_final_analysis(index,attribute,ancestor)
  79.  
  80. #format and save data
  81. def clean_final_analysis():
  82.    
  83.     #log detailed stats
  84.     f=open('data/'+date+'.txt','w+')
  85.     for key,data in final_analysis.items():
  86.         score=str(data['score'])+'/'+str(data['maxm'])
  87.         perc = str(math.floor((data['score']/data['maxm'])*100))+'%'
  88.  
  89.         comment=''
  90.  
  91.         if key in comments:
  92.             comment=comments[key]
  93.        
  94.         f.write(('    '*data['ancs'])+key+": "+score+' '+perc+' '+comment)
  95.         f.write("\r\n")
  96.         if key=='total_score':
  97.             f.write("\r\n")
  98.     f.close()
  99.  
  100.     #print out
  101.     f=open('data/'+str(date)+'.txt','r+')
  102.     print(f.read())
  103.     f.close()
  104.  
  105.     f=open('data/'+date+'.txt','a+')
  106.     final_comments = input("What are your comments for improvement?")
  107.  
  108.     f.write("\r\nFinal comments: "+final_comments)
  109.     f.close()
  110.  
  111.     #log generalised stats
  112.     data_txt=open('general/data.txt','a')
  113.    
  114.     data=final_analysis['total_score']
  115.    
  116.     score=str(data['score']) + '/' + str(data['maxm'])
  117.     perc=str(math.floor((data['score']/data['maxm'])*100))+'%'
  118.    
  119.     data_txt.write(str(date) + ': ' +score+' ' +perc+',\r\n')
  120.     data_txt.close()
  121.  
  122.  
  123.  
  124. parse_attribute(attributes)
  125. get_final_analysis('total_score',attributes,['total_score'])
  126. clean_final_analysis()
  127.  
  128. exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement