Writes code to a python file called 'name',
        erasing the previous contents.
        Files are created in a directory specified by gen_dir_name (see function gen_file_path)
        File name is second argument of path
337079
def write_code(self, name, code):
        
        file_path = self.gen_file_path(name)
        with open(file_path,'w') as f:
            f.write(code)
1192832
def write_file(fname_parts, content):
    

    fname_parts = [str(part) for part in fname_parts]
    # try to create the directory
    if len(fname_parts) > 1:
        try:
            os.makedirs(os.path.join(*fname_parts[:-1]))
        except OSError:
            pass
    # write file
    fhandle = open(os.path.join(*fname_parts), "w")
    fhandle.write(content)
    fhandle.close()
552413
def write_file(self, filename):
        
        with open(filename, "w") as f:
            f.write(self.__str__())
563759
def _write_to_filepath(content, output):
    
    outdir = os.path.dirname(output)
    if outdir and not os.path.exists(outdir):
        os.makedirs(outdir)

    with anytemplate.compat.copen(output, 'w') as out:
        out.write(content)
202957
def write filename, options={}
      extension = file_extension(filename)
      send("write_to_#{extension}".to_sym, filename, options)
    end
1024158
def copy_file(self, src_path, file_name, key=None):
        
        path = os.path.join(self._directories[key], file_name)
        shutil.copyfile(src_path, path)
1218692
def write_dict_to_new_file(file_name, localization_key_to_comment):
    
    output_file_descriptor = open_strings_file(file_name, "w")
    for entry_key, entry_comment in sorted(localization_key_to_comment.iteritems(), key=operator.itemgetter(1)):
        write_entry_to_file(output_file_descriptor, entry_comment, entry_key)
        output_file_descriptor.write(u'\n')
    output_file_descriptor.close()
815817
def remove_file(self, name):
        """"""
        self.check_write(name)
        path = os.path.join(self.cur_dir, name)
        os.remove(path)
1072214
def write_file(filename = 'foo', string = nil)
      raise ExportError, 'Nothing to export for #{filename}.' if string.nil? || string == ""
      f = File.new( File.expand_path(File.join(export_path, filename)), 'w+')
      f.puts string
      f.close
    end
1235181
def _make_rewritten_pyc(state, fn, pyc, co):
    """"""
    if sys.platform.startswith("win"):
        # Windows grants exclusive access to open files and doesn't have atomic
        # rename, so just write into the final file.
        _write_pyc(state, co, fn, pyc)
    else:
        # When not on windows, assume rename is atomic. Dump the code object
        # into a file specific to this process and atomically replace it.
        proc_pyc = pyc + "." + str(os.getpid())
        if _write_pyc(state, co, fn, proc_pyc):
            os.rename(proc_pyc, pyc)
1228130
def write_tree_newick(self, filename, hide_rooted_prefix=False):
        '''
        '''
        if not isinstance(filename, str):
            raise TypeError("filename must be a str")
        treestr = self.newick()
        if hide_rooted_prefix:
            if treestr.startswith('[&R]'):
                treestr = treestr[4:].strip()
            else:
                warn("Specified hide_rooted_prefix, but tree was not rooted")
        if filename.lower().endswith('.gz'): # gzipped file
            f = gopen(expanduser(filename),'wb',9); f.write(treestr.encode()); f.close()
        else: # plain-text file
            f = open(expanduser(filename),'w'); f.write(treestr); f.close()
268354
void genCode(String name, ArrayList<JFile> ilist,
               ArrayList<JRecord> rlist, String destDir, ArrayList<String> options)
    throws IOException {
    name = new File(destDir, (new File(name)).getName()).getAbsolutePath();

    FileWriter cc = new FileWriter(name+".cc");
    try {
      FileWriter hh = new FileWriter(name+".hh");
      
      try {
        String fileName = (new File(name)).getName();
        hh.write("#ifndef __"+fileName.toUpperCase().replace('.','_')+"__\n");
        hh.write("#define __"+fileName.toUpperCase().replace('.','_')+"__\n");
        hh.write("#include \"recordio.hh\"\n");
        hh.write("#include \"recordTypeInfo.hh\"\n");
        for (Iterator<JFile> iter = ilist.iterator(); iter.hasNext();) {
          hh.write("#include \""+iter.next().getName()+".hh\"\n");
        }
        
        cc.write("#include \""+fileName+".hh\"\n");
        cc.write("#include \"utils.hh\"\n");
        
        for (Iterator<JRecord> iter = rlist.iterator(); iter.hasNext();) {
          iter.next().genCppCode(hh, cc, options);
        }
        
        hh.write("#endif //"+fileName.toUpperCase().replace('.','_')+"__\n");
      } finally {
        hh.close();
      }
    } finally {
      cc.close();
    }
  }
852829
void genCode(String name, ArrayList<JFile> ilist,
               ArrayList<JRecord> rlist, String destDir, ArrayList<String> options)
    throws IOException {
    name = new File(destDir, (new File(name)).getName()).getAbsolutePath();
    FileWriter cc = new FileWriter(name+".c");
    try {
      FileWriter hh = new FileWriter(name+".h");
      try {
        hh.write("#ifndef __"+name.toUpperCase().replace('.','_')+"__\n");
        hh.write("#define __"+name.toUpperCase().replace('.','_')+"__\n");
        hh.write("#include \"recordio.h\"\n");
        for (Iterator<JFile> iter = ilist.iterator(); iter.hasNext();) {
          hh.write("#include \""+iter.next().getName()+".h\"\n");
        }

        cc.write("#include \""+name+".h\"\n");

        /*
        for (Iterator<JRecord> iter = rlist.iterator(); iter.hasNext();) {
        iter.next().genCppCode(hh, cc);
        }
         */

        hh.write("#endif //"+name.toUpperCase().replace('.','_')+"__\n");
      } finally {
        hh.close();
      }
    } finally {
      cc.close();
    }
  }
1218080
def create(
    name,

    create_file,
    open_file,
    remove_file,

    create_directory,
    list_directory,
    remove_empty_directory,
    temporary_directory,

    stat,

    lstat,
    link,
    readlink,

    realpath=_realpath,
    remove=_recursive_remove,
):
    

    methods = dict(
        create=create_file,
        open=lambda fs, path, mode="r": open_file(
            fs=fs, path=path, mode=mode,
        ),
        remove_file=remove_file,

        create_directory=create_directory,
        list_directory=list_directory,
        remove_empty_directory=remove_empty_directory,
        temporary_directory=temporary_directory,

        get_contents=_get_contents,
        set_contents=_set_contents,
        create_with_contents=_create_with_contents,

        remove=remove,
        removing=_removing,

        stat=stat,

        lstat=lstat,
        link=link,
        readlink=readlink,
        realpath=realpath,

        exists=_exists,
        is_dir=_is_dir,
        is_file=_is_file,
        is_link=_is_link,

        touch=_touch,

        children=_children,
        glob_children=_glob_children,
    )
    return attr.s(hash=True)(type(name, (object,), methods))
1133159
def _gen_file_name(self):
        '''
        
        '''
        date = datetime.datetime.now()
        dt = "{}-{}-{}-{}-{}-{}-{}".format(str(date.year),str(date.month),str(date.day),str(date.hour),str(date.minute),str(date.second),str(random.randint(0,10000)))
        return self._output_filename_pattern.format(dt)
253760
def writetofile(self, filename):
        ''''''
        f = open(filename, "w")
        f.write(self.read())
        f.close()
812821
def write_file(filename, content):
    """"""
    print 'Generating {0}'.format(filename)
    with open(filename, 'wb') as out_f:
        out_f.write(content)