nlpertools 1.0.9__tar.gz → 1.0.11__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.
- {nlpertools-1.0.9/src/nlpertools.egg-info → nlpertools-1.0.11}/PKG-INFO +27 -25
- {nlpertools-1.0.9 → nlpertools-1.0.11}/README.md +23 -23
- {nlpertools-1.0.9 → nlpertools-1.0.11}/setup.py +8 -10
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/__init__.py +3 -2
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/cli.py +26 -47
- nlpertools-1.0.11/src/nlpertools/dataprocess/__init__.py +1 -0
- nlpertools-1.0.11/src/nlpertools/dataprocess/dedupl.py +9 -0
- nlpertools-1.0.9/src/nlpertools/dataprocess.py → nlpertools-1.0.11/src/nlpertools/dataprocess/dp_main.py +13 -1
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/io/dir.py +25 -5
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/io/file.py +46 -43
- nlpertools-1.0.11/src/nlpertools/llm/__init__.py +3 -0
- nlpertools-1.0.11/src/nlpertools/llm/call_llm_once.py +60 -0
- nlpertools-1.0.11/src/nlpertools/llm/infer.py +119 -0
- nlpertools-1.0.11/src/nlpertools/llm/price.py +13 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/ml.py +72 -59
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/other.py +82 -53
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/utils/package.py +9 -10
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/wrapper.py +6 -4
- {nlpertools-1.0.9 → nlpertools-1.0.11/src/nlpertools.egg-info}/PKG-INFO +27 -25
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools.egg-info/SOURCES.txt +7 -1
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools.egg-info/requires.txt +1 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/LICENSE +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/pyproject.toml +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/setup.cfg +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/algo/__init__.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/algo/ac.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/algo/bit_ops.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/algo/kmp.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/algo/num_ops.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/algo/template.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/algo/union.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/data_client.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/data_structure/__init__.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/data_structure/base_structure.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/default_db_config.yml +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/draw/__init__.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/draw/draw.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/draw/math_func.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/get_2fa.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/io/__init__.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/monitor/__init__.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/monitor/gpu.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/monitor/memory.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/movie.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/nlpertools_config.yml +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/open_api.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/pic.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/plugin.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/reminder.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/template/__init__.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/utils/__init__.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/utils/lazy.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/utils/log_util.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/utils/package_v1.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/utils/package_v2.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/utils_for_nlpertools.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools/vector_index_demo.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools.egg-info/dependency_links.txt +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools.egg-info/entry_points.txt +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools.egg-info/top_level.txt +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/src/nlpertools_helper/__init__.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/tests/test_kmp.py +0 -0
- {nlpertools-1.0.9 → nlpertools-1.0.11}/tests/test_path_exists.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: nlpertools
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.11
|
4
4
|
Summary: A small package about small basic IO operation when coding
|
5
5
|
Home-page: https://github.com/lvzii/nlpertools
|
6
6
|
Author: youshuJi
|
@@ -15,8 +15,10 @@ License-File: LICENSE
|
|
15
15
|
Requires-Dist: numpy
|
16
16
|
Requires-Dist: pandas
|
17
17
|
Requires-Dist: psutil
|
18
|
+
Requires-Dist: openai
|
18
19
|
Provides-Extra: torch
|
19
20
|
Requires-Dist: torch; extra == "torch"
|
21
|
+
Dynamic: license-file
|
20
22
|
Dynamic: provides-extra
|
21
23
|
Dynamic: requires-dist
|
22
24
|
|
@@ -50,6 +52,25 @@ nlpertools
|
|
50
52
|
|
51
53
|
```
|
52
54
|
|
55
|
+
# 最常用/喜欢的功能(使用示例)
|
56
|
+
```python
|
57
|
+
# 读txt, json文件
|
58
|
+
import nlpertools
|
59
|
+
|
60
|
+
txt_data = nlpertools.readtxt_list_all_strip('res.txt')
|
61
|
+
json_data = nlpertools.load_from_json('res.json')
|
62
|
+
```
|
63
|
+
|
64
|
+
```bash
|
65
|
+
## git, 连接github不稳定的时候非常有用
|
66
|
+
ncli git pull
|
67
|
+
## 带有参数时,加上--以避免-u被解析
|
68
|
+
ncli -- git push -u origin main
|
69
|
+
|
70
|
+
# 生成pypi双因素认证的实时密钥(需要提供key)
|
71
|
+
ncli --get_2fa --get_2fa_key your_key
|
72
|
+
```
|
73
|
+
|
53
74
|
# 安装
|
54
75
|
|
55
76
|
Install the latest release version
|
@@ -101,30 +122,7 @@ https://nlpertools.readthedocs.io/en/latest/
|
|
101
122
|
|
102
123
|
一些可能需要配置才能用的函数,写上示例
|
103
124
|
|
104
|
-
## 使用示例
|
105
|
-
|
106
|
-
```python
|
107
|
-
import nlpertools
|
108
|
-
|
109
|
-
a = nlpertools.readtxt_list_all_strip('res.txt')
|
110
|
-
# 或
|
111
|
-
b = nlpertools.io.file.readtxt_list_all_strip('res.txt')
|
112
|
-
```
|
113
125
|
|
114
|
-
```bash
|
115
|
-
# 生成pypi双因素认证的实时密钥(需要提供key)
|
116
|
-
python -m nlpertools.cli --get_2fa --get_2fa_key your_key
|
117
|
-
|
118
|
-
## git
|
119
|
-
python -m nlpertools.cli --git_push
|
120
|
-
python -m nlpertools.cli --git_pull
|
121
|
-
|
122
|
-
# 以下功能被nvitop替代,不推荐使用
|
123
|
-
## 监控gpu显存
|
124
|
-
python -m nlpertools.monitor.gpu
|
125
|
-
## 监控cpu
|
126
|
-
python -m nlpertools.monitor.memory
|
127
|
-
```
|
128
126
|
|
129
127
|
## 一些常用项目
|
130
128
|
|
@@ -132,3 +130,7 @@ nvitop
|
|
132
130
|
|
133
131
|
ydata-profiling
|
134
132
|
|
133
|
+
## 贡献
|
134
|
+
|
135
|
+
https://github.com/bigscience-workshop/data-preparation
|
136
|
+
|
@@ -28,6 +28,25 @@ nlpertools
|
|
28
28
|
|
29
29
|
```
|
30
30
|
|
31
|
+
# 最常用/喜欢的功能(使用示例)
|
32
|
+
```python
|
33
|
+
# 读txt, json文件
|
34
|
+
import nlpertools
|
35
|
+
|
36
|
+
txt_data = nlpertools.readtxt_list_all_strip('res.txt')
|
37
|
+
json_data = nlpertools.load_from_json('res.json')
|
38
|
+
```
|
39
|
+
|
40
|
+
```bash
|
41
|
+
## git, 连接github不稳定的时候非常有用
|
42
|
+
ncli git pull
|
43
|
+
## 带有参数时,加上--以避免-u被解析
|
44
|
+
ncli -- git push -u origin main
|
45
|
+
|
46
|
+
# 生成pypi双因素认证的实时密钥(需要提供key)
|
47
|
+
ncli --get_2fa --get_2fa_key your_key
|
48
|
+
```
|
49
|
+
|
31
50
|
# 安装
|
32
51
|
|
33
52
|
Install the latest release version
|
@@ -79,30 +98,7 @@ https://nlpertools.readthedocs.io/en/latest/
|
|
79
98
|
|
80
99
|
一些可能需要配置才能用的函数,写上示例
|
81
100
|
|
82
|
-
## 使用示例
|
83
|
-
|
84
|
-
```python
|
85
|
-
import nlpertools
|
86
|
-
|
87
|
-
a = nlpertools.readtxt_list_all_strip('res.txt')
|
88
|
-
# 或
|
89
|
-
b = nlpertools.io.file.readtxt_list_all_strip('res.txt')
|
90
|
-
```
|
91
101
|
|
92
|
-
```bash
|
93
|
-
# 生成pypi双因素认证的实时密钥(需要提供key)
|
94
|
-
python -m nlpertools.cli --get_2fa --get_2fa_key your_key
|
95
|
-
|
96
|
-
## git
|
97
|
-
python -m nlpertools.cli --git_push
|
98
|
-
python -m nlpertools.cli --git_pull
|
99
|
-
|
100
|
-
# 以下功能被nvitop替代,不推荐使用
|
101
|
-
## 监控gpu显存
|
102
|
-
python -m nlpertools.monitor.gpu
|
103
|
-
## 监控cpu
|
104
|
-
python -m nlpertools.monitor.memory
|
105
|
-
```
|
106
102
|
|
107
103
|
## 一些常用项目
|
108
104
|
|
@@ -110,3 +106,7 @@ nvitop
|
|
110
106
|
|
111
107
|
ydata-profiling
|
112
108
|
|
109
|
+
## 贡献
|
110
|
+
|
111
|
+
https://github.com/bigscience-workshop/data-preparation
|
112
|
+
|
@@ -7,19 +7,17 @@ from setuptools import setup
|
|
7
7
|
def get_version():
|
8
8
|
with open(os.path.join("src", "nlpertools", "__init__.py"), "r", encoding="utf-8") as f:
|
9
9
|
file_content = f.read()
|
10
|
-
pattern = r"{}\W*=\W
|
11
|
-
|
12
|
-
|
10
|
+
pattern = r"{}\W*=\W*[\"']([^\"']+)[\"']".format("__version__")
|
11
|
+
matches = re.findall(pattern, file_content)
|
12
|
+
if not matches:
|
13
|
+
raise ValueError(f"Could not find __version__ in __init__.py")
|
14
|
+
return matches[0]
|
13
15
|
|
14
16
|
|
15
17
|
def main():
|
16
18
|
setup(
|
17
19
|
# https://juejin.cn/post/7369349560421040128
|
18
|
-
install_requires=[
|
19
|
-
"numpy",
|
20
|
-
"pandas",
|
21
|
-
"psutil"
|
22
|
-
],
|
20
|
+
install_requires=["numpy", "pandas", "psutil", "openai"],
|
23
21
|
extras_require={
|
24
22
|
"torch": ["torch"],
|
25
23
|
},
|
@@ -28,9 +26,9 @@ def main():
|
|
28
26
|
"console_scripts": [
|
29
27
|
"ncli=nlpertools.cli:main",
|
30
28
|
]
|
31
|
-
}
|
29
|
+
},
|
32
30
|
)
|
33
31
|
|
34
32
|
|
35
|
-
if __name__ ==
|
33
|
+
if __name__ == "__main__":
|
36
34
|
main()
|
@@ -4,6 +4,7 @@
|
|
4
4
|
from .algo.kmp import *
|
5
5
|
from .data_structure.base_structure import *
|
6
6
|
from .draw import *
|
7
|
+
from .dataprocess.dp_main import *
|
7
8
|
from .dataprocess import *
|
8
9
|
from .io.dir import *
|
9
10
|
from .io.file import *
|
@@ -17,7 +18,7 @@ from .utils_for_nlpertools import *
|
|
17
18
|
from .wrapper import *
|
18
19
|
from .monitor import *
|
19
20
|
from .cli import *
|
21
|
+
from .llm import *
|
20
22
|
|
21
23
|
|
22
|
-
|
23
|
-
__version__ = '1.0.9'
|
24
|
+
__version__ = "1.0.11"
|
@@ -2,45 +2,30 @@ import argparse
|
|
2
2
|
import os
|
3
3
|
import uuid
|
4
4
|
import sys
|
5
|
+
from .dataprocess.dp_main import startwith
|
5
6
|
|
6
|
-
"""
|
7
|
-
如何Debug cli.py
|
8
|
-
"""
|
9
7
|
|
10
|
-
|
11
|
-
def git_push():
|
12
|
-
"""
|
13
|
-
针对国内提交github经常失败,自动提交
|
14
|
-
"""
|
15
|
-
num = -1
|
16
|
-
while 1:
|
17
|
-
num += 1
|
18
|
-
print("retry num: {}".format(num))
|
19
|
-
info = os.system("git push --set-upstream origin main")
|
20
|
-
print(str(info))
|
21
|
-
if not str(info).startswith("fatal"):
|
22
|
-
print("scucess")
|
23
|
-
break
|
24
|
-
|
25
|
-
|
26
|
-
def git_pull():
|
8
|
+
def run_git_command(command):
|
27
9
|
"""
|
28
|
-
|
10
|
+
循环执行git命令,直到成功
|
29
11
|
"""
|
12
|
+
print(command)
|
30
13
|
num = -1
|
31
|
-
while
|
14
|
+
while True:
|
32
15
|
num += 1
|
33
|
-
print("retry num: {}"
|
34
|
-
info = os.system(
|
16
|
+
print(f"retry num: {num}")
|
17
|
+
info = os.system(command)
|
35
18
|
print(str(info))
|
36
|
-
|
37
|
-
|
19
|
+
# 检查命令执行结果,若未出现错误则认为执行成功
|
20
|
+
if (not startwith(str(info), ["fatal", "error", "128", "1"])) and "fatal" not in str(info):
|
21
|
+
print("success")
|
22
|
+
print(f"success info : ##{info}##")
|
38
23
|
break
|
39
24
|
|
40
25
|
|
41
26
|
def get_mac_address():
|
42
27
|
mac = uuid.UUID(int=uuid.getnode()).hex[-12:]
|
43
|
-
mac_address = ":".join([mac[e:e + 2] for e in range(0, 11, 2)])
|
28
|
+
mac_address = ":".join([mac[e : e + 2] for e in range(0, 11, 2)])
|
44
29
|
print("mac address 不一定准确")
|
45
30
|
print(mac_address)
|
46
31
|
return mac_address
|
@@ -48,6 +33,7 @@ def get_mac_address():
|
|
48
33
|
|
49
34
|
def get_2af_value(key):
|
50
35
|
import pyotp
|
36
|
+
|
51
37
|
"""
|
52
38
|
key应该是7位的
|
53
39
|
"""
|
@@ -80,15 +66,11 @@ def start_gpu_usage_notify_client():
|
|
80
66
|
from plyer import notification
|
81
67
|
import time
|
82
68
|
|
83
|
-
SERVER_URL =
|
69
|
+
SERVER_URL = "http://127.0.0.1:5000/notify" # 服务器的 API 地址
|
84
70
|
|
85
71
|
def notify(text):
|
86
72
|
# 使用 plyer 发送通知
|
87
|
-
notification.notify(
|
88
|
-
title='远程通知',
|
89
|
-
message=text,
|
90
|
-
timeout=10 # 10秒的通知显示时间
|
91
|
-
)
|
73
|
+
notification.notify(title="远程通知", message=text, timeout=10) # 10秒的通知显示时间
|
92
74
|
|
93
75
|
"""定时轮询服务器获取通知"""
|
94
76
|
while True:
|
@@ -108,22 +90,19 @@ def start_gpu_usage_notify_client():
|
|
108
90
|
|
109
91
|
|
110
92
|
def main():
|
111
|
-
parser = argparse.ArgumentParser(description="CLI tool for git operations and
|
112
|
-
parser.add_argument(
|
113
|
-
parser.add_argument(
|
114
|
-
parser.add_argument(
|
115
|
-
|
116
|
-
parser.add_argument(
|
117
|
-
parser.add_argument(
|
118
|
-
parser.add_argument('--monitor_gpu_cli', action='store_true', help='Get the 2fa value.')
|
119
|
-
parser.add_argument('--monitor_gpu_ser', action='store_true', help='Get the 2fa value.')
|
93
|
+
parser = argparse.ArgumentParser(description="CLI tool for git operations and other functions.")
|
94
|
+
parser.add_argument("git_command", nargs="*", help="Any git command (e.g., push, pull)")
|
95
|
+
parser.add_argument("--mac_address", action="store_true", help="Get the MAC address.")
|
96
|
+
parser.add_argument("--get_2fa", action="store_true", help="Get the 2fa value.")
|
97
|
+
parser.add_argument("--get_2fa_key", type=str, help="Get the 2fa value.")
|
98
|
+
parser.add_argument("--monitor_gpu_cli", action="store_true", help="monitor gpu cli")
|
99
|
+
parser.add_argument("--monitor_gpu_ser", action="store_true", help="monitor gpu ser")
|
120
100
|
|
121
101
|
args = parser.parse_args()
|
122
102
|
|
123
|
-
if args.
|
124
|
-
|
125
|
-
|
126
|
-
git_pull()
|
103
|
+
if args.git_command:
|
104
|
+
git_cmd = " ".join(args.git_command)
|
105
|
+
run_git_command(git_cmd)
|
127
106
|
elif args.mac_address:
|
128
107
|
get_mac_address()
|
129
108
|
elif args.monitor_gpu_cli:
|
@@ -139,5 +118,5 @@ def main():
|
|
139
118
|
print("No operation specified.")
|
140
119
|
|
141
120
|
|
142
|
-
if __name__ ==
|
121
|
+
if __name__ == "__main__":
|
143
122
|
main()
|
@@ -0,0 +1 @@
|
|
1
|
+
from .dedupl import *
|
@@ -8,7 +8,7 @@ from typing import List
|
|
8
8
|
import numpy as np
|
9
9
|
|
10
10
|
# from . import DB_CONFIG_FILE # cannot import name 'DB_CONFIG_FILE' from partially initialized module 'nlpertools'
|
11
|
-
from
|
11
|
+
from ..utils.package import *
|
12
12
|
|
13
13
|
main_special_characters = string.punctuation + string.digits + string.whitespace
|
14
14
|
other_special_characters = (
|
@@ -19,6 +19,18 @@ other_special_characters = (
|
|
19
19
|
"」﴾》"
|
20
20
|
)
|
21
21
|
|
22
|
+
def startwith(text: str, pattern_list: list) -> bool:
|
23
|
+
"""
|
24
|
+
判断text是否以pattern_list中的某个pattern开头
|
25
|
+
:param text:
|
26
|
+
:param pattern_list:
|
27
|
+
:return:
|
28
|
+
"""
|
29
|
+
for pattern in pattern_list:
|
30
|
+
if text.startswith(pattern):
|
31
|
+
return True
|
32
|
+
return False
|
33
|
+
|
22
34
|
|
23
35
|
class Pattern:
|
24
36
|
"""
|
@@ -3,6 +3,7 @@
|
|
3
3
|
# @Author : youshu.Ji
|
4
4
|
import os
|
5
5
|
from pathlib import Path
|
6
|
+
from typing import overload,Literal,Union
|
6
7
|
|
7
8
|
|
8
9
|
# dir ----------------------------------------------------------------------
|
@@ -45,15 +46,34 @@ def get_filename(path, suffix=True) -> str:
|
|
45
46
|
filename = filename.split('.')[0]
|
46
47
|
return filename
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
"""
|
50
|
+
因为os.listdir无法支持Path类型,虽然是bytelikepath,但是传入Path后只会返回字符串
|
51
|
+
且无法只返回文件名
|
52
|
+
故重新实现
|
53
|
+
"""
|
54
|
+
@overload
|
55
|
+
def listdir(dir_name: Path, including_dir: Literal[True]) -> list[Path]: ...
|
56
|
+
@overload
|
57
|
+
def listdir(dir_name: str, including_dir: Literal[True]) -> list[str]: ...
|
58
|
+
@overload
|
59
|
+
def listdir(dir_name: Path, including_dir: Literal[False] = False) -> list[str]: ...
|
60
|
+
@overload
|
61
|
+
def listdir(dir_name: str, including_dir: Literal[False] = False) -> list[str]: ...
|
62
|
+
|
63
|
+
def listdir(dir_name: Union[Path, str], including_dir: bool = False) -> list[Path] | list[str]:
|
64
|
+
"""
|
65
|
+
including_dir=True -> list[Path] or list[str]
|
66
|
+
including_dir=False -> list[str]
|
67
|
+
"""
|
68
|
+
filenames = os.listdir(str(dir_name))
|
51
69
|
if including_dir:
|
52
|
-
|
70
|
+
if isinstance(dir_name, Path):
|
71
|
+
return [dir_name / filename for filename in filenames]
|
72
|
+
else:
|
73
|
+
return [os.path.join(dir_name, filename) for filename in filenames]
|
53
74
|
else:
|
54
75
|
return list(filenames)
|
55
76
|
|
56
|
-
|
57
77
|
def listdir_yield(dir_name, including_dir=True):
|
58
78
|
filenames = os.listdir(dir_name)
|
59
79
|
for filename in filenames:
|