PyCatFile 0.16.4__tar.gz → 0.17.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: PyCatFile
3
- Version: 0.16.4
3
+ Version: 0.17.2
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.2
2
2
  Name: PyCatFile
3
- Version: 0.16.4
3
+ Version: 0.17.2
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
@@ -14,7 +14,7 @@
14
14
  Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
15
15
  Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
16
16
 
17
- $FileInfo: catfile.py - Last Update: 1/15/2025 Ver. 0.16.4 RC 1 - Author: cooldude2k $
17
+ $FileInfo: catfile.py - Last Update: 1/24/2025 Ver. 0.17.2 RC 1 - Author: cooldude2k $
18
18
  '''
19
19
 
20
20
  from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
@@ -78,7 +78,9 @@ __file_format_magic__ = pycatfile.__file_format_magic__
78
78
  __file_format_len__ = pycatfile.__file_format_len__
79
79
  __file_format_hex__ = pycatfile.__file_format_hex__
80
80
  __file_format_delimiter__ = pycatfile.__file_format_delimiter__
81
- __file_format_list__ = pycatfile.__file_format_list__
81
+ __file_format_dict__ = pycatfile.__file_format_dict__
82
+ __file_format_default__ = pycatfile.__file_format_default__
83
+ __file_format_multi_dict__ = pycatfile.__file_format_multi_dict__
82
84
  __use_new_style__ = pycatfile.__use_new_style__
83
85
  __use_advanced_list__ = pycatfile.__use_advanced_list__
84
86
  __use_alt_inode__ = pycatfile.__use_alt_inode__
@@ -112,11 +114,11 @@ argparser.add_argument("-r", "--repack", action="store_true",
112
114
  help="Re-concatenate files, fixing checksum errors if any.")
113
115
  # File manipulation options
114
116
  argparser.add_argument(
115
- "-F", "--format", default=__file_format_list__[0], help="Specify the format to use.")
117
+ "-F", "--format", default="auto", help="Specify the format to use.")
116
118
  argparser.add_argument(
117
- "-D", "--delimiter", default=__file_format_list__[5], help="Specify the delimiter to use.")
119
+ "-D", "--delimiter", default=__file_format_dict__['format_delimiter'], help="Specify the delimiter to use.")
118
120
  argparser.add_argument(
119
- "-m", "--formatver", default=__file_format_list__[6], help="Specify the format version.")
121
+ "-m", "--formatver", default=__file_format_dict__['format_ver'], help="Specify the format version.")
120
122
  argparser.add_argument("-l", "--list", action="store_true",
121
123
  help="List files included in the concatenated file.")
122
124
  # Compression options
@@ -146,21 +148,19 @@ getargs = argparser.parse_args()
146
148
 
147
149
  fname = getargs.format
148
150
  fnamelower = fname.lower()
149
- if(getargs.format==__file_format_list__[0]):
150
- fnamemagic = __file_format_magic__
151
- fnamelen = __file_format_len__
152
- fnamehex = __file_format_hex__
151
+ if(getargs.format=="auto"):
152
+ fnamedict = __file_format_multi_dict__
153
+ __file_format_default__ = getargs.format
153
154
  else:
154
155
  fnamemagic = fname
155
156
  fnamelen = len(fname)
156
157
  fnamehex = binascii.hexlify(fname.encode("UTF-8")).decode("UTF-8")
157
- fnamesty = __use_new_style__
158
- fnamelst = __use_advanced_list__
159
- fnameino = __use_alt_inode__
160
- fnamelist = [fname, fnamemagic, fnamelower, fnamelen, fnamehex,
161
- getargs.delimiter, getargs.formatver, fnamesty, fnamelst, fnameino]
162
- fnamedict = {'format_name': fname, 'format_magic': fnamemagic, 'format_lower': fnamelower, 'format_len': fnamelen, 'format_hex': fnamehex,
163
- 'format_delimiter': getargs.delimiter, 'format_ver': getargs.formatver, 'new_style': fnamesty, 'use_advanced_list': fnamelst, 'use_alt_inode': fnameino}
158
+ __file_format_default__ = fnamemagic
159
+ fnamesty = __use_new_style__
160
+ fnamelst = __use_advanced_list__
161
+ fnameino = __use_alt_inode__
162
+ fnamedict = {'format_name': fname, 'format_magic': fnamemagic, 'format_lower': fnamelower, 'format_len': fnamelen, 'format_hex': fnamehex,
163
+ 'format_delimiter': getargs.delimiter, 'format_ver': getargs.formatver, 'new_style': fnamesty, 'use_advanced_list': fnamelst, 'use_alt_inode': fnameino}
164
164
 
165
165
  # Determine the primary action based on user input
166
166
  actions = ['create', 'extract', 'list', 'repack', 'validate']
@@ -174,27 +174,24 @@ if active_action:
174
174
  if getargs.convert:
175
175
  checkcompressfile = pycatfile.CheckCompressionSubType(
176
176
  input_file, fnamedict, True)
177
- if(checkcompressfile == "catfile"):
178
- tmpout = pycatfile.RePackArchiveFile(input_file, getargs.output, getargs.compression, getargs.wholefile,
179
- getargs.level, pycatfile.compressionlistalt, False, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], fnamedict, getargs.verbose, False)
177
+ if((IsNestedDict(fnamedict) and compresscheck in fnamedict) or (IsSingleDict(fnamedict) and compresscheck==fnamedict['format_magic'])):
178
+ tmpout = pycatfile.RePackArchiveFile(input_file, getargs.output, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, False, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], fnamedict, getargs.verbose, False)
180
179
  else:
181
180
  tmpout = pycatfile.PackArchiveFileFromInFile(
182
- input_file, getargs.output, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum], [], fnamedict, getargs.verbose, False)
181
+ input_file, getargs.output, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum], [], fnamedict, getargs.verbose, False)
183
182
  if(not tmpout):
184
183
  sys.exit(1)
185
184
  else:
186
- pycatfile.PackArchiveFile(getargs.input, getargs.output, getargs.text, getargs.compression,
187
- getargs.wholefile, getargs.level, pycatfile.compressionlistalt, False, [getargs.checksum, getargs.checksum, getargs.checksum], [], fnamedict, getargs.verbose, False)
185
+ pycatfile.PackArchiveFile(getargs.input, getargs.output, getargs.text, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, False, [getargs.checksum, getargs.checksum, getargs.checksum], [], fnamedict, getargs.verbose, False)
188
186
  elif active_action == 'repack':
189
187
  if getargs.convert:
190
188
  checkcompressfile = pycatfile.CheckCompressionSubType(
191
189
  input_file, fnamedict, True)
192
- if(checkcompressfile == "catfile"):
190
+ if((IsNestedDict(fnamedict) and compresscheck in fnamedict) or (IsSingleDict(fnamedict) and compresscheck==fnamedict['format_magic'])):
193
191
  pycatfile.RePackArchiveFile(input_file, getargs.output, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt,
194
192
  False, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], fnamedict, getargs.verbose, False)
195
193
  else:
196
- pycatfile.PackArchiveFileFromInFile(input_file, getargs.output, getargs.compression,
197
- getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum], [], fnamedict, getargs.verbose, False)
194
+ pycatfile.PackArchiveFileFromInFile(input_file, getargs.output, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum], [], fnamedict, getargs.verbose, False)
198
195
  if(not tmpout):
199
196
  sys.exit(1)
200
197
  else:
@@ -205,12 +202,11 @@ if active_action:
205
202
  checkcompressfile = pycatfile.CheckCompressionSubType(
206
203
  input_file, fnamedict, True)
207
204
  tempout = BytesIO()
208
- if(checkcompressfile == "catfile"):
209
- tmpout = pycatfile.RePackArchiveFile(input_file, tempout, getargs.compression, getargs.wholefile,
210
- getargs.level, pycatfile.compressionlistalt, False, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], fnamedict, False, False)
205
+ if((IsNestedDict(fnamedict) and compresscheck in fnamedict) or (IsSingleDict(fnamedict) and compresscheck==fnamedict['format_magic'])):
206
+ tmpout = pycatfile.RePackArchiveFile(input_file, tempout, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, False, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], fnamedict, False, False)
211
207
  else:
212
208
  tmpout = pycatfile.PackArchiveFileFromInFile(
213
- input_file, tempout, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum], [], fnamedict, False, False)
209
+ input_file, tempout, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum], [], fnamedict, False, False)
214
210
  if(not tmpout):
215
211
  sys.exit(1)
216
212
  input_file = tempout
@@ -220,33 +216,29 @@ if active_action:
220
216
  if getargs.convert:
221
217
  checkcompressfile = pycatfile.CheckCompressionSubType(
222
218
  input_file, fnamedict, True)
223
- if(checkcompressfile == "catfile"):
224
- tmpout = pycatfile.ArchiveFileListFiles(
225
- input_file, 0, 0, getargs.skipchecksum, fnamedict, getargs.verbose, False)
219
+ if((IsNestedDict(fnamedict) and compresscheck in fnamedict) or (IsSingleDict(fnamedict) and compresscheck==fnamedict['format_magic'])):
220
+ tmpout = pycatfile.ArchiveFileListFiles(input_file, "auto", 0, 0, getargs.skipchecksum, fnamedict, getargs.verbose, False)
226
221
  else:
227
- tmpout = pycatfile.InFileListFiles(
228
- input_file, getargs.verbose, fnamedict, False)
222
+ tmpout = pycatfile.InFileListFiles(input_file, getargs.verbose, fnamedict, False)
229
223
  if(not tmpout):
230
224
  sys.exit(1)
231
225
  else:
232
- pycatfile.ArchiveFileListFiles(
233
- input_file, 0, 0, getargs.skipchecksum, fnamedict, getargs.verbose, False)
226
+ pycatfile.ArchiveFileListFiles(input_file, "auto", 0, 0, getargs.skipchecksum, fnamedict, getargs.verbose, False)
234
227
  elif active_action == 'validate':
235
228
  if getargs.convert:
236
229
  checkcompressfile = pycatfile.CheckCompressionSubType(
237
230
  input_file, fnamedict, True)
238
231
  tempout = BytesIO()
239
- if(checkcompressfile == "catfile"):
240
- tmpout = pycatfile.RePackArchiveFile(input_file, tempout, getargs.compression, getargs.wholefile,
241
- getargs.level, pycatfile.compressionlistalt, False, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], fnamedict, False, False)
232
+ if((IsNestedDict(fnamedict) and compresscheck in fnamedict) or (IsSingleDict(fnamedict) and compresscheck==fnamedict['format_magic'])):
233
+ tmpout = pycatfile.RePackArchiveFile(input_file, tempout, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, False, 0, 0, [getargs.checksum, getargs.checksum, getargs.checksum], getargs.skipchecksum, [], fnamedict, False, False)
242
234
  else:
243
235
  tmpout = pycatfile.PackArchiveFileFromInFile(
244
- input_file, tempout, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum], [], fnamedict, False, False)
236
+ input_file, tempout, __file_format_default__, getargs.compression, getargs.wholefile, getargs.level, pycatfile.compressionlistalt, [getargs.checksum, getargs.checksum, getargs.checksum], [], fnamedict, False, False)
245
237
  input_file = tempout
246
238
  if(not tmpout):
247
239
  sys.exit(1)
248
240
  fvalid = pycatfile.ArchiveFileValidate(
249
- input_file, fnamedict, getargs.verbose, False)
241
+ input_file, "auto", fnamedict, getargs.verbose, False)
250
242
  if(not getargs.verbose):
251
243
  import sys
252
244
  import logging
@@ -255,5 +247,4 @@ if active_action:
255
247
  if(fvalid):
256
248
  pycatfile.VerbosePrintOut("File is valid: \n" + str(input_file))
257
249
  else:
258
- pycatfile.VerbosePrintOut(
259
- "File is invalid: \n" + str(input_file))
250
+ pycatfile.VerbosePrintOut("File is invalid: \n" + str(input_file))
@@ -14,7 +14,7 @@
14
14
  Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
15
15
  Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
16
16
 
17
- $FileInfo: neocatfile.py - Last Update: 1/15/2025 Ver. 0.16.4 RC 1 - Author: cooldude2k $
17
+ $FileInfo: neocatfile.py - Last Update: 1/24/2025 Ver. 0.17.2 RC 1 - Author: cooldude2k $
18
18
  '''
