Merge "strutils: Defer import of pyparsing"

This commit is contained in:
Zuul 2022-05-31 14:54:43 +00:00 committed by Gerrit Code Review
commit 6890f1ef29
1 changed files with 7 additions and 4 deletions

View File

@ -23,8 +23,6 @@ import re
import unicodedata
import urllib
import pyparsing as pp
from oslo_utils._i18n import _
from oslo_utils import encodeutils
@ -575,8 +573,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: