def parse(cls, serialized): key, mode, size, atime, mtime, path_repr = cls._SPLIT_REGEX.split( serialized, 5) status = Stat( st_mode=int(mode, 8) | stat.S_IFREG, st_size=int(size), st_atime=utc2timestamp(float(atime)), st_mtime=utc2timestamp(float(mtime))) return cls(key, ast.literal_eval(path_repr), status)
def test_utc2timestamp(): ts = datetime2timestamp(datetime(1970, 1, 1, second=45)) assert utc2timestamp(ts) == 45