fs.info

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

Container for 资源信息, returned by the following methods:

参数:
  • 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.

返回类型:datetime
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.

返回类型:datetime
get(namespace, key, default=None)

Get a raw info value.

>>> info.get('access', 'permissions')
['u_r', 'u_w', '_wx']
参数:
  • 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.

返回类型:int
group

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

Requires the "access" namespace.

返回类型:str
has_namespace(namespace)

Check if the resource info contains a given namespace.

参数:namespace (str) – A namespace name.
返回类型:bool
is_dir

Check if the resource references a directory.

返回类型:bool
is_file

Check if a resource references a file.

返回类型:bool
is_writeable(namespace, key)

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

参数:
  • namespace (str) – A namespace identifier.
  • key (str) – A key within the namespace.
返回类型:

bool

make_path(dir_path)

Make a path by joining dir_path with the resource name.

参数:dir_path (str) – A path to a directory.
返回:A path.
返回类型:str
metadata_changed

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

Requires the "details" namespace.

返回类型:datetime
modified

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

Requires the "details" namespace.

返回类型:datetime
name

Get the resource name.

返回类型:str
permissions

Get a permissions object, or None if not available.

Requires the "access" namespace.

返回类型:fspermissions.Permissions
size

Get the size of the resource, in bytes.

Requires the "details" namespace.

返回类型:int
type

Get the resource type enumeration.

Requires the "details" namespace.

Type:ResourceType
uid

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

Requires the "access" namespace.

返回类型:int
user

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

Requires the "access" namespace.

返回类型:str