from fermiinstallclass import FermiInstallClass
import rhpl
from rhpl.translate import N_,_
from constants import *
from flags import flags
import os
import iutil
import types
import rpmUtils.arch

import logging
log = logging.getLogger("anaconda")


class InstallClass(FermiInstallClass):
    # name has underscore used for mnemonics, strip if you dont need it
    id = "fermi"
    name = ("Scientific Linux Fermi")
    _description = N_("The default installation of %s includes a set of "
                    "software applicable for general internet usage. "
                    "What additional tasks would you like your system "
                    "to include support for?") 
    sortPriority = 10000
#    repos = { "Fermi": ("http://linux1.fnal.gov/linux/slf5rolling/%s/sites/Fermi/SITERPMS" %(rpmUtils.arch.getBaseArch() ,), None) }

    def _get_description(self):
        return _(self._description) %(productName,)
    description = property(_get_description)

    def setInstallData(self, anaconda):
	FermiInstallClass.setInstallData(self, anaconda)
#        BaseInstallClass.setDefaultPartitioning(self, anaconda.id.partitions,
#                                                CLEARPART_TYPE_LINUX)

    def setGroupSelection(self, anaconda):
        grps = anaconda.backend.getDefaultGroups(anaconda)
        map(lambda x: anaconda.backend.selectGroup(x), grps)
	anaconda.backend.selectGroup("Core")
        anaconda.backend.selectGroup("Base")

    def setSteps(self, dispatch):
	FermiInstallClass.setSteps(self, dispatch);
	dispatch.skipStep("partition")
	dispatch.skipStep("tasksel")
	dispatch.skipStep("group-selection", skip = 0)

#    def getPackagePaths(self, uri):
#        rc = {}
#        for (name, path) in self.repopaths.items():
#            log.info("package is %s path is %s" %(name,path,))
#            if not type(uri) == types.ListType:
#                uri = [uri,]
#            if not type(path) == types.ListType:
#                path = [path,]
#
#            lst = []
#            for i in uri:
#                for p in path:
#                    lst.append("%s/%s" % (i, p))
#
#            rc[name] = lst
#
#        log.info("package paths is %s" %(rc,))
#        return rc

    def __init__(self, expert):
	FermiInstallClass.__init__(self, expert)

        self.repopaths = { "base": "%s" %(productPath,) }
        self.repopaths["fermi"] = "sites/Fermi/SITERPMS"
        self.repopaths["fermiupdates"] = "sites/Fermi/updates/security"
#	for name, path in get_repos_dict().items():

        log.info("repopaths is %s" %(self.repopaths,))

