def buildgroups(self,  servicelist):
        ''' Build a string of groups for use in a configuration message given
            a list of services. The group list string has the format 
            "title1:1-5|title2:6-9|10-12", where title is an optional group title
            and i-j is a numeric range of value indices; groups are
            separated by commas.
        '''
        i = 0
        r = ""
        lastgroup = "<undefined>"
        for service in servicelist:
            i += 1
            group = service._group
            if group != lastgroup:
                lastgroup = group
                # finish previous group
                if i > 1:
                    r += "-%d|" % (i -1)                
                # optionally include group title
                if group == "":
                    r += "%d" % i
                else:
                    r += (group,  i) % "%s:%d"
        # finish the last group list
        if i > 0:
            r += "-%d" % i
        return r
dataset/ETHPy150Open coreemu/core/daemon/core/service.py/CoreServices.buildgroups/swapped operands of `%`