def gidsplit(gidseq, format='text', sort=False, buf=None):
    """This function prints a columnar JSON representation of the splitted gids
    with the date in front so one can sort and extract data with the
    usual command line tools as well as read the output as JSON.
    """
    gids = [g for g in gidseq if is_global_id(g)]
    if not gids:
        return

    out = buf
    if out is None:
        out = sys.stdout

    def uniwrite(text):
        out.write(unistr(text))


    if sort:
        gids.sort()
    entries = [gidfields(gidseq, gid) for gid in gids]

    if format == 'json':
        root = {'gids': entries}
        uniwrite(json.dumps(root, sort_keys=True, indent=2, separators=(',', ':')))
        uniwrite('\n')
    elif format == 'text':
        formatstrings = {"date": "%s", "user": "%3d", "pid": "%3d", "random": "%10d",
                         "seq": "%5d", "gid": "%24s", "comment": "%s"}
        jsondumps = json.JSONEncoder().encode
        for d in entries:
            comment = d.get('comment')
            if comment is not None:
                d['comment'] = jsondumps(comment)
            uniwrite(' '.join(v % formatstrings[k] for k, v in d.items()))
            uniwrite('\n')
    return OK
dataset/ETHPy150Open mikr/xcodeprojer/xcodeprojer.py/gidsplit/swapped operands of `%`