

def __init__(self, authority=None, type=None, name=None, urn=None):
    if (not (urn is None)):
        if (not is_valid_urn(urn)):
            raise ValueError(('Invalid URN %s' % urn))
        spl = urn.split('+')
        self.authority = urn_to_string_format(spl[1])
        self.type = urn_to_string_format(spl[2])
        self.name = urn_to_string_format('+'.join(spl[3:]))
        self.urn = urn
    else:
        if ((not authority) or (not type) or (not name)):
            raise ValueError('Must provide either all of authority, type, and name, or a urn must be provided')
        for i in [authority, type, name]:
            if (i.strip() == ''):
                raise ValueError('Parameter to create_urn was empty string')
        self.authority = authority
        self.type = type
        self.name = name
        if (not is_valid_urn_string(authority)):
            authority = string_to_urn_format(authority)
        if (not is_valid_urn_string(type)):
            type = string_to_urn_format(type)
        if (not is_valid_urn_string(name)):
            name = string_to_urn_format(name)
        self.urn = ('%s+%s+%s+%s' % (Xrn.URN_PREFIX, authority, type, name))
        if (not is_valid_urn(self.urn)):
            raise ValueError(('Failed to create valid URN from args %s, %s, %s' % (self.authority, self.type, self.name)))

dataset/ETHPy150Open fp7-ofelia/ocf/ofam/src/src/ext/geni/util/urn_util.py URN.__init__/original