Write one file per GO group.
334757
def wr_txt_grouping_gos(self):
        """"""
        prt_goids = self.grprobj.gosubdag.prt_goids
        for hdrgo, usrgos in self.grprobj.hdrgo2usrgos.items():
            keygos = usrgos.union([hdrgo])
            fout_txt = "{BASE}.txt".format(BASE=self.grprobj.get_fout_base(hdrgo))
            with open(fout_txt, 'w') as prt:
                prt_goids(keygos, prt=prt)
                sys.stdout.write("  {N:5,} GO IDs WROTE: {TXT}\n".format(
                    N=len(keygos), TXT=fout_txt))
137240
def write(self, out):
        """"""
        out.write_short(self.priority)
        out.write_short(self.weight)
        out.write_short(self.port)
        out.write_name(self.server)
321012
def write_file(data, outfilename):
    """"""
    if not data:
        return False
    try:
        with open(outfilename, 'w') as outfile:
            for line in data:
                if line:
                    outfile.write(line)
        return True
    except (OSError, IOError) as err:
        sys.stderr.write('An error occurred while writing {0}:\n{1}'
                         .format(outfilename, str(err)))
        return False
548601
def prt_gos_flat(self, prt):
        """"""
        prtfmt = self.datobj.kws['fmtgo']
        _go2nt = self.sortobj.grprobj.go2nt
        go2nt = {go:_go2nt[go] for go in self.go2nt}
        prt.write("\n{N} GO IDs:\n".format(N=len(go2nt)))
        _sortby = self._get_sortgo()
        for ntgo in sorted(go2nt.values(), key=_sortby):
            prt.write(prtfmt.format(**ntgo._asdict()))
62928
def prt_goids(self, goids=None, prtfmt=None, sortby=True, prt=sys.stdout):
        """"""
        if goids is None:
            goids = self.go_sources
        nts = self.get_nts(goids, sortby)
        if prtfmt is None:
            prtfmt = self.prt_attr['fmta']
        for ntgo in nts:
            key2val = ntgo._asdict()
            prt.write("{GO}\n".format(GO=prtfmt.format(**key2val)))
        return nts
778126
def write_single_file(dir, filename = nil)
      FileUtils.mkdir_p File.join(dir)

      # HACKY: NEED TO FIX
      keys = snapshots.first.keys
      keys = snapshots.first[@field].first.keys if @field

      s = []
      s << keys.join(SEPERATOR)
      snapshots.each do |snapshot|
        # HACKY: NEED TO FIX
        if @field
          snapshot[@field].each_with_index do |e, i|
            s << e.values.map do |v|
              if v.is_a?(String)
                "\"#{v}\""
              else
                "#{v}"
              end
            end.join(SEPERATOR)
          end
        else
          s << [*snapshot.values].map { |e|
            e.is_a?(String) ? "\"#{e}\""  : "#{e}"
          } .join(SEPERATOR)
        end
      end

      filename ||= @parser.class.name.split("::").last
      path = File.join(dir, filename)
      File.open("#{path}.csv", 'w') { |f| f.write(s.join("\n")) }
    end
648094
def write(filename, mesh, fmt_version, write_binary=True):
    
    try:
        writer = _writers[fmt_version]
    except KeyError:
        try:
            writer = _writers[fmt_version.split(".")[0]]
        except KeyError:
            raise ValueError(
                "Need mesh format in {} (got {})".format(
                    sorted(_writers.keys()), fmt_version
                )
            )

    writer.write(filename, mesh, write_binary=write_binary)
974956
def init_group_write(self, dst_addr=1, data=None, dptsize=0):
        """"""
        self.init_group(dst_addr)

        # unnumbered data packet, group write
        self.tpci_apci = 0x00 * 256 + 0x80

        self.dptsize = dptsize
        if data is None:
            self.data = [0]
        else:
            self.data = data
