Skip to content

Commit 2898053

Browse files
committed
Replace Term.jl with ProgressMeter.jl
1 parent 31dafe5 commit 2898053

File tree

4 files changed

+15
-51
lines changed

4 files changed

+15
-51
lines changed

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name = "ScrapeSEC"
22
uuid = "856806e7-be2f-4540-8165-3a51303b7af0"
33
authors = ["tylerjthomas9 <[email protected]>"]
4-
version = "1.0.2"
4+
version = "1.1.0"
55

66
[deps]
77
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
88
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
99
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
1010
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
11-
Term = "22787eb5-b846-44ae-b979-8e399b8463ab"
11+
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
1212
ZipFile = "a5390f91-8eb1-5f08-bee0-b1d1ffed6cea"
1313

1414
[compat]
@@ -17,7 +17,7 @@ CSV = "0.10"
1717
DataFrames = "1"
1818
Dates = "<0.0.1, 1"
1919
HTTP = "1"
20-
Term = "2"
20+
ProgressMeter = "1.10"
2121
Test = "<0.0.1, 1"
2222
ZipFile = "0.10"
2323
julia = "1.6"

src/ScrapeSEC.jl

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,13 @@
11

22
module ScrapeSEC
33

4-
# Dependencies
54
using DataFrames
65
using Dates: Dates
76
using CSV: CSV
87
using HTTP: HTTP
9-
using Term.Progress
8+
using ProgressMeter
109
using ZipFile: ZipFile
1110

12-
const progress_bar_columns = [
13-
Progress.DescriptionColumn,
14-
Progress.SeparatorColumn,
15-
Progress.ProgressColumn,
16-
Progress.CompletedColumn,
17-
Progress.SeparatorColumn,
18-
Progress.ETAColumn,
19-
]
20-
21-
# source files
2211
include("download_metadata.jl")
2312
include("main_index.jl")
2413
include("download_filings.jl")

src/download_filings.jl

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ Parameters
5959
* `dest`: Destination folder for downloaded filings
6060
* `download_rate`: Number of filings to download every second (limit=10)
6161
* `skip_file`: If true, existing files will be skipped
62-
* `pbar`: ProgressBar (Term.jl)
63-
* `stop_pbar`: If false, progress bar will not be stopped
6462
* `pbar_desc`: pbar Description
6563
* `runnings_tests`: If true, only downloads one file
6664
* `clean_text`: function to clean text before writing to file
@@ -70,8 +68,6 @@ function download_filings(
7068
dest="./data/"::String,
7169
download_rate=10::Int,
7270
skip_file=true::Bool,
73-
pbar=ProgressBar(;)::ProgressBar,
74-
stop_pbar=true::Bool,
7571
pbar_desc="Downloading Filings"::String,
7672
running_tests=false::Bool,
7773
clean_text::Function=_pass_text,
@@ -100,24 +96,20 @@ function download_filings(
10096
return nothing
10197
end
10298

103-
job = addjob!(pbar; N=size(filenames, 1), description=pbar_desc)
104-
start!(pbar)
99+
p = Progress(size(filenames, 1); desc=pbar_desc)
105100
for file in filenames
106101
full_file = joinpath(dest, replace(file, "edgar/data/" => ""))
107102

108103
@async download_filing(file, full_file, dest; clean_text)
109104

110-
update!(job)
105+
next!(p)
111106
sleep(sleep_time)
112-
render(pbar)
113107

114108
if running_tests
115109
break
116110
end
117111
end
118-
if stop_pbar
119-
stop!(pbar)
120-
end
112+
finish!(p)
121113

122114
return nothing
123115
end
@@ -146,8 +138,6 @@ Parameters
146138
* `filing_types`: Types of filings to download (eg. ["10-K", "10-Q"])
147139
* `download_rate`: Number of filings to download every second (limit=10)
148140
* `skip_file`: If true, existing files will be skipped
149-
* `pbar`: ProgressBar (Term.jl)
150-
* `stop_pbar`: If false, progress bar will not be stopped
151141
* `pbar_desc`: pbar Description
152142
* `runnings_tests`: If true, only downloads one file
153143
* `clean_text`: function to clean text before writing to file
@@ -158,8 +148,6 @@ function download_filings(
158148
filing_types=["10-K"]::Vector{String},
159149
download_rate=10::Int,
160150
skip_file=true::Bool,
161-
pbar=ProgressBar(;)::ProgressBar,
162-
stop_pbar=true::Bool,
163151
pbar_desc="Downloading Filings"::String,
164152
running_tests=false::Bool,
165153
clean_text::Function=_pass_text,
@@ -185,8 +173,6 @@ function download_filings(
185173
dest=dest,
186174
download_rate=download_rate,
187175
skip_file=skip_file,
188-
pbar=pbar,
189-
stop_pbar=stop_pbar,
190176
pbar_desc=pbar_desc,
191177
running_tests=running_tests,
192178
clean_text,
@@ -261,12 +247,7 @@ function download_filings(
261247
dest=metadata_dest,
262248
skip_file=skip_metadata_file,
263249
)
264-
265-
pbar = ProgressBar(; columns=progress_bar_columns)
266-
job = addjob!(
267-
pbar; N=size(time_periods, 1), description="Iterating Over Time Periods..."
268-
)
269-
start!(pbar)
250+
p = Progress(size(time_periods, 1); desc="Iterating Over Time Periods...")
270251
for t in time_periods
271252
file = joinpath(metadata_dest, string(t[1]) * "-QTR" * string(t[2]) * ".tsv")
272253
download_filings(
@@ -275,16 +256,13 @@ function download_filings(
275256
filing_types=filing_types,
276257
download_rate=download_rate,
277258
skip_file=skip_file,
278-
pbar=pbar,
279-
stop_pbar=false,
280259
pbar_desc="Downloading $(t[1]) Q$(t[2]) Filings",
281260
running_tests=running_tests,
282261
clean_text,
283262
)
284-
update!(job)
285-
render(pbar)
263+
next!(p)
286264
end
287-
stop!(pbar)
265+
finish!(p)
288266

289267
return nothing
290268
end

src/download_metadata.jl

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,14 @@ function download_metadata_files(
136136

137137
urls = get_metadata_urls(time_periods)
138138
n_files = size(urls, 1)
139-
pbar = ProgressBar(;)
140-
job = addjob!(pbar; N=n_files, description="Downloading Metadata CSVs...")
141-
start!(pbar)
142-
@inbounds for idx in eachindex(urls)
143-
update!(job)
139+
p = Progress(n_files; desc="Downloading Metadata CSVs...")
140+
for url in urls
144141
ScrapeSEC.download_metadata(
145-
urls[idx]; dest=dest, skip_file=skip_file, verbose=verbose
142+
url; dest=dest, skip_file=skip_file, verbose=verbose
146143
)
147-
render(pbar)
144+
next!(p)
148145
end
149-
stop!(pbar)
146+
finish!(p)
150147

151148
return nothing
152149
end

0 commit comments

Comments
 (0)