Created
December 6, 2018 16:44
-
-
Save pepasflo/2e5966a951c09c4623401b02b2bf308e to your computer and use it in GitHub Desktop.
Python script to generate a units.js file for quickqwerty https://github.com/susam/quickqwerty
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
#!/usr/bin/env python | |
# generate a "Units.js" file for quickqwerty. | |
# see https://github.com/susam/quickqwerty | |
import sys | |
import random | |
def gen_subunit_str(chars): | |
words = [] | |
for i in range(len(chars)*len(chars)/2): | |
word = "" | |
for _ in range(random.choice(range(2,min(2*len(chars),7)))): | |
word += random.choice(chars) | |
words.append(word) | |
return ' '.join(words) | |
def print_subunits(charsets): | |
print "'subunits': {" | |
for chars in charsets: | |
print "'%s': '%s'," % (chars, gen_subunit_str(chars)) | |
print "}" | |
def print_units(title, last=False): | |
print "{" | |
print "'title': '%s'," % title | |
print "'guide': '(no guide available)'," | |
print_subunits(["fjdk","fjdks","fjdksl","fjdksla","fjdksla;"]) | |
if last: | |
print "}" | |
else: | |
print "}," | |
if __name__ == "__main__": | |
print "'use strict'" | |
print "var Units = {" | |
print "'mainLabel': '6-7 split'," | |
print "'mainConfirmMessage': 'You are choosing the 6-7 splt'," | |
print "'main':[" | |
print_units('(no title)', last=True) | |
print "]}" |
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 strict' | |
var Units = { | |
'mainLabel': '6-7 split', | |
'mainConfirmMessage': 'You are choosing the 6-7 splt', | |
'main':[ | |
{ | |
'title': '(no title)', | |
'guide': '(no guide available)', | |
'subunits': { | |
'fjdk': 'kkd fjjf fjj ffkdd kk fkkfk jjff jdjf', | |
'fjdks': 'ddk jj fsjdd kdsffk dkk ffs ksjds fsssj fdjsf kksd ksjdj df', | |
'fjdksl': 'sssd fsfk slf skjsj sds fsk sdk jkfjlf sjdfkl dsdkdj fld kd llfj kkf lfk dsjdfl kdddkd lljlk', | |
'fjdksla': 'jfkf ks laa dlfd sjkj kajslf jljkss ddj fkak jlfs jls jj fjf fk fjjs ddjasd kfk skdds ffkass adldlj jkksd jkjjjl kd ksd', | |
'fjdksla;': 'dfd; ;jskja kaada; ls j;a; ;ffkd sad jsjka ;dds;k fjaad laljd sdal asfl;; lf a;dfk laafs s;lk; aa s; jfadkd klkf l;f sks a;ala d;d;j ss;al sjfkd jjdkl kfla; dslssk ;ad; jfk;s', | |
} | |
} | |
]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment