获取最佳回答者

        :return: 此话题下最佳回答者，一般来说是5个，要不就没有，返回生成器
        :rtype: Author.Iterable
553278
def top_authors(self):
        
        from .author import Author, ANONYMOUS
        self._make_soup()
        t = self.soup.find('div', id='zh-topic-top-answerer')
        if t is None:
            return
        for d in t.find_all('div', class_='zm-topic-side-person-item-content'):
            url = Zhihu_URL + d.a['href']
            name = d.a.text
            motto = d.find('span', class_='bio')['title']
            try:
                yield Author(url, name, motto, session=self._session)
            except ValueError:  # invalid url
                yield ANONYMOUS
1194632
def parse_author(self, value):
        
        tokens = tuple([t.upper().strip() for t in value.split(',')])
        if len(tokens) == 1:
            tokens = value.split(' ')
        if len(tokens) > 0:
            if len(tokens) > 1:
                aulast, auinit = tokens[0:2]    # Ignore JR, II, III, etc.
            else:
                aulast = tokens[0]
                auinit = ''
        else:
            aulast, auinit = tokens[0], ''
        aulast = _strip_punctuation(aulast).upper()
        auinit = _strip_punctuation(auinit).upper()
        return aulast, auinit
136740
def list_authors():
    """"""
    authors = Author.query.all()
    content = '<p>Authors:</p>'
    for author in authors:
        content += '<p>%s</p>' % author.name
    return content
1162469
def authors(self):
        
        out = []
        order = 'name surname initials id url'
        auth = namedtuple('Author', order)
        for author in self._citeInfoMatrix.get('author'):
            author = {k.split(":", 1)[-1]: v for k, v in author.items()}
            new = auth(name=author.get('index-name'), id=author.get('authid'),
                       surname=author.get('surname'),
                       initials=author.get('initials'),
                       url=author.get('author-url'))
            out.append(new)
        return out or None
1046923
function author() {
      function _author(auth) {
        var format;
        if (typeof auth === 'string') {
          return auth;
        }
        format = require('util').format;
        return format('%s <%s>', auth.name, auth.email);
      }

      if (Array.isArray(pkg.author)) {
        return pkg.author.map(function makeAuthor(auth) {
          return _author(auth);
        }).join(', ');
      }
      return _author(pkg.author);
    }
716492
def author(self):
        
        CreationEvent = self.session.get_class(surf.ns.EFRBROO['F27_Work_Conception'])
        Person = self.session.get_class(surf.ns.EFRBROO['F10_Person'])
        creation_event =  CreationEvent.get_by(efrbroo_R16_initiated=self).first()
        return Person.get_by(efrbroo_P14i_performed = creation_event).first()
550570
def authors(self):
        
        result = []
        authors = self._safe_get_element('ItemAttributes.Author')
        if authors is not None:
            for author in authors:
                result.append(author.text)
        return result
199111
def get_statistics(self):
        
        statistics = {
            "number_authors": 0,
            "number_author_names": 0,
            "number_author_abbreviations": 0,
            "number_works": 0,
            "number_work_titles": 0,
            "number_title_abbreviations": 0,
            "number_opus_maximum":0,
        }
        for author in self.get_authors():
            if author.get_urn() is not None:
                opmax = True if self.get_opus_maximum_of(author.get_urn())\
                    is not None else False
                if opmax:
                    statistics["number_opus_maximum"] += 1
            statistics["number_authors"] += 1
            statistics["number_author_names"] += len(author.get_names())
            statistics["number_author_abbreviations"] += len(
                author.get_abbreviations()
            )
            for work in author.get_works():
                statistics["number_works"] += 1
                statistics["number_work_titles"] += len(work.get_titles())
                statistics["number_title_abbreviations"] += len(
                    work.get_abbreviations()
                )
        return statistics
714028
def generate_authors():
    
    print('Generating AUTHORS')

    # Get our list of authors
    print('Collecting author names')
    r = subprocess.Popen(['git', 'log', '--use-mailmap', '--format=%aN'],
                         stdout=subprocess.PIPE)
    seen_authors = []
    authors = []
    for authfile in ('AUTHORS', 'AUTHORS.rst'):
        if os.path.exists(authfile):
            break
    with open(authfile, 'r') as f:
        for line in f.readlines():
            if line.startswith("*"):
                author = force_text(line).strip("* \n")
                if author.lower() not in seen_authors:
                    seen_authors.append(author.lower())
                    authors.append(author)
    for author in r.stdout.readlines():
        author = force_text(author).strip()
        if author.lower() not in seen_authors:
            seen_authors.append(author.lower())
            authors.append(author)

    # Sort our list of Authors by their case insensitive name
    authors = sorted(authors, key=lambda x: x.lower())

    # Write our authors to the AUTHORS file
    print('Authors (%s):\n\n\n* %s' % (len(authors), '\n* '.join(authors)))
