def write_rule_subjs(dest, subjs):
    if (len(subjs) < 1):
        return
    for subj in subjs:
        subj['hrname'] = gen_rule_subj_hrname(subj)
    subjs.sort(key=(lambda s: s['hrname']))
    props = None
    stdout.write('\n')
    for subj in subjs:
        if (props is not None):
            dest.write(',\n')
        dest.write('    {')
        propsep = ' '
        del subj['hrname']
        props = ['o', 'd']
        props += [prop for prop in sorted(subj.keys()) if (prop not in props)]
        for prop in props:
            if subj.has_key(prop):
                dest.write((((propsep + json.dumps(prop)) + ': ') + json.dumps(subj[prop])))
                propsep = ', '
        dest.write(' }')
    stdout.write('\n  ')
def write_rule_subjs(dest, subjs):
    if (len(subjs) < 1):
        return
    for subj in subjs:
        subj['hrname'] = gen_rule_subj_hrname(subj)
    subjs.sort(key=(lambda s: s['hrname']))
    props = None
    stdout.write('\n')
    for subj in subjs:
        if (props is not None):
            dest.write(',\n')
        dest.write('    {')
        propsep = ' '
        del subj['hrname']
        props = ['o', 'd']
        props += [prop for prop in sorted(subj.keys()) if (prop not in props)]
        for prop in props:
            if subj.has_key(prop):
                dest.write((((propsep + json.dumps(prop)) + ': ') + json.dumps(subj[prop])))
                propsep = ', '
        dest.write(' }')
    stdout.write('\n  ')