Skip to content

Commit

Permalink
Merge pull request #5 from nimishgautam/master
Browse files Browse the repository at this point in the history
added a file to generate xcompose from yaml
  • Loading branch information
Granitosaurus authored Sep 26, 2022
2 parents 110bc0f + 4c5b5a9 commit 93e57b1
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions toXcompose.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import yaml
import click
from click import echo
from convcompose import KEY_MAP

mapping_dict = {v: k for k, v in KEY_MAP.items()}

def get_xcompose_key(key):
xval = "<Multi_key> " # might be another unique value
for i in key:
kval = i
if i in mapping_dict:
kval = mapping_dict[i]
xval += "<" + kval +"> "
return xval

def get_xcompose_val(val):
return '"' + val + '"'

@click.command()
@click.argument('yamlfile', type=click.File())
def main(yamlfile):
yamldata = yaml.load(yamlfile.read(), Loader=yaml.Loader)
for k, v in yamldata.items():
xkey = get_xcompose_key(k)
xval = get_xcompose_val(v)
echo(xkey + ":" + xval)

if __name__ == '__main__':
main()

0 comments on commit 93e57b1

Please sign in to comment.