PyCatFile 0.13.12__tar.gz → 0.13.14__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.1
2
2
  Name: PyCatFile
3
- Version: 0.13.12
3
+ Version: 0.13.14
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.13.12
3
+ Version: 0.13.14
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: 6/26/2024 Ver. 0.13.12 RC 1 - Author: cooldude2k $
17
+ $FileInfo: catfile.py - Last Update: 7/10/2024 Ver. 0.13.12 RC 1 - Author: cooldude2k $
18
18
  '''
19
19
 
20
20
  from __future__ import absolute_import, division, print_function, unicode_literals;
@@ -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: 6/26/2024 Ver. 0.13.12 RC 1 - Author: cooldude2k $
17
+ $FileInfo: neocatfile.py - Last Update: 7/10/2024 Ver. 0.13.12 RC 1 - Author: cooldude2k $
18
18
  '''
19
19
 
20
20
  from __future__ import absolute_import, division, print_function, unicode_literals
@@ -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: pycatfile.py - Last Update: 6/26/2024 Ver. 0.13.12 RC 1 - Author: cooldude2k $
17
+ $FileInfo: pycatfile.py - Last Update: 7/10/2024 Ver. 0.13.12 RC 1 - Author: cooldude2k $
18
18
  '''
19
19
 
20
20
  from __future__ import absolute_import, division, print_function, unicode_literals;
@@ -36,6 +36,11 @@ try:
36
36
  except ImportError:
37
37
  import json;
38
38
 
39
+ try:
40
+ import configparser;
41
+ except ImportError:
42
+ import ConfigParser as configparser;
43
+
39
44
  try:
40
45
  basestring;
41
46
  except NameError:
@@ -173,6 +178,8 @@ except ImportError:
173
178
 
174
179
  __use_pysftp__ = False;
175
180
  __use_alt_format__ = False;
181
+ __config_file__ = 'catfile.ini'
182
+ __use_ini_file__ = True;
176
183
  if(not havepysftp):
177
184
  __use_pysftp__ = False;
178
185
  __use_http_lib__ = "httpx";
@@ -182,43 +189,62 @@ if(__use_http_lib__=="requests" and havehttpx and not haverequests):
182
189
  __use_http_lib__ = "httpx";
183
190
  if((__use_http_lib__=="httpx" or __use_http_lib__=="requests") and not havehttpx and not haverequests):
184
191
  __use_http_lib__ = "urllib";
185
- if(not __use_alt_format__):
186
- ''' Format Info by Kazuki Przyborowski '''
187
- __file_format_name__ = "CatFile";
188
- __program_name__ = "Py"+__file_format_name__;
189
- __file_format_lower__ = __file_format_name__.lower();
190
- __file_format_magic__ = __file_format_name__;
191
- __file_format_len__ = len(__file_format_magic__);
192
- __file_format_hex__ = binascii.hexlify(__file_format_magic__.encode("UTF-8")).decode("UTF-8");
193
- __file_format_delimiter__ = "\x00";
194
- __file_format_ver__ = "001";
195
- __use_new_style__ = True;
196
- __use_advanced_list__ = True;
197
- __use_alt_inode__ = False;
198
- __file_format_extension__ = ".cat";
192
+ if os.path.exists(__config_file__) and __use_ini_file__:
193
+ # Create a ConfigParser object
194
+ config = configparser.ConfigParser();
195
+ # Read the configuration file
196
+ config.read(__config_file__);
197
+ # Accessing values from the config file
198
+ __file_format_name__ = config['main']['name'];
199
+ __program_name__ = config['main']['proname'];
200
+ __file_format_lower__ = config['main']['lower'];
201
+ __file_format_magic__ = config['main']['magic'];
202
+ __file_format_len__ = int(config['main']['len']);
203
+ __file_format_hex__ = config['main']['hex'];
204
+ __file_format_delimiter__ = config['main']['delimiter'];
205
+ __file_format_ver__ = config['main']['ver'];
206
+ __use_new_style__ = config.getboolean('main', 'newstyle');
207
+ __use_advanced_list__ = config.getboolean('main', 'advancedlist');
208
+ __use_alt_inode__ = config.getboolean('main', 'altinode');
209
+ __file_format_extension__ = config['main']['extension'];
199
210
  else:
200
- ''' Format Info Generated by ChatGPT '''
201
- __file_format_name__ = "FastArchive";
202
- __program_name__ = "Py" + __file_format_name__;
203
- __file_format_lower__ = __file_format_name__.lower();
204
- __file_format_magic__ = "FstArch";
205
- __file_format_len__ = len(__file_format_magic__);
206
- __file_format_hex__ = binascii.hexlify(__file_format_magic__.encode("UTF-8")).decode("UTF-8");
207
- __file_format_delimiter__ = "\x1F"; # Using a non-printable ASCII character as delimiter
208
- __file_format_ver__ = "001";
209
- __use_new_style__ = True;
210
- __use_advanced_list__ = False;
211
- __use_alt_inode__ = False;
212
- __file_format_extension__ = ".fast";
211
+ if not __use_alt_format__:
212
+ # Format Info by Kazuki Przyborowski
213
+ __file_format_name__ = "CatFile";
214
+ __program_name__ = "Py" + __file_format_name__;
215
+ __file_format_lower__ = __file_format_name__.lower();
216
+ __file_format_magic__ = __file_format_name__;
217
+ __file_format_len__ = len(__file_format_magic__);
218
+ __file_format_hex__ = binascii.hexlify(__file_format_magic__.encode("UTF-8")).decode("UTF-8");
219
+ __file_format_delimiter__ = "\x00";
220
+ __file_format_ver__ = "001";
221
+ __use_new_style__ = True;
222
+ __use_advanced_list__ = True;
223
+ __use_alt_inode__ = False;
224
+ __file_format_extension__ = ".cat";
225
+ else:
226
+ # Format Info Generated by ChatGPT
227
+ __file_format_name__ = "FastArchive";
228
+ __program_name__ = "Py" + __file_format_name__;
229
+ __file_format_lower__ = __file_format_name__.lower();
230
+ __file_format_magic__ = "FstArch";
231
+ __file_format_len__ = len(__file_format_magic__);
232
+ __file_format_hex__ = binascii.hexlify(__file_format_magic__.encode("UTF-8")).decode("UTF-8");
233
+ __file_format_delimiter__ = "\x1F"; # Using a non-printable ASCII character as delimiter
234
+ __file_format_ver__ = "001";
235
+ __use_new_style__ = True;
236
+ __use_advanced_list__ = False;
237
+ __use_alt_inode__ = False;
238
+ __file_format_extension__ = ".fast";
213
239
  __file_format_list__ = [__file_format_name__, __file_format_magic__, __file_format_lower__, __file_format_len__, __file_format_hex__, __file_format_delimiter__, __file_format_ver__, __use_new_style__, __use_advanced_list__, __use_alt_inode__];
214
240
  __file_format_dict__ = {'format_name': __file_format_name__, 'format_magic': __file_format_magic__, 'format_lower': __file_format_lower__, 'format_len': __file_format_len__, 'format_hex': __file_format_hex__, 'format_delimiter': __file_format_delimiter__, 'format_ver': __file_format_ver__, 'new_style': __use_new_style__, 'use_advanced_list': __use_advanced_list__, 'use_alt_inode': __use_alt_inode__};
215
241
  __project__ = __program_name__;
216
242
  __project_url__ = "https://github.com/GameMaker2k/PyCatFile";
217
- __version_info__ = (0, 13, 12, "RC 1", 1);
218
- __version_date_info__ = (2024, 6, 26, "RC 1", 1);
243
+ __version_info__ = (0, 13, 14, "RC 1", 1);
244
+ __version_date_info__ = (2024, 7, 10, "RC 1", 1);
219
245
  __version_date__ = str(__version_date_info__[0]) + "." + str(__version_date_info__[1]).zfill(2) + "." + str(__version_date_info__[2]).zfill(2);
220
246
  __revision__ = __version_info__[3];
221
- __revision_id__ = "$Id: 08421f3d82901583005f4ce8695097e5ed1c2e11 $";
247
+ __revision_id__ = "$Id: 07817c123c2d804a582cf92b14210256929bb667 $";
222
248
  if(__version_info__[4] is not None):
223
249
  __version_date_plusrc__ = __version_date__ + "-" + str(__version_date_info__[4]);
224
250
  if(__version_info__[4] is None):
@@ -2652,6 +2678,50 @@ def PrintPermissionStringAlt(fchmode, ftype):
2652
2678
  permissionoutstr = permissionstr;
2653
2679
  return permissionoutstr;
2654
2680
 
2681
+ def GzipCompressData(data, compresslevel=9):
2682
+ try:
2683
+ # Try using modern gzip.compress if available
2684
+ compressed_data = gzip.compress(data, compresslevel=compresslevel);
2685
+ except AttributeError:
2686
+ # Fallback to older method for Python 2.x and older 3.x versions
2687
+ out = BytesIO();
2688
+ with gzip.GzipFile(fileobj=out, mode="wb", compresslevel=compresslevel) as f:
2689
+ f.write(data);
2690
+ compressed_data = out.getvalue();
2691
+ return compressed_data;
2692
+
2693
+ def GzipDecompressData(compressed_data):
2694
+ try:
2695
+ # Try using modern gzip.decompress if available
2696
+ decompressed_data = gzip.decompress(compressed_data);
2697
+ except AttributeError:
2698
+ # Fallback to older method for Python 2.x and older 3.x versions
2699
+ inp = BytesIO(compressed_data);
2700
+ with gzip.GzipFile(fileobj=inp, mode="rb") as f:
2701
+ decompressed_data = f.read();
2702
+ return decompressed_data;
2703
+
2704
+ def BzipCompressData(data, compresslevel=9):
2705
+ try:
2706
+ # Try using modern bz2.compress if available
2707
+ compressed_data = bz2.compress(data, compresslevel=compresslevel);
2708
+ except AttributeError:
2709
+ # Fallback to older method for Python 2.x and older 3.x versions
2710
+ compressor = bz2.BZ2Compressor(compresslevel);
2711
+ compressed_data = compressor.compress(data);
2712
+ compressed_data += compressor.flush();
2713
+ return compressed_data;
2714
+
2715
+ def BzipDecompressData(compressed_data):
2716
+ try:
2717
+ # Try using modern bz2.decompress if available
2718
+ decompressed_data = bz2.decompress(compressed_data);
2719
+ except AttributeError:
2720
+ # Fallback to older method for Python 2.x and older 3.x versions
2721
+ decompressor = bz2.BZ2Decompressor();
2722
+ decompressed_data = decompressor.decompress(compressed_data);
2723
+ return decompressed_data;
2724
+
2655
2725
  def CheckCompressionType(infile, formatspecs=__file_format_dict__, closefp=True):
2656
2726
  formatspecs = FormatSpecsListToDict(formatspecs);
2657
2727
  if(hasattr(infile, "read") or hasattr(infile, "write")):
@@ -2877,9 +2947,9 @@ def UncompressFile(infile, formatspecs=__file_format_dict__, mode="rb"):
2877
2947
  def UncompressString(infile):
2878
2948
  compresscheck = CheckCompressionTypeFromString(infile, formatspecs, False);
2879
2949
  if(compresscheck=="gzip" and compresscheck in compressionsupport):
2880
- fileuz = gzip.decompress(infile);
2950
+ fileuz = GzipDecompressData(infile);
2881
2951
  if(compresscheck=="bzip2" and compresscheck in compressionsupport):
2882
- fileuz = bz2.decompress(infile);
2952
+ fileuz = BzipDecompressData(infile);
2883
2953
  if(compresscheck=="zstd" and compresscheck in compressionsupport):
2884
2954
  try:
2885
2955
  import zstandard;
@@ -3031,14 +3101,14 @@ def CompressArchiveFile(fp, compression="auto", compressionlevel=None, formatspe
3031
3101
  compressionlevel = 9;
3032
3102
  else:
3033
3103
  compressionlevel = int(compressionlevel);
3034
- catfp.write(gzip.compress(fp.read(), compresslevel=compressionlevel));
3104
+ catfp.write(GzipCompressData(fp.read(), compresslevel=compressionlevel));
3035
3105
  if(compression=="bzip2" and compression in compressionsupport):
3036
3106
  catfp = BytesIO();
3037
3107
  if(compressionlevel is None):
3038
3108
  compressionlevel = 9;
3039
3109
  else:
3040
3110
  compressionlevel = int(compressionlevel);
3041
- catfp.write(bz2.compress(fp.read(), compresslevel=compressionlevel));
3111
+ catfp.write(BzipCompressData(fp.read(), compresslevel=compressionlevel));
3042
3112
  if(compression=="lz4" and compression in compressionsupport):
3043
3113
  catfp = BytesIO();
3044
3114
  if(compressionlevel is None):
@@ -3080,7 +3150,7 @@ def CompressArchiveFile(fp, compression="auto", compressionlevel=None, formatspe
3080
3150
  compressionlevel = 9;
3081
3151
  else:
3082
3152
  compressionlevel = int(compressionlevel);
3083
- catfp.write(zlib.compress(fp.read(), level=compressionlevel));
3153
+ catfp.write(zlib.compress(fp.read(), compressionlevel));
3084
3154
  if(compression=="auto" or compression is None):
3085
3155
  catfp = fp;
3086
3156
  catfp.seek(0, 0);
@@ -13,7 +13,7 @@
13
13
  Copyright 2016-2024 Game Maker 2k - http://intdb.sourceforge.net/
14
14
  Copyright 2016-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
15
15
 
16
- $FileInfo: setup.py - Last Update: 6/26/2024 Ver. 0.13.12 RC 1 - Author: cooldude2k $
16
+ $FileInfo: setup.py - Last Update: 7/10/2024 Ver. 0.13.12 RC 1 - Author: cooldude2k $
17
17
  '''
18
18
 
19
19
  import os, re, sys, pkg_resources;
File without changes
File without changes
File without changes