sapiadapter 1.2.0__tar.gz → 1.4.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: sapiadapter
3
- Version: 1.2.0
3
+ Version: 1.4.0
4
4
  Summary: A minimal package exposing run, defdata, and defmeta methods
5
5
  Author: Zafar Iqbal
6
6
  Author-email: zaf@sparc.space
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "sapiadapter"
3
- version = "1.2.0"
3
+ version = "1.4.0"
4
4
  description = "A minimal package exposing run, defdata, and defmeta methods"
5
5
  authors = ["Zafar Iqbal <zaf@sparc.space>"]
6
6
  readme = "README.md"
@@ -1,12 +1,24 @@
1
1
 
2
2
  import requests
3
3
 
4
- __version__ = "1.2.0"
4
+ #__version__ = "1.2.0"
5
5
 
6
6
  __all__ = [ "run" , "defdata" , "defmeta" ]
7
7
 
8
8
  DATA = None
9
9
 
10
+ def check_compression(response):
11
+ encoding = response.headers.get("Content-Encoding", "").lower()
12
+ transfer_encoding = response.headers.get("Transfer-Encoding", "").lower()
13
+
14
+ return {
15
+ "content_encoding": encoding or None,
16
+ "transfer_encoding": transfer_encoding or None,
17
+ "is_compressed": encoding in ("gzip", "deflate", "br", "zstd"),
18
+ "content_length_header": response.headers.get("Content-Length"),
19
+ "actual_body_length": len(response.content),
20
+ }
21
+
10
22
  def run( url = None , params = None ) :
11
23
 
12
24
  if not url : raise "url params None"
@@ -27,6 +39,9 @@ def run( url = None , params = None ) :
27
39
  try : body = response.json( )
28
40
  except ValueError : body = response.text
29
41
 
42
+ #info = check_compression(response)
43
+ #print(info)
44
+
30
45
  global DATA
31
46
  DATA = body
32
47
 
File without changes