def auth(alias=None, url=None, cfg="<STR_LIT>"):
if not alias and not url:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if alias and url:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>cfg = os.path.expanduser(cfg)<EOL>if not os.path.exists(cfg):<EOL><INDENT>raise AuthError("<STR_LIT>" % cfg)<EOL><DEDENT>tree = etree.parse(os.path.expanduser(cfg))<EOL>res = None<EOL>if alias:<EOL><INDENT>res = tree.findall("<STR_LIT>" % alias)<EOL><DEDENT>if url:<EOL><INDENT>res = tree.findall("<STR_LIT>" % url)<EOL><DEDENT>if not res:<EOL><INDENT>raise AuthError("<STR_LIT>" % cfg)<EOL><DEDENT>elif len(res) > <NUM_LIT:1>:<EOL><INDENT>raise AuthError("<STR_LIT>" % cfg)<EOL><DEDENT>res = res.pop()<EOL>url = res.findall("<STR_LIT:url>")<EOL>if not url:<EOL><INDENT>raise AuthError("<STR_LIT>" % (alias, cfg))<EOL><DEDENT>elif len(url) > <NUM_LIT:1>:<EOL><INDENT>raise AuthError("<STR_LIT>" % (alias, cfg))<EOL><DEDENT>username = res.findall("<STR_LIT:username>")<EOL>if not username:<EOL><INDENT>raise AuthError("<STR_LIT>" % (alias, cfg))<EOL><DEDENT>elif len(username) > <NUM_LIT:1>:<EOL><INDENT>raise AuthError("<STR_LIT>" % (alias, cfg))<EOL><DEDENT>password = res.findall("<STR_LIT:password>")<EOL>if not password:<EOL><INDENT>raise AuthError("<STR_LIT>" % (alias, cfg))<EOL><DEDENT>elif len(password) > <NUM_LIT:1>:<EOL><INDENT>raise AuthError("<STR_LIT>" % (alias, cfg))<EOL><DEDENT>return XnatAuth(url=url.pop().text, username=username.pop().text, <EOL>password=password.pop().text)<EOL>
Read connection details from an xnat_auth XML file

Example:
    >>> import yaxil
    >>> auth = yaxil.auth('xnatastic')
    >>> auth.url, auth.username, auth.password
    ('https://www.xnatastic.org/', 'username', '********')

:param alias: XNAT alias
:type alias: str
:param url: XNAT URL
:type url: str
:param cfg: Configuration file
:type cfg: str
:returns: Named tuple of (url, username, password)
:rtype: :mod:`yaxil.XnatAuth`