A function to replace the old constructor call where a filename was passed in.
162548
def from_filepath(filepath, strict = True, parse_ligands = False):
        ''''''
        return PDB(read_file(filepath), strict = strict, parse_ligands = parse_ligands)
371732
def rerunExperimentFromLogfile(logFilename):
    
    callLog = LoggingDecorator.load(logFilename)

    # Assume first one is call to constructor
    exp = L246aNetwork(*callLog[0][1]["args"], **callLog[0][1]["kwargs"])

    # Call subsequent methods, using stored parameters
    for call in callLog[1:]:
      method = getattr(exp, call[0])
      method(*call[1]["args"], **call[1]["kwargs"])

    return exp
405319
function replaceDirect(brstars, replacer) {
    replacer(['require'], function(node) {
      var caller = node.parent
      if (!node.arguments.length) return
      if (!caller.arguments) return
      if (!caller.arguments.length) return
      var value = evaluate(caller.arguments[0])
      if (!value) return
      var source = evaluate(node.arguments[0])
      if (!source) return

      source = resolve.sync(source, {
        basedir: dirname
      })

      var index = brstars.indexOf(source)
      if (index === -1) return

      value = require(source)(value)
      replaceCount += 1
      hijack(caller, value)
    })
  }
747788
def replace_in_file(workspace, src_file_path, from_str, to_str):
  
  from_bytes = from_str.encode('ascii')
  to_bytes = to_str.encode('ascii')
  data = read_file(os.path.join(workspace, src_file_path), binary_mode=True)
  if from_bytes not in data and from_str not in src_file_path:
    return None

  dst_file_path = src_file_path.replace(from_str, to_str)
  safe_file_dump(os.path.join(workspace, dst_file_path),
                 data.replace(from_bytes, to_bytes),
                 mode='wb')
  if src_file_path != dst_file_path:
    os.unlink(os.path.join(workspace, src_file_path))
  return dst_file_path
1347664
def replace(old, new):
    
    parent = old.getparent()
    parent.replace(old, new)
784614
def from_filename(cls, filename):
    """"""
    result = cls._FROM_FILENAME_CACHE.get(filename)
    if result is None:
      result = cls(cls._normalize(filename))
      cls._FROM_FILENAME_CACHE.store(filename, result)
    return result
966183
def replace_if_changed(localfile, jottapath, JFS):
    """"""
    jf = JFS.getObject(jottapath)
    lf_hash = getxattrhash(localfile) # try to read previous hash, stored in xattr
    if lf_hash is None:               # no valid hash found in xattr,
        with open(localfile) as lf:
            lf_hash = calculate_md5(lf) # (re)calculate it
    if type(jf) == JFSIncompleteFile:
        log.debug("Local file %s is incompletely uploaded, continue", localfile)
        return resume(localfile, jf, JFS)
    elif jf.md5 == lf_hash: # hashes are the same
        log.debug("hash match (%s), file contents haven't changed", lf_hash)
        setxattrhash(localfile, lf_hash)
        return jf         # return the version from jottaclouds
    else:
        setxattrhash(localfile, lf_hash)
        return new(localfile, jottapath, JFS)
306014
function (from, to) {
            return (new java.io.File(from)).renameTo((new java.io.File(to)));
        }
264111
public static File replaceExtension(File file, String newExtension) throws IllegalArgumentException
  {
    Params.notNull(file, "File");
    return new File(replaceExtension(file.getPath(), newExtension));
  }
674115
def add_call(self, func):
        """"""
        self.trace.append("{} ({}:{})".format(
            object_name(func),
            inspect.getsourcefile(func),
            inspect.getsourcelines(func)[1]))

        return self
1354617
def replace_in_files(dirname, replace):
    """"""
    filepath = os.path.abspath(dirname / "requirements.in")
    if os.path.isfile(filepath) and header_footer_exists(filepath):
        replaced = re.sub(Utils.exp, replace, get_file_string(filepath))
        with open(filepath, "w") as f:
            f.write(replaced)
        print(color(
            "Written to file: {}".format(filepath),
            fg='magenta', style='bold'))
1007009
function(fileURL, newF){
			var fileName;
			if(this.options && this.options.newFileName && this.options.oldFileName) {
				fileName = newF ? this.options.newFileName : this.options.oldFileName;
			} else {
				fileName = fileURL.split("?")[0]; //$NON-NLS-0$
			}
			return fileName;
		}
785
function replaceInFile (filename, regex, replacement) {
    let contents = fs.readFileSync (filename, 'utf8')
    const parts = contents.split (regex)
    const newContents = parts[0] + replacement + parts[1]
    fs.truncateSync (filename)
    fs.writeFileSync (filename, newContents)
}
62435
function copyFile (oldName, newName) {
    let contents = fs.readFileSync (oldName, 'utf8')
    fs.truncateSync (newName)
    fs.writeFileSync (newName, contents)
}
432766
def _cleanup_after_optimize_aux(filename, new_filename, old_format,
                                new_format):
    
    bytes_in = 0
    bytes_out = 0
    final_filename = filename
    try:
        bytes_in = os.stat(filename).st_size
        bytes_out = os.stat(new_filename).st_size
        if (bytes_out > 0) and ((bytes_out < bytes_in) or Settings.bigger):
            if old_format != new_format:
                final_filename = replace_ext(filename,
                                             new_format.lower())
            rem_filename = filename + REMOVE_EXT
            if not Settings.test:
                os.rename(filename, rem_filename)
                os.rename(new_filename, final_filename)
                os.remove(rem_filename)
            else:
                os.remove(new_filename)

        else:
            os.remove(new_filename)
            bytes_out = bytes_in
    except OSError as ex:
        print(ex)

    return final_filename, bytes_in, bytes_out
1371503
function replace(root, options, callback) {
	analyser.readDir(root, options, function(err, files) {
		files = _.flatten(files);
		_.each(files, function(file){ 
			fs.readFile(file, 'UTF-8', function(err, data) {
				if(err) {throw err;}
				var i, value;
				for(i=0; i<options.values.length; i++) {
					value = options.values[i];
					if(value === Object(value)) {
						for(var key in value) {
							if(value.hasOwnProperty(key)) {
								data = data.replace(new RegExp('{{'+key+'}}','g'), value[key]);
							}
						}
					}
					fs.writeFile(file, data);
				}
			});
		});	
		if(callback) {
			callback(err, files);
		}
	});
}
626745
def _inject(self, fileobj, padding_func):
        """"""

        # Find the old pages in the file; we'll need to remove them,
        # plus grab any stray setup packet data out of them.
        fileobj.seek(0)
        page = OggPage(fileobj)
        while not page.packets[0].startswith(b"\x03vorbis"):
            page = OggPage(fileobj)

        old_pages = [page]
        while not (old_pages[-1].complete or len(old_pages[-1].packets) > 1):
            page = OggPage(fileobj)
            if page.serial == old_pages[0].serial:
                old_pages.append(page)

        packets = OggPage.to_packets(old_pages, strict=False)

        content_size = get_size(fileobj) - len(packets[0])  # approx
        vcomment_data = b"\x03vorbis" + self.write()
        padding_left = len(packets[0]) - len(vcomment_data)

        info = PaddingInfo(padding_left, content_size)
        new_padding = info._get_padding(padding_func)

        # Set the new comment packet.
        packets[0] = vcomment_data + b"\x00" * new_padding

        new_pages = OggPage._from_packets_try_preserve(packets, old_pages)
        OggPage.replace(fileobj, old_pages, new_pages)