def append_to_prop(dic, key, ln, indent=0):
    val = dic.get(key, None)
    if not val:
        val = {'type':'text', 'text':ln}
        dic[key] = val
    elif type(val) is str:
        val += ('\n\n' + ln)
        dic[key] = val
    elif type(val) is dict and ln.startswith('-'):
        subkey, dummy, subval = ln[1:].partition(':')
        if not dummy:
            error('Continuation *line must contain a colon')
            return
        subkey = subkey.strip()
        subval = subval.strip()
        if val.get('type', None) == 'portlist' and subkey == 'portal':
            subls = [ s2val.strip() for s2val in subval.split(',') ]
            if len(subls) != 4:
                error('Portal property must have four fields')
                return None
            val['_templist'].append(subls)
        else:
            val[subkey] = subval
    elif type(val) is dict and val.get('type', None) in ('code', 'gentext'):
        if '_baseindent' not in val:
            val['_baseindent'] = indent
        indentstr = '  ' * (indent - val['_baseindent'])
        if not val['text'].strip():
            val['text'] = ''
        else:
            indentstr = '\n' + indentstr
        val['text'] += (indentstr + ln)
    elif type(val) is dict and 'text' in val:
        # Covers {text}, {event}
        val['text'] += ('\n\n' + ln)
    else:
        error((key,) % 'Cannot append to property %s')
dataset/ETHPy150Open erkyrath/tworld/twloadworld.py/append_to_prop/swapped operands of `%`