fs.info

class fs.info.Info(raw_info, to_datetime=<function epoch_to_datetime>)

Container for Resource Info, returned by the following methods:

Parameters:
  • raw_info (dict) – A dict containing resource info.
  • to_datetime – A callable that converts an epoch time to a datetime object. The default uses epoch_to_datetime().
accessed

Get the time this resource was last accessed, or None if not available.

Requires the "details" namespace.

Return type:datetime
Raises:MissingInfoNamespace – if the ‘details’ namespace is not in the Info.
copy(to_datetime=None)

Create a copy of this resource info object.

created

Get the time this resource was created, or None if not available.

Requires the "details" namespace.

Return type:datetime
Raises:MissingInfoNamespace – if the ‘details’ namespace is not in the Info.
get(namespace, key, default=None)

Get a raw info value.

>>> info.get('access', 'permissions')
['u_r', 'u_w', '_wx']
Parameters:
  • namespace (str) – A namespace identifier.
  • key (str) – A key within the namespace.
  • default – A default value to return if either the namespace or namespace + key is not found.
gid

Get the group id of a resource, or None if not available.

Requires the "access" namespace.

Return type:int
Raises:MissingInfoNamespace – if the ‘access’ namespace is not in the Info.
group

Get the group of the resource owner, or None if not available.

Requires the "access" namespace.

Return type:str
Raises:MissingInfoNamespace – if the ‘access’ namespace is not in the Info.
has_namespace(namespace)

Check if the resource info contains a given namespace.

Parameters:namespace (str) – A namespace name.
Return type:bool
is_dir

Check if the resource references a directory.

Return type:bool
is_file

Check if a resource references a file.

Return type:bool

Check if a resource is a symlink.

Return type:bool
is_writeable(namespace, key)

Check if a given key in a namespace is writable (with setinfo()).

Parameters:
  • namespace (str) – A namespace identifier.
  • key (str) – A key within the namespace.
Return type:

bool

make_path(dir_path)

Make a path by joining dir_path with the resource name.

Parameters:dir_path (str) – A path to a directory.
Returns:A path.
Return type:str
metadata_changed

Get the time the metadata changed, or None if not available.

Requires the "details" namespace.

Return type:datetime
Raises:MissingInfoNamespace – if the ‘details’ namespace is not in the Info.
modified

Get the time the resource was modified, or None if not available.

Requires the "details" namespace.

Return type:datetime
Raises:MissingInfoNamespace – if the ‘details’ namespace is not in the Info.
name

Get the resource name.

Return type:str
permissions

Get a permissions object, or None if not available.

Requires the "access" namespace.

Return type:fs.permissions.Permissions
Raises:MissingInfoNamespace – if the ‘access’ namespace is not in the Info.
size

Get the size of the resource, in bytes.

Requires the "details" namespace.

Return type:int
Raises:MissingInfoNamespace – if the ‘details’ namespace is not in the Info.
target

Get the link target, if this is a symlink, or None if this is not a symlink.

Requires the "link" namespace.

Return type:bool
Raises:MissingInfoNamespace – if the ‘link’ namespace is not in the Info.
type

Get the resource type enumeration.

Requires the "details" namespace.

Type:ResourceType
Raises:MissingInfoNamespace – if the ‘details’ namespace is not in the Info.
uid

Get the user id of a resource, or None if not available.

Requires the "access" namespace.

Return type:int
Raises:MissingInfoNamespace – if the ‘access’ namespace is not in the Info.
user

Get the owner of a resource, or None if not available.

Requires the "access" namespace.

Return type:str
Raises:MissingInfoNamespace – if the ‘access’ namespace is not in the Info.