Opens a file for access with the given mode.  This function
    transparently wraps gzip and xz files as well as normal files.
    You can also open zip files using syntax like:

    f = utils.open_file('../semcor-parsed.zip:semcor000.txt')
196381
def open_file(filename, mode='rb'):
    
    if (('r' not in mode or hasattr(filename, 'read')) and
        (('a' not in mode and 'w' not in mode) or hasattr(filename, 'write')) and
        hasattr(filename, '__iter__')):
        return filename
    elif isinstance(filename, string_type):
        if filename == '-' and 'r' in mode:
            if PY3:
                return sys.stdin.buffer
            return sys.stdin
        elif filename == '-' and ('w' in mode or 'a' in mode):
            if PY3:
                return sys.stdout.buffer
            return sys.stdout
        if filename.lower().count('.zip:'):
            assert 'r' in mode
            assert filename.count(':') == 1
            import zipfile
            zipped_file = zipfile.ZipFile(filename.split(':')[0])
            unzipped_file = zipped_file.open(filename.split(':')[1], 'r')
            zipped_file.close()
            return unzipped_file
        elif filename.lower().endswith('.gz'):
            import gzip
            return gzip.open(filename, mode)
        elif filename.lower().endswith('.xz'):
            import lzma
            tmp = lzma.LZMAFile(filename, mode)
            dir(tmp)
            return tmp
        else:
            return open(filename, mode)
    else:
        raise Exception('Unknown type for argument filename')
53980
def _gzip_open_filename(handle):
    """"""
    import gzip
    if sys.version_info[0] > 2:
        handle = gzip.open(handle, mode='rt', encoding="UTF-8")
    else:
        handle = gzip.open(handle)
    return handle
1289879
def smart_open(filename: str, mode: str = 'Ur', buffering: int = -1,
               encoding: str = None, errors: str = None, newline: str = None,
               closefd: bool = True) -> IO:
    
    # https://stackoverflow.com/questions/17602878/how-to-handle-both-with-open-and-sys-stdout-nicely  # noqa
    # https://stackoverflow.com/questions/1744989/read-from-file-or-stdin/29824059#29824059  # noqa
    if filename == '-':
        if mode is None or mode == '' or 'r' in mode:
            fh = sys.stdin
        else:
            fh = sys.stdout
    else:
        fh = open(filename, mode=mode,
                  buffering=buffering, encoding=encoding, errors=errors,
                  newline=newline, closefd=closefd)
    try:
        yield fh
    finally:
        if filename is not '-':
            fh.close()
575818
def OpenFile(self, filepath):
    
    archive = False
    if '.zip/' in filepath:
      archive = True
      archive_type = '.zip'
    if '.par/' in filepath:
      archive = True
      archive_type = '.par'
    if archive:
      path, archived_file = filepath.split(archive_type)
      path += archive_type
      zip_file = zipfile.ZipFile(path)
      return zip_file.open(archived_file.strip('/'))
    return open(filepath)
588848
def open(path, mode, metainfo, useErrorhandler = true)
      file = File.open(path, mode)

      info = IOInfo.new(file, metainfo, true)
      info.useErrorhandler = useErrorhandler
      info.readFiberIoFacade.logger = @logger if @logger
      info.state = :connected
      @ioInfo[info.io] = info
    end
20923
function mustUnzip(file, mode){
  if (mode){
    return mode === 'tgz';
  }
  var extension = path.extname(file);
  return contains(['.tgz', '.gz'], extension);
}
165720
private static RegularFile open(RegularFile file, Set<OpenOption> options) {
    if (options.contains(TRUNCATE_EXISTING) && options.contains(WRITE)) {
      file.writeLock().lock();
      try {
        file.truncate(0);
      } finally {
        file.writeLock().unlock();
      }
    }

    // must be opened while holding a file store lock to ensure no race between opening and
    // deleting the file
    file.opened();

    return file;
  }
986727
def open(self, mode):
        
        if self.hdf5 == ():  # not already open
            kw = dict(mode=mode, libver='latest')
            if mode == 'r':
                kw['swmr'] = True
            try:
                self.hdf5 = hdf5.File(self.filename, **kw)
            except OSError as exc:
                raise OSError('%s in %s' % (exc, self.filename))
