apibuild: Fix indentation not multiple of 4
PEP8 recommends that the number of spaces used for indentation of Python code to be a multiple of four [1] [2]. 1: https://lintlyci.github.io/Flake8Rules/rules/E111.html 2: https://lintlyci.github.io/Flake8Rules/rules/E114.html Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
This commit is contained in:
parent
aad30c3e57
commit
eb327e6c61
296
docs/apibuild.py
296
docs/apibuild.py
@ -248,11 +248,12 @@ class index:
|
|||||||
return None
|
return None
|
||||||
d = None
|
d = None
|
||||||
try:
|
try:
|
||||||
d = self.identifiers[name]
|
d = self.identifiers[name]
|
||||||
d.update(header, module, type, lineno, info, extra, conditionals)
|
d.update(header, module, type, lineno, info, extra, conditionals)
|
||||||
except:
|
except:
|
||||||
d = identifier(name, header, module, type, lineno, info, extra, conditionals)
|
d = identifier(name, header, module, type, lineno, info, extra,
|
||||||
self.identifiers[name] = d
|
conditionals)
|
||||||
|
self.identifiers[name] = d
|
||||||
|
|
||||||
if d is not None and static == 1:
|
if d is not None and static == 1:
|
||||||
d.set_static(1)
|
d.set_static(1)
|
||||||
@ -265,16 +266,18 @@ class index:
|
|||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def add(self, name, header, module, static, type, lineno, info=None, extra=None, conditionals=None):
|
def add(self, name, header, module, static, type, lineno, info=None,
|
||||||
|
extra=None, conditionals=None):
|
||||||
if name[0:2] == '__':
|
if name[0:2] == '__':
|
||||||
return None
|
return None
|
||||||
d = None
|
d = None
|
||||||
try:
|
try:
|
||||||
d = self.identifiers[name]
|
d = self.identifiers[name]
|
||||||
d.update(header, module, type, lineno, info, extra, conditionals)
|
d.update(header, module, type, lineno, info, extra, conditionals)
|
||||||
except:
|
except:
|
||||||
d = identifier(name, header, module, type, lineno, info, extra, conditionals)
|
d = identifier(name, header, module, type, lineno, info, extra,
|
||||||
self.identifiers[name] = d
|
conditionals)
|
||||||
|
self.identifiers[name] = d
|
||||||
|
|
||||||
if d is not None and static == 1:
|
if d is not None and static == 1:
|
||||||
d.set_static(1)
|
d.set_static(1)
|
||||||
@ -308,92 +311,93 @@ class index:
|
|||||||
|
|
||||||
def merge(self, idx):
|
def merge(self, idx):
|
||||||
for id in idx.functions.keys():
|
for id in idx.functions.keys():
|
||||||
#
|
#
|
||||||
# macro might be used to override functions or variables
|
# macro might be used to override functions or variables
|
||||||
# definitions
|
# definitions
|
||||||
#
|
#
|
||||||
if id in self.macros:
|
if id in self.macros:
|
||||||
del self.macros[id]
|
del self.macros[id]
|
||||||
if id in self.functions:
|
if id in self.functions:
|
||||||
self.warning("function %s from %s redeclared in %s" % (
|
self.warning("function %s from %s redeclared in %s" % (
|
||||||
id, self.functions[id].header, idx.functions[id].header))
|
id, self.functions[id].header, idx.functions[id].header))
|
||||||
else:
|
else:
|
||||||
self.functions[id] = idx.functions[id]
|
self.functions[id] = idx.functions[id]
|
||||||
self.identifiers[id] = idx.functions[id]
|
self.identifiers[id] = idx.functions[id]
|
||||||
for id in idx.variables.keys():
|
for id in idx.variables.keys():
|
||||||
#
|
#
|
||||||
# macro might be used to override functions or variables
|
# macro might be used to override functions or variables
|
||||||
# definitions
|
# definitions
|
||||||
#
|
#
|
||||||
if id in self.macros:
|
if id in self.macros:
|
||||||
del self.macros[id]
|
del self.macros[id]
|
||||||
if id in self.variables:
|
if id in self.variables:
|
||||||
self.warning("variable %s from %s redeclared in %s" % (
|
self.warning("variable %s from %s redeclared in %s" % (
|
||||||
id, self.variables[id].header, idx.variables[id].header))
|
id, self.variables[id].header, idx.variables[id].header))
|
||||||
else:
|
else:
|
||||||
self.variables[id] = idx.variables[id]
|
self.variables[id] = idx.variables[id]
|
||||||
self.identifiers[id] = idx.variables[id]
|
self.identifiers[id] = idx.variables[id]
|
||||||
for id in idx.structs.keys():
|
for id in idx.structs.keys():
|
||||||
if id in self.structs:
|
if id in self.structs:
|
||||||
self.warning("struct %s from %s redeclared in %s" % (
|
self.warning("struct %s from %s redeclared in %s" % (
|
||||||
id, self.structs[id].header, idx.structs[id].header))
|
id, self.structs[id].header, idx.structs[id].header))
|
||||||
else:
|
else:
|
||||||
self.structs[id] = idx.structs[id]
|
self.structs[id] = idx.structs[id]
|
||||||
self.identifiers[id] = idx.structs[id]
|
self.identifiers[id] = idx.structs[id]
|
||||||
for id in idx.unions.keys():
|
for id in idx.unions.keys():
|
||||||
if id in self.unions:
|
if id in self.unions:
|
||||||
print("union %s from %s redeclared in %s" % (
|
print("union %s from %s redeclared in %s" % (
|
||||||
id, self.unions[id].header, idx.unions[id].header))
|
id, self.unions[id].header, idx.unions[id].header))
|
||||||
else:
|
else:
|
||||||
self.unions[id] = idx.unions[id]
|
self.unions[id] = idx.unions[id]
|
||||||
self.identifiers[id] = idx.unions[id]
|
self.identifiers[id] = idx.unions[id]
|
||||||
for id in idx.typedefs.keys():
|
for id in idx.typedefs.keys():
|
||||||
if id in self.typedefs:
|
if id in self.typedefs:
|
||||||
self.warning("typedef %s from %s redeclared in %s" % (
|
self.warning("typedef %s from %s redeclared in %s" % (
|
||||||
id, self.typedefs[id].header, idx.typedefs[id].header))
|
id, self.typedefs[id].header, idx.typedefs[id].header))
|
||||||
else:
|
else:
|
||||||
self.typedefs[id] = idx.typedefs[id]
|
self.typedefs[id] = idx.typedefs[id]
|
||||||
self.identifiers[id] = idx.typedefs[id]
|
self.identifiers[id] = idx.typedefs[id]
|
||||||
for id in idx.macros.keys():
|
for id in idx.macros.keys():
|
||||||
#
|
#
|
||||||
# macro might be used to override functions or variables
|
# macro might be used to override functions or variables
|
||||||
# definitions
|
# definitions
|
||||||
#
|
#
|
||||||
if id in self.variables:
|
if id in self.variables:
|
||||||
continue
|
continue
|
||||||
if id in self.functions:
|
if id in self.functions:
|
||||||
continue
|
continue
|
||||||
if id in self.enums:
|
if id in self.enums:
|
||||||
continue
|
continue
|
||||||
if id in self.macros:
|
if id in self.macros:
|
||||||
self.warning("macro %s from %s redeclared in %s" % (
|
self.warning("macro %s from %s redeclared in %s" % (
|
||||||
id, self.macros[id].header, idx.macros[id].header))
|
id, self.macros[id].header, idx.macros[id].header))
|
||||||
else:
|
else:
|
||||||
self.macros[id] = idx.macros[id]
|
self.macros[id] = idx.macros[id]
|
||||||
self.identifiers[id] = idx.macros[id]
|
self.identifiers[id] = idx.macros[id]
|
||||||
for id in idx.enums.keys():
|
for id in idx.enums.keys():
|
||||||
if id in self.enums:
|
if id in self.enums:
|
||||||
self.warning("enum %s from %s redeclared in %s" % (
|
self.warning("enum %s from %s redeclared in %s" % (
|
||||||
id, self.enums[id].header, idx.enums[id].header))
|
id, self.enums[id].header, idx.enums[id].header))
|
||||||
else:
|
else:
|
||||||
self.enums[id] = idx.enums[id]
|
self.enums[id] = idx.enums[id]
|
||||||
self.identifiers[id] = idx.enums[id]
|
self.identifiers[id] = idx.enums[id]
|
||||||
|
|
||||||
def merge_public(self, idx):
|
def merge_public(self, idx):
|
||||||
for id in idx.functions.keys():
|
for id in idx.functions.keys():
|
||||||
if id in self.functions:
|
if id in self.functions:
|
||||||
up = idx.functions[id]
|
up = idx.functions[id]
|
||||||
# check that function condition agrees with header
|
# check that function condition agrees with header
|
||||||
if up.conditionals != self.functions[id].conditionals:
|
if up.conditionals != self.functions[id].conditionals:
|
||||||
self.warning("Header condition differs from Function"
|
self.warning("Header condition differs from Function"
|
||||||
" for %s:" % id)
|
" for %s:" % id)
|
||||||
self.warning(" H: %s" % self.functions[id].conditionals)
|
self.warning(" H: %s" % self.functions[id].conditionals)
|
||||||
self.warning(" C: %s" % up.conditionals)
|
self.warning(" C: %s" % up.conditionals)
|
||||||
self.functions[id].update(None, up.module, up.type, up.info, up.extra)
|
self.functions[id].update(None, up.module, up.type, up.info,
|
||||||
# else:
|
up.extra)
|
||||||
# print("Function %s from %s is not declared in headers" % (
|
# else:
|
||||||
# id, idx.functions[id].module))
|
# print("Function %s from %s is not declared in headers" % (
|
||||||
# TODO: do the same for variables.
|
# id, idx.functions[id].module))
|
||||||
|
# TODO: do the same for variables.
|
||||||
|
|
||||||
def analyze_dict(self, type, dict):
|
def analyze_dict(self, type, dict):
|
||||||
count = 0
|
count = 0
|
||||||
@ -725,7 +729,7 @@ class CParser:
|
|||||||
elif line[i] == '*':
|
elif line[i] == '*':
|
||||||
return line[:i] + line[i + 1:]
|
return line[:i] + line[i + 1:]
|
||||||
else:
|
else:
|
||||||
return line
|
return line
|
||||||
return line
|
return line
|
||||||
|
|
||||||
def cleanupComment(self):
|
def cleanupComment(self):
|
||||||
@ -876,11 +880,11 @@ class CParser:
|
|||||||
|
|
||||||
return((args, desc))
|
return((args, desc))
|
||||||
|
|
||||||
#
|
#
|
||||||
# Parse a comment block and merge the information found in the
|
# Parse a comment block and merge the information found in the
|
||||||
# parameters descriptions, finally returns a block as complete
|
# parameters descriptions, finally returns a block as complete
|
||||||
# as possible
|
# as possible
|
||||||
#
|
#
|
||||||
def mergeFunctionComment(self, name, description, quiet=0):
|
def mergeFunctionComment(self, name, description, quiet=0):
|
||||||
global ignored_functions
|
global ignored_functions
|
||||||
|
|
||||||
@ -988,9 +992,9 @@ class CParser:
|
|||||||
desc = desc.strip()
|
desc = desc.strip()
|
||||||
|
|
||||||
if quiet == 0:
|
if quiet == 0:
|
||||||
#
|
#
|
||||||
# report missing comments
|
# report missing comments
|
||||||
#
|
#
|
||||||
i = 0
|
i = 0
|
||||||
while i < nbargs:
|
while i < nbargs:
|
||||||
if args[i][2] is None and args[i][0] != "void" and args[i][1] is not None:
|
if args[i][2] is None and args[i][0] != "void" and args[i][1] is not None:
|
||||||
@ -1022,7 +1026,7 @@ class CParser:
|
|||||||
if token is None:
|
if token is None:
|
||||||
return None
|
return None
|
||||||
if token[0] == 'preproc':
|
if token[0] == 'preproc':
|
||||||
# TODO macros with arguments
|
# TODO macros with arguments
|
||||||
name = token[1]
|
name = token[1]
|
||||||
lst = []
|
lst = []
|
||||||
token = self.lexer.token()
|
token = self.lexer.token()
|
||||||
@ -1107,11 +1111,11 @@ class CParser:
|
|||||||
token = self.lexer.token()
|
token = self.lexer.token()
|
||||||
return token
|
return token
|
||||||
|
|
||||||
#
|
#
|
||||||
# token acquisition on top of the lexer, it handle internally
|
# token acquisition on top of the lexer, it handle internally
|
||||||
# preprocessor and comments since they are logically not part of
|
# preprocessor and comments since they are logically not part of
|
||||||
# the program structure.
|
# the program structure.
|
||||||
#
|
#
|
||||||
def push(self, tok):
|
def push(self, tok):
|
||||||
self.lexer.push(tok)
|
self.lexer.push(tok)
|
||||||
|
|
||||||
@ -1148,9 +1152,9 @@ class CParser:
|
|||||||
return token
|
return token
|
||||||
return None
|
return None
|
||||||
|
|
||||||
#
|
#
|
||||||
# Parse a typedef, it records the type and its name.
|
# Parse a typedef, it records the type and its name.
|
||||||
#
|
#
|
||||||
def parseTypedef(self, token):
|
def parseTypedef(self, token):
|
||||||
if token is None:
|
if token is None:
|
||||||
return None
|
return None
|
||||||
@ -1160,7 +1164,7 @@ class CParser:
|
|||||||
return None
|
return None
|
||||||
base_type = self.type
|
base_type = self.type
|
||||||
type = base_type
|
type = base_type
|
||||||
#self.debug("end typedef type", token)
|
# self.debug("end typedef type", token)
|
||||||
while token is not None:
|
while token is not None:
|
||||||
if token[0] == "name":
|
if token[0] == "name":
|
||||||
name = token[1]
|
name = token[1]
|
||||||
@ -1185,7 +1189,7 @@ class CParser:
|
|||||||
else:
|
else:
|
||||||
self.error("parsing typedef: expecting a name")
|
self.error("parsing typedef: expecting a name")
|
||||||
return token
|
return token
|
||||||
#self.debug("end typedef", token)
|
# self.debug("end typedef", token)
|
||||||
if token is not None and token[0] == 'sep' and token[1] == ',':
|
if token is not None and token[0] == 'sep' and token[1] == ',':
|
||||||
type = base_type
|
type = base_type
|
||||||
token = self.token()
|
token = self.token()
|
||||||
@ -1203,10 +1207,10 @@ class CParser:
|
|||||||
token = self.token()
|
token = self.token()
|
||||||
return token
|
return token
|
||||||
|
|
||||||
#
|
#
|
||||||
# Parse a C code block, used for functions it parse till
|
# Parse a C code block, used for functions it parse till
|
||||||
# the balancing } included
|
# the balancing } included
|
||||||
#
|
#
|
||||||
def parseBlock(self, token):
|
def parseBlock(self, token):
|
||||||
while token is not None:
|
while token is not None:
|
||||||
if token[0] == "sep" and token[1] == "{":
|
if token[0] == "sep" and token[1] == "{":
|
||||||
@ -1242,27 +1246,27 @@ class CParser:
|
|||||||
token = self.token()
|
token = self.token()
|
||||||
return token
|
return token
|
||||||
|
|
||||||
#
|
#
|
||||||
# Parse a C struct definition till the balancing }
|
# Parse a C struct definition till the balancing }
|
||||||
#
|
#
|
||||||
def parseStruct(self, token):
|
def parseStruct(self, token):
|
||||||
fields = []
|
fields = []
|
||||||
#self.debug("start parseStruct", token)
|
# self.debug("start parseStruct", token)
|
||||||
while token is not None:
|
while token is not None:
|
||||||
if token[0] == "sep" and token[1] == "{":
|
if token[0] == "sep" and token[1] == "{":
|
||||||
token = self.token()
|
token = self.token()
|
||||||
token = self.parseTypeBlock(token)
|
token = self.parseTypeBlock(token)
|
||||||
elif token[0] == "sep" and token[1] == "}":
|
elif token[0] == "sep" and token[1] == "}":
|
||||||
self.struct_fields = fields
|
self.struct_fields = fields
|
||||||
#self.debug("end parseStruct", token)
|
# self.debug("end parseStruct", token)
|
||||||
#print(fields)
|
# print(fields)
|
||||||
token = self.token()
|
token = self.token()
|
||||||
return token
|
return token
|
||||||
else:
|
else:
|
||||||
base_type = self.type
|
base_type = self.type
|
||||||
#self.debug("before parseType", token)
|
# self.debug("before parseType", token)
|
||||||
token = self.parseType(token)
|
token = self.parseType(token)
|
||||||
#self.debug("after parseType", token)
|
# self.debug("after parseType", token)
|
||||||
if token is not None and token[0] == "name":
|
if token is not None and token[0] == "name":
|
||||||
fname = token[1]
|
fname = token[1]
|
||||||
token = self.token()
|
token = self.token()
|
||||||
@ -1293,13 +1297,13 @@ class CParser:
|
|||||||
token = self.token()
|
token = self.token()
|
||||||
self.type = base_type
|
self.type = base_type
|
||||||
self.struct_fields = fields
|
self.struct_fields = fields
|
||||||
#self.debug("end parseStruct", token)
|
# self.debug("end parseStruct", token)
|
||||||
#print(fields)
|
# print(fields)
|
||||||
return token
|
return token
|
||||||
|
|
||||||
#
|
#
|
||||||
# Parse a C union definition till the balancing }
|
# Parse a C union definition till the balancing }
|
||||||
#
|
#
|
||||||
def parseUnion(self, token):
|
def parseUnion(self, token):
|
||||||
fields = []
|
fields = []
|
||||||
# self.debug("start parseUnion", token)
|
# self.debug("start parseUnion", token)
|
||||||
@ -1347,9 +1351,9 @@ class CParser:
|
|||||||
# print(fields)
|
# print(fields)
|
||||||
return token
|
return token
|
||||||
|
|
||||||
#
|
#
|
||||||
# Parse a C enum block, parse till the balancing }
|
# Parse a C enum block, parse till the balancing }
|
||||||
#
|
#
|
||||||
def parseEnumBlock(self, token):
|
def parseEnumBlock(self, token):
|
||||||
self.enums = []
|
self.enums = []
|
||||||
name = None
|
name = None
|
||||||
@ -1512,10 +1516,10 @@ class CParser:
|
|||||||
|
|
||||||
return token
|
return token
|
||||||
|
|
||||||
#
|
#
|
||||||
# Parse a C definition block, used for structs or unions it parse till
|
# Parse a C definition block, used for structs or unions it parse till
|
||||||
# the balancing }
|
# the balancing }
|
||||||
#
|
#
|
||||||
def parseTypeBlock(self, token):
|
def parseTypeBlock(self, token):
|
||||||
while token is not None:
|
while token is not None:
|
||||||
if token[0] == "sep" and token[1] == "{":
|
if token[0] == "sep" and token[1] == "{":
|
||||||
@ -1528,11 +1532,11 @@ class CParser:
|
|||||||
token = self.token()
|
token = self.token()
|
||||||
return token
|
return token
|
||||||
|
|
||||||
#
|
#
|
||||||
# Parse a type: the fact that the type name can either occur after
|
# Parse a type: the fact that the type name can either occur after
|
||||||
# the definition or within the definition makes it a little harder
|
# the definition or within the definition makes it a little harder
|
||||||
# if inside, the name token is pushed back before returning
|
# if inside, the name token is pushed back before returning
|
||||||
#
|
#
|
||||||
def parseType(self, token):
|
def parseType(self, token):
|
||||||
self.type = ""
|
self.type = ""
|
||||||
self.struct_fields = []
|
self.struct_fields = []
|
||||||
@ -1710,9 +1714,9 @@ class CParser:
|
|||||||
self.type = self.type + " " + token[1]
|
self.type = self.type + " " + token[1]
|
||||||
token = self.token()
|
token = self.token()
|
||||||
|
|
||||||
#
|
#
|
||||||
# if there is a parenthesis here, this means a function type
|
# if there is a parenthesis here, this means a function type
|
||||||
#
|
#
|
||||||
if token is not None and token[0] == "sep" and token[1] == '(':
|
if token is not None and token[0] == "sep" and token[1] == '(':
|
||||||
self.type = self.type + token[1]
|
self.type = self.type + token[1]
|
||||||
token = self.token()
|
token = self.token()
|
||||||
@ -1743,9 +1747,9 @@ class CParser:
|
|||||||
token = nametok
|
token = nametok
|
||||||
return token
|
return token
|
||||||
|
|
||||||
#
|
#
|
||||||
# do some lookahead for arrays
|
# do some lookahead for arrays
|
||||||
#
|
#
|
||||||
if token is not None and token[0] == "name":
|
if token is not None and token[0] == "name":
|
||||||
nametok = token
|
nametok = token
|
||||||
token = self.token()
|
token = self.token()
|
||||||
@ -1765,7 +1769,7 @@ class CParser:
|
|||||||
self.error("parsing array type, ']' expected", token)
|
self.error("parsing array type, ']' expected", token)
|
||||||
return token
|
return token
|
||||||
elif token is not None and token[0] == "sep" and token[1] == ':':
|
elif token is not None and token[0] == "sep" and token[1] == ':':
|
||||||
# remove :12 in case it's a limited int size
|
# remove :12 in case it's a limited int size
|
||||||
token = self.token()
|
token = self.token()
|
||||||
token = self.token()
|
token = self.token()
|
||||||
self.lexer.push(token)
|
self.lexer.push(token)
|
||||||
@ -1773,9 +1777,9 @@ class CParser:
|
|||||||
|
|
||||||
return token
|
return token
|
||||||
|
|
||||||
#
|
#
|
||||||
# Parse a signature: '(' has been parsed and we scan the type definition
|
# Parse a signature: '(' has been parsed and we scan the type definition
|
||||||
# up to the ')' included
|
# up to the ')' included
|
||||||
def parseSignature(self, token):
|
def parseSignature(self, token):
|
||||||
signature = []
|
signature = []
|
||||||
if token is not None and token[0] == "sep" and token[1] == ')':
|
if token is not None and token[0] == "sep" and token[1] == ')':
|
||||||
@ -1791,7 +1795,7 @@ class CParser:
|
|||||||
token = self.token()
|
token = self.token()
|
||||||
continue
|
continue
|
||||||
elif token is not None and token[0] == "sep" and token[1] == ')':
|
elif token is not None and token[0] == "sep" and token[1] == ')':
|
||||||
# only the type was provided
|
# only the type was provided
|
||||||
if self.type == "...":
|
if self.type == "...":
|
||||||
signature.append((self.type, "...", None))
|
signature.append((self.type, "...", None))
|
||||||
else:
|
else:
|
||||||
@ -1885,10 +1889,10 @@ class CParser:
|
|||||||
"field '%s', use long long instead")
|
"field '%s', use long long instead")
|
||||||
% (name, field[1]))
|
% (name, field[1]))
|
||||||
|
|
||||||
#
|
#
|
||||||
# Parse a global definition, be it a type, variable or function
|
# Parse a global definition, be it a type, variable or function
|
||||||
# the extern "C" blocks are a bit nasty and require it to recurse.
|
# the extern "C" blocks are a bit nasty and require it to recurse.
|
||||||
#
|
#
|
||||||
def parseGlobal(self, token):
|
def parseGlobal(self, token):
|
||||||
static = 0
|
static = 0
|
||||||
if token[1] == 'extern':
|
if token[1] == 'extern':
|
||||||
@ -1945,9 +1949,9 @@ class CParser:
|
|||||||
token = self.token()
|
token = self.token()
|
||||||
|
|
||||||
if token is not None and token[0] == "op" and token[1] == "=":
|
if token is not None and token[0] == "op" and token[1] == "=":
|
||||||
#
|
#
|
||||||
# Skip the initialization of the variable
|
# Skip the initialization of the variable
|
||||||
#
|
#
|
||||||
token = self.token()
|
token = self.token()
|
||||||
if token[0] == 'sep' and token[1] == '{':
|
if token[0] == 'sep' and token[1] == '{':
|
||||||
token = self.token()
|
token = self.token()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user