Skip to content

Commit 6c6f499

Browse files
committed
Remove ansiprint dependency
1 parent 044d507 commit 6c6f499

File tree

3 files changed

+11
-29
lines changed

3 files changed

+11
-29
lines changed

psqlextra/management/commands/pgpartition.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
import sys
21

32
from typing import Optional
43

5-
import colorama
6-
7-
from ansimarkup import ansiprint, ansistring
84
from django.conf import settings
95
from django.core.management.base import BaseCommand
106
from django.utils.module_loading import import_string
@@ -70,10 +66,6 @@ def handle(
7066
*args,
7167
**kwargs,
7268
):
73-
# disable coloring if no terminal is attached
74-
if not sys.stdout.isatty():
75-
colorama.init(strip=True)
76-
7769
partitioning_manager = self._partitioning_manager()
7870

7971
plan = partitioning_manager.plan(
@@ -83,7 +75,7 @@ def handle(
8375
creations_count = len(plan.creations)
8476
deletions_count = len(plan.deletions)
8577
if creations_count == 0 and deletions_count == 0:
86-
ansiprint("<b><white>Nothing to be done.</white></b>")
78+
print("Nothing to be done.")
8779
return
8880

8981
plan.print()
@@ -92,18 +84,14 @@ def handle(
9284
return
9385

9486
if not yes:
95-
sys.stdout.write(
96-
ansistring(
97-
"<b><white>Do you want to proceed? (y/N) </white></b>"
98-
)
99-
)
87+
print("Do you want to proceed? (y/N) ")
10088

10189
if not self._ask_for_confirmation():
102-
ansiprint("<b><white>Operation aborted.</white></b>")
90+
print("Operation aborted.")
10391
return
10492

10593
plan.apply(using=using)
106-
ansiprint("<b><white>Operations applied.</white></b>")
94+
print("Operations applied.")
10795

10896
@staticmethod
10997
def _ask_for_confirmation() -> bool:

psqlextra/partitioning/plan.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from dataclasses import dataclass, field
22
from typing import List, Optional
33

4-
from ansimarkup import ansiprint
54
from django.db import connections, transaction
65

76
from .config import PostgresPartitioningConfig
@@ -49,17 +48,17 @@ def apply(self, using: Optional[str]) -> None:
4948
def print(self) -> None:
5049
"""Prints this model plan to the terminal in a readable format."""
5150

52-
ansiprint(f"<b><white>{self.config.model.__name__}:</white></b>")
51+
print(f"{self.config.model.__name__}:")
5352

5453
for partition in self.deletions:
55-
ansiprint("<b><red> - %s</red></b>" % partition.name())
54+
print(" - %s" % partition.name())
5655
for key, value in partition.deconstruct().items():
57-
ansiprint(f"<white> <b>{key}</b>: {value}</white>")
56+
print(f" {key}: {value}")
5857

5958
for partition in self.creations:
60-
ansiprint("<b><green> + %s</green></b>" % partition.name())
59+
print(" + %s" % partition.name())
6160
for key, value in partition.deconstruct().items():
62-
ansiprint(f"<white> <b>{key}</b>: {value}</white>")
61+
print(f" {key}: {value}")
6362

6463

6564
@dataclass
@@ -104,12 +103,8 @@ def print(self) -> None:
104103
create_count = len(self.creations)
105104
delete_count = len(self.deletions)
106105

107-
ansiprint(
108-
f"<b><red>{delete_count} partitions will be deleted</red></b>"
109-
)
110-
ansiprint(
111-
f"<b><green>{create_count} partitions will be created</green></b>"
112-
)
106+
print(f"{delete_count} partitions will be deleted")
107+
print(f"{create_count} partitions will be created")
113108

114109

115110
__all__ = ["PostgresPartitioningPlan", "PostgresModelPartitioningPlan"]

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ def run(self):
6767
install_requires=[
6868
"Django>=2.0,<5.0",
6969
"python-dateutil>=2.8.0,<=3.0.0",
70-
"ansimarkup>=1.4.0,<=2.0.0",
7170
],
7271
extras_require={
7372
':python_version <= "3.6"': ["dataclasses"],

0 commit comments

Comments
 (0)