from snakemake.remote.HTTP import RemoteProvider as HTTPRemoteProvider

HTTP = HTTPRemoteProvider()

shell("touch C && sleep 1 && touch B && sleep 1 && touch A && touch D && \
    mkdir -p github.com/snakemake/snakemake/raw/master/tests/test_remote_http/expected-results && \
    touch github.com/snakemake/snakemake/raw/master/tests/test_remote_http/expected-results/landsat-data.txt && \
    touch -t 200101010101 old_file")

#Will not be executed even though A is newer
rule a:
    input:
        ancient("A")
    output:
        "B"
    shell:
        "echo \"B recreated\" > {output}"

#Will be executed because B is newer
rule b:
    input:
        "B"
    output:
        "C"
    shell:
        "echo \"C recreated\" > {output}"

#Will be executed because C was updated in rule b
rule c:
    input:
        ancient("C")
    output:
        "D"
    shell:
        "echo \"D recreated\" > {output}"

# This should not run even though output is older than input
rule remote_ancient:
    input: ancient(HTTP.remote("github.com/snakemake/snakemake/raw/master/tests/test_remote_http/expected-results/landsat-data.txt"))
    output: "old_file"
    shell: "cp {input} {output}"
