toolbox-utils 5.0.8__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.
- toolbox_utils/__init__.py +0 -0
- toolbox_utils/readers/__init__.py +0 -0
- toolbox_utils/readers/hbn.py +392 -0
- toolbox_utils/readers/plotgen.py +55 -0
- toolbox_utils/readers/wdm.py +233 -0
- toolbox_utils/tssplit/setup.py +38 -0
- toolbox_utils/tssplit/tssplit/__init__.py +1 -0
- toolbox_utils/tssplit/tssplit/tssplit.py +45 -0
- toolbox_utils/tsutils.py +2638 -0
- toolbox_utils-5.0.8.dist-info/LICENSE.txt +27 -0
- toolbox_utils-5.0.8.dist-info/METADATA +117 -0
- toolbox_utils-5.0.8.dist-info/RECORD +14 -0
- toolbox_utils-5.0.8.dist-info/WHEEL +5 -0
- toolbox_utils-5.0.8.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from setuptools import setup
|
|
2
|
+
|
|
3
|
+
with open("README.md", "r") as fh:
|
|
4
|
+
long_description = fh.read()
|
|
5
|
+
|
|
6
|
+
setup(
|
|
7
|
+
name="tssplit",
|
|
8
|
+
version="1.0.6",
|
|
9
|
+
py_modules=["tssplit.tssplit"],
|
|
10
|
+
url="https://github.com/mezantrop/tssplit",
|
|
11
|
+
license="bsd-2-clause",
|
|
12
|
+
author="Mikhail Zakharov",
|
|
13
|
+
author_email="zmey20000@yahoo.com",
|
|
14
|
+
description="Trivial split for strings with quotes and escaped characters",
|
|
15
|
+
long_description=long_description,
|
|
16
|
+
long_description_content_type="text/markdown",
|
|
17
|
+
classifiers=[
|
|
18
|
+
"License :: OSI Approved :: BSD License",
|
|
19
|
+
"Development Status :: 5 - Production/Stable",
|
|
20
|
+
"Intended Audience :: Developers",
|
|
21
|
+
"Operating System :: OS Independent",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Topic :: Software Development",
|
|
24
|
+
"Topic :: Text Processing",
|
|
25
|
+
"Topic :: Text Processing :: Filters",
|
|
26
|
+
"Topic :: Text Processing :: General",
|
|
27
|
+
],
|
|
28
|
+
keywords=[
|
|
29
|
+
"split",
|
|
30
|
+
"parse",
|
|
31
|
+
"quote",
|
|
32
|
+
"trim",
|
|
33
|
+
"strip",
|
|
34
|
+
"string",
|
|
35
|
+
"delimiter",
|
|
36
|
+
"separator",
|
|
37
|
+
],
|
|
38
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .tssplit import tssplit
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
def tssplit(
|
|
2
|
+
s, quote="\"'", quote_keep=False, delimiter=":;,", escape="/^", trim="", remark="#"
|
|
3
|
+
):
|
|
4
|
+
"""Split a string by delimiters with quotes and escaped characters, optionally trimming results
|
|
5
|
+
|
|
6
|
+
:param s: A string to split into chunks
|
|
7
|
+
:param quote: Quote chars to protect a part of s from parsing
|
|
8
|
+
:param quote_keep: Preserve quote characters in the output or not
|
|
9
|
+
:param delimiter: A chunk separator character
|
|
10
|
+
:param escape: An escape character
|
|
11
|
+
:param trim: Trim characters from chunks
|
|
12
|
+
:param remark: Ignore all characters after remark sign
|
|
13
|
+
:return: A list of chunks
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
in_quotes = in_escape = False
|
|
17
|
+
token = ""
|
|
18
|
+
result = []
|
|
19
|
+
|
|
20
|
+
for c in s:
|
|
21
|
+
if in_escape:
|
|
22
|
+
token += c
|
|
23
|
+
in_escape = False
|
|
24
|
+
elif c in escape:
|
|
25
|
+
in_escape = True
|
|
26
|
+
if in_quotes:
|
|
27
|
+
token += c
|
|
28
|
+
elif c in quote:
|
|
29
|
+
in_quotes = not in_quotes
|
|
30
|
+
if quote_keep:
|
|
31
|
+
token += c
|
|
32
|
+
elif c in delimiter and not in_quotes:
|
|
33
|
+
if trim:
|
|
34
|
+
token = token.strip(trim)
|
|
35
|
+
result.append(token)
|
|
36
|
+
token = ""
|
|
37
|
+
elif c in remark:
|
|
38
|
+
break
|
|
39
|
+
else:
|
|
40
|
+
token += c
|
|
41
|
+
|
|
42
|
+
if trim:
|
|
43
|
+
token = token.strip(trim)
|
|
44
|
+
result.append(token)
|
|
45
|
+
return result
|