获取问题的提问者.
        
        :return: 提问者
        :rtype: Author or zhihu.ANONYMOUS
484316
def author(self):
        
        from .author import Author, ANONYMOUS

        logs = self._query_logs()
        author_a = logs[-1].find_all('div')[0].a
        if author_a.text == '匿名用户':
            return ANONYMOUS
        else:
            url = Zhihu_URL + author_a['href']
            return Author(url, name=author_a.text, session=self._session)
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);
    }
276086
def get_identities(self, item):
        

        field = self.get_field_author()
        yield self.get_sh_identity(item, field)
36649
def get_or_create_author(self, api_author):
        
        return Author.objects.get_or_create(site_id=self.site_id,
                                            wp_id=api_author["ID"],
                                            defaults=self.api_object_data("author", api_author))
1210197
def authors(self):
        """"""
        authors = self.xml.find('authors', ns)
        try:
            return [_ScopusAuthor(author) for author in authors]
        except TypeError:
            return None
1194249
def as_dict(self):
        
        data = get_dict_for_attrs(self, ['id', 'raw_id', 'short_id',
            'revision', 'date', 'message'])
        data['author'] = {'name': self.author_name, 'email': self.author_email}
        data['added'] = [node.path for node in self.added]
        data['changed'] = [node.path for node in self.changed]
        data['removed'] = [node.path for node in self.removed]
        return data
1210865
def get_identities(self, item):
        

        # question
        user = self.get_sh_identity(item, self.get_field_author())
        yield user

        # answers
        if 'answers' in item['data']:
            for answer in item['data']['answers']:
                # avoid "answered_by" : "This post is a wiki" corner case
                if type(answer['answered_by']) is dict:
                    user = self.get_sh_identity(answer['answered_by'])
                    yield user
                if 'comments' in answer:
                    for comment in answer['comments']:
                        commenter = self.get_sh_identity(comment)
                        yield commenter
1026606
def serializeInstitution(self):
        
        institution_data = []
        institution_instance_data = []
        affiliation_data = []
        affiliation_id = tethnedao.getMaxAffiliationID()
        institution_id = tethnedao.getMaxInstitutionID()
        institution_instance_id = tethnedao.getMaxInstitutionInstanceID()

        for paper in self.corpus:
            if hasattr(paper, 'authorAddress'):
                paper_key = getattr(paper, Serialize.paper_source_map[self.source])
                if type(paper.authorAddress) is unicode:
                    institution_id += 1
                    institution_instance_id += 1
                    institute_literal, authors = SerializeUtility.get_auth_inst(paper.authorAddress)
                    institute_row, institute_instance_row = self.get_details_from_inst_literal(institute_literal,
                                                                                               institution_id,
                                                                                               institution_instance_id,
                                                                                               paper_key)
                    if institute_row:
                        institution_data.append(institute_row)
                    institution_instance_data.append(institute_instance_row)
                    if authors:
                        for author in authors:
                            affiliation_id += 1
                            affiliation_row = self.get_affiliation_details(author, affiliation_id, institute_literal)
                            affiliation_data.append(affiliation_row)

                elif type(paper.authorAddress) is list:
                    for address in paper.authorAddress:
                        institution_id += 1
                        institution_instance_id += 1
                        institute_literal, authors = SerializeUtility.get_auth_inst(address)
                        institute_row, institute_instance_row = self.get_details_from_inst_literal(institute_literal,
                                                                                                   institution_id,
                                                                                                   institution_instance_id,
                                                                                                   paper_key)
                        if institute_row:
                            institution_data.append(institute_row)
                        institution_instance_data.append(institute_instance_row)
                        if authors is None:
                            authors = prevAuthors
                        for author in authors:
                            affiliation_id += 1
                            affiliation_row = self.get_affiliation_details(author, affiliation_id, institute_literal)
                            affiliation_data.append(affiliation_row)
                        prevAuthors = authors
        return institution_data, institution_instance_data, affiliation_data
881268
def send_message(self, author, content):
        
        if isinstance(author, Author) is False:
            raise ValueError('argument answer need to be Zhihu.Author object.')
        if not content:
            raise ValueError('answer content cannot be empty')
        if author.url == self.url:
                return False
        data = {
            'member_id': author.hash_id,
            'content': content,
            'token': '',
            '_xsrf': author.xsrf
        }
        res = self._session.post(Send_Message_Url,
                                 data=data)
        return res.json()['r'] == 0
202991
def unhelpful(self, answer, unhelpful=True):
        
        from .answer import Answer
        if isinstance(answer, Answer) is False:
            raise ValueError('argument answer need to be Zhihu.Answer object.')
        if answer.author.url == self.url:
                return False
        data = {
            '_xsrf': answer.xsrf,
            'aid': answer.aid
        }
        res = self._session.post(Unhelpful_Url if unhelpful else Cancel_Unhelpful_Url,
                                 data=data)
        return res.json()['r'] == 0
215868
def author_names(self):
        
        return {"%s$$n%i" % (author.get_urn(), i): name[1]
                for author in self.get_authors()
                for i, name in enumerate(author.get_names())
                if author.get_urn() is not None}
860133
def get(orcid_id):
    
    resp = requests.get(ORCID_PUBLIC_BASE_URL + unicode(orcid_id),
                        headers=BASE_HEADERS)
    json_body = resp.json()
    return Author(json_body)
756487
def login(self, user=None, password=None, **kwargs):
        
        cookies = kwargs.get('cookies')
        if cookies is None:
            raise TypeError('雪球登陆需要设置 cookies， 具体见'
                            'https://smalltool.github.io/2016/08/02/cookie/')
        headers = self._generate_headers()
        self.s.headers.update(headers)

        self.s.get(self.LOGIN_PAGE)

        cookie_dict = helpers.parse_cookies_str(cookies)
        self.s.cookies.update(cookie_dict)

        log.info('登录成功')
256000
def __fill_phab_ids(self, item):
        
        for p in item['projects']:
            if p and 'name' in p and 'phid' in p:
                self.phab_ids_names[p['phid']] = p['name']
        if 'authorData' not in item['fields'] or not item['fields']['authorData']:
            return
        self.phab_ids_names[item['fields']['authorData']['phid']] = item['fields']['authorData']['userName']
        if 'ownerData' in item['fields'] and item['fields']['ownerData']:
            self.phab_ids_names[item['fields']['ownerData']['phid']] = item['fields']['ownerData']['userName']
        if 'priority' in item['fields']:
            val = item['fields']['priority']['value']
            self.phab_ids_names[str(val)] = item['fields']['priority']['name']
        for t in item['transactions']:
            if 'authorData' in t and t['authorData'] and 'userName' in t['authorData']:
                self.phab_ids_names[t['authorData']['phid']] = t['authorData']['userName']
            elif t['authorData'] and 'name' in t['authorData']:
                # Herald
                self.phab_ids_names[t['authorData']['phid']] = t['authorData']['name']
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
499154
def upvoters(self):
        
        self._make_soup()
        next_req = '/answer/' + str(self.aid) + '/voters_profile'
        while next_req != '':
            data = self._session.get(Zhihu_URL + next_req).json()
            next_req = data['paging']['next']
            for html in data['payload']:
                soup = BeautifulSoup(html)
                yield self._parse_author_soup(soup)
468174
def author(self):
        """"""
        r = self.site.site_config['default_author']
        if 'author' in self._config:
            r = self._config['author']
        return r