# Path: nappingcat/contrib/git/exceptions.py
# class KittyGitRepoExists(NappingCatRejected):
#     def __init__(self, which):
#         super(KittyGitRepoExists, self).__init__("""
#             There's already a repo in %s. Whoops!
#         """.strip() % which)
# 
# class KittyGitUnauthorized(NappingCatRejected):
#     pass
# 
# class KittyGitBadParameter(NappingCatRejected):
#     pass
# 
# Path: nappingcat/exceptions.py
# class NappingCatException(Exception):
#     pass


import os
import sys
import subprocess
from nappingcat.contrib.git.exceptions import KittyGitRepoExists, KittyGitUnauthorized, KittyGitBadParameter
from nappingcat.exceptions import NappingCatException
        stdin=stdin,
        stdout=stdout,
        stderr=stderr,
        close_fds=True,
    )

def create_repository(git, stdin, stdout, stderr, directory, template_dir=None, bare=True):
    if os.path.isdir(directory):
        raise KittyGitRepoExists(directory)
    args = [git, '--git-dir=.', 'init', '--bare']
    if not bare:
        args = [git, 'init']
    if template_dir:
        if not os.path.isdir(template_dir):
            raise KittyGitBadParameter("""
                The template directory '%s' is invalid.
            """.strip() % (template_dir))
        args.append('--template=%s'%os.path.abspath(template_dir))
    os.makedirs(directory)
    return 0 == subprocess.call(
        args=args,
        cwd=directory,
        stdin=stdin,
        stdout=stdout,
        stderr=stderr,
        close_fds=True,
    )

def git_shell(git, stdin, stdout, stderr, action, directory):
    if not os.path.isdir(directory):

# Path: nappingcat/contrib/git/exceptions.py
# class KittyGitRepoExists(NappingCatRejected):
#     def __init__(self, which):
#         super(KittyGitRepoExists, self).__init__("""
#             There's already a repo in %s. Whoops!
#         """.strip() % which)
# 
# class KittyGitUnauthorized(NappingCatRejected):
#     pass
# 
# class KittyGitBadParameter(NappingCatRejected):
#     pass
# 
# Path: nappingcat/exceptions.py
# class NappingCatException(Exception):
#     pass


# Path: nappingcat/contrib/git/operations.py
import os
import sys
import subprocess
from nappingcat.contrib.git.exceptions import KittyGitRepoExists, KittyGitUnauthorized, KittyGitBadParameter
from nappingcat.exceptions import NappingCatException

        stdin=stdin,
        stdout=stdout,
        stderr=stderr,
        close_fds=True,
    )

def create_repository(git, stdin, stdout, stderr, directory, template_dir=None, bare=True):
    if os.path.isdir(directory):
        raise KittyGitRepoExists(directory)
    args = [git, '--git-dir=.', 'init', '--bare']
    if not bare:
        args = [git, 'init']
    if template_dir:
        if not os.path.isdir(template_dir):
            raise KittyGitBadParameter("""
                The template directory '%s' is invalid.
            """.strip() % (template_dir))
        args.append('--template=%s'%os.path.abspath(template_dir))
    os.makedirs(directory)
    return 0 == subprocess.call(
        args=args,
        cwd=directory,
        stdin=stdin,
        stdout=stdout,
        stderr=stderr,
        close_fds=True,
    )

def git_shell(git, stdin, stdout, stderr, action, directory):
    if not os.path.isdir(directory):

        raise KittyGitBadParameter("%s is not a valid repository." % directory)