lazysdk 0.1.111__py3-none-any.whl → 0.1.113__py3-none-any.whl

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.
lazysdk/lazy_header.py ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env python3
2
+ # coding = utf8
3
+ from lazysdk import showdata
4
+
5
+ def convert2dict(header_str: str):
6
+ header_temp = header_str.split('\n')
7
+ header_dict = dict()
8
+ for each in header_temp:
9
+ if len(each) == 0:
10
+ continue
11
+ else:
12
+ each_split = each.split(': ')
13
+ header_dict[each_split[0]] = each_split[1]
14
+ return header_dict
15
+
16
+
17
+ def get_lines():
18
+ lines = []
19
+ print("请输入多行数据,以空行结束:")
20
+ while True:
21
+ line = input()
22
+ if line:
23
+ lines.append(line)
24
+ else:
25
+ break
26
+
27
+ print("您输入的多行数据是:")
28
+ return "\n".join(lines)
29
+
30
+
31
+ if __name__ == '__main__':
32
+ test_lines = get_lines()
33
+ showdata.show_dict(convert2dict(header_str=test_lines))
34
+
lazysdk/lazydict.py CHANGED
@@ -291,18 +291,25 @@ def key_min_value(
291
291
  def get_value_list(
292
292
  list_in: list,
293
293
  key,
294
- deepcopy: bool = True
294
+ deepcopy: bool = True,
295
+ value_type: type = None
295
296
  ):
296
297
  """
297
298
  提取list嵌套的字典中某个key的值列表
299
+ :param value_type: 将值格式化为指定的类型,例如str
298
300
  """
299
301
  res = []
300
302
  if list_in:
301
303
  for each in list_in:
302
304
  if isinstance(each, dict):
303
305
  each_value = each.get(key)
304
- if each_value:
306
+ if each_value and value_type is None:
305
307
  res.append(each_value)
308
+ elif each_value and value_type is not None:
309
+ if isinstance(each_value, value_type):
310
+ res.append(each_value)
311
+ else:
312
+ res.append(value_type(each_value))
306
313
  else:
307
314
  continue
308
315
  else:
@@ -314,3 +321,16 @@ def get_value_list(
314
321
  else:
315
322
  return []
316
323
 
324
+
325
+ if __name__ == '__main__':
326
+ res = get_value_list(
327
+ list_in = [
328
+ {"a": "1"},
329
+ {"a": "2"},
330
+ {"a": None},
331
+ ],
332
+ key = "a",
333
+ value_type = int
334
+
335
+ )
336
+ print(res)
lazysdk/lazyrequests.py CHANGED
@@ -23,7 +23,8 @@ def lazy_requests(
23
23
  ReadTimeout_retry: bool = True, # 超时重试
24
24
  JSONDecodeError_retry: bool = True, # 返回非json类型重试
25
25
  ConnectionError_retry: bool = True, # 连接错误重试
26
- ChunkedEncodingError: bool = True,
26
+ ChunkedEncodingError_retry: bool = True,
27
+ TooManyRedirects_retry: bool = True,
27
28
 
28
29
  **kwargs
29
30
  ):
@@ -53,22 +54,27 @@ def lazy_requests(
53
54
  except requests.exceptions.ReadTimeout:
54
55
  if ReadTimeout_retry is True:
55
56
  retry_count += 1
56
- showlog.warning(f'ReadTimeout_retry,将在{retry_delay}秒后重试第{retry_count}次...')
57
+ showlog.warning(f'ReadTimeout,将在{retry_delay}秒后重试第{retry_count}次...')
57
58
  time.sleep(retry_delay)
58
59
  except requests.exceptions.JSONDecodeError:
59
60
  if JSONDecodeError_retry is True:
60
61
  retry_count += 1
61
- showlog.warning(f'JSONDecodeError_retry,将在{retry_delay}秒后重试第{retry_count}次...')
62
+ showlog.warning(f'JSONDecodeError,将在{retry_delay}秒后重试第{retry_count}次...')
62
63
  time.sleep(retry_delay)
63
64
  except requests.exceptions.ConnectionError: # 包含ProxyError
64
65
  if ConnectionError_retry is True:
65
66
  retry_count += 1
66
- showlog.warning(f'ConnectionError_retry,将在{retry_delay}秒后重试第{retry_count}次...')
67
+ showlog.warning(f'ConnectionError,将在{retry_delay}秒后重试第{retry_count}次...')
67
68
  time.sleep(retry_delay)
68
69
  except requests.exceptions.ChunkedEncodingError:
69
- if ChunkedEncodingError is True:
70
+ if ChunkedEncodingError_retry is True:
70
71
  retry_count += 1
71
- showlog.warning(f'ChunkedEncodingError_retry,将在{retry_delay}秒后重试第{retry_count}次...')
72
+ showlog.warning(f'ChunkedEncodingError,将在{retry_delay}秒后重试第{retry_count}次...')
73
+ time.sleep(retry_delay)
74
+ except requests.exceptions.TooManyRedirects:
75
+ if TooManyRedirects_retry is True:
76
+ retry_count += 1
77
+ showlog.warning(f'TooManyRedirects,将在{retry_delay}秒后重试第{retry_count}次...')
72
78
  time.sleep(retry_delay)
73
79
  if retry_limit == 0:
74
80
  break
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lazysdk
3
- Version: 0.1.111
3
+ Version: 0.1.113
4
4
  Summary: 基于Python的懒人包
5
5
  Home-page: https://gitee.com/ZeroSeeker/lazysdk
6
6
  Author: ZeroSeeker
@@ -1,11 +1,12 @@
1
1
  lazysdk/__init__.py,sha256=DnzFWyjDsoyNGq0VJ_s0Ha6dPOIGrZtA3DFQhg0HbEU,184
2
2
  lazysdk/lazyCrypto.py,sha256=OftFbJTzPgoQ-o2AI4LI6uyPNIZAp0XZnXl_qStnR78,389
3
+ lazysdk/lazy_header.py,sha256=Ias8LAIOg5iUXGFsyNwdQ7QcAgcR7pp-q29ZFiCH1xU,782
3
4
  lazysdk/lazy_id_card.py,sha256=b96SvObDaEavMLIdinbxpleupCEnHihklO-jycl5BJ8,2797
4
5
  lazysdk/lazybase64.py,sha256=8jtuH9S1jICXpzxhRLe7xNur_o9TWbT1BRmTshZWYh0,669
5
6
  lazysdk/lazycache.py,sha256=it4B-iTXITtua8yjeiUooDsye4Z_aGy4uAOibxoViNQ,571
6
7
  lazysdk/lazychromedriver.py,sha256=tJk6HIY31tqBFiSolq2ALxLqDTcOTrevOKaDqzUVPps,15383
7
8
  lazysdk/lazydecode.py,sha256=z3no94VDhxVxJCPQFwKxKTxz8v9Eikjk18TZWDttN6A,414
8
- lazysdk/lazydict.py,sha256=n3wBJDIt-U_AqyQfZHdDF1YIiwFQQOG8wW9WsA-r3rA,9493
9
+ lazysdk/lazydict.py,sha256=FZ6HsTh7AZFXbsv8_9VE3sVp3gn8Frs7qOdHB2K5lRk,10092
9
10
  lazysdk/lazyenv.py,sha256=P6HjO9cbBPzHD_Vs-Ww_GThDq-h9Wn31VSiu9OzTNWI,3024
10
11
  lazysdk/lazyexcel.py,sha256=adZTtQYuVZ2u5jMSRBJlKluGVdN7oHxJsLpxawV1ros,15835
11
12
  lazysdk/lazyfile.py,sha256=5p7yPWRLTqvToDUzQAEZ8uGfz-x-zSsM5ZHeT97ZpWo,20268
@@ -24,7 +25,7 @@ lazysdk/lazyproxies.py,sha256=bljLKkP3WksZ6jOHhjS5-jSHdUBRH6gx-BxEZTPJeXc,546
24
25
  lazysdk/lazyrandom.py,sha256=XZ8hTcNvc68FAI-BfaIt7QpCmzZ7m4RGDrfpy_U7zTw,1420
25
26
  lazysdk/lazyre.py,sha256=UQNpf9P1GyxRoRfuulyY4D1nnF227R4bzUGT3LevE7w,956
26
27
  lazysdk/lazyredis.py,sha256=78jM_tXNgUKULcp08CQEHmfAlzwlWuOsl6SuLwoLDdM,37918
27
- lazysdk/lazyrequests.py,sha256=qOUNkFhIThHNLALDTmOqPjKgMse5BVD-Kf9kheadMAY,3750
28
+ lazysdk/lazyrequests.py,sha256=kNtHmg-M39selgsOtdGb-6KHfAz80BE3IwdcTdrJth4,4065
28
29
  lazysdk/lazytext.py,sha256=1UgwxLt3c6i0JwUGRC7srSc_mhM3ICv1WrhOqkuIrLk,2672
29
30
  lazysdk/lazytime.py,sha256=uT6Q00XNPYifMgig0uTLmCRRBnqpciSfy96QoVbrQK4,27383
30
31
  lazysdk/lazyua.py,sha256=IqLmqGDECdJa3Wcr8h6sTxMErJZlCTM3Jk7IWm90UzI,4827
@@ -33,8 +34,8 @@ lazysdk/lazywebhook.py,sha256=DWn4AE4E_w2wZuev5aD51J5oGCJjitbucFokHSSnuHg,9377
33
34
  lazysdk/lazywifi.py,sha256=FOvLPTcb6BQE6D8kjfB0TLpfgGxw8jqC3vZbTs6LbD4,716
34
35
  lazysdk/lazyxml.py,sha256=PLAcDWjpu2GMJPsV9dHOv716CVmflQee7Aan-hqGxL8,770
35
36
  lazysdk/showdata.py,sha256=957JMXq7qfJ4ELpA3nBJwkyEUn6mRwtVXVBGYfZaCgg,1683
36
- lazysdk-0.1.111.dist-info/LICENSE,sha256=OC5E4ENUG6B4dGEVGwUpdsD-D9SZsCVC92NAgaqvE-c,1088
37
- lazysdk-0.1.111.dist-info/METADATA,sha256=BQeIitV7HwNlYnsKZosy1mfIjxeItG1z1PM8L-6pkH4,1901
38
- lazysdk-0.1.111.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
39
- lazysdk-0.1.111.dist-info/top_level.txt,sha256=--bGS42ZHUhVeO83y1wfvKFg6OjkTLxQ4V4riqPQljY,8
40
- lazysdk-0.1.111.dist-info/RECORD,,
37
+ lazysdk-0.1.113.dist-info/LICENSE,sha256=OC5E4ENUG6B4dGEVGwUpdsD-D9SZsCVC92NAgaqvE-c,1088
38
+ lazysdk-0.1.113.dist-info/METADATA,sha256=L29_6WGZW4XO0M3XzvJgJjsJbGOnU6RSUk8-S3Tctrw,1901
39
+ lazysdk-0.1.113.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
40
+ lazysdk-0.1.113.dist-info/top_level.txt,sha256=--bGS42ZHUhVeO83y1wfvKFg6OjkTLxQ4V4riqPQljY,8
41
+ lazysdk-0.1.113.dist-info/RECORD,,