Writes PUML from the system. If filename is given, stores result in the file.
            Otherwise returns result as a string.
191921
def write_puml(self, filename=''):
        
        def get_type(o):
            type = 'program'
            if isinstance(o, AbstractSensor):
                type = 'sensor'
            elif isinstance(o, AbstractActuator):
                type = 'actuator'
            return type

        if filename:
            s = open(filename, 'w')
        else:
            s = io.StringIO()
        s.write('@startuml\n')
        s.write('skinparam state {\n')
        for k, v in list(self.background_colors.items()):
            s.write('BackGroundColor<<%s>> %s\n' % (k, v))
        s.write('}\n')

        for o in self.system.objects:
            if isinstance(o, DefaultProgram) or o.hide_in_uml:
                continue

            if isinstance(o, ProgrammableSystemObject):
                s.write('state "%s" as %s <<%s>>\n' % (o, o, get_type(o)))

                s.write('%s: %s\n' % (o, o.class_name))
                if isinstance(o, AbstractActuator):
                    for p in reversed(o.program_stack):
                        s.write('%s: %s :: %s\n' % (o, p, o.program_status.get(p, '-')))
                elif hasattr(o, 'status'):
                    s.write('%s: Status: %s\n' % (o, o.status))
                if getattr(o, 'is_program', False):
                    s.write('%s: Priority: %s\n' % (o, o.priority))

                for t in o.actual_triggers:
                    if isinstance(t, DefaultProgram) or t.hide_in_uml:
                        continue
                    s.write('%s -[%s]-> %s\n' % (t, self.arrow_colors['trigger'], o))
                for t in o.actual_targets:
                    if t.hide_in_uml:
                        continue
                    if o.active:
                        color = 'active_target'
                    else:
                        color = 'inactive_target'
                    if getattr(t, 'program', None) == o:
                        color = 'controlled_target'

                    s.write('%s -[%s]-> %s\n' % (o, self.arrow_colors[color], t))
        s.write('@enduml\n')
        if filename:
            s.close()
        else:
            return s.getvalue()
466260
def write(self, filename):
        
        ext = os.path.splitext(filename)[1]
        writer = open(filename, 'w')
        if ext == '.py':
            writer.write(pprint.pformat(self))
        elif ext == '.yaml':
            writer.write(yaml.dump(self))
        else:
            writer.close()
            raise Exception('Unrecognized config format: %s'%ext)
        writer.close()
602167
def _print_results(filename, data):
    
    if filename:
        with open(filename, 'wb') as f:
            f.write(data)
    else:
        print data
977220
def write(self, filename, append=True):
        
        header = ' '.join(['# User:', getpass.getuser(),
                           '\n# Creation date:', str(UTCDateTime()),
                           '\n# EQcorrscan version:',
                           str(eqcorrscan.__version__),
                           '\n\n\n'])
        if append:
            f = open(filename, 'a')
        else:
            f = open(filename, 'w')
            f.write(header)
        parameters = self.__dict__
        f.write(str(parameters))
        f.write('\n')
        f.close()
        return
253760
def writetofile(self, filename):
        ''''''
        f = open(filename, "w")
        f.write(self.read())
        f.close()
419257
def _write_to_file(self, filename, bytesvalue):
        """"""
        fh, tmp = tempfile.mkstemp()
        with os.fdopen(fh, self._flag) as f:
            f.write(self._dumps(bytesvalue))
        rename(tmp, filename)
        os.chmod(filename, self._mode)
1140799
def __write(self, s):
        
        self.buf += s
        while len(self.buf) > self.bufsize:
            self.fileobj.write(self.buf[:self.bufsize])
            self.buf = self.buf[self.bufsize:]
286093
def save(self, filename):
        
        clibrebound.reb_output_binary(byref(self), c_char_p(filename.encode("ascii")))
763189
def write(text, filename, encoding='utf-8', mode='wb'):
    
    text, encoding = encode(text, encoding)
    if 'a' in mode:
        with open(filename, mode) as textfile:
            textfile.write(text)
    else:
        with atomic_write(filename,
                          overwrite=True,
                          mode=mode) as textfile:
            textfile.write(text)
    return encoding
569392
def _write_file(self, filename, data):
        

        if self.__compression:
            f = gzip.GzipFile(filename, "wb")
        else:
            f = open(filename, "wb")
        pickle.dump(data, f, pickle.HIGHEST_PROTOCOL)
        f.close()
1272243
def write_file(name, text, opts):
    """"""
    fname = path.join(opts.destdir, '%s.%s' % (name, opts.suffix))
    if opts.dryrun:
        print 'Would create file %s.' % fname
        return
    if not opts.force and path.isfile(fname):
        print 'File %s already exists, skipping.' % fname
    else:
        print 'Creating file %s.' % fname
        f = open(fname, 'w')
        try:
            f.write(text)
        finally:
            f.close()
232367
def write_file_lines(self, filename, contents):
        
        with open(filename, 'wb') as f:
            self.log.debug(contents)
            f.writelines(contents)
678980
def write_str2file(pathname, astr):
    """"""
    fname = pathname
    fhandle = open(fname, 'wb')
    fhandle.write(astr)
    fhandle.close()
314602
def write_file(file_name, file_contents)
      contents =  file_contents
                  .flatten
                  .select { |line| line }
                  .join("\n")
      File.open(file_name, "w") do |fh|
        fh.write(contents)
        fh.write("\n")
      end
    end
588062
def save(file_name, content):
    """"""
    with open(file_name, "w", encoding="utf-8") as output_file:
        output_file.write(content)
        return output_file.name
1098921
def write(file_name, data):
    """"""
    with open(file_name, 'w') as f:
        f.write(encode(data))
1120433
def save_to_file(self, fname):
        
        with open(fname, 'w') as f:
            f.write(str(self))