def endpoint_from_flag(flag):
    """The object used for interacting with relations tied to a flag, or None.
    """
    relation_name = None
    value = _get_flag_value(flag)
    if isinstance(value, dict) and 'relation' in value:
        # old-style RelationBase
        relation_name = value['relation']
    elif flag.startswith('endpoint.'):
        # new-style Endpoint
        relation_name = flag.split('.')[1]
    elif '.' in flag:
        # might be an unprefixed new-style Endpoint
        relation_name = flag.split('.')[0]
        if relation_name not in hookenv.relation_types():
            return None
    if relation_name:
        factory = relation_factory(relation_name)
        if factory:
            return factory.from_flag(flag)
    return None
def endpoint_from_flag ( flag ) : relation_name = None value = _get_flag_value ( flag ) if isinstance ( value , dict ) and 'relation' in value : relation_name = value [ 'relation' ] elif flag . startswith ( 'endpoint.' ) : relation_name = flag . split ( '.' ) [ 1 ] elif '.' in flag : relation_name = flag . split ( '.' ) [ 0 ] if relation_name not in hookenv . relation_types ( ) : return None if relation_name : factory = relation_factory ( relation_name ) if factory : return factory . from_flag ( flag ) return None
The object used for interacting with relations tied to a flag, or None.