'Format host records by order and with consistent indentation'

def __pretty_print_host_records(self, hosts, rectype='A', rclass='IN'):

    for system in self.systems:
        for (name, interface) in system.interfaces.iteritems():
            if (interface['dns_name'] == ''):
                self.logger.info(('Warning:    dns_name    unspecified    in    the    system:    %s,    while    writing    host    records' % system.name))
    names = [k for (k, v) in hosts.iteritems()]
    if (not names):
        return ''
    if (rectype == 'PTR'):
        names = self.__ip_sort(names)
    else:
        names.sort()
    max_name = max([len(i) for i in names])
    s = ''
    for name in names:
        spacing = ('    ' * (max_name - len(name)))
        my_name = ('%s%s' % (name, spacing))
        my_host_record = hosts[name]
        my_host_list = []
        if isinstance(my_host_record, basestring):
            my_host_list = [my_host_record]
        else:
            my_host_list = my_host_record
        for my_host in my_host_list:
            my_rectype = rectype[:]
            if (rectype == 'A'):
                if (':' in my_host):
                    my_rectype = 'AAAA'
                else:
                    my_rectype = 'A            '
            s += ('%s        %s        %s        %s;\n' % (my_name, rclass, my_rectype, my_host))
    return s
