method wrapper for printing all elements of a struct
542403
def __struct_params_s(obj, separator=', ', f=repr, fmt='%s = %s'):
    """"""
    s = separator.join([__single_param(obj, n, f, fmt) for n in dir(obj) if __inc_param(obj, n)])
    return s
110353
def debugTreePrint(node,pfx="->"):
  """"""
  print pfx,node.item
  for c in node.children:
    debugTreePrint(c,"  "+pfx)
334659
def _generate_struct(self, struct_type, extra_parameters=None, nameOverride=None):
        
        extra_parameters = extra_parameters if extra_parameters is not None else []
        self._emit_jsdoc_header(struct_type.doc)
        self.emit(
            ' * @typedef {Object} %s' % (
                nameOverride if nameOverride else fmt_type_name(struct_type)
            )
        )

        # Some structs can explicitly list their subtypes. These structs
        # have a .tag field that indicate which subtype they are.
        if struct_type.is_member_of_enumerated_subtypes_tree():
            if struct_type.has_enumerated_subtypes():
                # This struct is the parent to multiple subtypes.
                # Determine all of the possible values of the .tag
                # property.
                tag_values = []
                for tags, _ in struct_type.get_all_subtypes_with_tags():
                    for tag in tags:
                        tag_values.append('"%s"' % tag)

                jsdoc_tag_union = fmt_jsdoc_union(tag_values)
                txt = '@property {%s} .tag - Tag identifying the subtype variant.' % \
                    jsdoc_tag_union
                self.emit_wrapped_text(txt)
            else:
                # This struct is a particular subtype. Find the applicable
                # .tag value from the parent type, which may be an
                # arbitrary number of steps up the inheritance hierarchy.
                parent = struct_type.parent_type
                while not parent.has_enumerated_subtypes():
                    parent = parent.parent_type
                # parent now contains the closest parent type in the
                # inheritance hierarchy that has enumerated subtypes.
                # Determine which subtype this is.
                for subtype in parent.get_enumerated_subtypes():
                    if subtype.data_type == struct_type:
                        txt = '@property {\'%s\'} [.tag] - Tag identifying ' \
                            'this subtype variant. This field is only ' \
                            'present when needed to discriminate ' \
                            'between multiple possible subtypes.' % \
                            subtype.name
                        self.emit_wrapped_text(txt)
                        break

        for param_name, param_type, param_docstring in extra_parameters:
            param_docstring = ' - %s' % param_docstring if param_docstring else ''
            self.emit_wrapped_text(
                '@property {%s} %s%s' % (
                    param_type,
                    param_name,
                    param_docstring,
                ),
                prefix=' * ',
            )

        # NOTE: JSDoc @typedef does not support inheritance. Using @class would be inappropriate,
        # since these are not nominal types backed by a constructor. Thus, we emit all_fields,
        # which includes fields on parent types.
        for field in struct_type.all_fields:
            field_doc = ' - ' + field.doc if field.doc else ''
            field_type, nullable, _ = unwrap(field.data_type)
            field_js_type = fmt_type(field_type)
            # Translate nullable types into optional properties.
            field_name = '[' + field.name + ']' if nullable else field.name
            self.emit_wrapped_text(
                '@property {%s} %s%s' % (
                    field_js_type,
                    field_name,
                    self.process_doc(field_doc, self._docf),
                ),
                prefix=' * ',
            )

        self.emit(' */')
956218
def read_struct(fstream):
    
    line = fstream.readline().strip()
    fragments = line.split(",")
    fragments = [x for x in fragments if x is not None]
    partition = dict()
    if not len(fragments) >= 3:
        return None

    partition["struct"] = fragments[0]
    partition["info"] = fragments[1]
    partition["num_lines"] = fragments[2]

    struct = None
    if partition is not None and partition["struct"] == "STRUCT":
        num_lines = int(partition["num_lines"].strip())
        struct = {}
        for _ in range(num_lines):
            cols = fetch_cols(fstream)
            struct.update({cols[0]: cols[1:]})
    return struct
