knify 1.8.56__tar.gz → 1.8.58__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: knify
3
- Version: 1.8.56
3
+ Version: 1.8.58
4
4
  Summary: Development tools for python
5
5
  Home-page: https://github.com/qicongsheng/knify
6
6
  Author: qicongsheng
@@ -46,11 +46,12 @@ class HeaderBuilder:
46
46
  return self.headers
47
47
 
48
48
 
49
- def read_excel(file_path: str, sheet: str | int | None = 0, headers: list[Header] | None = None, start_row: int = 1):
49
+ def read_excel(file_path: str, sheet: str | int | None = 0, headers: list[Header] | None = None, start_row: int = 1,
50
+ header_row: int = 0) -> list[object]:
50
51
  results = []
51
52
  workbook = load_workbook(filename=file_path)
52
53
  sheet_ = workbook[sheet] if isinstance(sheet, str) else workbook[workbook.sheetnames[sheet]]
53
- headers_ = [cell.value for cell in sheet_[start_row]]
54
+ headers_ = [cell.value for cell in sheet_[header_row + 1]]
54
55
  for row_idx, row in enumerate(sheet_.rows):
55
56
  if row_idx < start_row:
56
57
  continue
@@ -8,7 +8,7 @@ def get_pip_name():
8
8
 
9
9
 
10
10
  def get_version():
11
- return '1.8.56'
11
+ return '1.8.58'
12
12
 
13
13
 
14
14
  def print_version():
@@ -1,12 +1,21 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  # Author: qicongsheng
4
+ from collections import defaultdict
5
+ from typing import Callable
4
6
 
5
7
 
6
- def partition(list_obj: list, partition_size):
8
+ def partition(list_obj: list, partition_size: int) -> list[object]:
7
9
  return [list_obj[i:i + partition_size] for i in range(0, len(list_obj), partition_size)]
8
10
 
9
11
 
12
+ def groupby(list_obj: list, key: Callable[[object], object], value: Callable[[object], object] = lambda v_: v_):
13
+ grouped = defaultdict(list)
14
+ for obj in list_obj:
15
+ grouped[key(obj)].append(value(obj))
16
+ return grouped
17
+
18
+
10
19
  def is_empty(list_obj: list):
11
20
  return list_obj is None or len(list_obj) == 0
12
21
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: knify
3
- Version: 1.8.56
3
+ Version: 1.8.58
4
4
  Summary: Development tools for python
5
5
  Home-page: https://github.com/qicongsheng/knify
6
6
  Author: qicongsheng
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