Prompt the user to choose who to assign the issue to in jira, given a list of candidates,
    including the original reporter and all commentors
970370
def choose_jira_assignee(issue, asf_jira):
    
    while True:
        try:
            reporter = issue.fields.reporter
            commentors = map(lambda x: x.author, issue.fields.comment.comments)
            candidates = set(commentors)
            candidates.add(reporter)
            candidates = list(candidates)
            print("JIRA is unassigned, choose assignee")
            for idx, author in enumerate(candidates):
                if author.key == "apachespark":
                    continue
                annotations = ["Reporter"] if author == reporter else []
                if author in commentors:
                    annotations.append("Commentor")
                print("[%d] %s (%s)" % (idx, author.displayName, ",".join(annotations)))
            raw_assignee = input(
                "Enter number of user, or userid, to assign to (blank to leave unassigned):")
            if raw_assignee == "":
                return None
            else:
                try:
                    id = int(raw_assignee)
                    assignee = candidates[id]
                except:
                    # assume it's a user id, and try to assign (might fail, we just prompt again)
                    assignee = asf_jira.user(raw_assignee)
                asf_jira.assign_issue(issue.key, assignee.key)
                return assignee
        except KeyboardInterrupt:
            raise
        except:
            traceback.print_exc()
            print("Error assigning JIRA, try again (or leave blank and fix manually)")
874716
def add_issue_type(self, name, **attrs):
        
        return IssueTypes(self.requester).create(self.id, name, **attrs)
941123
public void chooseChoiceIndex(int choiceIdx) throws Exception {
		List<Choice> choices = getCurrentChoices();
		Assert(choiceIdx >= 0 && choiceIdx < choices.size(), "choice out of range");

		// Replace callstack with the one from the thread at the choosing point,
		// so that we can jump into the right place in the flow.
		// This is important in case the flow was forked by a new thread, which
		// can create multiple leading edges for the story, each of
		// which has its own context.
		Choice choiceToChoose = choices.get(choiceIdx);
		state.getCallStack().setCurrentThread(choiceToChoose.getThreadAtGeneration());

		choosePath(choiceToChoose.targetPath);
	}
591142
def _choose_from_list(options, question):
    """"""
    message = ""
    for index, value in enumerate(options):
        message += "[{}] {}\n".format(index, value)
    message += "\n" + question

    def valid(n):
        if int(n) not in range(len(options)):
            raise ValueError("Not a valid option.")
        else:
            return int(n)

    prompt(message, validate=valid, key="answer")
    return env.answer
