Save a playlist
        Create a txt file and write stations in it.
        Then rename it to final target

        return    0: All ok
                 -1: Error writing file
                 -2: Error renaming file
481006
def save_playlist_file(self, stationFile=''):
        
        if self._playlist_format_changed():
            self.dirty_playlist = True
            self.new_format = not self.new_format

        if stationFile:
            st_file = stationFile
        else:
            st_file = self.stations_file

        if not self.dirty_playlist:
            if logger.isEnabledFor(logging.DEBUG):
                logger.debug('Playlist not modified...')
            return 0

        st_new_file = st_file.replace('.csv', '.txt')

        tmp_stations = self.stations[:]
        tmp_stations.reverse()
        if self.new_format:
            tmp_stations.append([ '# Find lots more stations at http://www.iheart.com' , '', '' ])
        else:
            tmp_stations.append([ '# Find lots more stations at http://www.iheart.com' , '' ])
        tmp_stations.reverse()
        try:
            with open(st_new_file, 'w') as cfgfile:
                writter = csv.writer(cfgfile)
                for a_station in tmp_stations:
                    writter.writerow(self._format_playlist_row(a_station))
        except:
            if logger.isEnabledFor(logging.DEBUG):
                logger.debug('Cannot open playlist file for writing,,,')
            return -1
        try:
            move(st_new_file, st_file)
        except:
            if logger.isEnabledFor(logging.DEBUG):
                logger.debug('Cannot rename playlist file...')
            return -2
        self.dirty_playlist = False
        return 0
88009
def save_data(data, suffix='', dirname=None):
    
    if type(data) == list:
        data = np.array(data).T

    name = create_graph_name(suffix, dirname) + '.txt'
    np.savetxt(name, data)
1111815
def save(self):
        """"""
        file_name = fd.asksaveasfilename()
        if file_name is "" or file_name is None:
            return
        with open(file_name, "w") as f:
            f.write(self.text.get("1.0", tk.END))
98752
def example_write_file_to_disk_if_changed():
    
    my_file = FileAsObj('/tmp/example_file.txt')
    my_file.rm(my_file.egrep('^#'))
    if my_file.changed:
        my_file.save()
398819
def save(self, filename=None):
        
        filename = filename or self._filename
        o = open(filename, 'w')
        o.write(self.write())
        o.close()
15854
def write(self, basename="/tmp/resynclist.xml"):
        
        self.default_capability()
        fh = open(basename, 'w')
        s = self.new_sitemap()
        s.resources_as_xml(self, fh=fh, sitemapindex=self.sitemapindex)
        fh.close()
448572
def save(self, filename):
        ''''''
        try:
            f = open(filename, mode='w')
        except Exception:
            return False
        for k in self.list():
            f.write("%s=%s\n" % (k, self.get(k)))
        f.close()
        return True
865741
def write(self, filename, type_='obo'):  #FIXME this is bugged
        
        if os.path.exists(filename):
            name, ext = filename.rsplit('.',1)
            try:
                prefix, num = name.rsplit('_',1)
                n = int(num)
                n += 1
                filename = prefix + '_' + str(n) + '.' + ext
            except ValueError:
                filename = name + '_1.' + ext
            print('file exists, renaming to %s' % filename)
            self.write(filename, type_)

        else:
            with open(filename, 'wt', encoding='utf-8') as f:
                if type_ == 'obo':
                    f.write(str(self))  # FIXME this is incredibly slow for big files :/
                elif type_ == 'ttl':
                    f.write(self.__ttl__())
                else:
                    raise TypeError('No exporter for file type %s!' % type_)
1009294
def save(self):
        
        d = self._to_dict()
        if len(d.get('videoIds', [])) > 0:
            if not self.id:
                self.id = self.connection.post('create_playlist', playlist=d)
            else:
                data = self.connection.post('update_playlist', playlist=d)
                if data:
                    self._load(data)
59062
def save_bed(cls, query, filename=sys.stdout):
        
        out = _open(filename, 'w')
        for o in query:
            out.write(o.bed() + '\n')
308568
def write_Note(file, note, bpm=120, repeat=0, verbose=False):
    
    m = MidiFile()
    t = MidiTrack(bpm)
    m.tracks = [t]
    while repeat >= 0:
        t.set_deltatime('\x00')
        t.play_Note(note)
        t.set_deltatime("\x48")
        t.stop_Note(note)
        repeat -= 1
    return m.write_file(file, verbose)