677060
def author(self):
        
        from .author import Author

        author = self.soup.find('div', class_='zm-item-answer-author-info')
        url, name, motto, photo = parser_author_from_tag(author)
        if name == '匿名用户':
            return ANONYMOUS
        else:
            return Author(url, name, motto, photo_url=photo,
                          session=self._session)
819889
def get_authors(self, language):
        
        return self.gettext(language, self._author) if self._author else ""
1279182
def blog_authors(*args):
    
    blog_posts = BlogPost.objects.published()
    authors = User.objects.filter(blogposts__in=blog_posts)
    return list(authors.annotate(post_count=Count("blogposts")))
369624
def author_from_git(self):
        
        self.author = None
        try:
            encoding = locale.getdefaultlocale()[1]
            # launch git command and get answer
            cmd = Popen(["git", "config", "--get", "user.name"], stdout=PIPE)
            stdoutdata = cmd.communicate().decode(encoding)
            if (stdoutdata[0]):
                import ipdb;ipdb.set_trace()
                author = stdoutdata[0].rstrip(os.linesep)
                self.author = author#.decode('utf8')
        except ImportError:
            pass
        except CalledProcessError:
            pass
        except OSError:
            pass

        return self.author
887961
def to_dict(self):
        ''''''
        if not self.record_type == 'journal':
            # todo: it may be worthwhile creating subclasses for each entry type (journal, conference, etc.) with a common
            # API e.g. to_json which creates output appropriately
            raise Exception('This function has only been tested on journal entries at present.')

        author_list = []
        authors = self.article.get('authors', [])
        for x in range(len(authors)):
            author = authors[x]
            first_name = None
            middle_names = None
            if author.get('given_name'):
                names = author['given_name'].split()
                first_name = names[0]
                middle_names = (' '.join(names[1:])) or None
            author_list.append(
                dict(
                    AuthorOrder = x + 1,
                    FirstName = first_name,
                    MiddleNames = middle_names,
                    Surname = author.get('surname')
                )
            )

        return dict(
            Title = self.article.get('title'),
            PublicationName = self.issue.get('full_title'),
            Volume = self.issue.get('volume'),
            Issue = self.issue.get('issue'),
            StartPage = self.article.get('first_page'),
            EndPage = self.article.get('last_page'),
            PublicationYear = self.get_year(),
            PublicationDate = self.get_earliest_date(),
            RIS = None,
            DOI = self.doi,
            PubMedID = self.get_pubmed_id(),
            URL = 'http://dx.doi.org/%s' % self.doi,
            ISSN = None, # eight-digit number
            authors = author_list,
            #
            RecordType = DOI.record_types.get(self.record_type)
        )
988570
def get_author(self):
        
        author = self.commit.author

        out = ""
        if author.name is not None:
            out += author.name

        if author.email is not None:
            out += " (" + author.email + ")"

        return out
279638
def unique_authors(self, limit):
        """"""
        seen = set()
        if limit == 0:
            limit = None
        seen_add = seen.add  # Assign to variable, so not resolved each time
        return [x.author for x in self.sorted_commits[:limit]
                if not (x.author in seen or seen_add(x.author))]
161844
def limit_author_choices():
    
    LIMIT_AUTHOR_CHOICES = getattr(settings, 'BLOG_LIMIT_AUTHOR_CHOICES_GROUP', None)
    if LIMIT_AUTHOR_CHOICES:
        if isinstance(LIMIT_AUTHOR_CHOICES, str):
            limit = Q(groups__name=LIMIT_AUTHOR_CHOICES)
        else:
            limit = Q()
            for s in LIMIT_AUTHOR_CHOICES:
                limit = limit | Q(groups__name=s)
        if getattr(settings, 'BLOG_LIMIT_AUTHOR_CHOICES_ADMIN', False):
            limit = limit | Q(is_staff=True)
    else:
        limit = {'is_staff': True}
    return limit