From 96a8e557d3bb9b887dd7d504a4c20f05a87e6cbe Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Sat, 13 Mar 2010 02:11:41 +0100 Subject: Make use of io.lines() where appropriate --- net.lua | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'net.lua') diff --git a/net.lua b/net.lua index 365d3c6..0550557 100644 --- a/net.lua +++ b/net.lua @@ -7,7 +7,7 @@ -- {{{ Grab environment local tonumber = tonumber local os = { time = os.time } -local io = { open = io.open } +local io = { lines = io.lines } local setmetatable = setmetatable local string = { match = string.match } local helpers = require("vicious.helpers") @@ -27,11 +27,10 @@ local unit = { ["b"] = 1, ["kb"] = 1024, -- {{{ Net widget type local function worker(format) - -- Get /proc/net/dev - local f = io.open("/proc/net/dev") local args = {} - for line in f:lines() do + -- Get NET stats + for line in io.lines("/proc/net/dev") do -- Match wmaster0 as well as rt0 (multiple leading spaces) local name = string.match(line, "^[%s]?[%s]?[%s]?[%s]?([%w]+):") if name ~= nil then @@ -68,7 +67,6 @@ local function worker(format) nets[name][2] = send end end - f:close() return args end -- cgit v1.2.3