FANDOM


#!/usr/bin/python
  
  import os, pprint, json
  
  rootdir = './logs'
  
  listoffiles=[]
  
  for subdir, dirs, files in os.walk(rootdir):
      for file in files:
          listoffiles.append(os.path.join(subdir, file))
  
  #print len(listoffiles)
  
  listofstrings = []
  
  for file in listoffiles:
    with open(file, 'r') as infile:
      copy = False
      for line in infile:
        if line.startswith('Quests In Progress'):
          copy = True
        elif '<' in line:
          copy = False
        elif copy:
          listofstrings.append(line.strip())  
  
  #print listofstrings
  
  questdict = {}
  questblock = False
  curquestkey = ''
  
  for str in listofstrings:
    str = str.strip()
    if str.startswith('['):
      curquestkey = str
      questblock = True
      if str not in questdict.keys():
        questdict[str] = {}
    elif str == '':
      questblock = False
      continue
    elif questblock:
      questdict[curquestkey][str] = ''
    else:
      curquestkey = str
      questblock = True
      if str in questdict.keys():
        continue
      else:
        questdict[str] = {}
  
  pprint.pprint(questdict)
  #print json.dumps(questdict)