lazysdk 0.1.86__tar.gz → 0.1.88__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.
Files changed (42) hide show
  1. {lazysdk-0.1.86 → lazysdk-0.1.88}/PKG-INFO +2 -1
  2. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazyexcel.py +5 -1
  3. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazyfile.py +23 -51
  4. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazytime.py +10 -0
  5. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk.egg-info/PKG-INFO +2 -1
  6. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk.egg-info/requires.txt +1 -0
  7. {lazysdk-0.1.86 → lazysdk-0.1.88}/setup.py +3 -2
  8. {lazysdk-0.1.86 → lazysdk-0.1.88}/LICENSE +0 -0
  9. {lazysdk-0.1.86 → lazysdk-0.1.88}/README.md +0 -0
  10. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/__init__.py +0 -0
  11. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazyCrypto.py +0 -0
  12. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazy_id_card.py +0 -0
  13. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazybase64.py +0 -0
  14. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazycache.py +0 -0
  15. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazychromedriver.py +0 -0
  16. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazydecode.py +0 -0
  17. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazydict.py +0 -0
  18. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazyenv.py +0 -0
  19. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazyflask.py +0 -0
  20. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazyhtml.py +0 -0
  21. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazyid.py +0 -0
  22. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazyinfo.py +0 -0
  23. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazyip.py +0 -0
  24. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazyjson.py +0 -0
  25. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazym3u8.py +0 -0
  26. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazymd5.py +0 -0
  27. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazypath.py +0 -0
  28. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazyprocess.py +0 -0
  29. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazyproxies.py +0 -0
  30. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazyrandom.py +0 -0
  31. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazyredis.py +0 -0
  32. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazyrequests.py +0 -0
  33. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazytext.py +0 -0
  34. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazyua.py +0 -0
  35. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazyurl.py +0 -0
  36. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazywebhook.py +0 -0
  37. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/lazywifi.py +0 -0
  38. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk/showdata.py +0 -0
  39. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk.egg-info/SOURCES.txt +0 -0
  40. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk.egg-info/dependency_links.txt +0 -0
  41. {lazysdk-0.1.86 → lazysdk-0.1.88}/lazysdk.egg-info/top_level.txt +0 -0
  42. {lazysdk-0.1.86 → lazysdk-0.1.88}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lazysdk
3
- Version: 0.1.86
3
+ Version: 0.1.88
4
4
  Summary: 基于Python的懒人包
5
5
  Home-page: https://gitee.com/ZeroSeeker/lazysdk
6
6
  Author: ZeroSeeker
@@ -22,6 +22,7 @@ Requires-Dist: pycryptodome==3.10.1
22
22
  Requires-Dist: filetype==1.2.0
23
23
  Requires-Dist: netifaces==0.11.0
24
24
  Requires-Dist: user_agents==2.2.0
25
+ Requires-Dist: rich>=13.5.2
25
26
 
26
27
  # lazysdk
