-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhex2XCompose
More file actions
executable file
·40 lines (29 loc) · 1.16 KB
/
hex2XCompose
File metadata and controls
executable file
·40 lines (29 loc) · 1.16 KB
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
#!/usr/bin/env python3
from typing import Callable
from argparse import ArgumentParser
from toXComposeTools import uhex2xc, uhex2xc_web
def main(hexstr: str, keys: str,
usr_hex2xc: Callable[[str, str], str]) -> None:
if '<Multi_key>' not in keys[0:11]:
keys = '<Multi_key> ' + keys
print(usr_hex2xc(hexstr, keys))
if __name__ == '__main__':
args = ArgumentParser(
description="Returns a string formatted for inclusion in XCompose")
args.add_argument('hexstr', help='The hex codepoint of 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.hexstr is None:
raise ValueError('Must specify a character to lookup.')
if args.web:
usr_hex2xc = uhex2xc_web
else:
usr_hex2xc = uhex2xc
main(args.hexstr, args.keys.strip(), usr_hex2xc)