FilePath

class audobject.resolver.FilePath[source]

File path resolver.

Turns file path to a relative path when object is serialized to a file and expands it again during reading.

Examples

>>> resolver = FilePath()
>>> resolver._object_root_ = '/some/root'  # usually set by object
>>> value = '/some/where/else'
>>> encoded_value = resolver.encode(value)
>>> encoded_value  
'../where/else'
>>> resolver.decode(encoded_value)  
'/some/where/else'

__hash__()

FilePath.__hash__()

Return hash(self).

decode()

FilePath.decode(value)[source]

Decode file path.

If object is read from a file, this will convert a relative file path to an absolute path by expanding it with the source directory.

Parameters

value (str) – relative file path

Return type

str

Returns

expanded file path

encode()

FilePath.encode(value)[source]

Encode file path.

If object is written to a file, this will convert a file path to a path that is relative to the target directory.

Parameters

value (str) – original file path

Return type

str

Returns

relative file path

encode_type()

FilePath.encode_type()[source]

Return encoded type.

Return type

type

Returns

encoded type

root

FilePath.root

Root folder.

Returns root folder when object is serialized to or from a file, otherwise None is returned.

Returns

root directory