'It will return full index code from index file.
:param index_name: the name of index to look for code'

def get_index_code(self, index_name, code_switch='All'):

    if (not (index_name in self.indexes_names)):
        self.__not_opened()
        raise IndexNotFoundException(("Index    `%s`    doesn't    exists" % index_name))
    ind = self.indexes_names[index_name]
    name = ('%.2d%s' % (ind._order, index_name))
    name += '.py'
    with io.FileIO(os.path.join(self.path, '_indexes', name), 'r') as f:
        co = f.read()
        if (code_switch == 'All'):
            return co
        if (code_switch == 'S'):
            try:
                ind = co.index('#SIMPLIFIED    CODE')
            except ValueError:
                return '    '
            else:
                s = co[ind:]
                l = s.splitlines()[1:(-2)]
                ll = map((lambda x: x[1:]), l)
                return '\n'.join(ll)
        if (code_switch == 'P'):
            try:
                ind = co.index('#SIMPLIFIED    CODE')
            except ValueError:
                return co
            else:
                return co[:ind]
    return ''
