fs.info¶
Container for filesystem resource informations.
- class fs.info.Info(raw_info: RawInfo, to_datetime: ToDatetime = <function epoch_to_datetime>)[source]¶
Container for Resource Info.
Resource information is 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
.
- __init__(raw_info: RawInfo, to_datetime: ToDatetime = <function epoch_to_datetime>) None [source]¶
Create a resource info object from a raw info dict.
- property accessed¶
the resource last access time, or
None
.Requires the
"details"
namespace.- Raises:
MissingInfoNamespace – if the
"details"
namespace is not in the Info.- Type:
- copy(to_datetime: Optional[ToDatetime] = None) Info [source]¶
Create a copy of this resource info object.
- property created¶
the resource creation time, or
None
.Requires the
"details"
namespace.- Raises:
MissingInfoNamespace – if the
"details"
namespace is not in the Info.- Type:
- get(namespace: Text, key: Text, default: Optional[Any] = None) Optional[Any] [source]¶
Get a raw info value.
- Parameters:
Example
>>> info = my_fs.getinfo("foo.py", namespaces=["details"]) >>> info.get('details', 'type') 2
- property gid¶
the group id of the resource, or
None
.Requires the
"access"
namespace.- Raises:
MissingInfoNamespace – if the
"access"
namespace is not in the Info.- Type:
- property group¶
the group of the resource owner, or
None
.Requires the
"access"
namespace.- Raises:
MissingInfoNamespace – if the
"access"
namespace is not in the Info.- Type:
- is_writeable(namespace: str, key: str) bool [source]¶
Check if a given key in a namespace is writable.
When creating an
Info
object, you can add a_write
key to each raw namespace that lists which keys are writable or not.In general, this means they are compatible with the
setinfo
function of filesystem objects.- Parameters:
- Returns:
- Return type:
Example
Create an
Info
object that marks only themodified
key as writable in thedetails
namespace:>>> now = time.time() >>> info = Info({ ... "basic": {"name": "foo", "is_dir": False}, ... "details": { ... "modified": now, ... "created": now, ... "_write": ["modified"], ... } ... }) >>> info.is_writeable("details", "created") False >>> info.is_writeable("details", "modified") True
- property metadata_changed¶
the resource metadata change time, or
None
.Requires the
"details"
namespace.- Raises:
MissingInfoNamespace – if the
"details"
namespace is not in the Info.- Type:
- property modified¶
the resource last modification time, or
None
.Requires the
"details"
namespace.- Raises:
MissingInfoNamespace – if the
"details"
namespace is not in the Info.- Type:
- property permissions¶
the permissions of the resource, or
None
.Requires the
"access"
namespace.- Raises:
MissingInfoNamespace – if the
"access"
namespace is not in the Info.- Type:
Permissions
- property size¶
the size of the resource, in bytes.
Requires the
"details"
namespace.- Raises:
MissingInfoNamespace – if the
"details"
namespace is not in the Info.- Type:
- property stem¶
the name minus any suffixes.
Example
>>> info = my_fs.getinfo("foo.tar.gz") >>> info.stem 'foo'
- Type:
- property suffix¶
the last component of the name (with dot).
In case there is no suffix, an empty string is returned.
Example
>>> info = my_fs.getinfo("foo.py") >>> info.suffix '.py' >>> info2 = my_fs.getinfo("bar") >>> info2.suffix ''
- Type:
- property suffixes¶
a list of any suffixes in the name.
Example
>>> info = my_fs.getinfo("foo.tar.gz") >>> info.suffixes ['.tar', '.gz']
- Type:
List
- property target¶
the link target (if resource is a symlink), or
None
.Requires the
"link"
namespace.- Raises:
MissingInfoNamespace – if the
"link"
namespace is not in the Info.- Type:
- property type¶
the type of the resource.
Requires the
"details"
namespace.- Raises:
MissingInfoNamespace – if the ‘details’ namespace is not in the Info.
- Type:
- property uid¶
the user id of the resource, or
None
.Requires the
"access"
namespace.- Raises:
MissingInfoNamespace – if the
"access"
namespace is not in the Info.- Type:
- property user¶
the owner of the resource, or
None
.Requires the
"access"
namespace.- Raises:
MissingInfoNamespace – if the
"access"
namespace is not in the Info.- Type: