Prints IMAGE_OPTIONAL_HEADER fields.
179943
def showOptionalHeaderData(peInstance):
    
    
    print "[+] IMAGE_OPTIONAL_HEADER:\n"
    ohFields = peInstance.ntHeaders.optionalHeader.getFields()
    for field in ohFields:
        if not isinstance(ohFields[field],  datadirs.DataDirectory):
            print "--> %s = 0x%08x" % (field,  ohFields[field].value)
380792
def mdprint(*values, plain=None, **options):
    
    print(*[mdrender(x, plain=plain) for x in values], **options)
1065609
protected void printStaticAccessors() {
    if (options.staticAccessorMethods()) {
      for (VariableDeclarationFragment fragment : getStaticFields()) {
        VariableElement var = fragment.getVariableElement();
        TypeMirror type = var.asType();
        String accessorName = nameTable.getStaticAccessorName(var);
        String objcType = nameTable.getObjCType(type);
        TypeElement declaringClass = ElementUtil.getDeclaringClass(var);
        String baseName = nameTable.getVariableBaseName(var);
        ExecutableElement getter =
            ElementUtil.findGetterMethod(baseName, type, declaringClass, /* isStatic = */ true);
        if (getter == null) {
          printf("\n+ (%s)%s;\n", objcType, accessorName);
        }
        ExecutableElement setter =
            ElementUtil.findSetterMethod(baseName, type, declaringClass, /* isStatic = */ true);
        if (setter == null && !ElementUtil.isFinal(var)) {
          printf("\n+ (void)set%s:(%s)value;\n", NameTable.capitalize(accessorName), objcType);
        }
      }
      if (typeNode instanceof EnumDeclaration) {
        for (EnumConstantDeclaration constant : ((EnumDeclaration) typeNode).getEnumConstants()) {
          String accessorName = nameTable.getStaticAccessorName(constant.getVariableElement());
          if (options.nullability()) {
            printf("\n+ (%s * __nonnull)%s;\n", typeName, accessorName);
          } else {
            printf("\n+ (%s *)%s;\n", typeName, accessorName);
          }
        }
      }
    }
  }
551629
def PrintSets(self):
        """"""
        sets=self._getphotosets()
        for setname in sets:
            print("%s [%d]"%(setname,sets[setname]['number_photos']))
689154
def _print_header(self):
        """"""
        header = " Iter  Dir  "
        if self.constraints is not None:
            header += '  SC CC'
        header += "         Function"
        if self.convergence_condition is not None:
            header += self.convergence_condition.get_header()
        header += "    Time"
        self._screen("-"*(len(header)), newline=True)
        self._screen(header, newline=True)
        self._screen("-"*(len(header)), newline=True)
413519
@Override
    public ImageHeader readHeader(InputStream input) throws IOException
    {
        checkSkippedError(input.skip(2), 2);
        int current = input.read();
        while (255 == current)
        {
            final int marker = input.read();
            final int len = readInt(input, 2, true);
            if (MARKER_1 == marker || MARKER_2 == marker || MARKER_3 == marker)
            {
                final long skipped = input.skip(1);
                checkSkippedError(skipped, 1);
                final int height = readInt(input, 2, true);
                final int width = readInt(input, 2, true);
                final ImageFormat format = ImageFormat.JPG;

                return new ImageHeaderModel(width, height, format);
            }
            final long skipped = input.skip(len - 2L);
            checkSkippedError(skipped, len - 2);
            current = input.read();
        }
        throw new IOException(ERROR_JPG);
    }
1263175
def print_attr_values( thing, all=False, heading=None, file=None ):
    '''
    
    '''
    if heading :
        if isinstance( heading, int ) :
            # request for default heading
            heading = '== {} attributes of {} =='.format(
                            'all' if all else 'non-empty',
                            getattr( thing, '__name__', str(thing) )
            )
        print( heading, file=file )

    for attr in object_attributes( thing, all ):
        attr_value = getattr( thing, attr )
        if attr_value is not None :
            print( attr, ':', attr_value, file=file )
        elif all :
            print( attr, ':' )
