Camlipy

Unofficial Python client for Camlistore.

Camlipy on GitHub.

API Documentation

camlipy

Camlistore client.

camlipy.compute_hash(data, blocksize=4096)

Return the hash object for the file `filepath’, processing the file by chunk of `blocksize’.

Parameters:
  • filepath (data) – string or fileobj
  • blocksize (int) – Size of the chunk when processing the file
camlipy.check_hash(_hash)

Check if the hash is valid.

class camlipy.Camlistore(server='http://localhost:3179', auth=None)

Camlistore Python client

Args:
server: server address auth: tuple (user, password) if authentication is enabled.
add_to_static_set(blob_refs)

Shortcut to create a new static-set.

describe_blob(blobref)

Return blob meta data.

get_blob(blobref)

Retrieve blob content, return a fileobj. If the blob is a schema, it returns a dict.

get_directory(br, path)

Shortcut for restoring/retrieving a directory.

Call camlipy.directory.get_directory under the hood.

get_file(blob_ref, fileobj=None)

Shortcut for downloading/restoring a file.

Call camlipy.filereader.get_file under the hood.

permanode(blob_ref=None)

Shortcut to initialize a permanode.

permanode_by_title(title, create=False)

Shortcut to fetch the first permanode with the given title.

planned_permanode(blob_ref=None)

Shortcut to initialize a planned permanode.

put_blob(blob)

Shortcut/helper for uploading a single blob.

Blob can be either a string or a fileobj.

put_blobs(blobs)

Upload blobs using with standard multi-part upload. Returns a dict with received (blobref and size) and skipped (blobref only)

put_directory(path, permanode=False)

Shortcut for upload an entire directory.

Call camlipy.directory.put_directory under the hood.

put_file(path=None, fileobj=None, permanode=False)

Shortcut for uploading a file along with its meta-data.

Call camlipy.filewriter.put_file under the hood.

search(value, attr='', fuzzy=False, max=100)

Perform query with the same syntax as Camistore ui.

Examples of queries: - tag:mytag - title:my_text_file.txt - my query

static_set(blob_ref=None)

Shortcut to initialize a static-set.

camlipy.directory

Helper for uploading recursively directory.

camlipy.directory.get_directory(con, br, path)

Download a directory.

camlipy.directory.put_directory(con, path, permanode=False)

Helper to put a directory.

camlipy.filereader

Read the file schema, and output chunk in a temp file.

camlipy.filereader.get_file(con, blob_ref, fileobj=None)

Helper for download a file from his blobRef to a fileobj.

camlipy.filewriter

Helper for uploading file, takes care of chunking file, create the file schema.

class camlipy.filewriter.Span(_from=0, to=0, bits=None, children=[], chunk_cnt=0, br=None, size=None)

Chunk metadata, used to create the tree, and compute chunk/bytesRef size.

camlipy.filewriter.put_file(con, path=None, fileobj=None, permanode=False)

Helper for uploading a file to a Camlistore server.

Specify either a path, or a fileobj.

Can also create a permanode.

camlipy.schema

Helper for creating/loading schemas.

class camlipy.schema.Bytes(con, br=None)

Bytes schema.

class camlipy.schema.Claim(con, permanode_blobref, claim_blobref=None)

Claim schema with support for set/add/del attribute.

class camlipy.schema.Directory(con, path=None, blob_ref=None)

Directory Schema

class camlipy.schema.File(con, path=None, file_name=None, blob_ref=None)

File schema.

file_name is guessed from path if provided.

class camlipy.schema.FileCommon(con, path=None, blob_ref=None)

FileCommon schema.

class camlipy.schema.Permanode(con, permanode_blob_ref=None)

Permanode Schema with helpers for claims.

add_attr(attr, value)

Create a claim to add avlue to attr.

add_camli_member(camli_member)

Append a new camliMember.

claims()

Return claims for the current permanode.

delete_attr(attr, value=None)

Create a claim to delete attr/attr:value.

get_attr(attr)

Retrieve attr from indexer.

get_camli_content()

Fetch the current camliContent blobRef.

get_camli_member()

Fetch the current camliMember blobRef.

save(camli_content=None, camli_member=None, title=None, tags=[])

Create the permanode, takes optional title and tags.

set_attr(attr, value, claim_date=None)

Create a claim to set attr to value.

set_camli_content(camli_content, claim_date=None)

Create a new camliContent claim.

class camlipy.schema.PlannedPermanode(con, permanode_blob_ref=None)

A planned permanode is like a normal permanode, except it have a meaningful “key” key, and a meaningful “claimDate”, so the signature for the given key, claimDate is always the same.

class camlipy.schema.Schema(con, blob_ref=None)

Basic Schema base class.

Also used to load (and decoding?) existing schema.

Args:
con: Camlistore instance blob_ref: Optional blobRef if the blob already exists.
describe()

Call the API to describe the blob.

json()

Return json data.

sign()

Return signed json.

class camlipy.schema.StaticSet(con, br=None)

StaticSet schema.

update(members=[])

Update a static-set by creating a new one.

camlipy.schema.dt_to_camli_iso(dt)

Convert a datetime to iso datetime compatible with camlistore.

camlipy.schema.get_stat_info(path)

Return OS stat info for the given path.

camlipy.schema.ts_to_camli_iso(ts)

Convert timestamp to UTC iso datetime compatible with camlistore.

camlipy.search

Search API wrapper.

class camlipy.search.Search(con)

Basic search wrapper around the API.

search(value, attr='', fuzzy=False, max=100)

Perform query with the same syntax as Camistore ui.

Examples of queries: - tag:mytag - title:my_text_file.txt - my query