aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/xkeyboard-config/tests/ruby/find_match.rb
blob: 10738fafd67e51d85191743f3f8f10ab6ccfdde7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/ruby
#
# $Id$
# The script finds best matching xkb_symbols in symbols/in
#
# Parameters: $0 - the name of the file with new xkb_symbols
#             $1 - max number of non-matching mappings (0 by default)
#

require "xkbparser.rb"

baseDir = "../.."

symbolsDir = "#{baseDir}/symbols"
#symbolsDir = "."

parser = Parser.new

allSyms = parser.parse("#{symbolsDir}/inet")

newSyms = parser.parse(ARGV[0])
limit = ARGV[1].to_i

newSyms.find_all do | key, value |

  if value.hidden?
    next
  end

  puts "Existing xkb_symbols matching #{key}: "

  sorted = allSyms.match_symbols(value,limit).sort_by do | symsName, diff |
    sprintf "%03d_%s", diff.size, symsName
  end

  sorted.find_all do | symsName, diff |
    puts "  #{symsName}, up to #{allSyms[symsName].size} keys (difference #{diff.size})-> #{diff}"
  end

end