+4.需要对输出的error_id中含有的特殊字符进行处理。
- 单引号,空格,冒号等
1. 定义一个白名单。名单之外的字符,统统替换为'-'. 2. 各种数字,统统替换为'#'. 3. 连续的-, #替换为单个
- def common_error_id(line)
- line = line.chomp
- line.gsub!(/ /, '-')
- line.gsub!(/:/, '') # error.:-'__mysql_packages'-is-undefined: 1
- line.gsub!(/,/, '')
- line.gsub!(/'/, '') # Failed-to-download-metadata-for-repo-'dockerrepo: 1
- line.gsub!(/!/, '') # Distribution-openEuler-is-not-supported-by-this-role!: 1
- line.gsub!(/{%/, ' ')
- line.gsub!(/%}/, ' ')
- line
- end
-- 2.23.0