Get a list of records for a frame and all higher (calling) frames.

    Each record contains a frame object, filename, line number, function
    name, a list of lines of context, and index within the context.
339768
def getouterframes(frame, context=1):
    """"""
    framelist = []
    while frame:
        framelist.append((frame,) + getframeinfo(frame, context))
        frame = frame.f_back
    return framelist
27460
def _list_records(self, rtype=None, name=None, content=None):
        
        if name:
            name = self._relative_name(name)
        if not rtype:
            rtype = "ANY"

        filter_query = {"rdtype": rtype, "name": name, "content": content}

        with localzone.manage(self.filename, self.origin, autosave=True) as zone:
            records = zone.find_record(**filter_query)  # pylint: disable=no-member

        result = []
        for record in records:
            rdict = {
                "type": record.rdtype,
                "name": self._full_name(record.name),
                "ttl": record.ttl,
                "content": record.content,
                "id": record.hashid,
            }

            if rdict["type"] == "TXT":
                rdict["content"] = rdict["content"].replace('"', "")

            result.append(rdict)

        LOGGER.debug("list_records: %s", result)
        return result
441103
def get_frame_info(tb, context_lines=7, simple=False):
    
    # line numbers / function / variables
    lineno = tb.tb_lineno
    function = tb.tb_frame.f_code.co_name
    variables = tb.tb_frame.f_locals

    files = {}

    # get filename
    if simple:
        fn = tb.tb_frame.f_code.co_filename
    else:
        fn = tb.tb_frame.f_globals.get('__file__')
        if not fn:
            fn = os.path.realpath(inspect.getsourcefile(tb) or
                                  inspect.getfile(tb))
        if fn[-4:] in ('.pyc', '.pyo'):
            fn = fn[:-1]

    #if filename is existed, then just read the file
    # get loader
    loader = None
    if not os.path.exists(fn):
        loader = tb.tb_frame.f_globals.get('__loader__')
        while not loader and tb.tb_next:
            tb = tb.tb_next
            loader = tb.tb_frame.f_globals.get('__loader__')


    # sourcecode
    source = ''
    pre_context, post_context = [], []
    context_line = raw_context_line = context_lineno = None
    try:
        if loader:
            source = loader.get_source(fn)
        else:
            if not fn in files:
                source = open(fn).read()
                files[fn] = source
            else:
                source = files[fn]
    except:
        pass
    else:
        try:
            raw_context_line = source.splitlines()[lineno - 1].strip()
        except IndexError:
            pass
        if not simple:
            parsed_source = highlight_python(source)
            lbound = max(0, lineno - context_lines - 1)
            ubound = lineno + context_lines
            try:
                context_line = parsed_source[lineno - 1]
                pre_context = parsed_source[lbound:lineno - 1]
                post_context = parsed_source[lineno:ubound]
            except IndexError as e:
                pass
            context_lineno = lbound

    if isinstance(fn, unicode):
        fn = fn.encode('utf-8')
    return {
        'tb':               tb,
        'filename':         fn,
        'basename':         os.path.basename(fn),
        'loader':           loader,
        'function':         function,
        'lineno':           lineno,
        'vars':             variables,
        'pre_context':      pre_context,
        'context_line':     context_line,
        'raw_context_line': raw_context_line,
        'post_context':     post_context,
        'context_lineno':   context_lineno,
        'source':           source
    }
505591
def dump_frames(self, frame):
        
        current_thread = threading.currentThread()
        frames = []
        frame_browser = frame
        
        # Browse the frame chain as far as we can
        _logger.f_debug("dump_frames(), frame analysis:")
        spacer = ""
        while hasattr(frame_browser, 'f_back') and frame_browser.f_back != self.frame_beginning:
            spacer += "="
            _logger.f_debug("%s>frame = %s, frame.f_code = %s, frame.f_back = %s, "
                            "self.frame_beginning = %s",
                            spacer,
                            hex(id(frame_browser)),
                            frame_browser.f_code,
                            hex(id(frame_browser.f_back)),
                            hex(id(self.frame_beginning)))

            # At root frame, globals == locals so we dump only globals
            if hasattr(frame_browser.f_back, 'f_back')\
                    and frame_browser.f_back.f_back != self.frame_beginning:
                locals_vars_list = self.extract_object_properties(frame_browser.f_locals,
                                                                  limit_size=True)
            else:
                locals_vars_list = []
                                
            globals_vars_list = self.extract_object_properties(frame_browser.f_globals,
                                                               limit_size=True)
            # normalize path sent to debugging client
            file_path = self.normalize_path_out(frame_browser.f_code.co_filename)

            frame_name = "%s() [%s]" % (frame_browser.f_code.co_name, current_thread.name,)
            remote_frame = {
                'id': id(frame_browser),
                'name': frame_name,
                'line_number': frame_browser.f_lineno,  # Warning 1 based
                'file_path': file_path,
                'f_locals': locals_vars_list + globals_vars_list,
                'thread': current_thread.ident,
                'thread_name': current_thread.name
            }
            frames.append(remote_frame)
            frame_browser = frame_browser.f_back
        return frames
