@@ -29,9 +29,9 @@ import com.looker.rtl.DEFAULT_HTTP_TRANSPORT
2929import com.looker.rtl.DEFAULT_TIMEOUT
3030import com.looker.rtl.asBoolean
3131import com.looker.rtl.unQuote
32- import org.ini4j.Ini
33- import java.io.ByteArrayInputStream
32+ import org.apache.commons.configuration.HierarchicalINIConfiguration
3433import java.io.File
34+ import java.io.StringReader
3535
3636/* * Structure read from an .INI file */
3737typealias ApiSections = Map <String , Map <String , String >>
@@ -40,14 +40,20 @@ typealias ApiSections = Map<String, Map<String, String>>
4040 * Parse and cleanup something that looks like an .INI file, stripping outermost quotes for values
4141 */
4242fun apiConfig (contents : String ): ApiSections {
43- val iniParser = Ini (ByteArrayInputStream (contents.toByteArray()))
44-
45- val ret = mutableMapOf<String , Map <String , String >>()
46- iniParser.forEach { (section, values) ->
47- ret[section] = values.map { it.key to unQuote(it.value) }.toMap()
43+ val iniParser = HierarchicalINIConfiguration ()
44+ iniParser.load(StringReader (contents))
45+
46+ return mutableMapOf<String , Map <String , String >>().also { mapToReturn ->
47+ iniParser.sections.forEach { section ->
48+ mapToReturn[section] = mutableMapOf<String , String >().also { sectionMap ->
49+ iniParser.getKeys(section).forEach { key ->
50+ // `key` is fully scoped (e.g. `Looker.<key>`) but we just want the key so
51+ // remove the section prefix before adding to the map.
52+ sectionMap[key.removePrefix(" $section ." )] = unQuote(iniParser.getString(key))
53+ }
54+ }
55+ }
4856 }
49-
50- return ret
5157}
5258
5359// TODO why no @JvmOverloads here?
0 commit comments