

def check_name_format(req, name, target_type):
    '\n    Validate that the header contains valid account or container name.\n\n    :param req: HTTP request object\n    :param name: header value to validate\n    :param target_type: which header is being validated (Account or Container)\n    :returns: A properly encoded account name or container name\n    :raise: HTTPPreconditionFailed if account header\n            is not well formatted.\n    '
    if (not name):
        raise HTTPPreconditionFailed(request=req, body=('%s name cannot be empty' % target_type))
    if isinstance(name, six.text_type):
        name = name.encode('utf-8')
    if ('/' in name):
        raise HTTPPreconditionFailed(request=req, body=('%s name cannot contain slashes' % target_type))
    return name

dataset/ETHPy150Open openstack/swift/swift/common/constraints.py check_name_format/original