Writes the chapter object to an xhtml file.

        Args:
            file_name (str): The full name of the xhtml file to save to.
763317
def write(self, file_name):
        
        try:
            assert file_name[-6:] == '.xhtml'
        except (AssertionError, IndexError):
            raise ValueError('filename must end with .xhtml')
        with open(file_name, 'wb') as f:
            f.write(self.content.encode('utf-8'))
1016123
def save(self, file_tag='2016', add_header='N'):
        
        fname = self.get_filename(file_tag)
        with open(fname, 'a') as f:
            if add_header == 'Y':
                f.write(self.format_hdr())
                
            for e in self.table: 
                    f.write(e.format_csv())
1154175
def save_file(self, filename = 'StockChart'):
        
        filename = filename + '.html'
        
        with open(filename, 'w') as f:
            #self.buildhtml()
            f.write(self.htmlcontent)
        
        f.closed
1115862
def to_file(self, filename):
        

        # save compressed file
        xml = self.to_xml()
        f = gzip.open(filename, 'wb')
        try:
            f.write(xml.encode('utf-8'))
        finally:
            f.close()
31129
def write_xls(data, file_name, worksheet_names=None):
    '''
    
    '''
    workbook = xlwt.Workbook()
    for sheet_index, sheet_data in enumerate(data):
        if worksheet_names and sheet_index < len(worksheet_names) and worksheet_names[sheet_index]:
            name = worksheet_names[sheet_index]
        else:
            name = 'Worksheet {}'.format(sheet_index)
        sheet = workbook.add_sheet(name)
        for row_index, row in enumerate(sheet_data):
            for col_index, value in enumerate(row):
                sheet.write(row_index, col_index, value)
    workbook.save(file_name)
1302613
def save_page(file_name = nil)
        file_name ||= Time.now.strftime("%Y%m%d%H%M%S") + ".html"
        puts "about to save page: #{File.expand_path(file_name)}" if $DEBUG
        File.open(file_name, "w").puts page_source
      end
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
190977
def write_to_file(self, filename):
        
        # TODO: give all file format writers the same API
        if filename.endswith('.cml'):
            from molmod.io import dump_cml
            dump_cml(filename, [self])
        elif filename.endswith('.xyz'):
            from molmod.io import XYZWriter
            symbols = []
            for n in self.numbers:
                atom = periodic[n]
                if atom is None:
                    symbols.append("X")
                else:
                    symbols.append(atom.symbol)
            xyz_writer = XYZWriter(filename, symbols)
            xyz_writer.dump(self.title, self.coordinates)
            del xyz_writer
        else:
            raise ValueError("Could not determine file format for %s." % filename)
1098921
def write(file_name, data):
    """"""
    with open(file_name, 'w') as f:
        f.write(encode(data))
562640
def htmlSaveFileFormat(self, filename, encoding, format):
        
        ret = libxml2mod.htmlSaveFileFormat(filename, self._o, encoding, format)
        return ret
77555
public function saveFile($file_name) {
    $path = 'public://govcms8-demo';
    if (file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
      $source = DRUPAL_ROOT . '/' . drupal_get_path('module', 'govcms8_default_content') . '/import/images/' . $file_name;
      $data = file_get_contents($source);
      return file_save_data($data, "public://govcms8-demo/" . $file_name, FILE_EXISTS_RENAME);
    }
  }
422884
def save_as(self, new_filename):
        
        xfile._save_file(
            self._filename, self._workbookTree, new_filename)
1173761
def write_document(self, name, document):
        
        with open(name, 'wb') as out:
            out.write(etree.tostring(document,
                                     encoding='utf-8',
                                     pretty_print=True))
1373502
def write_posterior(self, filename, **kwargs):
        
        f = h5py.File(filename, 'w')

        # Preserve top-level metadata
        for key in self.attrs:
            f.attrs[key] = self.attrs[key]

        f.attrs['filetype'] = PosteriorFile.name
        s = f.create_group('samples')
        fields = self[self.samples_group].keys()

        # Copy and squash fields into one dimensional arrays
        for field_name in fields:
            fvalue = self[self.samples_group][field_name][:]
            thin = fvalue[:,self.thin_start:self.thin_end:self.thin_interval]
            s[field_name] = thin.flatten()
225468
def save_html(self, filename=None, overwrite=False):
        

        if filename is None:
            raise ValueError('Please provide a filename, e.g. viz.save_html(filename="viz.html").')

        import os
        base = self._html
        js = self.load_embed()
        if os.path.exists(filename):
            if overwrite is False:
                raise ValueError("File '%s' exists. To ovewrite call save_html with overwrite=True."
                                 % os.path.abspath(filename))
            else:
                os.remove(filename)
        with open(filename, "wb") as f:
            f.write(base.encode('utf-8'))
            f.write('<script>' + js.encode('utf-8') + '</script>')
139357
def save(filename, html):
    
    try:
        out_file = open(filename, "w")
        out_file.write(html)
        out_file.close()
    except IOError as ex:
        parser.error("Could not write baked HTML to local file {name}. ({ex})".format(name=filename, ex=ex))
433595
def write_file(self, filename, contents):
        
        logger.info("Writing file: %s", format_path(filename))
        contents = contents.rstrip() + b"\n"
        self.context.write_file(filename, contents)
        logger.debug("Wrote %s to %s.",
                     pluralize(len(contents.splitlines()), "line"),
                     format_path(filename))