Return the user name to use when creating git objects or exit
    program.

    Parameters
    ----------
    args: parser.parse_args()

    Returns
    -------
    user: `string`
        git user name
161461
def lookup_user(args):
    
    user = args.user
    if user is None:
        user = gitusername()

    if user is None:
        raise RuntimeError(textwrap.dedent("""\
            unable to determine a git user name
            Specify --user option\
        """))

    debug("user name is {user}".format(user=user))

    return user
253462
def author_mail_from_git(self):
        
        try:
            # launch git command and get answer
            cmd = Popen(["git", "config", "--get", "user.email"], stdout=PIPE)
            stdoutdata = cmd.communicate()
            if (stdoutdata[0]):
                self.author_mail = stdoutdata[0].rstrip(os.linesep)
        except ImportError:
            pass
        except CalledProcessError:
            pass
        except OSError:
            pass

        return self.author_mail
801257
def user(self, username=None):
        """"""
        if username is None:
            username = self.__getUsername()
        parsedUsername = urlparse.quote(username)
        url = self.root + "/%s" % parsedUsername
        return User(url=url,
                    securityHandler=self._securityHandler,
                    proxy_url=self._proxy_url,
                    proxy_port=self._proxy_port,
                    initialize=False)
920200
def generate_username(self, user_class):
        
        m = getattr(user_class, 'generate_username', None)
        if m:
            return m()
        else:
            max_length = user_class._meta.get_field(
                self.username_field).max_length
            return uuid.uuid4().hex[:max_length]
262810
def chgid(name, gid):
    '''
    
    '''
    pre_info = info(name)
    if not pre_info:
        raise CommandExecutionError(
            'User \'{0}\' does not exist'.format(name)
        )
    if gid == pre_info['gid']:
        return True
    cmd = ['usermod', '-g', gid, name]
    __salt__['cmd.run'](cmd, python_shell=False)
    return info(name).get('gid') == gid
1198012
def get_user(self, username="~"):
        
        url = self._build_url("users/%s/" % username, _prepend_namespace=False)
        response = self._get(url)
        check_response(response)
        return response
565965
def _get_user(self, username):
        
        if username is None:
            return {}
        ret = {}
        for b in self.backends:
            try:
                tmp = self.backends[b].get_user(username)
            except UserDoesntExist as e:
                self._handle_exception(e)
                tmp = {}
            self._merge_user_attrs(tmp, ret, b)

        cherrypy.log.error(
            msg="user '" + username + "' attributes " + str(ret),
            severity=logging.DEBUG
        )
        return ret
562568
def get_user(username):
    '''
    
    '''
    try:
        enable()
        configure_terminal()
        cmd_out = sendline('show running-config | include "username {0} password 7"'.format(username))
        cmd_out.split('\n')
        user = cmd_out[1:-1]
        configure_terminal_exit()
        disable()
        return user
    except TerminalException as e:
        log.error(e)
        return 'Failed to get user'
107164
def getUser(self):
        
        username = self.getUsername()
        if not username:
            return None
        user = api.user.get(userid=username)
        return user
481395
def get_user_id(self, user):
        
        user_field = getattr(settings, 'SAML_IDP_DJANGO_USERNAME_FIELD', None) or \
                     getattr(user, 'USERNAME_FIELD', 'username')
        return str(getattr(user, user_field))
655792
def get_name_arg(argd, *argnames, default=None):
    
    val = None
    for argname in argnames:
        if argd[argname]:
            val = argd[argname].lower().strip()
            break
    return val if val else default
881826
def getUserName(self):
        """"""
        if not self._server_side:
            return
        mech = self._authenticator.current_mech
        return mech.getUserName() if mech else None
949002
def _input_github_repo(url=None):
    
    if url is None:
        url = user_input('Input the URL of the GitHub repository '
                         'to use as a `trytravis` repository: ')
    url = url.strip()
    http_match = _HTTPS_REGEX.match(url)
    ssh_match = _SSH_REGEX.match(url)
    if not http_match and not ssh_match:
        raise RuntimeError('That URL doesn\'t look like a valid '
                           'GitHub URL. We expect something '
                           'of the form: `https://github.com/[USERNAME]/'
                           '[REPOSITORY]` or `ssh://git@github.com/'
                           '[USERNAME]/[REPOSITORY]')

    # Make sure that the user actually made a new repository on GitHub.
    if http_match:
        _, name = http_match.groups()
    else:
        _, name = ssh_match.groups()
    if 'trytravis' not in name:
        raise RuntimeError('You must have `trytravis` in the name of your '
                           'repository. This is a security feature to reduce '
                           'chances of running git push -f on a repository '
                           'you don\'t mean to.')

    # Make sure that the user actually wants to use this repository.
    accept = user_input('Remember that `trytravis` will make commits on your '
                        'behalf to `%s`. Are you sure you wish to use this '
                        'repository? Type `y` or `yes` to accept: ' % url)
    if accept.lower() not in ['y', 'yes']:
        raise RuntimeError('Operation aborted by user.')

    if not os.path.isdir(config_dir):
        os.makedirs(config_dir)
    with open(os.path.join(config_dir, 'repo'), 'w+') as f:
        f.truncate()
        f.write(url)
    print('Repository saved successfully.')
1309092
def get_user(self, name):
        
        return self._api_get('/api/users/{0}'.format(
            urllib.parse.quote_plus(name)
        ))
450064
def get_user_info(self, username):
        
        info = self.get_users_info([username])
        return info[username] if info is not None else None
850119
def username(self):
        
        token = self.session.params.get('access_token')
        if not token:
            raise errors.TokenError(
                "session does not have a valid access_token param")
        data = token.split('.')[1]
        # replace url chars and add padding
        # (https://gist.github.com/perrygeo/ee7c65bb1541ff6ac770)
        data = data.replace('-', '+').replace('_', '/') + "==="
        try:
            return json.loads(base64.b64decode(data).decode('utf-8'))['u']
        except (ValueError, KeyError):
            raise errors.TokenError(
                "access_token does not contain username")
346345
def _get_username_hostname():
    ''''''
    user = 'na'
    host = 'na'
    try:
        user = getpass.getuser()
    except Exception:
        pass
    try:
        host = socket.gethostname()
    except Exception:
        pass
    return user, host