Pyjo.Asset - HTTP content storage base class

import Pyjo.Asset

class MyAsset(Pyjo.Asset.object):
    def add_chunk(self, chunk=b''):
        ...

    def close():
        ...

    def contains(self, chunk):
        ...

    def get_chunk(self, offset, maximum=131072):
        ...

    def move_to(self, dst):
        ...

    @property
    def mtime(self):
        ...

    @property
    def size(self):
        ...

    def slurp(self):
        ...

Pyjo.Asset is an abstract base class for HTTP content storage.

Events

Pyjo.Asset inherits all events from Pyjo.EventEmitter.

Classes

class Pyjo.Asset.Pyjo_Asset(**kwargs)

Pyjo.Asset inherits all attributes and methods from Pyjo.EventEmitter and implements the following new ones.

add_chunk(*args, **kwargs)
asset = asset.add_chunk('foo bar baz')

Add chunk of data to asset. Meant to be overloaded in a subclass.

close()
asset.close()

Close asset immediately and free resources. Used by context manager.

contains(*args, **kwargs)
position = asset.contains(b'bar')

Check if asset contains a specific string. Meant to be overloaded in a subclass.

end_range = None
end = asset.end_range
asset.end_range = 8

Pretend file ends earlier.

get_chunk(*args, **kwargs)
bstream = asset.get_chunk(offset)
bstream = asset.get_chunk(offset, maximum)

Get chunk of data starting from a specific position, defaults to a maximum chunk size of 131072 bytes (128KB). Meant to be overloaded in a subclass.

is_file
false = asset.is_file

False.

is_range
boolean = asset.is_range

Check if asset has a start_range or end_range.

move_to(*args, **kwargs)
asset = asset.move_to('/home/pyjo/foo.txt')

Move asset data into a specific file. Meant to be overloaded in a subclass.

mtime
mtime = asset.mtime

Modification time of asset. Meant to be overloaded in a subclass.

size
size = asset.size

Size of asset data in bytes. Meant to be overloaded in a subclass.

slurp(*args, **kwargs)
bstring = asset.slurp()

Read all asset data at once. Meant to be overloaded in a subclass.

start_range = None
start = asset.start_range
asset.start_range = 3

Pretend file starts later.

Pyjo.Asset.object

alias of Pyjo_Asset