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
Exemple #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
Exemple #3
0
def person(author, show_attr="username"):
    """Find the user identified by 'author', return one of the users attributes,
    default to the username attribute, None if there is no user"""
    from kallithea.model.db import User
    # if author is already an instance use it for extraction
    if isinstance(author, User):
        return getattr(author, show_attr)

    value = user_attr_or_none(author, show_attr)
    if value is not None:
        return value

    # Still nothing?  Just pass back the author name if any, else the email
    return author_name(author) or email(author)
Exemple #4
0
def person(author, show_attr="username"):
    """Find the user identified by 'author', return one of the users attributes,
    default to the username attribute, None if there is no user"""
    from kallithea.model.db import User
    # attr to return from fetched user
    person_getter = lambda usr: getattr(usr, show_attr)

    # if author is already an instance use it for extraction
    if isinstance(author, User):
        return person_getter(author)

    user = user_or_none(author)
    if user is not None:
        return person_getter(user)

    # Still nothing?  Just pass back the author name if any, else the email
    return author_name(author) or email(author)
Exemple #5
0
def person(author, show_attr="username"):
    """Find the user identified by 'author', return one of the users attributes,
    default to the username attribute, None if there is no user"""
    from kallithea.model.db import User
    # attr to return from fetched user
    person_getter = lambda usr: getattr(usr, show_attr)

    # if author is already an instance use it for extraction
    if isinstance(author, User):
        return person_getter(author)

    user = user_or_none(author)
    if user is not None:
        return person_getter(user)

    # Still nothing?  Just pass back the author name if any, else the email
    return author_name(author) or email(author)
Exemple #6
0
    def author_name(self):
        """
        Returns Author name for given commit
        """

        return author_name(self.author)
Exemple #7
0
    def committer_name(self):
        """
        Returns Author name for given commit
        """

        return author_name(self.committer)
Exemple #8
0
    def test_author_name(self):

        for test_str, result in self.TEST_AUTHORS:
            self.assertEqual(result[0], author_name(test_str))
Exemple #9
0
    def test_author_name(self):

        for test_str, result in self.TEST_AUTHORS:
            self.assertEqual(result[0], author_name(test_str))
Exemple #10
0
 def test_author_name(self):
     for test_str, result in self.TEST_AUTHORS:
         assert result[0] == author_name(test_str)
Exemple #11
0
    def author_name(self):
        """
        Returns Author name for given commit
        """

        return author_name(self.author)
Exemple #12
0
    def committer_name(self):
        """
        Returns Author name for given commit
        """

        return author_name(self.committer)