-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchar2XCompose
executable file
·42 lines (31 loc) · 1.23 KB
/
char2XCompose
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/env python3
from typing import Callable
from argparse import ArgumentParser
from toXComposeTools import char2xc, char2xc_web
def main(char: str, keys: str,
user_char2xc: Callable[[str, str], str]) -> None:
if '<Multi_key>' not in keys[0:11]:
keys = '<Multi_key> ' + keys
print(user_char2xc(char, keys))
if __name__ == '__main__':
args = ArgumentParser(
description="Returns a string formatted for inclusion in XCompose")
args.add_argument('char', help='The character to look up')
args.add_argument('--keys',
default='<Multi_key> ',
type=str,
help='Key combo string for XCompose.')
args.add_argument('-w', '--web',
action='store_true',
help='Use Internet resources to obtain \
unicode character data.')
args = args.parse_args()
if args.char is None:
raise ValueError('Must specify a character to lookup.')
if len(args.char) != 1:
raise ValueError('Must specify A SINGLE character to look up.')
if args.web:
user_char2xc = char2xc_web
else:
user_char2xc = char2xc
main(args.char, args.keys.strip(), user_char2xc)