From bbb0e4124b1afbc041b15ca68540e6fd3d441031 Mon Sep 17 00:00:00 2001 From: Tyler Beason Date: Sun, 5 Sep 2021 13:49:34 -0400 Subject: [PATCH] use Downloads, rm HTTP --- .travis.yml | 30 ------------------------------ Project.toml | 5 ++--- src/FamaFrenchData.jl | 13 +++++++++---- 3 files changed, 11 insertions(+), 37 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 193e03f..0000000 --- a/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ -## Documentation: http://docs.travis-ci.com/user/languages/julia/ -language: julia -dist: xenial -os: - - linux - - osx -julia: - - 1 # this always does julia-latest - - 1.3 - - nightly -notifications: - email: false -git: - depth: 99999999 - -jobs: - ## uncomment following lines to deploy documentation - include: - - stage: "Documentation" - julia: 1.5 - os: linux - script: - - julia --project=docs -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate();' - - julia --project=docs --color=yes docs/make.jl - after_success: skip - allow_failures: - - julia: nightly -after_success: - - julia --project=test/coverage -e 'using Pkg; Pkg.instantiate()' - - julia --project=test/coverage test/coverage/coverage.jl diff --git a/Project.toml b/Project.toml index badb023..7b049a2 100644 --- a/Project.toml +++ b/Project.toml @@ -1,19 +1,18 @@ name = "FamaFrenchData" uuid = "bd2a388e-9788-4ef7-9fc3-f4c919ffde82" authors = ["Tyler Beason "] -version = "0.3.1" +version = "0.4.0" [deps] CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" -HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" +Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6" ZipFile = "a5390f91-8eb1-5f08-bee0-b1d1ffed6cea" [compat] CSV = "^0.7.6, 0.8" DataFrames = "0.19.4, 0.20, 0.21, 0.22, 1" -HTTP = "^0.8.11, 0.9" ZipFile = "0.8.4, 0.9" julia = "^1.3" diff --git a/src/FamaFrenchData.jl b/src/FamaFrenchData.jl index 937e865..293166b 100644 --- a/src/FamaFrenchData.jl +++ b/src/FamaFrenchData.jl @@ -3,7 +3,7 @@ Julia package for easy access to the Ken French Data Library files. See `readFam """ module FamaFrenchData -using HTTP +using Downloads using CSV using ZipFile using DataFrames @@ -31,7 +31,8 @@ Returns three pieces: """ function readFamaFrench(ffn;kwargs...) if !isfile(ffn) - io = IOBuffer(HTTP.get(pathtoFamaFrench(ffn)).body) + io = IOBuffer() + Downloads.download(pathtoFamaFrench(ffn),io) z = ZipFile.Reader(io) ff = first(z.files) else @@ -52,7 +53,8 @@ Saves the extracted CSV file from `ffn` to local file `savename`. """ function downloadFamaFrench(savename,ffn) open(savename,"w") do f - io = IOBuffer(HTTP.get(pathtoFamaFrench(ffn)).body) + io = IOBuffer() + Downloads.download(pathtoFamaFrench(ffn),io) z = ZipFile.Reader(io) ff = first(z.files) for s in readlines(ff) @@ -77,7 +79,10 @@ function listFamaFrench(;refresh::Bool = false) if refresh # grabs filenames from website wname = "https://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html" - hs=String(HTTP.request("GET",wname).body) + io = IOBuffer() + Downloads.download(wname,io) + hs = String(take!(io)) + close(io) regx = r"(?<=ftp\/)(.*)(?=_CSV)" res=collect(eachmatch(regx,hs)) nms = getfield.(res,:match)