Open a DAF for subsequent write requests.

    http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/dafopw_c.html

    :param fname: Name of DAF to be opened.
    :type fname: str
    :return: Handle assigned to DAF.
    :rtype: int
424277
def dafopw(fname):
    
    fname = stypes.stringToCharP(fname)
    handle = ctypes.c_int()
    libspice.dafopw_c(fname, ctypes.byref(handle))
    return handle.value
795638
def open_external_file(self, fname):
        
        fname = encoding.to_unicode_from_fs(fname)
        if osp.isfile(fname):
            self.open_file(fname, external=True)
        elif osp.isfile(osp.join(CWD, fname)):
            self.open_file(osp.join(CWD, fname), external=True)
989512
def load(cls, fname):
        
        with open(fname) as f:
            return Config(**json.load(f))
379121
def open_by_pat(self, name, mode='r', **kwargs):
        '''
        
        '''
        fname = self.fname_by_pat(name, **kwargs)
        if mode == 'w':
            print >>sys.stderr, "Write[%s]: %s" % (name, fname)
        else:
            print >>sys.stderr, "Open[%s]: %s" % (name, fname)
        return file(fname, mode)
1130615
def save_params_to_file(self, fname: str):
        
        arg_params, aux_params = self.module.get_params()
        self.module.set_params(arg_params, aux_params)
        self.params = arg_params
        self.aux_params = aux_params
        super().save_params_to_file(fname)
831590
def open(self, _file, target=DEFAULT_TARGET):
        
        # Close any existing BFD structure instance. 
        self.close()

        #
        # STEP 1. Open the BFD pointer.
        #
        # Determine if the user passed a file-descriptor or a _file and
        # proceed accordingly.
        if type(_file) is FileType:
            # The user specified a file descriptor.
            filename = _file.name

            if islink(filename):
                raise BfdException("Symlinks file-descriptors are not valid")
                    
            try:
                self._ptr = _bfd.fdopenr(filename, target, dup(_file.fileno()))
            except Exception, err:
                raise BfdException(
                    "Unable to open file-descriptor %s : %s" % (filename, err))

        elif type(_file) is StringType:
            # The user spcified a filaname so first check if file exists.
            filename = _file
            try:
                with open(_file): pass
            except IOError:
                raise BfdException("File %s does not exist." % filename)

            #
            # Proceed to open the specified file and create a new BFD.
            #
            try:
                self._ptr = _bfd.openr(filename, target)
            except (TypeError, IOError), err:
                raise BfdException(
                    "Unable to open file %s : %s" % (filename, err))

        elif type(_file) is IntType:
            # The user specified an already-open BFD pointer so we avoid any
            # further open operation and move on to file format recognition.
            self._ptr = _file

        else:
            raise BfdException(
                "Invalid file type specified for open operation (%r)" % _file)

        #
        # STEP 2. Determine file format of the BFD.
        #
        # Now that the BFD is open we'll proceed to determine its file format.
        # We'll use the objdump logic to determine it and raise an error in
        # case we were unable to get it right.
        #
        try:
            # Type opening it as an archieve and if it success then check
            # subfiles.
            if _bfd.check_format(self._ptr, BfdFormat.ARCHIVE):
                # Set current format and store the inner file list.
                self.file_format = BfdFormat.ARCHIVE

                self.__populate_archive_files()
            else:
                # DO NOT USE bfd_check_format_matches() becuase its not tested.
                # An implementation example if on objdump.c at function
                # display_bfd().
                if _bfd.check_format(self._ptr, BfdFormat.OBJECT):
                    self.file_format = BfdFormat.OBJECT

                elif _bfd.check_format(self._ptr, BfdFormat.CORE):
                    self.file_format = BfdFormat.CORE

                else:
                    pass
                    raise BfdException(_bfd.get_last_error_message())

        except TypeError, err:
            raise BfdException(
                "Unable to initialize file format : %s" % err)

        #
        # STEP 3. Extract inner sections and symbolic information.
        #
        if self._ptr is not None:
            # If the file is a valid BFD file format but not an archive then
            # get its sections and symbolic information (if any).
            if self.file_format in [BfdFormat.OBJECT, BfdFormat.CORE]:
                self.__populate_sections()
                self.__populate_symbols()
526837
def count_open_fds():
    

    pid = os.getpid()
    procs = subprocess.check_output(
        ['lsof', '-w', '-Ff', '-p', str(pid)])

    nprocs = len(
        [s for s in procs.split('\n') if s and s[0] == 'f' and s[1:].isdigit()]
    )
    return nprocs
398224
def load(f, dict_=dict):
    
    if not f.read:
        raise ValueError('The first parameter needs to be a file object, ',
                         '%r is passed' % type(f))
    return loads(f.read(), dict_)
464897
def open_readable(self, name):
        
        # print("FTP open_readable({})".format(name))
        assert compat.is_native(name)
        out = SpooledTemporaryFile(max_size=self.MAX_SPOOL_MEM, mode="w+b")
        self.ftp.retrbinary(
            "RETR {}".format(name), out.write, FtpTarget.DEFAULT_BLOCKSIZE
        )
        out.seek(0)
        return out
985296
def write_tf_examples(filename, tf_examples, serialize=True):
    
    with tf.python_io.TFRecordWriter(
            filename, options=TF_RECORD_CONFIG) as writer:
        for ex in tf_examples:
            if serialize:
                writer.write(ex.SerializeToString())
            else:
                writer.write(ex)
866084
def cl_input(fname, unpack=True, anonpipe=True):
    
    try:
        manager = _get_storage_manager(fname)
    except ValueError:
        return fname

    return manager.cl_input(fname, unpack, anonpipe)
201566
def _open_fbdev(fbdev=None):
        
        dev = fbdev or os.getenv('FRAMEBUFFER', '/dev/fb0')
        fbfid = os.open(dev, os.O_RDWR)
        return fbfid
1246748
def file_pour(filepath, block_size=10240, *args, **kwargs):
    """"""

    def opener(archive_res):
        _LOGGER.debug("Opening from file (file_pour): %s", filepath)
        _archive_read_open_filename(archive_res, filepath, block_size)

    return _pour(opener, *args, flags=0, **kwargs)
538389
def open(filename):
        """"""
        if isinstance(filename, six.string_types):
            try:
                fdesc = gzip.open(filename, "rb")
                magic = fdesc.read(4)
            except IOError:
                fdesc = open(filename, "rb")
                magic = fdesc.read(4)
        else:
            fdesc = filename
            filename = getattr(fdesc, "name", "No name")
            magic = fdesc.read(4)
        return filename, fdesc, magic
463326
def open(self, filename, mode='r', bufsize=-1):
        
        sftp_client = self.open_sftp()
        return sftp_client.open(filename, mode, bufsize)
406916
def create_fa(self):
        

        if self._seqs is None:
            os.symlink(self._fa0_fn, self._fa_fn)
        else:
            in_seqs = pyfaidx.Fasta(self._fa0_fn)

            with open(self._fa_fn, "w+") as g:
                for seq_desc in self._seqs:
                    x = in_seqs[seq_desc]
                    name, seq = x.name, str(x)
                    g.write(">" + name + "\n")
                    n = 80
                    seq_split = "\n".join([seq[i:i + n] for i in range(0, len(seq), n)])
                    g.write(seq_split + "\n")
884477
def process_raw_data(self, fname, max_size):
        
        logging.info(f'Processing data from {fname}')
        data = []
        with open(fname) as dfile:
            for idx, line in enumerate(dfile):
                if max_size and idx == max_size:
                    break
                data.append(line)
        return data