Skip to content

use pyhasattr instead of hasproperty #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/PythonPlot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function Base.show(io::IO, ::MIME"text/plain", h::LazyHelp)
for k in h.keys
o = pygetattr(o, k)
end
if hasproperty(o, :__doc__)
if pyhasattr(o, "__doc__")
print(io, pyconvert(String, o.__doc__))
else
print(io, "no Python docstring found for ", o)
Expand Down Expand Up @@ -76,7 +76,7 @@ Base.getproperty(f::Figure, s::Symbol) = getproperty(Py(f), s)
Base.getproperty(f::Figure, s::AbstractString) = getproperty(f, Symbol(s))
Base.setproperty!(f::Figure, s::Symbol, x) = setproperty!(Py(f), s, x)
Base.setproperty!(f::Figure, s::AbstractString, x) = setproperty!(f, Symbol(s), x)
Base.hasproperty(f::Figure, s::Symbol) = hasproperty(Py(f), s)
Base.hasproperty(f::Figure, s::Symbol) = pyhasattr(Py(f), s)
Base.propertynames(f::Figure) = propertynames(Py(f))

for (mime,fmt) in aggformats
Expand Down Expand Up @@ -175,10 +175,10 @@ const plt_funcs = (:acorr,:annotate,:arrow,:autoscale,:autumn,:axes,:axhline,:ax
for f in plt_funcs
sf = string(f)
@eval @doc LazyHelp(pyplot,$sf) function $f(args...; kws...)
if !hasproperty(pyplot, $(QuoteNode(f)))
if !pyhasattr(pyplot, $sf)
error("matplotlib ", version, " does not have pyplot.", $sf)
end
return pycall(pyplot.$f, args...; kws...)
return pycall(pyplot.$sf, args...; kws...)
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/colormaps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Base.getproperty(c::ColorMap, s::AbstractString) = getproperty(Py(c), Symbol(s))
Base.setproperty!(c::ColorMap, s::Symbol, x) = setproperty!(Py(c), s, x)
Base.setproperty!(c::ColorMap, s::AbstractString, x) = setproperty!(Py(c), Symbol(s), x)
Base.propertynames(c::ColorMap) = propertynames(Py(c))
Base.hasproperty(c::ColorMap, s::Union{Symbol,AbstractString}) = hasproperty(Py(c), s)
Base.hasproperty(c::ColorMap, s::Union{Symbol,AbstractString}) = pyhasattr(Py(c), s)

function Base.show(io::IO, c::ColorMap)
print(io, "ColorMap \"$(pyconvert(String, c.name))\"")
Expand Down
2 changes: 1 addition & 1 deletion src/plot3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ PythonCall.Py(m::LazyPyModule) = _ispynull(getfield(m, :o)) ? PythonCall.pycopy!
Base.Docs.doc(m::LazyPyModule) = Base.Docs.Text(pyconvert(String, Py(m).__doc__))
Base.getproperty(m::LazyPyModule, x::Symbol) = getproperty(Py(m), x)
Base.setproperty!(m::LazyPyModule, x::Symbol, v) = setproperty!(Py(m), x, v)
Base.hasproperty(m::LazyPyModule, x::Symbol) = PyCall.hasproperty(Py(m), x)
Base.hasproperty(m::LazyPyModule, x::Symbol) = pyhasattr(Py(m), x)
Base.propertynames(m::LazyPyModule) = propertynames(Py(m))

###########################################################################
Expand Down