Writes generator data to a ReST table.
337924
def write_generator_data(self, file):
        
        report = CaseReport(self.case)
        generators = self.case.generators

        col_width = 8
        col_width_2 = col_width*2+1
        col1_width = 6
        col_width_bool = 3
        col_width_poly = 4
        col_width_3 = col_width_poly*3+2

        sep = ("=" * col1_width + " ") * 2 + \
            ("=" * col_width_bool + " ") + \
            ("=" * col_width + " ") * 5 + \
            ("=" * col_width_poly + " ") * 3 + "\n"

        file.write(sep)
        # Line one of column headers.
        file.write("Name".center(col1_width) + " ")
        file.write("Bus".center(col1_width) + " ")
        file.write("On".center(col_width_bool) + " ")
        file.write("Voltage".center(col_width) + " ")
        file.write("Pg".center(col_width) + " ")
        file.write("Qg".center(col_width) + " ")
#        file.write("Lambda ($/MVA-hr)".center(col_width_2) + " ")
        file.write("Active Power".center(col_width_2) + " ")
        file.write("Polynomial".center(col_width_3) + " ")
        file.write("\n")

        file.write(("-" * col1_width + " ") * 2)
        file.write(("-" * col_width_bool + " "))
        file.write(("-" * col_width + " ") * 3)
        file.write(("-" * col_width_2 + " "))
        file.write(("-" * col_width_3 + " ") + "\n")

        # Line two of column header
        file.write("..".ljust(col1_width) + " ")
        file.write("..".ljust(col1_width) + " ")
        file.write("..".ljust(col_width_bool) + " ")
        file.write("..".ljust(col_width) + " ")
        file.write("(MW)".center(col_width) + " ")
        file.write("(MVAr)".center(col_width) + " ")
        file.write("Pmax".center(col_width) + " ")
        file.write("Pmin".center(col_width) + " ")
        file.write("c2".center(col_width_poly) + " ")
        file.write("c1".center(col_width_poly) + " ")
        file.write("c0".center(col_width_poly) + " ")
        file.write("\n")
        file.write(sep)

        # Branch rows.
        for each in generators:
            file.write(each.name[:col1_width].ljust(col1_width) + " ")
            file.write("..".ljust(col1_width) + " ")
            if each.online:
                file.write("1".center(col_width_bool) + " ")
            else:
                file.write("0".center(col_width_bool) + " ")
            file.write("%8.2f" % each.v_magnitude + " ")
            file.write("%8.2f" % each.p + " ")
            file.write("%8.2f" % each.q + " ")
#            file.write("..".ljust(col_width) + " ")
#            file.write("..".ljust(col_width) + " ")
            file.write("%8.2f" % each.p_max + " ")
            file.write("%8.2f" % each.p_min + " ")
            if each.pcost_model == POLYNOMIAL:
                if len(each.p_cost) == 3:
                    file.write("%4.2f %4.1f %4.0f" % each.p_cost)
                elif len(each.p_cost) == 2:
                    file.write("0.0 %4.1f %4.0f" % each.p_cost)
                elif len(each.p_cost) == 1:
                    file.write("0.0  0.0 %4.0f" % each.p_cost)
            file.write("\n")

        # Totals.
        file.write(("..".ljust(col1_width) +  " ") * 2)
        file.write(("..".ljust(col_width_bool) +  " "))
        file.write("*Total:*".rjust(col1_width) + " ")
        ptot = getattr(report, "actual_pgen")
        qtot = getattr(report, "actual_qgen")
        file.write("%8.2f " % ptot)
        file.write("%8.2f " % qtot)
        file.write(("..".ljust(col_width) + " ") * 2)
        file.write(("..".ljust(col_width_poly) + " ") * 3)
        file.write("\n")
        file.write(sep)
        del report
213141
def to_table_data(self):
        

        self._validate_source_data()

        for table_key, json_records in six.iteritems(self._buffer):
            headers = sorted(six.viewkeys(json_records))

            self._loader.inc_table_count()
            self._table_key = table_key

            yield TableData(
                self._make_table_name(),
                headers,
                zip(*[json_records.get(header) for header in headers]),
                dp_extractor=self._loader.dp_extractor,
                type_hints=self._extract_type_hints(headers),
            )
688319
def write(self):
        
        # write data
        self.project_manager.writeInput(session=self.db_session,
                                        directory=self.project_directory,
                                        name=self.project_manager.name)
670140
def to_table_data(self):
        

        self._validate_source_data()

        for table_key, json_records in six.iteritems(self._buffer):
            self._loader.inc_table_count()
            self._table_key = table_key

            yield TableData(
                self._make_table_name(),
                ["key", "value"],
                [record for record in json_records.items()],
                dp_extractor=self._loader.dp_extractor,
                type_hints=self._extract_type_hints(),
            )
468961
def writeGenerator(self, gen):
        
        n = getattr(gen, 'next')

        while True:
            try:
                self.writeElement(n())
            except StopIteration:
                break
647631
private void writeObject(JsonGenerator jsonGenerator, Object entity) throws IOException {
        jsonGenerator.writeStartObject();

        writeName(jsonGenerator, entity);
        writeKind(jsonGenerator, entity);
        writeURL(jsonGenerator, entity);

        jsonGenerator.writeEndObject();
    }
713512
public void write(DataOutput out) throws IOException {
    out.writeLong(version);
    Text.writeString(out, dir);
    out.writeLong(gen);
  }
1271068
def store(self):
        
        output = tempfile.NamedTemporaryFile(suffix='.json')
        try:

            def write(o):
                line = json.dumps(o, default=json_default)
                return output.write(line + '\n')

            yield write

            output.seek(0)
            log.info("Uploading generated table (%s)...", self._obj)
            self.save_file(output.name, destructive=True)
        finally:
            try:
                output.close()
            except:
                pass
1153706
def write_generator_data(self, file):
        
        gen_attr = ["p", "q", "q_max", "q_min", "v_magnitude",
            "base_mva", "online", "p_max", "p_min", "mu_pmax", "mu_pmin",
            "mu_qmax", "mu_qmin"]

        file.write("\n%%%% generator data\n")
        file.write("%%\tbus\tPg\tQg\tQmax\tQmin\tVg\tmBase\tstatus\tPmax\tPmin")
        file.write("\tmu_Pmax\tmu_Pmin\tmu_Qmax\tmu_Qmin")
        file.write("\n%sgen = [\n" % self._prefix)

        for generator in self.case.generators:
            vals = [getattr(generator, a) for a in gen_attr]
            vals.insert(0, generator.bus._i)
            assert len(vals) == 14
            file.write("\t%d\t%g\t%g\t%g\t%g\t%.8g\t%g\t%d\t%g\t%g\t%g\t%g"
                       "\t%g\t%g;\n" % tuple(vals))
        file.write("];\n")
385669
def content_written(generator, content):
    
    url = "%s/%s" % (generator.settings.get('SITEURL', 'http://localhost:8000'), content.url)
    make_posts(generator, content.metadata, url)
384467
public void write(JsonGenerator jsonGenerator) throws IOException {
    jsonGenerator.writeStartObject();

    // clusterNodeInfo begins
    jsonGenerator.writeFieldName("clusterNodeInfo");
    jsonGenerator.writeStartObject();
    jsonGenerator.writeStringField("name", clusterNodeInfo.name);
    jsonGenerator.writeObjectField("address", clusterNodeInfo.address);
    jsonGenerator.writeObjectField("total", clusterNodeInfo.total);
    jsonGenerator.writeObjectField("free", clusterNodeInfo.free);
    jsonGenerator.writeObjectField("resourceInfos",
      clusterNodeInfo.resourceInfos);
    jsonGenerator.writeEndObject();
    // clusterNodeInfo ends

    // grants begins
    jsonGenerator.writeFieldName("grants");
    jsonGenerator.writeStartObject();
    for (Map.Entry<GrantId, ResourceRequestInfo> entry : grants.entrySet()) {
      jsonGenerator.writeFieldName(entry.getKey().unique);
      jsonGenerator.writeStartObject();
      jsonGenerator.writeFieldName("grantId");
      entry.getKey().write(jsonGenerator);
      jsonGenerator.writeFieldName("grant");
      entry.getValue().write(jsonGenerator);
      jsonGenerator.writeEndObject();
    }
    jsonGenerator.writeEndObject();
    // grants ends

    jsonGenerator.writeEndObject();
    // We skip the hostNode and lastHeartbeatTime as they need not be persisted.
    // resourceTypeToMaxCpu and resourceTypeToStatsMap can be rebuilt using the
    // conf and the grants respectively.
  }
1261509
def generate_output(self, writer):
        
        # write xml stylesheet
        with codecs_open(os.path.join(os.path.dirname(__file__), 'sitemap-stylesheet.xsl'), 'r', encoding='utf-8') as fd_origin:
            with codecs_open(os.path.join(self.path_output, 'sitemap-stylesheet.xsl'), 'w', encoding='utf-8') as fd_destination:
                xsl = fd_origin.read()
                # replace some template markers
                # TODO use pelican template magic
                xsl = xsl.replace('{{ SITENAME }}', self.context.get('SITENAME'))
                fd_destination.write(xsl)

        # will contain the url nodes as text
        urls = ''

        # get all articles sorted by time
        articles_sorted = sorted(self.context['articles'], key=self.__get_date_key, reverse=True)

        # get all pages with date/modified date
        pages_with_date = list(
            filter(
                lambda p: getattr(p, 'modified', False) or getattr(p, 'date', False),
                self.context.get('pages')
            )
        )
        pages_with_date_sorted = sorted(pages_with_date, key=self.__get_date_key, reverse=True)

        # get all pages without date
        pages_without_date = list(
            filter(
                lambda p: getattr(p, 'modified', None) is None and getattr(p, 'date', None) is None,
                self.context.get('pages')
            )
        )
        pages_without_date_sorted = sorted(pages_without_date, key=self.__get_title_key, reverse=False)

        # join them, first date sorted, then title sorted
        pages_sorted = pages_with_date_sorted + pages_without_date_sorted

        # the landing page
        if 'index' in self.context.get('DIRECT_TEMPLATES'):
            # assume that the index page has changed with the most current article or page
            # use the first article or page if no articles
            index_reference = None
            if len(articles_sorted) > 0:
                index_reference = articles_sorted[0]
            elif len(pages_sorted) > 0:
                index_reference = pages_sorted[0]

            if index_reference is not None:
                urls += self.__create_url_node_for_content(
                    index_reference,
                    'index',
                    url=self.url_site,
                )

        # process articles
        for article in articles_sorted:
            urls += self.__create_url_node_for_content(
                article,
                'articles',
                url=urljoin(self.url_site, article.url)
            )

        # process pages
        for page in pages_sorted:
            urls += self.__create_url_node_for_content(
                page,
                'pages',
                url=urljoin(self.url_site, page.url)
            )

        # process category pages
        if self.context.get('CATEGORY_URL'):
            urls += self.__process_url_wrapper_elements(self.context.get('categories'))

        # process tag pages
        if self.context.get('TAG_URL'):
            urls += self.__process_url_wrapper_elements(sorted(self.context.get('tags'), key=lambda x: x[0].name))

        # process author pages
        if self.context.get('AUTHOR_URL'):
            urls += self.__process_url_wrapper_elements(self.context.get('authors'))

        # handle all DIRECT_TEMPLATES but "index"
        for direct_template in list(filter(lambda p: p != 'index', self.context.get('DIRECT_TEMPLATES'))):
            # we assume the modification date of the last article as modification date for the listings of
            # categories, authors and archives (all values of DIRECT_TEMPLATES but "index")
            modification_time = getattr(articles_sorted[0], 'modified', getattr(articles_sorted[0], 'date', None))
            url = self.__get_direct_template_url(direct_template)
            urls += self.__create_url_node_for_content(None, 'others', url, modification_time)

        # write the final sitemap file
        with codecs_open(os.path.join(self.path_output, 'sitemap.xml'), 'w', encoding='utf-8') as fd:
            fd.write(self.xml_wrap % {
                'SITEURL': self.url_site,
                'urls': urls
            })
1147348
def write_record(fo, datum, schema):
    """"""
    for field in schema['fields']:
        name = field['name']
        if name not in datum and 'default' not in field and \
                'null' not in field['type']:
            raise ValueError('no value and no default for %s' % name)
        write_data(fo, datum.get(
            name, field.get('default')), field['type'])
1046881
def write_table_file(self, job_table_file=None, file_table_file=None):
        """"""
        if self._table is None:
            raise RuntimeError("No table to write")
        if self._table_ids is None:
            raise RuntimeError("No ID table to write")
        if job_table_file is not None:
            self._table_file = job_table_file
        if self._table_file is None:
            raise RuntimeError("No output file specified for table")
        write_tables_to_fits(self._table_file, [self._table, self._table_ids], clobber=True,
                             namelist=['JOB_ARCHIVE', 'FILE_IDS'])
        self._file_archive.write_table_file(file_table_file)
433715
def write_table(self):
        

        super(TextTableWriter, self).write_table()
        if self.is_write_null_line_after_table:
            self.write_null_line()
1172006
def _write_gen_model_stats(self, iteration:int)->None:
        ""
        generator = self.learn.gan_trainer.generator
        self.stats_writer.write(model=generator, iteration=iteration, tbwriter=self.tbwriter, name='gen_model_stats')
        self.gen_stats_updated = True
597121
public void write(JsonGenerator jsonGenerator) throws IOException {
    jsonGenerator.writeStartObject();

    jsonGenerator.writeFieldName("idToRequest");
    jsonGenerator.writeStartObject();
    for (Integer id : idToRequest.keySet()) {
      jsonGenerator.writeFieldName(id.toString());
      idToRequest.get(id).write(jsonGenerator);
    }
    jsonGenerator.writeEndObject();

    // idToPendingRequests is the same, and we only need to persist the
    // array of pending request ids
    jsonGenerator.writeFieldName("idToPendingRequests");
    jsonGenerator.writeStartArray();
    for (Integer id : idToPendingRequests.keySet()) {
      jsonGenerator.writeNumber(id);
    }
    jsonGenerator.writeEndArray();

    jsonGenerator.writeFieldName("idToGrant");
    jsonGenerator.writeStartObject();
    for (Integer id : idToGrant.keySet()) {
      jsonGenerator.writeObjectField(id.toString(), idToGrant.get(id));
    }
    jsonGenerator.writeEndObject();

    jsonGenerator.writeObjectField("status", status);

    jsonGenerator.writeStringField("sessionId", sessionId);

    jsonGenerator.writeBooleanField("deleted", deleted);

    jsonGenerator.writeNumberField("deletedTime", deletedTime);

    jsonGenerator.writeObjectField("info", info);
    
    jsonGenerator.writeNumberField("startTime", startTime);

    jsonGenerator.writeFieldName("poolInfo");
    poolInfo.write(jsonGenerator);

    jsonGenerator.writeFieldName("typeToFirstWait");
    jsonGenerator.writeStartObject();
    for (ResourceType resourceType : typeToFirstWait.keySet()) {
      Long wait = typeToFirstWait.get(resourceType);
      if (wait == null) {
        wait = new Long(-1);
      }
      jsonGenerator.writeNumberField(resourceType.toString(), wait);
    }
    jsonGenerator.writeEndObject();

    jsonGenerator.writeObjectField("expectedInfo", expectedInfo);
    
    jsonGenerator.writeObjectField("lastHeartbeat", lastHeartbeat);
    
    jsonGenerator.writeNumberField("lastSyncTime", lastSyncTime);

    jsonGenerator.writeEndObject();
    // No need to serialize lastHeartbeatTime, it will be reset.
    // typeToContext can be rebuilt
  }