Prompt for a new filename via terminal.
346909
def prompt_terminal(path):
    """"""

    def rlinput(prompt_msg, prefill=''):
        """
        One line is read from standard input. Display `prompt_msg` on
        standard error. `prefill` is placed into the editing buffer
        before editing begins.
        """
        import readline
        readline.set_startup_hook(lambda: readline.insert_text(prefill))
        try:
            return input(prompt_msg)
        finally:
            readline.set_startup_hook()

    filepath, extension = os.path.splitext(path)
    basename = os.path.basename(filepath)
    dirname = os.path.dirname(filepath)

    # display filename prompt
    new_basename = rlinput('Filename: ', basename)

    # retry prompt if new filename already exists
    while os.path.exists(os.path.join(dirname, new_basename + extension)) and \
            new_basename != basename:
        new_basename = rlinput('Sorry, please try again... Filename: ',
                               basename)

    if new_basename == '':
        new_basename = basename

    return os.path.join(dirname, new_basename + extension)
812951
def output(filename,**opts)
    term = opts.delete(:term) || opts.delete(:terminal)
    if term.nil? && /\.(\w+)$/ =~ filename
      term = $1
    end
    term = KNOWN_EXT[term] || term
    if term.nil?
      kernel_raise GnuplotError,"file extension is not given"
    end
    set :terminal, term, *opts
    set output:filename
    refresh
    unset :terminal
    unset :output
  end
1189805
def _make_command_filename(self, exe):
        """"""

        outfn = os.path.join(self.commons['cmddir'], self.name(),
                             self._mangle_command(exe))

        # check for collisions
        if os.path.exists(outfn):
            inc = 2
            while True:
                newfn = "%s_%d" % (outfn, inc)
                if not os.path.exists(newfn):
                    outfn = newfn
                    break
                inc += 1

        return outfn
221627
def set_output(self,filename,pass_to_command_line=True):
    
    self.__output = filename
    if pass_to_command_line:
      self.add_var_opt('output', filename)
    self.add_output_file(filename)
1333999
def _updateFilename(self):
        
        self._filename = self._filenameLineEdit.text()
        self._guessEncoding(self._filename)
        self._previewFile()
996582
def create_new_file(self, current_path, title, filters, create_func):
        """"""
        if current_path is None:
            current_path = ''
        if osp.isfile(current_path):
            current_path = osp.dirname(current_path)
        self.redirect_stdio.emit(False)
        fname, _selfilter = getsavefilename(self, title, current_path, filters)
        self.redirect_stdio.emit(True)
        if fname:
            try:
                create_func(fname)
                return fname
            except EnvironmentError as error:
                QMessageBox.critical(self, _("New file"),
                                     _("<b>Unable to create file <i>%s</i>"
                                       "</b><br><br>Error message:<br>%s"
                                       ) % (fname, to_text_string(error)))
1109230
def cli(ctx):
    """"""
    cmd = click.prompt('Command')
    desc = click.prompt('Description ')
    alias = click.prompt('Alias (optional)', default='')
    utils.save_command(cmd, desc, alias)

    utils.log(ctx, 'Saved the new command - {} - with the description - {}.'.format(cmd, desc))
822605
def random_filename(path=None):
    """"""
    filename = uuid4().hex
    if path is not None:
        filename = os.path.join(path, filename)
    return filename
1082175
def get_new_filename(self, name):
        """"""
        name = MigrationFile.normalize_name(name)
        migrations = self.get_migration_files()
        migration_id = migrations[-1].id if migrations else 0
        migration_id += 1
        return '{:04}_{}.py'.format(migration_id, name)
498521
def output_filename(name)
      path = File.expand_path(name, output_dir)
      output File.new(path, 'a+')
    end
1203202
def _getPFilename(self,native,prompt):
        
        return self.get(native=native,prompt=prompt)
356193
def overwrite_file_check(args, filename):
    """"""
    if not args['overwrite'] and os.path.exists(filename):
        # Confirm overwriting of the file, or modify filename
        if args['no_overwrite']:
            overwrite = False
        else:
            try:
                overwrite = confirm_input(input('Overwrite {0}? (yes/no): '
                                                .format(filename)))
            except (KeyboardInterrupt, EOFError):
                sys.exit()
        if not overwrite:
            new_filename = modify_filename_id(filename)
            while os.path.exists(new_filename):
                new_filename = modify_filename_id(new_filename)
            return new_filename
    return filename
404297
def display(self, filename=None):
        """"""

        if filename is None:
            filename = self.original_filename

        # write to a (by default temporary) file
        with open(filename, 'w') as output_svg:
            output_svg.write(etree.tostring(self.tree.getroot()))

        open_in_browser(filename)
1354617
def replace_in_files(dirname, replace):
    """"""
    filepath = os.path.abspath(dirname / "requirements.in")
    if os.path.isfile(filepath) and header_footer_exists(filepath):
        replaced = re.sub(Utils.exp, replace, get_file_string(filepath))
        with open(filepath, "w") as f:
            f.write(replaced)
        print(color(
            "Written to file: {}".format(filepath),
            fg='magenta', style='bold'))
210166
def password_prompt(ctx, param, value):
    """"""
    if ctx.resilient_parsing:
        return

    if not value:
        if 'password_stdin' in ctx.params:
            with click.open_file('-') as fp:
                value = fp.read().strip('\n')
        else:
            value = click.prompt('Password', hide_input=True)

    click.echo(value)
    return value
805219
async def prompt(self, text=None):
        '''
        
        '''
        if self.sess is None:
            hist = FileHistory(s_common.getSynPath('cmdr_history'))
            self.sess = PromptSession(history=hist)

        if text is None:
            text = self.cmdprompt

        with patch_stdout():
            retn = await self.sess.prompt(text, async_=True, vi_mode=self.vi_mode, enable_open_in_editor=True)
            return retn
1102000
def file_name(self, value):
        
        if isinstance(value, FileName):
            self._file_name = value
        else:
            self._file_name = FileName(value)