Read the header via the pipe.

 Returns a header.
763959
def get_header
      begin
        size = @out.read(33)
        size = size[0..-2]

        # Sanity check the size
        if not size_check(size)
          @log.error "Size returned from mentos.py invalid."
          stop "Size returned from mentos.py invalid."
          raise MentosError, "Size returned from mentos.py invalid."
        end

        # Read the amount of bytes we should be expecting. We first
        # convert the string of bits into an integer.
        header_bytes = size.to_s.to_i(2) + 1
        @log.info "Size in: #{size.to_s} (#{header_bytes.to_s})"
        @out.read(header_bytes)
      rescue
        @log.error "Failed to get header."
        stop "Failed to get header."
        raise MentosError, "Failed to get header."
      end
    end
1372807
def header(self):
        
        
        cmd = [self.__samtools, 'view', '-H', self.__bam]

        stdout = subprocess.Popen(cmd, stdout=subprocess.PIPE).stdout

        for l in stdout:
            yield l.decode('utf-8').strip()

        stdout.close()
1271705
def getheader(self, header, default=None):
        '''
        
        '''
        if isinstance(header, str):
            return self.headers.get(header.lower(), default)
        return self.__rawheaders.get(header, default)
587417
def next (self):
        
        header, packet = self.read()

        if packet is None:
            raise StopIteration

        return header, packet
1246511
def read_header(input)
      raise 'Not a Daybreak database' if input.read(MAGIC.bytesize) != MAGIC
      ver = input.read(2).unpack('n').first
      raise "Expected database version #{VERSION}, got #{ver}" if ver != VERSION
    end
895717
Header readHeader(@NonNull InputStream input) throws IOException {
        byte version = (byte) input.read();
        int keyLength = BitConverter.readInt(input);
        int valueLength = BitConverter.readInt(input);
        long entryVersion = BitConverter.readLong(input);
        validateHeader(keyLength, valueLength);
        return new Header(version, keyLength, valueLength, entryVersion);
    }
594852
def read_http_header(sock):
    """"""
    buf = []
    hdr_end = '\r\n\r\n'

    while True:
        buf.append(sock.recv(bufsize).decode('utf-8'))
        data = ''.join(buf)
        i = data.find(hdr_end)
        if i == -1:
            continue
        return data[:i], data[i + len(hdr_end):]
1261492
def extract_header(self):
        """"""
        self.log.info("Extracting the header")
        raw_header = self.raw_header = defaultdict(list)
        first_line = self.blob_file.readline()
        first_line = try_decode_string(first_line)
        self.blob_file.seek(0, 0)
        if not first_line.startswith(str('start_run')):
            self.log.warning("No header found.")
            return raw_header
        for line in iter(self.blob_file.readline, ''):
            line = try_decode_string(line)
            line = line.strip()
            try:
                tag, value = str(line).split(':')
            except ValueError:
                continue
            raw_header[tag].append(str(value).split())
            if line.startswith(str('end_event:')):
                self._record_offset()
                if self._auto_parse and 'physics' in raw_header:
                    parsers = [p[0].lower() for p in raw_header['physics']]
                    self._register_parsers(parsers)
                return raw_header
        raise ValueError("Incomplete header, no 'end_event' tag found!")
