You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
821 B

  1. import json
  2. from build import build, build_ext_list
  3. import time
  4. def full(ext,*starts):
  5. stime = time.time()
  6. paths = build(0,*starts)
  7. names = build_ext_list(ext,paths)
  8. return {
  9. "meta" : {
  10. "ext" : ext,
  11. "time": stime,
  12. },
  13. "data": names
  14. }
  15. def save(ext_map):
  16. ext = ext_map["meta"]["ext"]
  17. with open(f"{ext}-cache.json","w") as file:
  18. json.dump(ext_map,file)
  19. def load(ext):
  20. with open(f"{ext}-cache.json") as file:
  21. return json.load(file)
  22. def update(ext,*starts):
  23. ext_map = load(ext)
  24. prev_time = ext_map["meta"]["time"]
  25. stime = time.time()
  26. paths = build(prev_time,*starts)
  27. names = build_ext_list(ext,paths)
  28. ext_map.update(names)
  29. ext_map["meta"]["time"] = stime
  30. save(ext_map)
  31. return ext_map