mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Compatibility with prettytable>=3.12.0 (#3217)
They started showing deprecation warning when importing ALL and FRAME constants.
This commit is contained in:
+9
-2
@@ -38,7 +38,14 @@ import dateutil.tz
|
|||||||
import urllib3
|
import urllib3
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from prettytable import ALL, FRAME, PrettyTable
|
from prettytable import PrettyTable
|
||||||
|
|
||||||
|
try: # pragma: no cover
|
||||||
|
from prettytable import HRuleStyle
|
||||||
|
hrule_all = HRuleStyle.ALL
|
||||||
|
hrule_frame = HRuleStyle.FRAME
|
||||||
|
except ImportError: # pragma: no cover
|
||||||
|
from prettytable import ALL as hrule_all, FRAME as hrule_frame
|
||||||
|
|
||||||
if TYPE_CHECKING: # pragma: no cover
|
if TYPE_CHECKING: # pragma: no cover
|
||||||
from psycopg import Cursor
|
from psycopg import Cursor
|
||||||
@@ -437,7 +444,7 @@ def print_output(columns: Optional[List[str]], rows: List[List[Any]], alignment:
|
|||||||
else:
|
else:
|
||||||
# If any value is multi-line, then add horizontal between all table rows while printing to get a clear
|
# If any value is multi-line, then add horizontal between all table rows while printing to get a clear
|
||||||
# visual separation of rows.
|
# visual separation of rows.
|
||||||
hrules = ALL if any(any(isinstance(c, str) and '\n' in c for c in r) for r in rows) else FRAME
|
hrules = hrule_all if any(any(isinstance(c, str) and '\n' in c for c in r) for r in rows) else hrule_frame
|
||||||
table = PatronictlPrettyTable(header, columns, hrules=hrules)
|
table = PatronictlPrettyTable(header, columns, hrules=hrules)
|
||||||
table.align = 'l'
|
table.align = 'l'
|
||||||
for k, v in (alignment or {}).items():
|
for k, v in (alignment or {}).items():
|
||||||
|
|||||||
+9
-2
@@ -9,7 +9,14 @@ import click
|
|||||||
import etcd
|
import etcd
|
||||||
|
|
||||||
from click.testing import CliRunner
|
from click.testing import CliRunner
|
||||||
from prettytable import ALL, PrettyTable
|
from prettytable import PrettyTable
|
||||||
|
|
||||||
|
try:
|
||||||
|
from prettytable import HRuleStyle
|
||||||
|
hrule_all = HRuleStyle.ALL
|
||||||
|
except ImportError:
|
||||||
|
from prettytable import ALL as hrule_all
|
||||||
|
|
||||||
from urllib3 import PoolManager
|
from urllib3 import PoolManager
|
||||||
|
|
||||||
from patroni import global_config
|
from patroni import global_config
|
||||||
@@ -747,7 +754,7 @@ class TestCtl(unittest.TestCase):
|
|||||||
class TestPatronictlPrettyTable(unittest.TestCase):
|
class TestPatronictlPrettyTable(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.pt = PatronictlPrettyTable(' header', ['foo', 'bar'], hrules=ALL)
|
self.pt = PatronictlPrettyTable(' header', ['foo', 'bar'], hrules=hrule_all)
|
||||||
|
|
||||||
def test__get_hline(self):
|
def test__get_hline(self):
|
||||||
expected = '+-----+-----+'
|
expected = '+-----+-----+'
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
|
from enum import IntEnum
|
||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List
|
||||||
FRAME = 1
|
class HRuleStyle(IntEnum):
|
||||||
ALL = 1
|
FRAME = 0
|
||||||
|
ALL = 1
|
||||||
|
FRAME = HRuleStyle.FRAME
|
||||||
|
ALL = HRuleStyle.ALL
|
||||||
class PrettyTable:
|
class PrettyTable:
|
||||||
def __init__(self, *args: str, **kwargs: Any) -> None: ...
|
def __init__(self, *args: str, **kwargs: Any) -> None: ...
|
||||||
def _stringify_hrule(self, options: Dict[str, Any], where: str = '') -> str: ...
|
def _stringify_hrule(self, options: Dict[str, Any], where: str = '') -> str: ...
|
||||||
|
|||||||
Reference in New Issue
Block a user