mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
python: sanitize spaces either side of operators
There should be a single space either side of operators. Inline comments should have two spaces before the '#' src/hyperv/hyperv_wmi_generator.py:130:45: E261 at least two spaces before inline comment source += ' { "", "", 0 },\n' # null terminated ^ src/esx/esx_vi_generator.py:417:25: E221 multiple spaces before operator FEATURE__DESERIALIZE = (1 << 6) ^ tests/cputestdata/cpu-cpuid.py:187:78: E225 missing whitespace around operator f.write(" <msr index='0x%x' edx='0x%08x' eax='0x%08x'/>\n" %( ^ docs/apibuild.py:524:47: E226 missing whitespace around arithmetic operator self.line = line[i+2:] ^ ...more... Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
bc59247df9
commit
43d29cb40b
@ -884,12 +884,10 @@ sc_require_enum_last_marker:
|
||||
|
||||
# Validate many python style rules
|
||||
FLAKE8_INDENTATION = E114,E115,E116,E121,E125,E126,E127,E128,E129,E131
|
||||
FLAKE8_WHITESPACE = E211,E221,E222,E225,E226,E231,E261
|
||||
FLAKE8_LINE_LENGTH = E501
|
||||
FLAKE8_WARNINGS = W504
|
||||
|
||||
FLAKE8_IGNORE = $(FLAKE8_INDENTATION),$\
|
||||
$(FLAKE8_WHITESPACE),$\
|
||||
$(FLAKE8_LINE_LENGTH),$\
|
||||
$(FLAKE8_WARNINGS) \
|
||||
$(NULL)
|
||||
|
@ -520,9 +520,9 @@ class CLexer:
|
||||
i = 0
|
||||
nline = len(line)
|
||||
while i < nline:
|
||||
if line[i] == '*' and i+1 < nline and line[i+1] == '/':
|
||||
self.line = line[i+2:]
|
||||
line = line[:i-1]
|
||||
if line[i] == '*' and i + 1 < nline and line[i + 1] == '/':
|
||||
self.line = line[i + 2:]
|
||||
line = line[:i - 1]
|
||||
nline = i
|
||||
found = 1
|
||||
break
|
||||
@ -542,11 +542,11 @@ class CLexer:
|
||||
return self.last
|
||||
i = 0
|
||||
while i < nline:
|
||||
if line[i] == '/' and i+1 < nline and line[i+1] == '/':
|
||||
if line[i] == '/' and i + 1 < nline and line[i + 1] == '/':
|
||||
self.line = line[i:]
|
||||
line = line[:i]
|
||||
break
|
||||
if line[i] == '/' and i+1 < nline and line[i+1] == '*':
|
||||
if line[i] == '/' and i + 1 < nline and line[i + 1] == '*':
|
||||
self.line = line[i:]
|
||||
line = line[:i]
|
||||
break
|
||||
@ -576,14 +576,14 @@ class CLexer:
|
||||
continue
|
||||
if line[i] in "+-*><=/%&!|.":
|
||||
if line[i] == '.' and i + 2 < nline and \
|
||||
line[i+1] == '.' and line[i+2] == '.':
|
||||
line[i + 1] == '.' and line[i + 2] == '.':
|
||||
self.tokens.append(('name', '...'))
|
||||
i = i + 3
|
||||
continue
|
||||
|
||||
j = i + 1
|
||||
if j < nline and line[j] in "+-*><=/%&!|":
|
||||
self.tokens.append(('op', line[i:j+1]))
|
||||
self.tokens.append(('op', line[i:j + 1]))
|
||||
i = j + 1
|
||||
else:
|
||||
self.tokens.append(('op', line[i]))
|
||||
@ -994,7 +994,7 @@ class CParser:
|
||||
lst.append(token[1])
|
||||
token = self.lexer.token()
|
||||
try:
|
||||
name = name.split('(') [0]
|
||||
name = name.split('(')[0]
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
@ -402,7 +402,7 @@ class Type:
|
||||
return string
|
||||
|
||||
def generate_typefromstring(self):
|
||||
string = " if (STREQ(type, \"%s\"))\n" % self.name
|
||||
string = " if (STREQ(type, \"%s\"))\n" % self.name
|
||||
string += " return esxVI_Type_%s;\n" % self.name
|
||||
|
||||
return string
|
||||
@ -410,11 +410,11 @@ class Type:
|
||||
|
||||
class GenericObject(Type):
|
||||
FEATURE__DYNAMIC_CAST = (1 << 1)
|
||||
FEATURE__LIST = (1 << 2)
|
||||
FEATURE__DEEP_COPY = (1 << 3)
|
||||
FEATURE__ANY_TYPE = (1 << 4)
|
||||
FEATURE__SERIALIZE = (1 << 5)
|
||||
FEATURE__DESERIALIZE = (1 << 6)
|
||||
FEATURE__LIST = (1 << 2)
|
||||
FEATURE__DEEP_COPY = (1 << 3)
|
||||
FEATURE__ANY_TYPE = (1 << 4)
|
||||
FEATURE__SERIALIZE = (1 << 5)
|
||||
FEATURE__DESERIALIZE = (1 << 6)
|
||||
|
||||
def __init__(self, name, category, managed, generic_objects_by_name):
|
||||
Type.__init__(self, "struct", name)
|
||||
|
@ -127,7 +127,7 @@ class WmiClass:
|
||||
|
||||
for property in cls.properties:
|
||||
source += property.generate_typemap()
|
||||
source += ' { "", "", 0 },\n' # null terminated
|
||||
source += ' { "", "", 0 },\n' # null terminated
|
||||
source += '};\n\n'
|
||||
|
||||
source += self._define_WmiInfo_struct()
|
||||
|
@ -184,8 +184,8 @@ def formatCPUData(cpuData, path, comment):
|
||||
if "msr" in cpuData:
|
||||
msr = cpuData["msr"]
|
||||
for index in sorted(msr.keys()):
|
||||
f.write(" <msr index='0x%x' edx='0x%08x' eax='0x%08x'/>\n" %(
|
||||
index, msr[index]['edx'], msr[index]['eax']))
|
||||
f.write(" <msr index='0x%x' edx='0x%08x' eax='0x%08x'/>\n" %
|
||||
(index, msr[index]['edx'], msr[index]['eax']))
|
||||
|
||||
f.write("</cpudata>\n")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user