fs.info¶
Container for filesystem resource informations.
-
class
fs.info.
Info
(raw_info, to_datetime=<function epoch_to_datetime>)¶ Container for Resource Info.
Resource informations are returned by the following methods:
Parameters: - raw_info (dict) – A dict containing resource info.
- to_datetime (callable) – A callable that converts an
epoch time to a datetime object. The default uses
epoch_to_datetime()
.
-
accessed
¶ datetime
– the resource last access time, orNone
.Requires the
"details"
namespace.Raises: MissingInfoNamespace
– if the"details"
namespace is not in the Info.
-
copy
(to_datetime=None)¶ Create a copy of this resource info object.
-
created
¶ datetime
– the resource creation time, orNone
.Requires the
"details"
namespace.Raises: MissingInfoNamespace
– if the"details"
namespace is not in the Info.
-
get
(namespace, key, default=None)¶ Get a raw info value.
Parameters: Example
>>> info.get('access', 'permissions') ['u_r', 'u_w', '_wx']
-
gid
¶ int
– the group id of the resource, orNone
.Requires the
"access"
namespace.Raises: MissingInfoNamespace
– if the"access"
namespace is not in the Info.
-
group
¶ str
– the group of the resource owner, orNone
.Requires the
"access"
namespace.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 identifier. Returns: True
if the namespace was found,False
otherwise.Return type: bool
-
is_writeable
(namespace, key)¶ Check if a given key in a namespace is writable.
Uses
setinfo
.Parameters: Returns: Return type:
-
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 to the resource. Return type: str
-
metadata_changed
¶ datetime
– the resource metadata change time, orNone
.Requires the
"details"
namespace.Raises: MissingInfoNamespace
– if the"details"
namespace is not in the Info.
-
modified
¶ datetime
– the resource last modification time, orNone
.Requires the
"details"
namespace.Raises: MissingInfoNamespace
– if the"details"
namespace is not in the Info.
-
permissions
¶ Permissions
– the permissions of the resource, orNone
.Requires the
"access"
namespace.Raises: MissingInfoNamespace
– if the"access"
namespace is not in the Info.
-
size
¶ int
– the size of the resource, in bytes.Requires the
"details"
namespace.Raises: MissingInfoNamespace
– if the"details"
namespace is not in the Info.
-
suffix
¶ str
– the last component of the name (including dot), or an empty string if there is no suffix.Example
>>> info <info 'foo.py'> >>> info.suffix '.py'
-
suffixes
¶ List
– a list of any suffixes in the name.Example
>>> info <info 'foo.tar.gz'> >>> info.suffixes ['.tar', '.gz']
-
target
¶ str
– the link target (if resource is a symlink), orNone
.Requires the
"link"
namespace.Raises: MissingInfoNamespace
– if the"link"
namespace is not in the Info.
-
type
¶ ResourceType
– the type of the resource.Requires the
"details"
namespace.Raises: MissingInfoNamespace
– if the ‘details’ namespace is not in the Info.
-
uid
¶ int
– the user id of the resource, orNone
.Requires the
"access"
namespace.Raises: MissingInfoNamespace
– if the"access"
namespace is not in the Info.
-
user
¶ str
– the owner of the resource, orNone
.Requires the
"access"
namespace.Raises: MissingInfoNamespace
– if the"access"
namespace is not in the Info.