Skip to content

Commit

Permalink
feat(iolibs): add method to get file modified time
Browse files Browse the repository at this point in the history
  • Loading branch information
entelecheia committed Jun 20, 2023
1 parent e3cc176 commit 5ec4e36
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/hyfi/utils/iolibs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""File I/O functions"""
import os
import re
import time
from glob import glob
from pathlib import Path, PosixPath, WindowsPath
from typing import List, Union
Expand Down Expand Up @@ -233,3 +234,11 @@ def copyfile(src, dst, *, follow_symlinks=True):
dst = str(dst)
shutil.copyfile(src, dst, follow_symlinks=follow_symlinks)
logger.info(f"copied {src} to {dst}")

@staticmethod
def get_modified_time(path):
"""Return the modification time of a file"""
if not os.path.exists(path):
return None
modTimesinceEpoc = os.path.getmtime(path)
return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(modTimesinceEpoc))

0 comments on commit 5ec4e36

Please sign in to comment.