From: Tobias Ulmer Date: Tue, 19 Feb 2013 20:04:41 +0000 (+0100) Subject: Remove slashToDot() and export two replacements X-Git-Tag: e2factory-2.3.13rc1~8 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=0571d0dff9935e9ad993fc2b2eec667270900c6f;p=e2factory.git Remove slashToDot() and export two replacements Results/source names can now reliably be converted into a file system path or into e2factory group notation using e2tool.src_res_name_to_path() and e2tool.src_res_path_to_name() Signed-off-by: Tobias Ulmer --- diff --git a/local/e2tool.lua b/local/e2tool.lua index 8791d42..cf7afb7 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -937,9 +937,20 @@ function e2tool.verify_src_res_name_valid_chars(name) return true end ---- replaces all slashed in str with dots -local function slashToDot(str) - return string.gsub(str,"/", ".") +--- Convert source or result name, including groups, to a file system path. +-- @param name Name of a src or res, with optional group notation (string). +-- @return File system path equivalent of the input. +function e2tool.src_res_name_to_path(name) + return name:gsub("%.", "/") +end + +--- Convert file system path of a source or result, including sub-directories +-- to group notation separated by dots. +-- @param pathname File system path of a src or res, with optional +-- sub-directories (string). +-- @return Group dot notation equivalent of the input. +function e2tool.src_res_path_to_name(pathname) + return pathname:gsub("/", ".") end --- load source config. @@ -970,8 +981,8 @@ local function load_source_config(info) if not name and #list == 1 then e2lib.warnf("WDEFAULT", "`name' attribute missing in source config.") e2lib.warnf("WDEFAULT", " Defaulting to directory name") - item.data.name = slashToDot(src) - name = slashToDot(src) + item.data.name = e2tool.src_res_path_to_name(src) + name = item.data.name end if not name then @@ -1098,8 +1109,8 @@ local function load_result_config(info) return false, e end - item.data.name = slashToDot(res) - name = slashToDot(res) + item.data.name = e2tool.src_res_path_to_name(res) + name = item.data.name local rc, re = e2tool.verify_src_res_name_valid_chars(name) if not rc then