def _get_auth(self, force_console=False):
if not self.target:<EOL><INDENT>raise ValueError("<STR_LIT>".format(self.target))<EOL><DEDENT>elif not force_console and self.URL_RE.match(self.target):<EOL><INDENT>auth_url = urlparse(self.target)<EOL>source = '<STR_LIT:url>'<EOL>if auth_url.username:<EOL><INDENT>self.user = auth_url.username<EOL><DEDENT>if auth_url.password:<EOL><INDENT>self.password = auth_url.password<EOL><DEDENT>if not self.auth_valid():<EOL><INDENT>source = self._get_auth_from_keyring()<EOL><DEDENT>if not self.auth_valid():<EOL><INDENT>source = self._get_auth_from_netrc(auth_url.hostname)<EOL><DEDENT>if not self.auth_valid():<EOL><INDENT>source = self._get_auth_from_console(self.target)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>source = self._get_auth_from_console(self.target)<EOL><DEDENT>if self.auth_valid():<EOL><INDENT>self.source = source<EOL><DEDENT>
Try to get login auth from known sources.