Skip to content

Commit

Permalink
deprecate old find methods (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
bicycle1885 authored Aug 10, 2018
1 parent 5f14de5 commit 3751fbe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
9 changes: 9 additions & 0 deletions src/EzXML.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,13 @@ function __init__()
init_error_handler()
end

# deprcated methods
import Base: findall, findfirst, findlast
@deprecate findall(doc::Document, xpath::AbstractString) findall(xpath, doc)
@deprecate findfirst(doc::Document, xpath::AbstractString) findfirst(xpath, doc)
@deprecate findlast(doc::Document, xpath::AbstractString) findlast(xpath, doc)
@deprecate findall(node::Node, xpath::AbstractString, ns=namespaces(node)) findall(xpath, node, ns)
@deprecate findfirst(node::Node, xpath::AbstractString, ns=namespaces(node)) findfirst(xpath, node, ns)
@deprecate findlast(node::Node, xpath::AbstractString, ns=namespaces(node)) findlast(xpath, node, ns)

end # module
8 changes: 0 additions & 8 deletions src/xpath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,6 @@ function Base.findlast(xpath::AbstractString, node::Node, ns=namespaces(node))
return isempty(nodes) ? nothing : last(nodes)
end

# Deprecated
Base.findall(doc::Document, xpath::AbstractString) = findall(xpath, doc)
Base.findfirst(doc::Document, xpath::AbstractString) = first(findall(xpath, doc))
Base.findlast(doc::Document, xpath::AbstractString) = last(findall(xpath, doc))
Base.findall(node::Node, xpath::AbstractString, ns=namespaces(node)) = findall(xpath, node, ns)
Base.findfirst(node::Node, xpath::AbstractString, ns=namespaces(node)) = first(findall(xpath, node, ns))
Base.findlast(node::Node, xpath::AbstractString, ns=namespaces(node)) = last(findall(xpath, node, ns))

function new_xpath_context(doc)
context_ptr = ccall(
(:xmlXPathNewContext, libxml2),
Expand Down
9 changes: 0 additions & 9 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1216,15 +1216,6 @@ end
@test findfirst("bambam", root(doc)) === nothing
@test findlast("bambam", root(doc)) === nothing

# TODO: remove these tests; deprecated functions
@test_throws BoundsError findfirst(doc, "bambam")
@test_throws BoundsError findlast(doc, "bambam")
@test_throws BoundsError findfirst(root(doc), "bambam")
@test_throws BoundsError findlast(root(doc), "bambam")
@inferred findall(doc, "root")
@inferred findfirst(doc, "root")
@inferred findlast(doc, "root")

go = readxml(joinpath(dirname(@__FILE__), "go.sample.xml"))
go_uri = "http://www.geneontology.org/dtds/go.dtd#"
@test findall("/go:go", root(go)) == [root(go)]
Expand Down

0 comments on commit 3751fbe

Please sign in to comment.