converts a DiscourseDocumentGraph into a Geoff file and
    writes it to the given file (or file path).
760520
def write_geoff(discoursegraph, output_file):
    
    if isinstance(output_file, str):
        with open(output_file, 'w') as outfile:
            outfile.write(convert_to_geoff(discoursegraph))
    else:  # output_file is a file object
        output_file.write(convert_to_geoff(discoursegraph))
412357
public static void writeStringToFile(String path, String toWrite, JavaSparkContext sc) throws IOException {
        writeStringToFile(path, toWrite, sc.sc());
    }
239161
public void toFile(final File file) throws GitChangelogRepositoryException, IOException {
    createParentDirs(file);
    write(render().getBytes("UTF-8"), file);
  }
1340908
private <T,E extends TypedEdge<T>> void write(
                         Multigraph<T,E> g, File f, Map<T,Color> edgeColors, 
                         boolean useColors, Indexer<String> vertexLabels,
                         boolean useLabels) throws IOException {

        DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = null;
        try {
            docBuilder = dbfac.newDocumentBuilder();
        } catch (ParserConfigurationException pce) {
            throw new IOError(new IOException(pce));
        }
        Document doc = docBuilder.newDocument();

        Element root = doc.createElement("gexf");
        root.setAttribute("xmlns","http://www.gexf.net/1.2draft");
        root.setAttribute("xmlns:viz", "http://www.gexf.net/1.2draft/viz");
        root.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
        root.setAttribute("version","1.2");
        root.setAttribute("xsi:schemaLocation","http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd");
        doc.appendChild(root);

        Element graph = doc.createElement("graph");
        graph.setAttribute("defaultedgetype","undirected");
        root.appendChild(graph);

        Element nodes = doc.createElement("nodes");
        graph.appendChild(nodes);
        Element edges = doc.createElement("edges");
        graph.appendChild(edges);

        IntIterator vIter = g.vertices().iterator();
        while (vIter.hasNext()) {
            int vertex = vIter.next();
            Element node = doc.createElement("node");
            node.setAttribute("id", String.valueOf(vertex));
            if (useLabels) 
                node.setAttribute("label", vertexLabels.lookup(vertex));
            else
                node.setAttribute("label", String.valueOf(vertex));
            nodes.appendChild(node);
        }

        ColorGenerator cg = null;
        if (useColors)
            cg = new ColorGenerator();

        int edgeId = 0;
        for (E e : g.edges()) {
            Element edge = doc.createElement("edge");
            edges.appendChild(edge);
            edge.setAttribute("id", "" + (edgeId++));
            edge.setAttribute("source", String.valueOf(e.from()));
            edge.setAttribute("target", String.valueOf(e.to()));
            edge.setAttribute("label", String.valueOf(e.edgeType()));
            if (useColors) {
                Element cEdge = doc.createElement("viz:color");
                edge.appendChild(cEdge);
                Color c = edgeColors.get(e.edgeType());
                if (c == null) {
                    c = cg.next();
                    edgeColors.put(e.edgeType(), c);
                }
                cEdge.setAttribute("r", String.valueOf(c.getRed()));
                cEdge.setAttribute("g", String.valueOf(c.getGreen()));
                cEdge.setAttribute("b", String.valueOf(c.getBlue()));
            }
        }

        // Set up a transformer
        try {
            TransformerFactory transfac = TransformerFactory.newInstance();
            Transformer trans = transfac.newTransformer();
            trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
            trans.setOutputProperty(OutputKeys.INDENT, "yes");
            trans.setOutputProperty(
                "{http://xml.apache.org/xslt}indent-amount", "2");
        
            // Create string from xml tree
            BufferedOutputStream bos = 
                new BufferedOutputStream(new FileOutputStream(f));
            StreamResult result = new StreamResult(bos);
            DOMSource source = new DOMSource(doc);
            trans.transform(source, result);
            bos.close();         
        } catch (TransformerException te) {
            throw new IOError(new IOException(te));
        }
    }
993681
def write_file(file_path, content):
    
    handler = open(file_path, 'w+')
    handler.write(content)
    handler.close()
596639
public void write(WeightedGraph<? extends WeightedEdge> g, 
                      File gexfFile, Indexer<String> vertexLabels) 
            throws IOException {

        DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = null;
        try {
            docBuilder = dbfac.newDocumentBuilder();
        } catch (ParserConfigurationException pce) {
            throw new IOError(new IOException(pce));
        }
        Document doc = docBuilder.newDocument();

        Element root = doc.createElement("gexf");
        root.setAttribute("xmlns","http://www.gexf.net/1.2draft");
        root.setAttribute("xmlns:viz", "http://www.gexf.net/1.2draft/viz");
        root.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
        root.setAttribute("version","1.2");
        root.setAttribute("xsi:schemaLocation","http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd");
        doc.appendChild(root);

        Element graph = doc.createElement("graph");
        graph.setAttribute("defaultedgetype","undirected");
        root.appendChild(graph);

        Element nodes = doc.createElement("nodes");
        graph.appendChild(nodes);
        Element edges = doc.createElement("edges");
        graph.appendChild(edges);

        IntIterator vIter = g.vertices().iterator();
        while (vIter.hasNext()) {
            int vertex = vIter.next();
            Element node = doc.createElement("node");
            String vLabel = (vertexLabels == null)
                ? String.valueOf(vertex)
                : vertexLabels.lookup(vertex);
            if (vLabel == null)
                vLabel = String.valueOf(vertex);
            node.setAttribute("id", vLabel);
            node.setAttribute("label", vLabel);
            nodes.appendChild(node);
        }

        int edgeId = 0;
        for (WeightedEdge e : g.edges()) {
            Element edge = doc.createElement("edge");
            edges.appendChild(edge);
            edge.setAttribute("id", "" + (edgeId++));

            String sourceLabel = (vertexLabels == null)
                ? String.valueOf(e.from())
                : vertexLabels.lookup(e.from());
            if (sourceLabel == null)
                sourceLabel = String.valueOf(e.from());

            String targetLabel = (vertexLabels == null)
                ? String.valueOf(e.to())
                : vertexLabels.lookup(e.to());
            if (targetLabel == null)
                targetLabel = String.valueOf(e.to());

            edge.setAttribute("source", sourceLabel);
            edge.setAttribute("target", targetLabel);
            edge.setAttribute("weight", String.valueOf(e.weight()));
        }

        // Set up a transformer
        try {
            TransformerFactory transfac = TransformerFactory.newInstance();
            Transformer trans = transfac.newTransformer();
            trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
            trans.setOutputProperty(OutputKeys.INDENT, "yes");
            trans.setOutputProperty(
                "{http://xml.apache.org/xslt}indent-amount", "2");
        
            // Create string from xml tree
            BufferedOutputStream bos = 
                new BufferedOutputStream(new FileOutputStream(gexfFile));
            StreamResult result = new StreamResult(bos);
            DOMSource source = new DOMSource(doc);
            trans.transform(source, result);
            bos.close();         
        } catch (TransformerException te) {
            throw new IOError(new IOException(te));
        }
    }
142407
def to_file(output_file, encoder=EliotJSONEncoder):
    
    Logger._destinations.add(
        FileDestination(file=output_file, encoder=encoder)
    )
933118
def write_file(path, data):
    """"""
    with open(path, 'w') as f:
        log.debug('setting %s contents:\n%s', path, data)
        f.write(data)
    return f
733301
def merging_cli(debug=False):
    
    parser = argparse.ArgumentParser()

    parser.add_argument('-t', '--tiger-file',
                        help='TigerXML (syntax) file to be merged')
    parser.add_argument('-r', '--rst-file',
                        help='RS3 (rhetorical structure) file to be merged')
    parser.add_argument('-a', '--anaphoricity-file',
                        help='anaphoricity file to be merged')
    parser.add_argument('-c', '--conano-file',
                        help='conano file to be merged')
    parser.add_argument('-m', '--mmax-file',
                        help='MMAX2 file to be merged')
    parser.add_argument(
        '-o', '--output-format', default='dot',
        help=('output format: brackets, brat, dot, pickle, geoff, gexf, graphml, '
              'neo4j, exmaralda, conll, paula, no-output'))
    parser.add_argument('output_file', nargs='?', default=sys.stdout)

    args = parser.parse_args(sys.argv[1:])

    for filepath in (args.tiger_file, args.rst_file, args.anaphoricity_file,
                     args.conano_file):
        if filepath:  # if it was specified on the command line
            assert os.path.isfile(filepath), \
                "File '{}' doesn't exist".format(filepath)

    # create an empty document graph. merge it with other graphs later on.
    discourse_docgraph = DiscourseDocumentGraph()

    if args.tiger_file:
        from discoursegraphs.readwrite.tiger import TigerDocumentGraph
        tiger_docgraph = TigerDocumentGraph(args.tiger_file)
        discourse_docgraph.merge_graphs(tiger_docgraph)

    if args.rst_file:
        rst_graph = dg.read_rs3(args.rst_file)
        discourse_docgraph.merge_graphs(rst_graph)

    if args.anaphoricity_file:
        from discoursegraphs.readwrite import AnaphoraDocumentGraph
        anaphora_graph = AnaphoraDocumentGraph(args.anaphoricity_file)
        discourse_docgraph.merge_graphs(anaphora_graph)
        # the anaphora doc graph only contains trivial edges from its root
        # node.
        try:
            discourse_docgraph.remove_node('anaphoricity:root_node')
        except networkx.NetworkXError as e:  # ignore if the node doesn't exist
            pass

    if args.conano_file:
        from discoursegraphs.readwrite import ConanoDocumentGraph
        conano_graph = ConanoDocumentGraph(args.conano_file)
        discourse_docgraph.merge_graphs(conano_graph)

    if args.mmax_file:
        from discoursegraphs.readwrite import MMAXDocumentGraph
        mmax_graph = MMAXDocumentGraph(args.mmax_file)
        discourse_docgraph.merge_graphs(mmax_graph)

    if isinstance(args.output_file, str):  # if we're not piping to stdout ...
        # we need abspath to handle files in the current directory
        path_to_output_file = \
            os.path.dirname(os.path.abspath(args.output_file))
        if not os.path.isdir(path_to_output_file):
            create_dir(path_to_output_file)

    if args.output_format == 'dot':
        write_dot(discourse_docgraph, args.output_file)
    elif args.output_format == 'brat':
        dg.write_brat(discourse_docgraph, args.output_file)
    elif args.output_format == 'brackets':
        dg.write_brackets(discourse_docgraph, args.output_file)
    elif args.output_format == 'pickle':
        import cPickle as pickle
        with open(args.output_file, 'wb') as pickle_file:
            pickle.dump(discourse_docgraph, pickle_file)
    elif args.output_format in ('geoff', 'neo4j'):
        from discoursegraphs.readwrite.neo4j import write_geoff
        write_geoff(discourse_docgraph, args.output_file)
        print ''  # this is just cosmetic for stdout
    elif args.output_format == 'gexf':
        dg.write_gexf(discourse_docgraph, args.output_file)
    elif args.output_format == 'graphml':
        dg.write_graphml(discourse_docgraph, args.output_file)
    elif args.output_format == 'exmaralda':
        from discoursegraphs.readwrite.exmaralda import write_exb
        write_exb(discourse_docgraph, args.output_file)
    elif args.output_format == 'conll':
        from discoursegraphs.readwrite.conll import write_conll
        write_conll(discourse_docgraph, args.output_file)
    elif args.output_format == 'paula':
        from discoursegraphs.readwrite.paulaxml.paula import write_paula
        write_paula(discourse_docgraph, args.output_file)

    elif args.output_format == 'no-output':
        pass  # just testing if the merging works
    else:
        raise ValueError(
            "Unsupported output format: {}".format(args.output_format))

    if debug:
        print "Merged successfully: ", args.tiger_file
739295
def write_file(path, content, mode='w'):
    # type: (Text, Union[Text,bytes], Text) -> None
    
    from peltak.core import context
    from peltak.core import log

    if context.get('pretend', False):
        log.info("Would overwrite <34>{path}<32> with:\n<90>{content}",
                 path=path,
                 content=content)
    else:
        with open(path, mode) as fp:
            fp.write(content)
520781
def export_to_file(self, filepath, level_prefix = '  '):
        
        xmldom = self.export_to_dom()
        xmlstr = xmldom.toprettyxml(level_prefix, '\n',)


        f = open(filepath, 'w')
        f.write(xmlstr)
        f.close()
396629
function writeFile(file, content) {
    fs.writeFileSync(file, content);
    files.push(path.relative(app.components.get('path'), file));
}
552617
def write_documents(corpus, target, featureset_name, metadata_fields=[]):
    

    docpath = target + '_docs.txt'
    metapath = target + '_meta.csv'

    features = corpus.features[featureset_name].features
    ftype = type(corpus.features[featureset_name])
    index = corpus.features[featureset_name].index

    try:
        docFile = open(docpath, 'wb')
    except IOError:
        raise IOError('Invalid target. Could not open files for writing.')

    # Generate metadata.
    with codecs.open(metapath, 'w', encoding='utf-8') as f:
        writer = csv.writer(f)
        writer.writerow([corpus.index_by] + list(metadata_fields))
        for i, p in corpus.indexed_papers.iteritems():
            getter = lambda m: getattr(p, m) if hasattr(p, m) else None
            writer.writerow([i] + list(map(getter, metadata_fields)))

    # Write documents content.
    with codecs.open(docpath, 'w', encoding='utf-8') as f:
        for i, p in corpus.indexed_papers.iteritems():
            if i in features:
                row = [i, u'en']
                if ftype is FeatureSet:
                    row += [u' '.join(repeat(e, c)) for e, c in features[i]]
                elif ftype is StructuredFeatureSet:
                    row += features[i]
                f.write(u'\t'.join(row) + u'\n')

    return docpath, metapath
326788
function writeFile(pathToFile, content, verbose) {
  const directory = path.dirname(pathToFile);

  // Create directory if it doesn't exist
  if (!fs.existsSync(directory)) {
    fs.mkdirSync(directory);
  }

  // Try to write file to disk to the given location
  fs.writeFile(pathToFile, content, { flag: 'w' }, (error) => {
    if (error) {
      throw new Error(error);
    }

    // Log success message to the console if in verbose mode only
    if (verbose) {
      const successMessage = `\nVersion file written to ${chalk.green(pathToFile)}`;

      console.log(successMessage);
    }
  });
}
802198
def to_dotfile(G: nx.DiGraph, filename: str):
    
    A = to_agraph(G)
    A.write(filename)
962796
def write_file(self, path, contents):
		
		path = self._get_dist_path(path)
		if not os.path.isdir(os.path.dirname(path)):
			os.makedirs(os.path.dirname(path))
		if isinstance(contents, bytes):
			mode = 'wb+'
		else:
			mode = 'w'
		with open(path, mode) as file:
			file.write(contents)
861554
def write_journal(self, journal_file_path):
        
        # TODO: assert the extension is txt and not other
        with open(journal_file_path, "w") as jrn_file:
            jrn_file.write(self._journal_contents)