Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create compose_sequence_generator.py #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
66 changes: 66 additions & 0 deletions compose_sequence_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env python
import unicodedata, re

# the regular abcs or wtvr that will be typed out
# each letter in 'regular' corresponds to the respective letter in 'composed'
regular = "0123456789"

# the letter that compose spits out
composed = "𝟘𝟙𝟚𝟛𝟜𝟝𝟞𝟟𝟠𝟡"

# the sequence u type out.
# "<M_>" means the compose key.
# <MM> means compose key twice
# ★ is what will be replaced with whats in regular
sequence = "<M_> ★|"



specials = {'%' : 'percent',
'-' : 'minus',
'_' : 'underscore',
'>' : 'greater',
'<' : 'less',
',' : 'comma',
'.' : 'period',
'$' : 'dollar',
'!' : 'exclam',
'?' : 'question',
'+' : 'plus',
'/' : 'slash',
'#' : 'numbersign',
'@' : 'at',
'|' : 'bar',
'`' : 'grave',
'~' : 'asciitilde',
'^' : 'asciicircum',
'(' : 'parenleft',
')' : 'parenright',
'[' : 'bracketleft',
']' : 'bracketright',
'{' : 'braceleft',
'}' : 'braceright',
"'" : 'apostrophe',
'"' : 'quotedbl',
'\\': 'backslash',
':' : 'colon',
';' : 'semicolon',
'=' : 'equal',
' ' : 'space',
'*' : 'asterisk',
}

def replace(sequence):
sequence = "".join([f'<{specials.get(letter, letter)}> ' for letter in sequence])
sequence = re.sub(r"^<less> <M> <underscore> <greater> <space>", "<Multi_key>", sequence)
sequence = re.sub(r"^<less> <M> <M> <greater> <space>", "<Multi_key> <Multi_key>", sequence)
return sequence

sequence = replace(sequence)

if len(regular) == len(composed):
for position in range(len(regular)):
full_sequence = sequence.replace("<★>", replace(regular[position]))
print(full_sequence + ' : "'+composed[position]+'" '+str('U%04X' % ord(composed[position])) +' # '+ unicodedata.name(composed[position]))
else:
print("regular ("+ str(len(regular))+ ") is not equal to composed ("+str(len(composed))+ ")")