Select handler for authors.
341374
def _pick_selected_option(cls):
        
        for option in cls.select_el:
            # if the select is empty
            if not hasattr(option, "selected"):
                return None

            if option.selected:
                return option.value

        return None
1306650
def announce(version):
    """"""
    # Get our list of authors
    stdout = check_output(["git", "describe", "--abbrev=0", "--tags"])
    stdout = stdout.decode("utf-8")
    last_version = stdout.strip()

    stdout = check_output(
        ["git", "log", "{}..HEAD".format(last_version), "--format=%aN"]
    )
    stdout = stdout.decode("utf-8")

    contributors = set(stdout.splitlines())

    template_name = (
        "release.minor.rst" if version.endswith(".0") else "release.patch.rst"
    )
    template_text = (
        Path(__file__).parent.joinpath(template_name).read_text(encoding="UTF-8")
    )

    contributors_text = (
        "\n".join("* {}".format(name) for name in sorted(contributors)) + "\n"
    )
    text = template_text.format(version=version, contributors=contributors_text)

    target = Path(__file__).parent.joinpath(
        "../doc/en/announce/release-{}.rst".format(version)
    )
    target.write_text(text, encoding="UTF-8")
    print(f"{Fore.CYAN}[generate.announce] {Fore.RESET}Generated {target.name}")

    # Update index with the new release entry
    index_path = Path(__file__).parent.joinpath("../doc/en/announce/index.rst")
    lines = index_path.read_text(encoding="UTF-8").splitlines()
    indent = "   "
    for index, line in enumerate(lines):
        if line.startswith("{}release-".format(indent)):
            new_line = indent + target.stem
            if line != new_line:
                lines.insert(index, new_line)
                index_path.write_text("\n".join(lines) + "\n", encoding="UTF-8")
                print(
                    f"{Fore.CYAN}[generate.announce] {Fore.RESET}Updated {index_path.name}"
                )
            else:
                print(
                    f"{Fore.CYAN}[generate.announce] {Fore.RESET}Skip {index_path.name} (already contains release)"
                )
            break

    check_call(["git", "add", str(target)])
732585
protected function selectAuthors()
    {
        $options = $this->getAuthorsAsOptions();
        $this->getOutput()->writeln('');
        $this->getOutput()->writeln(
            '<info>Multiple authors found on ' .
            'project\'s composer.json file.</info>'
        );
        $question = new ChoiceQuestion(
            'Please select the author from the list above:',
            $options,
            0
        );
        $question->setErrorMessage('The choice %s is invalid.');
        $selected = $this->getQuestionHelper()
            ->ask($this->input, $this->output, $question);
        $parts = explode('<', $selected);
        return [
            'authorName' => trim($parts[0]),
            'authorEmail' => trim($parts[1], '>'),
        ];
    }
908680
def _ref_bib(key, ref):
    '''
    '''
    s = ''

    s += '@{}{{{},\n'.format(ref['type'], key)

    entry_lines = []
    for k, v in ref.items():
        if k == 'type':
            continue

        # Handle authors/editors
        if k == 'authors':
            entry_lines.append('    author = {{{}}}'.format(' and '.join(v)))
        elif k == 'editors':
            entry_lines.append('    editor = {{{}}}'.format(' and '.join(v)))
        else:
            entry_lines.append('    {} = {{{}}}'.format(k, v))

    s += ',\n'.join(entry_lines)
    s += '\n}'

    return s
1322588
def _filter(client, names=None, authors=None, include=None, exclude=None):
    
    if isinstance(authors, str):
        authors = set(authors.split(','))

    if isinstance(authors, list) or isinstance(authors, tuple):
        authors = set(authors)

    records = []
    for path_, dataset in client.datasets.items():
        if not names or dataset.name in names:
            for file_ in dataset.files.values():
                file_.dataset = dataset.name

                path_ = file_.full_path.relative_to(client.path)
                match = _include_exclude(path_, include, exclude)

                if authors:
                    match = match and authors.issubset({
                        author.name
                        for author in file_.authors
                    })

                if match:
                    records.append(file_)

    return sorted(records, key=lambda file_: file_.added)
1173632
def all_contributors(soup, detail="brief"):
    ""
    contrib_tags = raw_parser.contributors(soup)
    contributors = format_authors(soup, contrib_tags, detail)
    return contributors
524362
def compile_authors(authors):
    
    author_list = []
    for person in authors:
        author_list.append({'name': person['family'] + ", " + person['given']})
    return author_list
1368653
def postprocess_authors_init(self, entry):
        
        if type(entry.authors_init) is not list:
            entry.authors_init = [entry.authors_init]
1079648
def format_author_line(author_names):
    """"""
    author_line = None
    if not author_names:
        return author_line
    if len(author_names) <= 2:
        author_line = ", ".join(author_names)
    elif len(author_names) > 2:
        author_line = author_names[0] + " et al."
    return author_line
155922
def select(self, Class, set=None, recursive=True,  ignore=True, node=None):
        """"""
        if self.include:
            return self.subdoc.data[0].select(Class,set,recursive, ignore, node) #pass it on to the text node of the subdoc
        else:
            return iter([])
589786
def set_author(self):
        """"""
        try:
            self.author = self.soup.find('author').string
        except AttributeError:
            self.author = None
798260
def get_publisher_name(self, **kwargs):
        """"""
        children = kwargs.get('children', [])
        # Find the creator type in children.
        for child in children:
            if child.tag == 'name':
                return child.content
        return None
