Base

class audbackend.interface.Base(backend)[source]

Interface base class.

Provides an interface to a backend, see e.g. audbackend.Unversioned and audbackend.Versioned.

Derive from this class to create a new interface.

Parameters

backend (Base) – backend object

backend

Base.backend

Backend object.

Returns

backend object

Examples

>>> interface.backend
audbackend.backend.FileSystem('host', 'repo')

host

Base.host

Host path.

Returns: host path

Examples

>>> interface.host
'host'

join()

Base.join(path, *paths)[source]

Join to path on backend.

Parameters
  • path (str) – first part of path

  • *paths – additional parts of path

Return type

str

Returns

path joined by Backend.sep

Raises

ValueError – if path contains invalid character or does not start with '/', or if joined path contains invalid character

Examples

>>> interface.join("/", "file.txt")
'/file.txt'
>>> interface.join("/sub", "file.txt")
'/sub/file.txt'
>>> interface.join("//sub//", "/", "", None, "/file.txt")
'/sub/file.txt'

repository

Base.repository

Repository name.

Returns

repository name

Examples

>>> interface.repository
'repo'

sep

Base.sep

File separator on backend.

Returns

file separator

Examples

>>> interface.sep
'/'

split()

Base.split(path)[source]

Split path on backend into sub-path and basename.

Parameters

path (str) – path containing Backend.sep as separator

Return type

Tuple[str, str]

Returns

tuple containing (root, basename)

Raises

ValueError – if path does not start with '/' or does not match '[A-Za-z0-9/._-]+'

Examples

>>> interface.split("/")
('/', '')
>>> interface.split("/file.txt")
('/', 'file.txt')
>>> interface.split("/sub/")
('/sub/', '')
>>> interface.split("/sub//file.txt")
('/sub/', 'file.txt')