642695
def write(self, text):
        """"""
        index = text.find('\n')
        if index == -1:
            self._buffer = self._buffer + text
        else:
            self._buffer = self._buffer + text[:index + 1]
            if self._pattern:
                # pattern already compiled no need to check
                result = re.search(self._pattern, self._buffer)
                if result:
                    for group in result.groups():
                        if group:
                            self._buffer = self._buffer.replace(group, "***")
            self._file.write(self._buffer)
            self._file.flush()
            self._buffer = text[index + 1:]
113532
def write(self):
        """"""
        self._assure_writable("write")
        if not self._dirty:
            return

        if isinstance(self._file_or_files, (list, tuple)):
            raise AssertionError("Cannot write back if there is not exactly a single file to write to, have %i files"
                                 % len(self._file_or_files))
        # end assert multiple files

        if self._has_includes():
            log.debug("Skipping write-back of configuration file as include files were merged in." +
                      "Set merge_includes=False to prevent this.")
            return
        # end

        fp = self._file_or_files

        # we have a physical file on disk, so get a lock
        is_file_lock = isinstance(fp, string_types + (FileType, ))
        if is_file_lock:
            self._lock._obtain_lock()
        if not hasattr(fp, "seek"):
            with open(self._file_or_files, "wb") as fp:
                self._write(fp)
        else:
            fp.seek(0)
            # make sure we do not overwrite into an existing file
            if hasattr(fp, 'truncate'):
                fp.truncate()
            self._write(fp)
637352
def write_dag(self, out=sys.stdout):
        """"""
        for rec in sorted(self.values()):
            print(rec, file=out)
1315693
def write_hier(self, GO_id, out=sys.stdout,
                       len_dash=1, max_depth=None, num_child=None, short_prt=False,
                       include_only=None, go_marks=None):
        """"""
        gos_printed = set()
        self[GO_id].write_hier_rec(gos_printed, out, len_dash, max_depth, num_child,
            short_prt, include_only, go_marks)
571120
def rdtxt_gos(go_file, prt):
        """"""
        goids_all = set()
        if not os.path.exists(go_file):
            raise RuntimeError("CAN NOT READ GO FILE: {FILE}\n".format(FILE=go_file))
        re_go = re.compile(r'(GO:\d{7})+?')
        re_com = re.compile(r'^\s*#')  # Lines starting with a '#' are comment lines and ignored
        with open(go_file) as ifstrm:
            for line in ifstrm:
                # Skip lines that are comments
                if re_com.search(line):
                    continue
                # Search for GO IDs on the line
                goids_found = re_go.findall(line)
                if goids_found:
                    goids_all.update(goids_found)
            if prt:
                prt.write("  {N} GO IDs READ: {TXT}\n".format(N=len(goids_all), TXT=go_file))
        return goids_all
1059872
def pout(*args, **kwargs):
    """"""
    if should_msg(kwargs.get("groups", ["normal"])):
        args = indent_text(*args, **kwargs)

        # write to stdout
        sys.stderr.write("".join(args))
        sys.stderr.write("\n")
1032483
def wr_py_sections(self, fout_py, sections, doc=None):
        """"""
        if sections is None:
            sections = self.grprobj.get_sections_2d()
        sec2d_nt = self.get_sections_2dnt(sections)  # lists of GO Grouper namedtuples
        with open(fout_py, 'w') as prt:
            self._prt_py_sections(sec2d_nt, prt, doc)
            dat = SummarySec2dHdrGos().summarize_sec2hdrgos(sections)
            sys.stdout.write(self.grprobj.fmtsum.format(
                GO_DESC='hdr', SECs=len(dat['S']), GOs=len(dat['G']),
                UNGRP=len(dat['U']), undesc="unused",
                ACTION="WROTE:", FILE=fout_py))
778923
def write_files(text, where='.'):
    """"""
    for filename in text:
        target = os.path.join(where, filename)
        write_file(target, text[filename])
227060
def write_fmt(fp, fmt, *args):
    
    fmt = str(">" + fmt)
    fmt_size = struct.calcsize(fmt)
    written = write_bytes(fp, struct.pack(fmt, *args))
    assert written == fmt_size, 'written=%d, expected=%d' % (
        written, fmt_size
    )
    return written