write out types module to file descriptor.
351643
def writeTypes(self, fd):
        
        print >>fd, '#'*50
        print >>fd, '# file: %s.py' %self.getTypesModuleName()
        print >>fd, '#'
        print >>fd, '# schema types generated by "%s"' %self.__class__
        print >>fd, '#    %s' %' '.join(sys.argv)
        print >>fd, '#'
        print >>fd, '#'*50
                  
        print >>fd, TypesHeaderContainer()
        self.gatherNamespaces()
        for l in self.usedNamespaces.values():
            sd = SchemaDescription(do_extended=self.do_extended, 
                                   extPyClasses=self.extPyClasses)
            for schema in l:
                sd.fromSchema(schema)
            sd.write(fd)
334494
function write_binary_type(out, opts) {
	switch(opts.type) {
		case "string":
		case "base64":
		case "binary":
			var bstr = "";
			// $FlowIgnore
			for(var i = 0; i < out.length; ++i) bstr += String.fromCharCode(out[i]);
			return opts.type == 'base64' ? Base64.encode(bstr) : opts.type == 'string' ? utf8read(bstr) : bstr;
		case "file": return write_dl(opts.file, out);
		case "buffer": return out;
		default: throw new Error("Unrecognized type " + opts.type);
	}
}
468100
def write_file(fname, info):
    """"""
    with open(fname, 'w') as outfile:
        # File header
        outfile.write('# Copyright (c) 2018 MetPy Developers.\n')
        outfile.write('# Distributed under the terms of the BSD 3-Clause License.\n')
        outfile.write('# SPDX-License-Identifier: BSD-3-Clause\n\n')
        outfile.write('# flake8: noqa\n')
        outfile.write('# Generated file -- do not modify\n')

        # Variable descriptions
        outfile.write('descriptions = {')
        outdata = ',\n                '.join('"{name}": "{desc}"'.format(
            **i) for i in info if need_desc(i))
        outfile.write(outdata)
        outfile.write('}\n\n')

        # Now the struct format
        outfile.write('fields = [')
        outdata = ',\n          '.join('({fname}, "{fmt}")'.format(
            fname=field_name(i), **i) for i in info)
        outfile.write(outdata)
        outfile.write(']\n')
142554
def _from_python_type(self, obj, field, pytype):
        """"""
        json_schema = {
            'title': field.attribute or field.name,
        }

        for key, val in TYPE_MAP[pytype].items():
            json_schema[key] = val

        if field.dump_only:
            json_schema['readonly'] = True

        if field.default is not missing:
            json_schema['default'] = field.default

        # NOTE: doubled up to maintain backwards compatibility
        metadata = field.metadata.get('metadata', {})
        metadata.update(field.metadata)

        for md_key, md_val in metadata.items():
            if md_key == 'metadata':
                continue
            json_schema[md_key] = md_val

        if isinstance(field, fields.List):
            json_schema['items'] = self._get_schema_for_field(
                obj, field.container
            )
        return json_schema
777619
function(type) {
		//define if put type is present in config
		if (config.moduleTypes.indexOf(type) > -1) {
            config.moduleType = type;
            fs.writeFile(path.resolve(__dirname, 'config.json'), JSON.stringify(config, null, 4), 'utf8', function (err) {
                if (err) {
                    return console.log(err);
                }
            });
		} else {
			return console.log('Wrong type, available types: %j', config.moduleTypes);
		}
	}
1331246
def _write_docs(module_list, output_dir):
    ''''''
    for module_meta in module_list:
        directory = module_meta['directory']
        # Ensure target directory
        if directory and not path.isdir(directory):
            makedirs(directory)

        # Write the file
        file = open(module_meta['output'], 'w')
        file.write(module_meta['content'])
        file.close()
707012
def pytype_to_deps(t):
    
    res = set()
    for hpp_dep in pytype_to_deps_hpp(t):
        res.add(os.path.join('pythonic', 'types', hpp_dep))
        res.add(os.path.join('pythonic', 'include', 'types', hpp_dep))
    return res
1353059
function formatFileOutput(mappings, type) {
  var string = JSON.stringify(mappings, null, 2);
  if (type === '.js') {
    return 'module.exports=' + string;
  } else if (type === '.json') {
    return string;
  }
}
719603
def write(self, endpoints, filename):
        # type: (List[EndpointDescription], str) -> None
        
        with open(filename, "w") as filep:
            filep.write(self.to_string(endpoints))
537977
def fill_constants_types(module_name, elements):
    
    for elem, intrinsic in elements.items():
        if isinstance(intrinsic, dict):  # Submodule case
            fill_constants_types(module_name + (elem,), intrinsic)
        elif isinstance(intrinsic, ConstantIntr):
            # use introspection to get the Python constants types
            cst = getattr(__import__(".".join(module_name)), elem)
            intrinsic.signature = type(cst)
513775
def files_type(fs0, fs1, files):
    """"""
    for file_meta in files['deleted_files']:
        file_meta['type'] = fs0.file(file_meta['path'])
    for file_meta in files['created_files'] + files['modified_files']:
        file_meta['type'] = fs1.file(file_meta['path'])

    return files
1101511
def dump_declarations(declarations, file_path):
    

    with open(file_path, "w+") as f:
        print_declarations(declarations, writer=f.write)
717402
def import_from_stdlib(name):
    """"""
    import os
    import types
    import code  # arbitrary module which stays in the same dir as pdb
    stdlibdir, _ = os.path.split(code.__file__)
    pyfile = os.path.join(stdlibdir, name + '.py')
    result = types.ModuleType(name)
    exec(compile(open(pyfile).read(), pyfile, 'exec'), result.__dict__)
    return result
100093
private void writeSimple(Class<?> declaredType, Object value) throws IOException {
        // simple types have no need to write a type object
        Class<?> realType = value.getClass();
        if (realType == Integer.class) {
            output.writeInt(((Integer) value).intValue());
            return;
        } else if (realType == Double.class) {
            double dbl = ((Double) value).doubleValue();
            if (Double.isNaN(dbl) == false && Double.isInfinite(dbl) == false) {
                output.writeDouble(dbl);
                return;
            }
        } else if (realType == Boolean.class) {
            output.writeBoolean(((Boolean) value).booleanValue());
            return;
        }
        
        // handle no declared type and subclasses
        Class<?> effectiveType = declaredType;
        boolean requiresClose = false;
        if (declaredType == Object.class) {
            if (realType != String.class) {
                effectiveType = settings.getConverter().findTypedConverter(realType).getEffectiveType();
                String typeStr = SerTypeMapper.encodeType(effectiveType, settings, basePackage, knownTypes);
                output.writeObjectStart();
                output.writeObjectKeyValue(TYPE, typeStr);
                output.writeObjectKey(VALUE);
                requiresClose = true;
            } else {
                effectiveType = realType;
            }
        } else if (settings.getConverter().isConvertible(declaredType) == false) {
            effectiveType = settings.getConverter().findTypedConverter(realType).getEffectiveType();
            String typeStr = SerTypeMapper.encodeType(effectiveType, settings, basePackage, knownTypes);
            output.writeObjectStart();
            output.writeObjectKeyValue(TYPE, typeStr);
            output.writeObjectKey(VALUE);
            requiresClose = true;
        }
        
        // long/short/byte/float only processed now to ensure that exact numeric type can be identified
        if (realType == Long.class) {
            output.writeLong(((Long) value).longValue());
            
        } else if (realType == Short.class) {
            output.writeInt(((Short) value).shortValue());
            
        } else if (realType == Byte.class) {
            output.writeInt(((Byte) value).byteValue());
            
        } else if (realType == Float.class) {
            output.writeFloat(((Float) value).floatValue());
            
        } else {
            // write as a string
            try {
                String converted = settings.getConverter().convertToString(effectiveType, value);
                if (converted == null) {
                    throw new IllegalArgumentException("Unable to write because converter returned a null string: " + value);
                }
                output.writeString(converted);
            } catch (RuntimeException ex) {
                throw new IllegalArgumentException(
                        "Unable to convert type " + effectiveType.getName() + " declared as " + declaredType.getName(), ex);
            }
        }
        
        // close open map
        if (requiresClose) {
            output.writeObjectEnd();
        }
    }
1080160
public void writeHeaders(ShapeType type) throws IOException {
		try {
			handler = type.getShapeHandler();
		} catch (ShapefileException se) {
			throw new IOException("Error with type " + type, se);
		}
        if(indexBuffer != null) {
            indexBuffer.flush();
        }
        if(shapeBuffer != null) {
            shapeBuffer.flush();
        }
        long fileLength = shpChannel.position();
        shpChannel.position(0);
        shxChannel.position(0);
		ShapefileHeader header = new ShapefileHeader();
        Envelope writeBounds = bounds;
        if(writeBounds == null) {
            writeBounds = new Envelope();
        }
        indexBuffer = new WriteBufferManager(shxChannel);
        shapeBuffer = new WriteBufferManager(shpChannel);
		header.write(shapeBuffer, type, cnt, (int)(fileLength / 2),
                writeBounds.getMinX(), writeBounds.getMinY(), writeBounds.getMaxX(), writeBounds
						.getMaxY());
		header.write(indexBuffer, type, cnt,
                50 + 4 * cnt, writeBounds.getMinX(),
                writeBounds.getMinY(), writeBounds.getMaxX(), writeBounds.getMaxY());
		offset = 50;
		this.type = type;
	}
323362
public static void writeClasses(ObjectOutput out, Class<?>[] types)
            throws java.io.IOException {
        int i;

        if (types.length > Byte.MAX_VALUE) {
            throw new RuntimeException("to many dimensions");
        }
        out.writeByte((byte) types.length);
        for (i = 0; i < types.length; i++) {
            write(out, types[i]);
        }
    }
800139
def write_module_file(name, path, package):
    '''
    '''
    file_path = join(path, '%s.rst' % name)
    mod_file = open(file_path, 'w')

    mod_file.write('%s\n' % AUTOGEN)
    mod_file.write('%s\n' % name.title())
    mod_file.write('=' * len(name))
    mod_file.write('\n\n')
    mod_file.write('.. toctree::\n')
    mod_file.write('   :maxdepth: 1\n\n')
    mod_file.write('.. automodule:: %s.%s\n' % (package, name))
    mod_file.write('   :members:\n')
    mod_file.write('   :undoc-members:\n')
    mod_file.write('   :show-inheritance:\n')