634586
def _read_header(fid):
    
    fid.seek(0, SEEK_SET)
    fFileSignature = fid.read(4)
    assert fFileSignature == b'ABF2', 'only format ABF2 is currently supported'

    header = {}
    for key, offset, fmt in headerDescriptionV2:
        fid.seek(0 + offset, SEEK_SET)
        val = unpack(fmt, fid.read(calcsize(fmt)))
        if len(val) == 1:
            header[key] = val[0]
        else:
            header[key] = val

    # sections
    sections = {}
    for s, sectionName in enumerate(sectionNames):
        fid.seek(76 + s * 16)
        uBlockIndex, uBytes, llNumEntries = unpack('IIl', fid.read(calcsize('IIl')))
        sections[sectionName] = {}
        sections[sectionName]['uBlockIndex'] = uBlockIndex
        sections[sectionName]['uBytes'] = uBytes
        sections[sectionName]['llNumEntries'] = llNumEntries
    header['sections'] = sections

    # strings sections
    # hack for reading channels names and units
    fid.seek(sections['StringsSection']['uBlockIndex'] * BLOCKSIZE)
    big_string = fid.read(sections['StringsSection']['uBytes'])
    goodstart = -1
    for key in [b'AXENGN', b'clampex', b'Clampex', b'CLAMPEX', b'axoscope', b'Clampfit']:
        goodstart = big_string.find(key)
        if goodstart != -1:
            break
    assert goodstart != -1, 'This file does not contain clampex, axoscope or clampfit in the header'
    big_string = big_string[goodstart:]
    strings = big_string.split(b'\x00')

    # ADC sections
    header['listADCInfo'] = []
    for i in range(sections['ADCSection']['llNumEntries']):
        # read ADCInfo
        fid.seek(sections['ADCSection']['uBlockIndex'] *
                 BLOCKSIZE + sections['ADCSection']['uBytes'] * i)
        ADCInfo = _read_info_as_dict(fid, ADCInfoDescription)
        ADCInfo['ADCChNames'] = strings[ADCInfo['lADCChannelNameIndex'] - 1]
        ADCInfo['ADCChUnits'] = strings[ADCInfo['lADCUnitsIndex'] - 1]
        header['listADCInfo'].append(ADCInfo)

    # protocol sections
    fid.seek(sections['ProtocolSection']['uBlockIndex'] * BLOCKSIZE)
    header['protocol'] = _read_info_as_dict(fid, protocolInfoDescription)
    header['sProtocolPath'] = strings[header['uProtocolPathIndex'] - 1]

    # DAC sections
    header['listDACInfo'] = []
    for i in range(sections['DACSection']['llNumEntries']):
        # read DACInfo
        fid.seek(sections['DACSection']['uBlockIndex'] *
                 BLOCKSIZE + sections['DACSection']['uBytes'] * i)
        DACInfo = _read_info_as_dict(fid, DACInfoDescription)
        DACInfo['DACChNames'] = strings[DACInfo['lDACChannelNameIndex'] - 1]
        DACInfo['DACChUnits'] = strings[
            DACInfo['lDACChannelUnitsIndex'] - 1]

        header['listDACInfo'].append(DACInfo)

    """ Not present in test file. No tests, no code.
    # tags
    listTag = []
    for i in range(sections['TagSection']['llNumEntries']):
        fid.seek(sections['TagSection']['uBlockIndex'] *
                 BLOCKSIZE + sections['TagSection']['uBytes'] * i)
        tag = _read_info_as_dict(fid, TagInfoDescription)
        listTag.append(tag)

    header['listTag'] = listTag

    # EpochPerDAC  sections
    # header['dictEpochInfoPerDAC'] is dict of dicts:
    #  - the first index is the DAC number
    #  - the second index is the epoch number
    # It has to be done like that because data may not exist
    # and may not be in sorted order
    header['dictEpochInfoPerDAC'] = {}
    for i in range(sections['EpochPerDACSection']['llNumEntries']):
        #  read DACInfo
        fid.seek(sections['EpochPerDACSection']['uBlockIndex'] *
                 BLOCKSIZE +
                 sections['EpochPerDACSection']['uBytes'] * i)
        EpochInfoPerDAC = _read_info_as_dict(fid, EpochInfoPerDACDescription)
        DACNum = EpochInfoPerDAC['nDACNum']
        EpochNum = EpochInfoPerDAC['nEpochNum']
        # Checking if the key exists, if not, the value is empty
        # so we have to create empty dict to populate
        if DACNum not in header['dictEpochInfoPerDAC']:
            header['dictEpochInfoPerDAC'][DACNum] = {}

        header['dictEpochInfoPerDAC'][DACNum][EpochNum] =\
            EpochInfoPerDAC
    """

    return header
109418
def get_header(self, header_name, default=None):
        
        return self.headers.get(
            header_name, self.unredirected_headers.get(header_name, default))
2745
def read_pipe(pipe_out):
    
    out = b''
    while more_data(pipe_out):
        out += os.read(pipe_out, 1024)

    return out.decode('utf-8')
1226333
protected void readStreamHeader() throws IOException,
            StreamCorruptedException {
        if (input.readShort() == STREAM_MAGIC
                && input.readShort() == STREAM_VERSION) {
            return;
        }
        throw new StreamCorruptedException();
    }
312040
def _read_file_header(self):
        """"""
        header = self.fileobj.readline()
        payload1 = self.fileobj.readline()
        payload2 = self.fileobj.readline()
        version, reserved, organisation = payload1.split(None, 2)
        self.fileobj.readline() # Lose the separator newline
        self.header_read = True
        # print "--------------------------------------------------"
        # print header,"\n", payload1, "\n", payload2,"\n"
        # print "--------------------------------------------------"
        if self.version and int(self.version) != version:
            raise IOError("Version mismatch. Requested version was '%s' but version in file was '%s'"%(self.version, version))
        
        if version == '1':
            url, ip_address, date, content_type, length = header.split()
            self.file_headers = {"ip_address" : ip_address,
                                 "date" : datetime.datetime.strptime(date, "%Y%m%d%H%M%S"),
                                 "org" : organisation}
            self.version = 1
        elif version == '2':
            url, ip_address, date, content_type, result_code, checksum, location, offset, filename, length  = header.split()
            self.file_headers = {"ip_address" : ip_address,
                                 "date" : datetime.datetime.strptime(date, "%Y%m%d%H%M%S"),
                                 "org" : organisation}
            self.version = 2
        else:
            raise IOError("Unknown ARC version '%s'"%version)
298530
def transfer_header(self, fw=sys.stdout):
        
        print("\n".join(self.header), file=fw)
885558
public String readHeader() throws IOException {
		byte[] buffer = new byte[BUFFER_SIZE];
		StringBuilder content = new StringBuilder(BUFFER_SIZE);
		while (content.indexOf(HEADER_END) == -1) {
			int amountRead = checkedRead(buffer, 0, BUFFER_SIZE);
			content.append(new String(buffer, 0, amountRead));
		}
		return content.substring(0, content.indexOf(HEADER_END));
	}
503960
def header(self) -> str:
        
        return "/".join((self.pipeline, self.phase, self.data))
157487
def _parse_header(stream):
        '''
        

        '''
        parser = _PlyHeaderParser()
        while parser.consume(stream.readline()):
            pass

        return PlyData(
            [PlyElement(*e) for e in parser.elements],
            parser.format == 'ascii',
            _byte_order_map[parser.format],
            parser.comments,
            parser.obj_info
        )