PyFoxFile 0.19.0__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.
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2018, Game Maker 2k
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ * Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,23 @@
1
+ Metadata-Version: 2.2
2
+ Name: PyFoxFile
3
+ Version: 0.19.0
4
+ Summary: A tar like file format name foxfile.
5
+ Home-page: https://github.com/GameMaker2k/PyFoxFile
6
+ Download-URL: https://github.com/GameMaker2k/PyFoxFile/archive/master.tar.gz
7
+ Author: Kazuki Przyborowski
8
+ Author-email: Kazuki Przyborowski <kazuki.przyborowski@gmail.com>
9
+ Maintainer: Kazuki Przyborowski
10
+ Maintainer-email: kazuki.przyborowski@gmail.com
11
+ License: BSD-3-Clause
12
+ Platform: OS Independent
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Dynamic: author
16
+ Dynamic: download-url
17
+ Dynamic: home-page
18
+ Dynamic: maintainer
19
+ Dynamic: maintainer-email
20
+ Dynamic: platform
21
+
22
+ A tar like file format name FoxFile
23
+ ![](logo.png?raw=true)
@@ -0,0 +1,23 @@
1
+ Metadata-Version: 2.2
2
+ Name: PyFoxFile
3
+ Version: 0.19.0
4
+ Summary: A tar like file format name foxfile.
5
+ Home-page: https://github.com/GameMaker2k/PyFoxFile
6
+ Download-URL: https://github.com/GameMaker2k/PyFoxFile/archive/master.tar.gz
7
+ Author: Kazuki Przyborowski
8
+ Author-email: Kazuki Przyborowski <kazuki.przyborowski@gmail.com>
9
+ Maintainer: Kazuki Przyborowski
10
+ Maintainer-email: kazuki.przyborowski@gmail.com
11
+ License: BSD-3-Clause
12
+ Platform: OS Independent
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Dynamic: author
16
+ Dynamic: download-url
17
+ Dynamic: home-page
18
+ Dynamic: maintainer
19
+ Dynamic: maintainer-email
20
+ Dynamic: platform
21
+
22
+ A tar like file format name FoxFile
23
+ ![](logo.png?raw=true)
@@ -0,0 +1,13 @@
1
+ LICENSE
2
+ README.md
3
+ foxfile.py
4
+ neofoxfile.py
5
+ pyfoxfile.py
6
+ pyproject.toml
7
+ setup.cfg
8
+ setup.py
9
+ PyFoxFile.egg-info/PKG-INFO
10
+ PyFoxFile.egg-info/SOURCES.txt
11
+ PyFoxFile.egg-info/dependency_links.txt
12
+ PyFoxFile.egg-info/top_level.txt
13
+ PyFoxFile.egg-info/zip-safe
@@ -0,0 +1 @@
1
+ pyfoxfile
@@ -0,0 +1,2 @@
1
+ A tar like file format name FoxFile
2
+ ![](logo.png?raw=true)
@@ -0,0 +1,248 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ '''
5
+ This program is free software; you can redistribute it and/or modify
6
+ it under the terms of the Revised BSD License.
7
+
8
+ This program is distributed in the hope that it will be useful,
9
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ Revised BSD License for more details.
12
+
13
+ Copyright 2018-2024 Cool Dude 2k - http://idb.berlios.de/
14
+ Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
15
+ Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
16
+
17
+ $FileInfo: foxfile.py - Last Update: 3/7/2025 Ver. 0.19.0 RC 1 - Author: cooldude2k $
18
+ '''
19
+
20
+ from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
21
+ import os
22
+ import sys
23
+ import argparse
24
+ import pyfoxfile
25
+ import binascii
26
+
27
+ # Conditional import and signal handling for Unix-like systems
28
+ if os.name != 'nt': # Not Windows
29
+ import signal
30
+
31
+ def handler(signum, frame):
32
+ pyfoxfile.VerbosePrintOut(
33
+ "Received SIGPIPE, exiting gracefully.", "info")
34
+ sys.exit(0)
35
+ signal.signal(signal.SIGPIPE, handler)
36
+
37
+ rarfile_support = pyfoxfile.rarfile_support
38
+ py7zr_support = pyfoxfile.py7zr_support
39
+
40
+ if(sys.version[0] == "2"):
41
+ try:
42
+ from io import StringIO, BytesIO
43
+ except ImportError:
44
+ try:
45
+ from cStringIO import StringIO
46
+ from cStringIO import StringIO as BytesIO
47
+ except ImportError:
48
+ from StringIO import StringIO
49
+ from StringIO import StringIO as BytesIO
50
+ elif(sys.version[0] >= "3"):
51
+ from io import StringIO, BytesIO
52
+ else:
53
+ teststringio = 0
54
+ if(teststringio <= 0):
55
+ try:
56
+ from cStringIO import StringIO as BytesIO
57
+ teststringio = 1
58
+ except ImportError:
59
+ teststringio = 0
60
+ if(teststringio <= 0):
61
+ try:
62
+ from StringIO import StringIO as BytesIO
63
+ teststringio = 2
64
+ except ImportError:
65
+ teststringio = 0
66
+ if(teststringio <= 0):
67
+ try:
68
+ from io import BytesIO
69
+ teststringio = 3
70
+ except ImportError:
71
+ teststringio = 0
72
+
73
+ __project__ = pyfoxfile.__project__
74
+ __program_name__ = pyfoxfile.__program_name__
75
+ __file_format_name__ = pyfoxfile.__file_format_name__
76
+ __file_format_magic__ = pyfoxfile.__file_format_magic__
77
+ __file_format_len__ = pyfoxfile.__file_format_len__
78
+ __file_format_hex__ = pyfoxfile.__file_format_hex__
79
+ __file_format_delimiter__ = pyfoxfile.__file_format_delimiter__
80
+ __file_format_dict__ = pyfoxfile.__file_format_dict__
81
+ __file_format_default__ = pyfoxfile.__file_format_default__
82
+ __file_format_multi_dict__ = pyfoxfile.__file_format_multi_dict__
83
+ __use_new_style__ = pyfoxfile.__use_new_style__
84
+ __use_advanced_list__ = pyfoxfile.__use_advanced_list__
85
+ __use_alt_inode__ = pyfoxfile.__use_alt_inode__
86
+ __project_url__ = pyfoxfile.__project_url__
87
+ __version_info__ = pyfoxfile.__version_info__
88
+ __version_date_info__ = pyfoxfile.__version_date_info__
89
+ __version_date__ = pyfoxfile.__version_date__
90
+ __version_date_plusrc__ = pyfoxfile.__version_date_plusrc__
91
+ __version__ = pyfoxfile.__version__
92
+
93
+ # Initialize the argument parser
94
+ argparser = argparse.ArgumentParser(
95
+ description="Manipulate archive files.", conflict_handler="resolve", add_help=True)
96
+
97
+ # Version information
98
+ argparser.add_argument("-V", "--version", action="version",
99
+ version=__program_name__ + " " + __version__)
100
+ # Input and output specifications
101
+ argparser.add_argument(
102
+ "-i", "--input", nargs="+", help="Specify the file(s) to concatenate or the archive file to extract.", required=True)
103
+ argparser.add_argument("-o", "--output", default=None,
104
+ help="Specify the name for the extracted or output archive files.")
105
+ # Operations
106
+ argparser.add_argument("-c", "--create", action="store_true",
107
+ help="Perform only the concatenation operation.")
108
+ argparser.add_argument("-e", "--extract", action="store_true",
109
+ help="Perform only the extraction operation.")
110
+ argparser.add_argument("-t", "--convert", action="store_true",
111
+ help="Convert a tar/zip/rar/7zip file to a archive file.")
112
+ argparser.add_argument("-r", "--repack", action="store_true",
113
+ help="Re-concatenate files, fixing checksum errors if any.")
114
+ # File manipulation options
115
+ argparser.add_argument(
116
+ "-F", "--format", default="auto", help="Specify the format to use.")
117
+ argparser.add_argument(
118
+ "-D", "--delimiter", default=__file_format_dict__['format_delimiter'], help="Specify the delimiter to use.")
119
+ argparser.add_argument(
120
+ "-m", "--formatver", default=__file_format_dict__['format_ver'], help="Specify the format version.")
121
+ argparser.add_argument("-l", "--list", action="store_true",
122
+ help="List files included in the archive file.")
123
+ # Compression options
124
+ argparser.add_argument("-P", "--compression", default="auto",
125
+ help="Specify the compression method to use for concatenation.")
126
+ argparser.add_argument("-L", "--level", default=None,
127
+ help="Specify the compression level for concatenation.")
128
+ argparser.add_argument("-W", "--wholefile", action="store_true",
129
+ help="Whole file compression method to use for concatenation.")
130
+ # Checksum and validation
131
+ argparser.add_argument("-v", "--validate", action="store_true",
132
+ help="Validate archive file checksums.")
133
+ argparser.add_argument("-C", "--checksum", default="crc32",
134
+ help="Specify the type of checksum to use. The default is crc32.")
135
+ argparser.add_argument("-s", "--skipchecksum", action="store_true",
136
+ help="Skip the checksum check of files.")
137
+ # Permissions and metadata
138
+ argparser.add_argument("-p", "--preserve", action="store_false",
139
+ help="Do not preserve permissions and timestamps of files.")
140
+ # Miscellaneous
141
+ argparser.add_argument("-d", "--verbose", action="store_true",
142
+ help="Enable verbose mode to display various debugging information.")
143
+ argparser.add_argument("-T", "--text", action="store_true",
144
+ help="Read file locations from a text file.")
145
+ # Parse the arguments
146
+ getargs = argparser.parse_args()
147
+
148
+ fname = getargs.format
149
+ if(getargs.format=="auto"):
150
+ fnamedict = __file_format_multi_dict__
151
+ __file_format_default__ = getargs.format
152
+ else:
153
+ fnamemagic = fname
154
+ fnamelen = len(fname)
155
+ fnamehex = binascii.hexlify(fname.encode("UTF-8")).decode("UTF-8")
156
+ __file_format_default__ = fnamemagic
157
+ fnamesty = __use_new_style__
158
+ fnamelst = __use_advanced_list__
159
+ fnameino = __use_alt_inode__
160
+ fnamedict = {'format_name': fname, 'format_magic': fnamemagic, 'format_len': fnamelen, 'format_hex': fnamehex,
161
+ 'format_delimiter': getargs.delimiter, 'format_ver': getargs.formatver, 'new_style': fnamesty, 'use_advanced_list': fnamelst, 'use_alt_inode': fnameino}
162
+
163
+ # Determine the primary action based on user input
164
+ actions = ['create', 'extract', 'list', 'repack', 'validate']
165
+ active_action = next(
166
+ (action for action in actions if getattr(getargs, action)), None)
167
+ input_file = getargs.input[0]
168
+
169
+ # Execute the appropriate functions based on determined actions and arguments
170
+ if active_action:
171
+ if active_action == 'create':
172
+ if getargs.convert:
173
+ checkcompressfile = pyfoxfile.CheckCompressionSubType(
174
+ input_file, fnamedict, True)
175
+ if((IsNestedDict(fnamedict) and compresscheck in fnamedict) or (IsSingleDict(fnamedict) and compresscheck==fnamedict['format_magic'])):
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
+ else:
178
+ tmpout = pyfoxfile.PackFoxFileFromInFile(
179
+ input_file, getargs.output, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.verbose, False)
180
+ if(not tmpout):
181
+ sys.exit(1)
182
+ else:
183
+ pyfoxfile.PackFoxFile(getargs.input, getargs.output, getargs.text, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt, False, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.verbose, False)
184
+ elif active_action == 'repack':
185
+ if getargs.convert:
186
+ checkcompressfile = pyfoxfile.CheckCompressionSubType(
187
+ input_file, fnamedict, True)
188
+ if((IsNestedDict(fnamedict) and compresscheck in fnamedict) or (IsSingleDict(fnamedict) and compresscheck==fnamedict['format_magic'])):
189
+ pyfoxfile.RePackFoxFile(input_file, getargs.output, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt,
190
+ False, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.verbose, False)
191
+ else:
192
+ pyfoxfile.PackFoxFileFromInFile(input_file, getargs.output, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.verbose, False)
193
+ if(not tmpout):
194
+ sys.exit(1)
195
+ else:
196
+ pyfoxfile.RePackFoxFile(input_file, getargs.output, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt,
197
+ False, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.verbose, False)
198
+ elif active_action == 'extract':
199
+ if getargs.convert:
200
+ checkcompressfile = pyfoxfile.CheckCompressionSubType(
201
+ input_file, fnamedict, True)
202
+ tempout = BytesIO()
203
+ if((IsNestedDict(fnamedict) and compresscheck in fnamedict) or (IsSingleDict(fnamedict) and compresscheck==fnamedict['format_magic'])):
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
+ else:
206
+ tmpout = pyfoxfile.PackFoxFileFromInFile(
207
+ input_file, tempout, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, False, False)
208
+ if(not tmpout):
209
+ sys.exit(1)
210
+ input_file = tempout
211
+ pyfoxfile.UnPackFoxFile(input_file, getargs.output, False, 0, 0, getargs.skipchecksum,
212
+ fnamedict, getargs.verbose, getargs.preserve, getargs.preserve, False, False)
213
+ elif active_action == 'list':
214
+ if getargs.convert:
215
+ checkcompressfile = pyfoxfile.CheckCompressionSubType(
216
+ input_file, fnamedict, True)
217
+ if((IsNestedDict(fnamedict) and compresscheck in fnamedict) or (IsSingleDict(fnamedict) and compresscheck==fnamedict['format_magic'])):
218
+ tmpout = pyfoxfile.FoxFileListFiles(input_file, "auto", 0, 0, getargs.skipchecksum, fnamedict, False, getargs.verbose, False)
219
+ else:
220
+ tmpout = pyfoxfile.InFileListFiles(input_file, getargs.verbose, fnamedict, False, False)
221
+ if(not tmpout):
222
+ sys.exit(1)
223
+ else:
224
+ pyfoxfile.FoxFileListFiles(input_file, "auto", 0, 0, getargs.skipchecksum, fnamedict, False, getargs.verbose, False)
225
+ elif active_action == 'validate':
226
+ if getargs.convert:
227
+ checkcompressfile = pyfoxfile.CheckCompressionSubType(
228
+ input_file, fnamedict, True)
229
+ tempout = BytesIO()
230
+ if((IsNestedDict(fnamedict) and compresscheck in fnamedict) or (IsSingleDict(fnamedict) and compresscheck==fnamedict['format_magic'])):
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
+ else:
233
+ tmpout = pyfoxfile.PackFoxFileFromInFile(
234
+ input_file, tempout, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pyfoxfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, False, False)
235
+ input_file = tempout
236
+ if(not tmpout):
237
+ sys.exit(1)
238
+ fvalid = pyfoxfile.FoxFileValidate(
239
+ input_file, "auto", fnamedict, False, getargs.verbose, False)
240
+ if(not getargs.verbose):
241
+ import sys
242
+ import logging
243
+ logging.basicConfig(format="%(message)s",
244
+ stream=sys.stdout, level=logging.DEBUG)
245
+ if(fvalid):
246
+ pyfoxfile.VerbosePrintOut("File is valid: \n" + str(input_file))
247
+ else:
248
+ pyfoxfile.VerbosePrintOut("File is invalid: \n" + str(input_file))
@@ -0,0 +1,136 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ '''
5
+ This program is free software; you can redistribute it and/or modify
6
+ it under the terms of the Revised BSD License.
7
+
8
+ This program is distributed in the hope that it will be useful,
9
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ Revised BSD License for more details.
12
+
13
+ Copyright 2018-2024 Cool Dude 2k - http://idb.berlios.de/
14
+ Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
15
+ Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
16
+
17
+ $FileInfo: neofoxfile.py - Last Update: 3/7/2025 Ver. 0.19.0 RC 1 - Author: cooldude2k $
18
+ '''
19
+
20
+ from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
21
+ import argparse
22
+ import pyfoxfile
23
+
24
+ __project__ = pyfoxfile.__project__
25
+ __program_name__ = pyfoxfile.__program_name__
26
+ __file_format_name__ = pyfoxfile.__file_format_name__
27
+ __file_format_magic__ = pyfoxfile.__file_format_magic__
28
+ __file_format_len__ = pyfoxfile.__file_format_len__
29
+ __file_format_hex__ = pyfoxfile.__file_format_hex__
30
+ __file_format_delimiter__ = pyfoxfile.__file_format_delimiter__
31
+ __file_format_dict__ = pyfoxfile.__file_format_dict__
32
+ __file_format_default__ = pyfoxfile.__file_format_default__
33
+ __use_new_style__ = pyfoxfile.__use_new_style__
34
+ __use_advanced_list__ = pyfoxfile.__use_advanced_list__
35
+ __use_alt_inode__ = pyfoxfile.__use_alt_inode__
36
+ __project_url__ = pyfoxfile.__project_url__
37
+ __version_info__ = pyfoxfile.__version_info__
38
+ __version_date_info__ = pyfoxfile.__version_date_info__
39
+ __version_date__ = pyfoxfile.__version_date__
40
+ __version_date_plusrc__ = pyfoxfile.__version_date_plusrc__
41
+ __version__ = pyfoxfile.__version__
42
+
43
+ # Compatibility layer for Python 2 and 3 input
44
+ try:
45
+ input = raw_input
46
+ except NameError:
47
+ pass
48
+
49
+ # Determine if rar file support is enabled
50
+ rarfile_support = pyfoxfile.rarfile_support
51
+ py7zr_support = pyfoxfile.py7zr_support
52
+
53
+ # Set up the argument parser
54
+ argparser = argparse.ArgumentParser(
55
+ description="Manipulates archive files for various operations like creation, extraction, and validation.")
56
+ argparser.add_argument("-V", "--version", action="version", version="{0} {1}".format(
57
+ __program_name__, __version__), help="Displays the program's version.")
58
+ argparser.add_argument("-i", "--input", nargs="+", required=True,
59
+ help="Specifies input file(s) for processing.")
60
+ argparser.add_argument(
61
+ "-o", "--output", help="Specifies the output file name.")
62
+ argparser.add_argument("-d", "--verbose", action="store_true",
63
+ help="Enables verbose mode for detailed information.")
64
+ argparser.add_argument("-c", "--create", action="store_true",
65
+ help="Creates a new archive file from input.")
66
+ argparser.add_argument("-e", "--extract", action="store_true",
67
+ help="Extracts files from a archive archive.")
68
+ argparser.add_argument("-l", "--list", action="store_true",
69
+ help="Lists contents of a specified archive file.")
70
+ argparser.add_argument("-r", "--repack", action="store_true",
71
+ help="Repacks an existing archive file.")
72
+ argparser.add_argument("-v", "--validate", action="store_true",
73
+ help="Validates a archive file's integrity.")
74
+ argparser.add_argument("--checksum", default="crc32",
75
+ help="Specifies the checksum type (default: crc32).")
76
+ argparser.add_argument("--compression", default="auto",
77
+ help="Specifies the compression method (default: auto).")
78
+ argparser.add_argument("--level", help="Specifies the compression level.")
79
+ argparser.add_argument("--preserve", action="store_true",
80
+ help="Preserves file attributes when extracting.")
81
+ argparser.add_argument("--convert", choices=['tar', 'zip', '7zip', 'rar'],
82
+ help="Convert from an archive format (tar, zip, 7zip, rar) to a archive file.")
83
+ args = argparser.parse_args()
84
+
85
+ # Determine the primary action based on user input
86
+ primary_action = None
87
+ if args.create:
88
+ primary_action = 'create'
89
+ elif args.repack:
90
+ primary_action = 'repack'
91
+ elif args.extract:
92
+ primary_action = 'extract'
93
+ elif args.list:
94
+ primary_action = 'list'
95
+ elif args.validate:
96
+ primary_action = 'validate'
97
+ input_file = args.input[0]
98
+ # Functionality mappings
99
+ if primary_action == 'create':
100
+ if args.convert == 'tar':
101
+ pyfoxfile.PackFoxFileFromTarFile(input_file, args.output, args.compression, args.level, pyfoxfile.compressionlistalt, [args.checksum, args.checksum, args.checksum, args.checksum], [
102
+ ], pyfoxfile.__file_format_dict__, args.verbose, False)
103
+ elif args.convert == 'zip':
104
+ pyfoxfile.PackFoxFileFromZipFile(input_file, args.output, args.compression, args.level, pyfoxfile.compressionlistalt, [args.checksum, args.checksum, args.checksum, args.checksum], [
105
+ ], pyfoxfile.__file_format_dict__, args.verbose, False)
106
+ elif py7zr_support and args.convert == '7zip':
107
+ pyfoxfile.PackFoxFileFromSevenZipFile(input_file, args.output, args.compression, args.level, pyfoxfile.compressionlistalt, [args.checksum, args.checksum, args.checksum, args.checksum], [
108
+ ], pyfoxfile.__file_format_dict__, args.verbose, False)
109
+ elif rarfile_support and args.convert == 'rar':
110
+ pyfoxfile.PackFoxFileFromRarFile(input_file, args.output, args.compression, args.level, pyfoxfile.compressionlistalt, [args.checksum, args.checksum, args.checksum, args.checksum], [
111
+ ], pyfoxfile.__file_format_dict__, args.verbose, False)
112
+ else:
113
+ pyfoxfile.PackFoxFile(args.input, args.output, args.verbose, args.compression, args.level, pyfoxfile.compressionlistalt,
114
+ False, [args.checksum, args.checksum, args.checksum, args.checksum], [], {}, pyfoxfile.__file_format_dict__, args.verbose, False)
115
+ elif primary_action == 'repack':
116
+ pyfoxfile.RePackFoxFile(
117
+ input_file, args.output, args.compression, args.level, pyfoxfile.compressionlistalt, [args.checksum, args.checksum, args.checksum, args.checksum], False, args.verbose)
118
+ elif primary_action == 'extract':
119
+ pyfoxfile.UnPackFoxFile(
120
+ input_file, args.output, False, args.verbose, args.preserve)
121
+ elif primary_action == 'list':
122
+ if args.convert == 'tar':
123
+ pyfoxfile.TarFileListFiles(input_file, verbose=args.verbose)
124
+ elif args.convert == 'zip':
125
+ pyfoxfile.ZipFileListFiles(input_file, verbose=args.verbose)
126
+ elif args.convert == '7zip':
127
+ pyfoxfile.SevenZipFileListFiles(input_file, verbose=args.verbose)
128
+ elif rarfile_support and args.convert == 'rar':
129
+ pyfoxfile.RarFileListFiles(input_file, verbose=args.verbose)
130
+ else:
131
+ pyfoxfile.FoxFileListFiles(input_file, verbose=args.verbose)
132
+ elif primary_action == 'validate':
133
+ is_valid = pyfoxfile.FoxFileValidate(input_file, verbose=args.verbose)
134
+ result_msg = "Validation result for {0}: {1}".format(
135
+ input_file, 'Valid' if is_valid else 'Invalid')
136
+ print(result_msg)