Returns a fileobject for the specified section.

        This method optionally decompresses the data found in the .idb file,
        and returns a file-like object, with seek, read, tell.
482652
def getpart(self, ix):
        
        if self.offsets[ix] == 0:
            return

        comp, ofs, size, checksum = self.getsectioninfo(ix)

        fh = FileSection(self.fh, ofs, ofs + size)
        if comp == 2:
            import zlib
            # very old databases used a different compression scheme:
            wbits = -15 if self.magic == 'IDA0' else 15

            fh = makeStringIO(zlib.decompress(fh.read(size), wbits))
        elif comp == 0:
            pass
        else:
            raise Exception("unsupported section encoding: %02x" % comp)
        return fh
1235762
def load_segment(self, f, is_irom_segment=False):
        
        file_offs = f.tell()
        (offset, size) = struct.unpack('<II', f.read(8))
        self.warn_if_unusual_segment(offset, size, is_irom_segment)
        segment_data = f.read(size)
        if len(segment_data) < size:
            raise FatalError('End of file reading segment 0x%x, length %d (actual length %d)' % (offset, size, len(segment_data)))
        segment = ImageSegment(offset, segment_data, file_offs)
        self.segments.append(segment)
        return segment
119070
static function fetch( $sectionID, $asObject = true )
    {
        global $eZContentSectionObjectCache;

        // If the object given by its id is not cached or should be returned as array
        // then we fetch it from the DB (objects are always cached as arrays).
        if ( !isset( $eZContentSectionObjectCache[$sectionID] ) or $asObject === false )
        {
            $section = eZPersistentObject::fetchObject( eZSection::definition(),
                                                null,
                                                array( "id" => $sectionID ),
                                                $asObject );
            if ( $asObject )
            {
                $eZContentSectionObjectCache[$sectionID] = $section;
            }
        }
        else
        {
            $section = $eZContentSectionObjectCache[$sectionID];
        }
        return $section;
    }
1059890
def fileish_open(fileish, mode):
    
    if mode is not None and any(m in mode for m in ['+', 'w', 'a', 'x']):
        attr = 'write'
    else:
        attr = 'read'
    if hasattr(fileish, attr) and hasattr(fileish, 'seek'):
        # BytesIO-like object
        return fileish
    elif isinstance(fileish, str):
        # Python2 - file path, file contents in the case of a TypeError
        # Python3 - file path
        try:
            return open(fileish, mode)
        except TypeError:
            return io.BytesIO(fileish)
    else:
        # Python 3 - file contents
        return io.BytesIO(fileish)
1006670
public static Object readObjectFromFile(File f) {
        Object obj = null;
        try {
            FileInputStream fin = new FileInputStream(f);
            ObjectInputStream ois = new ObjectInputStream(fin);
            obj = ois.readObject();
            ois.close();
        } catch (Exception e) {
            System.out.println("Error reading Object from file: "
                    + e.getMessage());
            return null;
        }
        return obj;
    }
1064280
def _read_sections(ifile):
        """"""
        if os.path.exists(ifile):
            return read_sections(ifile, exclude_ungrouped=True, prt=None)
808540
public static INDArray readFromDisk(File readFrom) throws IOException {
        try (FileInputStream os = new FileInputStream(readFrom)) {
            FileChannel channel = os.getChannel();
            ByteBuffer buffer = ByteBuffer.allocateDirect((int) readFrom.length());
            channel.read(buffer);
            INDArray ret = toArray(buffer);
            return ret;
        }
    }
519521
function (id) {
                var res = this.idMap ? this.idMap[id] : null;
                if (res && res._type == TYPE_SECTION) {
                    return res;
                }
                return null;
            }
1000946
public JavaFileObject getJavaFileForOutput(Location location, String className, Kind kind, FileObject sibling)
    throws IOException {
        if (logger.isMdwDebugEnabled())
            logger.mdwDebug("Loading Dynamic Java byte code from: " + (sibling == null ? null : sibling.toUri()));
        try {
            JavaFileObject jfo = new ByteArrayJavaFileObject(className, kind);
            jfoCache.putIfAbsent(className, jfo);
            return jfo;
        }
        catch (Exception ex) {
            logger.severeException(ex.getMessage(), ex);
            throw new IOException(ex.getMessage(), ex);
        }
    }
