Skip to content

Commit

Permalink
update requirements
Browse files Browse the repository at this point in the history
update requirements

update requirements

update file_expiry scripts

update scripts

update scripts

update scripts
  • Loading branch information
cehune committed Oct 9, 2024
1 parent 41bbb79 commit fcc8761
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ classifiers = [
"Topic :: Software Development :: Build Tools",
"Programming Language :: Python :: 3",
]

dependencies = [
"typer>=0.9.0"
]
[tool.setuptools]
package-dir = {""= "src"}

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
typer>=0.12.3
typer>=0.9.0
2 changes: 2 additions & 0 deletions src/file_auto_expiry/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def collect_file_info(path: str, save_file: str = "", days_for_expiry: int = 10)
scrape_time = time.time()
seconds_for_expiry = int(days_for_expiry) * SECS_PER_DAY
expiry_threshold = scrape_time - seconds_for_expiry
print(seconds_for_expiry)
print(expiry_threshold)
collect_expired_file_information(folder_path=path,
save_file=save_file,
scrape_time=scrape_time,
Expand Down
10 changes: 4 additions & 6 deletions src/file_auto_expiry/utils/expiry_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,19 @@ def is_expired_filepath(path, file_stat, expiry_threshold):
# If all atime, ctime, mtime are more than the expiry date limit,
# then this return true, along with the other information
return expiry_tuple(
is_expired=timestamps_are_expired(atime, ctime, mtime,
is_expired=timestamps_are_expired(ctime, mtime,
expiry_threshold),
creators={creator},
atime=atime,
ctime=ctime,
mtime=mtime)

def timestamps_are_expired(atime, ctime, mtime, expiry_threshold):
def timestamps_are_expired(ctime, mtime, expiry_threshold):
"""
Checks if all atime, ctime, and mtime are expired.
Returns True when all are expired.
"""
return ((atime < expiry_threshold) and
(ctime < expiry_threshold) and
return ((ctime < expiry_threshold) and
(mtime < expiry_threshold))

def is_expired_link(path, file_stat, expiry_threshold):
Expand Down Expand Up @@ -98,8 +97,7 @@ def is_expired_folder(folder_path, folder_stat, expiry_threshold):
recent_mtime = folder_stat.st_mtime
folder_creator = get_file_creator(folder_path)
file_creators.add(folder_creator)
is_expired_flag = timestamps_are_expired(recent_atime,
recent_ctime,
is_expired_flag = timestamps_are_expired(recent_ctime,
recent_mtime,
expiry_threshold)

Expand Down
9 changes: 5 additions & 4 deletions src/file_auto_expiry/utils/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,15 @@ def collect_expired_file_information(folder_path, save_file, scrape_time, expiry
"mtime_datetime": str(datetime.datetime.fromtimestamp(mtime)),
}}

write_jsonl_information(path_info, save_file, scrape_time)
write_jsonl_information(path_info, save_file, scrape_time, expiry_threshold)

def write_jsonl_information(dict_info, file_path, scrape_time):
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,
"scrape_time_datetime": str(datetime.datetime.fromtimestamp(scrape_time))}) + "\n")
"scrape_time_datetime": str(datetime.datetime.fromtimestamp(scrape_time)),
"expiry_threshold": 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 @@ -138,4 +139,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 fcc8761

Please sign in to comment.