27
28
  ![](https://img.shields.io/badge/Python-3.8.6-green.svg)
@@ -7,6 +7,7 @@
7
7
  @ Gitee : https://gitee.com/ZeroSeeker
8
8
  """
9
9
  import decimal
10
+ import json
10
11
  from collections import OrderedDict
11
12
  from . import lazydict
12
13
  import openpyxl # 用于处理.xlsx,文档:https://openpyxl.readthedocs.io/en/stable/
@@ -335,10 +336,13 @@ def save_xlsx(
335
336
  for each in sheet_data_f:
336
337
  col_num = 1
337
338
  for key in each:
339
+ value = each.get(key)
340
+ if isinstance(value, dict) or isinstance(value, list):
341
+ value = json.dumps(value, ensure_ascii=False)
338
342
  sheet.cell(
339
343
  row=row_num,
340
344
  column=col_num,
341
- value=each.get(key)
345
+ value=value
342
346
  )
343
347
  col_num += 1
344
348
  row_num += 1
@@ -21,7 +21,8 @@ import xlrd
21
21
  import json
22
22
  import sys
23
23
  import os
24
- import zipfile
24
+ # import zipfile
25
+ from rich.progress import Progress
25
26
  from requests import exceptions
26
27
 
27
28
  headers_default = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0"}
@@ -183,9 +184,9 @@ def download(
183
184
  temp_size = 0 # 已经下载文件大小
184
185
  else:
185
186
  temp_size = range_start + 0 # 已经下载文件大小
186
- chunk_size = 1024 # 分割文件大小,字节B
187
+ chunk_size = 1024 * 1024 # 分割文件大小,字节B
187
188
  total_size = int(total_length) # 文件总大小
188
- total_size_mb = round(total_size / (1024 * 1024), 2) # 换算到MB的文件大小
189
+ # total_size_mb = round(total_size / (1024 * 1024), 2) # 换算到MB的文件大小
189
190
  # 添加文件大小控制,跳过下载超大文件
190
191
  if size_limit is None:
191
192
  pass
@@ -195,7 +196,6 @@ def download(
195
196
  else:
196
197
  pass
197
198
 
198
- time_start = time.time() # 获取下载开始时间
199
199
  is_finish = False
200
200
 
201
201
  if overwrite and os.path.exists(path_local):
@@ -216,54 +216,26 @@ def download(
216
216
  pass
217
217
 
218
218
  with open(path_local, "ab") as f: # wb新建文件,a追加
219
- for chunk in response.iter_content(chunk_size=chunk_size):
220
- try:
221
- temp_time_now = time.time() # 时间采样
222
- time_spend_total = temp_time_now - time_start
223
- if time_spend_total == 0:
224
- total_speed = round((temp_size-range_start) / (1024 * 1024) / 0.001, 2) # 计算速度:MB/s
225
- else:
226
- total_speed = round((temp_size-range_start) / (1024 * 1024) / time_spend_total, 2) # 计算速度:MB/s
227
- if not chunk:
228
- if temp_size >= total_size:
229
- is_finish = True
230
- else:
231
- is_finish = False
232
- break
233
- else:
234
- temp_size += len(chunk)
235
- f.write(chunk)
236
- f.flush()
237
- done = int(50 * temp_size / total_size)
238
- if total_speed == 0 or time_spend_total == 0:
239
- time_left = 0
240
- else:
241
- time_left = (total_size - temp_size) / total_speed / 1024 / 1024
242
- show_dict = {
243
- 'finish_mark': '█' * done,
244
- 'not_finish_mark': ' ' * (50 - done),
245
- 'total_size': total_size_mb, # 换算到M
246
- 'total_percent': round(100 * temp_size / total_size, 4),
247
- 'total_speed': total_speed,
248
- 'finish_size': round(temp_size / (1024 * 1024), 2),
249
- 'time_spend_total': int(time_spend_total),
250
- 'time_left': int(time_left)
251
- }
252
- show_msg = "\r[%(finish_mark)s%(not_finish_mark)s] " \
253
- "总大小:%(total_size)sMB " \
254
- "总进度:%(total_percent)s%% " \
255
- "平均速度:%(total_speed)sMB/s " \
256
- "已下载:%(finish_size)sMB " \
257
- "已耗时 %(time_spend_total)s 秒 " \
258
- "预计剩余 %(time_left)s 秒" % show_dict
259
- sys.stdout.write(show_msg)
260
- sys.stdout.flush()
261
- if temp_size >= total_size:
262
- is_finish = True
219
+ with Progress() as progress:
220
+ task = progress.add_task(description="[red]Downloading...", total=total_size)
221
+ for chunk in response.iter_content(chunk_size=chunk_size):
222
+ try:
223
+ if not chunk:
224
+ if temp_size >= total_size:
225
+ is_finish = True
226
+ else:
227
+ is_finish = False
228
+ break
263
229
  else:
264
- is_finish = False
265
- except:
266
- showlog.error('')
230
+ f.write(chunk)
231
+ f.flush()
232
+ progress.update(task, advance=chunk_size)
233
+ if temp_size >= total_size:
234
+ is_finish = True
235
+ else:
236
+ is_finish = False
237
+ except:
238
+ showlog.error('')
267
239
  print("\n ==> 文件已全部下载完成,保存位置:", path_local)
268
240
  res_dict = {
269
241
  'file_dir': path_local,
@@ -975,3 +975,13 @@ def get_recent_days_date(
975
975
  start_date=get_date_string(days=num_start),
976
976
  end_date=get_date_string(days=num_end)
977
977
  )
978
+
979
+
980
+ def network_timestamp():
981
+ """
982
+ 获取网络时间,精确到毫秒
983
+ """
984
+ url = 'https://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp' # 淘宝网络取时
985
+ res = requests.get(url=url)
986
+ net_t = res.json()['data']['t'] # 精确到毫秒的时间戳
987
+ return int(net_t)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lazysdk
3
- Version: 0.1.86
3
+ Version: 0.1.88
4
4
  Summary: 基于Python的懒人包
5
5
  Home-page: https://gitee.com/ZeroSeeker/lazysdk
6
6
  Author: ZeroSeeker
@@ -22,6 +22,7 @@ Requires-Dist: pycryptodome==3.10.1
22
22
  Requires-Dist: filetype==1.2.0
23
23
  Requires-Dist: netifaces==0.11.0
24
24
  Requires-Dist: user_agents==2.2.0
25
+ Requires-Dist: rich>=13.5.2
25
26
 
26
27
  # lazysdk
27
28
  ![](https://img.shields.io/badge/Python-3.8.6-green.svg)
@@ -10,3 +10,4 @@ pycryptodome==3.10.1
10
10
  filetype==1.2.0
11
11
  netifaces==0.11.0
12
12
  user_agents==2.2.0
13
+ rich>=13.5.2
@@ -13,7 +13,7 @@ with open("README.md", "r", encoding='utf-8') as fh:
13
13
 
14
14
  setuptools.setup(
15
15
  name="lazysdk",
16
- version="0.1.86",
16
+ version="0.1.88",
17
17
  description="基于Python的懒人包",
18
18
  long_description=long_description,
19
19
  long_description_content_type="text/markdown",
@@ -38,6 +38,7 @@ setuptools.setup(
38
38
  'pycryptodome==3.10.1',
39
39
  'filetype==1.2.0',
40
40
  'netifaces==0.11.0',
41
- 'user_agents==2.2.0'
41
+ 'user_agents==2.2.0',
42
+ 'rich>=13.5.2'
42
43
  ]
43
44
  )
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes