当前位置: 首页>>代码示例>>Python>>正文


Python moves.input方法代码示例

本文整理汇总了Python中six.moves.input方法的典型用法代码示例。如果您正苦于以下问题:Python moves.input方法的具体用法?Python moves.input怎么用?Python moves.input使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在six.moves的用法示例。


在下文中一共展示了moves.input方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ask_when_work_is_populated

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import input [as 别名]
def ask_when_work_is_populated(self, work):
    """When work is already populated asks whether we should continue.

    This method prints warning message that work is populated and asks
    whether user wants to continue or not.

    Args:
      work: instance of WorkPiecesBase

    Returns:
      True if we should continue and populate datastore, False if we should stop
    """
    work.read_all_from_datastore()
    if work.work:
      print('Work is already written to datastore.\n'
            'If you continue these data will be overwritten and '
            'possible corrupted.')
      inp = input_str('Do you want to continue? '
                      '(type "yes" without quotes to confirm): ')
      return inp == 'yes'
    else:
      return True 
开发者ID:StephanZheng,项目名称:neural-fingerprinting,代码行数:24,代码来源:master.py

示例2: get_name

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import input [as 别名]
def get_name():
    print("")
    print("Chute Name")
    print("")
    print("This name will be used on the router status page and chute store.")
    print("Please use only lowercase letters, numbers, and hypens.")
    print("")

    # Guess the project name based on the directory we are in.
    default_name = os.path.basename(os.getcwd())

    while True:
        name = input("name [{}]: ".format(default_name))
        if len(name) == 0:
            name = default_name

        match = re.match("[a-z][a-z0-9\-]*", name)
        if match is None:
            print("The name does not meet Paradrop's requirements for chute names.")
            print("Please use only lowercase letters, numbers, and hypens.")
            continue

        return name 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:25,代码来源:chute.py

示例3: get_chute_type

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import input [as 别名]
def get_chute_type():
    print("")
    print("Chute Type")
    print("")
    print("Paradrop has two types of chutes. Light chutes are based on a base")
    print("image that is optimized for a particular language such as Python or")
    print("JavaScript and use the language-specific package manager (pip or npm)")
    print("to install dependencies. Normal chutes give you more flexibility to")
    print("install dependencies but require that you write your own Dockerfile.")
    print("")
    print("Valid types: light, normal")
    valid = set(["light", "normal"])
    while True:
        ctype = input("type [normal]: ").lower()
        if len(ctype) == 0:
            ctype = "normal"

        if ctype not in valid:
            print("Valid types: light, normal")
            continue

        return ctype 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:24,代码来源:chute.py

示例4: get_base_name

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import input [as 别名]
def get_base_name():
    print("")
    print("Base Image Name")
    print("")
    print("Enter the name of the base image to use. This depends on the")
    print("programming language that you intend to use.")
    print("")
    print("Valid choices: " + ", ".join(SUPPORTED_BASE_IMAGES))
    while True:
        name = input("image [python2]: ").lower()
        if len(name) == 0:
            name = "python2"

        if name not in SUPPORTED_BASE_IMAGES:
            print("Valid choices: " + ", ".join(SUPPORTED_BASE_IMAGES))
            continue

        return name 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:20,代码来源:chute.py

示例5: _ModelSupportPrompt

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import input [as 别名]
def _ModelSupportPrompt(self, message: Text, this_model: Text) -> bool:
    """Prompts the user whether to halt an unsupported build.

    Args:
      message: A message to be displayed to the user.
      this_model: The hardware model that failed validation.

    Returns:
      true if the user wishes to proceed anyway, else false.
    """
    warning = message % this_model
    print(warning)
    answer = input('Do you still want to proceed (y/n)? ')
    answer_re = r'^[Yy](es)?$'
    if re.match(answer_re, answer):
      return True
    return False 
开发者ID:google,项目名称:glazier,代码行数:19,代码来源:device_model.py

示例6: parse

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import input [as 别名]
def parse(self, arg):
    """Parses and validates the provided argument.

    Args:
      arg: str, the string to be parsed and validated.

    Returns:
      A boolean for whether or not the provided input is valid.

    Raises:
      ValueError: when the provided argument is invalid.
    """
    if isinstance(arg, bool):
      return arg
    clean_arg = arg.strip().lower()
    if clean_arg in self._valid_yes:
      return True
    if clean_arg in self._valid_no:
      return False
    raise ValueError("the value {!r} is not a 'yes' or 'no'".format(arg)) 
