lazysdk 0.1.58__py3-none-any.whl → 0.1.60__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/lazyfile.py CHANGED
@@ -388,114 +388,6 @@ def read_(_source_file):
388
388
  return res
389
389
 
390
390
 
391
- def excel_read(source_file):
392
- # >>读取数据【方式:一次性全部读取】------------------------------------------------------------
393
- data = xlrd.open_workbook(source_file) # 打开表
394
- res = list()
395
- # table = data.sheets()[0] # 默认使用第一张表格
396
- for table in data.sheets():
397
- nrows = table.nrows # 获取行数
398
- ncols = table.ncols # 获取列数
399
- for inrows in range(nrows):
400
- res_temp = dict()
401
- for incols in range(ncols):
402
- res_temp.update({table.cell(0, incols).value: table.cell(inrows, incols).value})
403
- # print(res_temp)
404
- res.append(res_temp)
405
- return res
406
-
407
-
408
- def excel_read_all_table(source_file):
409
- try:
410
- # >>读取数据【方式:一次性全部读取】------------------------------------------------------------
411
- data = xlrd.open_workbook(source_file) # 打开表
412
- res = list()
413
- # table = data.sheets()[0] # 默认使用第一张表格
414
- for table in data.sheets():
415
- nrows = table.nrows # 获取行数
416
- ncols = table.ncols # 获取列数
417
- for inrows in range(nrows):
418
- res_temp = dict()
419
- for incols in range(ncols):
420
- res_temp.update({table.cell(0, incols).value: table.cell(inrows, incols).value})
421
- # print(res_temp)
422
- res.append(res_temp)
423
- return res
424
- except:
425
- return
426
-
427
-
428
- def excel_sheet_dict(source_file):
429
- try:
430
- # >>读取数据【方式:一次性全部读取】------------------------------------------------------------
431
- data = xlrd.open_workbook(source_file) # 打开表
432
- res = dict()
433
- for table in data.sheets():
434
- table_name = table.name
435
- nrows = table.nrows # 获取行数
436
- ncols = table.ncols # 获取列数
437
- res_temp = list()
438
- for inrows in range(nrows):
439
- data_temp = dict()
440
- for incols in range(ncols):
441
- data_temp.update({table.cell(0, incols).value: table.cell(inrows, incols).value})
442
- res_temp.append(data_temp)
443
- res.update({table_name: res_temp})
444
- return res
445
- except:
446
- return
447
-
448
-
449
- def excel_specify_dict(source_file, sheet_name, _up_data_col_list=None, _col_dict=None):
450
- try:
451
- col_dict = dict()
452
- if _col_dict is not None:
453
- temp0 = _col_dict.replace(" ", "").split(",")
454
- if temp0 is not None and len(temp0) > 0:
455
- for each in temp0:
456
- temp1 = each.split(":")
457
- col_dict.update({temp1[1]: temp1[0]})
458
- up_data_col_list = list()
459
- if _up_data_col_list is not None:
460
- up_data_col_list = _up_data_col_list.replace(" ", "").split(",")
461
-
462
- # >>读取数据【方式:一次性全部读取】------------------------------------------------------------
463
- data = xlrd.open_workbook(source_file) # 打开表
464
- res = dict()
465
- for table in data.sheets():
466
- table_name = table.name
467
- if table_name == sheet_name:
468
- nrows = table.nrows # 获取行数
469
- ncols = table.ncols # 获取列数
470
- res_temp = list()
471
- for inrows in range(nrows):
472
- data_temp = dict()
473
- for incols in range(ncols):
474
- # print(table.cell(0, incols).value)
475
- col_name_ori = table.cell(0, incols).value
476
- if len(col_dict) > 0 and col_dict is not None:
477
- col_name = col_dict.get(col_name_ori)
478
- else:
479
- col_name = col_name_ori
480
-
481
- if col_name_ori in up_data_col_list:
482
- # print(col_name_ori)
483
- try:
484
- col_value = xlrd.xldate.xldate_as_datetime(table.cell(inrows, incols).value, 0)
485
- except Exception as ex:
486
- # print(ex)
487
- col_value = None
488
- else:
489
- col_value = table.cell(inrows, incols).value
490
-
491
- data_temp.update({col_name: col_value})
492
- res_temp.append(data_temp)
493
- res.update({table_name: res_temp})
494
- return res
495
- except:
496
- return
497
-
498
-
499
391
  def read_txt(text_name, path=None):
500
392
  try:
501
393
  if path is None:
lazysdk/lazyhtml.py ADDED
@@ -0,0 +1,68 @@
1
+
2
+
3
+ def make_thead(head_list: list):
4
+ """
5
+ 制作表头,输入表头列表,输出生成的行代码列表
6
+ """
7
+ thead_list = list()
8
+ for each_head in head_list:
9
+ head_line = f'<th>{each_head}</th>'
10
+ thead_list.append(head_line)
11
+ return thead_list
12
+
13
+
14
+ def make_tbody(body_list: list):
15
+ """
16
+ 制作表格主题,即表格的数据部分
17
+ """
18
+ tbody_list = list()
19
+ for each_body in body_list:
20
+ body_line = f'<td>{each_body}</td>'
21
+ tbody_list.append(body_line)
22
+ return tbody_list
23
+
24
+
25
+ def make_tb(
26
+ data: list,
27
+ border: int = 0,
28
+ beautiful: bool = False
29
+ ) -> str:
30
+ """
31
+ 输入数据为list(dict()),输出生成的html表格代码
32
+ border=2--> 边框宽度为2,是指外面灰色边框
33
+ """
34
+ key_list = list()
35
+ for each_data in data:
36
+ key_list.extend(list(each_data.keys()))
37
+ key_list = list(set(key_list))
38
+ thead_list = make_thead(head_list=key_list)
39
+ html_head = f"<tr>{''.join(thead_list)}</tr>"
40
+
41
+ html_body = ''
42
+ for each_data in data:
43
+ body_list = list()
44
+ for each_key in key_list:
45
+ body_list.append(each_data.get(each_key))
46
+ body_list = make_tbody(body_list=body_list) # 这里每行数据都要生成一次
47
+ html_body += f"<tr>{''.join(body_list)}</tr>\n"
48
+
49
+ table_others = ''
50
+ if border:
51
+ table_others += f' border={border}'
52
+
53
+ html_table = f"<table{table_others}>\n{html_head}\n{html_body}</table>"
54
+
55
+ if beautiful:
56
+ # 美化输出
57
+ from lxml import html
58
+ from lxml.html import builder as E
59
+ # 创建一个lxml的Element对象
60
+ root = html.fromstring(html_table)
61
+
62
+ # 设置HTML的缩进和换行
63
+ E.PRETTY_PRINT = True
64
+
65
+ # 漂亮地打印HTML
66
+ html_table = html.tostring(root, pretty_print=True)
67
+
68
+ return html_table
lazysdk/lazyinfo.py CHANGED
@@ -1,16 +1,30 @@
1
1
  import platform
2
2
  import datetime
3
3
  import socket
4
- import uuid
5
4
  import os
6
5
 
7
6
 
8
7
  def get_mac_address() -> str:
9
8
  """
10
- 获取mac地址
9
+ 获取mac地址,只有联网才能生效
11
10
  """
12
- mac = uuid.UUID(int=uuid.getnode()).hex[-12:]
13
- return ":".join([mac[e:e+2] for e in range(0, 11, 2)])
11
+ import netifaces
12
+ try:
13
+ default_gate_way, default_nic_name = netifaces.gateways()['default'][netifaces.AF_INET] # 获取默认网关和网卡名称
14
+ default_nic_mac_addr = netifaces.ifaddresses(default_nic_name)[netifaces.AF_LINK][0]['addr'] # 默认网卡的mac地址
15
+ return default_nic_mac_addr
16
+ except:
17
+ return ''
18
+
19
+
20
+ def get_net_info():
21
+ import netifaces
22
+ default_gate_way, default_nic_name = netifaces.gateways()['default'][netifaces.AF_INET] # 获取默认网关和网卡名称
23
+ default_nic_mac_addr = netifaces.ifaddresses(default_nic_name)[netifaces.AF_LINK][0]['addr'] # 默认网卡的mac地址
24
+ default_ip_addr = netifaces.ifaddresses(default_nic_name)[netifaces.AF_INET][0]['addr'] # 本地ip
25
+ default_ip_netmask = netifaces.ifaddresses(default_nic_name)[netifaces.AF_INET][0]['netmask'] # 子网掩码
26
+ default_ip_broadcast = netifaces.ifaddresses(default_nic_name)[netifaces.AF_INET][0]['netmask']
27
+ return {'mac': default_nic_mac_addr, 'local_ip': default_ip_addr, 'netmask': default_ip_netmask, 'broadcast': default_ip_broadcast}
14
28
 
15
29
 
16
30
  def platform_info() -> dict:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lazysdk
3
- Version: 0.1.58
3
+ Version: 0.1.60
4
4
  Summary: 基于Python的懒人包
5
5
  Home-page: https://gitee.com/ZeroSeeker/lazysdk
6
6
  Author: ZeroSeeker
@@ -21,6 +21,7 @@ Requires-Dist: m3u8 (==3.5.0)
21
21
  Requires-Dist: pycryptodome (==3.10.1)
22
22
  Requires-Dist: filetype (==1.2.0)
23
23
  Requires-Dist: rich (==13.5.2)
24
+ Requires-Dist: netifaces (==0.11.0)
24
25
 
25
26
  # lazysdk
26
27
  ![](https://img.shields.io/badge/Python-3.8.6-green.svg)
@@ -5,10 +5,11 @@ lazysdk/lazybase64.py,sha256=8jtuH9S1jICXpzxhRLe7xNur_o9TWbT1BRmTshZWYh0,669
5
5
  lazysdk/lazydict.py,sha256=uPc0YtLrFtBskLooChUbjapfjJ27HNG92cFRqGiTxdQ,7636
6
6
  lazysdk/lazyenv.py,sha256=P6HjO9cbBPzHD_Vs-Ww_GThDq-h9Wn31VSiu9OzTNWI,3024
7
7
  lazysdk/lazyexcel.py,sha256=r8_VbCzB1dRhMbK4Dwk-cr5keJCo6AV4r8SYe4O5y6k,15129
8
- lazysdk/lazyfile.py,sha256=fHqcUBhmbnLyp_TmLuO838UbMOdJKP25WBKsTJyAIy8,24341
8
+ lazysdk/lazyfile.py,sha256=fjwvPQorN7x4r1Yxkwuvq9XnzSopzXTmvz6Rf6NybFs,19861
9
9
  lazysdk/lazyflask.py,sha256=VUhJqtNz_evVyGOS40FKkkQWWrqGEUZ26cv1RQxS388,727
10
+ lazysdk/lazyhtml.py,sha256=vTtiLPoAhWMzXsDBFsF0DoFSsKbfmuEPjPMOZI_n6ag,1867
10
11
  lazysdk/lazyid.py,sha256=pEmRpN78-6vdz4hzLxgoCSHJw6gvnOVQyNjqusZZLQE,607
11
- lazysdk/lazyinfo.py,sha256=LyJGSkXL2WKk4elxaa-pe3yVUiUeEkfmzHzA8m9eFUg,1383
12
+ lazysdk/lazyinfo.py,sha256=P-oBYEImwdW6gm1lznk23dM0P5c5qsjapdVA1qL70D0,2398
12
13
  lazysdk/lazyip.py,sha256=zogsOp4uhtTnRLmV6nWDpKyk6BaID5GW5Op8iS1kaTs,1119
13
14
  lazysdk/lazym3u8.py,sha256=NrwEBpivhAxpW6KhKl7YowFBKGMpPxiKrcafgw7n8wY,31937
14
15
  lazysdk/lazymd5.py,sha256=JSKIcUmH2zwPDDJAd9XajTYd59eKidoKAkLLNU8OHM4,1112
@@ -25,7 +26,7 @@ lazysdk/lazyurl.py,sha256=lstEUph_OwvUgUFRthD0qgyZm0oNWW07rBSjTNRu0Q8,1091
25
26
  lazysdk/lazywebhook.py,sha256=HwJIZ5j3wUpnEfPkFY-Xq9T_9xdhCJ71dYsWNX22_3Y,8386
26
27
  lazysdk/lazywifi.py,sha256=FOvLPTcb6BQE6D8kjfB0TLpfgGxw8jqC3vZbTs6LbD4,716
27
28
  lazysdk/showdata.py,sha256=v9TrDWrLl0Fn2JzDzfiISYlZS3uumIXpm9Dpix2XAXg,1678
28
- lazysdk-0.1.58.dist-info/METADATA,sha256=TSHsWCRfETfuHJDT5AtNdiljpWwYikErXhuSJMj4AwM,1764
29
- lazysdk-0.1.58.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
30
- lazysdk-0.1.58.dist-info/top_level.txt,sha256=--bGS42ZHUhVeO83y1wfvKFg6OjkTLxQ4V4riqPQljY,8
31
- lazysdk-0.1.58.dist-info/RECORD,,
29
+ lazysdk-0.1.60.dist-info/METADATA,sha256=MnN24TWkEz7ZSxGuPM7KJmwCZ2LYLxG2kDjC7BJQtEA,1800
30
+ lazysdk-0.1.60.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
31
+ lazysdk-0.1.60.dist-info/top_level.txt,sha256=--bGS42ZHUhVeO83y1wfvKFg6OjkTLxQ4V4riqPQljY,8
32
+ lazysdk-0.1.60.dist-info/RECORD,,