txwrap 1.0.0__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.
txwrap-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,42 @@
1
+ Metadata-Version: 2.4
2
+ Name: txwrap
3
+ Version: 1.0.0
4
+ Summary: Small helpers around the stdlib textwrap module: terminal-aware wrapping, column alignment, and simple CLI formatting.
5
+ Classifier: Programming Language :: Python :: 3
6
+ Classifier: License :: OSI Approved :: MIT License
7
+ Classifier: Operating System :: OS Independent
8
+ Classifier: Topic :: Text Processing :: General
9
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
10
+ Classifier: Intended Audience :: Developers
11
+ Requires-Python: >=3.6
12
+ Description-Content-Type: text/markdown
13
+ Dynamic: classifier
14
+ Dynamic: description
15
+ Dynamic: description-content-type
16
+ Dynamic: requires-python
17
+ Dynamic: summary
18
+
19
+ # txwrap
20
+
21
+ Thin utilities on top of Python's `textwrap` and `shutil.get_terminal_size`:
22
+
23
+ - **format_block** — wrap text to terminal width (or a fixed width) with optional indent
24
+ - **align_columns** — pad list items into aligned columns
25
+ - **dedent** / **fill** — thin wrappers around `textwrap.dedent` / `textwrap.fill`
26
+ - **format_header** / **format_status** — simple CLI banners and status lines
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ pip install txwrap
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ ```python
37
+ from txwrap import format_block, align_columns, format_header
38
+
39
+ print(format_block("Long line of text...", indent=2))
40
+ print(align_columns(["a", "bb", "ccc"]))
41
+ print(format_header("Done"))
42
+ ```
txwrap-1.0.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
txwrap-1.0.0/setup.py ADDED
@@ -0,0 +1,47 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="txwrap",
5
+ version="1.0.0",
6
+ description=(
7
+ "Small helpers around the stdlib textwrap module: terminal-aware wrapping, "
8
+ "column alignment, and simple CLI formatting."
9
+ ),
10
+ long_description="""# txwrap
11
+
12
+ Thin utilities on top of Python's `textwrap` and `shutil.get_terminal_size`:
13
+
14
+ - **format_block** — wrap text to terminal width (or a fixed width) with optional indent
15
+ - **align_columns** — pad list items into aligned columns
16
+ - **dedent** / **fill** — thin wrappers around `textwrap.dedent` / `textwrap.fill`
17
+ - **format_header** / **format_status** — simple CLI banners and status lines
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ pip install txwrap
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ```python
28
+ from txwrap import format_block, align_columns, format_header
29
+
30
+ print(format_block("Long line of text...", indent=2))
31
+ print(align_columns(["a", "bb", "ccc"]))
32
+ print(format_header("Done"))
33
+ ```
34
+ """,
35
+ long_description_content_type="text/markdown",
36
+ packages=find_packages(),
37
+ classifiers=[
38
+ "Programming Language :: Python :: 3",
39
+ "License :: OSI Approved :: MIT License",
40
+ "Operating System :: OS Independent",
41
+ "Topic :: Text Processing :: General",
42
+ "Topic :: Software Development :: Libraries :: Python Modules",
43
+ "Intended Audience :: Developers",
44
+ ],
45
+ python_requires=">=3.6",
46
+ install_requires=[],
47
+ )
@@ -0,0 +1 @@
1
+ from .formatter import format_block, align_columns, dedent, fill, format_header, format_status
@@ -0,0 +1,49 @@
1
+ import textwrap
2
+ import shutil
3
+
4
+ def format_block(text, width=None, indent=0):
5
+ """
6
+ Wraps text to the specified width, defaulting to the terminal width.
7
+ """
8
+ if not width:
9
+ # Get terminal width, fallback to 80
10
+ width = shutil.get_terminal_size((80, 20)).columns
11
+
12
+ prefix = " " * indent
13
+ wrapper = textwrap.TextWrapper(
14
+ width=width,
15
+ initial_indent=prefix,
16
+ subsequent_indent=prefix,
17
+ break_long_words=False,
18
+ replace_whitespace=False
19
+ )
20
+ return wrapper.fill(text)
21
+
22
+ def align_columns(data, padding=4):
23
+ """
24
+ Simple helper to align list data into columns.
25
+ """
26
+ if not data:
27
+ return ""
28
+ col_width = max(len(str(x)) for x in data) + padding
29
+ return "".join(str(x).ljust(col_width) for x in data)
30
+
31
+ def dedent(text):
32
+ """
33
+ Dedents text by removing common leading whitespace.
34
+ """
35
+ return textwrap.dedent(text)
36
+
37
+ def fill(text, width=70):
38
+ """Standard fill functionality."""
39
+ return textwrap.fill(text, width=width)
40
+
41
+ def format_header(text):
42
+ """Creates a stylized header for CLI tools."""
43
+ width = 60
44
+ border = "=" * width
45
+ return f"\n{border}\n{text.center(width)}\n{border}"
46
+
47
+ def format_status(text):
48
+ """Formats a status message with a prefix."""
49
+ return f"[+] {text}"
@@ -0,0 +1,42 @@
1
+ Metadata-Version: 2.4
2
+ Name: txwrap
3
+ Version: 1.0.0
4
+ Summary: Small helpers around the stdlib textwrap module: terminal-aware wrapping, column alignment, and simple CLI formatting.
5
+ Classifier: Programming Language :: Python :: 3
6
+ Classifier: License :: OSI Approved :: MIT License
7
+ Classifier: Operating System :: OS Independent
8
+ Classifier: Topic :: Text Processing :: General
9
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
10
+ Classifier: Intended Audience :: Developers
11
+ Requires-Python: >=3.6
12
+ Description-Content-Type: text/markdown
13
+ Dynamic: classifier
14
+ Dynamic: description
15
+ Dynamic: description-content-type
16
+ Dynamic: requires-python
17
+ Dynamic: summary
18
+
19
+ # txwrap
20
+
21
+ Thin utilities on top of Python's `textwrap` and `shutil.get_terminal_size`:
22
+
23
+ - **format_block** — wrap text to terminal width (or a fixed width) with optional indent
24
+ - **align_columns** — pad list items into aligned columns
25
+ - **dedent** / **fill** — thin wrappers around `textwrap.dedent` / `textwrap.fill`
26
+ - **format_header** / **format_status** — simple CLI banners and status lines
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ pip install txwrap
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ ```python
37
+ from txwrap import format_block, align_columns, format_header
38
+
39
+ print(format_block("Long line of text...", indent=2))
40
+ print(align_columns(["a", "bb", "ccc"]))
41
+ print(format_header("Done"))
42
+ ```
@@ -0,0 +1,7 @@
1
+ setup.py
2
+ txwrap/__init__.py
3
+ txwrap/formatter.py
4
+ txwrap.egg-info/PKG-INFO
5
+ txwrap.egg-info/SOURCES.txt
6
+ txwrap.egg-info/dependency_links.txt
7
+ txwrap.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ txwrap