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):
- dictionary = {}
- dictionary['name'] = line[0][0]
- dictionary['item_to_buy'] = line[0][1]
- dictionary['currency'] = line[0][2]
- dictionary['league'] = line[0][3]
- with open('logs.json', 'a+') as f:
- f.write(json.dumps(f))
- f.write('\n')
- 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