mirror of
https://github.com/ansible/awx.git
synced 2026-02-25 23:16:01 -03:30
Merge pull request #838 from AlanCoding/no_unicode_loop_2
Avoid slowdown generating smart_filter (alternative 2)
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
from pyparsing import (
|
from pyparsing import (
|
||||||
infixNotation,
|
infixNotation,
|
||||||
opAssoc,
|
opAssoc,
|
||||||
@@ -15,9 +14,6 @@ from awx.main.utils.common import get_search_fields
|
|||||||
|
|
||||||
__all__ = ['SmartFilter']
|
__all__ = ['SmartFilter']
|
||||||
|
|
||||||
unicode_spaces = [unichr(c) for c in xrange(sys.maxunicode) if unichr(c).isspace()]
|
|
||||||
unicode_spaces_other = unicode_spaces + [u'(', u')', u'=', u'"']
|
|
||||||
|
|
||||||
|
|
||||||
def string_to_type(t):
|
def string_to_type(t):
|
||||||
if t == u'true':
|
if t == u'true':
|
||||||
@@ -213,6 +209,8 @@ class SmartFilter(object):
|
|||||||
filter_string_raw = filter_string
|
filter_string_raw = filter_string
|
||||||
filter_string = unicode(filter_string)
|
filter_string = unicode(filter_string)
|
||||||
|
|
||||||
|
unicode_spaces = list(set(unicode(c) for c in filter_string if c.isspace()))
|
||||||
|
unicode_spaces_other = unicode_spaces + [u'(', u')', u'=', u'"']
|
||||||
atom = CharsNotIn(unicode_spaces_other)
|
atom = CharsNotIn(unicode_spaces_other)
|
||||||
atom_inside_quotes = CharsNotIn(u'"')
|
atom_inside_quotes = CharsNotIn(u'"')
|
||||||
atom_quoted = Literal('"') + Optional(atom_inside_quotes) + Literal('"')
|
atom_quoted = Literal('"') + Optional(atom_inside_quotes) + Literal('"')
|
||||||
|
|||||||
Reference in New Issue
Block a user