view rhodecode/lib/vcs/utils/archivers.py @ 2865:6d9b3ade3051 beta

Allowing multiple issue servers to be autolinked in the changeset view; linking is now contingent on issue_server_link, issue_pat and issue_prefix being defined; multiple servers can be used by specifying a common suffix on all the above variables, ie .. issue_server_link_1 issue_pat_1 issue_prefix_1 .. and .. issue_server_link_other issue_pat_other issue_prefix_other .. would be treated as two distinct servers, but .. issue_pat_thing .. would be ignored (since the other two requisite vars aren't present). This patch is backwards compatible with existing variables (as a suffix isn't needed).
author Zachary Auclair <zach101@gmail.com>
date Thu, 20 Sep 2012 20:30:55 -0400
parents 324ac367a4da
children
line wrap: on
line source

# -*- coding: utf-8 -*-
"""
    vcs.utils.archivers
    ~~~~~~~~~~~~~~~~~~~

    set of archiver functions for creating archives from repository content

    :created_on: Jan 21, 2011
    :copyright: (c) 2010-2011 by Marcin Kuzminski, Lukasz Balcerzak.
"""


class BaseArchiver(object):

    def __init__(self):
        self.archive_file = self._get_archive_file()

    def addfile(self):
        """
        Adds a file to archive container
        """
        pass

    def close(self):
        """
        Closes and finalizes operation of archive container object
        """
        self.archive_file.close()

    def _get_archive_file(self):
        """
        Returns container for specific archive
        """
        raise NotImplementedError()


class TarArchiver(BaseArchiver):
    pass


class Tbz2Archiver(BaseArchiver):
    pass


class TgzArchiver(BaseArchiver):
    pass


class ZipArchiver(BaseArchiver):
    pass


def get_archiver(self, kind):
    """
    Returns instance of archiver class specific to given kind

    :param kind: archive kind
    """

    archivers = {
        'tar': TarArchiver,
        'tbz2': Tbz2Archiver,
        'tgz': TgzArchiver,
        'zip': ZipArchiver,
    }

    return archivers[kind]()