knify 1.8.33__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.
knify-1.8.33/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 qicongsheng
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
knify-1.8.33/PKG-INFO ADDED
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 2.1
2
+ Name: knify
3
+ Version: 1.8.33
4
+ Summary: Development tools for python
5
+ Home-page: https://github.com/qicongsheng/knify
6
+ Author: qicongsheng
7
+ Author-email: qicongsheng@outlook.com
8
+ License: MIT License
9
+ Keywords: knify
10
+ Platform: any
11
+ License-File: LICENSE
12
+ Requires-Dist: loguru
13
+ Requires-Dist: urllib3
knify-1.8.33/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # knify
2
+
3
+ Development tools for python.
File without changes
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding:utf-8 -*-
3
+ # Author: qicongsheng
4
+ import datetime
5
+ import time
6
+
7
+ FORMAT_DATE_YYMMDD = "%Y-%m-%d"
8
+ FORMAT_DATE_HMS = "%H:%M:%S"
9
+ FORMAT_DATE_YYMMDDHMS = "%Y-%m-%d %H:%M:%S"
10
+ FORMAT_DATE_YYMMDDHMSF = "%Y-%m-%d %H:%M:%S.%f"
11
+
12
+
13
+ def now() -> datetime:
14
+ return datetime.datetime.now()
15
+
16
+
17
+ def date_to_str(date_obj: datetime, format: str = FORMAT_DATE_YYMMDDHMS) -> str:
18
+ if type(date_obj) == datetime.timedelta:
19
+ return (datetime.datetime(1970, 1, 1) + date_obj).strftime(format)
20
+ return date_obj.strftime(format)
21
+
22
+
23
+ def str_to_date(str_obj: str, format: str) -> datetime:
24
+ return datetime.datetime.strptime(str_obj, format)
25
+
26
+
27
+ def date_to_timestamp(date_obj: datetime):
28
+ return time.mktime(date_obj.timetuple())
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding:utf-8 -*-
3
+ # Author: qicongsheng
4
+
5
+ def get_pip_name():
6
+ return 'knify'
7
+
8
+
9
+ def get_version():
10
+ return '1.8.33'
11
+
12
+
13
+ def print_version():
14
+ print('''Knify %s
15
+ Development tools for python.''' % get_version())
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding:utf-8 -*-
3
+ # Author: qicongsheng
4
+
5
+ def partition(list_obj, partition_size):
6
+ return [list_obj[i:i + partition_size] for i in range(0, len(list_obj), partition_size)]
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding:utf-8 -*-
3
+ # Author: qicongsheng
4
+ import loguru
5
+
6
+ logger = loguru.logger.opt(depth=1)
7
+
8
+
9
+ def info(msg: str) -> None:
10
+ logger.info(msg)
11
+
12
+
13
+ def warn(msg: str) -> None:
14
+ logger.warning(msg)
15
+
16
+
17
+ def error(msg: str) -> None:
18
+ logger.error(msg)
19
+
20
+
21
+ def debug(msg: str) -> None:
22
+ logger.debug(msg)
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding:utf-8 -*-
3
+ # Author: qicongsheng
4
+ import datetime
5
+ import threading
6
+ import time
7
+
8
+ from . import dateutil
9
+ from . import listutil
10
+ from . import logger
11
+
12
+ task_lock = threading.Lock()
13
+ task_info = {'total': 0, 'processed': 0, 'time_start': None}
14
+
15
+
16
+ def print_task():
17
+ time_used = dateutil.now() - task_info['time_start']
18
+ time_estimate = datetime.timedelta(
19
+ seconds=time_used.total_seconds() * (task_info['total'] / task_info['processed']))
20
+ logger.info("Process: %.2f%% [%s/%s], Estimate: [%s/%s]" % (
21
+ task_info['processed'] / task_info['total'] * 100, task_info['processed'], task_info['total'],
22
+ dateutil.date_to_str(time_used, dateutil.FORMAT_DATE_HMS),
23
+ dateutil.date_to_str(time_estimate, dateutil.FORMAT_DATE_HMS)))
24
+
25
+
26
+ def func_wrapper(list_objs_: list, func_) -> None:
27
+ func_(list_objs_)
28
+ task_lock.acquire()
29
+ task_info['processed'] = task_info['processed'] + len(list_objs_)
30
+ task_lock.release()
31
+
32
+
33
+ def thread_partition_call(list_obj: list, func_, thread_num: int, partition_num: int) -> None:
34
+ list_partition = listutil.partition(list_obj, partition_num)
35
+ threads = []
36
+ logger.info("=================== start ===================")
37
+ task_info['total'] = len(list_obj)
38
+ task_info['time_start'] = dateutil.now()
39
+ for index_, list_for_process in enumerate(list_partition):
40
+ t = threading.Thread(target=func_wrapper, args=(list_for_process, func_))
41
+ t.start()
42
+ threads.append(t)
43
+ if len(threads) == thread_num or index_ == len(list_partition) - 1:
44
+ for t_ in threads:
45
+ t_.join()
46
+ threads = []
47
+ logger.info("=================== end ===================\r\n")
48
+ print_task()
49
+ if index_ < len(list_partition) - 1:
50
+ logger.info("=================== start ===================")
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding:utf-8 -*-
3
+ # Author: qicongsheng
4
+ import urllib3
5
+
6
+
7
+ def disable_ssl_warnings() -> None:
8
+ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 2.1
2
+ Name: knify
3
+ Version: 1.8.33
4
+ Summary: Development tools for python
5
+ Home-page: https://github.com/qicongsheng/knify
6
+ Author: qicongsheng
7
+ Author-email: qicongsheng@outlook.com
8
+ License: MIT License
9
+ Keywords: knify
10
+ Platform: any
11
+ License-File: LICENSE
12
+ Requires-Dist: loguru
13
+ Requires-Dist: urllib3
@@ -0,0 +1,15 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ knify/__init__.py
5
+ knify/dateutil.py
6
+ knify/help.py
7
+ knify/listutil.py
8
+ knify/logger.py
9
+ knify/threadutil.py
10
+ knify/warnutil.py
11
+ knify.egg-info/PKG-INFO
12
+ knify.egg-info/SOURCES.txt
13
+ knify.egg-info/dependency_links.txt
14
+ knify.egg-info/requires.txt
15
+ knify.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ loguru
2
+ urllib3
@@ -0,0 +1 @@
1
+ knify
knify-1.8.33/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
knify-1.8.33/setup.py ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding:utf-8 -*-
3
+ # Author: qicongsheng
4
+ from setuptools import setup, find_packages
5
+
6
+ from knify import help
7
+
8
+ setup(
9
+ name=help.get_pip_name(),
10
+ version=help.get_version(),
11
+ keywords=help.get_pip_name(),
12
+ description='Development tools for python',
13
+ license='MIT License',
14
+ url='https://github.com/qicongsheng/%s' % help.get_pip_name(),
15
+ author='qicongsheng',
16
+ author_email='qicongsheng@outlook.com',
17
+ packages=find_packages(),
18
+ include_package_data=True,
19
+ platforms='any',
20
+ install_requires=[
21
+ 'loguru',
22
+ 'urllib3'
23
+ ]
24
+ )