Shorthand for WARCFile(filename, mode).

    Auto detects file and opens it.
546375
def open(filename, mode="rb", format = None):
    
    if format == "auto" or format == None:
        format = detect_format(filename)

    if format == "warc":
        return WARCFile(filename, mode)
    elif format == "arc":
        return ARCFile(filename, mode)
    else:
        raise IOError("Don't know how to open '%s' files"%format)
1089235
def file_mode(self):
        """"""
        fms = self.attributes['file_mode']
        eax = set()
        if isinstance(fms, six.string_types):
            fms = shlex.split(fms)
        for fm in fms:
            if fm == 'both':
                eax.add('fpp')
                eax.add('onefile')
            elif fm in ['fpp', 'onefile']:
                eax.add(fm)
            else:
                raise Exception('Invalid IOR file mode: ' + fm)
        return eax
380908
def askopenfiles(mode="r", **options):
    

    files = askopenfilenames(**options)
    if files:
        ofiles = []
        for filename in files:
            ofiles.append(open(filename, mode))
        files = ofiles
    return files
298532
def open_file(self, fname, external=False):
        
        fname = to_text_string(fname)
        ext = osp.splitext(fname)[1]
        if encoding.is_text_file(fname):
            self.editor.load(fname)
        elif self.variableexplorer is not None and ext in IMPORT_EXT:
            self.variableexplorer.import_data(fname)
        elif not external:
            fname = file_uri(fname)
            programs.start_file(fname)
1009494
def opened(filename, mode):
    ""
    if isinstance(filename, str):
        file = open(filename, mode)
        try: 
            yield file
        finally: 
            if not file.closed:
                file.close()
    else:
        yield filename
924903
def _open(filename, mode='r', buffering=0):
    """"""
    if mode not in ('r', 'rb', 'rU'):
        raise RuntimeError("Invalid open file mode, must be 'r', 'rb', or 'rU'")
    if buffering > MAX_OPEN_BUFFER:
        raise RuntimeError("Invalid buffering value, max buffer size is {}".format(MAX_OPEN_BUFFER))
    return open(filename, mode, buffering)
1162244
def _open_for_csv(name, mode):
    
    if sys.version_info[0] < 3:
        return open_rw(name, mode + 'b')
    return open_rw(name, mode, newline='', encoding='utf-8')
695639
def file(self, name, *args, **kwargs):
        
        return open(self(name), *args, **kwargs)
485395
def defaultFile(self):
        """"""
        filename = self.curframe.f_code.co_filename
        if filename == '<string>' and self.mainpyfile:
            filename = self.mainpyfile
        return filename
645188
def open(self, file, mode='r', buffering=-1, encoding=None,
             errors=None, newline=None, closefd=True, opener=None):
        
        if opener is not None and sys.version_info < (3, 3):
            raise TypeError(
                "open() got an unexpected keyword argument 'opener'")
        fake_open = FakeFileOpen(self.filesystem, use_io=True)
        return fake_open(file, mode, buffering, encoding, errors,
                         newline, closefd, opener)
872834
def _open(self, mode=None):
        
        if mode is None:
            mode = self.mode
        if self.encoding is None:
            stream = open(self.baseFilename, mode)
        else:
            stream = codecs.open(self.baseFilename, mode, self.encoding)
        return stream
1096995
def taropen(cls, name, mode="r", fileobj=None, **kwargs):
        
        if len(mode) > 1 or mode not in "raw":
            raise ValueError("mode must be 'r', 'a' or 'w'")
        return cls(name, mode, fileobj, **kwargs)
1236520
def open(self, fname, mode='rb'):
        
        self.close()
        self.fp = open(fname, mode)
        self.fname = fname
578485
protected void openFileChooser()
   {
      if (m_model.getShowDialog())
      {
         if (m_fileChooser.showSaveDialog(m_parent) == JFileChooser.APPROVE_OPTION)
         {
            FileNameExtensionFilter filter = (FileNameExtensionFilter) m_fileChooser.getFileFilter();
            String description = filter.getDescription();
            m_model.setType(description.substring(0, description.indexOf(' ')));
            m_model.setFile(null);
            m_model.setFile(m_fileChooser.getSelectedFile());
         }
         m_model.setShowDialog(false);
      }
   }
30990
function openFileClicked() {
  var inputElement = document.createElement('input');
  inputElement['type'] = 'file';
  inputElement['multiple'] = true;
  inputElement['accept'] = [
    '.wtf-trace,application/x-extension-wtf-trace',
    '.wtf-json,application/x-extension-wtf-json',
    '.wtf-calls,application/x-extension-wtf-calls',
    '.cpuprofile,application/x-extension-cpuprofile',
    '.part,application/x-extension-part'
  ].join(',');
  inputElement.onchange = function(e) {
    _gaq.push(['_trackEvent', 'popup', 'open_file']);

    var fileEntries = [];
    for (var n = 0; n < inputElement.files.length; n++) {
      var file = inputElement.files[n];
      var blob = new Blob([file], {
        type: 'application/octet-stream'
      });
      var blobUrl = URL.createObjectURL(blob);
      fileEntries.push({
        name: file.name,
        url: blobUrl,
        size: blob.size
      });
    }

    port.postMessage({
      command: 'show_files',
      files: fileEntries
    });
    window.close();
  };
  inputElement.click();
}
197680
def handle_fobj(backend, f, **kwargs):
    
    if not is_binary(f):
        raise AssertionError('File must be opened in binary mode.')

    if callable(getattr(backend, 'handle_fobj', None)):
        # Prefer handle_fobj() if present.
        LOGGER.debug("using handle_fobj")
        return backend.handle_fobj(f)

    elif callable(getattr(backend, 'handle_path', None)):
        # Fallback to handle_path(). Warn user since this is potentially
        # expensive.
        LOGGER.debug("using handle_path")
        LOGGER.warning(
            "Using disk, %r backend does not provide `handle_fobj()`", backend)

        ext = ''
        if 'ext' in kwargs:
            ext = '.' + kwargs['ext']

        with fobj_to_tempfile(f, suffix=ext) as fname:
            return backend.handle_path(fname, **kwargs)
    else:
        raise AssertionError(
            'Backend %s has no _get functions' % backend.__name__)
276692
def open_filechooser(title, parent=None, patterns=None,
                     folder=None, filter=None, multiple=False,
                     _before_run=None, action=None):
    

    assert not (patterns and filter)
    if multiple:
        if action is not None and action != gtk.FILE_CHOOSER_ACTION_OPEN:
            raise ValueError('`multiple` is only valid for the action '
                             '`gtk.FILE_CHOOSER_ACTION_OPEN`.')
        action = gtk.FILE_CHOOSER_ACTION_OPEN
    else:
        assert action is not None
    filechooser = gtk.FileChooserDialog(title,
                                        parent,
                                        action,
                                        (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                         gtk.STOCK_OPEN, gtk.RESPONSE_OK))
    if multiple:
        filechooser.set_select_multiple(True)

    if patterns or filter:
        if not filter:
            filter = gtk.FileFilter()
            for pattern in patterns:
                filter.add_pattern(pattern)
        filechooser.set_filter(filter)
    filechooser.set_default_response(gtk.RESPONSE_OK)

    if folder:
        filechooser.set_current_folder(folder)

    try:
        if _before_run is not None:
            _before_run(filechooser)
        response = filechooser.run()
        if response not in (gtk.RESPONSE_OK, gtk.RESPONSE_NONE):
            return

        if multiple:
            return filechooser.get_filenames()
        else:
            return filechooser.get_filename()
    finally:
        _destroy(filechooser)