Ejemplo n.º 1
0
    def test_check_douban_email(self):
        emails = ("*****@*****.**", "*****@*****.**", "*****@*****.**")
        for e in emails:
            assert check_douban_email(e)

        emails = ("*****@*****.**", "", None, "whatsyouremailaddrs")
        for e in emails:
            assert not check_douban_email(e)
Ejemplo n.º 2
0
def get_author_by_email(email, author=''):
    # company
    email = email.rstrip('>') if email.endswith('>') else email
    if check_douban_email(email):
        username = email.split('@')[0]
        return username
    user = User.get_by_email(email)
    if check_douban_email(author):
        author = author.split('@')[0]
    return user and user.name or author
Ejemplo n.º 3
0
def get_author_by_email(email, author=''):
    # company
    email = email.rstrip('>') if email.endswith('>') else email
    if check_douban_email(email):
        username = email.split('@')[0]
        return username
    user = User.get_by_email(email)
    if check_douban_email(author):
        author = author.split('@')[0]
    return user and user.name or author
Ejemplo n.º 4
0
    def test_check_douban_email(self):
        emails = (
            '*****@*****.**',
            '*****@*****.**',
            '*****@*****.**',
        )
        for e in emails:
            assert check_douban_email(e)

        emails = ('*****@*****.**', '', None, 'whatsyouremailaddrs')
        for e in emails:
            assert not check_douban_email(e)
Ejemplo n.º 5
0
 def get_commits(self, path='', ref='HEAD'):
     if self.object_type(ref, path) != 'tree':
         raise IOError('get_commits works on a tree')
     bag = {}
     for item in self._list_tree(ref, path):
         sha = item['id']
         bag[sha] = {
             'id': sha,
             'mode': item['mode'],
             'type': item['type'],
             'name': item['name'],
             'path': item['path'],
         }
         latest_commit_sha = self.latest_commit(item['path'], ref)
         if latest_commit_sha:
             l_com = self.cat(latest_commit_sha)
             user = l_com['author']['email']
             user_t = user.split('@')[0] if '@' in user else user
             bag[sha]['contributor'] = user_t
             if check_douban_email(user):
                 bag[sha]['contributor_url'] = User(user_t).url
             else:
                 bag[sha]['contributor_url'] = False
             bag[sha]['message'] = l_com['message']
             bag[sha]['hash'] = latest_commit_sha
             bag[sha]['age'] = compute_relative_time(l_com['author']['ts'])
         else:
             bag[sha]['contributor'] = ''
             bag[sha]['contributor_url'] = ''
             bag[sha]['message'] = ''
             bag[sha]['hash'] = ''
             bag[sha]['age'] = ''
     return bag
Ejemplo n.º 6
0
 def get_commits(self, path='', ref='HEAD'):
     if self.object_type(ref, path) != 'tree':
         raise IOError('get_commits works on a tree')
     bag = {}
     for item in self._list_tree(ref, path):
         sha = item['id']
         bag[sha] = {
             'id': sha,
             'mode': item['mode'],
             'type': item['type'],
             'name': item['name'],
             'path': item['path'],
         }
         latest_commit_sha = self.latest_commit(item['path'], ref)
         if latest_commit_sha:
             l_com = self.cat(latest_commit_sha)
             user = l_com['author']['email']
             user_t = user.split('@')[0] if '@' in user else user
             bag[sha]['contributor'] = user_t
             if check_douban_email(user):
                 bag[sha]['contributor_url'] = User(user_t).url
             else:
                 bag[sha]['contributor_url'] = False
             bag[sha]['message'] = l_com['message']
             bag[sha]['hash'] = latest_commit_sha
             bag[sha]['age'] = compute_relative_time(l_com['author']['ts'])
         else:
             bag[sha]['contributor'] = ''
             bag[sha]['contributor_url'] = ''
             bag[sha]['message'] = ''
             bag[sha]['hash'] = ''
             bag[sha]['age'] = ''
     return bag
Ejemplo n.º 7
0
 def get_by_email(cls, email):
     username = None
     if check_douban_email(email):
         username = email.split('@')[0]
     else:
         user_email = CodeDoubanUserEmails.get_by_email(email)
         username = user_email.user_id if user_email else None
     return cls(username) if username else None
Ejemplo n.º 8
0
 def get_by_email(cls, email):
     username = None
     if check_douban_email(email):
         username = email.split('@')[0]
     else:
         user_email = CodeDoubanUserEmails.get_by_email(email)
         username = user_email.user_id if user_email else None
     return cls(username) if username else None