Open a file.

	:arg file: file-like or path-like object.
	:arg str mode: ``mode`` argument for :func:`open`.
6112
def open_file(file, mode):
	
	if hasattr(file, "read"):
		return file
	if hasattr(file, "open"):
		return file.open(mode)
	return open(file, mode)
537281
def open(self, name, *mode):
        
        return self.file_factory(self.file_path(name), *mode)
14540
def open(self, path, filename=None):
        
        scheme, key = self.getkey(path, filename=filename)
        return BotoReadFileHandle(scheme, key)
606707
def _open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None,
          closefd=True, opener=None, *, loop=None, executor=None):
    """"""
    if loop is None:
        loop = asyncio.get_event_loop()
    cb = partial(sync_open, file, mode=mode, buffering=buffering,
                 encoding=encoding, errors=errors, newline=newline,
                 closefd=closefd, opener=opener)
    f = yield from loop.run_in_executor(executor, cb)

    return wrap(f, loop=loop, executor=executor)
796248
def do_open(self, mode=None):
        
        if mode is None:
            mode = self.mode

        with self._alter_umask():
            # noinspection PyArgumentList
            stream = io.open(
                self.baseFilename, mode=mode, encoding=self.encoding, newline=self.newline)

        self._do_chown_and_chmod(self.baseFilename)

        return stream
501661
def _read_file(self, file):  # type: (str) -> Optional[str]
        
        if not self.setup_file_name:
            return None
        source = None
        if os.path.isfile(file):
            with self.file_opener.open_this(file, "r") as setup_py:
                source = setup_py.read()
        return source
534650
def open_tar(path_or_file, *args, **kwargs):
  
  (path, fileobj) = ((path_or_file, None) if isinstance(path_or_file, string_types)
                     else (None, path_or_file))  # TODO(#6071): stop using six.string_types
                                                 # This should only accept python3 `str`, not byte strings.
  with closing(TarFile.open(path, *args, fileobj=fileobj, **kwargs)) as tar:
    yield tar
486820
def _process_file(self, path):
        
        try:
            f = open(path)
            for line in f:
                self._process_line(line)

            os.remove(path)
        except IOError as ex:
            self.log.error("Could not open file `{path}': {error}".format(
                path=path, error=ex.strerror))
229104
def open_instance_resource(self, path: FilePath, mode: str='rb') -> IO[AnyStr]:
        
        return open(self.instance_path / file_path_to_path(path), mode)
1259212
def open_file(self, fname, length=None, offset=None, swap=None, block=None, peek=None):
        '''
        
        '''
        if length is None:
            length = self.length
        if offset is None:
            offset = self.offset
        if swap is None:
            swap = self.swap_size

        return binwalk.core.common.BlockFile(fname,
                                             subclass=self.subclass,
                                             length=length,
                                             offset=offset,
                                             swap=swap,
                                             block=block,
                                             peek=peek)
937673
def open_file(path, grib_errors='warn', **kwargs):
    """"""
    if 'mode' in kwargs:
        warnings.warn("the `mode` keyword argument is ignored and deprecated", FutureWarning)
        kwargs.pop('mode')
    stream = messages.FileStream(path, message_class=cfmessage.CfMessage, errors=grib_errors)
    return Dataset(*build_dataset_components(stream, **kwargs))
634236
def safe_open(filename, *args, **kwargs):
  
  safe_mkdir_for(filename)
  return open(filename, *args, **kwargs)
567865
def open_logfile(filename, mode='a'):
    
    filename = os.path.expanduser(filename)
    filename = os.path.abspath(filename)
    dirname = os.path.dirname(filename)
    if not os.path.exists(dirname):
        os.makedirs(dirname)
    exists = os.path.exists(filename)

    log_fp = open(filename, mode)
    if exists:
        log_fp.write('%s\n' % ('-'*60))
        log_fp.write('%s run on %s\n' % (sys.argv[0], time.strftime('%c')))
    return log_fp
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)
66335
def mkopen(p, *args, **kwargs):
    
    dir = os.path.dirname(p)
    mkdir(dir)
    return open(p, *args, **kwargs)
1171328
def _OpenFile(self, path):
    
    if not self._registry_file_reader:
      return None

    return self._registry_file_reader.Open(
        path, ascii_codepage=self._ascii_codepage)
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