Giter Club home page Giter Club logo

fossilpy's Introduction

fossilpy

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.

fossilpy's People

Contributors

gumblex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

fossilpy's Issues

fossilpy might benefit from libfossil

Hello Gumblex,

You might like to look at calling libfossil from Python to achieve your goals? https://fossil.wanderinghorse.net/r/libfossil/ has scripting bindings, although not yet for Python.

Looking at the comments in fossilpy, I can assure you that there is little value in trying to use SQL directly, although Fossil has an 'sql' command that can be useful. And there are code examples that will enable you to access pretty much any level of detail you like from a Fossil repo.

Dan Shearer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.