97255
def get_sample_frame(self):
        """"""
        for frame in self.frames:
            return frame.open()

        for res in self.results.values():
            return res.open()

        return None
334644
def _list_records(self, rtype=None, name=None, content=None):
        """"""
        records = [
            {
                'id': record['id'],
                'type': record['type'],
                'name': self._full_name(record['hostname']),
                'content': record['destination'],
                'priority': record['priority'],
                'ttl': self.zone_ttl,
            }
            for record in self._raw_records(None, rtype, name, content)
        ]
        LOGGER.debug('list_records: %s', records)
        return records
581715
def get_frames(root_path):
   """"""
   ret = []
   for root, _, files in os.walk(root_path):
       root=root.replace('\\','/')
       files=[s for s in files if ".dcm" in s]
       if len(files) == 0 or not files[0].endswith(".dcm") or root.find("sax") == -1:
           continue
       prefix = files[0].rsplit('-', 1)[0]
       fileset = set(files)
       expected = ["%s-%04d.dcm" % (prefix, i + 1) for i in range(30)]
       if all(x in fileset for x in expected):
           ret.append([root + "/" + x for x in expected])
   # sort for reproduciblity
   return sorted(ret, key = lambda x: x[0])
524550
def records(self):
        """"""
        records = ModelList()
        contextual_records = []
        head_def_record = None
        head_def_record_i = None
        last_product_record = None
        title_record = None
        for i, el in enumerate(self.elements):
            last_id_record = None

            # Save title compound
            if isinstance(el, Title):
                el_records = el.records
                if len(el_records) == 1 and el_records[0].is_id_only:
                    title_record = el_records[0]
            
            # Reset head_def_record unless consecutive heading with no records
            if isinstance(el, Heading) and head_def_record is not None:
                if not (i == head_def_record_i + 1 and len(el.records) == 0):
                    head_def_record = None
                    head_def_record_i = None

            # Paragraph with single sentence with single ID record considered a head_def_record like heading
            if isinstance(el, Paragraph) and len(el.sentences) == 1:
                el_records = el.records
                if len(el_records) == 1 and el_records[0].is_id_only:
                    head_def_record = el_records[0]
                    head_def_record_i = i
            elif isinstance(el, Paragraph) and len(el.sentences) > 0 and not (head_def_record_i == i - 1 and isinstance(self.elements[i - 1], Heading)):
                # head_def_record from first sentence in Paragraph with single ID record unless right after heading with previous head_def_record
                first_sent_records = el.sentences[0].records
                if len(first_sent_records) == 1 and first_sent_records[0].is_id_only:
                    sent_record = first_sent_records[0]
                    if sent_record.labels or (sent_record.names and len(sent_record.names[0]) > len(el.sentences[0].text) / 2):
                        head_def_record = sent_record
                        head_def_record_i = i

            for record in el.records:
                # Keep track of the most recent record with labels
                if isinstance(el, Paragraph) and record.labels:
                    last_id_record = record
                # Keep track of the most recent 'product' record
                if 'product' in record.roles:
                    last_product_record = record
                if isinstance(el, Heading) and (record.labels or record.names):
                    head_def_record = record
                    head_def_record_i = i

                    # If 2 consecutive headings with compound ID, merge in from previous
                    if i > 0 and isinstance(self.elements[i - 1], Heading):
                        prev = self.elements[i - 1]
                        if (len(el.records) == 1 and record.is_id_only and len(prev.records) == 1 and
                                prev.records[0].is_id_only and not (record.labels and prev.records[0].labels) and
                                not (record.names and prev.records[0].names)):
                            record.names.extend(prev.records[0].names)
                            record.labels.extend(prev.records[0].labels)
                            record.roles.extend(prev.records[0].roles)

                if record.is_unidentified:
                    if record.is_contextual:
                        # Add contextual record to a list of all from the document for later merging
                        contextual_records.append(record)
                        continue
                    else:
                        # print(record.serialize())
                        # We have property values but no names or labels... try merge those from previous
                        if isinstance(el, Paragraph) and (head_def_record or last_product_record or last_id_record or title_record):
                            # head_def_record from heading takes priority if the heading directly precedes the paragraph ( NOPE: or the last_id_record has no name)
                            if head_def_record_i and head_def_record_i + 1 == i: # or (last_id_record and not last_id_record.names)):
                                if head_def_record:
                                    record.names = head_def_record.names
                                    record.labels = head_def_record.labels
                                    record.roles = head_def_record.roles
                                elif last_id_record:
                                    record.names = last_id_record.names
                                    record.labels = last_id_record.labels
                                    record.roles = last_id_record.roles
                                elif last_product_record:
                                    record.names = last_product_record.names
                                    record.labels = last_product_record.labels
                                    record.roles = last_product_record.roles
                                elif title_record:
                                    record.names = title_record.names
                                    record.labels = title_record.labels
                                    record.roles = title_record.roles
                            else:
                                if last_id_record:
                                    record.names = last_id_record.names
                                    record.labels = last_id_record.labels
                                    record.roles = last_id_record.roles
                                elif head_def_record:
                                    record.names = head_def_record.names
                                    record.labels = head_def_record.labels
                                    record.roles = head_def_record.roles
                                elif last_product_record:
                                    record.names = last_product_record.names
                                    record.labels = last_product_record.labels
                                    record.roles = last_product_record.roles
                                elif title_record:
                                    record.names = title_record.names
                                    record.labels = title_record.labels
                                    record.roles = title_record.roles
                        else:
                            # Consider continue here to filter records missing name/label...
                            pass
                records.append(record)

        for record in records:
            for contextual_record in contextual_records:
                record.merge_contextual(contextual_record)

        for record in records:
            for short, long, entity in self.abbreviation_definitions:
                if entity == 'CM':
                    name = ' '.join(long)
                    abbrev = ' '.join(short)
                    if name in record.names and not abbrev in record.names:
                        record.names.append(abbrev)
                    if abbrev in record.names and not name in record.names:
                        record.names.append(name)

        # Merge records with any shared name/label
        len_l = len(records)
        i = 0
        while i < (len_l - 1):
            for j in range(i + 1, len_l):
                r = records[i]
                other_r = records[j]

                # Strip whitespace and lowercase to compare names
                rnames_std = {''.join(n.split()).lower() for n in r.names}
                onames_std = {''.join(n.split()).lower() for n in other_r.names}

                # Clashing labels, don't merge
                if len(set(r.labels) - set(other_r.labels)) > 0 and len(set(other_r.labels) - set(r.labels)) > 0:
                    continue

                if any(n in rnames_std for n in onames_std) or any(l in r.labels for l in other_r.labels):
                    records.pop(j)
                    records.pop(i)
                    records.append(r.merge(other_r))
                    len_l -= 1
                    i -= 1
                    break
            i += 1
        return records
