textfmt 0.1.0__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.
@@ -0,0 +1,57 @@
1
+ Metadata-Version: 2.4
2
+ Name: textfmt
3
+ Version: 0.1.0
4
+ Summary: A Python module for ANSI text formatting, word art, and table styling
5
+ Author-email: Rihaan Meher <meherrihaan@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/sharktide/textformat
8
+ Requires-Python: >=3.6
9
+ Description-Content-Type: text/markdown
10
+
11
+ # textfmt
12
+
13
+ A lightweight Python module for ANSI text formatting, customizable word art, and table rendering in CLI applications.
14
+
15
+ ## Features
16
+ - **ANSI Colors & Styles** – Easily format text using intuitive color mappings.
17
+ - **Customizable Word Art** – Generate banners with adjustable characters and widths.
18
+ - **Table Formatting** – Display structured data in a clean, readable format.
19
+
20
+ ## Installation
21
+ Install via PyPI:
22
+ ```sh
23
+ pip install textformat
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ Basic Text Formatting
29
+
30
+ ```python
31
+ import textfmt
32
+
33
+ print(textfmt.TextFmt.style("Hello, World!", textfmt.TextFmt.BOLD, textfmt.TextFmt.COLORS["blue"]))
34
+ ```
35
+
36
+ Custom Word Art Banner
37
+ ```python
38
+ import textfmt.word_art
39
+
40
+ print(textfmt.word_art.WordArt.banner("TEXTFMT", char="*", width=40))
41
+ ```
42
+
43
+ Table Rendering
44
+ ```python
45
+ import textfmt.table
46
+
47
+ headers = ["Name", "Color", "Effect"]
48
+ data = [
49
+ ["Bold", "White", "Strong emphasis"],
50
+ ["Underline", "Blue", "Text decoration"],
51
+ ["Warning", "Yellow", "Cautionary message"],
52
+ ]
53
+
54
+ print(textfmt.table.TableFormatter.generate(headers, data))
55
+ ```
56
+ ## License
57
+ MIT License – Free to use and modify.
@@ -0,0 +1,8 @@
1
+ textformat/__init__.py,sha256=OeDcG1aKyzES1aLCdjxC06NYtNBDRMrqnGVO7KDW1pc,182
2
+ textformat/table.py,sha256=GA7MsMWNuug61XxK9Ot3SOg5bl9zh5GO9Hae8-Y2qeE,604
3
+ textformat/textformat.py,sha256=hRfVOZqQCT8955F9qj8_rFPPn0tZxtOpogRtkxZ7BL8,859
4
+ textformat/word_art.py,sha256=GsJka0ukV23FTvhuyuGRChhNGOjTWOdKBK3h0e-LnX8,318
5
+ textfmt-0.1.0.dist-info/METADATA,sha256=ojispDnWgHDPog7otaNGULpybth0GFLuFUM2qKRW7Hw,1486
6
+ textfmt-0.1.0.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
7
+ textfmt-0.1.0.dist-info/top_level.txt,sha256=Nf6G1sI6EqA2opfIdIio6ZqKNbpT2EtYf5cd0sKgPRo,11
8
+ textfmt-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.8.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ textformat
textformat/__init__.py ADDED
@@ -0,0 +1,6 @@
1
+ # textfmt/__init__.py
2
+ from .textformat import TextFormat
3
+ from .word_art import WordArt
4
+ from .table import TableFormatter
5
+
6
+ __all__ = ["TextFormat", "WordArt", "TableFormatter"]
textformat/table.py ADDED
@@ -0,0 +1,13 @@
1
+ class TableFormatter:
2
+ """ Formats tables for CLI display """
3
+
4
+ @staticmethod
5
+ def generate(headers, data):
6
+ """ Creates a formatted table for structured output """
7
+ col_widths = [max(len(str(item)) for item in col) for col in zip(headers, *data)]
8
+ border = "+".join("-" * (w + 2) for w in col_widths)
9
+
10
+ def format_row(row):
11
+ return "| " + " | ".join(f"{str(item).ljust(w)}" for item, w in zip(row, col_widths)) + " |"
12
+
13
+ return f"{border}\n{format_row(headers)}\n{border}\n" + "\n".join(format_row(row) for row in data) + f"\n{border}"
@@ -0,0 +1,24 @@
1
+ class TextFormat:
2
+ """ ANSI Escape Code Formatting for Python CLI Output """
3
+ RESET = "\x1b[0m"
4
+
5
+ BOLD = "\x1b[1m" # Basic bold without a color
6
+
7
+ UNDERLINE = "\x1b[4m" # Add this line for underline support
8
+
9
+ COLORS = {
10
+ "black": "\x1b[30m", "blue": "\x1b[34m", "cyan": "\x1b[36m",
11
+ "green": "\x1b[32m", "grey": "\x1b[90m", "magenta": "\x1b[35m",
12
+ "red": "\x1b[31m", "white": "\x1b[37m", "yellow": "\x1b[33m"
13
+ }
14
+
15
+ BOLD_COLORS = {
16
+ "black": "\x1b[1;30m", "blue": "\x1b[1;34m", "cyan": "\x1b[1;36m",
17
+ "green": "\x1b[1;32m", "magenta": "\x1b[1;35m", "red": "\x1b[1;31m",
18
+ "white": "\x1b[1;37m", "yellow": "\x1b[1;33m"
19
+ }
20
+
21
+ @staticmethod
22
+ def style(text, *styles):
23
+ """ Applies ANSI styles to text """
24
+ return "".join(styles) + text + TextFormat.RESET
textformat/word_art.py ADDED
@@ -0,0 +1,9 @@
1
+ class WordArt:
2
+ """ Generates customizable word art banners """
3
+
4
+ @staticmethod
5
+ def banner(text, char="█", width=50):
6
+ """ Creates a formatted word art banner """
7
+ top = char * width
8
+ middle = f"{char} {text.center(width - 4)} {char}"
9
+ return f"{top}\n{middle}\n{top}"