PyCatFile 0.13.12__tar.gz → 0.14.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.
- {pycatfile-0.13.12 → pycatfile-0.14.0}/PKG-INFO +1 -1
- {pycatfile-0.13.12 → pycatfile-0.14.0}/PyCatFile.egg-info/PKG-INFO +1 -1
- pycatfile-0.14.0/catfile.py +253 -0
- pycatfile-0.14.0/neocatfile.py +117 -0
- pycatfile-0.14.0/pycatfile.py +9203 -0
- pycatfile-0.14.0/setup.py +147 -0
- pycatfile-0.13.12/catfile.py +0 -200
- pycatfile-0.13.12/neocatfile.py +0 -90
- pycatfile-0.13.12/pycatfile.py +0 -8337
- pycatfile-0.13.12/setup.py +0 -115
- {pycatfile-0.13.12 → pycatfile-0.14.0}/LICENSE +0 -0
- {pycatfile-0.13.12 → pycatfile-0.14.0}/PyCatFile.egg-info/SOURCES.txt +0 -0
- {pycatfile-0.13.12 → pycatfile-0.14.0}/PyCatFile.egg-info/dependency_links.txt +0 -0
- {pycatfile-0.13.12 → pycatfile-0.14.0}/PyCatFile.egg-info/top_level.txt +0 -0
- {pycatfile-0.13.12 → pycatfile-0.14.0}/PyCatFile.egg-info/zip-safe +0 -0
- {pycatfile-0.13.12 → pycatfile-0.14.0}/README.md +0 -0
- {pycatfile-0.13.12 → pycatfile-0.14.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PyCatFile
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.14.0
|
|
4
4
|
Summary: A tar like file format name catfile after unix cat command (concatenate files) .
|
|
5
5
|
Home-page: https://github.com/GameMaker2k/PyCatFile
|
|
6
6
|
Download-URL: https://github.com/GameMaker2k/PyCatFile/archive/master.tar.gz
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PyCatFile
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.14.0
|
|
4
4
|
Summary: A tar like file format name catfile after unix cat command (concatenate files) .
|
|
5
5
|
Home-page: https://github.com/GameMaker2k/PyCatFile
|
|
6
6
|
Download-URL: https://github.com/GameMaker2k/PyCatFile/archive/master.tar.gz
|
|
@@ -0,0 +1,253 @@
|
|
|
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: catfile.py - Last Update: 7/10/2024 Ver. 0.13.12 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 pycatfile
|
|
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
|
+
pycatfile.VerbosePrintOut(
|
|
33
|
+
"Received SIGPIPE, exiting gracefully.", "info")
|
|
34
|
+
sys.exit(0)
|
|
35
|
+
signal.signal(signal.SIGPIPE, handler)
|
|
36
|
+
|
|
37
|
+
rarfile_support = pycatfile.rarfile_support
|
|
38
|
+
py7zr_support = pycatfile.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__ = pycatfile.__project__
|
|
74
|
+
__program_name__ = pycatfile.__program_name__
|
|
75
|
+
__file_format_name__ = pycatfile.__file_format_name__
|
|
76
|
+
__file_format_lower__ = pycatfile.__file_format_lower__
|
|
77
|
+
__file_format_magic__ = pycatfile.__file_format_magic__
|
|
78
|
+
__file_format_len__ = pycatfile.__file_format_len__
|
|
79
|
+
__file_format_hex__ = pycatfile.__file_format_hex__
|
|
80
|
+
__file_format_delimiter__ = pycatfile.__file_format_delimiter__
|
|
81
|
+
__file_format_list__ = pycatfile.__file_format_list__
|
|
82
|
+
__use_new_style__ = pycatfile.__use_new_style__
|
|
83
|
+
__use_advanced_list__ = pycatfile.__use_advanced_list__
|
|
84
|
+
__use_alt_inode__ = pycatfile.__use_alt_inode__
|
|
85
|
+
__project_url__ = pycatfile.__project_url__
|
|
86
|
+
__version_info__ = pycatfile.__version_info__
|
|
87
|
+
__version_date_info__ = pycatfile.__version_date_info__
|
|
88
|
+
__version_date__ = pycatfile.__version_date__
|
|
89
|
+
__version_date_plusrc__ = pycatfile.__version_date_plusrc__
|
|
90
|
+
__version__ = pycatfile.__version__
|
|
91
|
+
|
|
92
|
+
# Initialize the argument parser
|
|
93
|
+
argparser = argparse.ArgumentParser(
|
|
94
|
+
description="Manipulate concatenated files.", conflict_handler="resolve", add_help=True)
|
|
95
|
+
|
|
96
|
+
# Version information
|
|
97
|
+
argparser.add_argument("-V", "--version", action="version",
|
|
98
|
+
version=__program_name__ + " " + __version__)
|
|
99
|
+
# Input and output specifications
|
|
100
|
+
argparser.add_argument(
|
|
101
|
+
"-i", "--input", help="Specify the file(s) to concatenate or the concatenated file to extract.", required=True)
|
|
102
|
+
argparser.add_argument("-o", "--output", default=None,
|
|
103
|
+
help="Specify the name for the extracted or output concatenated files.")
|
|
104
|
+
# Operations
|
|
105
|
+
argparser.add_argument("-c", "--create", action="store_true",
|
|
106
|
+
help="Perform only the concatenation operation.")
|
|
107
|
+
argparser.add_argument("-e", "--extract", action="store_true",
|
|
108
|
+
help="Perform only the extraction operation.")
|
|
109
|
+
argparser.add_argument("-t", "--convert", action="store_true",
|
|
110
|
+
help="Convert a tar/zip/rar/7zip file to a concatenated file.")
|
|
111
|
+
argparser.add_argument("-r", "--repack", action="store_true",
|
|
112
|
+
help="Re-concatenate files, fixing checksum errors if any.")
|
|
113
|
+
# File manipulation options
|
|
114
|
+
argparser.add_argument(
|
|
115
|
+
"-F", "--format", default=__file_format_list__[0], help="Specify the format to use.")
|
|
116
|
+
argparser.add_argument(
|
|
117
|
+
"-D", "--delimiter", default=__file_format_list__[5], help="Specify the delimiter to use.")
|
|
118
|
+
argparser.add_argument(
|
|
119
|
+
"-m", "--formatver", default=__file_format_list__[6], help="Specify the format version.")
|
|
120
|
+
argparser.add_argument("-l", "--list", action="store_true",
|
|
121
|
+
help="List files included in the concatenated file.")
|
|
122
|
+
# Compression options
|
|
123
|
+
argparser.add_argument("-P", "--compression", default="auto",
|
|
124
|
+
help="Specify the compression method to use for concatenation.")
|
|
125
|
+
argparser.add_argument("-L", "--level", default=None,
|
|
126
|
+
help="Specify the compression level for concatenation.")
|
|
127
|
+
argparser.add_argument("-W", "--wholefile", action="store_true",
|
|
128
|
+
help="Whole file compression method to use for concatenation.")
|
|
129
|
+
# Checksum and validation
|
|
130
|
+
argparser.add_argument("-v", "--validate", action="store_true",
|
|
131
|
+
help="Validate concatenated file checksums.")
|
|
132
|
+
argparser.add_argument("-C", "--checksum", default="crc32",
|
|
133
|
+
help="Specify the type of checksum to use. The default is crc32.")
|
|
134
|
+
argparser.add_argument("-s", "--skipchecksum", action="store_true",
|
|
135
|
+
help="Skip the checksum check of files.")
|
|
136
|
+
# Permissions and metadata
|
|
137
|
+
argparser.add_argument("-p", "--preserve", action="store_false",
|
|
138
|
+
help="Do not preserve permissions and timestamps of files.")
|
|
139
|
+
# Miscellaneous
|
|
140
|
+
argparser.add_argument("-d", "--verbose", action="store_true",
|
|
141
|
+
help="Enable verbose mode to display various debugging information.")
|
|
142
|
+
argparser.add_argument("-T", "--text", action="store_true",
|
|
143
|
+
help="Read file locations from a text file.")
|
|
144
|
+
# Parse the arguments
|
|
145
|
+
getargs = argparser.parse_args()
|
|
146
|
+
|
|
147
|
+
fname = getargs.format
|
|
148
|
+
fnamelower = fname.lower()
|
|
149
|
+
fnamemagic = fname
|
|
150
|
+
fnamelen = len(fname)
|
|
151
|
+
fnamehex = binascii.hexlify(fname.encode("UTF-8")).decode("UTF-8")
|
|
152
|
+
fnamesty = __use_new_style__
|
|
153
|
+
fnamelst = __use_advanced_list__
|
|
154
|
+
fnameino = __use_alt_inode__
|
|
155
|
+
fnamelist = [fname, fnamemagic, fnamelower, fnamelen, fnamehex,
|
|
156
|
+
getargs.delimiter, getargs.formatver, fnamesty, fnamelst, fnameino]
|
|
157
|
+
fnamedict = {'format_name': fname, 'format_magic': fnamemagic, 'format_lower': fnamelower, 'format_len': fnamelen, 'format_hex': fnamehex,
|
|
158
|
+
'format_delimiter': getargs.delimiter, 'format_ver': getargs.formatver, 'new_style': fnamesty, 'use_advanced_list': fnamelst, 'use_alt_inode': fnameino}
|
|
159
|
+
|
|
160
|
+
# Determine the primary action based on user input
|
|
161
|
+
actions = ['create', 'extract', 'list', 'repack', 'validate']
|
|
162
|
+
active_action = next(
|
|
163
|
+
(action for action in actions if getattr(getargs, action)), None)
|
|
164
|
+
|
|
165
|
+
# Execute the appropriate functions based on determined actions and arguments
|
|
166
|
+
if active_action:
|
|
167
|
+
if active_action == 'create':
|
|
168
|
+
if getargs.convert:
|
|
169
|
+
checkcompressfile = pycatfile.CheckCompressionSubType(
|
|
170
|
+
getargs.input, fnamedict, True)
|
|
171
|
+
if(checkcompressfile == "catfile"):
|
|
172
|
+
tmpout = pycatfile.RePackArchiveFile(getargs.input, getargs.output, getargs.compression, getargs.wholefile,
|
|
173
|
+
getargs.level, False, 0, 0, getargs.checksum, getargs.skipchecksum, [], fnamedict, getargs.verbose, False)
|
|
174
|
+
else:
|
|
175
|
+
tmpout = pycatfile.PackArchiveFileFromInFile(
|
|
176
|
+
getargs.input, getargs.output, getargs.compression, getargs.wholefile, getargs.level, getargs.checksum, [], fnamedict, getargs.verbose, False)
|
|
177
|
+
if(not tmpout):
|
|
178
|
+
sys.exit(1)
|
|
179
|
+
else:
|
|
180
|
+
pycatfile.PackArchiveFile(getargs.input, getargs.output, getargs.text, getargs.compression,
|
|
181
|
+
getargs.wholefile, getargs.level, False, getargs.checksum, [], fnamedict, getargs.verbose, False)
|
|
182
|
+
elif active_action == 'repack':
|
|
183
|
+
if getargs.convert:
|
|
184
|
+
checkcompressfile = pycatfile.CheckCompressionSubType(
|
|
185
|
+
getargs.input, fnamedict, True)
|
|
186
|
+
if(checkcompressfile == "catfile"):
|
|
187
|
+
pycatfile.RePackArchiveFile(getargs.input, getargs.output, getargs.compression, getargs.wholefile, getargs.level,
|
|
188
|
+
False, 0, 0, getargs.checksum, getargs.skipchecksum, [], fnamedict, getargs.verbose, False)
|
|
189
|
+
else:
|
|
190
|
+
pycatfile.PackArchiveFileFromInFile(getargs.input, getargs.output, getargs.compression,
|
|
191
|
+
getargs.wholefile, getargs.level, getargs.checksum, [], fnamedict, getargs.verbose, False)
|
|
192
|
+
if(not tmpout):
|
|
193
|
+
sys.exit(1)
|
|
194
|
+
else:
|
|
195
|
+
pycatfile.RePackArchiveFile(getargs.input, getargs.output, getargs.compression, getargs.wholefile, getargs.level,
|
|
196
|
+
False, 0, 0, getargs.checksum, getargs.skipchecksum, [], fnamedict, getargs.verbose, False)
|
|
197
|
+
elif active_action == 'extract':
|
|
198
|
+
if getargs.convert:
|
|
199
|
+
checkcompressfile = pycatfile.CheckCompressionSubType(
|
|
200
|
+
getargs.input, fnamedict, True)
|
|
201
|
+
tempout = BytesIO()
|
|
202
|
+
if(checkcompressfile == "catfile"):
|
|
203
|
+
tmpout = pycatfile.RePackArchiveFile(getargs.input, tempout, getargs.compression, getargs.wholefile,
|
|
204
|
+
getargs.level, False, 0, 0, getargs.checksum, getargs.skipchecksum, [], fnamedict, False, False)
|
|
205
|
+
else:
|
|
206
|
+
tmpout = pycatfile.PackArchiveFileFromInFile(
|
|
207
|
+
getargs.input, tempout, getargs.compression, getargs.wholefile, getargs.level, getargs.checksum, [], fnamedict, False, False)
|
|
208
|
+
if(not tmpout):
|
|
209
|
+
sys.exit(1)
|
|
210
|
+
getargs.input = tempout
|
|
211
|
+
pycatfile.UnPackArchiveFile(getargs.input, getargs.output, False, 0, 0, getargs.skipchecksum,
|
|
212
|
+
fnamedict, getargs.verbose, getargs.preserve, getargs.preserve, False)
|
|
213
|
+
elif active_action == 'list':
|
|
214
|
+
if getargs.convert:
|
|
215
|
+
checkcompressfile = pycatfile.CheckCompressionSubType(
|
|
216
|
+
getargs.input, fnamedict, True)
|
|
217
|
+
if(checkcompressfile == "catfile"):
|
|
218
|
+
tmpout = pycatfile.ArchiveFileListFiles(
|
|
219
|
+
getargs.input, 0, 0, getargs.skipchecksum, fnamedict, getargs.verbose, False)
|
|
220
|
+
else:
|
|
221
|
+
tmpout = pycatfile.InFileListFiles(
|
|
222
|
+
getargs.input, getargs.verbose, fnamedict, False)
|
|
223
|
+
if(not tmpout):
|
|
224
|
+
sys.exit(1)
|
|
225
|
+
else:
|
|
226
|
+
pycatfile.ArchiveFileListFiles(
|
|
227
|
+
getargs.input, 0, 0, getargs.skipchecksum, fnamedict, getargs.verbose, False)
|
|
228
|
+
elif active_action == 'validate':
|
|
229
|
+
if getargs.convert:
|
|
230
|
+
checkcompressfile = pycatfile.CheckCompressionSubType(
|
|
231
|
+
getargs.input, fnamedict, True)
|
|
232
|
+
tempout = BytesIO()
|
|
233
|
+
if(checkcompressfile == "catfile"):
|
|
234
|
+
tmpout = pycatfile.RePackArchiveFile(getargs.input, tempout, getargs.compression, getargs.wholefile,
|
|
235
|
+
getargs.level, False, 0, 0, getargs.checksum, getargs.skipchecksum, [], fnamedict, False, False)
|
|
236
|
+
else:
|
|
237
|
+
tmpout = pycatfile.PackArchiveFileFromInFile(
|
|
238
|
+
getargs.input, tempout, getargs.compression, getargs.wholefile, getargs.level, getargs.checksum, [], fnamedict, False, False)
|
|
239
|
+
getargs.input = tempout
|
|
240
|
+
if(not tmpout):
|
|
241
|
+
sys.exit(1)
|
|
242
|
+
fvalid = pycatfile.ArchiveFileValidate(
|
|
243
|
+
getargs.input, fnamedict, getargs.verbose, False)
|
|
244
|
+
if(not getargs.verbose):
|
|
245
|
+
import sys
|
|
246
|
+
import logging
|
|
247
|
+
logging.basicConfig(format="%(message)s",
|
|
248
|
+
stream=sys.stdout, level=logging.DEBUG)
|
|
249
|
+
if(fvalid):
|
|
250
|
+
pycatfile.VerbosePrintOut("File is valid: \n" + str(getargs.input))
|
|
251
|
+
else:
|
|
252
|
+
pycatfile.VerbosePrintOut(
|
|
253
|
+
"File is invalid: \n" + str(getargs.input))
|
|
@@ -0,0 +1,117 @@
|
|
|
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: neocatfile.py - Last Update: 7/10/2024 Ver. 0.13.12 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 pycatfile
|
|
23
|
+
|
|
24
|
+
# Compatibility layer for Python 2 and 3 input
|
|
25
|
+
try:
|
|
26
|
+
input = raw_input
|
|
27
|
+
except NameError:
|
|
28
|
+
pass
|
|
29
|
+
|
|
30
|
+
# Determine if rar file support is enabled
|
|
31
|
+
rarfile_support = pycatfile.rarfile_support
|
|
32
|
+
py7zr_support = pycatfile.py7zr_support
|
|
33
|
+
|
|
34
|
+
# Set up the argument parser
|
|
35
|
+
argparser = argparse.ArgumentParser(
|
|
36
|
+
description="Manipulates concatenated files for various operations like creation, extraction, and validation.")
|
|
37
|
+
argparser.add_argument("-V", "--version", action="version", version="{0} {1}".format(
|
|
38
|
+
pycatfile.__program_name__, pycatfile.__version__), help="Displays the program's version.")
|
|
39
|
+
argparser.add_argument("-i", "--input", required=True,
|
|
40
|
+
help="Specifies input file(s) for processing.")
|
|
41
|
+
argparser.add_argument(
|
|
42
|
+
"-o", "--output", help="Specifies the output file name.")
|
|
43
|
+
argparser.add_argument("-d", "--verbose", action="store_true",
|
|
44
|
+
help="Enables verbose mode for detailed information.")
|
|
45
|
+
argparser.add_argument("-c", "--create", action="store_true",
|
|
46
|
+
help="Creates a new concatenated file from input.")
|
|
47
|
+
argparser.add_argument("-e", "--extract", action="store_true",
|
|
48
|
+
help="Extracts files from a concatenated archive.")
|
|
49
|
+
argparser.add_argument("-l", "--list", action="store_true",
|
|
50
|
+
help="Lists contents of a specified concatenated file.")
|
|
51
|
+
argparser.add_argument("-r", "--repack", action="store_true",
|
|
52
|
+
help="Repacks an existing concatenated file.")
|
|
53
|
+
argparser.add_argument("-v", "--validate", action="store_true",
|
|
54
|
+
help="Validates a concatenated file's integrity.")
|
|
55
|
+
argparser.add_argument("--checksum", default="crc32",
|
|
56
|
+
help="Specifies the checksum type (default: crc32).")
|
|
57
|
+
argparser.add_argument("--compression", default="auto",
|
|
58
|
+
help="Specifies the compression method (default: auto).")
|
|
59
|
+
argparser.add_argument("--level", help="Specifies the compression level.")
|
|
60
|
+
argparser.add_argument("--preserve", action="store_true",
|
|
61
|
+
help="Preserves file attributes when extracting.")
|
|
62
|
+
argparser.add_argument("--convert", choices=['tar', 'zip', '7zip', 'rar'],
|
|
63
|
+
help="Convert from an archive format (tar, zip, 7zip, rar) to a concatenated file.")
|
|
64
|
+
args = argparser.parse_args()
|
|
65
|
+
|
|
66
|
+
# Determine the primary action based on user input
|
|
67
|
+
primary_action = None
|
|
68
|
+
if args.create:
|
|
69
|
+
primary_action = 'create'
|
|
70
|
+
elif args.repack:
|
|
71
|
+
primary_action = 'repack'
|
|
72
|
+
elif args.extract:
|
|
73
|
+
primary_action = 'extract'
|
|
74
|
+
elif args.list:
|
|
75
|
+
primary_action = 'list'
|
|
76
|
+
elif args.validate:
|
|
77
|
+
primary_action = 'validate'
|
|
78
|
+
|
|
79
|
+
# Functionality mappings
|
|
80
|
+
if primary_action == 'create':
|
|
81
|
+
if args.convert == 'tar':
|
|
82
|
+
pycatfile.PackArchiveFileFromTarFile(args.input, args.output, args.compression, args.level, args.checksum, [
|
|
83
|
+
], pycatfile.__file_format_list__, args.verbose, False)
|
|
84
|
+
elif args.convert == 'zip':
|
|
85
|
+
pycatfile.PackArchiveFileFromZipFile(args.input, args.output, args.compression, args.level, args.checksum, [
|
|
86
|
+
], pycatfile.__file_format_list__, args.verbose, False)
|
|
87
|
+
elif py7zr_support and args.convert == '7zip':
|
|
88
|
+
pycatfile.PackArchiveFileFromSevenZipFile(args.input, args.output, args.compression, args.level, args.checksum, [
|
|
89
|
+
], pycatfile.__file_format_list__, args.verbose, False)
|
|
90
|
+
elif rarfile_support and args.convert == 'rar':
|
|
91
|
+
pycatfile.PackArchiveFileFromRarFile(args.input, args.output, args.compression, args.level, args.checksum, [
|
|
92
|
+
], pycatfile.__file_format_list__, args.verbose, False)
|
|
93
|
+
else:
|
|
94
|
+
pycatfile.PackArchiveFile(args.input, args.output, args.verbose, args.compression, args.level,
|
|
95
|
+
False, args.checksum, [], pycatfile.__file_format_list__, args.verbose, False)
|
|
96
|
+
elif primary_action == 'repack':
|
|
97
|
+
pycatfile.RePackArchiveFile(
|
|
98
|
+
args.input, args.output, args.compression, args.level, args.checksum, args.verbose)
|
|
99
|
+
elif primary_action == 'extract':
|
|
100
|
+
pycatfile.UnPackArchiveFile(
|
|
101
|
+
args.input, args.output, args.verbose, args.preserve)
|
|
102
|
+
elif primary_action == 'list':
|
|
103
|
+
if args.convert == 'tar':
|
|
104
|
+
pycatfile.TarFileListFiles(args.input, verbose=args.verbose)
|
|
105
|
+
elif args.convert == 'zip':
|
|
106
|
+
pycatfile.ZipFileListFiles(args.input, verbose=args.verbose)
|
|
107
|
+
elif args.convert == '7zip':
|
|
108
|
+
pycatfile.SevenZipFileListFiles(args.input, verbose=args.verbose)
|
|
109
|
+
elif rarfile_support and args.convert == 'rar':
|
|
110
|
+
pycatfile.RarFileListFiles(args.input, verbose=args.verbose)
|
|
111
|
+
else:
|
|
112
|
+
pycatfile.ArchiveFileListFiles(args.input, verbose=args.verbose)
|
|
113
|
+
elif primary_action == 'validate':
|
|
114
|
+
is_valid = pycatfile.ArchiveFileValidate(args.input, args.verbose)
|
|
115
|
+
result_msg = "Validation result for {0}: {1}".format(
|
|
116
|
+
args.input, 'Valid' if is_valid else 'Invalid')
|
|
117
|
+
print(result_msg)
|