-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
28 lines (21 loc) · 809 Bytes
/
main.py
File metadata and controls
28 lines (21 loc) · 809 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
import os, sys
from ds_types.bnd3 import BND3
from ds_types.dcx import DCX
extensions = {'bnd': BND3, 'dcx': DCX, 'tpf': 'tpf parser'}
if __name__ == '__main__':
for file in sys.argv[1:]:
extension = os.path.basename(file).split('.')
extension = extension[len(extension) - 1]
print(extension)
parser = [par for ext, par in extensions.items() if ext in extension]
if parser:
parser = parser[0]
print(parser)
try:
with open(file, 'rb') as f:
ds_file = parser(f)
while ds_file.has_next():
file_path, data = ds_file.next()
ds_file.write(file_path, data)
except FileNotFoundError as e:
print(e)