840514
function headers(buffer) {
    var head = {};
    if (buffer[0] === 0x89 && buffer[1] === 0x50 && buffer[2] === 0x4E &&
        buffer[3] === 0x47 && buffer[4] === 0x0D && buffer[5] === 0x0A &&
        buffer[6] === 0x1A && buffer[7] === 0x0A) {
        head['Content-Type'] = 'image/png';
    } else if (buffer[0] === 0xFF && buffer[1] === 0xD8 &&
        buffer[buffer.length - 2] === 0xFF && buffer[buffer.length - 1] === 0xD9) {
        head['Content-Type'] = 'image/jpeg';
    } else if (buffer[0] === 0x47 && buffer[1] === 0x49 && buffer[2] === 0x46 &&
        buffer[3] === 0x38 && (buffer[4] === 0x39 || buffer[4] === 0x37) &&
        buffer[5] === 0x61) {
        head['Content-Type'] = 'image/gif';
    } else if (buffer[0] === 0x52 && buffer[1] === 0x49 && buffer[2] === 0x46 && buffer[3] === 0x46 &&
        buffer[8] === 0x57 && buffer[9] === 0x45 && buffer[10] === 0x42 && buffer[11] === 0x50) {
        head['Content-Type'] = 'image/webp';
    // deflate: recklessly assumes contents are PBF.
    } else if (buffer[0] === 0x78 && buffer[1] === 0x9C) {
        head['Content-Type'] = 'application/x-protobuf';
        head['Content-Encoding'] = 'deflate';
    // gzip: recklessly assumes contents are PBF.
    } else if (buffer[0] === 0x1F && buffer[1] === 0x8B) {
        head['Content-Type'] = 'application/x-protobuf';
        head['Content-Encoding'] = 'gzip';
    }
    return head;
}
17272
public void printHtmlHeading(PrintWriter out)
    {
        if (this.getScreenField().getConverter() != null)
            super.printHtmlHeading(out);
        else if (this.getScreenField().getParentScreen() instanceof GridScreen)
        { // These are command buttons such as "Form" or "Detail"
            String strImage = "Form";
            if (((SButtonBox)this.getScreenField()).getImageButtonName() != null)
                strImage = ((SButtonBox)this.getScreenField()).getImageButtonName();
            out.println("<th align=\"center\" valign=\"center\"><img src=\"" + HtmlConstants.IMAGE_DIR + "buttons/" + strImage + ".gif\" width=\"16\" height=\"16\" alt=\"Open this record\"></th>");
        }
    }
852508
private function _output($options = array())
    {
        if (!isset($options["type"])) $options["type"] = "png";
        if (!isset($options["page"])) $options["page"] = 1;
        $type = strtolower($options["type"]);

        if (isset($this->_imgs[$options["page"] - 1])) {
            $img = $this->_imgs[$options["page"] - 1];
        } else {
            $img = $this->_imgs[0];
        }

        // Perform any antialiasing
        if ($this->_aa_factor != 1) {
            $dst_w = $this->_actual_width / $this->_aa_factor;
            $dst_h = $this->_actual_height / $this->_aa_factor;
            $dst = imagecreatetruecolor($dst_w, $dst_h);
            imagecopyresampled($dst, $img, 0, 0, 0, 0,
                $dst_w, $dst_h,
                $this->_actual_width, $this->_actual_height);
        } else {
            $dst = $img;
        }

        switch ($type) {
            case "jpg":
            case "jpeg":
                if (!isset($options["quality"])) {
                    $options["quality"] = 75;
                }

                imagejpeg($dst, null, $options["quality"]);
                break;
            case "png":
            default:
                imagepng($dst);
                break;
        }

        if ($this->_aa_factor != 1) {
            imagedestroy($dst);
        }
    }
952635
def printtable(h, header):
    """"""
    hk = header_fields(h)
    if (header):
        printheader()
    writer = csv.DictWriter(sys.stdout, hk, extrasaction='ignore')
    writer.writerow(h)
