PyCatFile 0.28.8__tar.gz → 0.30.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyCatFile
3
- Version: 0.28.8
3
+ Version: 0.30.0
4
4
  Summary: A tar like file format name archivefile.
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.4
2
2
  Name: PyCatFile
3
- Version: 0.28.8
3
+ Version: 0.30.0
4
4
  Summary: A tar like file format name archivefile.
5
5
  Home-page: https://github.com/GameMaker2k/PyCatFile
6
6
  Download-URL: https://github.com/GameMaker2k/PyCatFile/archive/master.tar.gz
@@ -1,9 +1,5 @@
1
1
  LICENSE
2
2
  README.md
3
- catfile.py
4
- catfile_py3.py
5
- pycatfile.py
6
- pycatfile_py3.py
7
3
  pyproject.toml
8
4
  setup.cfg
9
5
  setup.py
@@ -0,0 +1 @@
1
+ pycatfile
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "PyCatFile"
3
- version = "0.28.8"
3
+ version = "0.30.0"
4
4
  readme = "README.md"
5
5
  license = { text = "BSD-3-Clause" }
6
6
  keywords = []
@@ -22,7 +22,7 @@ import sys
22
22
  from setuptools import setup
23
23
 
24
24
  # Open and read the version info file in a Python 2/3 compatible way
25
- verinfofilename = os.path.realpath("."+os.path.sep+os.path.sep+"pycatfile.py")
25
+ verinfofilename = os.path.realpath("."+os.path.sep+"pycatfile"+os.path.sep+"pycatfile.py")
26
26
 
27
27
  # Use `with` to ensure the file is properly closed after reading
28
28
  # In Python 2, open defaults to text mode; in Python 3, it’s better to specify encoding
@@ -79,12 +79,8 @@ pymodule[
79
79
  'longdescription'] = 'A tar like file format name catfile after unix cat command (concatenate files) .'
80
80
  pymodule['platforms'] = 'OS Independent'
81
81
  pymodule['zipsafe'] = True
82
- if(PY2):
83
- pymodule['pymodules'] = ['pycatfile']
84
- pymodule['scripts'] = ['catfile.py']
85
- else:
86
- pymodule['pymodules'] = ['pycatfile', 'pycatfile_py3']
87
- pymodule['scripts'] = ['catfile.py', 'catfile_py3.py']
82
+ pymodule['pymodules'] = ['pycatfile']
83
+ pymodule['scripts'] = []
88
84
  pymodule['classifiers'] = [
89
85
  'Development Status :: 5 - Production/Stable',
90
86
  'Intended Audience :: Developers',
@@ -1,2 +0,0 @@
1
- pycatfile
2
- pycatfile_py3
@@ -1,242 +0,0 @@
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-2026 Cool Dude 2k - http://idb.berlios.de/
14
- Copyright 2018-2026 Game Maker 2k - http://intdb.sourceforge.net/
15
- Copyright 2018-2026 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
16
-
17
- $FileInfo: catfile.py - Last Update: 2/8/2026 Ver. 0.28.8 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 logging
24
- import argparse
25
- import pycatfile
26
- import binascii
27
-
28
- # Text streams (as provided by Python)
29
- PY_STDIN_TEXT = sys.stdin
30
- PY_STDOUT_TEXT = sys.stdout
31
- PY_STDERR_TEXT = sys.stderr
32
-
33
- # Binary-friendly streams (use .buffer on Py3, fall back on Py2)
34
- PY_STDIN_BUF = getattr(sys.stdin, "buffer", sys.stdin)
35
- PY_STDOUT_BUF = getattr(sys.stdout, "buffer", sys.stdout)
36
- PY_STDERR_BUF = getattr(sys.stderr, "buffer", sys.stderr)
37
- logging.basicConfig(format="%(message)s", stream=PY_STDOUT_TEXT, level=logging.DEBUG)
38
-
39
- # Conditional import and signal handling for Unix-like systems
40
- if os.name != 'nt': # Not Windows
41
- import signal
42
- if hasattr(signal, 'SIGPIPE'):
43
- def handler(signum, frame):
44
- pycatfile.VerbosePrintOut(
45
- "Received SIGPIPE, exiting gracefully.", "info")
46
- sys.exit(0)
47
- signal.signal(signal.SIGPIPE, handler)
48
-
49
- rarfile_support = pycatfile.rarfile_support
50
- py7zr_support = pycatfile.py7zr_support
51
-
52
- if(sys.version[0] == "2"):
53
- try:
54
- from io import StringIO, BytesIO
55
- except ImportError:
56
- try:
57
- from cStringIO import StringIO
58
- from cStringIO import StringIO as BytesIO
59
- except ImportError:
60
- from StringIO import StringIO
61
- from StringIO import StringIO as BytesIO
62
- elif(sys.version[0] >= "3"):
63
- from io import StringIO, BytesIO
64
- else:
65
- teststringio = 0
66
- if(teststringio <= 0):
67
- try:
68
- from cStringIO import StringIO as BytesIO
69
- teststringio = 1
70
- except ImportError:
71
- teststringio = 0
72
- if(teststringio <= 0):
73
- try:
74
- from StringIO import StringIO as BytesIO
75
- teststringio = 2
76
- except ImportError:
77
- teststringio = 0
78
- if(teststringio <= 0):
79
- try:
80
- from io import BytesIO
81
- teststringio = 3
82
- except ImportError:
83
- teststringio = 0
84
-
85
- __project__ = pycatfile.__project__
86
- __program_name__ = pycatfile.__program_name__
87
- __file_format_name__ = pycatfile.__file_format_name__
88
- __file_format_magic__ = pycatfile.__file_format_magic__
89
- __file_format_len__ = pycatfile.__file_format_len__
90
- __file_format_hex__ = pycatfile.__file_format_hex__
91
- __file_format_delimiter__ = pycatfile.__file_format_delimiter__
92
- __file_format_dict__ = pycatfile.__file_format_dict__
93
- __file_format_default__ = pycatfile.__file_format_default__
94
- __file_format_multi_dict__ = pycatfile.__file_format_multi_dict__
95
- __use_new_style__ = pycatfile.__use_new_style__
96
- __use_advanced_list__ = pycatfile.__use_advanced_list__
97
- __use_alt_inode__ = pycatfile.__use_alt_inode__
98
- __project_url__ = pycatfile.__project_url__
99
- __version_info__ = pycatfile.__version_info__
100
- __version_date_info__ = pycatfile.__version_date_info__
101
- __version_date__ = pycatfile.__version_date__
102
- __version_date_plusrc__ = pycatfile.__version_date_plusrc__
103
- __version__ = pycatfile.__version__
104
-
105
- # Initialize the argument parser
106
- argparser = argparse.ArgumentParser(description="Manipulate archive files.", conflict_handler="resolve", add_help=True)
107
-
108
- # Version information
109
- argparser.add_argument("-V", "--version", action="version", version=__program_name__ + " " + __version__)
110
- # Input and output specifications
111
- argparser.add_argument("-i", "--input", nargs="+", help="Specify the file(s) to concatenate or the archive file to extract.", required=True)
112
- argparser.add_argument("-o", "--output", default=None, help="Specify the name for the extracted or output archive files.")
113
- # Operations
114
- argparser.add_argument("-c", "--create", action="store_true", help="Perform only the concatenation operation.")
115
- argparser.add_argument("-e", "--extract", action="store_true", help="Perform only the extraction operation.")
116
- argparser.add_argument("-t", "--convert", action="store_true", help="Convert a tar/zip/rar/7zip file to a archive file.")
117
- argparser.add_argument("-r", "--repack", action="store_true", help="Re-concatenate files, fixing checksum errors if any.")
118
- argparser.add_argument("-S", "--filestart", type=int, default=0, help="Start reading file at.")
119
- # File manipulation options
120
- argparser.add_argument("-F", "--format", default="auto", help="Specify the format to use.")
121
- argparser.add_argument("-D", "--delimiter", default=__file_format_dict__['format_delimiter'], help="Specify the delimiter to use.")
122
- argparser.add_argument("-m", "--formatver", default=__file_format_dict__['format_ver'], help="Specify the format version.")
123
- argparser.add_argument("-l", "--list", action="store_true", help="List files included in the archive file.")
124
- # Compression options
125
- argparser.add_argument("-P", "--compression", default="auto", help="Specify the compression method to use for concatenation.")
126
- argparser.add_argument("-L", "--level", default=None, help="Specify the compression level for concatenation.")
127
- argparser.add_argument("-W", "--wholefile", action="store_true", help="Whole file compression method to use for concatenation.")
128
- # Checksum and validation
129
- argparser.add_argument("-v", "--validate", action="store_true", help="Validate archive file checksums.")
130
- argparser.add_argument("-C", "--checksum", default="md5", help="Specify the type of checksum to use. The default is crc32.")
131
- argparser.add_argument("-s", "--skipchecksum", action="store_true", help="Skip the checksum check of files.")
132
- argparser.add_argument("-k", "--insecretkey", default=None, help="Secretkey to use for checksum input.")
133
- argparser.add_argument("-K", "--outsecretkey", default=None, help="Secretkey to use for checksum output.")
134
- # Permissions and metadata
135
- argparser.add_argument("-p", "--preserve", action="store_false", help="Do not preserve permissions and timestamps of files.")
136
- # Miscellaneous
137
- argparser.add_argument("-d", "--verbose", action="store_true", help="Enable verbose mode to display various debugging information.")
138
- argparser.add_argument("-T", "--text", action="store_true", help="Read file locations from a text file.")
139
- # Parse the arguments
140
- getargs = argparser.parse_args()
141
-
142
- fname = getargs.format
143
- if(getargs.format=="auto"):
144
- fnamedict = __file_format_multi_dict__
145
- __file_format_default__ = getargs.format
146
- else:
147
- fnamemagic = fname
148
- fnamelen = len(fname)
149
- fnamehex = binascii.hexlify(fname.encode("UTF-8")).decode("UTF-8")
150
- __file_format_default__ = fnamemagic
151
- fnamesty = __use_new_style__
152
- fnamelst = __use_advanced_list__
153
- fnameino = __use_alt_inode__
154
- fnamedict = {'format_name': fname, 'format_magic': fnamemagic, 'format_len': fnamelen, 'format_hex': fnamehex,
155
- 'format_delimiter': getargs.delimiter, 'format_ver': getargs.formatver, 'new_style': fnamesty, 'use_advanced_list': fnamelst, 'use_alt_inode': fnameino}
156
-
157
- # Determine the primary action based on user input
158
- actions = ['create', 'extract', 'list', 'repack', 'validate']
159
- active_action = next(
160
- (action for action in actions if getattr(getargs, action)), None)
161
- input_file = getargs.input[0]
162
-
163
- # Execute the appropriate functions based on determined actions and arguments
164
- if active_action:
165
- if active_action == 'create':
166
- if getargs.convert:
167
- checkcompressfile = pycatfile.CheckCompressionSubType(
168
- input_file, fnamedict, 0, True)
169
- if((pycatfile.IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (pycatfile.IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
170
- tmpout = pycatfile.RePackCatFile(input_file, getargs.output, "auto", getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, False, getargs.filestart, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.insecretkey, getargs.outsecretkey, False, getargs.verbose, False)
171
- else:
172
- tmpout = pycatfile.PackCatFileFromInFile(
173
- input_file, getargs.output, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.outsecretkey, getargs.verbose, False)
174
- if(not tmpout):
175
- sys.exit(1)
176
- else:
177
- pycatfile.PackCatFile(getargs.input, getargs.output, getargs.text, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, False, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.outsecretkey, getargs.verbose, False)
178
- elif active_action == 'repack':
179
- if getargs.convert:
180
- checkcompressfile = pycatfile.CheckCompressionSubType(
181
- input_file, fnamedict, 0, True)
182
- if((pycatfile.IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (pycatfile.IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
183
- pycatfile.RePackCatFile(input_file, getargs.output, "auto", getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt,
184
- False, getargs.filestart, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.insecretkey, getargs.outsecretkey, False, getargs.verbose, False)
185
- else:
186
- pycatfile.PackCatFileFromInFile(input_file, getargs.output, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.outsecretkey, getargs.verbose, False)
187
- if(not tmpout):
188
- sys.exit(1)
189
- else:
190
- pycatfile.RePackCatFile(input_file, getargs.output, "auto", getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt,
191
- False, getargs.filestart, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.insecretkey, getargs.outsecretkey, False, getargs.verbose, False)
192
- elif active_action == 'extract':
193
- if getargs.convert:
194
- checkcompressfile = pycatfile.CheckCompressionSubType(
195
- input_file, fnamedict, 0, True)
196
- tempout = BytesIO()
197
- if((pycatfile.IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (pycatfile.IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
198
- tmpout = pycatfile.RePackCatFile(input_file, tempout, "auto", getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, False, getargs.filestart, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.insecretkey, getargs.outsecretkey, False, False)
199
- else:
200
- tmpout = pycatfile.PackCatFileFromInFile(
201
- input_file, tempout, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.outsecretkey, False, False)
202
- if(not tmpout):
203
- sys.exit(1)
204
- input_file = tempout
205
- pycatfile.UnPackCatFile(input_file, getargs.output, False, getargs.filestart, 0, 0, getargs.skipchecksum,
206
- fnamedict, getargs.insecretkey, getargs.preserve, getargs.preserve, False, getargs.verbose, False)
207
- elif active_action == 'list':
208
- if getargs.convert:
209
- checkcompressfile = pycatfile.CheckCompressionSubType(
210
- input_file, fnamedict, 0, True)
211
- if((pycatfile.IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (pycatfile.IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
212
- tmpout = pycatfile.CatFileListFiles(input_file, "auto", getargs.filestart, 0, 0, getargs.skipchecksum, fnamedict, getargs.insecretkey, False, getargs.verbose, False, False)
213
- else:
214
- tmpout = pycatfile.InFileListFiles(input_file, getargs.verbose, fnamedict, getargs.insecretkey, False, False, False)
215
- if(not tmpout):
216
- sys.exit(1)
217
- else:
218
- pycatfile.CatFileListFiles(input_file, "auto", getargs.filestart, 0, 0, getargs.skipchecksum, fnamedict, getargs.insecretkey, False, getargs.verbose, False, False)
219
- elif active_action == 'validate':
220
- if getargs.convert:
221
- checkcompressfile = pycatfile.CheckCompressionSubType(
222
- input_file, fnamedict, 0, True)
223
- tempout = BytesIO()
224
- if((pycatfile.IsNestedDict(fnamedict) and checkcompressfile in fnamedict) or (pycatfile.IsSingleDict(fnamedict) and checkcompressfile==fnamedict['format_magic'])):
225
- tmpout = pycatfile.RePackCatFile(input_file, tempout, "auto", getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, False, getargs.filestart, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], {}, fnamedict, getargs.insecretkey, getargs.outsecretkey, False, False, False)
226
- else:
227
- tmpout = pycatfile.PackCatFileFromInFile(
228
- input_file, tempout, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum, getargs.checksum], [], {}, fnamedict, getargs.outsecretkey, False, False)
229
- input_file = tempout
230
- if(not tmpout):
231
- sys.exit(1)
232
- fvalid = pycatfile.StackedCatFileValidate(
233
- input_file, "auto", getargs.filestart, fnamedict, getargs.insecretkey, False, getargs.verbose, False)
234
- if(not getargs.verbose):
235
- import sys
236
- import logging
237
- logging.basicConfig(format="%(message)s",
238
- stream=sys.stdout, level=logging.DEBUG)
239
- if(fvalid):
240
- pycatfile.VerbosePrintOut("File is valid: \n" + str(input_file))
241
- else:
242
- pycatfile.VerbosePrintOut("File is invalid: \n" + str(input_file))