Beispiel #1
0
    def get_user_name(self, config_file=None):
        """
        Returns user's name from global configuration file.

        :param config_file: A path to file which should be used to retrieve
          configuration from (might also be a list of file paths)
        """
        username = self.get_config_value('ui', 'username')
        if username:
            return author_name(username)
        return None
Beispiel #2
0
    def get_user_name(self, config_file=None):
        """
        Returns user's name from global configuration file.

        :param config_file: A path to file which should be used to retrieve
          configuration from (might also be a list of file paths)
        """
        username = self.get_config_value('ui', 'username')
        if username:
            return author_name(username)
        return None
Beispiel #3
0
def email_or_none(author):
    _email = email(author)
    if _email != '':
        return _email

    # See if it contains a username we can get an email from
    user = User.get_by_username(author_name(author), case_insensitive=True,
                                cache=True)
    if user is not None:
        return user.email

    # No valid email, not a valid user in the system, none!
    return None
Beispiel #4
0
def email_or_none(author):
    _email = email(author)
    if _email != '':
        return _email

    # See if it contains a username we can get an email from
    user = User.get_by_username(author_name(author),
                                case_insensitive=True,
                                cache=True)
    if user is not None:
        return user.email

    # No valid email, not a valid user in the system, none!
    return None
Beispiel #5
0
def person(author, show_attr="username_and_name"):
    # attr to return from fetched user
    person_getter = lambda usr: getattr(usr, show_attr)

    # Valid email in the attribute passed, see if they're in the system
    _email = email(author)
    if _email != '':
        user = User.get_by_email(_email, case_insensitive=True, cache=True)
        if user is not None:
            return person_getter(user)

    # Maybe it's a username?
    _author = author_name(author)
    user = User.get_by_username(_author, case_insensitive=True, cache=True)
    if user is not None:
        return person_getter(user)

    # Still nothing?  Just pass back the author name if any, else the email
    return _author or _email
Beispiel #6
0
def email_or_none(author):
    # extract email from the commit string
    _email = email(author)
    if _email != '':
        # check it against RhodeCode database, and use the MAIN email for this
        # user
        user = User.get_by_email(_email, case_insensitive=True, cache=True)
        if user is not None:
            return user.email
        return _email

    # See if it contains a username we can get an email from
    user = User.get_by_username(author_name(author), case_insensitive=True,
                                cache=True)
    if user is not None:
        return user.email

    # No valid email, not a valid user in the system, none!
    return None
Beispiel #7
0
def person(author, show_attr="username_and_name"):
    # attr to return from fetched user
    person_getter = lambda usr: getattr(usr, show_attr)

    # Valid email in the attribute passed, see if they're in the system
    _email = email(author)
    if _email != '':
        user = User.get_by_email(_email, case_insensitive=True, cache=True)
        if user is not None:
            return person_getter(user)

    # Maybe it's a username?
    _author = author_name(author)
    user = User.get_by_username(_author, case_insensitive=True,
                                cache=True)
    if user is not None:
        return person_getter(user)

    # Still nothing?  Just pass back the author name if any, else the email
    return _author or _email
Beispiel #8
0
def email_or_none(author):
    # extract email from the commit string
    _email = email(author)
    if _email != '':
        # check it against RhodeCode database, and use the MAIN email for this
        # user
        user = User.get_by_email(_email, case_insensitive=True, cache=True)
        if user is not None:
            return user.email
        return _email

    # See if it contains a username we can get an email from
    user = User.get_by_username(author_name(author),
                                case_insensitive=True,
                                cache=True)
    if user is not None:
        return user.email

    # No valid email, not a valid user in the system, none!
    return None
Beispiel #9
0
    def committer_name(self):
        """
        Returns Author name for given commit
        """

        return author_name(self.committer)
Beispiel #10
0
    def committer_name(self):
        """
        Returns Author name for given commit
        """

        return author_name(self.committer)
Beispiel #11
0
    def test_author_name(self):

        for test_str, result in self.TEST_AUTHORS:
            self.assertEqual(result[0], author_name(test_str))
Beispiel #12
0
    def author_name(self):
        """
        Returns author name for this commit
        """

        return author_name(self.author)
Beispiel #13
0
    def committer_name(self):
        """
        Returns committer name for this commit
        """

        return author_name(self.committer)
Beispiel #14
0
    def test_author_name(self):

        for test_str, result in self.TEST_AUTHORS:
            self.assertEqual(result[0], author_name(test_str))
Beispiel #15
0
    def author_name(self):
        """
        Returns Author name for given commit
        """

        return author_name(self.author)
Beispiel #16
0
    def author_name(self):
        """
        Returns Author name for given commit
        """

        return author_name(self.author)
Beispiel #17
0
 def test_author_name(self, test_str, name, email):
     assert name == author_name(test_str)