lib/openstudio/analysis/translator/excel.rb in openstudio-analysis-0.3.1 vs lib/openstudio/analysis/translator/excel.rb in openstudio-analysis-0.3.2

- old
+ new

@@ -525,11 +525,18 @@ else @name = UUID.new.generate end @machine_name = @name.snake_case end - @export_path = File.expand_path(File.join(@root_path, row[1])) if row[0] == 'Export Directory' + if row[0] == 'Export Directory' + tmp_filepath = row[1] + if (Pathname.new tmp_filepath).absolute? + @export_path = tmp_filepath + else + @export_path = File.expand_path(File.join(@root_path, tmp_filepath)) + end + end if row[0] == 'Measure Directory' tmp_filepath = row[1] if (Pathname.new tmp_filepath).absolute? @measure_path = tmp_filepath else @@ -555,20 +562,37 @@ v = v.to_i if v % 1 == 0 @algorithm["#{row[0].snake_case}"] = v end elsif b_weather_files if row[0] == 'Weather File' - @weather_files += Dir.glob(File.expand_path(File.join(@root_path, row[1]))) + weather_path = row[1] + unless (Pathname.new weather_path).absolute? + weather_path = File.expand_path(File.join(@root_path, weather_path)) + end + @weather_files += Dir.glob(weather_path) end elsif b_models if row[1] tmp_m_name = row[1] else tmp_m_name = UUID.new.generate end - @models << {name: tmp_m_name.snake_case, display_name: tmp_m_name, type: row[2], path: File.expand_path(File.join(@root_path, row[3]))} + # Only add models if the row is flagged + if row[0] && row[0].downcase == 'model' + model_path = row[3] + unless (Pathname.new model_path).absolute? + model_path = File.expand_path(File.join(@root_path, model_path)) + end + @models << {name: tmp_m_name.snake_case, display_name: tmp_m_name, type: row[2], path: model_path} + end elsif b_other_libs - @other_files << {lib_zip_name: row[1], path: row[2]} + # determine if the path is relative + other_path = row[2] + unless (Pathname.new other_path).absolute? + other_path = File.expand_path(File.join(@root_path, other_path)) + end + + @other_files << {lib_zip_name: row[1], path: other_path} end end end # parse_variables will parse the XLS spreadsheet and save the data into