Simple pure-python library for reading Fossil repositories.
Project description
Simple pure-python library for reading Fossil repositories.
>>> r = Repo('project.fossil')
>>> f = r.file(123)
>>> f.blob
b'File content...'
>>> filelist = r.manifest(124).F
>>> filelist
[('file', '1234567890aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')]
This is a thin wrapper, and Fossil is an SQLite-based version control system. So using raw SQL (Repo.execute) may be necessary to get more information.
Writing, committing, or executing Fossil commands is not supported. (Although you can do SQL, writing is not recommended.) Reading the config database (~/.fossil), the checkout database (_FOSSIL_), or the checkout directory is also not supported.
Install python-fossil-delta for better performance.
API
Classes
Repo(repository, check=False, cachesize=64): Represents a Fossil repo. repository is the file name. check specifies whether to calculate checksum. If numpy is not installed, calculation will be much slower. cachesize specifies how much blobs should be cached, set to 0 to disable.
Repo.file(self, key): Returns a File according to the key, which is either the blob’s rid or uuid (SHA1/SHA3-256).
Repo.manifest(self, key): Returns a StructuralArtifact according to the key.
Repo.artifact(self, key, type_=None): Returns an Artifact according to the key. type_ can be 'structural' or 'file'.
Repo.__getitem__(self, key): Returns an Artifact according to the key.
Repo.find_artifact(self, prefix): Given the uuid (SHA1/SHA3-256) prefix, returns a tuple (rid, uuid). If not found, raises a KeyError.
Repo.to_uuid(self, rid): Given the rid, returns the uuid of a blob. If not found, raises an IndexError.
Repo.to_rid(self, uuid): Given the uuid, returns the rid of a blob. If not found, raises an IndexError.
Repo.execute(self, sql, parameters=None): Execute raw SQL statements on the Fossil repo (SQLite database). See also src/schema.c.
Artifact(blob=None, rid=None, uuid=None): Represents a Fossil artifact, which is anything inside the blob table. Has attributes blob, rid and uuid. blob is the artifact(file) content.
File(blob=None, rid=None, uuid=None): Represents a file, same as Artifact.
StructuralArtifact(blob=None, rid=None, uuid=None): Represent a structural artifact, aka. manifest, can be such as check-in, wiki and tickets.
StructuralArtifact.keys(): List cards.
StructuralArtifact.cards: Dictionary of cards. If a card type can occur multiple times, cards of the same type are stored in a list.
Cards can be accessed like art.F, art['F'] or art.file. See also Fossil documentation. Some useful cards: F(file), C(comment), P(parent_artifact), U(user_login), D(datetime), W(wiki_text)
Misc.
LRUCache(maxlen): A simple implementation of least recently used (LRU) cache.
Fossil uses Julian date in most tables.
julian_to_unix(t): Convert Julian date t to unix timestamp.
unix_to_julian(t): Convert unix timestamp t to Julian date.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file fossilpy-0.3.1.tar.gz
.
File metadata
- Download URL: fossilpy-0.3.1.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb88d85062c8d9fbc5d1d1ec005c76266a59671d1b648b6e510a6f06335a75c1 |
|
MD5 | 311ff9e8048a7c8e6b08878d0df5c357 |
|
BLAKE2b-256 | 5a22c91cac9d28a45c0f01ac6e34521c13076c373ff184c793bdf66824243686 |