19
19
 
20
20
  from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
@@ -29,7 +29,8 @@ __file_format_magic__ = pycatfile.__file_format_magic__
29
29
  __file_format_len__ = pycatfile.__file_format_len__
30
30
  __file_format_hex__ = pycatfile.__file_format_hex__
31
31
  __file_format_delimiter__ = pycatfile.__file_format_delimiter__
32
- __file_format_list__ = pycatfile.__file_format_list__
32
+ __file_format_dict__ = pycatfile.__file_format_dict__
33
+ __file_format_default__ = pycatfile.__file_format_default__
33
34
  __use_new_style__ = pycatfile.__use_new_style__
34
35
  __use_advanced_list__ = pycatfile.__use_advanced_list__
35
36
  __use_alt_inode__ = pycatfile.__use_alt_inode__
@@ -99,19 +100,19 @@ input_file = args.input[0]
99
100
  if primary_action == 'create':
100
101
  if args.convert == 'tar':
101
102
  pycatfile.PackArchiveFileFromTarFile(input_file, args.output, args.compression, args.level, pycatfile.compressionlistalt, [args.checksum, args.checksum, args.checksum], [
102
- ], pycatfile.__file_format_list__, args.verbose, False)
103
+ ], pycatfile.__file_format_dict__, args.verbose, False)
103
104
  elif args.convert == 'zip':
104
105
  pycatfile.PackArchiveFileFromZipFile(input_file, args.output, args.compression, args.level, pycatfile.compressionlistalt, [args.checksum, args.checksum, args.checksum], [
105
- ], pycatfile.__file_format_list__, args.verbose, False)
106
+ ], pycatfile.__file_format_dict__, args.verbose, False)
106
107
  elif py7zr_support and args.convert == '7zip':
107
108
  pycatfile.PackArchiveFileFromSevenZipFile(input_file, args.output, args.compression, args.level, pycatfile.compressionlistalt, [args.checksum, args.checksum, args.checksum], [
108
- ], pycatfile.__file_format_list__, args.verbose, False)
109
+ ], pycatfile.__file_format_dict__, args.verbose, False)
109
110
  elif rarfile_support and args.convert == 'rar':
110
111
  pycatfile.PackArchiveFileFromRarFile(input_file, args.output, args.compression, args.level, pycatfile.compressionlistalt, [args.checksum, args.checksum, args.checksum], [
111
- ], pycatfile.__file_format_list__, args.verbose, False)
112
+ ], pycatfile.__file_format_dict__, args.verbose, False)
112
113
  else:
113
114
  pycatfile.PackArchiveFile(args.input, args.output, args.verbose, args.compression, args.level, pycatfile.compressionlistalt,
114
- False, [args.checksum, args.checksum, args.checksum], [], pycatfile.__file_format_list__, args.verbose, False)
115
+ False, [args.checksum, args.checksum, args.checksum], [], pycatfile.__file_format_dict__, args.verbose, False)
115
116
  elif primary_action == 'repack':
116
117
  pycatfile.RePackArchiveFile(
117
118
  input_file, args.output, args.compression, args.level, pycatfile.compressionlistalt, [args.checksum, args.checksum, args.checksum], args.verbose)
@@ -130,7 +131,7 @@ elif primary_action == 'list':
130
131
  else:
131
132
  pycatfile.ArchiveFileListFiles(input_file, verbose=args.verbose)
132
133
  elif primary_action == 'validate':
133
- is_valid = pycatfile.ArchiveFileValidate(input_file, args.verbose)
134
+ is_valid = pycatfile.ArchiveFileValidate(input_file, verbose=args.verbose)
134
135
  result_msg = "Validation result for {0}: {1}".format(
135
136
  input_file, 'Valid' if is_valid else 'Invalid')
136
137
  print(result_msg)