Created
          November 25, 2012 09:26 
        
      - 
      
 - 
        
Save valpackett/4142920 to your computer and use it in GitHub Desktop.  
    Slate ASCIIToCode generator example
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # use: | |
| # cat Slate/ASCIIToCode.plist | head -n -2 | tail -n +5 | python gen_c.py > Slate/ASCIIToCode_Colemak.plist | |
| import re | |
| import sys | |
| def iter_pairs(a): | |
| for i in range(len(a))[::2]: | |
| yield(a[i], a[i+1]) | |
| qwerty = {} | |
| for k, v in iter_pairs(sys.stdin.read().split('\n')[:-1]): | |
| k = k.replace('<key>', '').replace('</key>', '').replace(' ', '') | |
| v = v.replace('<integer>', '').replace('</integer>', '').replace(' ', '') | |
| qwerty[k] = v | |
| colemak = qwerty.copy() | |
| qwerty_conv = "qwertyuiopasdfghjkl;zxcvbnm" | |
| colemak_conv = "qwfpgjluy;arstdhneiozxcvbkm" | |
| for i, char in enumerate(colemak_conv): | |
| colemak[char] = qwerty[qwerty_conv[i]] | |
| print """<?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> """ | |
| for k, v in colemak.iteritems(): | |
| print ' <key>' + k + '</key>' | |
| print ' <integer>' + v + '</integer>' | |
| print """</dict> | |
| </plist>""" | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment