Writes the AST as a configuration file.

            `filename`
                Filename to save configuration file to.
            `header`
                Header string to use for the file.

            Returns boolean.
541576
def write(self, filename, header=None):
        

        origfile = self._filename

        try:
            with open(filename, 'w') as _file:
                self.writestream(_file, header)
                self._filename = filename
            return True

        except IOError:
            self._filename = origfile
            return False
642561
def write_file(name, contents)
      path = File.join(Billy.config.certs_path, name)
      FileUtils.mkdir_p(File.dirname(path))
      File.write(path, contents)
      path
    end
845372
def write(self, filename = ""):
        
        file_data = str(self)
        if filename:
            try:
                self.__write(filename, file_data)
            except IOError:
                raise IOError("File could not be opened for write operations.")
        else:
            return file_data
552413
def write_file(self, filename):
        
        with open(filename, "w") as f:
            f.write(self.__str__())
653714
def save(self, filename):
        
        with open(filename, 'wb') as fp:
            writer = BlockWriter()
            factory = BlockFactory()

            preamble_dummy_bytes = bytearray([0] * 9)
            preamble = bread.parse(
                preamble_dummy_bytes, spec.lsdsng_preamble)
            preamble.name = self.name
            preamble.version = self.version

            preamble_data = bread.write(preamble)
            raw_data = self.get_raw_data()
            compressed_data = filepack.compress(raw_data)

            writer.write(compressed_data, factory)

            fp.write(preamble_data)

            for key in sorted(factory.blocks.keys()):
                fp.write(bytearray(factory.blocks[key].data))
3181
def dump(self, filename):
        
        flags = os.O_WRONLY|os.O_CREAT|os.O_NOFOLLOW|os.O_EXCL
        fd = os.open(filename, flags, 0o0600)
        os.write(fd, bytes(self.__str__(), locale.getpreferredencoding()))
        os.close(fd)
1216514
def save_response_to_file(self, response, filename):
        
        try:
            last_response = self.get_last_response()
            with open(filename, 'w') as f:
                f.write(last_response.content)
        except OSError, e:
            return False
        return True
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()
1157532
def write(self, config_dir=None, config_name=None, codec=None):
        
        # get name of config directory
        if not config_dir:
            config_dir = self._meta_config_dir
            if not config_dir:
                raise IOError("config_dir not set")

        # get name of config file
        if not config_name:
            config_name = self._defaults.get('config_name', None)
        if not config_name:
            raise KeyError('config_name not set')

        if codec:
            codec = munge.get_codec(codec)()
        else:
            codec = munge.get_codec(self._defaults['codec'])()

        config_dir = os.path.expanduser(config_dir)
        if not os.path.exists(config_dir):
            os.mkdir(config_dir)

        codec.dumpu(self.data, os.path.join(config_dir, 'config.' + codec.extension))
748859
def write_header(self):
        
        for properties in self.header.values():
            value = properties['value']
            offset_bytes = int(properties['offset'])
            self.file.seek(offset_bytes)
            value.tofile(self.file)
286093
def save(self, filename):
        
        clibrebound.reb_output_binary(byref(self), c_char_p(filename.encode("ascii")))
400302
def save_as_header(self, response, **kwargs):
        
        save_as = kwargs.get('save_as', None)
        if save_as is False:
            return
        file_obj = kwargs.get('file_obj', None)
        if save_as is True or save_as is None:
            filename = os.path.basename(file_obj.path)
        else:
            filename = save_as
        response['Content-Disposition'] = smart_str(
            'attachment; filename=%s' % filename)
515638
def write_file(filename, text):
    """"""
    logging.debug(_('Writing file: %s'), filename)
    try:
        with open(filename, 'w') as writable:
            writable.write(text)
    except (PermissionError, NotADirectoryError):
        logging.error(_('Error writing file: %s'), filename)
        return False
    return True
493881
def save_as(self, filename: str) -> None:
        
        lib.TCOD_image_save(self.image_c, filename.encode("utf-8"))
14871
def write_file(self):
        ''''''
        if self.config:
            try:
                with open(self.config_file, 'w') as file:
                    json.dump(self.config, file)
            except IOError as error:
                print('Error:', error)
                return
580246
def save(self, filename, config):
        """"""
        return open(os.path.expanduser(filename), 'w').write(json.dumps(config, cls=HCEncoder, sort_keys=True, indent=2, separators=(',', ': ')))
1072080
def _save(self):
        
        # See Issue 1086 and 1242 for background on why this
        # method contains all the exception handling.
        fname = self.filename()

        def _write_file(fname):
            if PY2:
                # Python 2
                with codecs.open(fname, 'w', encoding='utf-8') as configfile:
                    self._write(configfile)
            else:
                # Python 3
                with open(fname, 'w', encoding='utf-8') as configfile:
                    self.write(configfile)

        try:  # the "easy" way
            _write_file(fname)
        except EnvironmentError:
            try:  # the "delete and sleep" way
                if osp.isfile(fname):
                    os.remove(fname)
                time.sleep(0.05)
                _write_file(fname)
            except Exception as e:
                print("Failed to write user configuration file to disk, with "
                      "the exception shown below")  # spyder: test-skip
                print(e)