-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTypesToDifferentFiles.lua
47 lines (30 loc) · 1.1 KB
/
TypesToDifferentFiles.lua
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
-- Created by Alan Wake 8/8/2024
local xml2lua = require("xml2lua")
local handler = require("xmlhandler.tree")
local file = io.open("types.xml", "r")
if (not file) then
print("You should insert your types.xml near the prog")
return 1
end
file:close()
local file_contents = xml2lua.loadFile("types.xml")
local parser = xml2lua.parser(handler)
parser:parse(file_contents)
local created_io = {}
local function tryNewIO(category, type, loc)
if (created_io[category]) then
created_io[category]:write("\n" .. type .. " " ..loc)
return
end
created_io[category] = io.open(category..".txt", "w+")
created_io[category]:write("\n" .. type .. " " ..loc)
end
local txt = ""
for k,v in pairs(handler.root.types.type)do
local name = v._attr.name
local usage = v.usage and v.usage._attr and v.usage._attr.name or "usage_not_defined"
local category = v.category and v.category._attr and v.category._attr.name or "undefined_category"
tryNewIO(category, name, usage)
end
local f = io.open("test.txt","w+")
f:write(txt)