-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Expand file tree
/
Copy pathTradeQueryGenerator.lua.rej
More file actions
64 lines (58 loc) · 2.56 KB
/
Copy pathTradeQueryGenerator.lua.rej
File metadata and controls
64 lines (58 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
diff a/src/Classes/TradeQueryGenerator.lua b/src/Classes/TradeQueryGenerator.lua (rejected hunks)
@@ -10,6 +10,7 @@ local m_max = math.max
local s_format = string.format
local t_insert = table.insert
local tradeHelpers = LoadModule("Classes/TradeHelpers")
+local utils = LoadModule("Modules/Utils")
-- string are an any type while tables require all fields to be matched with type and subType require both to be matched exactly. [1] type, [2] subType, subType is optional and must be nil if not present.
local tradeCategoryNames = {
@@ -395,11 +396,6 @@ function TradeQueryGeneratorClass:InitMods()
error("Error received from api/trade2/data/stats: "..body.error.message)
end
- local f = io.open("./Data/TradeSiteStats.lua", "w")
- if not f then
- error("Could not open file for writing trade stat data")
- end
-
for catIdx, _ in ipairs(body.result) do
table.sort(body.result[catIdx].entries, function(a, b)
if a.text == b.text then
@@ -409,14 +405,8 @@ function TradeQueryGeneratorClass:InitMods()
end)
end
- local template = [[-- This file is automatically downloaded, do not edit!
--- Trade site stat data (c) Grinding Gear Games
--- https://www.pathofexile.com/api/trade2/data/stats
--- spell-checker: disable
-return %s
--- spell-checker: enable]]
- f:write(s_format(template, stringify(body.result)))
- f:close()
+ local description = "This file contains the trade site data from https://www.pathofexile.com/api/trade2/data/stats"
+ utils.saveTableToFile("./Data/TradeSiteStats.lua", body.result, description)
self.modData = {
["Explicit"] = { },
@@ -636,19 +626,12 @@ return %s
end
end
- local queryModsFile = io.open(queryModFilePath, 'w')
- queryModsFile:write([[-- This file is automatically generated, do not edit!
--- Stat data (c) Grinding Gear Games
-
--- This file contains categories of stats, mapped from trade hash to details
--- relevant for generating search weights Note that the trade site requires a
--- prefix of e.g. explicit.stat_{hash}. See
--- https://www.pathofexile.com/api/trade2/data/stats for a list of all trade
--- site stats.
-
-]])
- queryModsFile:write("return " .. stringify(self.modData))
- queryModsFile:close()
+ local qmDescription = [[This file contains categories of stats, mapped from trade hash to details
+relevant for generating search weights Note that the trade site requires a
+prefix of e.g. explicit.stat_{hash}. See
+TradeSiteStats.lua for a list of all trade
+site stats.]]
+ utils.saveTableToFile(queryModFilePath, self.modData, qmDescription)
end
function TradeQueryGeneratorClass:GenerateModWeights(modsToTest)