5 def csv2hash(command_path)
6 #command_name = File.basename(command_path)
7 option_path = "#{command_path}/Config/OptionControlFile"
9 # option[0] = about -i,
10 # option[1] = about -o,
11 # option[3] = about -m, .... etc
15 CSV.foreach(option_path) do |ref|
20 # [{argIndex: ,argName: ,argType: ,initialValue: },{.,.}.,.{.,.}]
21 optionNumber = ref[4].to_s.to_i
24 option[index] = Hash.new{|i|{}}
25 option[index]["option"] = ref[0].to_s
26 option[index]["fullOption"] = ref[1]
27 option[index]["optionName"] = ref[2]
28 option[index]["optionProperties"] = ref[3].to_s == "Essential"
29 option[index]["optionNumber"] = ref[4].to_s.to_i
32 option[index]["arg"] = Array.new(option[index]["optionNumber"]){|i|{}}
34 option[index]["arg"].each_with_index do |arg,i|
35 arg["argIndex"] = ref[4*(i+1)+1].to_s
36 arg["argName"] = ref[4*(i+1)+2].to_s
37 argType = ref[4*(i+1)+3].to_s.split('::') #argType{ inFile::mrcImage::ASCII } and so on
38 arg["argType"] = argType.shift #arg["argType"] = inFile | outFile | appendFile ...
39 arg["attribute"] = argType.empty? ? nil : argType #arg["attribute"] = [ mrcImage,ASCII,... ]
40 arg["initialValue"] = ref[4*(i+1)+4].to_s
43 when "inFile","inFileList","inFileListNoOpen" then
44 arg["formType"] = "select"
45 when "outFile","outFileList","appendFile","appendFileList","Character","String","StringAll" then
46 arg["formType"] = "text"
47 when "Integer","Real" then
48 arg["formType"] = "number"
53 if (arg["initialValue"] == "NULL"||
54 arg["initialValue"] == "stdout") then
55 arg["initialValue"] = ""
63 success[:option] = option
67 return option_path,ex.class
70 module_function :csv2hash