dulwich.contrib.swift module¶
Repo implementation atop OpenStack SWIFT.
-
class
dulwich.contrib.swift.PackInfoMissingObjectFinder(object_store, haves, wants, progress=None, get_tagged=None, concurrency=1, get_parents=None)¶ Bases:
dulwich.greenthreads.GreenThreadsMissingObjectFinder-
next()¶
-
-
class
dulwich.contrib.swift.PackInfoObjectStoreIterator(store, shas, finder, concurrency=1)¶
-
class
dulwich.contrib.swift.SwiftConnector(root, conf)¶ Bases:
objectA Connector to swift that manage authentication and errors catching
Initialize a SwiftConnector
Parameters: - root – The swift container that will act as Git bare repository
- conf – A ConfigParser Object
-
create_root()¶ Create the Swift container
Raise: SwiftException if unable to create
-
del_object(name)¶ Delete an object
Parameters: name – The object name Raise: SwiftException if unable to delete
-
del_root()¶ Delete the root container by removing container content
Raise: SwiftException if unable to delete
-
get_container_objects()¶ Retrieve objects list in a container
Returns: A list of dict that describe objects or None if container does not exist
-
get_object(name, range=None)¶ Retrieve an object
Parameters: - name – The object name
- range – A string range like “0-10” to retrieve specified bytes in object content
Returns: A file like instance or bytestring if range is specified
-
get_object_stat(name)¶ Retrieve object stat
Parameters: name – The object name Returns: A dict that describe the object or None if object does not exist
-
put_object(name, content)¶ Put an object
Parameters: - name – The object name
- content – A file object
Raise: SwiftException if unable to create
-
swift_auth_v1()¶
-
swift_auth_v2()¶
-
test_root_exists()¶ Check that Swift container exist
Returns: True if exist or None it not
-
exception
dulwich.contrib.swift.SwiftException¶ Bases:
exceptions.Exception
-
class
dulwich.contrib.swift.SwiftInfoRefsContainer(scon, store)¶ Bases:
dulwich.refs.InfoRefsContainerManage references in info/refs object.
-
allkeys()¶ All refs present in this container.
-
remove_if_equals(name, old_ref)¶ Remove a refname only if it currently equals old_ref.
-
set_if_equals(name, old_ref, new_ref)¶ Set a refname to new_ref only if it currently equals old_ref.
-
-
class
dulwich.contrib.swift.SwiftObjectStore(scon)¶ Bases:
dulwich.object_store.PackBasedObjectStoreA Swift Object Store
Allow to manage a bare Git repository from Openstack Swift. This object store only supports pack files and not loose objects.
Open a Swift object store.
Parameters: scon – A SwiftConnector instance -
add_object(obj)¶ Add a single object to this object store.
-
add_pack()¶ Add a new pack to this object store.
Returns: Fileobject to write to and a commit function to call when the pack is finished.
-
add_thin_pack(read_all, read_some)¶ Read a thin pack
Read it from a stream and complete it in a temporary file. Then the pack and the corresponding index file are uploaded to Swift.
-
find_missing_objects(*args, **kwargs)¶ Find the missing objects required for a set of revisions.
Parameters: - haves – Iterable over SHAs already in common.
- wants – Iterable over SHAs of objects to fetch.
- progress – Simple progress function that will be called with updated progress strings.
- get_tagged – Function that returns a dict of pointed-to sha -> tag sha for including tags.
- get_parents – Optional function for getting the parents of a commit.
Returns: Iterator over (sha, path) pairs.
-
iter_shas(finder)¶ An iterator over pack’s ObjectStore.
Returns: a ObjectStoreIterator or GreenThreadsObjectStoreIterator instance if gevent is enabled
-
pack_info_get(sha)¶
-
-
class
dulwich.contrib.swift.SwiftPack(*args, **kwargs)¶ Bases:
dulwich.pack.PackA Git pack object.
Same implementation as pack.Pack except that _idx_load and _data_load are bounded to Swift version of load_pack_index and PackData.
-
pack_info¶ The pack data object being used.
-
-
class
dulwich.contrib.swift.SwiftPackData(scon, filename)¶ Bases:
dulwich.pack.PackDataThe data contained in a packfile.
We use the SwiftPackReader to read bytes from packs stored in Swift using the Range header feature of Swift.
Initialize a SwiftPackReader
Parameters: - scon – a SwiftConnector instance
- filename – the pack filename
-
close()¶
-
get_object_at(offset)¶ Given an offset in to the packfile return the object that is there.
Using the associated index the location of an object can be looked up, and then the packfile can be asked directly for that object using this function.
-
get_stored_checksum()¶ Return the expected checksum stored in this pack.
-
class
dulwich.contrib.swift.SwiftPackReader(scon, filename, pack_length)¶ Bases:
objectA SwiftPackReader that mimic read and sync method
The reader allows to read a specified amount of bytes from a given offset of a Swift object. A read offset is kept internaly. The reader will read from Swift a specified amount of data to complete its internal buffer. chunk_length specifiy the amount of data to read from Swift.
Initialize a SwiftPackReader
Parameters: - scon – a SwiftConnector instance
- filename – the pack filename
- pack_length – The size of the pack object
-
read(length)¶ Read a specified amount of Bytes form the pack object
Parameters: length – amount of bytes to read Returns: bytestring
-
read_checksum()¶ Read the checksum from the pack
Returns: the checksum bytestring
-
seek(offset)¶ Seek to a specified offset
Parameters: offset – the offset to seek to
-
class
dulwich.contrib.swift.SwiftRepo(root, conf)¶ Bases:
dulwich.repo.BaseRepoInit a Git bare Repository on top of a Swift container.
References are managed in info/refs objects by SwiftInfoRefsContainer. The root attribute is the Swift container that contain the Git bare repository.
Parameters: - root – The container which contains the bare repo
- conf – A ConfigParser object
-
classmethod
init_bare(scon, conf)¶ Create a new bare repository.
Parameters: - scon – a SwiftConnector instance
- conf – a ConfigParser object
Returns: a SwiftRepo instance
-
class
dulwich.contrib.swift.SwiftSystemBackend(logger, conf)¶ Bases:
dulwich.server.Backend-
open_repository(path)¶ Open the repository at a path.
Parameters: path – Path to the repository Raises: NotGitRepository – no git repository was found at path Returns: Instance of BackendRepo
-
-
dulwich.contrib.swift.cmd_daemon(args)¶ Entry point for starting a TCP git server.
-
dulwich.contrib.swift.cmd_init(args)¶
-
dulwich.contrib.swift.load_conf(path=None, file=None)¶ Load configuration in global var CONF
Parameters: - path – The path to the configuration file
- file – If provided read instead the file like object
-
dulwich.contrib.swift.load_pack_info(filename, scon=None, file=None)¶
-
dulwich.contrib.swift.main(argv=['/usr/bin/sphinx-build', '-b', 'html', '-d', 'build/doctrees', '.', 'build/html'])¶
-
dulwich.contrib.swift.pack_info_create(pack_data, pack_index)¶
-
dulwich.contrib.swift.swift_load_pack_index(scon, filename)¶ Read a pack index file from Swift
Parameters: - scon – a SwiftConnector instance
- filename – Path to the index file objectise
Returns: a PackIndexer instance