-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse.py
More file actions
28 lines (23 loc) · 866 Bytes
/
parse.py
File metadata and controls
28 lines (23 loc) · 866 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 argparse
import os
import re
from InputStream import InputStream
from PCKFile import PCKFile
def main():
parser = argparse.ArgumentParser()
parser.add_argument("pck_file", type=str)
parser.add_argument("-d", type=str, dest="dump", help="Dumps all files of a pck file into the provided folder")
parser.add_argument("-l", action="store_true", dest="list", help="List PCK content")
args = parser.parse_args()
if not os.path.exists(args.pck_file): raise FileNotFoundError("file does not exist")
with open(args.pck_file, "rb") as pck:
pck_file = PCKFile()
pck_file.parse(InputStream(pck.read()))
if args.list:
print(pck_file)
if args.dump:
path = f"dump/{args.dump}"
if not os.path.exists(path): os.makedirs(path)
pck_file.dump(path)
if __name__ == "__main__":
main()