28 lines
756 B
Python
28 lines
756 B
Python
import argparse
|
|
import os
|
|
from time import sleep
|
|
|
|
def main():
|
|
args = get_args()
|
|
buckets = {}
|
|
with open(args.p, "r") as f:
|
|
f.seek(0, os.SEEK_END)
|
|
while True:
|
|
line = f.readline().strip()
|
|
if not line:
|
|
sleep(0.25)
|
|
continue
|
|
key = line.strip("/").split()[0]
|
|
if not key in buckets:
|
|
buckets[key] = False
|
|
buckets[key] = False if line[0] == "/" else float(line.split()[-1])
|
|
print(sorted([(int(i),buckets[i]) for i in buckets if buckets[i]]))
|
|
|
|
def get_args():
|
|
ap = argparse.ArgumentParser()
|
|
ap.add_argument("-p", type=str, help="path to write out to", default="/tmp/cbappend.both.txt")
|
|
return ap.parse_args()
|
|
|
|
if __name__ == "__main__":
|
|
main()
|