771665
private void createPrintContactsSubForm() {
		add(new WHeading(HeadingLevel.H3, "Print to CSV"));

		WButton printBtn = new WButton("Print");
		printBtn.setAction(new Action() {
			@Override
			public void execute(final ActionEvent event) {
				printDetails();
			}
		});
		printBtn.setImage("/image/document-print.png");
		printBtn.setImagePosition(WButton.ImagePosition.EAST);

		WFieldLayout layout = new WFieldLayout();
		add(layout);
		layout.setMargin(new Margin(Size.LARGE, null, null, null));
		layout.addField("Print output", printOutput);
		layout.addField((WLabel) null, printBtn);
		add(new WAjaxControl(printBtn, printOutput));
	}
47380
def parse_header(options = {})
      check_header
      @hdr = parse_basic_header
      @extended_header = parse_extended_header

      # Optional image gathering
      read_image if options[:image]
      get_image_narray(@image_rubyarray, @hdr['dim']) if options[:narray]

      @success = true
    end
122441
def dump_info(self, dump=None, encoding='ascii'):
        """"""

        if dump is None:
            dump = Dump()

        warnings = self.get_warnings()
        if warnings:
            dump.add_header('Parsing Warnings')
            for warning in warnings:
                dump.add_line(warning)
                dump.add_newline()


        dump.add_header('DOS_HEADER')
        dump.add_lines(self.DOS_HEADER.dump())
        dump.add_newline()

        dump.add_header('NT_HEADERS')
        dump.add_lines(self.NT_HEADERS.dump())
        dump.add_newline()

        dump.add_header('FILE_HEADER')
        dump.add_lines(self.FILE_HEADER.dump())

        image_flags = retrieve_flags(IMAGE_CHARACTERISTICS, 'IMAGE_FILE_')

        dump.add('Flags: ')
        flags = []
        for flag in sorted(image_flags):
            if getattr(self.FILE_HEADER, flag[0]):
                flags.append(flag[0])
        dump.add_line(', '.join(flags))
        dump.add_newline()

        if hasattr(self, 'OPTIONAL_HEADER') and self.OPTIONAL_HEADER is not None:
            dump.add_header('OPTIONAL_HEADER')
            dump.add_lines(self.OPTIONAL_HEADER.dump())

        dll_characteristics_flags = retrieve_flags(DLL_CHARACTERISTICS, 'IMAGE_DLLCHARACTERISTICS_')

        dump.add('DllCharacteristics: ')
        flags = []
        for flag in sorted(dll_characteristics_flags):
            if getattr(self.OPTIONAL_HEADER, flag[0]):
                flags.append(flag[0])
        dump.add_line(', '.join(flags))
        dump.add_newline()


        dump.add_header('PE Sections')

        section_flags = retrieve_flags(SECTION_CHARACTERISTICS, 'IMAGE_SCN_')

        for section in self.sections:
            dump.add_lines(section.dump())
            dump.add('Flags: ')
            flags = []
            for flag in sorted(section_flags):
                if getattr(section, flag[0]):
                    flags.append(flag[0])
            dump.add_line(', '.join(flags))
            dump.add_line('Entropy: {0:f} (Min=0.0, Max=8.0)'.format(
                section.get_entropy()))
            if md5 is not None:
                dump.add_line('MD5     hash: {0}'.format(
                    section.get_hash_md5()))
            if sha1 is not None:
                dump.add_line('SHA-1   hash: %s' % section.get_hash_sha1() )
            if sha256 is not None:
                dump.add_line('SHA-256 hash: %s' % section.get_hash_sha256() )
            if sha512 is not None:
                dump.add_line('SHA-512 hash: %s' % section.get_hash_sha512() )
            dump.add_newline()



        if (hasattr(self, 'OPTIONAL_HEADER') and
            hasattr(self.OPTIONAL_HEADER, 'DATA_DIRECTORY') ):

            dump.add_header('Directories')
            for idx in range(len(self.OPTIONAL_HEADER.DATA_DIRECTORY)):
                directory = self.OPTIONAL_HEADER.DATA_DIRECTORY[idx]
                dump.add_lines(directory.dump())
            dump.add_newline()

        if hasattr(self, 'VS_VERSIONINFO'):
            for idx in range(len(self.VS_VERSIONINFO)):
                if len(self.VS_VERSIONINFO) > 1:
                    dump.add_header('Version Information {:d}'.format(idx + 1))
                else:
                    dump.add_header('Version Information')
                dump.add_lines(self.VS_VERSIONINFO[idx].dump())
                dump.add_newline()

                if hasattr(self, 'VS_FIXEDFILEINFO'):
                    dump.add_lines(self.VS_FIXEDFILEINFO[idx].dump())
                    dump.add_newline()

                if hasattr(self, 'FileInfo') and len(self.FileInfo) > idx:
                    for entry in self.FileInfo[idx]:
                        dump.add_lines(entry.dump())
                        dump.add_newline()

                        if hasattr(entry, 'StringTable'):
                            for st_entry in entry.StringTable:
                                [dump.add_line(u'  '+line) for line in st_entry.dump()]
                                dump.add_line(u'  LangID: {0}'.format(
                                    st_entry.LangID.decode(encoding, 'backslashreplace_')))
                                dump.add_newline()
                                for str_entry in sorted(list(st_entry.entries.items())):
                                    # try:
                                    dump.add_line( u'    {0}: {1}'.format(
                                        str_entry[0].decode(encoding, 'backslashreplace_'),
                                        str_entry[1].decode(encoding, 'backslashreplace_')))

                            dump.add_newline()

                        elif hasattr(entry, 'Var'):
                            for var_entry in entry.Var:
                                if hasattr(var_entry, 'entry'):
                                    [dump.add_line('  '+line) for line in var_entry.dump()]
                                    dump.add_line(
                                        u'    {0}: {1}'.format(
                                            list(var_entry.entry.keys())[0].decode(
                                                'utf-8', 'backslashreplace_'),
                                            list(var_entry.entry.values())[0]))

                            dump.add_newline()

        if hasattr(self, 'DIRECTORY_ENTRY_EXPORT'):
            dump.add_header('Exported symbols')
            dump.add_lines(self.DIRECTORY_ENTRY_EXPORT.struct.dump())
            dump.add_newline()
            dump.add_line(u'%-10s   %-10s  %s' % ('Ordinal', 'RVA', 'Name'))
            for export in self.DIRECTORY_ENTRY_EXPORT.symbols:
                if export.address is not None:
                    name = b('None')
                    if export.name:
                        name = export.name
                    dump.add(u'%-10d 0x%08X    %s' % (
                        export.ordinal, export.address, name.decode(encoding)))
                    if export.forwarder:
                        dump.add_line(u' forwarder: {0}'.format(
                            export.forwarder.decode(encoding, 'backslashreplace_')))
                    else:
                        dump.add_newline()

            dump.add_newline()

        if hasattr(self, 'DIRECTORY_ENTRY_IMPORT'):
            dump.add_header('Imported symbols')
            for module in self.DIRECTORY_ENTRY_IMPORT:
                dump.add_lines(module.struct.dump())
                # Print the name of the DLL if there are no imports.
                if not module.imports:
                    dump.add('  Name -> {0}'.format(
                        self.get_string_at_rva(module.struct.Name).decode(
                            encoding, 'backslashreplace_')))
                    dump.add_newline()
                dump.add_newline()
                for symbol in module.imports:
                    if symbol.import_by_ordinal is True:
                        if symbol.name is not None:
                            dump.add('{0}.{1} Ordinal[{2}] (Imported by Ordinal)'.format(
                                     module.dll.decode('utf-8'),
                                     symbol.name.decode('utf-8'),
                                     symbol.ordinal))
                        else:
                            dump.add('{0} Ordinal[{1}] (Imported by Ordinal)'.format(
                                module.dll.decode('utf-8'), symbol.ordinal))
                    else:
                        dump.add('{0}.{1} Hint[{2:d}]'.format(
                            module.dll.decode(encoding, 'backslashreplace_'),
                            symbol.name.decode(encoding, 'backslashreplace_'),
                            symbol.hint))

                    if symbol.bound:
                        dump.add_line(' Bound: 0x{0:08X}'.format(symbol.bound))
                    else:
                        dump.add_newline()
                dump.add_newline()


        if hasattr(self, 'DIRECTORY_ENTRY_BOUND_IMPORT'):
            dump.add_header('Bound imports')
            for bound_imp_desc in self.DIRECTORY_ENTRY_BOUND_IMPORT:

                dump.add_lines(bound_imp_desc.struct.dump())
                dump.add_line('DLL: {0}'.format(
                    bound_imp_desc.name.decode(encoding, 'backslashreplace_')))
                dump.add_newline()

                for bound_imp_ref in bound_imp_desc.entries:
                    dump.add_lines(bound_imp_ref.struct.dump(), 4)
                    dump.add_line('DLL: {0}'.format(
                        bound_imp_ref.name.decode(encoding, 'backslashreplace_')), 4)
                    dump.add_newline()


        if hasattr(self, 'DIRECTORY_ENTRY_DELAY_IMPORT'):
            dump.add_header('Delay Imported symbols')
            for module in self.DIRECTORY_ENTRY_DELAY_IMPORT:

                dump.add_lines(module.struct.dump())
                dump.add_newline()

                for symbol in module.imports:
                    if symbol.import_by_ordinal is True:
                        dump.add('{0} Ordinal[{1:d}] (Imported by Ordinal)'.format(
                            module.dll.decode(encoding, 'backslashreplace_'),
                            symbol.ordinal))
                    else:
                        dump.add('{0}.{1} Hint[{2}]'.format(
                            module.dll.decode(encoding, 'backslashreplace_'),
                            symbol.name.decode(encoding, 'backslashreplace_'), symbol.hint))

                    if symbol.bound:
                        dump.add_line(' Bound: 0x{0:08X}'.format(symbol.bound))
                    else:
                        dump.add_newline()
                dump.add_newline()


        if hasattr(self, 'DIRECTORY_ENTRY_RESOURCE'):
            dump.add_header('Resource directory')

            dump.add_lines(self.DIRECTORY_ENTRY_RESOURCE.struct.dump())

            for resource_type in self.DIRECTORY_ENTRY_RESOURCE.entries:

                if resource_type.name is not None:
                    # name = str(resource_type.name) #.string if resource_type.name.string else ''
                    dump.add_line(u'Name: [{0}]'.format(
                        resource_type.name.decode(encoding, 'backslashreplace_')
                        ), 2)
                else:
                    dump.add_line(u'Id: [0x{0:X}] ({1})'.format(
                        resource_type.struct.Id, RESOURCE_TYPE.get(
                            resource_type.struct.Id, '-')),
                        2)

                dump.add_lines(resource_type.struct.dump(), 2)

                if hasattr(resource_type, 'directory'):

                    dump.add_lines(resource_type.directory.struct.dump(), 4)

                    for resource_id in resource_type.directory.entries:

                        if resource_id.name is not None:
                            dump.add_line(u'Name: [{0}]'.format(
                                resource_id.name.decode(
                                    'utf-8', 'backslashreplace_')), 6)
                        else:
                            dump.add_line('Id: [0x{0:X}]'.format(resource_id.struct.Id), 6)

                        dump.add_lines(resource_id.struct.dump(), 6)

                        if hasattr(resource_id, 'directory'):
                            dump.add_lines(resource_id.directory.struct.dump(), 8)

                            for resource_lang in resource_id.directory.entries:
                                if hasattr(resource_lang, 'data'):
                                    dump.add_line(u'\\--- LANG [%d,%d][%s,%s]' % (
                                        resource_lang.data.lang,
                                        resource_lang.data.sublang,
                                        LANG.get(resource_lang.data.lang, '*unknown*'),
                                        get_sublang_name_for_lang( resource_lang.data.lang, resource_lang.data.sublang ) ), 8)
                                    dump.add_lines(resource_lang.struct.dump(), 10)
                                    dump.add_lines(resource_lang.data.struct.dump(), 12)
                            if hasattr(resource_id.directory, 'strings') and resource_id.directory.strings:
                                dump.add_line(u'[STRINGS]' , 10 )
                                for idx, res_string in list(sorted(resource_id.directory.strings.items())):
                                    dump.add_line( '{0:6d}: {1}'.format(idx,
                                        res_string.encode(
                                            'unicode-escape',
                                            'backslashreplace').decode(
                                                'ascii')),
                                        12)

                dump.add_newline()

            dump.add_newline()


        if ( hasattr(self, 'DIRECTORY_ENTRY_TLS') and
             self.DIRECTORY_ENTRY_TLS and
             self.DIRECTORY_ENTRY_TLS.struct ):

            dump.add_header('TLS')
            dump.add_lines(self.DIRECTORY_ENTRY_TLS.struct.dump())
            dump.add_newline()


        if ( hasattr(self, 'DIRECTORY_ENTRY_LOAD_CONFIG') and
             self.DIRECTORY_ENTRY_LOAD_CONFIG and
             self.DIRECTORY_ENTRY_LOAD_CONFIG.struct ):

            dump.add_header('LOAD_CONFIG')
            dump.add_lines(self.DIRECTORY_ENTRY_LOAD_CONFIG.struct.dump())
            dump.add_newline()

        if hasattr(self, 'DIRECTORY_ENTRY_DEBUG'):
            dump.add_header('Debug information')
            for dbg in self.DIRECTORY_ENTRY_DEBUG:
                dump.add_lines(dbg.struct.dump())
                try:
                    dump.add_line('Type: '+DEBUG_TYPE[dbg.struct.Type])
                except KeyError:
                    dump.add_line(
                        'Type: 0x{0:x}(Unknown)'.format(dbg.struct.Type))
                dump.add_newline()
                if dbg.entry:
                    dump.add_lines(dbg.entry.dump(), 4)
                    dump.add_newline()

        if self.has_relocs():
            dump.add_header('Base relocations')
            for base_reloc in self.DIRECTORY_ENTRY_BASERELOC:
                dump.add_lines(base_reloc.struct.dump())
                for reloc in base_reloc.entries:
                    try:
                        dump.add_line('%08Xh %s' % (
                            reloc.rva, RELOCATION_TYPE[reloc.type][16:]), 4)
                    except KeyError:
                        dump.add_line('0x%08X 0x%x(Unknown)' % (
                            reloc.rva, reloc.type), 4)
                dump.add_newline()

        return dump.get_text()
884464
def header_odict(nside,nest=False,coord=None, partial=True):
    """"""
    hdr = odict([])
    hdr['PIXTYPE']=odict([('name','PIXTYPE'),
                          ('value','HEALPIX'),
                          ('comment','HEALPIX pixelisation')])

    ordering = 'NEST' if nest else 'RING'
    hdr['ORDERING']=odict([('name','ORDERING'),
                           ('value',ordering),
                           ('comment','Pixel ordering scheme, either RING or NESTED')])
    hdr['NSIDE']=odict([('name','NSIDE'),
                        ('value',nside),
                        ('comment','Resolution parameter of HEALPIX')])
    if coord:
        hdr['COORDSYS']=odict([('name','COORDSYS'), 
                               ('value',coord), 
                               ('comment','Ecliptic, Galactic or Celestial (equatorial)')])
    
    if not partial:
        hdr['FIRSTPIX']=odict([('name','FIRSTPIX'),
                               ('value',0), 
                               ('comment','First pixel # (0 based)')])
        hdr['LASTPIX']=odict([('name','LASTPIX'),
                              ('value',hp.nside2npix(nside)-1),
                              ('comment','Last pixel # (0 based)')])
    hdr['INDXSCHM']=odict([('name','INDXSCHM'),
                           ('value','EXPLICIT' if partial else 'IMPLICIT'),
                           ('comment','Indexing: IMPLICIT or EXPLICIT')])
    hdr['OBJECT']=odict([('name','OBJECT'), 
                         ('value','PARTIAL' if partial else 'FULLSKY'),
                         ('comment','Sky coverage, either FULLSKY or PARTIAL')])
    return hdr
944
def print_header_row r, c, len, value, color, attr
      #acolor = $promptcolor
      @graphic.printstring  r, c+@left_margin, "%-*s" % [len-@left_margin ,value], color, attr
    end
323238
def print_header(text):
  """"""
  print()
  print('#'*(len(text)+4))
  print('# ' + text + ' #')
  print('#'*(len(text)+4))
  print()