# Path: confab/files.py
# @runs_once
# def _clear_dir(dir_name):
#     """
#     Remove an entire directory tree.
#     """
#     if os.path.isdir(dir_name):
#         shutil.rmtree(dir_name)
# 
# def _clear_file(file_name):
#     """
#     Remove a single file.
#     """
#     if os.path.exists(file_name):
#         os.remove(file_name)
# 
# def _ensure_dir(dir_name):
#     """
#     Ensure that a directory exists.
#     """
#     if not os.path.exists(dir_name):
#         os.makedirs(dir_name)
# 
# Path: confab/options.py
# def _should_render(mime_type):
# def _is_empty(mime_type):
# def _is_not_temporary(file_name):
# def _is_not_internal(file_name):
# def _filter_func(file_name):
# def _get_mime_type(file_name):
# def _diff(a, b, fromfile=None, tofile=None):
# def _as_dict(module):
# def _get_base_dir():
#     def __init__(self, **kwargs):
#     def __enter__(self):
#     def __exit__(self, exc_type, value, traceback):
# def assume_yes():
# class Options(object):
# 
# Path: confab/validate.py
# def assert_may_be_created(path):
#     """
#     Assert that path's directory either exists or can be created.
#     """
#     directory = dirname(path)
#     if not exists(directory):
#         try:
#             makedirs(directory)
#         except OSError as e:
#             abort(e)
#     elif not isdir(directory):
#         abort('{} is not a valid directory'.format(directory))
# 
# Path: confab/jinja_filters.py
# def select(value, key):
# def rotate(list_, pivot):
# def map_format(sequence, format):
# def built_in_filters():
#     def __init__(self):
#     def add_filter(self, filter):
#     def remove_filter(self, filter):
#     def filters(self):
#     def register(self, environment):
#     def __init__(self, *filters):
#     def __enter__(self):
#     def __exit__(self, type, value, traceback):
# def add_jinja_filter(filter):
# def remove_jinja_filter(filter):
# class JinjaFiltersRegistry(object):
# class JinjaFilters(object):


from os.path import dirname, exists, join
from hashlib import sha1
from warnings import warn
from fabric.api import get, put, sudo
from fabric.colors import blue, red, green, magenta
from fabric.contrib.files import exists as exists_remote
from fabric.contrib.console import confirm
from gusset.output import debug, status
from confab.files import _clear_dir, _clear_file, _ensure_dir
from confab.options import options
from confab.validate import assert_may_be_created
from confab.jinja_filters import jinja_filters
import os
import shutil
        for conffile in self.conffiles:
            conffile.diff(host_generated_dir, host_remotes_dir).show()

    def push(self, directory=None):
        """
        Push configuration files that have changes, given user confirmation.
        """
        host_generated_dir = self._get_host_generated_dir(directory)
        host_remotes_dir = self._get_host_remotes_dir(directory)

        for conffile in self.conffiles:
            conffile.pull(host_remotes_dir)

        for conffile in self.conffiles:
            conffile.generate(host_generated_dir)

        has_diff = lambda conffile: conffile.diff(host_generated_dir, host_remotes_dir, True)
        with_diffs = filter(has_diff, self.conffiles)

        if not with_diffs:
            print(magenta('No configuration files to push for {host}'
                          .format(host=self.host)))
            return

        print(magenta('The following configuration files have changed for {host}:'
                      .format(host=self.host)))
        print
        for conffile in with_diffs:
            print(magenta('\t' + conffile.remote))


# Path: confab/files.py
# @runs_once
# def _clear_dir(dir_name):
#     """
#     Remove an entire directory tree.
#     """
#     if os.path.isdir(dir_name):
#         shutil.rmtree(dir_name)
# 
# def _clear_file(file_name):
#     """
#     Remove a single file.
#     """
#     if os.path.exists(file_name):
#         os.remove(file_name)
# 
# def _ensure_dir(dir_name):
#     """
#     Ensure that a directory exists.
#     """
#     if not os.path.exists(dir_name):
#         os.makedirs(dir_name)
# 
# Path: confab/options.py
# def _should_render(mime_type):
# def _is_empty(mime_type):
# def _is_not_temporary(file_name):
# def _is_not_internal(file_name):
# def _filter_func(file_name):
# def _get_mime_type(file_name):
# def _diff(a, b, fromfile=None, tofile=None):
# def _as_dict(module):
# def _get_base_dir():
#     def __init__(self, **kwargs):
#     def __enter__(self):
#     def __exit__(self, exc_type, value, traceback):
# def assume_yes():
# class Options(object):
# 
# Path: confab/validate.py
# def assert_may_be_created(path):
#     """
#     Assert that path's directory either exists or can be created.
#     """
#     directory = dirname(path)
#     if not exists(directory):
#         try:
#             makedirs(directory)
#         except OSError as e:
#             abort(e)
#     elif not isdir(directory):
#         abort('{} is not a valid directory'.format(directory))
# 
# Path: confab/jinja_filters.py
# def select(value, key):
# def rotate(list_, pivot):
# def map_format(sequence, format):
# def built_in_filters():
#     def __init__(self):
#     def add_filter(self, filter):
#     def remove_filter(self, filter):
#     def filters(self):
#     def register(self, environment):
#     def __init__(self, *filters):
#     def __enter__(self):
#     def __exit__(self, type, value, traceback):
# def add_jinja_filter(filter):
# def remove_jinja_filter(filter):
# class JinjaFiltersRegistry(object):
# class JinjaFilters(object):


# Path: confab/conffiles.py
from os.path import dirname, exists, join
from hashlib import sha1
from warnings import warn
from fabric.api import get, put, sudo
from fabric.colors import blue, red, green, magenta
from fabric.contrib.files import exists as exists_remote
from fabric.contrib.console import confirm
from gusset.output import debug, status
from confab.files import _clear_dir, _clear_file, _ensure_dir
from confab.options import options
from confab.validate import assert_may_be_created
from confab.jinja_filters import jinja_filters
import os
import shutil

        for conffile in self.conffiles:
            conffile.diff(host_generated_dir, host_remotes_dir).show()

    def push(self, directory=None):
        """
        Push configuration files that have changes, given user confirmation.
        """
        host_generated_dir = self._get_host_generated_dir(directory)
        host_remotes_dir = self._get_host_remotes_dir(directory)

        for conffile in self.conffiles:
            conffile.pull(host_remotes_dir)

        for conffile in self.conffiles:
            conffile.generate(host_generated_dir)

        has_diff = lambda conffile: conffile.diff(host_generated_dir, host_remotes_dir, True)
        with_diffs = filter(has_diff, self.conffiles)

        if not with_diffs:
            print(magenta('No configuration files to push for {host}'
                          .format(host=self.host)))
            return

        print(magenta('The following configuration files have changed for {host}:'
                      .format(host=self.host)))
        print
        for conffile in with_diffs:
            print(magenta('\t' + conffile.remote))


        if options.assume_yes or confirm('Push configuration files to {host}?'