with_units_to_int,
)
from cephadmlib.file_utils import (
+ get_file_timestamp,
makedirs,
+ pathify,
populate_files,
read_file,
recursive_chown,
return cp
-def pathify(p):
- # type: (str) -> str
- p = os.path.expanduser(p)
- return os.path.abspath(p)
-
-
-def get_file_timestamp(fn):
- # type: (str) -> Optional[str]
- try:
- mt = os.path.getmtime(fn)
- return datetime.datetime.fromtimestamp(
- mt, tz=datetime.timezone.utc
- ).strftime(DATEFMT)
- except Exception:
- return None
-
-
def try_convert_datetime(s):
# type: (str) -> Optional[str]
# This is super irritating because
# file_utils.py - generic file and directory utility functions
+import datetime
import logging
import os
import tempfile
from pathlib import Path
from typing import Dict, Any, Union, Tuple, Optional, Generator, IO, List
-from .constants import DEFAULT_MODE
+from .constants import DEFAULT_MODE, DATEFMT
from .data_utils import dict_get_join
logger = logging.getLogger()
else:
return content
return 'Unknown'
+
+
+def pathify(p):
+ # type: (str) -> str
+ p = os.path.expanduser(p)
+ return os.path.abspath(p)
+
+
+def get_file_timestamp(fn):
+ # type: (str) -> Optional[str]
+ try:
+ mt = os.path.getmtime(fn)
+ return datetime.datetime.fromtimestamp(
+ mt, tz=datetime.timezone.utc
+ ).strftime(DATEFMT)
+ except Exception:
+ return None