Buckets and Files

Manage buckets and files on the server.

class renga.models.storage.BucketCollection(client=None)[source]

Represent storage buckets on the server.

Create representation of objects on the server.

class Meta[source]

Information about individual buckets.

model

alias of Bucket

backends

Return a list of the enabled backends.

create(name=None, backend='local', **kwargs)[source]

Create new Bucket instance.

list()

Return list if the collection is iterable.

Bucket objects

class renga.models.storage.Bucket[source]

Represent a storage bucket.

Create representation of object on the server.

backend

The backend of this bucket.

files

The FileCollection instance.

id

The identifier of the object.

name

The bucket name.

Files

Manage files in the bucket.

class renga.models.storage.FileCollection(bucket, **kwargs)[source]

Represent files in a bucket on the server.

Initialize collection of files in the bucket.

class Meta[source]

Information about individual files.

model

alias of File

create(file_name=None)[source]

Create an empty file in this bucket.

from_url(url, file_name=None)[source]

Create a file with data from the streamed GET response.

Example

>>> file_ = client.buckets[1234].files.from_url(
...     'https://example.com/tests/data', file_name='hello')
>>> file_.open('r').read()
b'hello world'
list()

Return list if the collection is iterable.

open(file_name=None, mode='w')[source]

Create an empty file in this bucket.

File objects

class renga.models.storage.File[source]

Represent a file object.

Create representation of object on the server.

access_token

The access token for performing file operations.

filename

Filename of the file.

id

The identifier of the object.

open(mode='r')[source]

Return the FileHandle instance.

File handle objects

class renga.models.storage.FileHandle[source]

An object exposing a pythonic file-oriented API.

Depending on the bucket to which it belongs to, a file object can mediate access to different storage backends (local, Swift, etc).

Create representation of object on the server.

can_read

Check if the file handle is readable.

can_write

Check if the file handle is writable.

from_url(url)[source]

Write data from the streamed GET response from the given URL.

Example

>>> with client.buckets[1234].files[1234].open('w') as fp:
...     fp.from_url('https://example.com/tests/data')
id

The identifier of the object.

read(*args, **kwargs)[source]

Read data from the file.

write(data)[source]

Write data to the file.