231839
def __get_chunk(self, start=0, end=None):
        '''
        
        '''
        piece = False

        if (self.__filename and os.access(self.__filename, os.R_OK)):

            fhandle = None

            try:
                fhandle = os.open(self.__filename, os.O_RDONLY)
            except OSError:
                print(("Couldn't open file %s" % (self.__filename)))
                fhandle = None

            if (fhandle):

                try:
                    sarmap = mmap.mmap(fhandle, length=0, prot=mmap.PROT_READ)
                except (TypeError, IndexError):
                    os.close(fhandle)
                    traceback.print_exc()
                    #sys.exit(-1)
                    return False

                if (not end):
                    end = sarmap.size()

                try:
                    sarmap.seek(start)
                    piece = sarmap.read(end - start)
                except:
                    traceback.print_exc()

            os.close(fhandle)

        return(piece)
911826
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
        // Get default form
        in.defaultReadObject();

        // Create new Archive
        final String name = this.name;
        final ZipImporter archive = ShrinkWrap.create(ZipImporter.class, name);

        // Read in
        archive.importFrom(in);

        // Set
        this.archive = archive.as(JavaArchive.class);

        // Log
        if (log.isLoggable(Level.FINER)) {
            log.finer("Read in archive: " + archive.toString());
        }

        /*
         * Leave this bit here.
         *
         * After reading in the ZIP stream contents, we need to also get to the EOF marker (which is not read in by the
         * ZIP import process because it's the ZIP header, not part of the true contents. Putting this loop here ensures
         * we reach the marker, which is *not* the true end of the stream. Object data may be read again after here via
         * something like:
         *
         * in.readObject();
         *
         * Without this loop we'll get an OptionalDataException when trying to read more objects in from the stream. In
         * the future we may add state which needs to be part of the serialization protocol, and things need to stay in
         * order, so they'll be added *after* the archive ZIP contents. Thus we must be able to read them.
         */
        while (in.read() != -1) {
        }

        // We've now added an ID to archives, so add this into the wire protocol
        try {
            final String id = (String) in.readObject();
            this.archive.as(Identifiable.class).setId(id);
        } catch (final OptionalDataException ode) {
            /*
             * Swallow; this occurs when an older wire format (without notion of ID) attempts to send an archive to a
             * new format. The new archive will have the ID assigned to it at creation time, and we'll ignore that we
             * can't read in the remote one from this stream (as the remote one from the old version does not have an ID
             * to send
             */
            if (log.isLoggable(Level.FINER)) {
                log.finer("Detected an older version of the archive sent over the wire; no ID was sent.  "
                    + "Ignoring and using the default ID for this archive: " + archive.toString());
            }
        }

    }
570550
def section(self):
        
        if self.api and self.section_id:
            return self.api._get_section(self.section_id)
1177062
def from_file(cls, file_path, compressed=False, encoded=False):
        """"""
        file_id = '.'.join(path.basename(file_path).split('.')[:-1])
        file_format = file_path.split('.')[-1]
        content = cls(file_id, file_format, compressed, encoded)
        content.file_exists = True
        content._location = path.dirname(file_path)
        return content
307857
public static Object getObjectFromBytes(byte[] objBytes) throws Exception {
		if (objBytes == null || objBytes.length == 0) {
			return null;
		}
		ByteArrayInputStream bi = new ByteArrayInputStream(objBytes);
		ObjectInputStream oi = new ObjectInputStream(bi);
		return oi.readObject();
	}
1091087
def from_file(filename, section='matrix'):
    
    config = parse_config(open(filename), section=section)
    return from_config(config)
184663
function fetchSectionObject( $sectionID = false, $sectionIdentifier = false )
    {
        if( $sectionID !== false )
        {
            if( $sectionIdentifier !== false )
            {
                $sectionObject = null;
            }
            else
            {
                $sectionObject = eZSection::fetch( $sectionID );
            }
        }
        else
        {
            if( $sectionIdentifier === false )
            {
                $sectionObject = null;
            }
            else
            {
                $sectionObject = eZSection::fetchByIdentifier( $sectionIdentifier );
            }
        }
        if ( $sectionObject === null )
            return array( 'error' => array( 'error_type' => 'kernel',
                                            'error_code' => eZError::KERNEL_NOT_FOUND ) );
        return array( 'result' => $sectionObject );
    }
1227819
def _extract_section(sect_req, elffile, mem=None):
        
        for nseg, section in enumerate(elffile.iter_sections()):
            request = sect_req.get(section.name, None)
            if request:
                request.set_found(True)
                request.set_sect_properties(section.header.sh_addr,
                                            section.header.sh_size)
                if mem:
                    mem.add_vma(section.header.sh_addr, section.data())
                else:
                    request.memory.add_vma(section.header.sh_addr, section.data())