# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
# 
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
# 
# Path: revolver/server.py
# def timezone(zone='UTC'):
# def version():
# def codename():
# 
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
# 
# Path: revolver/decorator.py
# def sudo(func):
#     def wrapper(*args, **kwargs):
# def multiargs(func):
#     def wrapper(*args, **kwargs):
# def inject_use_sudo(func):
#     def inject_wrapper(*args, **kwargs):


from cuisine import package_ensure as ensure
from cuisine import package_install as install
from cuisine import package_update as update
from cuisine import package_upgrade as upgrade
from revolver import contextmanager as ctx
from revolver import file, server, core, decorator
# -*- coding: utf-8 -*-

from __future__ import absolute_import, division, with_statement



ensure = decorator.multiargs(decorator.sudo(ensure))
install = decorator.multiargs(decorator.sudo(install))
update = decorator.multiargs(decorator.sudo(update))
upgrade = decorator.sudo(upgrade)


def is_installed(name):
    with ctx.settings(warn_only=True):
        res = core.run("dpkg -s %s" % name)
        for line in res.splitlines():
            if line.startswith("Status: "):
                status = line[8:]
                if "installed" in status.split(" "):
                    return True
        return False


def install_ppa(name):
    ensure("python-software-properties")

    with ctx.cd("/etc/apt/sources.list.d"):
        name_normalizes = name.replace("/", "-")

# Path: revolver/contextmanager.py
# def sudo(username=None, login=False):
# def unpatched_state():
# 
# Path: revolver/file.py
# def temp(mode=None, owner=None, group=None):
# def remove(location, recursive=False, force=True):
# def touch(location, mode=None, owner=None, group=None):
# def copy(source, destination, force=True, mode=None, owner=None, group=None):
# 
# Path: revolver/server.py
# def timezone(zone='UTC'):
# def version():
# def codename():
# 
# Path: revolver/core.py
# VERSION = '0.0.5'
# def put(*args, **kwargs):
# def run(*args, **kwargs):
# def sudo(*args, **kwargs):
# 
# Path: revolver/decorator.py
# def sudo(func):
#     def wrapper(*args, **kwargs):
# def multiargs(func):
#     def wrapper(*args, **kwargs):
# def inject_use_sudo(func):
#     def inject_wrapper(*args, **kwargs):


# Path: revolver/package.py
from cuisine import package_ensure as ensure
from cuisine import package_install as install
from cuisine import package_update as update
from cuisine import package_upgrade as upgrade
from revolver import contextmanager as ctx
from revolver import file, server, core, decorator

# -*- coding: utf-8 -*-

from __future__ import absolute_import, division, with_statement



ensure = decorator.multiargs(decorator.sudo(ensure))
install = decorator.multiargs(decorator.sudo(install))
update = decorator.multiargs(decorator.sudo(update))
upgrade = decorator.sudo(upgrade)


def is_installed(name):
    with ctx.settings(warn_only=True):
        res = core.run("dpkg -s %s" % name)
        for line in res.splitlines():
            if line.startswith("Status: "):
                status = line[8:]
                if "installed" in status.split(" "):
                    return True
        return False


def install_ppa(name):
    ensure("python-software-properties")

    with ctx.cd("/etc/apt/sources.list.d"):
        name_normalizes = name.replace("/", "-")

        source_list = "%s-%s.list" % (name_normalizes, server.codename())