开发者ID:google,项目名称:loaner,代码行数:22,代码来源:utils.py

示例7: prompt_enum

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import input [as 别名]
def prompt_enum(message, accepted_values=None, case_sensitive=True, **kwargs):
  """Prompts the user for a value within an Enum.

  Args:
    message: str, the info message to display before prompting for user input.
    accepted_values: List[Any], a list of accepted values.
    case_sensitive: bool, whether or not validation should require the response
        to be the same case.
    **kwargs: keyword arguments to be passed to prompt.

  Returns:
    A user provided value from within the Enum.
  """
  message += '\nAvailable options are: {}'.format(', '.join(accepted_values))
  parser = flags.EnumParser(
      enum_values=accepted_values, case_sensitive=case_sensitive)
  return prompt(message, parser=parser, **kwargs) 
开发者ID:google,项目名称:loaner,代码行数:19,代码来源:utils.py

示例8: __init__

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import input [as 别名]
def __init__(self):
        self.more_info = False
        self.dynamic = False
        self.mode_list = ['frequency', 'sigscore', 'count']
        self.mode = 'frequency'
        # self.spanish_to_english = False
        self.num_options = 20

        load_prev = input('Load previous session? y/n\n')
        if load_prev != 'n':
            loaded_voicebox = self.load_session()               # unpickles a previously-saved object
            self.cursor = loaded_voicebox.cursor
            self.cursor_position = loaded_voicebox.cursor_position
            self.voices = loaded_voicebox.voices
            self.active_voice = loaded_voicebox.active_voice
            self.log = loaded_voicebox.log
        else:
            self.cursor = "|"
            self.cursor_position = 0
            self.voices = {}
            self.load_voices()
            self.active_voice = self.choose_voice()
            self.log = [] 
开发者ID:jbrew,项目名称:pt-voicebox,代码行数:25,代码来源:voicebox.py

示例9: add_voice

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import input [as 别名]
def add_voice(self):
        new_voice = Voice({})     # creates new voice with no name and empty tree of corpora
        texts = os.listdir('texts')
        add_another_corpus = ''
        while add_another_corpus != 'n':
            for i in range(len(texts)):
                print("%s %s" % (i + 1, texts[i]))
            choice = input('Enter the number of the corpus you want to load:\n')
            corpus_name = texts[int(choice) - 1]
            path = 'texts/%s' % corpus_name
            f = open(path, 'r')
            text = f.read()
            corpus_weight_prompt = 'Enter the weight for %s:\n' % corpus_name
            corpus_weight = float(input(corpus_weight_prompt))
            new_voice.add_corpus(Corpus(text, corpus_name), corpus_weight)
            texts.remove(corpus_name)
            add_another_corpus = input('Add another corpus to this voice? y/n\n')
        voicename = input('Name this voice:\n')
        new_voice.name = voicename
        new_voice.normalize_weights()
        self.voices[voicename] = new_voice

    # asks user to specify a transcript and number of characters, and makes separate voices for that number of
    # the most represented characters in the transcript 
开发者ID:jbrew,项目名称:pt-voicebox,代码行数:26,代码来源:voicebox.py

示例10: load_voices_from_transcript

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import input [as 别名]
def load_voices_from_transcript(self):
        transcripts = os.listdir('texts/transcripts')
        for i in range(len(transcripts)):
            print("%s %s" % (i + 1, transcripts[i]))
        choice = input('Enter the number of the transcript you want to load:\n')
        transcript_name = transcripts[int(choice) - 1]
        number = int(input('Enter the number of voices to load:\n'))
        for charname, size in self.biggest_characters(transcript_name, number):
            print(charname)
            path = 'texts/transcripts/%s/%s' % (transcript_name, charname)
            source_text = open(path).read()
            corpus_name = charname
            weighted_corpora = {}
            weighted_corpora[charname] = [Corpus(source_text, corpus_name), 1]
            self.voices[charname] = Voice(weighted_corpora, charname)

    # retrieves a list of the top 20 largest character text files in a transcript folder 
开发者ID:jbrew,项目名称:pt-voicebox,代码行数:19,代码来源:voicebox.py

示例11: label

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import input [as 别名]
def label(self, feature):
        plt.imshow(feature, cmap=plt.cm.gray_r, interpolation='nearest')
        plt.draw()

        banner = "Enter the associated label with the image: "

        if self.label_name is not None:
            banner += str(self.label_name) + ' '

        lbl = input(banner)

        while (self.label_name is not None) and (lbl not in self.label_name):
            print('Invalid label, please re-enter the associated label.')
            lbl = input(banner)

        return self.label_name.index(lbl) 
