mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06: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
|
# Validate many python style rules
|
||||||
FLAKE8_INDENTATION = E114,E115,E116,E121,E125,E126,E127,E128,E129,E131
|
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_LINE_LENGTH = E501
|
||||||
FLAKE8_WARNINGS = W504
|
FLAKE8_WARNINGS = W504
|
||||||
|
|
||||||
FLAKE8_IGNORE = $(FLAKE8_INDENTATION),$\
|
FLAKE8_IGNORE = $(FLAKE8_INDENTATION),$\
|
||||||
$(FLAKE8_WHITESPACE),$\
|
|
||||||
$(FLAKE8_LINE_LENGTH),$\
|
$(FLAKE8_LINE_LENGTH),$\
|
||||||
$(FLAKE8_WARNINGS) \
|
$(FLAKE8_WARNINGS) \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
@ -520,9 +520,9 @@ class CLexer:
|
|||||||
i = 0
|
i = 0
|
||||||
nline = len(line)
|
nline = len(line)
|
||||||
while i < nline:
|
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+2:]
|
self.line = line[i + 2:]
|
||||||
line = line[:i-1]
|
line = line[:i - 1]
|
||||||
nline = i
|
nline = i
|
||||||
found = 1
|
found = 1
|
||||||
break
|
break
|
||||||
@ -542,11 +542,11 @@ class CLexer:
|
|||||||
return self.last
|
return self.last
|
||||||
i = 0
|
i = 0
|
||||||
while i < nline:
|
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:]
|
self.line = line[i:]
|
||||||
line = line[:i]
|
line = line[:i]
|
||||||
break
|
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:]
|
self.line = line[i:]
|
||||||
line = line[:i]
|
line = line[:i]
|
||||||
break
|
break
|
||||||
@ -576,14 +576,14 @@ class CLexer:
|
|||||||
continue
|
continue
|
||||||
if line[i] in "+-*><=/%&!|.":
|
if line[i] in "+-*><=/%&!|.":
|
||||||
if line[i] == '.' and i + 2 < nline and \
|
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', '...'))
|
self.tokens.append(('name', '...'))
|
||||||
i = i + 3
|
i = i + 3
|
||||||
continue
|
continue
|
||||||
|
|
||||||
j = i + 1
|
j = i + 1
|
||||||
if j < nline and line[j] in "+-*><=/%&!|":
|
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
|
i = j + 1
|
||||||
else:
|
else:
|
||||||
self.tokens.append(('op', line[i]))
|
self.tokens.append(('op', line[i]))
|
||||||
@ -994,7 +994,7 @@ class CParser:
|
|||||||
lst.append(token[1])
|
lst.append(token[1])
|
||||||
token = self.lexer.token()
|
token = self.lexer.token()
|
||||||
try:
|
try:
|
||||||
name = name.split('(') [0]
|
name = name.split('(')[0]
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -402,7 +402,7 @@ class Type:
|
|||||||
return string
|
return string
|
||||||
|
|
||||||
def generate_typefromstring(self):
|
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
|
string += " return esxVI_Type_%s;\n" % self.name
|
||||||
|
|
||||||
return string
|
return string
|
||||||
@ -410,11 +410,11 @@ class Type:
|
|||||||
|
|
||||||
class GenericObject(Type):
|
class GenericObject(Type):
|
||||||
FEATURE__DYNAMIC_CAST = (1 << 1)
|
FEATURE__DYNAMIC_CAST = (1 << 1)
|
||||||
FEATURE__LIST = (1 << 2)
|
FEATURE__LIST = (1 << 2)
|
||||||
FEATURE__DEEP_COPY = (1 << 3)
|
FEATURE__DEEP_COPY = (1 << 3)
|
||||||
FEATURE__ANY_TYPE = (1 << 4)
|
FEATURE__ANY_TYPE = (1 << 4)
|
||||||
FEATURE__SERIALIZE = (1 << 5)
|
FEATURE__SERIALIZE = (1 << 5)
|
||||||
FEATURE__DESERIALIZE = (1 << 6)
|
FEATURE__DESERIALIZE = (1 << 6)
|
||||||
|
|
||||||
def __init__(self, name, category, managed, generic_objects_by_name):
|
def __init__(self, name, category, managed, generic_objects_by_name):
|
||||||
Type.__init__(self, "struct", name)
|
Type.__init__(self, "struct", name)
|
||||||
|
@ -127,7 +127,7 @@ class WmiClass:
|
|||||||
|
|
||||||
for property in cls.properties:
|
for property in cls.properties:
|
||||||
source += property.generate_typemap()
|
source += property.generate_typemap()
|
||||||
source += ' { "", "", 0 },\n' # null terminated
|
source += ' { "", "", 0 },\n' # null terminated
|
||||||
source += '};\n\n'
|
source += '};\n\n'
|
||||||
|
|
||||||
source += self._define_WmiInfo_struct()
|
source += self._define_WmiInfo_struct()
|
||||||
|
@ -184,8 +184,8 @@ def formatCPUData(cpuData, path, comment):
|
|||||||
if "msr" in cpuData:
|
if "msr" in cpuData:
|
||||||
msr = cpuData["msr"]
|
msr = cpuData["msr"]
|
||||||
for index in sorted(msr.keys()):
|
for index in sorted(msr.keys()):
|
||||||
f.write(" <msr index='0x%x' edx='0x%08x' eax='0x%08x'/>\n" %(
|
f.write(" <msr index='0x%x' edx='0x%08x' eax='0x%08x'/>\n" %
|
||||||
index, msr[index]['edx'], msr[index]['eax']))
|
(index, msr[index]['edx'], msr[index]['eax']))
|
||||||
|
|
||||||
f.write("</cpudata>\n")
|
f.write("</cpudata>\n")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user