1183142
function onCreating(model, attrs, options) {
            if (!model.get('author_id')) {
                if (model.get('authors')) {
                    model.set('author_id', model.get('authors')[0].id);
                } else {
                    model.set('author_id', this.contextUser(options));
                }
            }

            if (!model.get('authors')) {
                model.set('authors', [{
                    id: model.get('author_id')
                }]);
            }

            return this._handleOptions('onCreating')(model, attrs, options);
        }
137198
def import_authors(self, tree):
        
        self.write_out(self.style.STEP('- Importing authors\n'))

        post_authors = set()
        for item in tree.findall('channel/item'):
            post_type = item.find('{%s}post_type' % WP_NS).text
            if post_type == 'post':
                post_authors.add(item.find(
                    '{http://purl.org/dc/elements/1.1/}creator').text)

        self.write_out('> %i authors found.\n' % len(post_authors))

        authors = {}
        for post_author in post_authors:
            if self.default_author:
                authors[post_author] = self.default_author
            else:
                authors[post_author] = self.migrate_author(
                    post_author.replace(' ', '-'))
        return authors
86757
protected function selectionHandler()
    {
        $userCount = count($this->choices);
        if ($userCount > static::MAX_USER_CHOICES) {
            $this->autocomplete();
        } elseif ($userCount > 1) {
            $this->selector();
        } elseif (1 === $userCount) {
            $this->editor($this->choices[0]);
        }
    }
214285
def handle_CR(self, value):
        
        citation = self.entry_class()

        value = strip_tags(value)

        # First-author name and publication date.
        ptn = '([\w\s\W]+),\s([0-9]{4}),\s([\w\s]+)'
        ny_match = re.match(ptn, value, flags=re.U)
        nj_match = re.match('([\w\s\W]+),\s([\w\s]+)',
                            value, flags=re.U)
        if ny_match is not None:
            name_raw, date, journal = ny_match.groups()
        elif nj_match is not None:
            name_raw, journal = nj_match.groups()
            date = None
        else:
            return

        datematch = re.match('([0-9]{4})', value)
        if datematch:
            date = datematch.group(1)
            name_raw = None

        if name_raw:
            name_tokens = [t.replace('.', '') for t in name_raw.split(' ')]
            if len(name_tokens) > 4 or value.startswith('*'):    # Probably not a person.
                proc = lambda x: _strip_punctuation(x)
                aulast = ' '.join([proc(n) for n in name_tokens]).upper()
                auinit = ''
            elif len(name_tokens) > 0:
                aulast = name_tokens[0].upper()
                proc = lambda x: _space_sep(_strip_punctuation(x))
                auinit = ' '.join([proc(n) for n in name_tokens[1:]]).upper()
            else:
                aulast = name_tokens[0].upper()
                auinit = ''

            setattr(citation, 'authors_init', [(aulast, auinit)])

        if date:
            date = int(date)
        setattr(citation, 'date', date)
        setattr(citation, 'journal', journal)

        # Volume.
        v_match = re.search('\,\s+V([0-9A-Za-z]+)', value)
        if v_match is not None:
            volume = v_match.group(1)
        else:
            volume = None
        setattr(citation, 'volume', volume)

        # Start page.
        p_match = re.search('\,\s+[Pp]([0-9A-Za-z]+)', value)
        if p_match is not None:
            page = p_match.group(1)
        else:
            page = None
        setattr(citation, 'pageStart', page)

        # DOI.
        doi_match = re.search('DOI\s(.*)', value)
        if doi_match is not None:
            doi = doi_match.group(1)
        else:
            doi = None
        setattr(citation, 'doi', doi)
        return citation
955064
def references_json_authors(ref_authors, ref_content):
    ""
    all_authors = references_authors(ref_authors)
    if all_authors != {}:
        if ref_content.get("type") in ["conference-proceeding", "journal", "other",
                                           "periodical", "preprint", "report", "web"]:
            for author_type in ["authors", "authorsEtAl"]:
                set_if_value(ref_content, author_type, all_authors.get(author_type))
        elif ref_content.get("type") in ["book", "book-chapter"]:
            for author_type in ["authors", "authorsEtAl", "editors", "editorsEtAl"]:
                set_if_value(ref_content, author_type, all_authors.get(author_type))
        elif ref_content.get("type") in ["clinical-trial"]:
            # Always set as authors, once,  then add the authorsType
            for author_type in ["authors", "collaborators", "sponsors"]:
                if "authorsType" not in ref_content and all_authors.get(author_type):
                    set_if_value(ref_content, "authors", all_authors.get(author_type))
                    set_if_value(ref_content, "authorsEtAl", all_authors.get(author_type + "EtAl"))
                    ref_content["authorsType"] = author_type
        elif ref_content.get("type") in ["data", "software"]:
            for author_type in ["authors", "authorsEtAl",
                                "compilers", "compilersEtAl", "curators", "curatorsEtAl"]:
                set_if_value(ref_content, author_type, all_authors.get(author_type))
        elif ref_content.get("type") in ["patent"]:
            for author_type in ["inventors", "inventorsEtAl", "assignees", "assigneesEtAl"]:
                set_if_value(ref_content, author_type, all_authors.get(author_type))
        elif ref_content.get("type") in ["thesis"]:
            # Convert list to a non-list
            if all_authors.get("authors") and len(all_authors.get("authors")) > 0:
                ref_content["author"] = all_authors.get("authors")[0]
    return ref_content