Writes the RtfShape. Some settings are automatically translated into
or require other properties and these are set first.
499672
public void writeContent(final OutputStream result) throws IOException
    {
		this.shapeNr = this.doc.getRandomInt();
		
		this.properties.put("ShapeType", new RtfShapeProperty("ShapeType", this.type));
		if(this.position.isShapeBelowText()) {
			this.properties.put("fBehindDocument", new RtfShapeProperty("fBehindDocument", true));
		}
		if(this.inTable) {
			this.properties.put("fLayoutInCell", new RtfShapeProperty("fLayoutInCell", true));
		}
		if(this.properties.containsKey("posh")) {
			this.position.setIgnoreXRelative(true);
		}
		if(this.properties.containsKey("posv")) {
			this.position.setIgnoreYRelative(true);
		}
    	
    	result.write(OPEN_GROUP);
    	result.write(DocWriter.getISOBytes("\\shp"));
    	result.write(DocWriter.getISOBytes("\\shplid"));
    	result.write(intToByteArray(this.shapeNr));
    	this.position.writeContent(result);
    	switch(this.wrapping) {
    	case SHAPE_WRAP_NONE:
    		result.write(DocWriter.getISOBytes("\\shpwr3"));
    		break;
    	case SHAPE_WRAP_TOP_BOTTOM:
    		result.write(DocWriter.getISOBytes("\\shpwr1"));
    		break;
    	case SHAPE_WRAP_BOTH:
    		result.write(DocWriter.getISOBytes("\\shpwr2"));
    		result.write(DocWriter.getISOBytes("\\shpwrk0"));
    		break;
    	case SHAPE_WRAP_LEFT:
    		result.write(DocWriter.getISOBytes("\\shpwr2"));
    		result.write(DocWriter.getISOBytes("\\shpwrk1"));
    		break;
    	case SHAPE_WRAP_RIGHT:
    		result.write(DocWriter.getISOBytes("\\shpwr2"));
    		result.write(DocWriter.getISOBytes("\\shpwrk2"));
    		break;
    	case SHAPE_WRAP_LARGEST:
    		result.write(DocWriter.getISOBytes("\\shpwr2"));
    		result.write(DocWriter.getISOBytes("\\shpwrk3"));
    		break;
    	case SHAPE_WRAP_TIGHT_BOTH:
    		result.write(DocWriter.getISOBytes("\\shpwr4"));
    		result.write(DocWriter.getISOBytes("\\shpwrk0"));
    		break;
    	case SHAPE_WRAP_TIGHT_LEFT:
    		result.write(DocWriter.getISOBytes("\\shpwr4"));
    		result.write(DocWriter.getISOBytes("\\shpwrk1"));
    		break;
    	case SHAPE_WRAP_TIGHT_RIGHT:
    		result.write(DocWriter.getISOBytes("\\shpwr4"));
    		result.write(DocWriter.getISOBytes("\\shpwrk2"));
    		break;
    	case SHAPE_WRAP_TIGHT_LARGEST:
    		result.write(DocWriter.getISOBytes("\\shpwr4"));
    		result.write(DocWriter.getISOBytes("\\shpwrk3"));
    		break;
    	case SHAPE_WRAP_THROUGH:
    		result.write(DocWriter.getISOBytes("\\shpwr5"));
    		break;
    	default:
    		result.write(DocWriter.getISOBytes("\\shpwr3"));
    	}
    	if(this.inHeader) {
    		result.write(DocWriter.getISOBytes("\\shpfhdr1"));
    	} 
    	this.doc.outputDebugLinebreak(result);
    	result.write(OPEN_GROUP);
    	result.write(DocWriter.getISOBytes("\\*\\shpinst"));
    	Iterator it = this.properties.values().iterator();
    	while(it.hasNext()) {
    		RtfShapeProperty rsp = (RtfShapeProperty) it.next();
    		rsp.setRtfDocument(this.doc);
    		rsp.writeContent(result);
    	}
    	if(!this.shapeText.equals("")) {
    		result.write(OPEN_GROUP);
    		result.write(DocWriter.getISOBytes("\\shptxt"));
    		result.write(DELIMITER);
    		result.write(DocWriter.getISOBytes(this.shapeText));
    		result.write(CLOSE_GROUP);
    	}
    	result.write(CLOSE_GROUP);
    	this.doc.outputDebugLinebreak(result);
    	result.write(CLOSE_GROUP);
		
    }
