"""Copy file from one directory to another

This version demonstrates use of the grapevne helper using the object instance.
"""
configfile: "config/config.yaml"

from grapevne_helper import import_grapevne
import shutil

grapevne = import_grapevne(workflow)
gv = grapevne.Helper(workflow)

rule copy:
    input:
        filename=gv.input(gv.params("filename")),
        dummy_script=gv.script("dummy.sh"),
        dummy_resource=gv.resource("dummy.txt"),
    output:
        filename=gv.output(gv.params("filename")),
    log:
        gv.log("copy.log"),
    run:
        shutil.copy(input.filename, output.filename)

rule _test:
    input:
        # Check that the input file has been copied
        infile=gv.input(gv.params("filename")),
        outfile=gv.output(gv.params("filename")),
    run:
        # Verify file contents
        assert open(input.infile).read() == open(input.outfile).read()