656519
def recordings(self):
        
        if self._recordings is None:
            self._recordings = RecordingList(self)
        return self._recordings
544136
def list(self,table, **kparams):
        
        records = self.api.list(table, **kparams)
        return records
563007
def records(self):
        """"""
        caption_records = self.caption.records
        # Parse headers to extract contextual data and determine value parser for the column
        value_parsers = {}
        header_compounds = defaultdict(list)
        table_records = ModelList()
        seen_compound_col = False
        log.debug('Parsing table headers')

        for i, col_headings in enumerate(zip(*self.headings)):
            # log.info('Considering column %s' % i)
            for parsers in self.parsers:
                log.debug(parsers)
                heading_parser = parsers[0]
                value_parser = parsers[1] if len(parsers) > 1 else None
                disallowed_parser = parsers[2] if len(parsers) > 2 else None
                allowed = False
                disallowed = False
                for cell in col_headings:
                    log.debug(cell.tagged_tokens)
                    results = list(heading_parser.parse(cell.tagged_tokens))
                    if results:
                        allowed = True
                        log.debug('Heading column %s: Match %s: %s' % (i, heading_parser.__class__.__name__, [c.serialize() for c in results]))
                    # Results from every parser are stored as header compounds
                    header_compounds[i].extend(results)
                    # Referenced footnote records are also stored
                    for footnote in self.footnotes:
                        # print('%s - %s - %s' % (footnote.id, cell.references, footnote.id in cell.references))
                        if footnote.id in cell.references:
                            log.debug('Adding footnote %s to column %s: %s' % (footnote.id, i, [c.serialize() for c in footnote.records]))
                            # print('Footnote records: %s' % [c.to_primitive() for c in footnote.records])
                            header_compounds[i].extend(footnote.records)
                    # Check if the disallowed parser matches this cell
                    if disallowed_parser and list(disallowed_parser.parse(cell.tagged_tokens)):
                        log.debug('Column %s: Disallowed %s' % (i, heading_parser.__class__.__name__))
                        disallowed = True
                # If heading parser matches and disallowed parser doesn't, store the value parser
                if allowed and not disallowed and value_parser and i not in value_parsers:
                    if isinstance(value_parser, CompoundCellParser):
                        # Only take the first compound col
                        if seen_compound_col:
                            continue
                        seen_compound_col = True
                    log.debug('Column %s: Value parser: %s' % (i, value_parser.__class__.__name__))
                    value_parsers[i] = value_parser
                    # Stop after value parser is assigned?

        # for hrow in self.headings:
        #     for i, cell in enumerate(hrow):
        #         log.debug(cell.tagged_tokens)
        #         for heading_parser, value_parser in self.parsers:
        #             results = list(heading_parser.parse(cell.tagged_tokens))
        #             if results:
        #                 log.debug('Heading column %s: Match %s: %s' % (i, heading_parser.__class__.__name__, [c.to_primitive() for c in results]))
        #             # Results from every parser are stored as header compounds
        #             header_compounds[i].extend(results)
        #             if results and value_parser and i not in value_parsers:
        #                 if isinstance(value_parser, CompoundCellParser):
        #                     # Only take the first compound col
        #                     if seen_compound_col:
        #                         continue
        #                     seen_compound_col = True
        #                 value_parsers[i] = value_parser
        #                 break  # Stop after first heading parser matches
        #         # Referenced footnote records are also stored
        #         for footnote in self.footnotes:
        #             # print('%s - %s - %s' % (footnote.id, cell.references, footnote.id in cell.references))
        #             if footnote.id in cell.references:
        #                 log.debug('Adding footnote %s to column %s: %s' % (footnote.id, i, [c.to_primitive() for c in footnote.records]))
        #                 # print('Footnote records: %s' % [c.to_primitive() for c in footnote.records])
        #                 header_compounds[i].extend(footnote.records)

        # If no parsers, skip processing table
        if value_parsers:

            # If no CompoundCellParser() in value_parsers and value_parsers[0] == [] then set CompoundCellParser()
            if not seen_compound_col and 0 not in value_parsers:
                log.debug('No compound column found in table, assuming first column')
                value_parsers[0] = CompoundCellParser()

            for row in self.rows:
                row_compound = Compound()
                # Keep cell records that are contextual to merge at the end
                contextual_cell_compounds = []
                for i, cell in enumerate(row):
                    log.debug(cell.tagged_tokens)
                    if i in value_parsers:
                        results = list(value_parsers[i].parse(cell.tagged_tokens))
                        if results:
                            log.debug('Cell column %s: Match %s: %s' % (i, value_parsers[i].__class__.__name__, [c.serialize() for c in results]))
                        # For each result, merge in values from elsewhere
                        for result in results:
                            # Merge each header_compounds[i]
                            for header_compound in header_compounds[i]:
                                if header_compound.is_contextual:
                                    result.merge_contextual(header_compound)
                            # Merge footnote compounds
                            for footnote in self.footnotes:
                                if footnote.id in cell.references:
                                    for footnote_compound in footnote.records:
                                        result.merge_contextual(footnote_compound)
                            if result.is_contextual:
                                # Don't merge cell as a value compound if there are no values
                                contextual_cell_compounds.append(result)
                            else:
                                row_compound.merge(result)
                # Merge contextual information from cells
                for contextual_cell_compound in contextual_cell_compounds:
                    row_compound.merge_contextual(contextual_cell_compound)
                # If no compound name/label, try take from previous row
                if not row_compound.names and not row_compound.labels and table_records:
                    prev = table_records[-1]
                    row_compound.names = prev.names
                    row_compound.labels = prev.labels
                # Merge contextual information from caption into the full row
                for caption_compound in caption_records:
                    if caption_compound.is_contextual:
                        row_compound.merge_contextual(caption_compound)
                # And also merge from any footnotes that are referenced from the caption
                for footnote in self.footnotes:
                    if footnote.id in self.caption.references:
                        # print('Footnote records: %s' % [c.to_primitive() for c in footnote.records])
                        for fn_compound in footnote.records:
                            row_compound.merge_contextual(fn_compound)

                log.debug(row_compound.serialize())
                if row_compound.serialize():
                    table_records.append(row_compound)

        # TODO: If no rows have name or label, see if one is in the caption

        # Include non-contextual caption records in the final output
        caption_records = [c for c in caption_records if not c.is_contextual]
        table_records += caption_records
        return table_records
