-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.py
More file actions
36 lines (28 loc) · 909 Bytes
/
Copy pathscript.py
File metadata and controls
36 lines (28 loc) · 909 Bytes
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
import sys
import os
import config
import subprocess
from typing import List
def convert(filepath: str, output_dir: str) -> List[str]:
'''
Converts a txd file to png.
Args:
filepath: The TXD file path.
output_dir: The output directory path.
Returns:
List of png files.
'''
output = subprocess.check_output([config.TXD2PNG, os.path.abspath(filepath)],
cwd=output_dir)
lines = output.decode().splitlines()
return [line.split()[1] for line in lines]
if __name__ == "__main__":
args = sys.argv
if (len(args) < 2):
print('Usage: %s [path to txd]' % args[0])
exit(1)
filepath = args[1]
output_dir = os.getcwd()
png_files = convert(filepath, output_dir)
for file in png_files:
print('\033[92m+ %s.png\033[0m' % os.path.join(output_dir, file))