19483
protected void printStaticAccessors() {
    if (!options.staticAccessorMethods()) {
      return;
    }
    for (VariableDeclarationFragment fragment : getStaticFields()) {
      if (!((FieldDeclaration) fragment.getParent()).hasPrivateDeclaration()) {
        VariableElement varElement = fragment.getVariableElement();
        TypeMirror type = varElement.asType();
        boolean isVolatile = ElementUtil.isVolatile(varElement);
        boolean isPrimitive = type.getKind().isPrimitive();
        String accessorName = nameTable.getStaticAccessorName(varElement);
        String varName = nameTable.getVariableQualifiedName(varElement);
        String objcType = nameTable.getObjCType(type);
        String typeSuffix = isPrimitive ? NameTable.capitalize(TypeUtil.getName(type)) : "Id";
        TypeElement declaringClass = ElementUtil.getDeclaringClass(varElement);
        String baseName = nameTable.getVariableBaseName(varElement);
        ExecutableElement getter =
            ElementUtil.findGetterMethod(baseName, type, declaringClass, /* isStatic = */ true);
        if (getter == null) {
          if (isVolatile) {
            printf(
                "\n+ (%s)%s {\n  return JreLoadVolatile%s(&%s);\n}\n",
                objcType, accessorName, typeSuffix, varName);
          } else {
            printf("\n+ (%s)%s {\n  return %s;\n}\n", objcType, accessorName, varName);
          }
        }
        ExecutableElement setter =
            ElementUtil.findSetterMethod(baseName, type, declaringClass, /* isStatic = */ true);
        if (setter == null && !ElementUtil.isFinal(varElement)) {
          String setterFunc = isVolatile
              ? (isPrimitive ? "JreAssignVolatile" + typeSuffix : "JreVolatileStrongAssign")
              : (isPrimitive | options.useARC() ? null : "JreStrongAssign");
          if (setterFunc == null) {
            printf("\n+ (void)set%s:(%s)value {\n  %s = value;\n}\n",
                NameTable.capitalize(accessorName), objcType, varName);
          } else {
            printf("\n+ (void)set%s:(%s)value {\n  %s(&%s, value);\n}\n",
                NameTable.capitalize(accessorName), objcType, setterFunc, varName);
          }
        }
      }
    }
    if (typeNode instanceof EnumDeclaration) {
      for (EnumConstantDeclaration constant : ((EnumDeclaration) typeNode).getEnumConstants()) {
        VariableElement varElement = constant.getVariableElement();
        printf("\n+ (%s *)%s {\n  return %s;\n}\n",
            typeName, nameTable.getStaticAccessorName(varElement),
            nameTable.getVariableQualifiedName(varElement));
      }
    }
  }
89322
def print_tree(sent, token_attr):
    
    def __print_sent__(token, attr):
        print("{", end=" ")
        [__print_sent__(t, attr) for t in token.lefts]
        print(u"%s->%s(%s)" % (token,token.dep_,token.tag_ if not attr else getattr(token, attr)), end="")
        [__print_sent__(t, attr) for t in token.rights]
        print("}", end=" ")
    return __print_sent__(sent.root, token_attr)
1106169
private void defineWriteStructMethod()
    {
        MethodDefinition write = new MethodDefinition(
                a(PUBLIC),
                "write",
                null,
                arg("struct", structType),
                arg("protocol", TProtocol.class)
        );

        classDefinition.addMethod(write);

        // TProtocolReader reader = new TProtocolReader(protocol);
        write.addLocalVariable(type(TProtocolWriter.class), "writer");
        write.newObject(TProtocolWriter.class);
        write.dup();
        write.loadVariable("protocol");
        write.invokeConstructor(type(TProtocolWriter.class), type(TProtocol.class));
        write.storeVariable("writer");

        LocalVariableDefinition protocol = write.getLocalVariable("writer");

        // protocol.writeStructBegin("bonk");
        write.loadVariable(protocol)
                .loadConstant(metadata.getStructName())
                .invokeVirtual(TProtocolWriter.class, "writeStructBegin", void.class, String.class);

        // write fields
        for (ThriftFieldMetadata field : metadata.getFields(THRIFT_FIELD)) {
            writeField(write, protocol, field);
        }

        write.loadVariable(protocol)
                .invokeVirtual(TProtocolWriter.class, "writeStructEnd", void.class);

        write.ret();
    }
28760
def parse_struct(s):
    
    docs = s['comment']
    code = '<span class="k">struct</span> <span class="gs">%s</span>' % s['name']
    if s['extends']:
        code += ' extends <span class="gs">%s</span>' % s['extends']
    code += ' {\n'
    namelen = 0
    typelen = 0
    for v in s["fields"]:
        tlen = len(format_type(v, includeOptional=False))
        if len(v['name']) > namelen:
            namelen = len(v['name'])
        if tlen > typelen:
          typelen = tlen

    namelen += 1
    typelen += 1

    formatstr = '    <span class="nv">%s</span><span class="kt">%s %s</span>\n'

    i = 0
    for v in s["fields"]:
        if v.has_key('comment') and v['comment']:
            if i > 0: code += "\n"
            for line in v['comment'].split("\n"):
                code += '    <span class="c1">// %s</span>\n' % line
        opt = ""
        if v.has_key('optional') and v['optional'] == True:
          opt = " [optional]"
        code += formatstr % (string.ljust(v['name'], namelen), string.ljust(format_type(v, includeOptional=False), typelen), opt)
        i += 1
    code += "}"

    return to_section(docs, code)
50108
def printClassTree(self, element=None, showids=False, labels=False, showtype=False):
        
        TYPE_MARGIN = 11  # length for owl:class etc..

        if not element:  # first time
            for x in self.toplayer_classes:
                printGenericTree(x, 0, showids, labels, showtype, TYPE_MARGIN)

        else:
            printGenericTree(element, 0, showids, labels, showtype, TYPE_MARGIN)
1199394
private String _serializeStruct(Struct struct, Map<Object, String> done, String id) throws ConverterException {
	StringBuilder sb = new StringBuilder(goIn() + "<STRUCT ID=\"" + id + "\">");

	Iterator<Key> it = struct.keyIterator();

	deep++;
	while (it.hasNext()) {
	    Key key = it.next();
	    // <ENTRY NAME="STRING" TYPE="STRING">hello</ENTRY>
	    String value = _serialize(struct.get(key, null), done);
	    sb.append(goIn() + "<ENTRY NAME=\"" + key.toString() + "\" TYPE=\"" + type + "\">");
	    sb.append(value);
	    sb.append(goIn() + "</ENTRY>");
	}
	deep--;

	sb.append(goIn() + "</STRUCT>");
	type = "STRUCT";
	return sb.toString();
    }
971191
def template_engine(self, entry, startnode):
        

        # print("-----")
        # print(startnode)
        # print(entry[0])
        # print('======')

        startnode_start = len(self.f.getvalue())
        start = startnode_start

        fmt = entry[0]
        arg = 1
        i = 0
        lastC = -1
        recurse_node = False

        m = escape.search(fmt)
        while m:
            i = m.end()
            self.write(m.group('prefix'))

            typ = m.group('type') or '{'
            node = startnode
            try:
                if m.group('child'):
                    node = node[int(m.group('child'))]
                    node.parent = startnode
            except:
                print(node.__dict__)
                raise

            if typ == '%':
                start = len(self.f.getvalue())
                self.write('%')
                self.set_pos_info(node, start, len(self.f.getvalue()))

            elif typ == '+': self.indent_more()
            elif typ == '-': self.indent_less()
            elif typ == '|': self.write(self.indent)
            # no longer used, since BUILD_TUPLE_n is pretty printed:
            elif typ == 'r': recurse_node = True
            elif typ == ',':
                if lastC == 1:
                    self.write(',')
            elif typ == 'b':
                finish = len(self.f.getvalue())
                self.set_pos_info(node[entry[arg]], start, finish)
                arg += 1
            elif typ == 'c':
                start = len(self.f.getvalue())

                index = entry[arg]
                if isinstance(index, tuple):
                    assert node[index[0]] == index[1], (
                        "at %s[%d], expected %s node; got %s" % (
                            node.kind, arg, node[index[0]].kind, index[1])
                        )
                    index = index[0]
                assert isinstance(index, int), (
                    "at %s[%d], %s should be int or tuple" % (
                        node.kind, arg, type(index)))
                self.preorder(node[index])

                finish = len(self.f.getvalue())
                self.set_pos_info(node, start, finish)
                arg += 1
            elif typ == 'p':
                p = self.prec
                (index, self.prec) = entry[arg]
                node[index].parent = node
                start = len(self.f.getvalue())
                self.preorder(node[index])
                self.set_pos_info(node, start, len(self.f.getvalue()))
                self.prec = p
                arg += 1
            elif typ == 'C':
                low, high, sep = entry[arg]
                lastC = remaining = len(node[low:high])
                start = len(self.f.getvalue())
                for subnode in node[low:high]:
                    self.preorder(subnode)
                    remaining -= 1
                    if remaining > 0:
                        self.write(sep)

                self.set_pos_info(node, start, len(self.f.getvalue()))
                arg += 1
            elif typ == 'D':
                low, high, sep = entry[arg]
                lastC = remaining = len(node[low:high])
                for subnode in node[low:high]:
                    remaining -= 1
                    if len(subnode) > 0:
                        self.preorder(subnode)
                        if remaining > 0:
                            self.write(sep)
                            pass
                        pass
                    pass
                arg += 1
            elif typ == 'x':
                src, dest = entry[arg]
                for d in dest:
                    self.set_pos_info_recurse(node[d], node[src].start, node[src].finish)
                    pass
                arg += 1
            elif typ == 'P':
                p = self.prec
                low, high, sep, self.prec = entry[arg]
                lastC = remaining = len(node[low:high])
                start = self.last_finish
                for subnode in node[low:high]:
                    self.preorder(subnode)
                    remaining -= 1
                    if remaining > 0:
                        self.write(sep)
                self.prec = p
                arg += 1

            elif typ == '{':
                d = node.__dict__
                expr = m.group('expr')

                # Line mapping stuff
                if (hasattr(node, 'linestart') and node.linestart
                    and hasattr(node, 'current_line_number')):
                    self.source_linemap[self.current_line_number] = node.linestart
                # Additional fragment-position stuff
                try:
                    start = len(self.f.getvalue())
                    self.write(eval(expr, d, d))
                    self.set_pos_info(node, start, len(self.f.getvalue()))
                except:
                    print(node)
                    raise
            m = escape.search(fmt, i)
            pass

        self.write(fmt[i:])
        fin = len(self.f.getvalue())
        if recurse_node:
            self.set_pos_info_recurse(startnode, startnode_start, fin)
        else:
            self.set_pos_info(startnode, startnode_start, fin)

        # FIXME rocky: figure out how to get these casess to be table driven.
        # 2. subroutine calls. It the last op is the call and for purposes of printing
        # we don't need to print anything special there. However it encompases the
        # entire string of the node fn(...)
        if startnode.kind == 'call':
            last_node = startnode[-1]
            self.set_pos_info(last_node, startnode_start, self.last_finish)
        return
