Write a new Abook file with the given vcards
519897
def abook_file(vcard, bookfile):
        """"""
        book = ConfigParser(default_section='format')

        book['format'] = {}
        book['format']['program'] = 'abook'
        book['format']['version'] = '0.6.1'

        for (i, card) in enumerate(readComponents(vcard.read())):
            Abook.to_abook(card, str(i), book, bookfile)
        with open(bookfile, 'w') as fp:
            book.write(fp, False)
308960
def to_vcards(self):
        """"""
        self._update()
        return [self._to_vcard(self._book[entry]) for entry in self._book.sections()]
531603
function writeSync(description, options) {
  var file = vfile(description)
  fs.writeFileSync(
    path.resolve(file.cwd, file.path),
    file.contents || '',
    options
  )
}
711132
def write(self, buf, url):
        """"""
        (store_name, path) = self._split_url(url)
        adapter = self._create_adapter(store_name)
        with adapter.open(path, 'wb') as f:
            f.write(buf.encode())
1353208
def write_file(self, filename, cart_coords=False):
        
        with zopen(filename, "w") as f:
            f.write(self.to_string(cart_coords))
1372642
def _write(self, session, openFile, replaceParamFile):
        
        # Retrieve output locations
        locations = self.outputLocations

        # Write lines
        openFile.write('%s\n' % self.numLocations)

        for location in locations:
            openFile.write('%s %s\n' % (location.linkOrCellI,
                                        location.nodeOrCellJ))
408073
def write(self, fn=None):
        """"""
        fn = fn or self.fn
        if not os.path.exists(os.path.dirname(fn)):
            os.makedirs(os.path.dirname(fn))
        f = open(self.fn, 'rb')
        b = f.read()
        f.close()
        f = open(fn, 'wb')
        f.write(b)
        f.close()
1024809
function writeFile(filepath, data, options, callback) {
  if (typeof options === 'function') {
    callback = options;
    options = {};
  }

  if (!Buffer.isBuffer(data)) {
    return callback(new TypeError('Data must be a Buffer'));
  }

  if (!options) {
    options = {};
  }

  // Default the same as node
  var mode = options.mode || constants.DEFAULT_FILE_MODE;
  var flags = options.flags || 'w';
  var position = APPEND_MODE_REGEXP.test(flags) ? null : 0;

  fs.open(filepath, flags, mode, onOpen);

  function onOpen(openErr, fd) {
    if (openErr) {
      return onComplete(openErr);
    }

    fs.write(fd, data, 0, data.length, position, onComplete);

    function onComplete(writeErr) {
      callback(writeErr, fd);
    }
  }
}
1129911
def write_multiple_files(args, base_dir, crawler):
    """"""
    for i, query in enumerate(args['query']):
        if query in args['files']:
            # Write files
            if args['out'] and i < len(args['out']):
                outfilename = args['out'][i]
            else:
                outfilename = '.'.join(query.split('.')[:-1])
            write_files(args, [query], outfilename)
        elif query in args['urls']:
            # Scrape/crawl urls
            domain = utils.get_domain(query)
            if args['html']:
                # Create a directory to save PART.html files in
                if not args['quiet']:
                    print('Storing html files in {0}/'.format(domain))
                utils.mkdir_and_cd(domain)

            if args['crawl'] or args['crawl_all']:
                # Crawl and save HTML files/image files to disk
                infilenames = crawler.crawl_links(query)
            else:
                raw_resp = utils.get_raw_resp(query)
                if raw_resp is None:
                    return False

                # Saves page as PART.html file
                prev_part_num = utils.get_num_part_files()
                utils.write_part_file(args, query, raw_resp)
                curr_part_num = prev_part_num + 1
                infilenames = utils.get_part_filenames(curr_part_num, prev_part_num)

            # Convert output or leave as PART.html files
            if args['html']:
                # HTML files have been written already, so return to base dir
                os.chdir(base_dir)
            else:
                # Write files to text or pdf
                if infilenames:
                    if args['out'] and i < len(args['out']):
                        outfilename = args['out'][i]
                    else:
                        outfilename = utils.get_outfilename(query, domain)
                    write_files(args, infilenames, outfilename)
                else:
                    sys.stderr.write('Failed to retrieve content from {0}.\n'
                                     .format(query))
    return True
