xlin 0.1.16__py2.py3-none-any.whl → 0.1.17__py2.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.
- xlin/__init__.py +1 -0
- xlin/timing.py +43 -0
- xlin/util.py +9 -1
- {xlin-0.1.16.dist-info → xlin-0.1.17.dist-info}/LICENSE +1 -1
- {xlin-0.1.16.dist-info → xlin-0.1.17.dist-info}/METADATA +2 -2
- {xlin-0.1.16.dist-info → xlin-0.1.17.dist-info}/RECORD +7 -6
- {xlin-0.1.16.dist-info → xlin-0.1.17.dist-info}/WHEEL +0 -0
xlin/__init__.py
CHANGED
xlin/timing.py
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
from timeit import default_timer as timer
|
2
|
+
from functools import wraps
|
3
|
+
import time
|
4
|
+
|
5
|
+
|
6
|
+
class Benchmark(object):
|
7
|
+
|
8
|
+
def __init__(self, msg, fmt="%0.3g"):
|
9
|
+
self.msg = msg
|
10
|
+
self.fmt = fmt
|
11
|
+
|
12
|
+
def __enter__(self):
|
13
|
+
self.start = timer()
|
14
|
+
return self
|
15
|
+
|
16
|
+
def __exit__(self, *args):
|
17
|
+
t = timer() - self.start
|
18
|
+
print(("%s : " + self.fmt + " seconds") % (self.msg, t))
|
19
|
+
self.time = t
|
20
|
+
|
21
|
+
|
22
|
+
def timing(f):
|
23
|
+
@wraps(f)
|
24
|
+
def wrap(*args, **kw):
|
25
|
+
ts = time.time()
|
26
|
+
result = f(*args, **kw)
|
27
|
+
te = time.time()
|
28
|
+
print(f'func:{f.__name__!r} args:[{args!r}, {kw!r}] took: {te - ts:2.4f} sec')
|
29
|
+
return result
|
30
|
+
|
31
|
+
return wrap
|
32
|
+
|
33
|
+
|
34
|
+
class Timer:
|
35
|
+
""" Simple block which can be called as a context, to know the time of a block. """
|
36
|
+
|
37
|
+
def __enter__(self):
|
38
|
+
self.start = time.perf_counter()
|
39
|
+
return self
|
40
|
+
|
41
|
+
def __exit__(self, *args):
|
42
|
+
self.end = time.perf_counter()
|
43
|
+
self.interval = self.end - self.start
|
xlin/util.py
CHANGED
@@ -133,10 +133,18 @@ def cp(
|
|
133
133
|
base_input_dir = input_paths[0].parent
|
134
134
|
base_input_dir = Path(base_input_dir)
|
135
135
|
output_dir_path = Path(output_dir_path)
|
136
|
+
if output_dir_path.exists() and not output_dir_path.is_dir():
|
137
|
+
raise Exception(f"output_dir_path exists and is not a directory: {output_dir_path}")
|
138
|
+
if not output_dir_path.exists():
|
139
|
+
output_dir_path.mkdir(parents=True, exist_ok=True)
|
140
|
+
logger.warning(f"创建文件夹 {output_dir_path}")
|
141
|
+
if not base_input_dir.exists():
|
142
|
+
raise Exception(f"base_input_dir does not exist: {base_input_dir}")
|
143
|
+
if not base_input_dir.is_dir():
|
144
|
+
raise Exception(f"base_input_dir is not a directory: {base_input_dir}")
|
136
145
|
for input_path in input_paths:
|
137
146
|
relative_path = input_path.relative_to(base_input_dir)
|
138
147
|
output_path = output_dir_path / relative_path
|
139
|
-
output_path.parent.mkdir(parents=True, exist_ok=True)
|
140
148
|
copy_file(input_path, output_path, force_overwrite, verbose)
|
141
149
|
|
142
150
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: xlin
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.17
|
4
4
|
Summary: toolbox for LinXueyuan
|
5
5
|
License: MIT
|
6
|
-
Author:
|
6
|
+
Author: LinXueyuanStdio
|
7
7
|
Author-email: 23211526+LinXueyuanStdio@users.noreply.github.com
|
8
8
|
Classifier: License :: OSI Approved :: MIT License
|
9
9
|
Classifier: Programming Language :: Python :: 2
|
@@ -1,14 +1,15 @@
|
|
1
|
-
xlin/__init__.py,sha256=
|
1
|
+
xlin/__init__.py,sha256=MWWCNPgJFS_oV2US52ULa4yg4Ku61qjn40NVKqcp9-c,248
|
2
2
|
xlin/ischinese.py,sha256=Ia9IMQ6q-UHkdLwqS70L1fTnfSPbluFrv_I1UqsKquo,293
|
3
3
|
xlin/jsonl.py,sha256=DvVM241a9VgQlp5WIMPRv-JIolT0RdSxw47IG_fc7xE,6690
|
4
4
|
xlin/metric.py,sha256=N7wJ35y-C-IaBr1I1CJ_37lTG7gA69zmn9Xg6xSwKoI,1690
|
5
5
|
xlin/multiprocess_mapping.py,sha256=pmzyEUYpbpIZ_ezyvWWWRpr7D7n4t3E3jW1nGXBbVck,7652
|
6
6
|
xlin/read_as_dataframe.py,sha256=P8bOYW-zm8uGhehCldZI9ZQhHHLGqDPDbSMNWI2li6g,8885
|
7
7
|
xlin/statistic.py,sha256=i0Z1gbW2IYHCA0lb16w1Ncrk0Q7Q1Ttm0n4we-ki6II,9301
|
8
|
-
xlin/
|
8
|
+
xlin/timing.py,sha256=XMT8dMcMolOMohDvAZOIM_BAiPMREhGQKnO1kc5s6PU,998
|
9
|
+
xlin/util.py,sha256=TTWJaqF5D_r-gAZ_fj0kyHomvCagjwHXQZ2OPSgwd54,10976
|
9
10
|
xlin/xls2xlsx.py,sha256=5zfcM0gmunFQOcOj9nYd9Dj0HMhU7-cPKnPIy6Ot9iU,930
|
10
11
|
xlin/yaml.py,sha256=kICi7G3Td5q2MaSXXt85qNTWoHMgjzt7pvn7r3C4dME,183
|
11
|
-
xlin-0.1.
|
12
|
-
xlin-0.1.
|
13
|
-
xlin-0.1.
|
14
|
-
xlin-0.1.
|
12
|
+
xlin-0.1.17.dist-info/LICENSE,sha256=60ys6rRtc1dZOP8UjSUr9fAqhZudT3WpKe5WbMCralM,1066
|
13
|
+
xlin-0.1.17.dist-info/METADATA,sha256=Lg-wFcZRx0nvtw2tvaB6HCrLrPjRYnVELCp1Duz_IKI,1098
|
14
|
+
xlin-0.1.17.dist-info/WHEEL,sha256=IrRNNNJ-uuL1ggO5qMvT1GGhQVdQU54d6ZpYqEZfEWo,92
|
15
|
+
xlin-0.1.17.dist-info/RECORD,,
|
File without changes
|