add generation script for package stats
This commit is contained in:
parent
fa3473cdc2
commit
28eb0a39ae
3 changed files with 69 additions and 24 deletions
|
|
@ -19,29 +19,6 @@ def filesize_csv(input_dir: Path, output_dir: Path) -> None:
|
|||
writer.writerow([p_date, p_fname, p_mtime, p_size])
|
||||
|
||||
|
||||
def newer_than_last_clean(
|
||||
input_glob: Generator[Path], output_glob: Generator[Path], desc: str | None = None
|
||||
) -> bool:
|
||||
last_raw_update: datetime = datetime(1, 1, 1)
|
||||
oldest_clean: datetime = datetime.now()
|
||||
for file in input_glob:
|
||||
mdate = datetime.fromtimestamp(file.stat().st_mtime)
|
||||
if mdate > last_raw_update:
|
||||
last_raw_update = mdate
|
||||
for file in output_glob:
|
||||
mdate = datetime.fromtimestamp(file.stat().st_mtime)
|
||||
if mdate < oldest_clean:
|
||||
oldest_clean = mdate
|
||||
if oldest_clean > last_raw_update:
|
||||
print(
|
||||
"INFO: Skip creating cleaned data"
|
||||
+ f"{f' for {desc}' if desc else ''}"
|
||||
+ f", last processing {oldest_clean} newer than {last_raw_update}"
|
||||
)
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def ensure_dirs(input_dir: Path, output_dir: Path):
|
||||
if not input_dir.is_dir():
|
||||
raise ValueError
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue