PyFoxFile 0.20.8__tar.gz → 0.21.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyFoxFile
3
- Version: 0.20.8
3
+ Version: 0.21.2
4
4
  Summary: A tar like file format name foxfile.
5
5
  Home-page: https://github.com/GameMaker2k/PyFoxFile
6
6
  Download-URL: https://github.com/GameMaker2k/PyFoxFile/archive/master.tar.gz
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyFoxFile
3
- Version: 0.20.8
3
+ Version: 0.21.2
4
4
  Summary: A tar like file format name foxfile.
5
5
  Home-page: https://github.com/GameMaker2k/PyFoxFile
6
6
  Download-URL: https://github.com/GameMaker2k/PyFoxFile/archive/master.tar.gz
@@ -1,6 +1,7 @@
1
1
  LICENSE
2
2
  README.md
3
3
  foxfile.py
4
+ foxneofile.py
4
5
  neofoxfile.py
5
6
  pyfoxfile.py
6
7
  pyproject.toml
@@ -14,7 +14,7 @@
14
14
  Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
15
15
  Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
16
16
 
17
- $FileInfo: foxfile.py - Last Update: 8/20/2025 Ver. 0.20.2 RC 1 - Author: cooldude2k $
17
+ $FileInfo: foxfile.py - Last Update: 8/24/2025 Ver. 0.21.2 RC 1 - Author: cooldude2k $
18
18
  '''
19
19
 
20
20
  from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
@@ -172,7 +172,7 @@ if active_action:
172
172
  if getargs.convert:
173
173
  checkcompressfile = pyfoxfile.CheckCompressionSubType(
174
174
  input_file, fnamedict, True)
175
- if((IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
175
+ if((pyfoxfile.IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (pyfoxfile.IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
176
176
  tmpout = pyfoxfile.RePackFoxFile(input_file, getargs.output, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt, False, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.verbose, False)
177
177
  else:
178
178
  tmpout = pyfoxfile.PackFoxFileFromInFile(
@@ -185,7 +185,7 @@ if active_action:
185
185
  if getargs.convert:
186
186
  checkcompressfile = pyfoxfile.CheckCompressionSubType(
187
187
  input_file, fnamedict, True)
188
- if((IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
188
+ if((pyfoxfile.IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (pyfoxfile.IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
189
189
  pyfoxfile.RePackFoxFile(input_file, getargs.output, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt,
190
190
  False, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.verbose, False)
191
191
  else:
@@ -200,7 +200,7 @@ if active_action:
200
200
  checkcompressfile = pyfoxfile.CheckCompressionSubType(
201
201
  input_file, fnamedict, True)
202
202
  tempout = BytesIO()
203
- if((IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
203
+ if((pyfoxfile.IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (pyfoxfile.IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
204
204
  tmpout = pyfoxfile.RePackFoxFile(input_file, tempout, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt, False, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, False, False)
205
205
  else:
206
206
  tmpout = pyfoxfile.PackFoxFileFromInFile(
@@ -214,7 +214,7 @@ if active_action:
214
214
  if getargs.convert:
215
215
  checkcompressfile = pyfoxfile.CheckCompressionSubType(
216
216
  input_file, fnamedict, True)
217
- if((IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
217
+ if((pyfoxfile.IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (pyfoxfile.IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
218
218
  tmpout = pyfoxfile.FoxFileListFiles(input_file, "auto", 0, 0, getargs.skipchecksum, fnamedict, False, getargs.verbose, False, False)
219
219
  else:
220
220
  tmpout = pyfoxfile.InFileListFiles(input_file, getargs.verbose, fnamedict, False, False, False)
@@ -227,7 +227,7 @@ if active_action:
227
227
  checkcompressfile = pyfoxfile.CheckCompressionSubType(
228
228
  input_file, fnamedict, True)
229
229
  tempout = BytesIO()
230
- if((IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
230
+ if((pyfoxfile.IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (pyfoxfile.IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
231
231
  tmpout = pyfoxfile.RePackFoxFile(input_file, tempout, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt, False, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, False, False, False)
232
232
  else:
233
233
  tmpout = pyfoxfile.PackFoxFileFromInFile(
@@ -0,0 +1,130 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ from __future__ import absolute_import, division, print_function, unicode_literals
4
+
5
+ import sys, os, io, argparse
6
+
7
+ try:
8
+ import pyfoxfile as P # core must provide *_neo functions
9
+ except Exception as e:
10
+ sys.stderr.write("Failed to import core module 'pyfoxfile': %s\n" % (e,))
11
+ sys.exit(2)
12
+
13
+
14
+ def _expand_combined_short_opts(argv):
15
+ out = [argv[0]]
16
+ i = 1
17
+ while i < len(argv):
18
+ a = argv[i]
19
+ if a.startswith("--") or not (a.startswith("-") and len(a) > 2):
20
+ out.append(a); i += 1; continue
21
+ for ch in a[1:]:
22
+ out.append("-" + ch)
23
+ i += 1
24
+ return out
25
+
26
+
27
+ def main():
28
+ argv = _expand_combined_short_opts(sys.argv)
29
+
30
+ p = argparse.ArgumentParser(
31
+ description="PyNeoFile CLI (uses pyfoxfile core)")
32
+ g = p.add_mutually_exclusive_group(required=True)
33
+ g.add_argument("-l", "--list", action="store_true", help="List archive")
34
+ g.add_argument("-e", "--extract", action="store_true", help="Extract archive")
35
+ g.add_argument("-c", "--create", action="store_true", help="Create archive from path")
36
+ g.add_argument("-r", "--repack", action="store_true", help="Repack (recompress) an archive")
37
+ g.add_argument("-E", "--empty", action="store_true", help="Create an empty archive")
38
+
39
+ p.add_argument("-i", "--input", help="Input file/path", nargs="*")
40
+ p.add_argument("-o", "--output", help="Output file/dir (or '-' for stdout)")
41
+ p.add_argument("-d", "--verbose", action="store_true", help="Verbose/detailed listing")
42
+ p.add_argument("-P", "--compression", default="auto", help="Compression algo (auto, none, zlib, gzip, bz2, lzma)")
43
+ p.add_argument("-L", "--level", type=int, default=None, help="Compression level/preset")
44
+ p.add_argument("--checksum", default="crc32", help="Checksum type for header/content/json (default: crc32)")
45
+
46
+ args = p.parse_args(argv[1:])
47
+
48
+ src = None
49
+ if args.input:
50
+ if isinstance(args.input, list) and len(args.input) == 1:
51
+ src = args.input[0]
52
+ elif isinstance(args.input, list) and len(args.input) > 1:
53
+ src = args.input[0]
54
+ else:
55
+ src = args.input
56
+
57
+ if args.empty:
58
+ dst = args.output or "-"
59
+ blob_or_true = P.make_empty_file_neo(dst, fmttype="auto", checksumtype=args.checksum, encoding="UTF-8", returnfp=False)
60
+ if dst in (None, "-"):
61
+ data = blob_or_true if isinstance(blob_or_true, (bytes, bytearray)) else b""
62
+ if hasattr(sys.stdout, "buffer"):
63
+ sys.stdout.buffer.write(data)
64
+ else:
65
+ sys.stdout.write(data.decode("latin1"))
66
+ return 0
67
+
68
+ if args.list:
69
+ if not src:
70
+ p.error("list requires -i <archive>")
71
+ P.archivefilelistfiles_neo(src, advanced=args.verbose, include_dirs=True)
72
+ return 0
73
+
74
+ if args.extract:
75
+ if not src:
76
+ p.error("extract requires -i <archive>")
77
+ outdir = args.output or "."
78
+ ok = P.unpack_neo(src, outdir, skipchecksum=False, uncompress=True)
79
+ return 0 if ok else 1
80
+
81
+ if args.create:
82
+ if not src:
83
+ p.error("create requires -i <path>")
84
+ if args.verbose:
85
+ walkroot = src
86
+ if os.path.isdir(walkroot):
87
+ print(walkroot)
88
+ for root, dirs, files in os.walk(walkroot):
89
+ relroot = root if root.startswith("./") else "./" + root.replace("\\", "/")
90
+ if root != walkroot:
91
+ print(relroot)
92
+ for name in sorted(files):
93
+ path = os.path.join(root, name).replace("\\", "/")
94
+ if not path.startswith("./"):
95
+ path = "./" + path
96
+ print(path)
97
+ else:
98
+ path = src if src.startswith("./") else "./" + src
99
+ print(path)
100
+
101
+ outpath = args.output or "-"
102
+ ok = P.pack_neo(src, outpath, checksumtypes=(args.checksum,args.checksum,args.checksum,args.checksum),
103
+ encoding="UTF-8", compression=args.compression, compression_level=args.level)
104
+ if outpath in (None, "-") and isinstance(ok, (bytes, bytearray)):
105
+ if hasattr(sys.stdout, "buffer"):
106
+ sys.stdout.buffer.write(ok)
107
+ else:
108
+ sys.stdout.write(ok.decode("latin1"))
109
+ return 0
110
+ return 0 if ok else 1
111
+
112
+ if args.repack:
113
+ if not src:
114
+ p.error("repack requires -i <archive>")
115
+ outpath = args.output or "-"
116
+ ok = P.repack_neo(src, outpath, checksumtypes=(args.checksum,args.checksum,args.checksum,args.checksum),
117
+ compression=args.compression, compression_level=args.level)
118
+ if outpath in (None, "-") and isinstance(ok, (bytes, bytearray)):
119
+ if hasattr(sys.stdout, "buffer"):
120
+ sys.stdout.buffer.write(ok)
121
+ else:
122
+ sys.stdout.write(ok.decode("latin1"))
123
+ return 0
124
+ return 0 if ok else 1
125
+
126
+ return 0
127
+
128
+
129
+ if __name__ == "__main__":
130
+ sys.exit(main())