mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 01:18:00 +03:00
python: sanitize indentation after line continuations
Line continuations should be 4 space indented unless a previous opening brace required different alignment. docs/apibuild.py:2014:24: E126 continuation line over-indented for hanging indent token[0], token[1])) ^ docs/apibuild.py:74:3: E121 continuation line under-indented for hanging indent "ATTRIBUTE_UNUSED": (0, "macro keyword"), ^ ...more... Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
43d29cb40b
commit
3df69e628f
@ -883,12 +883,10 @@ sc_require_enum_last_marker:
|
||||
exit 1; } || :
|
||||
|
||||
# Validate many python style rules
|
||||
FLAKE8_INDENTATION = E114,E115,E116,E121,E125,E126,E127,E128,E129,E131
|
||||
FLAKE8_LINE_LENGTH = E501
|
||||
FLAKE8_WARNINGS = W504
|
||||
|
||||
FLAKE8_IGNORE = $(FLAKE8_INDENTATION),$\
|
||||
$(FLAKE8_LINE_LENGTH),$\
|
||||
FLAKE8_IGNORE = $(FLAKE8_LINE_LENGTH),$\
|
||||
$(FLAKE8_WARNINGS) \
|
||||
$(NULL)
|
||||
|
||||
|
@ -909,8 +909,8 @@ class CParser:
|
||||
i = i + 1
|
||||
if i >= nbargs:
|
||||
if not quiet:
|
||||
self.warning("Unable to find arg %s from function comment for %s" % (
|
||||
arg, name))
|
||||
self.warning("Unable to find arg %s from function comment for %s" %
|
||||
(arg, name))
|
||||
while len(lines) > 0 and lines[0] == '*':
|
||||
del lines[0]
|
||||
desc = None
|
||||
@ -989,8 +989,8 @@ class CParser:
|
||||
name = token[1]
|
||||
lst = []
|
||||
token = self.lexer.token()
|
||||
while token is not None and token[0] == 'preproc' and \
|
||||
token[1][0] != '#':
|
||||
while (token is not None and token[0] == 'preproc' and
|
||||
token[1][0] != '#'):
|
||||
lst.append(token[1])
|
||||
token = self.lexer.token()
|
||||
try:
|
||||
@ -1058,17 +1058,17 @@ class CParser:
|
||||
except Exception:
|
||||
pass
|
||||
elif name == "#else":
|
||||
if self.conditionals != [] and \
|
||||
self.defines[-1].find('ENABLED') != -1:
|
||||
if (self.conditionals != [] and
|
||||
self.defines[-1].find('ENABLED') != -1):
|
||||
self.conditionals[-1] = "!(%s)" % self.conditionals[-1]
|
||||
elif name == "#endif":
|
||||
if self.conditionals != [] and \
|
||||
self.defines[-1].find('ENABLED') != -1:
|
||||
if (self.conditionals != [] and
|
||||
self.defines[-1].find('ENABLED') != -1):
|
||||
self.conditionals = self.conditionals[:-1]
|
||||
self.defines = self.defines[:-1]
|
||||
token = self.lexer.token()
|
||||
while token is not None and token[0] == 'preproc' and \
|
||||
token[1][0] != '#':
|
||||
while (token is not None and token[0] == 'preproc' and
|
||||
token[1][0] != '#'):
|
||||
token = self.lexer.token()
|
||||
return token
|
||||
|
||||
@ -1670,7 +1670,8 @@ class CParser:
|
||||
return token
|
||||
token = self.token()
|
||||
while token is not None and (token[0] == "op" or
|
||||
token[0] == "name" and token[1] == "const"):
|
||||
token[0] == "name" and
|
||||
token[1] == "const"):
|
||||
self.type = self.type + " " + token[1]
|
||||
token = self.token()
|
||||
|
||||
@ -1718,8 +1719,8 @@ class CParser:
|
||||
while token is not None and token[0] == "sep" and token[1] == '[':
|
||||
self.type = self.type + token[1]
|
||||
token = self.token()
|
||||
while token is not None and token[0] != 'sep' and \
|
||||
token[1] != ']' and token[1] != ';':
|
||||
while (token is not None and token[0] != 'sep' and
|
||||
token[1] != ']' and token[1] != ';'):
|
||||
self.type = self.type + token[1]
|
||||
token = self.token()
|
||||
if token is not None and token[0] == 'sep' and token[1] == ']':
|
||||
@ -1872,9 +1873,9 @@ class CParser:
|
||||
if token[0] == 'name':
|
||||
token = self.parseGlobal(token)
|
||||
else:
|
||||
self.error(
|
||||
"token %s %s unexpected at the top level" % (
|
||||
token[0], token[1]))
|
||||
self.error(("token %s %s unexpected at the "
|
||||
"top level") %
|
||||
(token[0], token[1]))
|
||||
token = self.parseGlobal(token)
|
||||
# print('Exiting extern "C" line', self.lineno())
|
||||
token = self.token()
|
||||
@ -1933,7 +1934,8 @@ class CParser:
|
||||
if type == "struct":
|
||||
self.checkLongLegacyStruct(self.name, self.struct_fields)
|
||||
self.index_add(self.name, self.filename,
|
||||
not self.is_header, "struct", self.struct_fields)
|
||||
not self.is_header, "struct",
|
||||
self.struct_fields)
|
||||
else:
|
||||
self.index_add(self.name, self.filename,
|
||||
not self.is_header, "variable", type)
|
||||
@ -1946,14 +1948,16 @@ class CParser:
|
||||
if token[0] == "sep" and token[1] == ";":
|
||||
self.checkLongLegacyFunction(self.name, type, self.signature)
|
||||
d = self.mergeFunctionComment(self.name,
|
||||
((type, None), self.signature), 1)
|
||||
((type, None),
|
||||
self.signature), 1)
|
||||
self.index_add(self.name, self.filename, static,
|
||||
"function", d)
|
||||
token = self.token()
|
||||
elif token[0] == "sep" and token[1] == "{":
|
||||
self.checkLongLegacyFunction(self.name, type, self.signature)
|
||||
d = self.mergeFunctionComment(self.name,
|
||||
((type, None), self.signature), static)
|
||||
((type, None),
|
||||
self.signature), static)
|
||||
self.index_add(self.name, self.filename, static,
|
||||
"function", d)
|
||||
token = self.token()
|
||||
@ -2407,8 +2411,8 @@ class docBuilder:
|
||||
for id in typ:
|
||||
idf = self.idx.identifiers[id]
|
||||
module = idf.header
|
||||
output.write(" <reference name='%s' href='%s'/>\n" % (id,
|
||||
'html/' + self.basename + '-' +
|
||||
output.write(" <reference name='%s' href='%s'/>\n" %
|
||||
(id, 'html/' + self.basename + '-' +
|
||||
self.modulename_file(module) + '.html#' +
|
||||
id))
|
||||
|
||||
|
@ -453,8 +453,8 @@ class GenericObject(Type):
|
||||
members += "\n"
|
||||
|
||||
if self.extends is not None:
|
||||
members += self.generic_objects_by_name[self.extends] \
|
||||
.generate_struct_members(add_banner=True,
|
||||
obj = self.generic_objects_by_name[self.extends]
|
||||
members += obj.generate_struct_members(add_banner=True,
|
||||
struct_gap=False) + "\n"
|
||||
|
||||
if self.extends is not None or add_banner:
|
||||
@ -482,8 +482,8 @@ class GenericObject(Type):
|
||||
% (suffix, extended_by)
|
||||
|
||||
for extended_by in self.extended_by:
|
||||
source += self.generic_objects_by_name[extended_by] \
|
||||
.generate_dispatch(suffix, False)
|
||||
obj = self.generic_objects_by_name[extended_by]
|
||||
source += obj.generate_dispatch(suffix, False)
|
||||
|
||||
return source
|
||||
|
||||
@ -491,8 +491,8 @@ class GenericObject(Type):
|
||||
source = ""
|
||||
|
||||
if self.extends is not None:
|
||||
source += self.generic_objects_by_name[self.extends] \
|
||||
.generate_free_code(add_banner=True) + "\n"
|
||||
obj = self.generic_objects_by_name[self.extends]
|
||||
source += obj.generate_free_code(add_banner=True) + "\n"
|
||||
|
||||
if self.extends is not None or add_banner:
|
||||
source += " /* %s */\n" % self.name
|
||||
@ -516,8 +516,8 @@ class GenericObject(Type):
|
||||
source = ""
|
||||
|
||||
if self.extends is not None:
|
||||
source += self.generic_objects_by_name[self.extends] \
|
||||
.generate_validate_code(add_banner=True) + "\n"
|
||||
obj = self.generic_objects_by_name[self.extends]
|
||||
source += obj.generate_validate_code(add_banner=True) + "\n"
|
||||
|
||||
if self.extends is not None or add_banner:
|
||||
source += " /* %s */\n" % self.name
|
||||
@ -564,8 +564,8 @@ class Object(GenericObject):
|
||||
% extended_by
|
||||
|
||||
for extended_by in self.extended_by:
|
||||
source += objects_by_name[extended_by] \
|
||||
.generate_dynamic_cast_code(False)
|
||||
obj = objects_by_name[extended_by]
|
||||
source += obj.generate_dynamic_cast_code(False)
|
||||
|
||||
return source
|
||||
|
||||
@ -573,8 +573,8 @@ class Object(GenericObject):
|
||||
source = ""
|
||||
|
||||
if self.extends is not None:
|
||||
source += objects_by_name[self.extends] \
|
||||
.generate_deep_copy_code(add_banner=True) + "\n"
|
||||
obj = objects_by_name[self.extends]
|
||||
source += obj.generate_deep_copy_code(add_banner=True) + "\n"
|
||||
|
||||
if self.extends is not None or add_banner:
|
||||
source += " /* %s */\n" % self.name
|
||||
@ -598,8 +598,8 @@ class Object(GenericObject):
|
||||
source = ""
|
||||
|
||||
if self.extends is not None:
|
||||
source += objects_by_name[self.extends] \
|
||||
.generate_serialize_code(add_banner=True) + "\n"
|
||||
obj = objects_by_name[self.extends]
|
||||
source += obj.generate_serialize_code(add_banner=True) + "\n"
|
||||
|
||||
if self.extends is not None or add_banner:
|
||||
source += " /* %s */\n" % self.name
|
||||
@ -616,8 +616,8 @@ class Object(GenericObject):
|
||||
source = ""
|
||||
|
||||
if self.extends is not None:
|
||||
source += objects_by_name[self.extends] \
|
||||
.generate_deserialize_code(add_banner=True) + "\n"
|
||||
obj = objects_by_name[self.extends]
|
||||
source += obj.generate_deserialize_code(add_banner=True) + "\n"
|
||||
|
||||
if self.extends is not None or add_banner:
|
||||
source += " /* %s */\n" % self.name
|
||||
@ -671,40 +671,46 @@ class Object(GenericObject):
|
||||
% (self.name, self.name, self.name)
|
||||
|
||||
if self.features & Object.FEATURE__LIST:
|
||||
header += ("int esxVI_%s_DeepCopyList(esxVI_%s **dstList, "
|
||||
"esxVI_%s *srcList);\n") \
|
||||
% (self.name, self.name, self.name)
|
||||
header += ((
|
||||
"int esxVI_%s_DeepCopyList(esxVI_%s **dstList, "
|
||||
" esxVI_%s *srcList);\n") %
|
||||
(self.name, self.name, self.name))
|
||||
|
||||
if self.features & Object.FEATURE__ANY_TYPE:
|
||||
header += ("int esxVI_%s_CastFromAnyType(esxVI_AnyType *anyType, "
|
||||
"esxVI_%s **item);\n") \
|
||||
% (self.name, self.name)
|
||||
header += ((
|
||||
"int esxVI_%s_CastFromAnyType(esxVI_AnyType *anyType, "
|
||||
" esxVI_%s **item);\n") %
|
||||
(self.name, self.name))
|
||||
|
||||
if self.features & Object.FEATURE__LIST:
|
||||
header += ("int esxVI_%s_CastListFromAnyType(esxVI_AnyType *anyType, "
|
||||
"esxVI_%s **list);\n") \
|
||||
% (self.name, self.name)
|
||||
header += ((
|
||||
"int esxVI_%s_CastListFromAnyType(esxVI_AnyType *anyType, "
|
||||
" esxVI_%s **list);\n") %
|
||||
(self.name, self.name))
|
||||
|
||||
if self.features & Object.FEATURE__SERIALIZE:
|
||||
header += ("int esxVI_%s_Serialize(esxVI_%s *item, "
|
||||
header += ((
|
||||
"int esxVI_%s_Serialize(esxVI_%s *item, "
|
||||
" const char *element, "
|
||||
"virBufferPtr output);\n") \
|
||||
% (self.name, self.name)
|
||||
" virBufferPtr output);\n") %
|
||||
(self.name, self.name))
|
||||
|
||||
if self.features & Object.FEATURE__LIST:
|
||||
header += ("int esxVI_%s_SerializeList(esxVI_%s *list, "
|
||||
header += ((
|
||||
"int esxVI_%s_SerializeList(esxVI_%s *list, "
|
||||
" const char *element, "
|
||||
"virBufferPtr output);\n") \
|
||||
% (self.name, self.name)
|
||||
" virBufferPtr output);\n") %
|
||||
(self.name, self.name))
|
||||
|
||||
if self.features & Object.FEATURE__DESERIALIZE:
|
||||
header += "int esxVI_%s_Deserialize(xmlNodePtr node, esxVI_%s **item);\n" \
|
||||
% (self.name, self.name)
|
||||
|
||||
if self.features & Object.FEATURE__LIST:
|
||||
header += ("int esxVI_%s_DeserializeList(xmlNodePtr node, "
|
||||
"esxVI_%s **list);\n") \
|
||||
% (self.name, self.name)
|
||||
header += ((
|
||||
"int esxVI_%s_DeserializeList(xmlNodePtr node, "
|
||||
" esxVI_%s **list);\n") %
|
||||
(self.name, self.name))
|
||||
|
||||
header += "\n\n\n"
|
||||
|
||||
@ -887,8 +893,8 @@ class ManagedObject(GenericObject):
|
||||
source = ""
|
||||
|
||||
if self.extends is not None:
|
||||
source += managed_objects_by_name[self.extends] \
|
||||
.generate_lookup_code1(add_banner=True) + "\n"
|
||||
obj = managed_objects_by_name[self.extends]
|
||||
source += obj.generate_lookup_code1(add_banner=True) + "\n"
|
||||
|
||||
if self.extends is not None or add_banner:
|
||||
source += " /* %s */\n" % self.name
|
||||
@ -912,8 +918,8 @@ class ManagedObject(GenericObject):
|
||||
source = ""
|
||||
|
||||
if self.extends is not None:
|
||||
source += managed_objects_by_name[self.extends] \
|
||||
.generate_lookup_code2(add_banner=True) + "\n"
|
||||
obj = managed_objects_by_name[self.extends]
|
||||
source += obj.generate_lookup_code2(add_banner=True) + "\n"
|
||||
|
||||
if self.extends is not None or add_banner:
|
||||
source += " /* %s */\n" % self.name
|
||||
@ -1239,11 +1245,11 @@ def parse_method(block):
|
||||
|
||||
|
||||
def is_known_type(type):
|
||||
return type in predefined_objects or \
|
||||
type in predefined_enums or \
|
||||
type in objects_by_name or \
|
||||
type in managed_objects_by_name or \
|
||||
type in enums_by_name
|
||||
return (type in predefined_objects or
|
||||
type in predefined_enums or
|
||||
type in objects_by_name or
|
||||
type in managed_objects_by_name or
|
||||
type in enums_by_name)
|
||||
|
||||
|
||||
def open_and_print(filename):
|
||||
@ -1497,17 +1503,19 @@ def propagate_feature(obj, feature):
|
||||
return
|
||||
|
||||
for property in obj.properties:
|
||||
if property.occurrence == OCCURRENCE__IGNORED or \
|
||||
not property.is_type_generated():
|
||||
if (property.occurrence == OCCURRENCE__IGNORED or
|
||||
not property.is_type_generated()):
|
||||
continue
|
||||
|
||||
if property.is_enum():
|
||||
if feature == Object.FEATURE__SERIALIZE and \
|
||||
not (enums_by_name[property.type].features & Enum.FEATURE__SERIALIZE):
|
||||
if (feature == Object.FEATURE__SERIALIZE and
|
||||
not (enums_by_name[property.type].features &
|
||||
Enum.FEATURE__SERIALIZE)):
|
||||
enums_by_name[property.type].features |= Enum.FEATURE__SERIALIZE
|
||||
features_have_changed = True
|
||||
elif feature == Object.FEATURE__DESERIALIZE and \
|
||||
not (enums_by_name[property.type].features & Enum.FEATURE__DESERIALIZE):
|
||||
elif (feature == Object.FEATURE__DESERIALIZE and
|
||||
not (enums_by_name[property.type].features &
|
||||
Enum.FEATURE__DESERIALIZE)):
|
||||
enums_by_name[property.type].features |= Enum.FEATURE__DESERIALIZE
|
||||
features_have_changed = True
|
||||
elif property.is_object():
|
||||
|
Loading…
Reference in New Issue
Block a user