Skip to content

Commit

Permalink
Fix deprecation warnings on julia 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Jul 31, 2016
1 parent a0f1551 commit 8914643
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
julia 0.4
Compat 0.7.16
20 changes: 11 additions & 9 deletions src/MetadataTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ module MetadataTools

export get_pkg, get_all_pkg, get_upper_limit, get_pkg_info

using Compat

#-----------------------------------------------------------------------

"""
Expand All @@ -21,8 +23,8 @@ Represents a version of a package in METADATA.jl
"""
immutable PkgMetaVersion
ver::VersionNumber
sha::UTF8String
requires::Vector{UTF8String}
sha::Compat.UTF8String
requires::Vector{Compat.UTF8String}
end
function printer(io::IO, pmv::PkgMetaVersion)
print(io, " ", pmv.ver, ",", pmv.sha[1:6])
Expand All @@ -37,8 +39,8 @@ Base.show( io::IO, pmv::PkgMetaVersion) = printer(io,pmv)
Represents a packages entry in METADATA.jl
"""
immutable PkgMeta
name::UTF8String
url::UTF8String
name::Compat.UTF8String
url::Compat.UTF8String
versions::Vector{PkgMetaVersion}
end
function printer(io::IO, pm::PkgMeta)
Expand Down Expand Up @@ -78,7 +80,7 @@ function get_pkg(pkg_name::AbstractString;

url_path = joinpath(pkg_path,"url")
!isfile(url_path) && error("Couldn't find url for $pkg_name (expected $url_path)")
url = chomp(readall(url_path))
url = chomp(readstring(url_path))

vers_path = joinpath(pkg_path,"versions")
!isdir(vers_path) &&
Expand All @@ -89,11 +91,11 @@ function get_pkg(pkg_name::AbstractString;
for dir in readdir(vers_path)
ver_num = convert(VersionNumber, dir)
ver_path = joinpath(vers_path, dir)
sha = strip(readall(joinpath(ver_path,"sha1")))
sha = strip(readstring(joinpath(ver_path,"sha1")))
req_path = joinpath(ver_path,"requires")
reqs = UTF8String[]
reqs = Compat.UTF8String[]
if isfile(req_path)
req_file = map(strip,split(readall(req_path),"\n"))
req_file = map(strip,split(readstring(req_path),"\n"))
for req in req_file
length(req) == 0 && continue
req[1] == '#' && continue
Expand All @@ -116,7 +118,7 @@ in the METADATA folder.
function get_all_pkg(; meta_path=Pkg.dir("METADATA"))
!isdir(meta_path) && error("Couldn't find METADATA folder at $meta_path")

pkgs = Dict{UTF8String,PkgMeta}()
pkgs = Dict{Compat.UTF8String,PkgMeta}()
for fname in readdir(meta_path)
# Skip files
!isdir(joinpath(meta_path, fname)) && continue
Expand Down
14 changes: 7 additions & 7 deletions src/pkg_graph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ package dependency graph.
"""
type PkgGraph
adjlist::Vector{Vector{Int}}
pkgnames::Vector{UTF8String}
pkgname_idx::Dict{UTF8String,Int}
pkgnames::Vector{Compat.UTF8String}
pkgname_idx::Dict{Compat.UTF8String,Int}
end

"""
Expand Down Expand Up @@ -54,10 +54,10 @@ Given a Dict{UTF8String,PkgMeta} (e.g., from `get_all_pkg`), build a
directed graph with an edge from PkgA to PkgB iff PkgA directly requires
PkgB. Alternatively reverse the direction of the edges if `reverse` is true.
"""
function make_dep_graph(pkgs::Dict{UTF8String,PkgMeta}; reverse=false)
function make_dep_graph(pkgs::Dict{Compat.UTF8String,PkgMeta}; reverse=false)
pkgnames = collect(keys(pkgs))
pkgname_idx = Dict{UTF8String,Int}(
[pkgname => i for (i,pkgname) in enumerate(pkgnames)])
pkgname_idx = Dict{Compat.UTF8String,Int}(
[(pkgname, i) for (i,pkgname) in enumerate(pkgnames)]) # TODO: Dict(pkgname=>i for ...)
numpkg = length(pkgnames)
adjlist = Vector{Int}[Vector{Int}() for pkgname in pkgnames]

Expand Down Expand Up @@ -139,8 +139,8 @@ function get_pkg_dep_graph(pkgname::AbstractString, pg::PkgGraph; depth=Inf)
end
end
# Build subgraph
new_pkgnames = UTF8String["" for i in 1:new_n]
new_pkgname_idx = Dict{UTF8String,Int}()
new_pkgnames = Compat.UTF8String["" for i in 1:new_n]
new_pkgname_idx = Dict{Compat.UTF8String,Int}()
new_adjlist = Vector{Int}[Vector{Int}() for i in 1:new_n]
for old_idx in 1:n
!visited[old_idx] && continue
Expand Down

0 comments on commit 8914643

Please sign in to comment.