TigerFetch.jl

Download TIGER/Line shapefiles from the US Census Bureau
Log | Files | Refs | README | LICENSE

artifacts.jl (2191B)


      1 # ABOUTME: Artifact management for bundled reference data (state/county FIPS lists)
      2 # ABOUTME: Handles artifact installation, path resolution, and reference data file access
      3 using Pkg.Artifacts
      4 
      5 """
      6 Bind the artifact to the GitHub-hosted tarball.
      7 Run this script once to update Artifacts.toml.
      8 """
      9 
     10 """
     11 Bind the artifact from a GitHub-hosted tarball.
     12 Run this script once to update Artifacts.toml.
     13 """
     14 # function bind_github_artifact()
     15 
     16 # artifact_url = "https://github.com/eloualiche/TigerFetch.jl/releases/download/0.1.1/fips_state_county_list.tar.gz"
     17 
     18 
     19 # # sha256
     20 # artifact_hash_256 = "f00e895f9358863c07e9c6c3b9eedf199cc740aab0583ce25de39e9d7159b565"
     21 
     22 # # The SHA1 hash (obtained from sha256sum)
     23 # # using SHA
     24 # # artifact_path = "assets/fips_state_county_list.tar.gz"
     25 # # artifact_hash = bytes2hex(open(sha1, artifact_path))
     26 # artifact_hash = "d9f2ce485acf54390052e796cb4ccf8c01e70bcb"
     27 # sha1_hash = Base.SHA1(artifact_hash)
     28 
     29 # # Bind the artifact with its SHA1 hash
     30 # bind_artifact!(
     31 #     "Artifacts.toml",      # Path to Artifacts.toml
     32 #     "fips_state_county_list",         # Name of the artifact
     33 #     sha1_hash;             # SHA1 hash (as a Base.SHA1 object)
     34 #     download_info=[(artifact_url, artifact_hash_256)],  # URL for downloading the artifact and its SHA256 hash
     35 #     force=true             # Overwrite if exists
     36 # )
     37 
     38 # end
     39 
     40 
     41 """
     42 Get the directory containing the artifact files.
     43 """
     44 function artifact_dir()
     45     artifact_toml = joinpath(@__DIR__, "..", "Artifacts.toml")
     46 
     47     # Get the hash from Artifacts.toml
     48     hash = artifact_hash("fips_state_county_list", artifact_toml)
     49     if hash === nothing
     50         error("Could not find fips_state_county_list entry in Artifacts.toml")
     51     end
     52 
     53     # Ensure the artifact is installed (downloads if needed)
     54     ensure_artifact_installed("fips_state_county_list", artifact_toml)
     55 
     56     # Return the artifact directory path
     57     return artifact_path(hash)
     58 end
     59 
     60 """
     61 Get paths to specific reference files.
     62 """
     63 function get_reference_data()
     64     base_path = artifact_dir()
     65 
     66     return Dict(
     67         "county" => joinpath(base_path, "national_county2020.txt"),
     68         "state" => joinpath(base_path, "national_state2020.txt")
     69     )
     70 end