PyCatFile 0.13.6__tar.gz → 0.13.10__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.6
3
+ Version: 0.13.10
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.6
3
+ Version: 0.13.10
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/18/2024 Ver. 0.13.6 RC 1 - Author: cooldude2k $
17
+ $FileInfo: catfile.py - Last Update: 6/20/2024 Ver. 0.13.10 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/18/2024 Ver. 0.13.6 RC 1 - Author: cooldude2k $
17
+ $FileInfo: neocatfile.py - Last Update: 6/20/2024 Ver. 0.13.10 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/18/2024 Ver. 0.13.6 RC 1 - Author: cooldude2k $
17
+ $FileInfo: pycatfile.py - Last Update: 6/20/2024 Ver. 0.13.10 RC 1 - Author: cooldude2k $
18
18
  '''
19
19
 
20
20
  from __future__ import absolute_import, division, print_function, unicode_literals;
@@ -148,6 +148,7 @@ try:
148
148
  import httpx;
149
149
  havehttpx = True;
150
150
  logging.getLogger("httpx").setLevel(logging.WARNING);
151
+ logging.getLogger("httpcore").setLevel(logging.WARNING);
151
152
  except ImportError:
152
153
  pass;
153
154
 
@@ -213,11 +214,11 @@ __file_format_list__ = [__file_format_name__, __file_format_magic__, __file_form
213
214
  __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__};
214
215
  __project__ = __program_name__;
215
216
  __project_url__ = "https://github.com/GameMaker2k/PyCatFile";
216
- __version_info__ = (0, 13, 6, "RC 1", 1);
217
- __version_date_info__ = (2024, 6, 18, "RC 1", 1);
217
+ __version_info__ = (0, 13, 10, "RC 1", 1);
218
+ __version_date_info__ = (2024, 6, 20, "RC 1", 1);
218
219
  __version_date__ = str(__version_date_info__[0]) + "." + str(__version_date_info__[1]).zfill(2) + "." + str(__version_date_info__[2]).zfill(2);
219
220
  __revision__ = __version_info__[3];
220
- __revision_id__ = "$Id: e5caffc4692281eb011729629dd8fde86ce63098 $";
221
+ __revision_id__ = "$Id: 3d66f8fd117dbce383a71cad2e06f0e48f834871 $";
221
222
  if(__version_info__[4] is not None):
222
223
  __version_date_plusrc__ = __version_date__ + "-" + str(__version_date_info__[4]);
223
224
  if(__version_info__[4] is None):
@@ -2726,8 +2727,10 @@ def CheckCompressionType(infile, formatspecs=__file_format_dict__, closefp=True)
2726
2727
  filetype = "tarfile";
2727
2728
  elif(zipfile.is_zipfile(catfp)):
2728
2729
  filetype = "zipfile";
2729
- elif(rarfile.is_rarfile(catfp) or rarfile.is_rarfile_sfx(catfp)):
2730
+ elif(rarfile_support and (rarfile.is_rarfile(catfp) or rarfile.is_rarfile_sfx(catfp))):
2730
2731
  filetype = "rarile";
2732
+ elif(py7zr_support and py7zr.is_7zfile(catfp)):
2733
+ return "7zipfile";
2731
2734
  else:
2732
2735
  filetype = False;
2733
2736
  catfp.seek(0, 0);
@@ -2933,8 +2936,10 @@ def CheckCompressionSubType(infile, formatspecs=__file_format_dict__, closefp=Tr
2933
2936
  return "tarfile";
2934
2937
  elif(zipfile.is_zipfile(infile)):
2935
2938
  return "zipfile";
2936
- elif(rarfile.is_rarfile(infile) or rarfile.is_rarfile_sfx(infile)):
2939
+ elif(rarfile_support and (rarfile.is_rarfile(infile) or rarfile.is_rarfile_sfx(infile))):
2937
2940
  return "rarile";
2941
+ elif(py7zr_support and py7zr.is_7zfile(infile)):
2942
+ return "7zipfile";
2938
2943
  else:
2939
2944
  return False;
2940
2945
  return False;
@@ -3869,19 +3874,28 @@ def PackArchiveFileFromZipFile(infile, outfile, compression="auto", compresswhol
3869
3874
  ftypemod = stat.S_IFMT(int(stat.S_IFDIR + 511));
3870
3875
  elif(zipinfo.create_system==3):
3871
3876
  fwinattributes = format(int(0), 'x').lower();
3872
- fmode = format(int(zipinfo.external_attr), 'x').lower();
3873
- fchmode = stat.S_IMODE(int(zipinfo.external_attr));
3874
- ftypemod = stat.S_IFMT(int(zipinfo.external_attr));
3877
+ try:
3878
+ fmode = format(int(zipinfo.external_attr), 'x').lower();
3879
+ prefmode = int(zipinfo.external_attr);
3880
+ fchmode = stat.S_IMODE(prefmode);
3881
+ ftypemod = stat.S_IFMT(prefmode);
3882
+ except OverflowError:
3883
+ fmode = format(int(zipinfo.external_attr >> 16), 'x').lower();
3884
+ prefmode = int(zipinfo.external_attr >> 16);
3885
+ fchmode = stat.S_IMODE(prefmode);
3886
+ ftypemod = stat.S_IFMT(prefmode);
3875
3887
  else:
3876
3888
  fwinattributes = format(int(0), 'x').lower();
3877
3889
  if(not member.is_dir()):
3878
3890
  fmode = format(int(stat.S_IFREG + 438), 'x').lower();
3879
- fchmode = stat.S_IMODE(fmode);
3880
- ftypemod = stat.S_IFMT(fmode);
3891
+ prefmode = int(stat.S_IFREG + 438);
3892
+ fchmode = stat.S_IMODE(prefmode);
3893
+ ftypemod = stat.S_IFMT(prefmode);
3881
3894
  elif(member.is_dir()):
3882
3895
  fmode = format(int(stat.S_IFDIR + 511), 'x').lower();
3883
- fchmode = stat.S_IMODE(fmode);
3884
- ftypemod = stat.S_IFMT(fmode);
3896
+ prefmode = int(stat.S_IFDIR + 511);
3897
+ fchmode = stat.S_IMODE(prefmode);
3898
+ ftypemod = stat.S_IFMT(prefmode);
3885
3899
  fcompression = "";
3886
3900
  fcsize = format(int(0), 'x').lower();
3887
3901
  try:
@@ -6129,7 +6143,14 @@ def ZipFileToArrayAlt(infile, listonly=False, checksumtype="crc32", extradata=[]
6129
6143
  ftypemod = int(stat.S_IFMT(int(stat.S_IFDIR + 511)));
6130
6144
  elif(zipinfo.create_system==3):
6131
6145
  fwinattributes = int(0);
6132
- fmode = int(zipinfo.external_attr);
6146
+ try:
6147
+ fmode = int(zipinfo.external_attr);
6148
+ fchmode = stat.S_IMODE(fmode);
6149
+ ftypemod = stat.S_IFMT(fmode);
6150
+ except OverflowError:
6151
+ fmode = int(zipinfo.external_attr >> 16);
6152
+ fchmode = stat.S_IMODE(fmode);
6153
+ ftypemod = stat.S_IFMT(fmode);
6133
6154
  else:
6134
6155
  fwinattributes = int(0);
6135
6156
  if(not member.is_dir()):
@@ -7366,9 +7387,14 @@ def ZipFileListFiles(infile, verbose=False, returnfp=False):
7366
7387
  ftypemod = int(stat.S_IFMT(int(stat.S_IFDIR + 511)));
7367
7388
  elif(zipinfo.create_system==3):
7368
7389
  fwinattributes =int(0);
7369
- fmode = int(zipinfo.external_attr);
7370
- fchmode = int(stat.S_IMODE(fmode));
7371
- ftypemod = int(stat.S_IFMT(fmode));
7390
+ try:
7391
+ fmode = int(zipinfo.external_attr);
7392
+ fchmode = stat.S_IMODE(fmode);
7393
+ ftypemod = stat.S_IFMT(fmode);
7394
+ except OverflowError:
7395
+ fmode = int(zipinfo.external_attr >> 16);
7396
+ fchmode = stat.S_IMODE(fmode);
7397
+ ftypemod = stat.S_IFMT(fmode);
7372
7398
  else:
7373
7399
  fwinattributes = int(0);
7374
7400
  if(not member.is_dir()):
@@ -7863,6 +7889,26 @@ def upload_file_to_ftp_string(ftpstring, url):
7863
7889
  ftpfileo.close();
7864
7890
  return ftpfile;
7865
7891
 
7892
+ class RawIteratorWrapper:
7893
+ def __init__(self, iterator):
7894
+ self.iterator = iterator;
7895
+ self.buffer = b"";
7896
+ self._iterator_exhausted = False;
7897
+ def read(self, size=-1):
7898
+ if self._iterator_exhausted:
7899
+ return b'';
7900
+ while size < 0 or len(self.buffer) < size:
7901
+ try:
7902
+ chunk = next(self.iterator);
7903
+ self.buffer += chunk;
7904
+ except StopIteration:
7905
+ self._iterator_exhausted = True;
7906
+ break;
7907
+ if size < 0:
7908
+ size = len(self.buffer);
7909
+ result, self.buffer = self.buffer[:size], self.buffer[size:];
7910
+ return result;
7911
+
7866
7912
  def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__):
7867
7913
  if headers is None:
7868
7914
  headers = {};
@@ -7880,7 +7926,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__):
7880
7926
  elif urlparts.scheme == "ftp" or urlparts.scheme == "ftps":
7881
7927
  return download_file_from_ftp_file(url);
7882
7928
  if urlparts.port:
7883
- netloc += ':' + str(urlparts.port)
7929
+ netloc += ':' + str(urlparts.port);
7884
7930
  rebuilt_url = urlunparse((urlparts.scheme, netloc, urlparts.path, urlparts.params, urlparts.query, urlparts.fragment));
7885
7931
  # Create a temporary file object
7886
7932
  httpfile = BytesIO();
@@ -7890,17 +7936,17 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__):
7890
7936
  response = requests.get(rebuilt_url, headers=headers, auth=(username, password), stream=True);
7891
7937
  else:
7892
7938
  response = requests.get(rebuilt_url, headers=headers, stream=True);
7893
- response.raw.decode_content = True;
7939
+ response.raw.decode_content = True
7894
7940
  shutil.copyfileobj(response.raw, httpfile);
7895
7941
  elif usehttp == 'httpx' and havehttpx:
7896
7942
  # Use httpx if selected and available
7897
- with httpx.Client() as client:
7943
+ with httpx.Client(follow_redirects=True) as client:
7898
7944
  if username and password:
7899
- response = client.get(rebuilt_url, headers=headers, auth=(username, password), stream=True);
7945
+ response = client.get(rebuilt_url, headers=headers, auth=(username, password));
7900
7946
  else:
7901
- response = client.get(rebuilt_url, headers=headers, stream=True);
7902
- for chunk in response.iter_bytes():
7903
- httpfile.write(chunk);
7947
+ response = client.get(rebuilt_url, headers=headers);
7948
+ raw_wrapper = RawIteratorWrapper(response.iter_bytes());
7949
+ shutil.copyfileobj(raw_wrapper, httpfile);
7904
7950
  else:
7905
7951
  # Use urllib as a fallback
7906
7952
  # Build a Request object for urllib
@@ -7917,15 +7963,15 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__):
7917
7963
  opener = build_opener(auth_handler);
7918
7964
  else:
7919
7965
  opener = build_opener();
7920
- with opener.open(request) as response:
7921
- shutil.copyfileobj(response, httpfile);
7966
+ response = opener.open(request);
7967
+ shutil.copyfileobj(response, httpfile);
7922
7968
  # Reset file pointer to the start
7923
7969
  httpfile.seek(0, 0);
7924
7970
  # Return the temporary file object
7925
7971
  return httpfile;
7926
7972
 
7927
- def download_file_from_http_string(url, headers=geturls_headers_pycatfile_python_alt):
7928
- httpfile = download_file_from_http_file(url, headers);
7973
+ def download_file_from_http_string(url, headers=geturls_headers_pycatfile_python_alt, usehttp=__use_http_lib__):
7974
+ httpfile = download_file_from_http_file(url, headers, usehttp);
7929
7975
  return ftpfile.read();
7930
7976
 
7931
7977
  if(haveparamiko):
@@ -8156,10 +8202,10 @@ else:
8156
8202
  def upload_file_to_pysftp_string(url):
8157
8203
  return False;
8158
8204
 
8159
- def download_file_from_internet_file(url, headers=geturls_headers_pycatfile_python_alt):
8205
+ def download_file_from_internet_file(url, headers=geturls_headers_pycatfile_python_alt, usehttp=__use_http_lib__):
8160
8206
  urlparts = urlparse(url);
8161
8207
  if(urlparts.scheme=="http" or urlparts.scheme=="https"):
8162
- return download_file_from_http_file(url, headers);
8208
+ return download_file_from_http_file(url, headers, usehttp);
8163
8209
  elif(urlparts.scheme=="ftp" or urlparts.scheme=="ftps"):
8164
8210
  return download_file_from_ftp_file(url);
8165
8211
  elif(urlparts.scheme=="sftp"):
@@ -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/18/2024 Ver. 0.13.6 RC 1 - Author: cooldude2k $
16
+ $FileInfo: setup.py - Last Update: 6/20/2024 Ver. 0.13.10 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