-- -- --- --- --- --- --- --- ------- ------- ------- |
"""
-- -- --- --- --- --- --- --- ------- ------- ------- |
Archivers module.
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
Specifies a standard interface for finding revisions (versions) of a path and switching to them.
-- -- --- --- --- --- --- --- ------- ------- ------- |
"""
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
from collections import namedtuple
-- -- --- --- --- --- --- --- ------- ------- ------- |
from dataclasses import dataclass
-- -- --- --- --- --- --- --- ------- ------- ------- |
from typing import List
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
02 -- --- --- --- --- --- --- ------- ------- ------- |
class BaseArchiver(object):
02 -- --- --- --- --- --- --- ------- ------- ------- |
"""Abstract Archiver Class."""
02 -- --- --- --- --- --- --- ------- ------- ------- |
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
def revisions(self, path, max_revisions):
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
"""
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
Get the list of revisions.
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
:param path: the path to target.
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
:type path: ``str``
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
:param max_revisions: the maximum number of revisions.
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
:type max_revisions: ``int``
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
:return: A list of revisions.
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
:rtype: ``list`` of :class:`Revision`
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
"""
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
raise NotImplementedError
02 -- --- --- --- --- --- --- ------- ------- ------- |
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
def checkout(self, revision, **options):
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
"""
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
Checkout a specific revision.
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
:param revision: The revision identifier.
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
:type revision: :class:`Revision`
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
:param options: Any additional options.
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
:type options: ``dict``
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
"""
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
raise NotImplementedError
02 -- --- --- --- --- --- --- ------- ------- ------- |
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
def finish(self):
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
"""Clean up any state if processing completed/failed."""
02 01 000 000 000 000 000 000 0000.00 0000.00 0000.00 |
pass
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
@dataclass
01 -- --- --- --- --- --- --- ------- ------- ------- |
class Revision:
01 -- --- --- --- --- --- --- ------- ------- ------- |
"""Represents a revision in the archiver."""
01 -- --- --- --- --- --- --- ------- ------- ------- |
01 -- --- --- --- --- --- --- ------- ------- ------- |
key: str
01 -- --- --- --- --- --- --- ------- ------- ------- |
author_name: str
01 -- --- --- --- --- --- --- ------- ------- ------- |
author_email: str
01 -- --- --- --- --- --- --- ------- ------- ------- |
date: str
01 -- --- --- --- --- --- --- ------- ------- ------- |
message: str
01 -- --- --- --- --- --- --- ------- ------- ------- |
files: List[str]
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
from wily.archivers.git import GitArchiver
-- -- --- --- --- --- --- --- ------- ------- ------- |
from wily.archivers.filesystem import FilesystemArchiver
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
"""Type for an operator"""
-- -- --- --- --- --- --- --- ------- ------- ------- |
Archiver = namedtuple("Archiver", "name cls description")
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
"""Git Operator defined in `wily.archivers.git`"""
-- -- --- --- --- --- --- --- ------- ------- ------- |
ARCHIVER_GIT = Archiver(name="git", cls=GitArchiver, description="Git archiver")
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
"""Filesystem archiver"""
-- -- --- --- --- --- --- --- ------- ------- ------- |
ARCHIVER_FILESYSTEM = Archiver(
-- -- --- --- --- --- --- --- ------- ------- ------- |
name="filesystem", cls=FilesystemArchiver, description="Filesystem archiver"
-- -- --- --- --- --- --- --- ------- ------- ------- |
)
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
"""Set of all available archivers"""
-- -- --- --- --- --- --- --- ------- ------- ------- |
ALL_ARCHIVERS = {a.name: a for a in [ARCHIVER_GIT, ARCHIVER_FILESYSTEM]}
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- 02 001 002 001 002 003 003 0004.75 0002.38 0000.50 |
def resolve_archiver(name):
-- 02 001 002 001 002 003 003 0004.75 0002.38 0000.50 |
"""
-- 02 001 002 001 002 003 003 0004.75 0002.38 0000.50 |
Get the :class:`wily.archivers.Archiver` for a given name.
-- 02 001 002 001 002 003 003 0004.75 0002.38 0000.50 |
-- 02 001 002 001 002 003 003 0004.75 0002.38 0000.50 |
:param name: The name of the archiver
-- 02 001 002 001 002 003 003 0004.75 0002.38 0000.50 |
:type name: ``str``
-- 02 001 002 001 002 003 003 0004.75 0002.38 0000.50 |
:return: The archiver type
-- 02 001 002 001 002 003 003 0004.75 0002.38 0000.50 |
"""
-- 02 001 002 001 002 003 003 0004.75 0002.38 0000.50 |
if name not in ALL_ARCHIVERS:
-- 02 001 002 001 002 003 003 0004.75 0002.38 0000.50 |
raise ValueError(f"Resolver {name} not recognised.")
-- 02 001 002 001 002 003 003 0004.75 0002.38 0000.50 |
else:
-- 02 001 002 001 002 003 003 0004.75 0002.38 0000.50 |
return ALL_ARCHIVERS[name.lower()]