Advertisement
bananas717

Untitled

Jun 5th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. def menuhub_load(file):
  2. def datetime_to_float(d):
  3. return d.timestamp()
  4. pattern = re.compile(r"(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2}).(\d{3})") #use this to search for timestamp
  5. with open(file) as hubload_read:
  6. hublist = [] # list of timestamps
  7. hubtimes = [] # list of times taken for menu hub to load
  8. i = 0
  9. hub_value = True
  10. while(hub_value):
  11. line = hubload_read.readline()
  12. if line is not None:
  13. if 'generic hook' in line or 'other hook' in line: # hooks
  14. match = re.match(pattern, line)
  15. hublist.append(match.group()) # appends only the timestamp from the line
  16. else:
  17. hub_value = False
  18.  
  19. while i in range(0, len(hublist) -1):
  20. hubtimes.append(datetime.strptime(hublist[i+1], "%Y-%m-%d %H:%M:%S.%f") - datetime.strptime(hublist[i], "%Y-%m-%d %H:%M:%S.%f")) #subtracts the adjacent timestamps associated with each hook
  21. i += 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement