textfmt 0.1.0__tar.gz → 0.2.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.
- textfmt-0.2.0/LICENSE +21 -0
- {textfmt-0.1.0 → textfmt-0.2.0}/PKG-INFO +17 -14
- textfmt-0.2.0/README.md +48 -0
- {textfmt-0.1.0 → textfmt-0.2.0}/pyproject.toml +2 -2
- {textfmt-0.1.0 → textfmt-0.2.0}/textfmt.egg-info/PKG-INFO +17 -14
- {textfmt-0.1.0 → textfmt-0.2.0}/textfmt.egg-info/SOURCES.txt +2 -0
- textfmt-0.2.0/textformat/__init__.py +5 -0
- textfmt-0.2.0/textformat/progress.py +86 -0
- {textfmt-0.1.0 → textfmt-0.2.0}/textformat/textformat.py +12 -0
- textfmt-0.1.0/README.md +0 -47
- textfmt-0.1.0/textformat/__init__.py +0 -6
- {textfmt-0.1.0 → textfmt-0.2.0}/setup.cfg +0 -0
- {textfmt-0.1.0 → textfmt-0.2.0}/textfmt.egg-info/dependency_links.txt +0 -0
- {textfmt-0.1.0 → textfmt-0.2.0}/textfmt.egg-info/top_level.txt +0 -0
- {textfmt-0.1.0 → textfmt-0.2.0}/textformat/table.py +0 -0
- {textfmt-0.1.0 → textfmt-0.2.0}/textformat/word_art.py +0 -0
textfmt-0.2.0/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Rihaan Meher
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -1,16 +1,18 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: textfmt
|
3
|
-
Version: 0.
|
4
|
-
Summary: A Python module for
|
3
|
+
Version: 0.2.0
|
4
|
+
Summary: A Python module for terminal text styling without the overhead of rich
|
5
5
|
Author-email: Rihaan Meher <meherrihaan@gmail.com>
|
6
6
|
License: MIT
|
7
7
|
Project-URL: Homepage, https://github.com/sharktide/textformat
|
8
8
|
Requires-Python: >=3.6
|
9
9
|
Description-Content-Type: text/markdown
|
10
|
+
License-File: LICENSE
|
11
|
+
Dynamic: license-file
|
10
12
|
|
11
|
-
#
|
13
|
+
# TextFormat
|
12
14
|
|
13
|
-
|
15
|
+
TextFormat is a lightweight Python module for ANSI text formatting, customizable word art, and table rendering in CLI applications.
|
14
16
|
|
15
17
|
## Features
|
16
18
|
- **ANSI Colors & Styles** – Easily format text using intuitive color mappings.
|
@@ -20,38 +22,39 @@ A lightweight Python module for ANSI text formatting, customizable word art, and
|
|
20
22
|
## Installation
|
21
23
|
Install via PyPI:
|
22
24
|
```sh
|
23
|
-
pip install
|
25
|
+
pip install textfmt
|
24
26
|
```
|
25
27
|
|
26
28
|
## Usage
|
27
|
-
|
28
29
|
Basic Text Formatting
|
29
|
-
|
30
30
|
```python
|
31
|
-
import
|
31
|
+
from textformat import TextFormat
|
32
32
|
|
33
|
-
print(
|
33
|
+
print(TextFormat.style("Hello, World!", TextFormat.BOLD, TextFormat.COLORS["blue"]))
|
34
34
|
```
|
35
35
|
|
36
36
|
Custom Word Art Banner
|
37
|
+
|
37
38
|
```python
|
38
|
-
|
39
|
+
from textformat.word_art import WordArt
|
39
40
|
|
40
|
-
print(
|
41
|
+
print(WordArt.banner("TEXTFORMAT", char="*", width=40))
|
41
42
|
```
|
42
43
|
|
43
44
|
Table Rendering
|
44
45
|
```python
|
45
|
-
|
46
|
+
from textformat.table import TableFormatter
|
46
47
|
|
47
|
-
headers = ["
|
48
|
+
headers = ["Feature", "Color", "Effect"]
|
48
49
|
data = [
|
49
50
|
["Bold", "White", "Strong emphasis"],
|
50
51
|
["Underline", "Blue", "Text decoration"],
|
51
52
|
["Warning", "Yellow", "Cautionary message"],
|
52
53
|
]
|
53
54
|
|
54
|
-
print(
|
55
|
+
print(TableFormatter.generate(headers, data))
|
55
56
|
```
|
57
|
+
|
56
58
|
## License
|
59
|
+
|
57
60
|
MIT License – Free to use and modify.
|
textfmt-0.2.0/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# TextFormat
|
2
|
+
|
3
|
+
TextFormat is a lightweight Python module for ANSI text formatting, customizable word art, and table rendering in CLI applications.
|
4
|
+
|
5
|
+
## Features
|
6
|
+
- **ANSI Colors & Styles** – Easily format text using intuitive color mappings.
|
7
|
+
- **Customizable Word Art** – Generate banners with adjustable characters and widths.
|
8
|
+
- **Table Formatting** – Display structured data in a clean, readable format.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
Install via PyPI:
|
12
|
+
```sh
|
13
|
+
pip install textfmt
|
14
|
+
```
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
Basic Text Formatting
|
18
|
+
```python
|
19
|
+
from textformat import TextFormat
|
20
|
+
|
21
|
+
print(TextFormat.style("Hello, World!", TextFormat.BOLD, TextFormat.COLORS["blue"]))
|
22
|
+
```
|
23
|
+
|
24
|
+
Custom Word Art Banner
|
25
|
+
|
26
|
+
```python
|
27
|
+
from textformat.word_art import WordArt
|
28
|
+
|
29
|
+
print(WordArt.banner("TEXTFORMAT", char="*", width=40))
|
30
|
+
```
|
31
|
+
|
32
|
+
Table Rendering
|
33
|
+
```python
|
34
|
+
from textformat.table import TableFormatter
|
35
|
+
|
36
|
+
headers = ["Feature", "Color", "Effect"]
|
37
|
+
data = [
|
38
|
+
["Bold", "White", "Strong emphasis"],
|
39
|
+
["Underline", "Blue", "Text decoration"],
|
40
|
+
["Warning", "Yellow", "Cautionary message"],
|
41
|
+
]
|
42
|
+
|
43
|
+
print(TableFormatter.generate(headers, data))
|
44
|
+
```
|
45
|
+
|
46
|
+
## License
|
47
|
+
|
48
|
+
MIT License – Free to use and modify.
|
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "textfmt"
|
7
|
-
version = "0.
|
8
|
-
description = "A Python module for
|
7
|
+
version = "0.2.0"
|
8
|
+
description = "A Python module for terminal text styling without the overhead of rich"
|
9
9
|
authors = [{name = "Rihaan Meher", email = "meherrihaan@gmail.com"}]
|
10
10
|
license = {text = "MIT"}
|
11
11
|
readme = "README.md"
|
@@ -1,16 +1,18 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: textfmt
|
3
|
-
Version: 0.
|
4
|
-
Summary: A Python module for
|
3
|
+
Version: 0.2.0
|
4
|
+
Summary: A Python module for terminal text styling without the overhead of rich
|
5
5
|
Author-email: Rihaan Meher <meherrihaan@gmail.com>
|
6
6
|
License: MIT
|
7
7
|
Project-URL: Homepage, https://github.com/sharktide/textformat
|
8
8
|
Requires-Python: >=3.6
|
9
9
|
Description-Content-Type: text/markdown
|
10
|
+
License-File: LICENSE
|
11
|
+
Dynamic: license-file
|
10
12
|
|
11
|
-
#
|
13
|
+
# TextFormat
|
12
14
|
|
13
|
-
|
15
|
+
TextFormat is a lightweight Python module for ANSI text formatting, customizable word art, and table rendering in CLI applications.
|
14
16
|
|
15
17
|
## Features
|
16
18
|
- **ANSI Colors & Styles** – Easily format text using intuitive color mappings.
|
@@ -20,38 +22,39 @@ A lightweight Python module for ANSI text formatting, customizable word art, and
|
|
20
22
|
## Installation
|
21
23
|
Install via PyPI:
|
22
24
|
```sh
|
23
|
-
pip install
|
25
|
+
pip install textfmt
|
24
26
|
```
|
25
27
|
|
26
28
|
## Usage
|
27
|
-
|
28
29
|
Basic Text Formatting
|
29
|
-
|
30
30
|
```python
|
31
|
-
import
|
31
|
+
from textformat import TextFormat
|
32
32
|
|
33
|
-
print(
|
33
|
+
print(TextFormat.style("Hello, World!", TextFormat.BOLD, TextFormat.COLORS["blue"]))
|
34
34
|
```
|
35
35
|
|
36
36
|
Custom Word Art Banner
|
37
|
+
|
37
38
|
```python
|
38
|
-
|
39
|
+
from textformat.word_art import WordArt
|
39
40
|
|
40
|
-
print(
|
41
|
+
print(WordArt.banner("TEXTFORMAT", char="*", width=40))
|
41
42
|
```
|
42
43
|
|
43
44
|
Table Rendering
|
44
45
|
```python
|
45
|
-
|
46
|
+
from textformat.table import TableFormatter
|
46
47
|
|
47
|
-
headers = ["
|
48
|
+
headers = ["Feature", "Color", "Effect"]
|
48
49
|
data = [
|
49
50
|
["Bold", "White", "Strong emphasis"],
|
50
51
|
["Underline", "Blue", "Text decoration"],
|
51
52
|
["Warning", "Yellow", "Cautionary message"],
|
52
53
|
]
|
53
54
|
|
54
|
-
print(
|
55
|
+
print(TableFormatter.generate(headers, data))
|
55
56
|
```
|
57
|
+
|
56
58
|
## License
|
59
|
+
|
57
60
|
MIT License – Free to use and modify.
|
@@ -1,3 +1,4 @@
|
|
1
|
+
LICENSE
|
1
2
|
README.md
|
2
3
|
pyproject.toml
|
3
4
|
textfmt.egg-info/PKG-INFO
|
@@ -5,6 +6,7 @@ textfmt.egg-info/SOURCES.txt
|
|
5
6
|
textfmt.egg-info/dependency_links.txt
|
6
7
|
textfmt.egg-info/top_level.txt
|
7
8
|
textformat/__init__.py
|
9
|
+
textformat/progress.py
|
8
10
|
textformat/table.py
|
9
11
|
textformat/textformat.py
|
10
12
|
textformat/word_art.py
|
@@ -0,0 +1,86 @@
|
|
1
|
+
import requests
|
2
|
+
import time
|
3
|
+
from pathlib import Path
|
4
|
+
import sys
|
5
|
+
|
6
|
+
# Define color codes for terminal (ANSI escape codes)
|
7
|
+
class Colors:
|
8
|
+
RESET = "\033[0m"
|
9
|
+
GREEN = "\033[92m"
|
10
|
+
BLUE = "\033[94m"
|
11
|
+
RED = "\033[91m"
|
12
|
+
YELLOW = "\033[93m"
|
13
|
+
MAGENTA = "\033[95m"
|
14
|
+
CYAN = "\033[96m"
|
15
|
+
WHITE = "\033[97m"
|
16
|
+
LIGHT_GREEN = "\033[92m"
|
17
|
+
LIGHT_BLUE = "\033[94m"
|
18
|
+
LIGHT_RED = "\033[91m"
|
19
|
+
LIGHT_YELLOW = "\033[93m"
|
20
|
+
LIGHT_MAGENTA = "\033[95m"
|
21
|
+
LIGHT_CYAN = "\033[96m"
|
22
|
+
|
23
|
+
# List of all available colors for easy access
|
24
|
+
ALL_COLORS = [
|
25
|
+
GREEN, BLUE, RED, YELLOW, MAGENTA, CYAN, WHITE,
|
26
|
+
LIGHT_GREEN, LIGHT_BLUE, LIGHT_RED, LIGHT_YELLOW, LIGHT_MAGENTA, LIGHT_CYAN
|
27
|
+
]
|
28
|
+
|
29
|
+
class ProgressBar:
|
30
|
+
def __init__(self, total, prefix='', length=40, fill='━', empty=' ', print_end="\r",
|
31
|
+
download_color=Colors.GREEN, complete_color=Colors.BLUE):
|
32
|
+
"""
|
33
|
+
Initializes the progress bar.
|
34
|
+
|
35
|
+
Parameters:
|
36
|
+
total (int): Total number of bytes to download.
|
37
|
+
prefix (str): Prefix for the progress bar.
|
38
|
+
length (int): Length of the progress bar.
|
39
|
+
fill (str): Character to fill the progress bar.
|
40
|
+
empty (str): Character to represent empty space in the progress bar.
|
41
|
+
print_end (str): Ending character for printing.
|
42
|
+
download_color (str): Color code for progress bar during download.
|
43
|
+
complete_color (str): Color code for progress bar when download is complete.
|
44
|
+
"""
|
45
|
+
self.total = total
|
46
|
+
self.prefix = prefix
|
47
|
+
self.length = length
|
48
|
+
self.fill = fill
|
49
|
+
self.empty = empty
|
50
|
+
self.print_end = print_end
|
51
|
+
self.download_color = download_color
|
52
|
+
self.complete_color = complete_color
|
53
|
+
self.start_time = time.time()
|
54
|
+
self.downloaded = 0
|
55
|
+
|
56
|
+
def update(self, downloaded):
|
57
|
+
self.downloaded = downloaded
|
58
|
+
percent = ("{0:.1f}").format(100 * (self.downloaded / float(self.total)))
|
59
|
+
filled_length = int(self.length * self.downloaded // self.total)
|
60
|
+
bar = self.fill * filled_length + self.empty * (self.length - filled_length)
|
61
|
+
|
62
|
+
# Calculate current file size and total file size
|
63
|
+
current_size = self.format_size(self.downloaded)
|
64
|
+
total_size = self.format_size(self.total)
|
65
|
+
|
66
|
+
# Set color based on progress
|
67
|
+
if self.downloaded == self.total:
|
68
|
+
color = self.complete_color # Completed color
|
69
|
+
else:
|
70
|
+
color = self.download_color # Downloading color
|
71
|
+
|
72
|
+
# Print the progress bar with color, percentage, and file size
|
73
|
+
sys.stdout.write(f'\r{self.prefix} {color}{bar}{Colors.RESET} {percent}% • {current_size}/{total_size}')
|
74
|
+
sys.stdout.flush()
|
75
|
+
|
76
|
+
if self.downloaded == self.total:
|
77
|
+
sys.stdout.write(self.print_end)
|
78
|
+
sys.stdout.flush()
|
79
|
+
|
80
|
+
def format_size(self, size_in_bytes):
|
81
|
+
"""Format the size in a human-readable format (e.g., KB, MB, GB)."""
|
82
|
+
for unit in ['B', 'KiB', 'MiB', 'GiB', 'TiB']:
|
83
|
+
if size_in_bytes < 1024:
|
84
|
+
return f"{size_in_bytes:.1f} {unit}"
|
85
|
+
size_in_bytes /= 1024
|
86
|
+
|
@@ -1,3 +1,15 @@
|
|
1
|
+
class bcolors:
|
2
|
+
HEADER = '\033[95m'
|
3
|
+
OKBLUE = '\033[94m'
|
4
|
+
OKCYAN = '\033[96m'
|
5
|
+
OKGREEN = '\033[92m'
|
6
|
+
NOTE = '\x1b[35m'
|
7
|
+
WARNING = '\033[93m'
|
8
|
+
FAIL = '\033[91m'
|
9
|
+
ENDC = '\033[0m'
|
10
|
+
BOLD = '\033[1m'
|
11
|
+
UNDERLINE = '\033[4m'
|
12
|
+
|
1
13
|
class TextFormat:
|
2
14
|
""" ANSI Escape Code Formatting for Python CLI Output """
|
3
15
|
RESET = "\x1b[0m"
|
textfmt-0.1.0/README.md
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
# textfmt
|
2
|
-
|
3
|
-
A lightweight Python module for ANSI text formatting, customizable word art, and table rendering in CLI applications.
|
4
|
-
|
5
|
-
## Features
|
6
|
-
- **ANSI Colors & Styles** – Easily format text using intuitive color mappings.
|
7
|
-
- **Customizable Word Art** – Generate banners with adjustable characters and widths.
|
8
|
-
- **Table Formatting** – Display structured data in a clean, readable format.
|
9
|
-
|
10
|
-
## Installation
|
11
|
-
Install via PyPI:
|
12
|
-
```sh
|
13
|
-
pip install textformat
|
14
|
-
```
|
15
|
-
|
16
|
-
## Usage
|
17
|
-
|
18
|
-
Basic Text Formatting
|
19
|
-
|
20
|
-
```python
|
21
|
-
import textfmt
|
22
|
-
|
23
|
-
print(textfmt.TextFmt.style("Hello, World!", textfmt.TextFmt.BOLD, textfmt.TextFmt.COLORS["blue"]))
|
24
|
-
```
|
25
|
-
|
26
|
-
Custom Word Art Banner
|
27
|
-
```python
|
28
|
-
import textfmt.word_art
|
29
|
-
|
30
|
-
print(textfmt.word_art.WordArt.banner("TEXTFMT", char="*", width=40))
|
31
|
-
```
|
32
|
-
|
33
|
-
Table Rendering
|
34
|
-
```python
|
35
|
-
import textfmt.table
|
36
|
-
|
37
|
-
headers = ["Name", "Color", "Effect"]
|
38
|
-
data = [
|
39
|
-
["Bold", "White", "Strong emphasis"],
|
40
|
-
["Underline", "Blue", "Text decoration"],
|
41
|
-
["Warning", "Yellow", "Cautionary message"],
|
42
|
-
]
|
43
|
-
|
44
|
-
print(textfmt.table.TableFormatter.generate(headers, data))
|
45
|
-
```
|
46
|
-
## License
|
47
|
-
MIT License – Free to use and modify.
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|