Browse Source

Make PrettyTable optional

PrettyTable as a depend can have a tendency to conflict with other
things that want to use it, which is a shame for a general purpose
library like futurist. Make it optional to reduce the transitive
dependency burden for consumers.

Change-Id: Ie976f7f4e544f273fccf0cf579b82b659cbd48d1
tags/2.1.0^0
Monty Taylor 4 months ago
parent
commit
79f240b79f
4 changed files with 21 additions and 4 deletions
  1. +13
    -3
      futurist/periodics.py
  2. +7
    -0
      releasenotes/notes/prettytable-optional-2c9198a9250427b6.yaml
  3. +0
    -1
      requirements.txt
  4. +1
    -0
      test-requirements.txt

+ 13
- 3
futurist/periodics.py View File

@@ -25,7 +25,10 @@ import random
import threading

from concurrent import futures
import prettytable
try:
import prettytable
except ImportError:
prettytable = None
import six

import futurist
@@ -748,10 +751,17 @@ class PeriodicWorker(object):
cols = list(_DEFAULT_COLS)
for c in ['Runs in', 'Active', 'Periodicity']:
cols.remove(c)
self._log.debug("Stopped running %s callbacks:\n%s",
len(self._works), self.pformat(columns=cols))
self._log.debug(
"Stopped running %s callbacks:\n%s",
len(self._works),
self.pformat(columns=cols) if prettytable
else "statistics not available, PrettyTable missing"
)

def pformat(self, columns=_DEFAULT_COLS):
if prettytable is None:
raise ImportError(
"PrettyTable is required to use the pformat method")
# Convert to a list to ensure we maintain the same order when used
# further in this function (since order will matter)...
if not isinstance(columns, (list, tuple)):


+ 7
- 0
releasenotes/notes/prettytable-optional-2c9198a9250427b6.yaml View File

@@ -0,0 +1,7 @@
---
upgrade:
- |
The ``PrettyTable`` dependency has been made optional, as it
is only used in the `Periodics.pformat` method. If the use
of that method is important, users should depend on
``PrettyTable`` directly.

+ 0
- 1
requirements.txt View File

@@ -4,4 +4,3 @@

pbr!=2.1.0,>=2.0.0 # Apache-2.0
six>=1.10.0 # MIT
PrettyTable<0.8,>=0.7.1 # BSD

+ 1
- 0
test-requirements.txt View File

@@ -14,3 +14,4 @@ oslotest>=3.2.0 # Apache-2.0
stestr>=2.0.0 # Apache-2.0
testscenarios>=0.4 # Apache-2.0/BSD
testtools>=2.2.0 # MIT
PrettyTable<0.8,>=0.7.1 # BSD

Loading…
Cancel
Save