From e63928049d9bedbafc148c9d59fc189e2eda4552 Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Sat, 15 Jun 2019 14:56:19 -0400 Subject: [PATCH] loader: Update to new INI api Signed-off-by: Alexandre Terrasa --- lib/github/loader.nit | 16 +++++++++++----- src/loader.nit | 6 +++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/github/loader.nit b/lib/github/loader.nit index 4ffa501..0704e5f 100644 --- a/lib/github/loader.nit +++ b/lib/github/loader.nit @@ -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 diff --git a/src/loader.nit b/src/loader.nit index 8bdfcb2..169d52e 100644 --- a/src/loader.nit +++ b/src/loader.nit @@ -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 -- 1.7.9.5