

def hrn_to_urn(hrn, type=None):
    '\n    convert an hrn and type to a urn string\n    '
    if ((not hrn) or hrn.startswith(URN_PREFIX)):
        return hrn
    authority = get_authority(hrn)
    name = get_leaf(hrn)
    if (type == 'authority'):
        authority = hrn
        name = 'sa'
    if authority.startswith('plc'):
        if (type == None):
            urn = '+'.join(['', authority.replace('.', ':'), name])
        else:
            urn = '+'.join(['', authority.replace('.', ':'), type, name])
    else:
        urn = '+'.join(['', authority, type, name])
    return (URN_PREFIX + urn)

dataset/ETHPy150Open fp7-ofelia/ocf/expedient/src/python/sfa/util/namespace.py hrn_to_urn/original