Skip to content

Commit

Permalink
run JuliaFormatter
Browse files Browse the repository at this point in the history
  • Loading branch information
visr committed Sep 27, 2021
1 parent ebc9c15 commit 6b4ef1a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
13 changes: 5 additions & 8 deletions src/DBFTables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct Header
mdx::Bool
lang_id::UInt8
fields::Vector{FieldDescriptor}
fieldcolumns::Dict{Symbol, Int}
fieldcolumns::Dict{Symbol,Int}
end

"Struct representing the DBF Table"
Expand Down Expand Up @@ -97,7 +97,7 @@ function Header(io::IO)
fields = FieldDescriptor[]

# use Dict for quicker column index lookup
fieldcolumns = Dict{Symbol, Int}()
fieldcolumns = Dict{Symbol,Int}()
col = 1
while !eof(io)
field = read_dbf_field(io)
Expand Down Expand Up @@ -146,8 +146,7 @@ function dbf_value(::Type{Bool}, str::AbstractString)
end
end

dbf_value(T::Union{Type{Int},Type{Float64}}, str::AbstractString) =
miss(tryparse(T, str))
dbf_value(T::Union{Type{Int},Type{Float64}}, str::AbstractString) = miss(tryparse(T, str))
# String to avoid returning SubString{String}
function dbf_value(::Type{String}, str::AbstractString)
stripped = rstrip(str)
Expand Down Expand Up @@ -221,10 +220,8 @@ function Base.NamedTuple(row::Row)
ncol = length(fields)
rowidx = getrow(row)
@inbounds record = @view str[:, rowidx]
@inbounds prs = (fields[col].name => dbf_value(
fields[col].type,
record[col],
) for col = 1:ncol)
@inbounds prs =
(fields[col].name => dbf_value(fields[col].type, record[col]) for col = 1:ncol)
return (; prs...)
end

Expand Down
6 changes: 2 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ row, st = iterate(dbf)
@testset "show" begin
@test sprint(show, row) === sprint(show, NamedTuple(row))
# use replace to update to julia 1.4 union printing
@test replace(sprint(
show,
dbf,
), r"\} +"=>"}") === "DBFTables.Table with 7 rows and 6 columns\nTables.Schema:\n :CHAR Union{Missing, String}\n :DATE Union{Missing, String}\n :BOOL Union{Missing, Bool}\n :FLOAT Union{Missing, Float64}\n :NUMERIC Union{Missing, Float64}\n :INTEGER Union{Missing, $Int}\n"
@test replace(sprint(show, dbf), r"\} +" => "}") ===
"DBFTables.Table with 7 rows and 6 columns\nTables.Schema:\n :CHAR Union{Missing, String}\n :DATE Union{Missing, String}\n :BOOL Union{Missing, Bool}\n :FLOAT Union{Missing, Float64}\n :NUMERIC Union{Missing, Float64}\n :INTEGER Union{Missing, $Int}\n"
end

@testset "iterate" begin
Expand Down

2 comments on commit 6b4ef1a

@visr
Copy link
Collaborator Author

@visr visr commented on 6b4ef1a Sep 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/45583

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.0 -m "<description of version>" 6b4ef1ab5843225a0e0fae04abbc3bbb44fcac44
git push origin v1.0.0

Please sign in to comment.