plugins(chore): fix static check errors

pull/2311/head
Qingping Hou 8 years ago
parent 378ba2c7fe
commit 93873bfd69

@ -1,12 +1,11 @@
local InputContainer = require("ui/widget/container/inputcontainer") local InputContainer = require("ui/widget/container/inputcontainer")
local InfoMessage = require("ui/widget/infomessage") local InfoMessage = require("ui/widget/infomessage")
local UIManager = require("ui/uimanager") local UIManager = require("ui/uimanager")
local util = require("ffi/util")
local JSON = require("json") local JSON = require("json")
local DEBUG = require("dbg") local DEBUG = require("dbg")
local _ = require("gettext") local _ = require("gettext")
local dummy = require("ffi/zeromq_h") require("ffi/zeromq_h")
--[[ --[[
This plugin implements a simple Calibre Companion protocol that communicates This plugin implements a simple Calibre Companion protocol that communicates
@ -66,14 +65,14 @@ function CalibreCompanion:find_calibre_server()
udp:settimeout(3) udp:settimeout(3)
for _, port in ipairs(self.broadcast_ports) do for _, port in ipairs(self.broadcast_ports) do
-- broadcast anything to calibre ports and listen to the reply -- broadcast anything to calibre ports and listen to the reply
local sent, err = udp:sendto("hello", "255.255.255.255", port) local _, err = udp:sendto("hello", "255.255.255.255", port)
if not err then if not err then
local dgram, host = udp:receivefrom() local dgram, host = udp:receivefrom()
if dgram and host then if dgram and host then
-- replied diagram has greet message from calibre and calibre hostname -- replied diagram has greet message from calibre and calibre hostname
-- calibre opds port and calibre socket port we will later connect to -- calibre opds port and calibre socket port we will later connect to
local _, hostname, _, port = dgram:match("(.-)%(on (.-)%);(.-),(.-)$") local _, _, _, replied_port = dgram:match("(.-)%(on (.-)%);(.-),(.-)$")
return host, port return host, replied_port
end end
end end
end end
@ -123,7 +122,6 @@ end
-- will callback initCalibreMQ if inbox is confirmed to be set -- will callback initCalibreMQ if inbox is confirmed to be set
function CalibreCompanion:setInboxDir(host, port) function CalibreCompanion:setInboxDir(host, port)
local lastdir = G_reader_settings:readSetting("lastdir") or "."
local calibre_device = self local calibre_device = self
require("ui/downloadmgr"):new{ require("ui/downloadmgr"):new{
title = _("Choose inbox"), title = _("Choose inbox"),
@ -173,7 +171,7 @@ function CalibreCompanion:onReceiveJSON(data)
--DEBUG("buffer", self.buffer) --DEBUG("buffer", self.buffer)
local index = self.buffer:find('%[') or 1 local index = self.buffer:find('%[') or 1
local size = tonumber(self.buffer:sub(1, index - 1)) local size = tonumber(self.buffer:sub(1, index - 1))
local json_data = nil local json_data
if size and #self.buffer >= index - 1 + size then if size and #self.buffer >= index - 1 + size then
json_data = self.buffer:sub(index, index - 1 + size) json_data = self.buffer:sub(index, index - 1 + size)
--DEBUG("json_data", json_data) --DEBUG("json_data", json_data)
@ -295,7 +293,6 @@ end
function CalibreCompanion:getBookCount(arg) function CalibreCompanion:getBookCount(arg)
DEBUG("GET_BOOK_COUNT", arg) DEBUG("GET_BOOK_COUNT", arg)
local option = arg
local books = { local books = {
willStream = true, willStream = true,
willScan = true, willScan = true,
@ -340,8 +337,8 @@ function CalibreCompanion:sendBook(arg)
timeout = 1, timeout = 1,
}) })
-- switch to JSON data receiving mode -- switch to JSON data receiving mode
calibre_socket.receiveCallback = function(data) calibre_socket.receiveCallback = function(json_data)
calibre_device:onReceiveJSON(data) calibre_device:onReceiveJSON(json_data)
end end
-- if calibre sends multiple files there may be left JSON data -- if calibre sends multiple files there may be left JSON data
calibre_device.buffer = data:sub(#to_write_data + 1) or "" calibre_device.buffer = data:sub(#to_write_data + 1) or ""

@ -1,8 +1,6 @@
local DocumentRegistry = require("document/documentregistry") local DocumentRegistry = require("document/documentregistry")
local DocSettings = require("docsettings") local DocSettings = require("docsettings")
local DEBUG = require("dbg")
local md5 = require("ffi/MD5") local md5 = require("ffi/MD5")
-- lfs
local MyClipping = { local MyClipping = {
my_clippings = "/mnt/us/documents/My Clippings.txt", my_clippings = "/mnt/us/documents/My Clippings.txt",
@ -10,7 +8,7 @@ local MyClipping = {
} }
function MyClipping:new(o) function MyClipping:new(o)
o = o or {} if o == nil then o = {} end
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o
@ -48,7 +46,6 @@ function MyClipping:parseMyClippings()
local clippings = {} local clippings = {}
if file then if file then
local index = 1 local index = 1
local corrupted = false
local title, author, info, text local title, author, info, text
for line in file:lines() do for line in file:lines() do
line = line:match("^%s*(.-)%s*$") or "" line = line:match("^%s*(.-)%s*$") or ""
@ -264,10 +261,10 @@ function MyClipping:parseHistory()
if ok and stored.highlight then if ok and stored.highlight then
local _, _, docname = path:find("%[.*%](.*)%.lua$") local _, _, docname = path:find("%[.*%](.*)%.lua$")
local title, author = self:getTitle(docname) local title, author = self:getTitle(docname)
local path = DocSettings:getPathFromHistory(f) local docpath = DocSettings:getPathFromHistory(f)
local name = DocSettings:getNameFromHistory(f) local name = DocSettings:getNameFromHistory(f)
clippings[title] = { clippings[title] = {
file = path .. "/" .. name, file = docpath .. "/" .. name,
title = title, title = title,
author = author, author = author,
} }

@ -6,7 +6,6 @@ local DataStorage = require("datastorage")
local DocSettings = require("docsettings") local DocSettings = require("docsettings")
local UIManager = require("ui/uimanager") local UIManager = require("ui/uimanager")
local Screen = require("device").screen local Screen = require("device").screen
local Event = require("ui/event")
local util = require("ffi/util") local util = require("ffi/util")
local Device = require("device") local Device = require("device")
local DEBUG = require("dbg") local DEBUG = require("dbg")
@ -23,8 +22,8 @@ local EvernoteExporter = InputContainer:new{
notemarks = _("Note: "), notemarks = _("Note: "),
clipping_dir = DataStorage:getDataDir() .. "/clipboard", clipping_dir = DataStorage:getDataDir() .. "/clipboard",
evernote_token, evernote_token = nil,
notebook_guid, notebook_guid = nil,
} }
function EvernoteExporter:init() function EvernoteExporter:init()
@ -61,7 +60,7 @@ function EvernoteExporter:addToMainMenu(tab_item_table)
sub_item_table = { sub_item_table = {
{ {
text_func = function() text_func = function()
local domain = nil local domain
if self.evernote_domain == "sandbox" then if self.evernote_domain == "sandbox" then
domain = "Sandbox" domain = "Sandbox"
elseif self.evernote_domain == "yinxiang" then elseif self.evernote_domain == "yinxiang" then
@ -212,7 +211,8 @@ function EvernoteExporter:doLogin(username, password)
domain = self.evernote_domain, domain = self.evernote_domain,
authToken = token, authToken = token,
} }
local ok, guid = pcall(self.getExportNotebook, self, client) local guid
ok, guid = pcall(self.getExportNotebook, self, client)
if not ok and guid and guid:find("Transport not open") then if not ok and guid and guid:find("Transport not open") then
NetworkMgr:promptWifiOn() NetworkMgr:promptWifiOn()
return return

@ -19,7 +19,7 @@ local function include_fold(template, start_tag, end_tag, fold_func, init_func)
local start_tag_inc = start_tag..'include:' local start_tag_inc = start_tag..'include:'
local start1, end1 = string.find(template, start_tag_inc, 1, true) local start1, end1 = string.find(template, start_tag_inc, 1, true)
local start2 = nil local start2
local end2 = 0 local end2 = 0
while start1 ~= nil do while start1 ~= nil do
@ -101,7 +101,7 @@ function slt2.loadstring(template, start_tag, end_tag, tmpl_name)
template = slt2.precompile(template, start_tag, end_tag) template = slt2.precompile(template, start_tag, end_tag)
local start1, end1 = string.find(template, start_tag, 1, true) local start1, end1 = string.find(template, start_tag, 1, true)
local start2 = nil local start2
local end2 = 0 local end2 = 0
local cEqual = string.byte('=', 1) local cEqual = string.byte('=', 1)

@ -7,7 +7,7 @@ local KOSyncClient = {
} }
function KOSyncClient:new(o) function KOSyncClient:new(o)
local o = o or {} if o == nil then o = {} end
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
if o.init then o:init() end if o.init then o:init() end
@ -21,7 +21,7 @@ function KOSyncClient:init()
base_url = self.custom_url, base_url = self.custom_url,
}) })
package.loaded['Spore.Middleware.GinClient'] = {} package.loaded['Spore.Middleware.GinClient'] = {}
require('Spore.Middleware.GinClient').call = function(self, req) require('Spore.Middleware.GinClient').call = function(_, req)
req.headers['accept'] = "application/vnd.koreader.v1+json" req.headers['accept'] = "application/vnd.koreader.v1+json"
end end
package.loaded['Spore.Middleware.KOSyncAuth'] = {} package.loaded['Spore.Middleware.KOSyncAuth'] = {}

@ -1,10 +1,8 @@
local InputContainer = require("ui/widget/container/inputcontainer") local InputContainer = require("ui/widget/container/inputcontainer")
local MultiInputDialog = require("ui/widget/multiinputdialog") local MultiInputDialog = require("ui/widget/multiinputdialog")
local CenterContainer = require("ui/widget/container/centercontainer")
local KeyValuePage = require("ui/widget/keyvaluepage") local KeyValuePage = require("ui/widget/keyvaluepage")
local UIManager = require("ui/uimanager") local UIManager = require("ui/uimanager")
local Screen = require("device").screen local Screen = require("device").screen
local Font = require("ui/font")
local TimeVal = require("ui/timeval") local TimeVal = require("ui/timeval")
local DataStorage = require("datastorage") local DataStorage = require("datastorage")
local lfs = require("libs/libkoreader-lfs") local lfs = require("libs/libkoreader-lfs")
@ -286,7 +284,7 @@ function ReaderStatistics:getCurrentStat()
} }
end end
function generateReadBooksTable(title, dates) local function generateReadBooksTable(title, dates)
local result = {} local result = {}
for k, v in tableutil.spairs(dates, function(t, a, b) return t[b].date < t[a].date end) do for k, v in tableutil.spairs(dates, function(t, a, b) return t[b].date < t[a].date end) do
table.insert(result, { table.insert(result, {
@ -298,7 +296,7 @@ function generateReadBooksTable(title, dates)
end end
-- For backward compatibility -- For backward compatibility
function getDatesForBookOldFormat(book) local function getDatesForBookOldFormat(book)
local dates = {} local dates = {}
for k, v in pairs(book.details) do for k, v in pairs(book.details) do
@ -330,7 +328,6 @@ function ReaderStatistics:getDatesFromAll(sdays, ptype)
local dates = {} local dates = {}
local sorted_performance_in_pages local sorted_performance_in_pages
local diff local diff
local book = {}
local now_t = os.date("*t") local now_t = os.date("*t")
local from_begin_day = now_t.hour *3600 + now_t.min*60 + now_t.sec local from_begin_day = now_t.hour *3600 + now_t.min*60 + now_t.sec
local now_stamp = os.time() local now_stamp = os.time()
@ -399,7 +396,7 @@ function ReaderStatistics:getDatesFromAll(sdays, ptype)
return generateReadBooksTable("", dates) return generateReadBooksTable("", dates)
end end
function getDatesForBook(book) local function getDatesForBook(book)
local dates = {} local dates = {}
local sorted_performance_in_pages = {} local sorted_performance_in_pages = {}
local diff local diff

@ -1,20 +1,9 @@
local InputContainer = require("ui/widget/container/inputcontainer") local InputContainer = require("ui/widget/container/inputcontainer")
local FrameContainer = require("ui/widget/container/framecontainer")
local VerticalGroup = require("ui/widget/verticalgroup")
local VerticalSpan = require("ui/widget/verticalspan")
local ButtonDialog = require("ui/widget/buttondialog")
local InfoMessage = require("ui/widget/infomessage") local InfoMessage = require("ui/widget/infomessage")
local TextWidget = require("ui/widget/textwidget")
local DocSettings = require("docsettings")
local UIManager = require("ui/uimanager") local UIManager = require("ui/uimanager")
local Screen = require("device").screen
local Event = require("ui/event")
local Font = require("ui/font")
local ltn12 = require("ltn12") local ltn12 = require("ltn12")
local DEBUG = require("dbg") local DEBUG = require("dbg")
local _ = require("gettext") local _ = require("gettext")
local util = require("ffi/util")
-- lfs
local ffi = require("ffi") local ffi = require("ffi")
ffi.cdef[[ ffi.cdef[[
@ -22,7 +11,7 @@ int remove(const char *);
int rmdir(const char *); int rmdir(const char *);
]] ]]
local dummy = require("ffi/zeromq_h") require("ffi/zeromq_h")
local ZSync = InputContainer:new{ local ZSync = InputContainer:new{
name = "zsync", name = "zsync",
} }

@ -72,7 +72,6 @@ local function showusage()
print("") print("")
print("This software is licensed under the AGPLv3.") print("This software is licensed under the AGPLv3.")
print("See http://github.com/koreader/koreader for more info.") print("See http://github.com/koreader/koreader for more info.")
return
end end
-- should check DEBUG option in arg and turn on DEBUG before loading other -- should check DEBUG option in arg and turn on DEBUG before loading other

Loading…
Cancel
Save