538012
function(target, filelist) {
    var buster = config.timestamp ? '# Time: ' + (new Date()) + '\n' : '';
    var content = [header, buster, section, filelist, network, settings];
    fss.writeFile(target, content.join('\n'));
}
20153
def _format_playlist_line(self, lineNum, pad, station):
        
        line = "{0}. {1}".format(str(lineNum + self.startPos + 1).rjust(pad), station[0])
        f_data = ' [{0}, {1}]'.format(station[2], station[1])
        if version_info < (3, 0):
            if len(line.decode('utf-8', 'replace')) + len(f_data.decode('utf-8', 'replace')) > self.bodyMaxX -2:
                """ this is too long, try to shorten it
                    by removing file size """
                f_data = ' [{0}]'.format(station[1])
            if len(line.decode('utf-8', 'replace')) + len(f_data.decode('utf-8', 'replace')) > self.bodyMaxX - 2:
                """ still too long. start removing chars """
                while len(line.decode('utf-8', 'replace')) + len(f_data.decode('utf-8', 'replace')) > self.bodyMaxX - 3:
                    f_data = f_data[:-1]
                f_data += ']'
            """ if too short, pad f_data to the right """
            if len(line.decode('utf-8', 'replace')) + len(f_data.decode('utf-8', 'replace')) < self.maxX - 2:
                while len(line.decode('utf-8', 'replace')) + len(f_data.decode('utf-8', 'replace')) < self.maxX - 2:
                    line += ' '
        else:
            if len(line) + len(f_data) > self.bodyMaxX -2:
                """ this is too long, try to shorten it
                    by removing file size """
                f_data = ' [{0}]'.format(station[1])
            if len(line) + len(f_data) > self.bodyMaxX - 2:
                """ still too long. start removing chars """
                while len(line) + len(f_data) > self.bodyMaxX - 3:
                    f_data = f_data[:-1]
                f_data += ']'
            """ if too short, pad f_data to the right """
            if len(line) + len(f_data) < self.maxX - 2:
                while len(line) + len(f_data) < self.maxX - 2:
                    line += ' '
        line += f_data
        return line
558771
function( err, streams ) {

			// Get base name
			var path = originalFile.path;
			var parts = path.split("."); parts.pop();
			var baseName =  parts.join(".");

	    	// Push each stream to output
	    	for (var i=0; i<streams.length; i++) {
	    		var f = originalFile.clone();
	    		f.contents = streams[i][0]; // Content
	    		f.path = baseName + streams[i][1]; // Suffix
				self.push(f);
	    	}

	    	// We are done
			done();
			return;
	    }
199272
def make_file(self, filename, content):
        
        with open(filename, 'w') as fp:
            fp.write(content)
35054
def download_playlist(playlist):
    
    global arguments
    invalid_chars = '\/:*?|<>"'
    playlist_name = playlist['title'].encode('utf-8', 'ignore')
    playlist_name = playlist_name.decode('utf8')
    playlist_name = ''.join(c for c in playlist_name if c not in invalid_chars)

    if not arguments['--no-playlist-folder']:
        if not os.path.exists(playlist_name):
            os.makedirs(playlist_name)
        os.chdir(playlist_name)

    try:
        with codecs.open(playlist_name + '.m3u', 'w+', 'utf8') as playlist_file:
            playlist_file.write('#EXTM3U' + os.linesep)
            del playlist['tracks'][:offset - 1]
            for counter, track_raw in enumerate(playlist['tracks'], offset):
                logger.debug(track_raw)
                logger.info('Track n°{0}'.format(counter))
                download_track(track_raw, playlist['title'], playlist_file)
    finally:
        os.chdir('..')
388507
def save_beat(
        self,
        output_file_name,
        frequencys,
        play_time,
        sample_rate=44100,
        volume=0.01
    ):
        '''
        
        '''
        left_frequency, right_frequency = frequencys
        left_chunk = self.__create_chunk(left_frequency, play_time, sample_rate)
        right_chunk = self.__create_chunk(right_frequency, play_time, sample_rate)
        frame_list = self.read_stream(left_chunk, right_chunk, volume)

        wf = wave.open(output_file_name, 'wb')
        wf.setparams((2, 2, sample_rate, 0, 'NONE', 'not compressed'))
        wf.writeframes(b''.join(frame_list))
        wf.close()