Ver Fonte

Move type definition configs; various improvements.

scossu há 1 mês atrás
pai
commit
98e61f840e

+ 4 - 1
.gitignore

@@ -40,4 +40,7 @@ luac.out
 *.x86_64
 *.hex
 
-
+# Project-specific
+data/dres
+data/ores
+!.keep

+ 0 - 0
config/model/agent.yml → config/model/typedef/agent.yml


+ 0 - 0
config/model/anything.yml → config/model/typedef/anything.yml


+ 0 - 0
config/model/artifact.yml → config/model/typedef/artifact.yml


+ 0 - 0
config/model/file.yml → config/model/typedef/file.yml


+ 0 - 0
config/model/part.yml → config/model/typedef/part.yml


+ 0 - 0
data/.keep


+ 1 - 1
model_parser.lua

@@ -9,7 +9,7 @@ local M = {}
 
 -- Parameters that do not get inherited.
 local NO_INHERIT = {abstract = true}
-local MODEL_PATH = "./config/model/"
+local MODEL_PATH = "./config/model/typedef/"
 
 
 local function camel2snake(src)

+ 22 - 4
submission.lua

@@ -1,7 +1,13 @@
 local io = io
 
 local csv = require "csv"
+local uuid = require "uuid"
 
+-- Random number generator for uuid()
+local posix_uuid = pcall(function()
+    uuid.set_rng(uuid.rng.urandom())
+end)
+if not posix_uuid then rng = uuid.set_rng(uuid.rng.win_ffi()) end
 
 local M = {}  -- Submission module
 
@@ -27,7 +33,7 @@ local function escape_pattern(s)
 end
 
 
-M.deposit = function(path)
+M.generate_sip = function(path)
     local sub_data = assert(csv.open(path))
     local md = {}
     local prev_ref, prev_k
@@ -74,16 +80,20 @@ M.deposit = function(path)
             end
         end
 
-        md[ref] = md[ref] or {path = ref, _sort = i}
+        md[ref] = md[ref] or {id = uuid(), path = ref, _sort = i}
         md[ref][k] = md[ref][k] or {}
-        table.insert(md[ref][k], v)
+        if k == "type" then
+            md[ref][k] = v
+        else
+            table.insert(md[ref][k], v)
+        end
 
         ::continue::
         i = i + 1
     end
 
     -- Move md to an ordered list.
-    mdlist = {}
+    mdlist = {root_path = path:match("(.*/)")}
     for _, v in pairs(md) do table.insert(mdlist, v) end
     table.sort(mdlist, function (a, b) return (a._sort < b._sort) end)
 
@@ -108,4 +118,12 @@ M.deposit = function(path)
     return mdlist
 end
 
+
+M.deposit = function(sip)
+    for i, rsrc in ipairs(sip) do
+        print(("Processing resource #%d of %d"):format(i, #sip))
+        abs_path = sip.root_path 
+    end
+end
+
 return M