-
Notifications
You must be signed in to change notification settings - Fork 1
/
process_led_map.py
46 lines (33 loc) · 1.06 KB
/
process_led_map.py
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
43
44
45
46
import argparse
import os
import sys
import pyperclip
from ledworld import LedWorld
def main(options):
world = LedWorld.from_json_file(options.infile)
world.plot()
world.fill_missing_leds()
world.plot()
world.smoothen()
world.plot()
world.to_json_file(options.outfile)
def read_arguments(args):
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
description="""
Postprocess Pyledstrip Heightmap
""".strip()
)
parser.add_argument('--infile', help="input file", default=None, type=str)
parser.add_argument('--outfile', help="output file", default=None, type=str)
options = parser.parse_args(args)
if options.infile is None:
options.infile = pyperclip.paste()
if not os.path.isfile(options.infile):
raise Exception("no such file")
if options.outfile is None:
options.outfile = options.infile + ".processed.json"
return options
if __name__ == '__main__':
options = read_arguments(sys.argv[1:])
main(options)