30537
def write(self, path, data, offset, fh):  # pragma: no cover
        
        # print("write {}".format(path))
        with self.attr_lock:
            base = self.attr[path][BASE_KEY]
            staged = self.attr[path][STAGED_KEY]
            if not staged.closed:
                base.st_size += len(data)
                staged.write(data)
        return len(data)
1086617
def write_to(self, group):
        
        # The HDF5 group where to write data
        items_group = group[self.name]

        nitems = items_group.shape[0]
        items_group.resize((nitems + len(self.data),))
        items_group[nitems:] = self.data
1054029
def _WriteRow(self, output_writer, values, in_bold=False):
    
    row_strings = []
    for value_index, value_string in enumerate(values):
      padding_size = self._column_sizes[value_index] - len(value_string)
      padding_string = ' ' * padding_size

      row_strings.extend([value_string, padding_string])

    row_strings.pop()

    row_strings = ''.join(row_strings)

    if in_bold and not win32console:
      # TODO: for win32console get current color and set intensity,
      # write the header separately then reset intensity.
      row_strings = '\x1b[1m{0:s}\x1b[0m'.format(row_strings)

    output_writer.Write('{0:s}\n'.format(row_strings))
769834
public void setRtfDocument(RtfDocument doc) {
        super.setRtfDocument(doc);
        if(document != null) {
            this.colorNumber = document.getDocumentHeader().getColorNumber(this);
        }
    }
1268961
def WriteToFD(self, fd):
    """"""
    if self.writeback:
      self.writeback.SaveDataToFD(self.writeback_data, fd)
    else:
      raise RuntimeError("Attempting to write a configuration without a "
                         "writeback location.")
1227995
public void writeDefinition(final OutputStream result) throws IOException 
    {
        result.write(DocWriter.getISOBytes("{"));
        result.write(DocWriter.getISOBytes("\\style"));
        result.write(DocWriter.getISOBytes("\\s"));
        result.write(intToByteArray(this.styleNumber));
        result.write(RtfBasicElement.DELIMITER);
        writeParagraphSettings(result);
        super.writeBegin(result);
        result.write(RtfBasicElement.DELIMITER);
        result.write(DocWriter.getISOBytes(this.styleName));
        result.write(DocWriter.getISOBytes(";"));
        result.write(DocWriter.getISOBytes("}"));
        this.document.outputDebugLinebreak(result);   	
    }
377909
def write_frame(self, buf):
        '''
        
        '''
        writer = Writer(buf)
        writer.write_octet(self.type())
        writer.write_short(self.channel_id)

        # Track the position where we're going to write the total length
        # of the frame arguments.
        stream_args_len_pos = len(buf)
        writer.write_long(0)

        stream_method_pos = len(buf)

        writer.write_short(self._class_id)
        writer.write_short(self._weight)
        writer.write_longlong(self._size)

        # Like frame parsing, branch to faster code for default properties
        if self.DEFAULT_PROPERTIES:
            # Track the position where we're going to write the flags.
            flags_pos = len(buf)
            writer.write_short(0)
            flag_bits = 0
            for key, proptype, rfunc, wfunc, mask in self.PROPERTIES:
                val = self._properties.get(key, None)
                if val is not None:
                    flag_bits |= mask
                    wfunc(writer, val)
            writer.write_short_at(flag_bits, flags_pos)
        else:
            shift = 15
            flag_bits = 0
            flags = []
            stack = deque()
            for key, proptype, rfunc, wfunc, mask in self.PROPERTIES:
                val = self._properties.get(key, None)
                if val is not None:
                    if shift == 0:
                        flags.append(flag_bits)
                        flag_bits = 0
                        shift = 15

                    flag_bits |= (1 << shift)
                    stack.append((wfunc, val))

                shift -= 1

            flags.append(flag_bits)
            for flag_bits in flags:
                writer.write_short(flag_bits)
            for method, val in stack:
                method(writer, val)

        # Write the total length back at the beginning of the frame
        stream_len = len(buf) - stream_method_pos
        writer.write_long_at(stream_len, stream_args_len_pos)

        writer.write_octet(0xce)
485303
public void writeContent(final OutputStream result) throws IOException
    {
        try {
            // This is so that all color, font and similar information is processed once, before
            // the header section is written.
            writeSectionDefinition(new RtfNilOutputStream());
            
            this.codePage.writeDefinition(result);
            this.fontList.writeDefinition(result);
            this.colorList.writeDefinition(result);
            this.stylesheetList.writeDefinition(result);
            this.listTable.writeDefinition(result);
            this.generator.writeContent(result);
            this.infoGroup.writeContent(result);
            this.protectionSetting.writeDefinition(result);
            this.pageSetting.writeDefinition(result);
            
            writeSectionDefinition(result);
        } catch(IOException ioe) {
            ioe.printStackTrace();
        }
    }
1171574
public void writeContent(final OutputStream result) throws IOException
    {
    	
        if(this.topLevelElement) {
            result.write(RtfParagraph.PARAGRAPH_DEFAULTS);
            switch(alignment) {
                case Element.ALIGN_LEFT:
                    result.write(RtfParagraphStyle.ALIGN_LEFT);
                    break;
                case Element.ALIGN_RIGHT:
                    result.write(RtfParagraphStyle.ALIGN_RIGHT);
                    break;
                case Element.ALIGN_CENTER:
                    result.write(RtfParagraphStyle.ALIGN_CENTER);
                    break;
                case Element.ALIGN_JUSTIFIED:
                    result.write(RtfParagraphStyle.ALIGN_JUSTIFY);
                    break;
            }
        }
        result.write(OPEN_GROUP);
        result.write(PICTURE_GROUP);
        result.write(OPEN_GROUP);
        result.write(PICTURE);
        switch(imageType) {
        	case Image.ORIGINAL_JPEG:
        	    result.write(PICTURE_JPEG);
        		break;
        	case Image.ORIGINAL_PNG:
            case Image.ORIGINAL_GIF:
        	    result.write(PICTURE_PNG);
        		break;
        	case Image.ORIGINAL_WMF:
        	case Image.ORIGINAL_BMP:
        	    result.write(PICTURE_WMF);
        		break;
        }
        result.write(PICTURE_WIDTH);
        result.write(intToByteArray((int) width));
        result.write(PICTURE_HEIGHT);
        result.write(intToByteArray((int) height));
        if(this.document.getDocumentSettings().isWriteImageScalingInformation()) {
            result.write(PICTURE_SCALE_X);
            result.write(intToByteArray((int)(100 * plainWidth / width)));
            result.write(PICTURE_SCALE_Y);
            result.write(intToByteArray((int)(100 * plainHeight / height)));
        }
        if(this.document.getDocumentSettings().isImagePDFConformance()) {
            result.write(PICTURE_SCALED_WIDTH);
            result.write(intToByteArray((int) (plainWidth * RtfElement.TWIPS_FACTOR)));
            result.write(PICTURE_SCALED_HEIGHT);
            result.write(intToByteArray((int) (plainHeight * RtfElement.TWIPS_FACTOR)));
        } else {
            if(this.width != this.plainWidth || this.imageType == Image.ORIGINAL_BMP) {
                result.write(PICTURE_SCALED_WIDTH);
                result.write(intToByteArray((int) (plainWidth * PIXEL_TWIPS_FACTOR)));
            }
            if(this.height != this.plainHeight || this.imageType == Image.ORIGINAL_BMP) {
                result.write(PICTURE_SCALED_HEIGHT);
                result.write(intToByteArray((int) (plainHeight * PIXEL_TWIPS_FACTOR)));
            }
        }

        if(this.document.getDocumentSettings().isImageWrittenAsBinary()) {
        	//binary
        	result.write('\n');
        	result.write(PICTURE_BINARY_DATA);
        	result.write(intToByteArray(imageDataSize()));
            result.write(DELIMITER);
            if(result instanceof RtfByteArrayBuffer) {
            	((RtfByteArrayBuffer)result).append(imageData);
            } else {
            	for(int k = 0; k < imageData.length; k++) {
					result.write(imageData[k]);
				}
            }
        } else {
        	//hex encoded
            result.write(DELIMITER);
        	result.write('\n');
        	writeImageDataHexEncoded(result);
        }
        
        result.write(CLOSE_GROUP);
        result.write(CLOSE_GROUP);
        if(this.topLevelElement) {
            result.write(RtfParagraph.PARAGRAPH);
            result.write(RtfParagraph.PARAGRAPH);
        }
        result.write('\n');    	
    }
806007
def write_frames(self, frames_out):
        
        self.check_for_errors()
        self._connection.write_frames(self.channel_id, frames_out)
129313
def write_vcf(path, callset, rename=None, number=None, description=None,
              fill=None, write_header=True):
    """"""

    names, callset = normalize_callset(callset)

    with open(path, 'w') as vcf_file:
        if write_header:
            write_vcf_header(vcf_file, names, callset=callset, rename=rename,
                             number=number, description=description)
        write_vcf_data(vcf_file, names, callset=callset, rename=rename, fill=fill)
963496
def write(self, destination, source_model, name=None):
        
        if os.path.exists(destination + ".shp"):
            os.system("rm %s.*" % destination)
        self.destination = destination
        self.filter_params(source_model)

        w_area = shapefile.Writer(shapefile.POLYGON)
        w_point = shapefile.Writer(shapefile.POINT)
        w_simple = shapefile.Writer(shapefile.POLYLINE)
        w_simple3d = shapefile.Writer(shapefile.POLYGONZ)
        w_complex = shapefile.Writer(shapefile.POLYLINEZ)
        w_planar = shapefile.Writer(shapefile.POLYGONZ)

        register_fields(w_area)
        register_fields(w_point)
        register_fields(w_simple)
        register_fields(w_simple3d)
        register_fields(w_complex)
        register_fields(w_planar)

        for src in source_model.sources:

            # Order is important here
            if "areaSource" in src.tag:
                set_params(w_area, src)
                set_area_geometry(w_area, src)
            elif "pointSource" in src.tag:
                set_params(w_point, src)
                set_point_geometry(w_point, src)
            elif "complexFaultSource" in src.tag:
                set_params(w_complex, src)
                set_complex_fault_geometry(w_complex, src)
            elif "simpleFaultSource" in src.tag:
                set_params(w_simple, src)
                set_simple_fault_geometry(w_simple, src)
                # Create the 3D polygon
                set_params(w_simple3d, src)
                set_simple_fault_geometry_3D(w_simple3d, src)
            elif "characteristicFaultSource" in src.tag:
                src_taglist = get_taglist(src)
                surface_node = src.nodes[src_taglist.index("surface")]
                for subnode in surface_node:
                    if "simpleFaultGeometry" in subnode.tag:
                        set_params(w_simple, src)
                        set_params(w_simple3d, src)
                    elif "complexFaultGeometry" in subnode.tag:
                        set_params(w_complex, src)
                    elif "planarSurface" in subnode.tag:
                        set_params(w_planar, src)
                    else:
                        raise ValueError(
                            'Geometry class %s not recognized'
                            % subnode.tag)
                    set_characteristic_geometry(w_simple, w_simple3d,
                                                w_complex, w_planar, src)
            else:
                raise ValueError('Source type %s not recognized'
                                 % src.tag)

        root = self.destination
        if len(w_area.shapes()) > 0:
            w_area.save('%s_area' % root)
        if len(w_point.shapes()) > 0:
            w_point.save('%s_point' % root)
        if len(w_complex.shapes()) > 0:
            w_complex.save('%s_complex' % root)
        if len(w_simple.shapes()) > 0:
            w_simple.save('%s_simple' % root)
            w_simple3d.save('%s_simple3d' % root)
        if len(w_planar.shapes()) > 0:
            w_planar.save('%s_planar' % root)
158530
public static void writeObject(DataOutput out, Object instance,
                                 Class declaredClass, 
                                 Configuration conf) throws IOException {

    if (instance == null) {                       // null
      instance = new NullInstance(declaredClass, conf);
      declaredClass = Writable.class;
    }
    
    // handle FastWritable first (including ShortVoid)
    if (instance instanceof FastWritable) {
      FastWritable fwInstance = (FastWritable) instance;
      byte[] serializedName = fwInstance.getSerializedName();
      out.write(serializedName, 0, serializedName.length);
      fwInstance.write(out);
      return;
    }
    
    // write declared name
    writeStringCached(out, declaredClass.getName());

    if (declaredClass.isArray()) {                // array
      int length = Array.getLength(instance);
      out.writeInt(length);
      for (int i = 0; i < length; i++) {
        writeObject(out, Array.get(instance, i),
                    declaredClass.getComponentType(), conf);
      }
      
    } else if (declaredClass == String.class) {   // String
      UTF8.writeStringOpt(out, (String)instance);
      
    } else if (declaredClass.isPrimitive()) {     // primitive type

      if (declaredClass == Boolean.TYPE) {        // boolean
        out.writeBoolean(((Boolean)instance).booleanValue());
      } else if (declaredClass == Character.TYPE) { // char
        out.writeChar(((Character)instance).charValue());
      } else if (declaredClass == Byte.TYPE) {    // byte
        out.writeByte(((Byte)instance).byteValue());
      } else if (declaredClass == Short.TYPE) {   // short
        out.writeShort(((Short)instance).shortValue());
      } else if (declaredClass == Integer.TYPE) { // int
        out.writeInt(((Integer)instance).intValue());
      } else if (declaredClass == Long.TYPE) {    // long
        out.writeLong(((Long)instance).longValue());
      } else if (declaredClass == Float.TYPE) {   // float
        out.writeFloat(((Float)instance).floatValue());
      } else if (declaredClass == Double.TYPE) {  // double
        out.writeDouble(((Double)instance).doubleValue());
      } else if (declaredClass == Void.TYPE) {    // void
      } else {
        throw new IllegalArgumentException("Not a primitive: "+declaredClass);
      }
    } else if (declaredClass.isEnum()) {         // enum
      writeStringCached(out, ((Enum)instance).name());
    } else if (Writable.class.isAssignableFrom(declaredClass)) { // Writable
      writeStringCached(out, instance.getClass().getName());
      ((Writable)instance).write(out);

    } else {
      throw new IOException("Can't write: "+instance+" as "+declaredClass);
    }
  }
371830
def write(self, f):
        
        rdf = ET.Element(NS('rdf', 'RDF'), nsmap=XML_NS)

        # TODO: TopLevel Annotations
        sequence_values = sorted(self._sequences.values(), key=lambda x: x.identity)
        self._add_to_root(rdf, sequence_values)
        component_values = sorted(self._components.values(), key=lambda x: x.identity)
        self._add_to_root(rdf, component_values)
        model_values = sorted(self._models.values(), key=lambda x: x.identity)
        self._add_to_root(rdf, model_values)
        module_values = sorted(self._modules.values(), key=lambda x: x.identity)
        self._add_to_root(rdf, module_values)
        collection_values = sorted(self._collections.values(), key=lambda x: x.identity)
        self._add_to_root(rdf, collection_values)
        annotation_values = sorted(self._annotations.values(), key=lambda x: x.identity)
        self._add_to_root(rdf, annotation_values)

        f.write(ET.tostring(rdf,
                            pretty_print=True,
                            xml_declaration=True,
                            encoding='utf-8'))
82436
public void writeContent(final OutputStream result) throws IOException
    {
        result.write(PARAGRAPH_DEFAULTS);
        result.write(PLAIN);
        if(inTable) {
            result.write(IN_TABLE);
        }
        if(this.lineLeading > 0) {
            result.write(LINE_SPACING);
            result.write(intToByteArray(this.lineLeading));
        }
        for(int i = 0; i < chunks.size(); i++) {
        	RtfBasicElement rbe = (RtfBasicElement) chunks.get(i);
        	rbe.writeContent(result);
        }
    }
244052
@Override
	protected DocWriter createWriter(final MBasicTable table, final Document document,
			final OutputStream out) {
		final RtfWriter2 writer = RtfWriter2.getInstance(document, out);

		// title
		final String title = buildTitle(table);
		if (title != null) {
			final HeaderFooter header = new RtfHeaderFooter(new Paragraph(title));
			header.setAlignment(Element.ALIGN_LEFT);
			header.setBorder(Rectangle.NO_BORDER);
			document.setHeader(header);
			document.addTitle(title);
		}

		// advanced page numbers : x/y
		final Paragraph footerParagraph = new Paragraph();
		final Font font = FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL);
		footerParagraph.add(new RtfPageNumber(font));
		footerParagraph.add(new Phrase(" / ", font));
		footerParagraph.add(new RtfTotalPageNumber(font));
		footerParagraph.setAlignment(Element.ALIGN_CENTER);
		final HeaderFooter footer = new RtfHeaderFooter(footerParagraph);
		footer.setBorder(Rectangle.TOP);
		document.setFooter(footer);

		return writer;
	}