Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def follow(file):
- file.seek(0,2)
- while True:
- line = file.readline()
- if not line:
- time.sleep(0.1)
- continue
- line = str(line).replace('"', '\"')
- line = str(line).replace("'", "\'")
- if re.findall(TO_REGEX_OFFICIAL, line) != []:
- strings = re.findall(TO_REGEX_OFFICIAL, line)
- elif re.findall(TO_REGEX_POE_XYZ, line) != []:
- strings = re.findall(TO_REGEX_POE_XYZ, line)
- else:
- continue
- yield strings
- def filewriter(line):
- with open('logs.json') as f:
- jsonobj = json.load(f)
- dictionary = {}
- dictionary['name'] = line[0][0]
- dictionary['item_to_buy'] = line[0][1]
- dictionary['currency'] = line[0][2]
- dictionary['league'] = line[0][3]
- jsonobj.append(dictionary)
- with open('logs.json', 'w') as f:
- json.dump(jsonobj, f)
- with open(logfile) as fp:
- for line in follow(fp):
- filewriter(line) # writing to .json endlessly
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement