Writes market experiment data to file in ReStructuredText format.
543190
def write(self, file):
        
        # Write environment state data.
        file.write("State\n")
        file.write( ("-" * 5) + "\n")
        self.writeDataTable(file, type="state")

        # Write action data.
        file.write("Action\n")
        file.write( ("-" * 6) + "\n")
        self.writeDataTable(file, type="action")

        # Write reward data.
        file.write("Reward\n")
        file.write( ("-" * 6) + "\n")
        self.writeDataTable(file, type="reward")
977196
def write(url, object_, **args):
    """"""
    default_content_type = ('text/plain', {'charset': 'US-ASCII'})
    content_encoding = args.get('content_encoding', 'base64')
    content_type, params = args.get('content_type', default_content_type)
    data = content_types.get(content_type).format(object_, **params)
    args['data'].write('data:{}'.format(content_type))
    for param, value in params.items():
        args['data'].write(';{}={}'.format(param, value))
    if content_encoding == 'base64':
        args['data'].write(';base64,{}'.format(base64.b64decode(data)))
    else:
        args['data'].write(',{}', urllib.quote(data))
    args['data'].seek(0)
779530
def writer(datasets, dataset_names, output_dir):
    """"""
    for dataset, dataset_name in zip(datasets, dataset_names):
        if dataset:
            filepath = output_dir + '/' + dataset_name + '.txt'
            with open(filepath, 'w+') as out_file:
                joined = '\n'.join(dataset)
                out_file.write(str(joined.encode('utf-8').decode('utf-8')))
                out_file.write('\n')
648760
def _write_rough_result_xml_to_file(self, xml, filename):
        """"""
        # Write content to temp file first
        error = xml.get('error', None)
        xml.set('error', 'incomplete') # Mark result file as incomplete
        temp_filename = filename + ".tmp"
        with open(temp_filename, 'wb') as file:
            ET.ElementTree(xml).write(file, encoding='utf-8', xml_declaration=True)
        os.rename(temp_filename, filename)
        if error is not None:
            xml.set('error', error)
        else:
            del xml.attrib['error']
846745
def save_to_rst(prefix, data):
  
  with open(find_full_name(prefix), "w") as rst_file:
    rst_file.write(full_gpl_for_rst)
    rst_file.write(data)
1368861
def write_r(df, f, sep=",", index_join="@", columns_join="."):
    

    df = df.copy()
    df.index = ["@".join([str(s) for s in v]) for v in df.index.values]
    df.columns = [".".join([str(s) for s in v]) for v in df.index.values]
    df.to_csv(f, sep=sep)
1068041
String writeDocument(Meter meter, Consumer<StringBuilder> consumer) {
        StringBuilder sb = new StringBuilder(indexLine);
        String timestamp = TIMESTAMP_FORMATTER.format(Instant.ofEpochMilli(config().clock().wallTime()));
        String name = getConventionName(meter.getId());
        String type = meter.getId().getType().toString().toLowerCase();
        sb.append("{\"").append(config.timestampFieldName()).append("\":\"").append(timestamp).append('"')
                .append(",\"name\":\"").append(escapeJson(name)).append('"')
                .append(",\"type\":\"").append(type).append('"');

        List<Tag> tags = getConventionTags(meter.getId());
        for (Tag tag : tags) {
            sb.append(",\"").append(escapeJson(tag.getKey())).append("\":\"")
                    .append(escapeJson(tag.getValue())).append('"');
        }

        consumer.accept(sb);
        sb.append("}");

        return sb.toString();
    }
608201
def write_data(data):
    

    sorted_dict = sort_recursive(data)

    with open(_datafile, 'w') as file:
        _json.dump(sorted_dict, file, indent=2)
284462
def format_data(raw_data, limit_per_url_group=LIMIT_PER_URL_GROUP, limit_url_groups=LIMIT_URL_GROUPS):
    """"""
    data = copy.deepcopy(raw_data)
    for k, v in list(data['data_details'].items()):
        # Only reserve first ``limit_per_url_group`` items
        v['urls'] = sorted(list(v['urls'].items()), key=lambda k_v: k_v[1].total,
                           reverse=True)[:limit_per_url_group]

    data_details = sorted(iter(data['data_details'].items()),
                          key=lambda k_v1: k_v1[1]["duration_agr_data"].total, 
                          reverse=True)[:limit_url_groups]

    if data['requests_counter']['normal']:
        slow_rate = format(data['requests_counter']['slow'] / \
                           float(data['requests_counter']['normal']), '.2%')
    else:
        slow_rate = '-'
    data.update({
        'slow_rate': slow_rate,
        'data_details': data_details,
    })
    return data
580977
def write(self, buf, url):
        """"""
        params = self._split_url(url)

        block_blob_service = self._block_blob_service(
            account_name=params["account"], sas_token=params["sas_token"]
        )

        block_blob_service.create_blob_from_text(
            container_name=params["container"], blob_name=params["blob"], text=buf
        )
960956
private void saveSummaryXml(SampleNode root) {

        root.sortTree();
        Document doc = DocumentHelper.createDocument();
        Element rootElem = doc.addElement("root");
        root.appendToXml(rootElem);
        OutputFormat outformat = OutputFormat.createPrettyPrint();
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        outformat.setEncoding("UTF-8");
        try {
            XMLWriter writer = new XMLWriter(buffer, outformat);
            writer.write(doc);
            writer.flush();
            try (FileOutputStream fos = new FileOutputStream(m_summaryFilename)) {
                fos.write(buffer.toByteArray());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
760233
def write_real (self, url_data):
        """"""
        self.write(self.part("realurl") + self.spaces("realurl"))
        self.writeln(unicode(url_data.url), color=self.colorreal)
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'))
578868
def _write(self, text):
        """"""
        spaces = ' ' * (self.indent * self.indentlevel)
        t = spaces + text.strip() + '\n'
        if hasattr(t, 'encode'):
            t = t.encode(self.encoding, 'xmlcharrefreplace')
        self.stream.write(t)
496255
def _rewrite_ser_data(self, ser, series_data, date_1904):
        
        ser._remove_tx()
        ser._remove_cat()
        ser._remove_val()

        xml_writer = _CategorySeriesXmlWriter(series_data, date_1904)

        ser._insert_tx(xml_writer.tx)
        ser._insert_cat(xml_writer.cat)
        ser._insert_val(xml_writer.val)
528741
function rewriteDuration() {
                var
                    buffer = new ArrayBufferDataStream(8),
                    oldPos = blobBuffer.pos;
                
                // Rewrite the data payload (don't need to update the id or size)
                buffer.writeDoubleBE(clusterStartTime);
                
                // And write that through to the file
                blobBuffer.seek(segmentDuration.dataOffset);
                blobBuffer.write(buffer.getAsDataArray());
        
                blobBuffer.seek(oldPos);
            }
602108
def write_to_file(self, f):
        """"""
        for section, values in self._values.iteritems():
            try:
                section_name, subsection_name = section
            except ValueError:
                (section_name, ) = section
                subsection_name = None
            if subsection_name is None:
                f.write("[%s]\n" % section_name)
            else:
                f.write("[%s \"%s\"]\n" % (section_name, subsection_name))
            for key, value in values.iteritems():
                f.write("%s = %s\n" % (key, _escape_value(value)))