FileInfo

class typhon.files.handlers.common.FileInfo(path=None, times=None, attr=None, fs=None)[source]

Container of information about a file (time coverage, etc.)

This is a simple object that holds the path and name, time coverage and further attributes of a file. It fulfills the os.PathLike protocol, i.e. you can use it as filename argument for the most python functions.

See this Example:

# Initialise a FileInfo object that points to a file
file_info = FileInfo(
    path="path/to/a/file.txt",
    # The time coverage of the file (needed by Dataset classes)
    times=[datetime(2018, 1, 1), datetime(2018, 1, 10)],
    # Additional attributes:
    attr={},
)

with open(file_info) as file:
    ...

# If you need to access the path or other attributes directly, you can
# do it like this:
file_info.path   # "path/to/a/file.txt"
file_info.times  # [datetime(2018, 1, 1), datetime(2018, 1, 10)]
file_info.attr   # {}
__init__(path=None, times=None, attr=None, fs=None)[source]

Initialise a FileInfo object.

Parameters
  • path – Absolute path to a file.

  • times – A list or tuple of two datetime objects indicating start and end time of the file.

  • attr – A dictionary with further attributes.

  • fs – Implementation of fsspec file system

Methods

__init__([path, times, attr, fs])

Initialise a FileInfo object.

copy()

from_json_dict(json_dict)

to_json_dict()

update(other_info[, ignore_none_time])

Update this object with another FileInfo object.

Attributes

path

times