mirror of https://github.com/yandex/gixy
Minor code style improvements
parent
411b74f7ba
commit
3dc9bde70b
|
@ -5,7 +5,6 @@ from six.moves import StringIO
|
||||||
|
|
||||||
from gixy.core.plugins_manager import PluginsManager
|
from gixy.core.plugins_manager import PluginsManager
|
||||||
|
|
||||||
|
|
||||||
# used while parsing args to keep track of where they came from
|
# used while parsing args to keep track of where they came from
|
||||||
_COMMAND_LINE_SOURCE_KEY = 'command_line'
|
_COMMAND_LINE_SOURCE_KEY = 'command_line'
|
||||||
_ENV_VAR_SOURCE_KEY = 'environment_variables'
|
_ENV_VAR_SOURCE_KEY = 'environment_variables'
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
from gixy.core.regexp import Regexp
|
from gixy.core.regexp import Regexp
|
||||||
from gixy.core.variable import Variable
|
from gixy.core.variable import Variable
|
||||||
|
|
||||||
|
|
||||||
BUILTIN_VARIABLES = {
|
BUILTIN_VARIABLES = {
|
||||||
# http://nginx.org/en/docs/http/ngx_http_core_module.html#var_uri
|
# http://nginx.org/en/docs/http/ngx_http_core_module.html#var_uri
|
||||||
'uri': '/[^\x20\t]*',
|
'uri': '/[^\x20\t]*',
|
||||||
|
|
|
@ -9,7 +9,6 @@ class Config(object):
|
||||||
output_format=None,
|
output_format=None,
|
||||||
output_file=None,
|
output_file=None,
|
||||||
allow_includes=True):
|
allow_includes=True):
|
||||||
|
|
||||||
self.severity = severity
|
self.severity = severity
|
||||||
self.output_format = output_format
|
self.output_format = output_format
|
||||||
self.output_file = output_file
|
self.output_file = output_file
|
||||||
|
|
|
@ -3,7 +3,6 @@ import copy
|
||||||
|
|
||||||
from gixy.core.utils import is_indexed_name
|
from gixy.core.utils import is_indexed_name
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
CONTEXTS = []
|
CONTEXTS = []
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
class Issue(object):
|
class Issue(object):
|
||||||
|
|
||||||
def __init__(self, plugin, summary=None, description=None,
|
def __init__(self, plugin, summary=None, description=None,
|
||||||
severity=None, reason=None, help_url=None, directives=None):
|
severity=None, reason=None, help_url=None, directives=None):
|
||||||
self.plugin = plugin
|
self.plugin = plugin
|
||||||
|
|
|
@ -5,7 +5,6 @@ from gixy.plugins.plugin import Plugin
|
||||||
|
|
||||||
|
|
||||||
class PluginsManager(object):
|
class PluginsManager(object):
|
||||||
|
|
||||||
def __init__(self, config=None):
|
def __init__(self, config=None):
|
||||||
self.imported = False
|
self.imported = False
|
||||||
self.config = config
|
self.config = config
|
||||||
|
|
|
@ -21,14 +21,17 @@ try:
|
||||||
from _sre import MAXREPEAT
|
from _sre import MAXREPEAT
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import _sre
|
import _sre
|
||||||
|
|
||||||
MAXREPEAT = _sre.MAXREPEAT = 65535
|
MAXREPEAT = _sre.MAXREPEAT = 65535
|
||||||
|
|
||||||
|
|
||||||
# SRE standard exception (access as sre.error)
|
# SRE standard exception (access as sre.error)
|
||||||
# should this really be here?
|
# should this really be here?
|
||||||
|
|
||||||
class error(Exception):
|
class error(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
# operators
|
# operators
|
||||||
|
|
||||||
FAILURE = "failure"
|
FAILURE = "failure"
|
||||||
|
@ -148,6 +151,7 @@ CHCODES = [
|
||||||
CATEGORY_UNI_NOT_LINEBREAK
|
CATEGORY_UNI_NOT_LINEBREAK
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def makedict(list):
|
def makedict(list):
|
||||||
d = {}
|
d = {}
|
||||||
i = 0
|
i = 0
|
||||||
|
@ -156,6 +160,7 @@ def makedict(list):
|
||||||
i = i + 1
|
i = i + 1
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
OPCODES = makedict(OPCODES)
|
OPCODES = makedict(OPCODES)
|
||||||
ATCODES = makedict(ATCODES)
|
ATCODES = makedict(ATCODES)
|
||||||
CHCODES = makedict(CHCODES)
|
CHCODES = makedict(CHCODES)
|
||||||
|
@ -219,4 +224,3 @@ SRE_FLAG_DEBUG = 128 # debugging
|
||||||
SRE_INFO_PREFIX = 1 # has prefix
|
SRE_INFO_PREFIX = 1 # has prefix
|
||||||
SRE_INFO_LITERAL = 2 # entire pattern is literal (given by prefix)
|
SRE_INFO_LITERAL = 2 # entire pattern is literal (given by prefix)
|
||||||
SRE_INFO_CHARSET = 4 # pattern starts with character from given set
|
SRE_INFO_CHARSET = 4 # pattern starts with character from given set
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import logging
|
||||||
from gixy.core.regexp import Regexp
|
from gixy.core.regexp import Regexp
|
||||||
from gixy.core.context import get_context
|
from gixy.core.context import get_context
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
# See ngx_http_script_compile in http/ngx_http_script.c
|
# See ngx_http_script_compile in http/ngx_http_script.c
|
||||||
EXTRACT_RE = re.compile(r'\$([1-9]|[a-z_][a-z0-9_]*|\{[a-z0-9_]+\})', re.IGNORECASE)
|
EXTRACT_RE = re.compile(r'\$([1-9]|[a-z_][a-z0-9_]*|\{[a-z0-9_]+\})', re.IGNORECASE)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import os
|
import os
|
||||||
from gixy.directives.directive import Directive
|
from gixy.directives.directive import Directive
|
||||||
|
|
||||||
|
|
||||||
DIRECTIVES = {}
|
DIRECTIVES = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
"""NginxParser is a member object of the NginxConfigurator class."""
|
|
||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
import logging
|
import logging
|
||||||
|
@ -13,7 +12,6 @@ LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class NginxParser(object):
|
class NginxParser(object):
|
||||||
|
|
||||||
def __init__(self, file_path, allow_includes=True):
|
def __init__(self, file_path, allow_includes=True):
|
||||||
self.base_file_path = file_path
|
self.base_file_path = file_path
|
||||||
self.cwd = os.path.dirname(file_path)
|
self.cwd = os.path.dirname(file_path)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
"""Very low-level nginx config parser based on pyparsing."""
|
|
||||||
import re
|
import re
|
||||||
import logging
|
import logging
|
||||||
from cached_property import cached_property
|
from cached_property import cached_property
|
||||||
|
@ -7,7 +6,6 @@ from pyparsing import (
|
||||||
Literal, Suppress, White, Word, alphanums, Forward, Group, Optional, Combine,
|
Literal, Suppress, White, Word, alphanums, Forward, Group, Optional, Combine,
|
||||||
Keyword, OneOrMore, ZeroOrMore, Regex, QuotedString, nestedExpr)
|
Keyword, OneOrMore, ZeroOrMore, Regex, QuotedString, nestedExpr)
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue