PyCatFile 0.13.4__tar.gz → 0.13.8__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.4
3
+ Version: 0.13.8
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.4
3
+ Version: 0.13.8
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.4 RC 1 - Author: cooldude2k $
17
+ $FileInfo: catfile.py - Last Update: 6/19/2024 Ver. 0.13.8 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.4 RC 1 - Author: cooldude2k $
17
+ $FileInfo: neocatfile.py - Last Update: 6/19/2024 Ver. 0.13.8 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.4 RC 1 - Author: cooldude2k $
17
+ $FileInfo: pycatfile.py - Last Update: 6/19/2024 Ver. 0.13.8 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
 
@@ -175,9 +176,9 @@ __use_alt_format__ = False;
175
176
  if(not havepysftp):
176
177
  __use_pysftp__ = False;
177
178
  __use_http_lib__ = "httpx";
178
- if(__use_http_lib__=="httpx" haverequests and not havehttpx):
179
+ if(__use_http_lib__=="httpx" and haverequests and not havehttpx):
179
180
  __use_http_lib__ = "requests";
180
- if(__use_http_lib__=="requests" havehttpx and not haverequests):
181
+ if(__use_http_lib__=="requests" and havehttpx and not haverequests):
181
182
  __use_http_lib__ = "httpx";
182
183
  if((__use_http_lib__=="httpx" or __use_http_lib__=="requests") and not havehttpx and not haverequests):
183
184
  __use_http_lib__ = "urllib";
@@ -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, 4, "RC 1", 1);
217
- __version_date_info__ = (2024, 6, 18, "RC 1", 1);
217
+ __version_info__ = (0, 13, 8, "RC 1", 1);
218
+ __version_date_info__ = (2024, 6, 19, "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: 0c3bc3acf2863566af9a19f45254762656cc7ce7 $";
221
+ __revision_id__ = "$Id: 851e6a66748b503035c639482ba1cc17441d1e99 $";
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;
@@ -7863,6 +7868,26 @@ def upload_file_to_ftp_string(ftpstring, url):
7863
7868
  ftpfileo.close();
7864
7869
  return ftpfile;
7865
7870
 
7871
+ class RawIteratorWrapper:
7872
+ def __init__(self, iterator):
7873
+ self.iterator = iterator;
7874
+ self.buffer = b"";
7875
+ self._iterator_exhausted = False;
7876
+ def read(self, size=-1):
7877
+ if self._iterator_exhausted:
7878
+ return b'';
7879
+ while size < 0 or len(self.buffer) < size:
7880
+ try:
7881
+ chunk = next(self.iterator);
7882
+ self.buffer += chunk;
7883
+ except StopIteration:
7884
+ self._iterator_exhausted = True;
7885
+ break;
7886
+ if size < 0:
7887
+ size = len(self.buffer);
7888
+ result, self.buffer = self.buffer[:size], self.buffer[size:];
7889
+ return result;
7890
+
7866
7891
  def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__):
7867
7892
  if headers is None:
7868
7893
  headers = {};
@@ -7880,7 +7905,7 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__):
7880
7905
  elif urlparts.scheme == "ftp" or urlparts.scheme == "ftps":
7881
7906
  return download_file_from_ftp_file(url);
7882
7907
  if urlparts.port:
7883
- netloc += ':' + str(urlparts.port)
7908
+ netloc += ':' + str(urlparts.port);
7884
7909
  rebuilt_url = urlunparse((urlparts.scheme, netloc, urlparts.path, urlparts.params, urlparts.query, urlparts.fragment));
7885
7910
  # Create a temporary file object
7886
7911
  httpfile = BytesIO();
@@ -7890,17 +7915,17 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__):
7890
7915
  response = requests.get(rebuilt_url, headers=headers, auth=(username, password), stream=True);
7891
7916
  else:
7892
7917
  response = requests.get(rebuilt_url, headers=headers, stream=True);
7893
- response.raw.decode_content = True;
7918
+ response.raw.decode_content = True
7894
7919
  shutil.copyfileobj(response.raw, httpfile);
7895
7920
  elif usehttp == 'httpx' and havehttpx:
7896
7921
  # Use httpx if selected and available
7897
- with httpx.Client() as client:
7922
+ with httpx.Client(follow_redirects=True) as client:
7898
7923
  if username and password:
7899
- response = client.get(rebuilt_url, headers=headers, auth=(username, password), stream=True);
7924
+ response = client.get(rebuilt_url, headers=headers, auth=(username, password));
7900
7925
  else:
7901
- response = client.get(rebuilt_url, headers=headers, stream=True);
7902
- for chunk in response.iter_bytes():
7903
- httpfile.write(chunk);
7926
+ response = client.get(rebuilt_url, headers=headers);
7927
+ raw_wrapper = RawIteratorWrapper(response.iter_bytes());
7928
+ shutil.copyfileobj(raw_wrapper, httpfile);
7904
7929
  else:
7905
7930
  # Use urllib as a fallback
7906
7931
  # Build a Request object for urllib
@@ -7917,15 +7942,15 @@ def download_file_from_http_file(url, headers=None, usehttp=__use_http_lib__):
7917
7942
  opener = build_opener(auth_handler);
7918
7943
  else:
7919
7944
  opener = build_opener();
7920
- with opener.open(request) as response:
7921
- shutil.copyfileobj(response, httpfile);
7945
+ response = opener.open(request);
7946
+ shutil.copyfileobj(response, httpfile);
7922
7947
  # Reset file pointer to the start
7923
7948
  httpfile.seek(0, 0);
7924
7949
  # Return the temporary file object
7925
7950
  return httpfile;
7926
7951
 
7927
- def download_file_from_http_string(url, headers=geturls_headers_pycatfile_python_alt):
7928
- httpfile = download_file_from_http_file(url, headers);
7952
+ def download_file_from_http_string(url, headers=geturls_headers_pycatfile_python_alt, usehttp=__use_http_lib__):
7953
+ httpfile = download_file_from_http_file(url, headers, usehttp);
7929
7954
  return ftpfile.read();
7930
7955
 
7931
7956
  if(haveparamiko):
@@ -8156,10 +8181,10 @@ else:
8156
8181
  def upload_file_to_pysftp_string(url):
8157
8182
  return False;
8158
8183
 
8159
- def download_file_from_internet_file(url, headers=geturls_headers_pycatfile_python_alt):
8184
+ def download_file_from_internet_file(url, headers=geturls_headers_pycatfile_python_alt, usehttp=__use_http_lib__):
8160
8185
  urlparts = urlparse(url);
8161
8186
  if(urlparts.scheme=="http" or urlparts.scheme=="https"):
8162
- return download_file_from_http_file(url, headers);
8187
+ return download_file_from_http_file(url, headers, usehttp);
8163
8188
  elif(urlparts.scheme=="ftp" or urlparts.scheme=="ftps"):
8164
8189
  return download_file_from_ftp_file(url);
8165
8190
  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.4 RC 1 - Author: cooldude2k $
16
+ $FileInfo: setup.py - Last Update: 6/19/2024 Ver. 0.13.8 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