#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Mythbuntu Control Centre Launcher Script
#
# Copyright (C) 2007, Mario Limonciello, for Mythbuntu
#
#
# Mythbuntu is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this application; if not, write to the Free Software Foundation, Inc., 51
# Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
##################################################################################


import sys
from MythbuntuControlCentre.core import ControlCentre
import string

#This is quite hackish, but should do the trick
#To prevent apps from getting all the Recommends installed too
def comment_file(file,comment):
    """Comment & Uncomments out a file to override it's behavior"""
    in_f = open(file)
    lines = in_f.readlines()
    in_f.close()
    out_f = open(file, "w")
    for line in lines:
        if comment:
            out_f.write("//" + line)
        else:
            out_f.write(string.split(line,"//")[1])
    out_f.close()

if __name__ == '__main__':
    comment_file("/etc/apt/apt.conf.d/01ubuntu",True)
    script = ControlCentre()
    script.run()
    comment_file("/etc/apt/apt.conf.d/01ubuntu",False)
    sys.exit(0)
