xlin 0.1.16__py2.py3-none-any.whl → 0.1.18__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 CHANGED
@@ -4,6 +4,7 @@ from .metric import *
4
4
  from .multiprocess_mapping import *
5
5
  from .read_as_dataframe import *
6
6
  from .statistic import *
7
+ from .timing import *
7
8
  from .util import *
8
9
  from .xls2xlsx import *
9
10
  from .yaml import *
xlin/read_as_dataframe.py CHANGED
@@ -162,7 +162,10 @@ def save_df(df: pd.DataFrame, output_filepath: Union[str, Path]):
162
162
 
163
163
 
164
164
  def lazy_build_dataframe(
165
- name: str, output_filepath: Path, func, filetype: str = "xlsx"
165
+ name: str,
166
+ output_filepath: Path,
167
+ func,
168
+ filetype: str = "xlsx",
166
169
  ):
167
170
  logger.info(name)
168
171
  output_filepath.parent.mkdir(parents=True, exist_ok=True)
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
 
xlin/xls2xlsx.py CHANGED
@@ -4,13 +4,13 @@ import os
4
4
  import pyexcel as p
5
5
 
6
6
 
7
- def convert_xls_dir_to_xlsx(data_dir):
7
+ def convert_xls_dir_to_xlsx(data_dir: str):
8
8
  filenames = os.listdir(data_dir)
9
9
  for filename in filenames:
10
10
  if filename.endswith(".xls"):
11
11
  convert_xls_to_xlsx(os.path.join(data_dir, filename))
12
12
 
13
- def convert_xls_to_xlsx(file_name):
13
+ def convert_xls_to_xlsx(file_name: str) -> str:
14
14
  converted_filename = file_name + 'x'
15
15
  if is_xslx(file_name):
16
16
  # rename to .xlsx
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 兮尘
3
+ Copyright (c) 2025 林学渊
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xlin
3
- Version: 0.1.16
3
+ Version: 0.1.18
4
4
  Summary: toolbox for LinXueyuan
5
5
  License: MIT
6
- Author: XiChen
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
@@ -0,0 +1,15 @@
1
+ xlin/__init__.py,sha256=MWWCNPgJFS_oV2US52ULa4yg4Ku61qjn40NVKqcp9-c,248
2
+ xlin/ischinese.py,sha256=Ia9IMQ6q-UHkdLwqS70L1fTnfSPbluFrv_I1UqsKquo,293
3
+ xlin/jsonl.py,sha256=DvVM241a9VgQlp5WIMPRv-JIolT0RdSxw47IG_fc7xE,6690
4
+ xlin/metric.py,sha256=N7wJ35y-C-IaBr1I1CJ_37lTG7gA69zmn9Xg6xSwKoI,1690
5
+ xlin/multiprocess_mapping.py,sha256=pmzyEUYpbpIZ_ezyvWWWRpr7D7n4t3E3jW1nGXBbVck,7652
6
+ xlin/read_as_dataframe.py,sha256=T8A4qk4Grof_WC_mNz4QVaWDQgJ103rUAQ8tsamm8SQ,8898
7
+ xlin/statistic.py,sha256=i0Z1gbW2IYHCA0lb16w1Ncrk0Q7Q1Ttm0n4we-ki6II,9301
8
+ xlin/timing.py,sha256=XMT8dMcMolOMohDvAZOIM_BAiPMREhGQKnO1kc5s6PU,998
9
+ xlin/util.py,sha256=TTWJaqF5D_r-gAZ_fj0kyHomvCagjwHXQZ2OPSgwd54,10976
10
+ xlin/xls2xlsx.py,sha256=uSmXcDvIhi5Sq0LGidMXy0wErNBXdjaoa6EftYVjTXs,947
11
+ xlin/yaml.py,sha256=kICi7G3Td5q2MaSXXt85qNTWoHMgjzt7pvn7r3C4dME,183
12
+ xlin-0.1.18.dist-info/LICENSE,sha256=60ys6rRtc1dZOP8UjSUr9fAqhZudT3WpKe5WbMCralM,1066
13
+ xlin-0.1.18.dist-info/METADATA,sha256=BWrBEOgAePxk0-vrjAgh2da_YA3HORi3awuFbZZbBUY,1098
14
+ xlin-0.1.18.dist-info/WHEEL,sha256=IrRNNNJ-uuL1ggO5qMvT1GGhQVdQU54d6ZpYqEZfEWo,92
15
+ xlin-0.1.18.dist-info/RECORD,,
@@ -1,14 +0,0 @@
1
- xlin/__init__.py,sha256=xH5nS8y2RhQ8IDMM2pVkD5W0lxEFuymUSpzSWKo-358,226
2
- xlin/ischinese.py,sha256=Ia9IMQ6q-UHkdLwqS70L1fTnfSPbluFrv_I1UqsKquo,293
3
- xlin/jsonl.py,sha256=DvVM241a9VgQlp5WIMPRv-JIolT0RdSxw47IG_fc7xE,6690
4
- xlin/metric.py,sha256=N7wJ35y-C-IaBr1I1CJ_37lTG7gA69zmn9Xg6xSwKoI,1690
5
- xlin/multiprocess_mapping.py,sha256=pmzyEUYpbpIZ_ezyvWWWRpr7D7n4t3E3jW1nGXBbVck,7652
6
- xlin/read_as_dataframe.py,sha256=P8bOYW-zm8uGhehCldZI9ZQhHHLGqDPDbSMNWI2li6g,8885
7
- xlin/statistic.py,sha256=i0Z1gbW2IYHCA0lb16w1Ncrk0Q7Q1Ttm0n4we-ki6II,9301
8
- xlin/util.py,sha256=RJHMBKC1xVwso3NfYXxIY3qqAfahzDDgzuU7jvNhQBA,10494
9
- xlin/xls2xlsx.py,sha256=5zfcM0gmunFQOcOj9nYd9Dj0HMhU7-cPKnPIy6Ot9iU,930
10
- xlin/yaml.py,sha256=kICi7G3Td5q2MaSXXt85qNTWoHMgjzt7pvn7r3C4dME,183
11
- xlin-0.1.16.dist-info/LICENSE,sha256=KX0dDCYlO4DskqMZY8qeY94EZMrDRNnNqlGLkXVlKyM,1063
12
- xlin-0.1.16.dist-info/METADATA,sha256=Yt2LF4GpTonDmVqlIFEhLj22AATSgC0k773Zrb3rcLs,1089
13
- xlin-0.1.16.dist-info/WHEEL,sha256=IrRNNNJ-uuL1ggO5qMvT1GGhQVdQU54d6ZpYqEZfEWo,92
14
- xlin-0.1.16.dist-info/RECORD,,
File without changes