loader: Update to new INI api
authorAlexandre Terrasa <alexandre@moz-code.org>
Sat, 15 Jun 2019 18:56:19 +0000 (14:56 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Thu, 20 Jun 2019 23:12:04 +0000 (19:12 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

lib/github/loader.nit
src/loader.nit

index 4ffa501..0704e5f 100644 (file)
@@ -104,12 +104,18 @@ class LoaderConfig
 
        # Github tokens used to access data.
        var tokens: Array[String] is lazy do
-               var arr = opt_tokens.value
-               if arr.is_empty then
-                       var iarr = ini.at("tokens")
-                       if iarr != null then arr = iarr.values.to_a
+               var opt_tokens = self.opt_tokens.value
+               if opt_tokens.not_empty then return opt_tokens
+
+               var res = new Array[String]
+               var ini_tokens = ini.section("tokens")
+               if ini_tokens == null then return res
+
+               for token in ini_tokens.values do
+                       if token == null then continue
+                       res.add token
                end
-               return arr or else new Array[String]
+               return res
        end
 
        # Github tokens wallet\13
index 8bdfcb2..169d52e 100644 (file)
@@ -477,7 +477,7 @@ redef class ModelBuilder
                        # Attach homonymous `ini` file to the package
                        var inipath = path.dirname / "{pn}.ini"
                        if inipath.file_exists then
-                               var ini = new ConfigTree(inipath)
+                               var ini = new IniFile.from_file(inipath)
                                mpackage.ini = ini
                        end
                end
@@ -543,7 +543,7 @@ redef class ModelBuilder
                var parent = null
                var inipath = dirpath / "package.ini"
                if inipath.file_exists then
-                       ini = new ConfigTree(inipath)
+                       ini = new IniFile.from_file(inipath)
                end
 
                if ini == null then
@@ -1178,7 +1178,7 @@ redef class MPackage
        # The `ini` file is given as is and might contain invalid or missing information.
        #
        # Some packages, like stand-alone packages or virtual packages have no `ini` file associated.
-       var ini: nullable ConfigTree = null
+       var ini: nullable IniFile = null
 
        # Array of relative source paths excluded according to the `source.exclude` key of the `ini`
        var excludes: nullable Array[String] is lazy do