diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2013-12-31 10:11:56 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2013-12-31 10:11:56 +0000 |
commit | 97e61df20acf6cc7cefb2b194f0167798fe735b0 (patch) | |
tree | 0fcf3d6115ac18b6a73a4d7de55e749482b6692d /aports/db.lua | |
parent | f84810bb676c829f0b8a5a69d2ae03e4cc507f24 (diff) | |
download | lua-aports-97e61df20acf6cc7cefb2b194f0167798fe735b0.tar.bz2 lua-aports-97e61df20acf6cc7cefb2b194f0167798fe735b0.tar.xz |
db: API changes
rename functions:
each() -> each_name()
each_pkg -> each_pkg_with_name() (returns pkg, index)
new functions:
each() iterates all pkgs. returns pkg, name
Diffstat (limited to 'aports/db.lua')
-rw-r--r-- | aports/db.lua | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/aports/db.lua b/aports/db.lua index 009520b..a13c8b2 100644 --- a/aports/db.lua +++ b/aports/db.lua @@ -146,7 +146,7 @@ function Aports:target_packages(pkgname) end) end -function Aports:each() +function Aports:each_name() local apks = self.apks return coroutine.wrap(function() for k,v in pairs(self.apks) do @@ -163,24 +163,32 @@ function Aports:each_reverse_dependency(pkg) end) end -function Aports:each_pkg(pkg, f) - if self.apks[pkg] == nil then - io.stderr:write("WARNING: "..pkg.." has no data\n") +function Aports:each_pkg_with_name(name) + if self.apks[name] == nil then + io.stderr:write("WARNING: "..name.." has no data\n") end return coroutine.wrap(function() - for k,v in pairs(self.apks[pkg]) do - coroutine.yield(k,v) + for index, pkg in pairs(self.apks[name]) do + coroutine.yield(pkg, index) + end + end) +end + +function Aports:each() + return coroutine.wrap(function() + for name, a in self:each_name() do + for _, pkg in pairs(a) do + coroutine.yield(pkg, name) + end end end) end function Aports:each_aport() return coroutine.wrap(function() - for pkgname,v in self:each() do - for _,pkg in self:each_pkg(pkgname) do - if pkgname == pkg.pkgname then - coroutine.yield(pkg) - end + for pkg, name in self:each() do + if name == pkg.pkgname then + coroutine.yield(pkg) end end end) |