1098203
def record(self):
        

        modules = []
        scripts = []
        if self.get_content_of_file('RECORD'):
            lines = self.get_content_of_file('RECORD').splitlines()
            for line in lines:
                if 'dist-info' in line or '/' not in line:
                    continue
                elif '.data/scripts' in line:
                    script = line.split(',', 1)[0]
                    # strip Name.version.data/scripts/
                    scripts.append(re.sub('.*/.*/', '', script))
                else:
                    # strip everything from first occurance of slash
                    modules.append(re.sub('/.*', '', line))

        return {'modules': sorted(set(modules)),
                'scripts': sorted(set(scripts))}
129389
def list_records(self, limit=None, offset=None):
        
        return self.manager.list_records(self, limit=limit, offset=offset)
618713
public List<JSONObject> getRecords()
    {
        List<JSONObject> records = new ArrayList<JSONObject>();
    
        try
        {
            if (data != null && data.has(getRecordParam))
            {
                JSONObject jsonGetRecord = data.getJSONObject(getRecordParam);
                
                if (jsonGetRecord.has(recordParam))
                {
                    JSONArray jsonRecords = jsonGetRecord.getJSONArray(recordParam);
                    
                    for(int i = 0; i < jsonRecords.length(); i++)
                    {
                        JSONObject record = jsonRecords.getJSONObject(i);
                        records.add(record);
                    }
                }
            }
        }
        catch (JSONException e)
        {
            //This is already handled by the enclosing "has" checks
        }
        
        return records;
    }
