From 9180df19b8995bff044995f167291422d20f3c58 Mon Sep 17 00:00:00 2001 From: Nguyen Hung Phuong Date: Tue, 30 Jan 2018 13:58:45 +0700 Subject: [PATCH] Clean imports in code In some part in the code we import objects. In the Openstack style guidelines they recommend to import only modules. https://docs.openstack.org/hacking/0.10.3/ Change-Id: Ie0151c2878c6a0ae09b7efcd5ccc7b31c622c0e7 --- oslo_utils/specs_matcher.py | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/oslo_utils/specs_matcher.py b/oslo_utils/specs_matcher.py index d654db5d..35c4e494 100644 --- a/oslo_utils/specs_matcher.py +++ b/oslo_utils/specs_matcher.py @@ -17,9 +17,6 @@ import ast import operator import pyparsing -from pyparsing import Literal -from pyparsing import OneOrMore -from pyparsing import Regex def _all_in(x, *y): @@ -62,25 +59,25 @@ def make_grammar(): unary_ops = ( # Order matters here (so that '=' doesn't match before '==') - Literal("==") | Literal("=") | - Literal("!=") | Literal("") | - Literal(">=") | Literal("<=") | - Literal(">") | Literal("<") | - Literal("s==") | Literal("s!=") | + pyparsing.Literal("==") | pyparsing.Literal("=") | + pyparsing.Literal("!=") | pyparsing.Literal("") | + pyparsing.Literal(">=") | pyparsing.Literal("<=") | + pyparsing.Literal(">") | pyparsing.Literal("<") | + pyparsing.Literal("s==") | pyparsing.Literal("s!=") | # Order matters here (so that '<' doesn't match before '<=') - Literal("s<=") | Literal("s<") | + pyparsing.Literal("s<=") | pyparsing.Literal("s<") | # Order matters here (so that '>' doesn't match before '>=') - Literal("s>=") | Literal("s>")) + pyparsing.Literal("s>=") | pyparsing.Literal("s>")) - all_in_nary_op = Literal("") - or_ = Literal("") + all_in_nary_op = pyparsing.Literal("") + or_ = pyparsing.Literal("") # An atom is anything not an keyword followed by anything but whitespace - atom = ~(unary_ops | all_in_nary_op | or_) + Regex(r"\S+") + atom = ~(unary_ops | all_in_nary_op | or_) + pyparsing.Regex(r"\S+") unary = unary_ops + atom - nary = all_in_nary_op + OneOrMore(atom) - disjunction = OneOrMore(or_ + atom) + nary = all_in_nary_op + pyparsing.OneOrMore(atom) + disjunction = pyparsing.OneOrMore(or_ + atom) # Even-numbered tokens will be '', so we drop them disjunction.setParseAction(lambda _s, _l, t: [""] + t[1::2])