143596
function ObjectTypeIndexer(node, print) {
  if (node["static"]) this.push("static ");
  this.push("[");
  print.plain(node.id);
  this.push(":");
  this.space();
  print.plain(node.key);
  this.push("]");
  this.push(":");
  this.space();
  print.plain(node.value);
}
280515
def print_all() -> None:
    
    for code in sorted(term2hex_map):
        print(' '.join((
            '\033[48;5;{code}m{code:<3}:{hexval:<6}\033[0m',
            '\033[38;5;{code}m{code:<3}:{hexval:<6}\033[0m'
        )).format(code=code, hexval=term2hex_map[code]))
168247
def showSectionsHeaders(peInstance):
    
    
    print "[+] Sections information:\n"
    print "--> NumberOfSections: %d\n" % peInstance.ntHeaders.fileHeader.numberOfSections.value
    for section in peInstance.sectionHeaders:
        fields = section.getFields()
        for field in fields:
            if isinstance(fields[field],  datatypes.String):
                fmt = "%s = %s"
            else:
                fmt = "%s = 0x%08x"
            print fmt % (field,  fields[field].value)
        print "\n"
643971
def dbg_print(self, indent=0):
        
        lst = []
        more_data = False
        for i, addr in enumerate(self.mem.keys()):
            lst.append(addr)
            if i >= 20:
                more_data = True
                break

        for addr in sorted(lst):
            data = self.mem[addr]
            if isinstance(data, SimMemoryObject):
                memobj = data
                print("%s%xh: (%s)[%d]" % (" " * indent, addr, memobj, addr - memobj.base))
            else:
                print("%s%xh: <default data>" % (" " * indent, addr))
        if more_data:
            print("%s..." % (" " * indent))
942733
def _structure_list(self, obj, cl):
        """"""
        if is_bare(cl) or cl.__args__[0] is Any:
            return [e for e in obj]
        else:
            elem_type = cl.__args__[0]
            return [
                self._structure_func.dispatch(elem_type)(e, elem_type)
                for e in obj
            ]
1318382
def print_all_param_defaults():
    """"""
    print("_______________________________________________________________________________")
    print("")
    print("                           Parameter Default Values")
    print("")
    classes = descendents(Parameterized)
    classes.sort(key=lambda x:x.__name__)
    for c in classes:
        c.print_param_defaults()
    print("_______________________________________________________________________________")