703334
def load_abgfiles(dir=None):
    """"""
    import ephem,string
    if dir is None:
        import tkFileDialog
	try: 
            dir=tkFileDialog.askdirectory()
        except:
            return
    if dir is None:
        return None
    from glob import glob
    files=glob(dir+"/*.abg")
    import os
    for f in files:
        (name,ext)=os.path.splitext(os.path.basename(f))
	NAME=name.strip().upper()
	kbos[name]=f
	#print name
        aei=file(dir+"/"+name+".aei")
        lines=aei.readlines()
        aei.close()
        objInfoDict[name]="%6s %6s %6s\n" % ( string.center("a",6),
				            string.center("e",6),
	 				    string.center("i",6) ) 
        try:
          (a,e,i,N,w,T) = lines[4].split()
        except:
          print lines[4]
          (a,e,i,N,w,T) = (0,0,0,0,0,0)
        objInfoDict[name]+="%6.2f %6.3f %6.2f\n" % (float(a),float(e),float(i))
        s=lines[5][0:2]
        (a,e,i,N,w,T) = lines[5][2:-1].split()
        objInfoDict[name]+=" %6.3f %6.3f %6.3f\n" % (float(a),float(e),float(i))
        abg = file(dir+"/"+name+".abg")
        lines = abg.readlines()
        abg.close()
	for line in lines:
	    if not line[0:5] == "# Bar":
	        continue
            objInfoDict[name]+=line[2:-1]+"\n"
            break
        res=file(dir+"/"+name+".res")
        lines=res.readlines()
        res.close()
        line=lines.pop()
        values=line.split()
        s = "[nobs: "+values[0]+" dt: "+values[1]+"]\n"
        objInfoDict[name]+=s
        mpc = file(dir+"/../mpc/"+name+".mpc")
        lines=mpc.readlines()
        mpc.close()
	last_date=0
	for line in lines:
	    if len(line)==0:
		continue
	    if line[0]=="#":
		continue
            this_year=int(line[15:19])
            this_month=int(line[20:22])
            this_day = int(line[23:25])
	    this_date =  this_year+this_month/12.0 +this_day/365.25
	    if last_date < this_date:
		last_date=this_date
		year=this_year
		day = this_day
		month=this_month	
        mag={}
        for line in lines:
            try:
                mags=line[65:69].strip()
		if len(mags)==0:
		    continue
                filter=line[70]
	        if filter not in mag:
                    mag[filter]=[]
                mag[filter].append(float(mags)) 
	    except:
	        continue
        mags=''
        for filter in mag:
	    magv=0
 	    for m in mag[filter]:
	        magv = magv+m/len(mag[filter]) 
            mags = mags+ "%4.1f-%s " % ( magv , filter)
        if len(mags)==0:
	    mags= "N/A"
        objInfoDict[name]+="MAG: "+mags+"\n"
        objInfoDict[name]+="Last obs: %s %s %s \n" % (year,month, day)

    doplot(kbos)
206529
def write(file_name, file_contents, data)
      fname = cache_file_name(file_name, file_contents)
      @previous_entry = fname
      File.open(fname, "wb") {|file| Marshal::dump(data, file) }
    end
53419
def write_text_files(args, infilenames, outfilename):
    
    if not outfilename.endswith('.txt'):
        outfilename = outfilename + '.txt'
    outfilename = overwrite_file_check(args, outfilename)

    all_text = []  # Text must be aggregated if writing to a single output file
    for i, infilename in enumerate(infilenames):
        parsed_text = get_parsed_text(args, infilename)
        if parsed_text:
            if args['multiple']:
                if not args['quiet']:
                    print('Attempting to write to {0}.'.format(outfilename))
                write_file(parsed_text, outfilename)
            elif args['single']:
                all_text += parsed_text
                # Newline added between multiple files being aggregated
                if len(infilenames) > 1 and i < len(infilenames) - 1:
                    all_text.append('\n')

    # Write all text to a single output file
    if args['single'] and all_text:
        if not args['quiet']:
            print('Attempting to write {0} page(s) to {1}.'
                  .format(len(infilenames), outfilename))
        write_file(all_text, outfilename)
1301104
def as_ab_write(self, start, data):
        
        wordlen = snap7.snap7types.S7WLByte
        type_ = snap7.snap7types.wordlen_to_ctypes[wordlen]
        size = len(data)
        cdata = (type_ * size).from_buffer_copy(data)
        logger.debug("ab write: start: %s: size: %s: " % (start, size))
        return self.library.Cli_AsABWrite(
            self.pointer, start, size, byref(cdata))
1023447
def write(self):
        
        index_file = self.path
        new_index_file = index_file + '.new'
        bak_index_file = index_file + '.bak'

        if not self._db:
            return

        with open(new_index_file, 'w') as f:
            json.dump(self._db, f, indent=4)

        if exists(index_file):
            copy(index_file, bak_index_file)

        rename(new_index_file, index_file)
801676
def writefile(openedfile, newcontents):
    """"""
    openedfile.seek(0)
    openedfile.truncate()
    openedfile.write(newcontents)
1245068
def _writeXput(self, session, directory, fileCards,
                   name=None, replaceParamFile=None):
        
        for card in self.projectCards:
            if (card.name in fileCards) and self._noneOrNumValue(card.value) \
                    and fileCards[card.name]:
                fileIO = fileCards[card.name]
                filename = card.value.strip('"')

                # Check for replacement variables
                if '[' in filename or ']' in filename:
                    log.info('The file for project card {0} cannot be '
                             'written, because the path has been replaced '
                             'with replacement variable {1}.'.format(card.name, filename))
                    return

                # Determine new filename
                filename = self._replaceNewFilename(filename=filename,
                                                    name=name)

                # Invoke write method on each file
                self._invokeWrite(fileIO=fileIO,
                                  session=session,
                                  directory=directory,
                                  filename=filename,
                                  replaceParamFile=replaceParamFile)
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