开发者ID:ntucllab,项目名称:libact,代码行数:18,代码来源:interactive_labeler.py

示例12: cleanup_failed_attacks

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import input [as 别名]
def cleanup_failed_attacks(self):
    """Cleans up data of failed attacks."""
    print_header('Cleaning up failed attacks')
    attacks_to_replace = {}
    self.attack_work.read_all_from_datastore()
    failed_submissions = set()
    error_msg = set()
    for k, v in iteritems(self.attack_work.work):
      if v['error'] is not None:
        attacks_to_replace[k] = dict(v)
        failed_submissions.add(v['submission_id'])
        error_msg.add(v['error'])
        attacks_to_replace[k].update(
            {
                'claimed_worker_id': None,
                'claimed_worker_start_time': None,
                'is_completed': False,
                'error': None,
                'elapsed_time': None,
            })
    self.attack_work.replace_work(attacks_to_replace)
    print('Affected submissions:')
    print(' '.join(sorted(failed_submissions)))
    print('Error messages:')
    print(' '.join(sorted(error_msg)))
    print('')
    inp = input_str('Are you sure? (type "yes" without quotes to confirm): ')
    if inp != 'yes':
      return
    self.attack_work.write_all_to_datastore()
    print('Work cleaned up') 
开发者ID:StephanZheng,项目名称:neural-fingerprinting,代码行数:33,代码来源:master.py

示例13: _cleanup_keys_with_confirmation

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import input [as 别名]
def _cleanup_keys_with_confirmation(self, keys_to_delete):
    """Asks confirmation and then deletes entries with keys.

    Args:
      keys_to_delete: list of datastore keys for which entries should be deleted
    """
    print('Round name: ', self.round_name)
    print('Number of entities to be deleted: ', len(keys_to_delete))
    if not keys_to_delete:
      return
    if self.verbose:
      print('Entities to delete:')
      idx = 0
      prev_key_prefix = None
      dots_printed_after_same_prefix = False
      for k in keys_to_delete:
        if idx >= 20:
          print('   ...')
          print('   ...')
          break
        key_prefix = (k.flat_path[0:1]
                      if k.flat_path[0] in [u'SubmissionType', u'WorkType']
                      else k.flat_path[0])
        if prev_key_prefix == key_prefix:
          if not dots_printed_after_same_prefix:
            print('   ...')
          dots_printed_after_same_prefix = True
        else:
          print('  ', k)
          dots_printed_after_same_prefix = False
          idx += 1
        prev_key_prefix = key_prefix
    print()
    inp = input_str('Are you sure? (type "yes" without quotes to confirm): ')
    if inp != 'yes':
      return
    with self.datastore_client.no_transact_batch() as batch:
      for k in keys_to_delete:
        batch.delete(k)
    print('Data deleted') 
开发者ID:StephanZheng,项目名称:neural-fingerprinting,代码行数:42,代码来源:master.py

示例14: get_description

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import input [as 别名]
def get_description():
    print("")
    print("Chute Description")
    print("")
    print("Enter a description for the chute. This will be displayed in")
    print("the chute store.")
    print("")
    while True:
        desc = input("description: ")
        if len(desc) == 0:
            continue

        return desc 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:15,代码来源:chute.py

示例15: get_command

# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import input [as 别名]
def get_command(name="my-app", use=None):
    print("")
    print("Command")
    print("")
    print("This is the command to start your application.")

    default = None
    if use == "go":
        print("For Go applications, it is highly recommended that you use the default.")
        default = "app"
    elif use == "gradle":
        print("For Java applications, you can accept the default and update")
        print("paradrop.yaml after you have decided on the structure of your project.")
        default = "java -jar build/libs/{name}-0.1.0.jar".format(name=name)
    elif use == "maven":
        print("For Java applications, you can accept the default and update")
        print("paradrop.yaml after you have decided on the structure of your project.")
        default = "java -cp target/{name}-1.0-SNAPSHOT.jar com.mycompany.{name}.Main".format(name=name)
    elif use == "node":
        default = "node index.js"
    elif use == "python2":
        default = "python2 -u main.py"
    else:
        default = ""
    print("")

    entry = input("command [{}]: ".format(default))
    if len(entry) == 0:
        entry = default

    return entry 
开发者ID:ParadropLabs,项目名称:Paradrop,代码行数:33,代码来源:chute.py


注:本文中的six.moves.input方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。