From 0172c61e5039ead7e66dc110a73a07cbc22cef0d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 29 Apr 2021 18:20:28 +0000 Subject: [PATCH] Format files using DocumentFormat --- docs/make.jl | 8 ++++---- src/CSVFiles.jl | 28 ++++++++++++++-------------- src/csv_writer.jl | 22 +++++++++++----------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/docs/make.jl b/docs/make.jl index d5b2f51..d8b0dda 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,14 +1,14 @@ using Documenter, CSVFiles makedocs( - modules = [CSVFiles], - sitename = "CSVFiles.jl", + modules=[CSVFiles], + sitename="CSVFiles.jl", analytics="UA-132838790-1", - pages = [ + pages=[ "Introduction" => "index.md" ] ) deploydocs( - repo = "github.com/queryverse/CSVFiles.jl.git" + repo="github.com/queryverse/CSVFiles.jl.git" ) diff --git a/src/CSVFiles.jl b/src/CSVFiles.jl index 7be4e06..d00fc16 100644 --- a/src/CSVFiles.jl +++ b/src/CSVFiles.jl @@ -50,36 +50,36 @@ end Base.showable(::MIME"application/vnd.dataresource+json", source::CSVStream) = true -function fileio_load(f::FileIO.File{FileIO.format"CSV"}, deprecated_delim=nothing; delim=deprecated_delim===nothing ? ',' : deprecated_delim, args...) - if deprecated_delim!==nothing - deprecated_delim!=delim && error("deprecated_delim and delim can not both be used at the same time.") +function fileio_load(f::FileIO.File{FileIO.format"CSV"}, deprecated_delim=nothing; delim=deprecated_delim === nothing ? ',' : deprecated_delim, args...) + if deprecated_delim !== nothing + deprecated_delim != delim && error("deprecated_delim and delim can not both be used at the same time.") Base.depwarn("The positional `delim` keyword in the `load` function is deprecated. Instead use the keyword argument `delim`.", :CSVFiles) end return CSVFile(f.filename, delim, args) end -function fileio_load(f::FileIO.File{FileIO.format"TSV"}, deprecated_delim=nothing; delim=deprecated_delim===nothing ? '\t' : deprecated_delim, args...) - if deprecated_delim!==nothing - deprecated_delim!=delim && error("deprecated_delim and delim can not both be used at the same time.") +function fileio_load(f::FileIO.File{FileIO.format"TSV"}, deprecated_delim=nothing; delim=deprecated_delim === nothing ? '\t' : deprecated_delim, args...) + if deprecated_delim !== nothing + deprecated_delim != delim && error("deprecated_delim and delim can not both be used at the same time.") Base.depwarn("The positional `delim` keyword in the `load` function is deprecated. Instead use the keyword argument `delim`.", :CSVFiles) end return CSVFile(f.filename, delim, args) end -function fileio_load(s::FileIO.Stream{FileIO.format"CSV"}, deprecated_delim=nothing; delim=deprecated_delim===nothing ? ',' : deprecated_delim, args...) - if deprecated_delim!==nothing - deprecated_delim!=delim && error("deprecated_delim and delim can not both be used at the same time.") +function fileio_load(s::FileIO.Stream{FileIO.format"CSV"}, deprecated_delim=nothing; delim=deprecated_delim === nothing ? ',' : deprecated_delim, args...) + if deprecated_delim !== nothing + deprecated_delim != delim && error("deprecated_delim and delim can not both be used at the same time.") Base.depwarn("The positional `delim` keyword in the `load` function is deprecated. Instead use the keyword argument `delim`.", :CSVFiles) end return CSVStream(s.io, delim, args) end -function fileio_load(s::FileIO.Stream{FileIO.format"TSV"}, deprecated_delim=nothing; delim=deprecated_delim===nothing ? '\t' : deprecated_delim, args...) - if deprecated_delim!==nothing - deprecated_delim!=delim && error("deprecated_delim and delim can not both be used at the same time.") +function fileio_load(s::FileIO.Stream{FileIO.format"TSV"}, deprecated_delim=nothing; delim=deprecated_delim === nothing ? '\t' : deprecated_delim, args...) + if deprecated_delim !== nothing + deprecated_delim != delim && error("deprecated_delim and delim can not both be used at the same time.") Base.depwarn("The positional `delim` keyword in the `load` function is deprecated. Instead use the keyword argument `delim`.", :CSVFiles) end @@ -114,7 +114,7 @@ end function TableTraits.get_columns_copy_using_missing(file::CSVFile) columns, colnames = _loaddata(file) - return NamedTuple{(Symbol.(colnames)...,), Tuple{typeof.(columns)...}}((columns...,)) + return NamedTuple{(Symbol.(colnames)...,),Tuple{typeof.(columns)...}}((columns...,)) end function IteratorInterfaceExtensions.getiterator(s::CSVStream) @@ -127,7 +127,7 @@ end function TableTraits.get_columns_copy_using_missing(s::CSVStream) columns, colnames = TextParse.csvread(s.io, s.delim; stringarraytype=Array, s.keywords...) - return NamedTuple{(Symbol.(colnames)...,), Tuple{typeof.(columns)...}}((columns...,)) + return NamedTuple{(Symbol.(colnames)...,),Tuple{typeof.(columns)...}}((columns...,)) end function Base.collect(x::CSVFile) diff --git a/src/csv_writer.jl b/src/csv_writer.jl index c439490..63fc4b4 100644 --- a/src/csv_writer.jl +++ b/src/csv_writer.jl @@ -5,7 +5,7 @@ end function _writevalue(io::IO, value::AbstractString, delim, quotechar, escapechar, nastring) print(io, quotechar) for c in value - if c==quotechar || c==escapechar + if c == quotechar || c == escapechar print(io, escapechar) end print(io, c) @@ -32,8 +32,8 @@ end push_exprs = Expr(:block) for i in 1:n push!(push_exprs.args, :( _writevalue(io, i.$(col_names[i]), delim, quotechar, escapechar, nastring) )) - if i "$(escapechar)$(quotechar)") * "$(quotechar)" for colname in colnames],delim) + join(io, ["$(quotechar)" * replace(string(colname), quotechar => "$(escapechar)$(quotechar)") * "$(quotechar)" for colname in colnames], delim) end println(io) end @@ -99,7 +99,7 @@ end # # Streaming version writes header (if any) on first call, then appends on subsequent calls. # -const CSV_or_TSV = Union{FileIO.format"CSV", FileIO.format"TSV"} +const CSV_or_TSV = Union{FileIO.format"CSV",FileIO.format"TSV"} _delim(T) = T <: FileIO.format"CSV" ? ',' : '\t' @@ -117,21 +117,21 @@ function fileio_savestreaming(f::FileIO.File{T}, data=nothing; delim=_delim(T), header=true) where T <: CSV_or_TSV io = open(f.filename, "w") - if data!==nothing + if data !== nothing _save(io, data; delim=delim, quotechar=quotechar, escapechar=escapechar, nastring=nastring, header=header) end - return CSVFileSaveStream(io, data!==nothing, delim, quotechar, escapechar, nastring, header) + return CSVFileSaveStream(io, data !== nothing, delim, quotechar, escapechar, nastring, header) end function fileio_savestreaming(s::FileIO.Stream{T}, data=nothing; delim=_delim(T), quotechar='"', escapechar='"', nastring="NA", header=false) where T <: CSV_or_TSV - if data!==nothing + if data !== nothing _save(s.io, data; delim=delim, quotechar=quotechar, escapechar=escapechar, nastring=nastring, header=header) end - return CSVFileSaveStream(s.io, data!==nothing, delim, quotechar, escapechar, nastring, header) + return CSVFileSaveStream(s.io, data !== nothing, delim, quotechar, escapechar, nastring, header) end function Base.write(s::CSVFileSaveStream, data)