Encodes a dictionary-like object to a Lua string
        :param qualifier:
        :param obj: object to encode
        :return: valid Lua string

def encode(self, obj, qualifier: str):
        """Encodes a dictionary-like object to a Lua string
        :param qualifier:
        :param obj: object to encode
        :return: valid Lua string
        """
        LOGGER.debug('encoding dictionary to text')
        if not obj:
            if qualifier.replace('=', '').rstrip() == 'mapResource':
                # Accept empty mapResource
                return '{}\n{{\n}} -- end of {}\n'.format(qualifier, qualifier.replace('=', '').rstrip())
            else:
                LOGGER.error('{}\n{{\n}} -- end of {}\n'.format(qualifier, qualifier.replace('=', '').rstrip()))
                raise SLTPEmptyObjectError(qualifier)
        self.depth = 0
        out = []
        s = self.__encode(obj)
        lines = s.split(self.newline)
        for line in lines:
            m = self.line_end.match(line)
            if m:
                out.append('{},{}'.format(m.group('intro'), m.group('comment')))
            else:
                out.append(line)
        return '{}{} -- end of {}\n'.format(qualifier, self.newline.join(out), qualifier.replace('=', '').rstrip())