256234
def create_single_poll_submission(self, poll_id, poll_session_id, poll_submissions_poll_choice_id):
        
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - poll_id
        """ID"""
        path["poll_id"] = poll_id

        # REQUIRED - PATH - poll_session_id
        """ID"""
        path["poll_session_id"] = poll_session_id

        # REQUIRED - poll_submissions[poll_choice_id]
        """The chosen poll choice for this submission."""
        data["poll_submissions[poll_choice_id]"] = poll_submissions_poll_choice_id

        self.logger.debug("POST /api/v1/polls/{poll_id}/poll_sessions/{poll_session_id}/poll_submissions with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("POST", "/api/v1/polls/{poll_id}/poll_sessions/{poll_session_id}/poll_submissions".format(**path), data=data, params=params, no_data=True)
350147
def run_create_admin(*args):
    '''
    
    '''
    post_data = {
        'user_name': 'giser',
        'user_email': 'giser@osgeo.cn',
        'user_pass': '131322',
        'role': '3300',
    }
    if MUser.get_by_name(post_data['user_name']):
        print('User {user_name} already exists.'.format(user_name='giser'))
    else:
        MUser.create_user(post_data)
18324
def issue(self, issue_instance_id):
        
        with self.db.make_session() as session:
            selected_issue = (
                session.query(IssueInstance)
                .filter(IssueInstance.id == issue_instance_id)
                .scalar()
            )

            if selected_issue is None:
                self.warning(
                    f"Issue {issue_instance_id} doesn't exist. "
                    "Type 'issues' for available issues."
                )
                return

            self.sources = self._get_leaves_issue_instance(
                session, issue_instance_id, SharedTextKind.SOURCE
            )

            self.sinks = self._get_leaves_issue_instance(
                session, issue_instance_id, SharedTextKind.SINK
            )

        self.current_issue_instance_id = int(selected_issue.id)
        self.current_frame_id = -1
        self.current_trace_frame_index = 1  # first one after the source

        print(f"Set issue to {issue_instance_id}.")
        if int(selected_issue.run_id) != self.current_run_id:
            self.current_run_id = int(selected_issue.run_id)
            print(f"Set run to {self.current_run_id}.")
        print()

        self._generate_trace_from_issue()
        self.show()
606557
def allow_analyst_reassignment(self):
        
        reassing_analyst_transition = {
            "id": "reassign",
            "title": _("Reassign")}
        for rs in self.review_states:
            if rs["id"] not in ["default", "mine", "open", "all"]:
                continue
            rs["custom_transitions"].append(reassing_analyst_transition)
        self.show_select_column = True
        self.show_workflow_action_buttons = True
542022
def get_create_option(self, context, q):
        """"""
        create_option = []
        display_create_option = False
        if self.create_field and q:
            page_obj = context.get('page_obj', None)
            if page_obj is None or page_obj.number == 1:
                display_create_option = True

        if display_create_option and self.has_add_permission(self.request):
            '''
            Generate querysets of Locations, StaffMembers, and Users that 
            match the query string.
            '''
            for s in Location.objects.filter(
                Q(
                    Q(name__istartswith=q) & Q(transactionparty__isnull=True)
                )
            ):
                create_option += [{
                    'id': 'Location_%s' % s.id,
                    'text': _('Generate from location "%(location)s"') % {'location': s.name},
                    'create_id': True,
                }]

            for s in StaffMember.objects.filter(
                Q(
                    (Q(firstName__istartswith=q) | Q(lastName__istartswith=q)) &
                    Q(transactionparty__isnull=True)
                )
            ):
                create_option += [{
                    'id': 'StaffMember_%s' % s.id,
                    'text': _('Generate from staff member "%(staff_member)s"') % {'staff_member': s.fullName},
                    'create_id': True,
                }]

            for s in User.objects.filter(
                Q(
                    (Q(first_name__istartswith=q) | Q(last_name__istartswith=q)) &
                    Q(staffmember__isnull=True) & Q(transactionparty__isnull=True)
                )
            ):
                create_option += [{
                    'id': 'User_%s' % s.id,
                    'text': _('Generate from user "%(user)s"') % {'user': s.get_full_name()},
                    'create_id': True,
                }]

            # Finally, allow creation from a name only.
            create_option += [{
                'id': q,
                'text': _('Create "%(new_value)s"') % {'new_value': q},
                'create_id': True,
            }]
        return create_option
1267267
def prompt(questions: List[Dict[Text, Any]],
           answers: Optional[Dict[Text, Any]] = None,
           patch_stdout: bool = False,
           true_color: bool = False,
           kbi_msg: Text = DEFAULT_KBI_MESSAGE,
           **kwargs):
    """"""

    if isinstance(questions, dict):
        questions = [questions]

    answers = answers or {}

    for question_config in questions:
        # import the question
        if 'type' not in question_config:
            raise PromptParameterException('type')
        if 'name' not in question_config:
            raise PromptParameterException('name')

        choices = question_config.get('choices')
        if choices is not None and callable(choices):
            question_config['choices'] = choices(answers)

        _kwargs = kwargs.copy()
        _kwargs.update(question_config)

        _type = _kwargs.pop('type')
        _filter = _kwargs.pop('filter', None)
        name = _kwargs.pop('name')
        when = _kwargs.pop('when', None)

        if true_color:
            _kwargs["color_depth"] = ColorDepth.TRUE_COLOR

        try:
            if when:
                # at least a little sanity check!
                if callable(question_config['when']):
                    try:
                        if not question_config['when'](answers):
                            continue
                    except Exception as e:
                        raise ValueError("Problem in 'when' check of {} "
                                         "question: {}".format(name, e))
                else:
                    raise ValueError("'when' needs to be function that "
                                     "accepts a dict argument")
            if _filter:
                # at least a little sanity check!
                if not callable(_filter):
                    raise ValueError("'filter' needs to be function that "
                                     "accepts an argument")

            if callable(question_config.get('default')):
                _kwargs['default'] = question_config['default'](answers)

            create_question_func = prompt_by_name(_type)

            if not create_question_func:
                raise ValueError("No question type '{}' found. "
                                 "Known question types are {}."
                                 "".format(_type, ", ".join(AVAILABLE_PROMPTS)))

            missing_args = list(utils.missing_arguments(create_question_func,
                                                        _kwargs))
            if missing_args:
                raise PromptParameterException(missing_args[0])

            question = create_question_func(**_kwargs)

            answer = question.unsafe_ask(patch_stdout)

            if answer is not None:
                if _filter:
                    try:
                        answer = _filter(answer)
                    except Exception as e:
                        raise ValueError("Problem processing 'filter' of {} "
                                         "question: {}".format(name, e))
                answers[name] = answer
        except KeyboardInterrupt:
            print('')
            print(kbi_msg)
            print('')
            return {}
    return answers
734925
def createissue(accountable, options):
    
    issue = accountable.issue_create(options)
    headers = sorted(['id', 'key', 'self'])
    rows = [headers, [itemgetter(header)(issue) for header in headers]]
    print_table(SingleTable(rows))
366370
def list_user_participants(self, id, registration_status=None):
        
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - id
        """ID"""
        path["id"] = id

        # OPTIONAL - registration_status
        """Limits results to the a given participation status, defaults to "all""""
        if registration_status is not None:
            self._validate_enum(registration_status, ["all", "registered", "registered"])
            params["registration_status"] = registration_status

        self.logger.debug("GET /api/v1/appointment_groups/{id}/users with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("GET", "/api/v1/appointment_groups/{id}/users".format(**path), data=data, params=params, no_data=True)
1145616
def prompt_for_choice(values, message, input_type=int, output_type=None):
    """"""
    output = None
    while not output:
        index = prompt_for_input(message, input_type=input_type)

        try:
            output = utf8(values[index])
        except IndexError:
            error_message('Selection out of range')
            continue

    if output_type:
        output = output_type(output)

    return output
981110
def extract(self, item, list_article_candidate):
        
        list_author = []

        # The authors of the ArticleCandidates and the respective extractors are saved in a tuple in list_author.
        for article_candidate in list_article_candidate:
            if (article_candidate.author is not None) and (article_candidate.author != '[]'):
                list_author.append((article_candidate.author, article_candidate.extractor))

        # If there is no value in the list, return None.
        if len(list_author) == 0:
            return None

        # If there are more options than one, return the result from newspaper.
        list_newspaper = [x for x in list_author if x[1] == "newspaper"]
        if len(list_newspaper) == 0:

            # If there is no author extracted by newspaper, return the first result of list_author.
            return list_author[0][0]
        else:
            return list_newspaper[0][0]
764089
def jira_role(name, rawtext, text, lineno, inliner,
              options=None, content=None, oxford_comma=True):
    
    options = options or {}
    content = content or []
    config = inliner.document.settings.env.app.config

    ticket_ids = [each.strip() for each in utils.unescape(text).split(',')]
    n_tickets = len(ticket_ids)

    if oxford_comma:
        sep_factory = _oxford_comma_separator
    else:
        sep_factory = _comma_separator

    node_list = []
    for i, ticket_id in enumerate(ticket_ids):
        node = _make_ticket_node(ticket_id, config, options=options)
        node_list.append(node)
        sep_text = sep_factory(i, n_tickets)
        if sep_text is not None:
            sep = nodes.raw(text=sep_text, format='html')
            node_list.append(sep)
    return node_list, []
526653
def create(user_name, repo_name, issue_id, params={})
      _update_user_repo_params(user_name, repo_name)
      _validate_user_repo_params(user, repo) unless user? && repo?
      _validate_presence_of issue_id

      normalize! params
      # _merge_mime_type(:issue_comment, params)
      filter! VALID_ISSUE_COMMENT_PARAM_NAME, params
      assert_required_keys(%w[ content ], params)

      post_request("/1.0/repositories/#{user}/#{repo.downcase}/issues/#{issue_id}/comments/", params)
    end
1252307
def process_submitters(self):
        """"""
        for submission in self.submissions.values():
            if submission.author and (self.distinguished or
                                      submission.distinguished is None):
                self.submitters[submission.author].append(submission)