diff options
author | Stephen Finucane <sfinucan@redhat.com> | 2022-05-18 12:51:01 +0100 |
---|---|---|
committer | Stephen Finucane <sfinucan@redhat.com> | 2022-05-18 12:51:01 +0100 |
commit | 0eaa7de6a7b4754638640e5caaec0de9832e4dbb (patch) | |
tree | 00bdd5276407f5b2a352684b0cefd56522097577 | |
parent | 383789ce70efb7070a69885f7fa7bb6e3d90af55 (diff) | |
download | oslo-utils-0eaa7de6a7b4754638640e5caaec0de9832e4dbb.tar.gz |
strutils: Defer import of pyparsing
This is a slow import and the single user of it, the 'split_by_commas'
helper, does not appear to have any users outside of python-glareclient
(which is a dead project). We might want to remove the user at some
point, but for now simply defer loading of the library.
Change-Id: I91d0c6eec5333a660f995a9d1436e4b068693900
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
-rw-r--r-- | oslo_utils/strutils.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/oslo_utils/strutils.py b/oslo_utils/strutils.py index 0bb9fc5..ae5cfc0 100644 --- a/oslo_utils/strutils.py +++ b/oslo_utils/strutils.py @@ -23,8 +23,6 @@ import re import unicodedata import urllib -import pyparsing as pp - from oslo_utils._i18n import _ from oslo_utils import encodeutils @@ -577,8 +575,13 @@ def split_by_commas(value): .. versionadded:: 3.17 """ - word = (pp.QuotedString(quoteChar='"', escChar='\\') | - pp.Word(pp.printables, excludeChars='",')) + # pyparsing is a slow import; defer loading until we need it + import pyparsing as pp + + word = ( + pp.QuotedString(quoteChar='"', escChar='\\') | + pp.Word(pp.printables, excludeChars='",') + ) grammar = pp.stringStart + pp.delimitedList(word) + pp.stringEnd try: |