Parse the TLM segment.

        Parameters
        ----------
        fptr : file
            Open file object.

        Returns
        -------
        TLMSegment
            The current TLM segment.
492744
def _parse_tlm_segment(self, fptr):
        
        offset = fptr.tell() - 2

        read_buffer = fptr.read(2)
        length, = struct.unpack('>H', read_buffer)

        read_buffer = fptr.read(length - 2)
        ztlm, stlm = struct.unpack_from('>BB', read_buffer)
        ttlm_st = (stlm >> 4) & 0x3
        ptlm_sp = (stlm >> 6) & 0x1

        nbytes = length - 4
        if ttlm_st == 0:
            ntiles = nbytes / ((ptlm_sp + 1) * 2)
        else:
            ntiles = nbytes / (ttlm_st + (ptlm_sp + 1) * 2)

        if ttlm_st == 0:
            ttlm = None
            fmt = ''
        elif ttlm_st == 1:
            fmt = 'B'
        elif ttlm_st == 2:
            fmt = 'H'

        if ptlm_sp == 0:
            fmt += 'H'
        else:
            fmt += 'I'

        data = struct.unpack_from('>' + fmt * int(ntiles), read_buffer,
                                  offset=2)
        if ttlm_st == 0:
            ttlm = None
            ptlm = data
        else:
            ttlm = data[0::2]
            ptlm = data[1::2]

        return TLMsegment(ztlm, ttlm, ptlm, length, offset)
79387
def from_fptr(cls, label, type_, fptr):
        """"""
        return FSEntry(
            label=label,
            type=type_,
            path=fptr.path,
            use=fptr.use,
            file_uuid=fptr.file_uuid,
            derived_from=fptr.derived_from,
            checksum=fptr.checksum,
            checksumtype=fptr.checksumtype,
        )
838327
def read_segment(self, segment):
        
        log.debug("read segment {0}".format(segment))
        if segment < 0 or segment > 15:
            raise ValueError("invalid segment number")
        cmd = "\x10" + chr(segment << 4) + 8 * chr(0) + self.uid
        rsp = self.transceive(cmd)
        if len(rsp) < 129:
            raise Type1TagCommandError(RESPONSE_ERROR)
        return rsp[1:129]
1107664
def returnData(self, dsptr):
        
        dataPtr = dsptr & 0x00FFFFFFL
        dataLen = (dsptr >> 24) & 0xFF

        self.__f.seek(dataPtr)

        data = self.__f.read(dataLen)
        result = data[4:].split('|')
        location = Location(self.getLong(data, 0), result[0], result[1], result[2], result[3], result[4])

        return location
259381
def _parse(self):
        
        with open(self.path, "rt") as reader:
            return ast.parse(reader.read(), filename=self.path)
139302
def ParseFileObject(self, parser_mediator, file_object):
    
    display_name = parser_mediator.GetDisplayName()
    self.ParseFileLNKFile(parser_mediator, file_object, display_name)
401078
def _parse_crg_segment(self, fptr):
        
        offset = fptr.tell() - 2

        read_buffer = fptr.read(2)
        length, = struct.unpack('>H', read_buffer)

        read_buffer = fptr.read(4 * self._csiz)
        data = struct.unpack('>' + 'HH' * self._csiz, read_buffer)
        xcrg = data[0::2]
        ycrg = data[1::2]

        return CRGsegment(xcrg, ycrg, length, offset)
616871
def parse(self, fp, headersonly=True):
        """"""
        feedparser = FeedParser(self._class)
        feedparser._set_headersonly()

        try:
            mp = mmap.mmap(fp.fileno(), 0, access=mmap.ACCESS_READ)
        except:
            mp = fp

        data = ""

        # While parsing the header we can convert to us-ascii?
        while True:
            line = mp.readline()
            data = data + line.decode("us-ascii")
            if line == b"\n":
                break
        feedparser.feed(data) # mp[0:5000])
        return feedparser.close()
386166
def parse(self, data):
        

        data = data.decode('utf-8')
        self.linesep = detect_linesep(data)

        # the first section is the main one for the manifest. It's
        # also where we will check for our newline separator
        sections = parse_sections(data)
        self.load(next(sections))

        # and all following sections are considered sub-sections
        for section in sections:
            next_section = ManifestSection(None)
            next_section.load(section)
            self.sub_sections[next_section.primary()] = next_section
435339
def segment(self, webvtt, output='', seconds=SECONDS, mpegts=MPEGTS):
        """"""
        if isinstance(webvtt, str):
            # if a string is supplied we parse the file
            captions = WebVTT().read(webvtt).captions
        elif not self._validate_webvtt(webvtt):
            raise InvalidCaptionsError('The captions provided are invalid')
        else:
            # we expect to have a webvtt object
            captions = webvtt.captions

        self._total_segments = 0 if not captions else int(ceil(captions[-1].end_in_seconds / seconds))
        self._output_folder = output
        self._seconds = seconds
        self._mpegts = mpegts

        output_folder = os.path.join(os.getcwd(), output)
        if not os.path.exists(output_folder):
            os.makedirs(output_folder)

        self._slice_segments(captions)
        self._write_segments()
        self._write_manifest()
536934
def _parse_reserved_segment(self, fptr):
        
        offset = fptr.tell() - 2

        read_buffer = fptr.read(2)
        length, = struct.unpack('>H', read_buffer)
        if length > 0:
            data = fptr.read(length - 2)
        else:
            data = None

        segment = Segment(marker_id='0x{0:x}'.format(self._marker_id),
                          offset=offset, length=length, data=data)
        return segment
1000940
def parse_c_serialized(f):
    
    # TODO: rewrite to use re library
    f.seek(0)
    try:
        p_rec_type = None
        while True:
            rec_off = f.tell()
            while True:
                if f.read(2) == b'\xff\xff':
                    h = struct.unpack('<HH', f.read(4))
                    if h[1] < 64 and h[1] != 0:
                        rec_type = f.read(h[1])
                        if rec_type[0] == 67:  # starts with 'C'
                            break
                if f.read(1) == b'':
                    raise EOFError
                f.seek(f.tell() - 2)
            if p_rec_type is not None:
                rec_len = f.tell() - 6 - len(rec_type) - rec_off
                f.seek(rec_off)
                yield p_rec_type, f.read(rec_len)
                f.seek(f.tell() + 6 + len(rec_type))
            # p_type = h[0]
            p_rec_type = rec_type
    except EOFError:
        rec_len = f.tell() - 6 - len(rec_type) - rec_off
        f.seek(rec_off)
        yield p_rec_type, f.read(rec_len)
497224
def _parse_ppm_segment(self, fptr):
        
        offset = fptr.tell() - 2

        read_buffer = fptr.read(3)
        length, zppm = struct.unpack('>HB', read_buffer)

        numbytes = length - 3
        read_buffer = fptr.read(numbytes)

        return PPMsegment(zppm, read_buffer, length, offset)
1312139
def parse(self, f):
        '''
        '''
        self._listener.parse_start()

        while len(f):
            data = f.read(self._buffer_size).encode('utf-8')
            status = yajl.yajl_parse(self._handler, data, len(data))
            self._listener.parse_buf()
            if status != OK.value:
                if status == CLIENT_CANCELLED.value:
                    if self._exc_info:
                        exc_info = self._exc_info
                        raise exc_info[0](exc_info[1]).with_traceback(exc_info[2])
                    else:
                        raise YajlError("Client probably cancelled callback")
                else:
                    yajl.yajl_get_error.restype = c_char_p
                    error = yajl.yajl_get_error(self._handler, 1, data, len(data))
                    raise YajlError(error)
            if not data: return
1253522
def parse_segments(vcffile):
    
    from cStringIO import StringIO
    from cyvcf2 import VCF

    output = StringIO()
    for v in VCF(vcffile):
        chrom = v.CHROM
        start = v.start
        end = v.INFO.get('END') - 1
        cn, = v.format('CN')[0]
        print("\t".join(str(x) for x in (chrom, start, end, cn)), file=output)

    beds = BedTool(output.getvalue(), from_string=True)
    return beds
929137
def _parseSegments(self, data, elfHeader):
        """"""
        offset = elfHeader.header.e_phoff
        segments = []
        for i in range(elfHeader.header.e_phnum):
            phdr = self.__classes.PHDR.from_buffer(data, offset)
            segment_bytes = (c_ubyte * phdr.p_filesz).from_buffer(data, phdr.p_offset)

            phdrData = PhdrData(header=phdr, raw=segment_bytes, bytes=bytearray(segment_bytes), type=PT[phdr.p_type], vaddr=phdr.p_vaddr, offset=phdr.p_offset)
            segments.append(phdrData)

            offset += elfHeader.header.e_phentsize

        return segments
72972
def parse(self, buf):
        
        self._tokenizer = tokenize_asdl(buf)
        self._advance()
        return self._parse_module()