1229423
def get_frames(self):
        ""
        nb_frames = self.input_totalframes // self.output_blocksize

        if self.input_totalframes % self.output_blocksize == 0:
            nb_frames -= 1  # Last frame must send eod=True

        for index in xrange(0,
                            nb_frames * self.output_blocksize,
                            self.output_blocksize):
            yield (self.samples[index:index + self.output_blocksize], False)

        yield (self.samples[nb_frames * self.output_blocksize:], True)
467562
def getinnerframes(tb, context=1):
    """"""
    framelist = []
    while tb:
        framelist.append((tb.tb_frame,) + getframeinfo(tb, context))
        tb = tb.tb_next
    return framelist
1292419
def _load_virtual_frames(self):
        """"""
        pages = self.pages
        try:
            if sys.version_info[0] == 2:
                raise ValueError('not supported on Python 2')
            if len(pages) > 1:
                raise ValueError('pages already loaded')
            page = pages[0]
            bytecounts = page._offsetscounts[1]
            if len(bytecounts) != 1:
                raise ValueError('data not contiguous')
            self._seek(4)
            delta = pages[2] - pages[1]
            if pages[3] - pages[2] != delta or pages[4] - pages[3] != delta:
                raise ValueError('page offsets not equidistant')
            page1 = self._getitem(1, validate=page.hash)
            offsetoffset = page1._offsetscounts[0][0] - page1.offset
            if offsetoffset < 0 or offsetoffset > delta:
                raise ValueError('page offsets not equidistant')
            pages = [page, page1]
            filesize = self.parent.filehandle.size - delta
            for index, offset in enumerate(range(page1.offset+delta,
                                                 filesize, delta)):
                offsets = [offset + offsetoffset]
                offset = offset if offset < 2**31 else None
                pages.append(
                    TiffFrame(parent=page.parent, index=index+2, offset=None,
                              offsets=offsets, bytecounts=bytecounts,
                              keyframe=page))
        except Exception as exc:
            log.warning(
                'TiffPages: failed to load virtual frames: %s', str(exc))
        assert pages[1]
        self.pages = pages
        self._cache = True
        self._cached = True
        self._indexed = True