]> git.e2factory.org Git - e2factory.git/commitdiff
source: add licences() method just like file_class
authorTobias Ulmer <tu@emlix.com>
Fri, 3 Mar 2017 17:35:40 +0000 (18:35 +0100)
committerTobias Ulmer <tu@emlix.com>
Fri, 3 Mar 2017 17:35:43 +0000 (18:35 +0100)
Saves a lot of string list copying that's better done in an explicit
fashion.  get_licences()/set_licences() stay until all extensions are
updated.

Signed-off-by: Tobias Ulmer <tu@emlix.com>
local/source.lua

index 5aa7028f8b07f37114bfd8bab2102aded67a8203..041205c08ca0b359df54503a2bd600d84bce4091 100644 (file)
@@ -89,16 +89,34 @@ function source.basic_source:get_type()
     return self._type
 end
 
+--- Get/set licence string list.
+-- Note this returns all licences used in a source. Some sources may have more
+-- detailed licensing information which can be accessed by other means.
+-- @param lic_sl Optional string list of licence names (sl).
+-- @return String list of licence names.
+function source.basic_source:licences(lic_sl)
+    if lic_sl then
+        assertIsTable(lic_sl)
+        assert(lic_sl:isInstanceOf(sl.sl))
+        self._licences = lic_sl
+    end
+
+    return self._licences or false
+end
+
 --- Set licence array.
+-- Obsolete interface.
 -- @param licences String list of licence names (sl).
 function source.basic_source:set_licences(licences)
     assert(type(licences) == "table" and licences.class.name == "sl")
     self._licences = licences:copy()
 end
 
---- Get licence array. Must be set before calling get_licences(). Note that
--- this returns all licences used in a source. Some sources may have more
--- detailed licensing information which can be accessed by other means.
+--- Get licence array.
+-- Obsolete interface.
+-- Must be set before calling get_licences(). Note that this returns all
+-- licences used in a source. Some sources may have more detailed licensing
+-- information which can be accessed by other means.
 -- @return String list of licence names (sl).
 function source.basic_source:get_licences()
     assert(type(self._licences) == "table")
@@ -417,7 +435,7 @@ function source.generic_source_validate_licences(rawsrc, src)
         licences:insert(licencename)
     end
 
-    src:set_licences(licences)
+    src:licences(licences)
 
     return true
 end