Skip to content

Commit

Permalink
Update version (#6)
Browse files Browse the repository at this point in the history
Update version and add check into file expiry files for the last date
for which a file is considered 'expired'.
  • Loading branch information
cehune authored Oct 9, 2024
1 parent 6d91701 commit 9d78aa8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "file_auto_expiry"
version = "0.0.1"
version = "0.0.2"
description = "WATCloud project containing scripts to check if directories / files are expired"
readme = "README.md"
requires-python = ">=3.7, <4"
Expand Down
12 changes: 8 additions & 4 deletions src/file_auto_expiry/utils/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,17 @@ def collect_expired_file_information(folder_path, save_file, scrape_time, expiry

write_jsonl_information(path_info, save_file, scrape_time, expiry_threshold)

def write_jsonl_information(dict_info, file_path, scrape_time, expiry_threshold):
def write_jsonl_information(dict_info, file_path, scrape_time, expiry_threshold=""):
current_time = time.time()

with open(file_path, "w") as file:
file.write(json.dumps({"scrape_time:": scrape_time,
if expiry_threshold=="":
file.write(json.dumps({"scrape_time:": scrape_time,
"scrape_time_datetime": str(datetime.datetime.fromtimestamp(scrape_time))}), + "\n")
else:
file.write(json.dumps({"scrape_time:": scrape_time,
"scrape_time_datetime": str(datetime.datetime.fromtimestamp(scrape_time)),
"expiry_threshold": expiry_threshold}), + "\n")
"expiry_threshold": str(datetime.datetime.fromtimestamp(expiry_threshold))}) + "\n")
file.write(json.dumps({"time_for_scrape_sec": current_time - scrape_time,
"time_for_scrape_min": (current_time - scrape_time) / 60}) + "\n")

Expand Down Expand Up @@ -139,4 +143,4 @@ def collect_creator_information(path_info_file, save_file, scrape_time):
"uid": user[1],
"gid": user[2]}

write_jsonl_information(creator_info, save_file, scrape_time, "")
write_jsonl_information(creator_info, save_file, scrape_time)

0 comments on commit 9d78aa8

Please sign in to comment.