PyCatFile 0.8.6__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.8.6/LICENSE +29 -0
- pycatfile-0.8.6/PKG-INFO +35 -0
- pycatfile-0.8.6/PyCatFile.egg-info/PKG-INFO +35 -0
- pycatfile-0.8.6/PyCatFile.egg-info/SOURCES.txt +12 -0
- pycatfile-0.8.6/PyCatFile.egg-info/dependency_links.txt +1 -0
- pycatfile-0.8.6/PyCatFile.egg-info/top_level.txt +1 -0
- pycatfile-0.8.6/PyCatFile.egg-info/zip-safe +1 -0
- pycatfile-0.8.6/README.md +1 -0
- pycatfile-0.8.6/catfile.py +215 -0
- pycatfile-0.8.6/neocatfile.py +90 -0
- pycatfile-0.8.6/pycatfile.py +8314 -0
- pycatfile-0.8.6/setup.cfg +8 -0
- pycatfile-0.8.6/setup.py +115 -0
pycatfile-0.8.6/LICENSE
ADDED
|
@@ -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.
|
pycatfile-0.8.6/PKG-INFO
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: PyCatFile
|
|
3
|
+
Version: 0.8.6
|
|
4
|
+
Summary: A tar like file format name catfile after unix cat command (concatenate files) .
|
|
5
|
+
Home-page: https://github.com/GameMaker2k/PyCatFile
|
|
6
|
+
Download-URL: https://github.com/GameMaker2k/PyCatFile/archive/master.tar.gz
|
|
7
|
+
Author: Kazuki Przyborowski
|
|
8
|
+
Author-email: kazuki.przyborowski@gmail.com
|
|
9
|
+
Maintainer: Kazuki Przyborowski
|
|
10
|
+
Maintainer-email: kazuki.przyborowski@gmail.com
|
|
11
|
+
License: Revised BSD License
|
|
12
|
+
Keywords: catfile pycatfile python python-catfile
|
|
13
|
+
Platform: OS Independent
|
|
14
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Other Audience
|
|
17
|
+
Classifier: License :: OSI Approved
|
|
18
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
19
|
+
Classifier: Natural Language :: English
|
|
20
|
+
Classifier: Operating System :: MacOS
|
|
21
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
22
|
+
Classifier: Operating System :: Microsoft
|
|
23
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
24
|
+
Classifier: Operating System :: OS/2
|
|
25
|
+
Classifier: Operating System :: OS Independent
|
|
26
|
+
Classifier: Operating System :: POSIX
|
|
27
|
+
Classifier: Operating System :: Unix
|
|
28
|
+
Classifier: Programming Language :: Python
|
|
29
|
+
Classifier: Topic :: Utilities
|
|
30
|
+
Classifier: Topic :: Software Development
|
|
31
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
32
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
33
|
+
License-File: LICENSE
|
|
34
|
+
|
|
35
|
+
A tar like file format name catfile after unix cat command (concatenate files) .
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: PyCatFile
|
|
3
|
+
Version: 0.8.6
|
|
4
|
+
Summary: A tar like file format name catfile after unix cat command (concatenate files) .
|
|
5
|
+
Home-page: https://github.com/GameMaker2k/PyCatFile
|
|
6
|
+
Download-URL: https://github.com/GameMaker2k/PyCatFile/archive/master.tar.gz
|
|
7
|
+
Author: Kazuki Przyborowski
|
|
8
|
+
Author-email: kazuki.przyborowski@gmail.com
|
|
9
|
+
Maintainer: Kazuki Przyborowski
|
|
10
|
+
Maintainer-email: kazuki.przyborowski@gmail.com
|
|
11
|
+
License: Revised BSD License
|
|
12
|
+
Keywords: catfile pycatfile python python-catfile
|
|
13
|
+
Platform: OS Independent
|
|
14
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Other Audience
|
|
17
|
+
Classifier: License :: OSI Approved
|
|
18
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
19
|
+
Classifier: Natural Language :: English
|
|
20
|
+
Classifier: Operating System :: MacOS
|
|
21
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
22
|
+
Classifier: Operating System :: Microsoft
|
|
23
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
24
|
+
Classifier: Operating System :: OS/2
|
|
25
|
+
Classifier: Operating System :: OS Independent
|
|
26
|
+
Classifier: Operating System :: POSIX
|
|
27
|
+
Classifier: Operating System :: Unix
|
|
28
|
+
Classifier: Programming Language :: Python
|
|
29
|
+
Classifier: Topic :: Utilities
|
|
30
|
+
Classifier: Topic :: Software Development
|
|
31
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
32
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
33
|
+
License-File: LICENSE
|
|
34
|
+
|
|
35
|
+
A tar like file format name catfile after unix cat command (concatenate files) .
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
catfile.py
|
|
4
|
+
neocatfile.py
|
|
5
|
+
pycatfile.py
|
|
6
|
+
setup.cfg
|
|
7
|
+
setup.py
|
|
8
|
+
PyCatFile.egg-info/PKG-INFO
|
|
9
|
+
PyCatFile.egg-info/SOURCES.txt
|
|
10
|
+
PyCatFile.egg-info/dependency_links.txt
|
|
11
|
+
PyCatFile.egg-info/top_level.txt
|
|
12
|
+
PyCatFile.egg-info/zip-safe
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pycatfile
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
A tar like file format name catfile after unix cat command (concatenate files)
|
|
@@ -0,0 +1,215 @@
|
|
|
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: 4/26/2024 Ver. 0.8.6 RC 1 - Author: cooldude2k $
|
|
18
|
+
'''
|
|
19
|
+
|
|
20
|
+
from __future__ import absolute_import, division, print_function, unicode_literals;
|
|
21
|
+
import sys, argparse, pycatfile, binascii;
|
|
22
|
+
|
|
23
|
+
rarfile_support = pycatfile.rarfile_support;
|
|
24
|
+
py7zr_support = pycatfile.py7zr_support;
|
|
25
|
+
|
|
26
|
+
if(sys.version[0]=="2"):
|
|
27
|
+
try:
|
|
28
|
+
from io import StringIO, BytesIO;
|
|
29
|
+
except ImportError:
|
|
30
|
+
try:
|
|
31
|
+
from cStringIO import StringIO;
|
|
32
|
+
from cStringIO import StringIO as BytesIO;
|
|
33
|
+
except ImportError:
|
|
34
|
+
from StringIO import StringIO;
|
|
35
|
+
from StringIO import StringIO as BytesIO;
|
|
36
|
+
elif(sys.version[0]>="3"):
|
|
37
|
+
from io import StringIO, BytesIO;
|
|
38
|
+
else:
|
|
39
|
+
teststringio = 0;
|
|
40
|
+
if(teststringio<=0):
|
|
41
|
+
try:
|
|
42
|
+
from cStringIO import StringIO as BytesIO;
|
|
43
|
+
teststringio = 1;
|
|
44
|
+
except ImportError:
|
|
45
|
+
teststringio = 0;
|
|
46
|
+
if(teststringio<=0):
|
|
47
|
+
try:
|
|
48
|
+
from StringIO import StringIO as BytesIO;
|
|
49
|
+
teststringio = 2;
|
|
50
|
+
except ImportError:
|
|
51
|
+
teststringio = 0;
|
|
52
|
+
if(teststringio<=0):
|
|
53
|
+
try:
|
|
54
|
+
from io import BytesIO;
|
|
55
|
+
teststringio = 3;
|
|
56
|
+
except ImportError:
|
|
57
|
+
teststringio = 0;
|
|
58
|
+
|
|
59
|
+
__project__ = pycatfile.__project__;
|
|
60
|
+
__program_name__ = pycatfile.__program_name__;
|
|
61
|
+
__file_format_name__ = pycatfile.__file_format_name__;
|
|
62
|
+
__file_format_lower__ = pycatfile.__file_format_lower__;
|
|
63
|
+
__file_format_magic__ = pycatfile.__file_format_magic__;
|
|
64
|
+
__file_format_len__ = pycatfile.__file_format_len__;
|
|
65
|
+
__file_format_hex__ = pycatfile.__file_format_hex__;
|
|
66
|
+
__file_format_delimiter__ = pycatfile.__file_format_delimiter__;
|
|
67
|
+
__file_format_list__ = pycatfile.__file_format_list__;
|
|
68
|
+
__use_new_style__ = pycatfile.__use_new_style__;
|
|
69
|
+
__use_advanced_list__ = pycatfile.__use_advanced_list__;
|
|
70
|
+
__use_alt_inode__ = pycatfile.__use_alt_inode__;
|
|
71
|
+
__project_url__ = pycatfile.__project_url__;
|
|
72
|
+
__version_info__ = pycatfile.__version_info__;
|
|
73
|
+
__version_date_info__ = pycatfile.__version_date_info__;
|
|
74
|
+
__version_date__ = pycatfile.__version_date__;
|
|
75
|
+
__version_date_plusrc__ = pycatfile.__version_date_plusrc__;
|
|
76
|
+
__version__ = pycatfile.__version__;
|
|
77
|
+
|
|
78
|
+
argparser = argparse.ArgumentParser(description="Manipulate concatenated files.", conflict_handler="resolve", add_help=True);
|
|
79
|
+
argparser.add_argument("-V", "--version", action="version", version=__program_name__ + " " + __version__);
|
|
80
|
+
argparser.add_argument("-i", "--input", help="Specify the file(s) to concatenate or the concatenated file to extract.", required=True);
|
|
81
|
+
argparser.add_argument("-d", "--verbose", action="store_true", help="Enable verbose mode to display various debugging information.");
|
|
82
|
+
argparser.add_argument("-c", "--create", action="store_true", help="Perform concatenation operation only.");
|
|
83
|
+
argparser.add_argument("-v", "--validate", action="store_true", help="Validate CatFile checksums.");
|
|
84
|
+
argparser.add_argument("-C", "--checksum", default="crc32", help="Specify the type of checksum to use. The default is crc32.");
|
|
85
|
+
argparser.add_argument("-s", "--skipchecksum", action="store_true", help="Skip the checksum check of files.");
|
|
86
|
+
argparser.add_argument("-e", "--extract", action="store_true", help="Perform extraction operation only.");
|
|
87
|
+
argparser.add_argument("-F", "--format", default=__file_format_list__[0], help="Specify the format to use.");
|
|
88
|
+
argparser.add_argument("-D", "--delimiter", default=__file_format_list__[5], help="Specify the delimiter to use.");
|
|
89
|
+
argparser.add_argument("-m", "--formatver", default=__file_format_list__[6], help="Specify the format version.");
|
|
90
|
+
argparser.add_argument("-l", "--list", action="store_true", help="List files included in the concatenated file.");
|
|
91
|
+
argparser.add_argument("-p", "--preserve", action="store_false", help="Preserve permissions and timestamps of files.");
|
|
92
|
+
argparser.add_argument("-R", "--repack", action="store_true", help="Re-concatenate files, fixing checksum errors, if any.");
|
|
93
|
+
argparser.add_argument("-o", "--output", default=None, help="Specify the name for the extracted or output concatenated files.");
|
|
94
|
+
argparser.add_argument("-P", "--compression", default="auto", help="Specify the compression method to use for concatenation.");
|
|
95
|
+
argparser.add_argument("-L", "--level", default=None, help="Specify the compression level for concatenation.");
|
|
96
|
+
argparser.add_argument("-t", "--convert", action="store_true", help="Convert a tar / zip / rar / 7zip file to a CatFile.");
|
|
97
|
+
argparser.add_argument("-T", "--text", action="store_true", help="Read file locations from a text file.");
|
|
98
|
+
getargs = argparser.parse_args()
|
|
99
|
+
|
|
100
|
+
fname = getargs.format;
|
|
101
|
+
fnamelower = fname.lower();
|
|
102
|
+
fnamemagic = fname;
|
|
103
|
+
fnamelen = len(fname);
|
|
104
|
+
fnamehex = binascii.hexlify(fname.encode("UTF-8")).decode("UTF-8");
|
|
105
|
+
fnamesty = __use_new_style__;
|
|
106
|
+
fnamelst = __use_advanced_list__;
|
|
107
|
+
fnameino = __use_alt_inode__;
|
|
108
|
+
fnamelist = [fname, fnamemagic, fnamelower, fnamelen, fnamehex, getargs.delimiter, getargs.formatver, fnamesty, fnamelst, fnameino];
|
|
109
|
+
|
|
110
|
+
# Determine actions based on user input
|
|
111
|
+
should_create = getargs.create and not getargs.extract and not getargs.list;
|
|
112
|
+
should_extract = getargs.extract and not getargs.create and not getargs.list;
|
|
113
|
+
should_list = getargs.list and not getargs.create and not getargs.extract;
|
|
114
|
+
should_repack = getargs.create and getargs.repack;
|
|
115
|
+
should_validate = getargs.validate;
|
|
116
|
+
|
|
117
|
+
# Execute the appropriate functions based on determined actions and arguments
|
|
118
|
+
if should_create:
|
|
119
|
+
if getargs.convert:
|
|
120
|
+
checkcompressfile = pycatfile.CheckCompressionSubType(getargs.input, fnamelist, True);
|
|
121
|
+
if(checkcompressfile=="tarfile"):
|
|
122
|
+
pycatfile.PackArchiveFileFromTarFile(getargs.input, getargs.output, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
|
|
123
|
+
elif(checkcompressfile=="zipfile"):
|
|
124
|
+
pycatfile.PackArchiveFileFromZipFile(getargs.input, getargs.output, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
|
|
125
|
+
elif(checkcompressfile=="catfile"):
|
|
126
|
+
pycatfile.RePackArchiveFile(getargs.input, getargs.output, getargs.compression, getargs.level, False, 0, 0, getargs.checksum, getargs.skipchecksum, [], fnamelist, getargs.verbose, False);
|
|
127
|
+
elif(rarfile_support and checkcompressfile=="rarfile"):
|
|
128
|
+
pycatfile.PackArchiveFileFromRarFile(getargs.input, getargs.output, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
|
|
129
|
+
elif(py7zr_support and checkcompressfile=="7zipfile"):
|
|
130
|
+
pycatfile.PackArchiveFileFromSevenZipFile(getargs.input, getargs.output, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
|
|
131
|
+
else:
|
|
132
|
+
sys.exit(1);
|
|
133
|
+
else:
|
|
134
|
+
pycatfile.PackArchiveFile(getargs.input, getargs.output, getargs.text, getargs.compression, getargs.level, False, getargs.checksum, [], fnamelist, getargs.verbose, False);
|
|
135
|
+
|
|
136
|
+
elif should_repack:
|
|
137
|
+
if getargs.convert:
|
|
138
|
+
checkcompressfile = pycatfile.CheckCompressionSubType(getargs.input, fnamelist, True);
|
|
139
|
+
if(checkcompressfile=="tarfile"):
|
|
140
|
+
pycatfile.PackArchiveFileFromTarFile(getargs.input, getargs.output, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
|
|
141
|
+
elif(checkcompressfile=="zipfile"):
|
|
142
|
+
pycatfile.PackArchiveFileFromZipFile(getargs.input, getargs.output, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
|
|
143
|
+
elif(checkcompressfile=="catfile"):
|
|
144
|
+
pycatfile.RePackArchiveFile(getargs.input, getargs.output, getargs.compression, getargs.level, False, 0, 0, getargs.checksum, getargs.skipchecksum, [], fnamelist, getargs.verbose, False);
|
|
145
|
+
elif(rarfile_support and checkcompressfile=="rarfile"):
|
|
146
|
+
pycatfile.PackArchiveFileFromRarFile(getargs.input, getargs.output, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
|
|
147
|
+
elif(py7zr_support and checkcompressfile=="7zipfile"):
|
|
148
|
+
pycatfile.PackArchiveFileFromSevenZipFile(getargs.input, getargs.output, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
|
|
149
|
+
else:
|
|
150
|
+
sys.exit(1);
|
|
151
|
+
else:
|
|
152
|
+
pycatfile.RePackArchiveFile(getargs.input, getargs.output, getargs.compression, getargs.level, False, 0, 0, getargs.checksum, getargs.skipchecksum, [], fnamelist, getargs.verbose, False);
|
|
153
|
+
|
|
154
|
+
elif should_extract:
|
|
155
|
+
if getargs.convert:
|
|
156
|
+
checkcompressfile = pycatfile.CheckCompressionSubType(getargs.input, fnamelist, True);
|
|
157
|
+
tempout = BytesIO();
|
|
158
|
+
if(checkcompressfile=="tarfile"):
|
|
159
|
+
pycatfile.PackArchiveFileFromTarFile(getargs.input, tempout, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
|
|
160
|
+
elif(checkcompressfile=="zipfile"):
|
|
161
|
+
pycatfile.PackArchiveFileFromZipFile(getargs.input, tempout, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
|
|
162
|
+
elif(checkcompressfile=="catfile"):
|
|
163
|
+
pycatfile.RePackArchiveFile(getargs.input, tempout, getargs.compression, getargs.level, False, 0, 0, getargs.checksum, getargs.skipchecksum, [], fnamelist, getargs.verbose, False);
|
|
164
|
+
elif(rarfile_support and checkcompressfile=="rarfile"):
|
|
165
|
+
pycatfile.PackArchiveFileFromRarFile(getargs.input, tempout, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
|
|
166
|
+
elif(py7zr_support and checkcompressfile=="7zipfile"):
|
|
167
|
+
pycatfile.PackArchiveFileFromSevenZipFile(getargs.input, tempout, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
|
|
168
|
+
else:
|
|
169
|
+
sys.exit(1);
|
|
170
|
+
getargs.input = tempout;
|
|
171
|
+
pycatfile.UnPackArchiveFile(getargs.input, getargs.output, False, 0, 0, getargs.skipchecksum, fnamelist, getargs.verbose, getargs.preserve, getargs.preserve, False);
|
|
172
|
+
|
|
173
|
+
elif should_list:
|
|
174
|
+
if getargs.convert:
|
|
175
|
+
checkcompressfile = pycatfile.CheckCompressionSubType(getargs.input, fnamelist, True);
|
|
176
|
+
if(checkcompressfile=="tarfile"):
|
|
177
|
+
pycatfile.TarFileListFiles(getargs.input, getargs.verbose, False);
|
|
178
|
+
elif(checkcompressfile=="zipfile"):
|
|
179
|
+
pycatfile.ZipFileListFiles(getargs.input, getargs.verbose, False);
|
|
180
|
+
elif(checkcompressfile=="catfile"):
|
|
181
|
+
pycatfile.ArchiveFileListFiles(getargs.input, 0, 0, getargs.skipchecksum, fnamelist, getargs.verbose, False);
|
|
182
|
+
elif(rarfile_support and checkcompressfile=="rarfile"):
|
|
183
|
+
pycatfile.RarFileListFiles(getargs.input, getargs.verbose, False);
|
|
184
|
+
elif(py7zr_support and checkcompressfile=="7zipfile"):
|
|
185
|
+
pycatfile.SevenZipFileListFiles(getargs.input, getargs.verbose, False);
|
|
186
|
+
else:
|
|
187
|
+
sys.exit(1);
|
|
188
|
+
else:
|
|
189
|
+
pycatfile.ArchiveFileListFiles(getargs.input, 0, 0, getargs.skipchecksum, fnamelist, getargs.verbose, False);
|
|
190
|
+
|
|
191
|
+
elif should_validate:
|
|
192
|
+
if getargs.convert:
|
|
193
|
+
checkcompressfile = pycatfile.CheckCompressionSubType(getargs.input, fnamelist, True);
|
|
194
|
+
tempout = BytesIO();
|
|
195
|
+
if(checkcompressfile=="tarfile"):
|
|
196
|
+
pycatfile.PackArchiveFileFromTarFile(getargs.input, tempout, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
|
|
197
|
+
elif(checkcompressfile=="zipfile"):
|
|
198
|
+
pycatfile.PackArchiveFileFromZipFile(getargs.input, tempout, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
|
|
199
|
+
elif(checkcompressfile=="catfile"):
|
|
200
|
+
pycatfile.RePackArchiveFile(getargs.input, tempout, getargs.compression, getargs.level, False, 0, 0, getargs.checksum, getargs.skipchecksum, [], fnamelist, getargs.verbose, False);
|
|
201
|
+
elif(rarfile_support and checkcompressfile=="rarfile"):
|
|
202
|
+
pycatfile.PackArchiveFileFromRarFile(getargs.input, tempout, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
|
|
203
|
+
elif(py7zr_support and checkcompressfile=="7zipfile"):
|
|
204
|
+
pycatfile.PackArchiveFileFromSevenZipFile(getargs.input, tempout, getargs.compression, getargs.level, getargs.checksum, [], fnamelist, getargs.verbose, False);
|
|
205
|
+
else:
|
|
206
|
+
sys.exit(1);
|
|
207
|
+
getargs.input = tempout;
|
|
208
|
+
fvalid = pycatfile.ArchiveFileValidate(getargs.input, fnamelist, getargs.verbose, False);
|
|
209
|
+
if(not getargs.verbose):
|
|
210
|
+
import sys, logging;
|
|
211
|
+
logging.basicConfig(format="%(message)s", stream=sys.stdout, level=logging.DEBUG);
|
|
212
|
+
if(fvalid):
|
|
213
|
+
pycatfile.VerbosePrintOut("File is valid: \n" + str(getargs.input));
|
|
214
|
+
else:
|
|
215
|
+
pycatfile.VerbosePrintOut("File is invalid: \n" + str(getargs.input));
|
|
@@ -0,0 +1,90 @@
|
|
|
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: 4/26/2024 Ver. 0.8.6 RC 1 - Author: cooldude2k $
|
|
18
|
+
'''
|
|
19
|
+
|
|
20
|
+
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
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
|
+
|
|
33
|
+
# Set up the argument parser
|
|
34
|
+
argparser = argparse.ArgumentParser(description="Manipulates concatenated files for various operations like creation, extraction, and validation.")
|
|
35
|
+
argparser.add_argument("-V", "--version", action="version", version="{0} {1}".format(pycatfile.__program_name__, pycatfile.__version__), help="Displays the program's version.")
|
|
36
|
+
argparser.add_argument("-i", "--input", required=True, help="Specifies input file(s) for processing.")
|
|
37
|
+
argparser.add_argument("-o", "--output", help="Specifies the output file name.")
|
|
38
|
+
argparser.add_argument("-d", "--verbose", action="store_true", help="Enables verbose mode for detailed information.")
|
|
39
|
+
argparser.add_argument("-c", "--create", action="store_true", help="Creates a new concatenated file from input.")
|
|
40
|
+
argparser.add_argument("-e", "--extract", action="store_true", help="Extracts files from a concatenated archive.")
|
|
41
|
+
argparser.add_argument("-l", "--list", action="store_true", help="Lists contents of a specified concatenated file.")
|
|
42
|
+
argparser.add_argument("-r", "--repack", action="store_true", help="Repacks an existing concatenated file.")
|
|
43
|
+
argparser.add_argument("-v", "--validate", action="store_true", help="Validates a concatenated file's integrity.")
|
|
44
|
+
argparser.add_argument("--checksum", default="crc32", help="Specifies the checksum type (default: crc32).")
|
|
45
|
+
argparser.add_argument("--compression", default="auto", help="Specifies the compression method (default: auto).")
|
|
46
|
+
argparser.add_argument("--level", help="Specifies the compression level.")
|
|
47
|
+
argparser.add_argument("--preserve", action="store_true", help="Preserves file attributes when extracting.")
|
|
48
|
+
argparser.add_argument("--convert", choices=['tar', 'zip', 'rar'], help="Convert from an archive format (tar, zip, rar) to a concatenated file.")
|
|
49
|
+
args = argparser.parse_args()
|
|
50
|
+
|
|
51
|
+
# Determine the primary action based on user input
|
|
52
|
+
primary_action = None
|
|
53
|
+
if args.create:
|
|
54
|
+
primary_action = 'create'
|
|
55
|
+
elif args.repack:
|
|
56
|
+
primary_action = 'repack'
|
|
57
|
+
elif args.extract:
|
|
58
|
+
primary_action = 'extract'
|
|
59
|
+
elif args.list:
|
|
60
|
+
primary_action = 'list'
|
|
61
|
+
elif args.validate:
|
|
62
|
+
primary_action = 'validate'
|
|
63
|
+
|
|
64
|
+
# Functionality mappings
|
|
65
|
+
if primary_action == 'create':
|
|
66
|
+
if args.convert == 'tar':
|
|
67
|
+
pycatfile.PackArchiveFileFromTarFile(args.input, args.output, args.compression, args.level, args.checksum, [], pycatfile.__file_format_list__, args.verbose, False)
|
|
68
|
+
elif args.convert == 'zip':
|
|
69
|
+
pycatfile.PackArchiveFileFromZipFile(args.input, args.output, args.compression, args.level, args.checksum, [], pycatfile.__file_format_list__, args.verbose, False)
|
|
70
|
+
elif rarfile_support and args.convert == 'rar':
|
|
71
|
+
pycatfile.PackArchiveFileFromRarFile(args.input, args.output, args.compression, args.level, args.checksum, [], pycatfile.__file_format_list__, args.verbose, False)
|
|
72
|
+
else:
|
|
73
|
+
pycatfile.PackArchiveFile(args.input, args.output, args.verbose, args.compression, args.level, False, args.checksum, [], pycatfile.__file_format_list__, args.verbose, False)
|
|
74
|
+
elif primary_action == 'repack':
|
|
75
|
+
pycatfile.RePackArchiveFile(args.input, args.output, args.compression, args.level, args.checksum, args.verbose)
|
|
76
|
+
elif primary_action == 'extract':
|
|
77
|
+
pycatfile.UnPackArchiveFile(args.input, args.output, args.verbose, args.preserve)
|
|
78
|
+
elif primary_action == 'list':
|
|
79
|
+
if args.convert == 'tar':
|
|
80
|
+
pycatfile.TarFileListFiles(args.input, args.verbose, False)
|
|
81
|
+
elif args.convert == 'zip':
|
|
82
|
+
pycatfile.ZipFileListFiles(args.input, args.verbose, False)
|
|
83
|
+
elif rarfile_support and args.convert == 'rar':
|
|
84
|
+
pycatfile.RarFileListFiles(args.input, args.verbose, False)
|
|
85
|
+
else:
|
|
86
|
+
pycatfile.ArchiveFileListFiles(args.input, args.verbose)
|
|
87
|
+
elif primary_action == 'validate':
|
|
88
|
+
is_valid = pycatfile.ArchiveFileValidate(args.input, args.verbose)
|
|
89
|
+
result_msg = "Validation result for {0}: {1}".format(args.input, 'Valid' if is_valid else 'Invalid')
|
|
90
|
+
print(result_msg)
|