Open existing input file
328711
def load_input():
    
    file = open(_input_file, 'r')
    result = json.loads(file.read().strip('\0').strip())
    file.close()
    return result
150596
def input(self, str, filename=''):
        
        self.filestack.append([filename, 1, self.lex, self.input_data])

        self.input_data = str
        self.lex = lex.lex(object=self)
        self.lex.input(self.input_data)
312862
def OpenFile(self, filename):
    """"""
    (mime_type, encoding) = mimetypes.guess_type(filename)
    assert mime_type
    # A crude guess of when we should use binary mode. Without it non-unix
    # platforms may corrupt binary files.
    if mime_type.startswith('text/'):
      mode = 'r'
    else:
      mode = 'rb'
    return open(os.path.join(self.server.file_dir, filename), mode), mime_type
177082
def file(input_file, light=False):
    """"""
    util.create_dir(os.path.join(CONF_DIR, "colorschemes/light/"))
    util.create_dir(os.path.join(CONF_DIR, "colorschemes/dark/"))

    theme_name = ".".join((input_file, "json"))
    bri = "light" if light else "dark"

    user_theme_file = os.path.join(CONF_DIR, "colorschemes", bri, theme_name)
    theme_file = os.path.join(MODULE_DIR, "colorschemes", bri, theme_name)

    # Find the theme file.
    if input_file in ("random", "random_dark"):
        theme_file = get_random_theme()

    elif input_file == "random_light":
        theme_file = get_random_theme(light)

    elif os.path.isfile(user_theme_file):
        theme_file = user_theme_file

    elif os.path.isfile(input_file):
        theme_file = input_file

    # Parse the theme file.
    if os.path.isfile(theme_file):
        logging.info("Set theme to \033[1;37m%s\033[0m.",
                     os.path.basename(theme_file))
        return parse(theme_file)

    logging.error("No %s colorscheme file found.", bri)
    logging.error("Try adding   '-l' to set light themes.")
    logging.error("Try removing '-l' to set dark themes.")
    sys.exit(1)
761609
def split_input(self, input_filepath):
        """"""
        with open(input_filepath, 'r') as input_file:
            input_file_str = input_file.read()
            merge_file_str, parsetree_str = input_file_str.split('ParentedTree', 1)
            return merge_file_str, 'ParentedTree' + parsetree_str
1354512
private static InputStream inputFor( File file)
    {
    try
      {
      return
        file == null
        ? null
        : new FileInputStream( file);
      }
    catch( Exception e)
      {
      throw new IllegalArgumentException( "Can't open file=" + file);
      }
    }
923834
def load(name, path=None, ext="dat", silent=False):
    
    filename = __get_filename(path, name, ext)

    if not os.path.exists(filename):
        if not silent:
            raise ValueException("Specified input filename doesn't exist.")
        return None

    with open(filename, "rb") as f:
        return pickle.load(f)
1039590
def read_input(self, filename, has_header=True):
        
        stream = open(filename)
        reader = csv.reader(stream)
        csv_data = []
        for (i, row) in enumerate(reader):
            if i==0:
                if not has_header:
                    csv_data.append([str(i) for i in xrange(0,len(row))])
            csv_data.append(row)
        self.data = csv_data
1139374
def on_open_input_tool_clicked(self):
        
        input_path = self.input_path.text()
        if not input_path:
            input_path = os.path.expanduser('~')
        # noinspection PyCallByClass,PyTypeChecker
        filename, __ = QFileDialog.getOpenFileName(
            self, tr('Input file'), input_path, tr('Raw grid file (*.xml)'))
        if filename:
            self.input_path.setText(filename)
1227555
private InputStream openFile() throws IOException {
    Path file = Paths.get(filePath);
    if (Files.exists(file)) {
      return Files.newInputStream(file);
    }
    InputStream input = getClass().getResourceAsStream(filePath);
    checkArgument(input != null, "Could not find file: " + filePath);
    return input;
  }
155621
def read_file(filename: PathLike = "experiment.yml") -> Dict[str, Any]:
    """"""
    logger.debug("Input file: %s", filename)

    with open(filename, "r") as stream:
        structure = yaml.safe_load(stream)
    return structure
957052
def askopenfile(mode="r", **options):
    ""

    filename = askopenfilename(**options)
    if filename:
        return open(filename, mode)
    return None
228842
def split_input(args):
    """"""
    args['files'] = []
    args['urls'] = []
    for arg in args['query']:
        if os.path.isfile(arg):
            args['files'].append(arg)
        else:
            args['urls'].append(arg.strip('/'))
397181
def input(self, _in, out, **kw):
        
        # create a temp file
        tmp = NamedTemporaryFile(suffix='.js', delete=False)
        tmp.close()  # close it so windows can read it

        # write to a temp file
        elm_make = self.binary or 'elm-make'
        change_directory = bool(self.change_directory or False)
        source = kw['source_path']
        source_dir = os.path.dirname(source)
        exec_dir = source_dir if change_directory else os.getcwd()
        write_args = [elm_make, source, '--output', tmp.name, '--yes']
        with excursion(exec_dir), TemporaryFile(mode='w') as fake_write_obj:
            self.subprocess(write_args, fake_write_obj)

        # read the temp file
        cat_or_type = 'type' if platform == 'win32' else 'cat'
        read_args = [cat_or_type, tmp.name]
        self.subprocess(read_args, out)
        os.remove(tmp.name)
551739
def reformat_file(self, input_file, input_format, output_format):
        
        #Return none if input_file or input_format do not exist
        if input_file is None or input_format is None:
            return None
        #Find the needed input class and read the input stream
        try:
            input_cls = self.find_input(input_format)
            input_inst = input_cls()
        except TypeError:
            #Return none if input_cls is a Nonetype
            return None
        #If the input file cannot be found, return None
        try:
            input_inst.read_input(self.absolute_filepath(input_file))
        except IOError:
            return None

        formatter = find_needed_formatter(input_format, output_format)
        if formatter is None:
            raise Exception("Cannot find a formatter that can convert from {0} to {1}".format(self.input_format, output_format))
        formatter_inst = formatter()
        formatter_inst.read_input(input_inst.get_data(), input_format)
        data = formatter_inst.get_data(output_format)
        return data
209914
def file_or_filename(input):
    
    if isinstance(input, string_types):
        # input was a filename: open as file
        yield smart_open(input)
    else:
        # input already a file-like object; just reset to the beginning
        input.seek(0)
        yield input
777070
def input_file(self, filename, lines=None, expected=None, line_offset=0):
        """"""
        if self.options.verbose:
            print('checking %s' % filename)
        fchecker = self.checker_class(
            filename, lines=lines, options=self.options)
        return fchecker.check_all(expected=expected, line_offset=line_offset)