def recreate_tree(outdir, indir, infiles, action): """Creates a new tree with only the input files in it. Arguments: outdir: Output directory to create the files in. indir: Root directory the infiles are based in. infiles: List of files to map from |indir| to |outdir|. action: See assert below. """ logging.debug('recreate_tree(%s, %s, %s, %s)' % (outdir, indir, infiles, action)) logging.info('Mapping from %s to %s' % (indir, outdir)) assert action in (tree_creator.HARDLINK, tree_creator.SYMLINK, tree_creator.COPY) outdir = os.path.normpath(outdir) if not os.path.isdir(outdir): logging.info('Creating %s' % outdir) os.makedirs(outdir) # Do not call abspath until the directory exists. outdir = os.path.abspath(outdir) for relfile in infiles: infile = os.path.join(indir, relfile) outfile = os.path.join(outdir, relfile) outsubdir = os.path.dirname(outfile) if not os.path.isdir(outsubdir): os.makedirs(outsubdir) tree_creator.link_file(outfile, infile, action)
def recreate_tree(outdir, indir, infiles, action): """Creates a new tree with only the input files in it. Arguments: outdir: Output directory to create the files in. indir: Root directory the infiles are based in. infiles: List of files to map from |indir| to |outdir|. action: See assert below. """ logging.debug( 'recreate_tree(%s, %s, %s, %s)' % (outdir, indir, infiles, action)) logging.info('Mapping from %s to %s' % (indir, outdir)) assert action in ( tree_creator.HARDLINK, tree_creator.SYMLINK, tree_creator.COPY) outdir = os.path.normpath(outdir) if not os.path.isdir(outdir): logging.info ('Creating %s' % outdir) os.makedirs(outdir) # Do not call abspath until the directory exists. outdir = os.path.abspath(outdir) for relfile in infiles: infile = os.path.join(indir, relfile) outfile = os.path.join(outdir, relfile) outsubdir = os.path.dirname(outfile) if not os.path.isdir(outsubdir): os.makedirs(outsubdir) tree_creator.link_file(outfile, infile, action)
def MODEhashtable(outdir, indir, dictfiles, _read_only, _cmd, _relative_cwd, resultfile): outdir = outdir or os.path.dirname(resultfile) for relfile, properties in dictfiles.iteritems(): infile = os.path.join(indir, relfile) outfile = os.path.join(outdir, properties['sha-1']) if os.path.isfile(outfile): # Just do a quick check that the file size matches. if os.stat(infile).st_size == os.stat(outfile).st_size: continue # Otherwise, an exception will be raised. tree_creator.link_file(outfile, infile, tree_creator.HARDLINK) return 0
def MODEhashtable( outdir, indir, dictfiles, _read_only, _cmd, _relative_cwd, resultfile): outdir = outdir or os.path.dirname(resultfile) for relfile, properties in dictfiles.iteritems(): infile = os.path.join(indir, relfile) outfile = os.path.join(outdir, properties['sha-1']) if os.path.isfile(outfile): # Just do a quick check that the file size matches. if os.stat(infile).st_size == os.stat(outfile).st_size: continue # Otherwise, an exception will be raised. tree_creator.link_file(outfile, infile, tree_creator.HARDLINK) return 0