795412
def Open(self, file_object):
    
    self._file_object = file_object
    self._regf_file.open_file_object(self._file_object)
    return True
725530
def open(self, mode=MODE_READ):
        
        if mode not in [MODE_READ, MODE_WRITE]:
            error = "Open mode must be '{}' or '{}'".format(
                MODE_READ, MODE_WRITE)
            raise ValueError(error)
        self._openMode = mode
        if mode == MODE_READ:
            self.assertExists()
        if mode == MODE_READ:
            # This is part of the transitional behaviour where
            # we load the whole DB into memory to get access to
            # the data model.
            self.load()
144558
def open(mode = "r")
      # XFS module methods use miqfs instance accessors to touch @boot_sector.
      @mode = mode.downcase
      @de = ifs_getFile(@path, @miqfs)
      raise "File is directory: '#{@path}'" if  @de && @de.directory?

      if mode.include?("r")
        raise "File not found: '#{@path}'" if @de.nil?
        @inode = @miqfs.superblock.get_inode(@de.inode)
      end
    end
958436
def open(self, mode='r', **kwargs):
        """"""
        _fs, filename = opener.parse(self.uri)
        return _fs.open(filename, mode=mode, **kwargs)
631477
def open(self, encoding=None):
        """"""
        try:
            if IS_GZIPPED_FILE.search(self._filename):
                _file = gzip.open(self._filename, 'rb')
            else:
                if encoding:
                    _file = io.open(self._filename, 'r', encoding=encoding, errors='replace')
                elif self._encoding:
                    _file = io.open(self._filename, 'r', encoding=self._encoding, errors='replace')
                else:
                    _file = io.open(self._filename, 'r', errors='replace')
        except IOError, e:
            self._log_warning(str(e))
            _file = None
            self.close()

        return _file
663156
def open_oo_file(options)
      Zip::File.open(@filename) do |zip_file|
        content_entry = zip_file.glob('content.xml').first
        fail ArgumentError, ERROR_MISSING_CONTENT_XML unless content_entry

        roo_content_xml_path = ::File.join(@tmpdir, 'roo_content.xml')
        content_entry.extract(roo_content_xml_path)
        decrypt_if_necessary(zip_file, content_entry, roo_content_xml_path, options)
      end
    end
340378
def open(self):
        
        self.zf = zipfile.ZipFile(self.write_to_path, self.mode)
1082897
def open(self, name, mode='r', compression=None):
        

        if compression == 'use_ext':
            self.get_compression_type(name)
        else:
            self.ctype = compression

        if not self.ctype:
            self.fp = open(name, mode)
        elif self.ctype == 'gzip':
            self.fp = gzip.open(name, mode + 't')
        elif self.ctype == 'bzip2':
            try:
                # Python 3 supports opening bzip2 files in text mode
                # therefore, we prefer to open them this way
                self.fp = bz2.open(name, mode + 't')
            except:
                # BZ2File opens a file in binary mode
                # thus, we have to use codecs.getreader()
                # to be able to use it in text mode
                self.fp_extra = bz2.BZ2File(name, mode)

                if mode == 'r':
                    self.fp = codecs.getreader('ascii')(self.fp_extra)
                else:  # mode == 'w'
                    self.fp = codecs.getwriter('ascii')(self.fp_extra)
        else:  # self.ctype == 'lzma'
            # LZMA is available in Python 2 only if backports.lzma is installed
            # Python 3 supports it by default
            assert lzma_present, 'LZMA compression is unavailable.'
            self.fp = lzma.open(name, mode=mode + 't')
143674
def open_file(file)
      if File.exist?(file)
        if File.readable?(file)
          if not File.directory?(file)
            if File.size(file) > 8
              begin
                @file = Zlib::GzipReader.new(File.new(file, "rb"))
              rescue Zlib::GzipFile::Error
                @file = File.new(file, "rb")
              end
            else
              @msg << "Error! File is too small to contain DICOM information (#{file})."
            end
          else
            @msg << "Error! File is a directory (#{file})."
          end
        else
          @msg << "Error! File exists but I don't have permission to read it (#{file})."
        end
      else
        @msg << "Error! The file you have supplied does not exist (#{file})."
      end
    end