提交 28593b5b 编写于 作者: R Radostin Stoyanov 提交者: Daniel P. Berrangé

apibuild: Remove whitespace before ', ' and ':'

PEP8 recommends removing whitespace immediately before a comma,
semicolon, or colon [1]. In addition remove multiple spaces after
keyword (PEP8 - E271).

1: https://www.python.org/dev/peps/pep-0008/#whitespace-in-expressions-and-statementsReviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
Signed-off-by: NRadostin Stoyanov <rstoyanov1@gmail.com>
上级 6d43a754
......@@ -1401,7 +1401,7 @@ class CParser:
while token[0] != "sep" or (token[1] != ',' and
token[1] != '}'):
# We might be dealing with '1U << 12' here
value = value + re.sub("^(\d+)U$","\\1", token[1])
value = value + re.sub("^(\d+)U$", "\\1", token[1])
token = self.token()
else:
try:
......@@ -1735,7 +1735,7 @@ class CParser:
while token is not None and token[0] == "op" and token[1] == '*':
self.type = self.type + token[1]
token = self.token()
if token is None or token[0] != "name" :
if token is None or token[0] != "name":
self.error("parsing function type, name expected", token)
return token
self.type = self.type + token[1]
......@@ -1825,41 +1825,42 @@ class CParser:
# this dict contains the functions that are allowed to use [unsigned]
# long for legacy reasons in their signature and return type. this list is
# fixed. new procedures and public APIs have to use [unsigned] long long
long_legacy_functions = \
{ "virGetVersion" : (False, ("libVer", "typeVer")),
"virConnectGetLibVersion" : (False, ("libVer")),
"virConnectGetVersion" : (False, ("hvVer")),
"virDomainGetMaxMemory" : (True, ()),
"virDomainMigrate" : (False, ("flags", "bandwidth")),
"virDomainMigrate2" : (False, ("flags", "bandwidth")),
"virDomainMigrateBegin3" : (False, ("flags", "bandwidth")),
"virDomainMigrateConfirm3" : (False, ("flags", "bandwidth")),
"virDomainMigrateDirect" : (False, ("flags", "bandwidth")),
"virDomainMigrateFinish" : (False, ("flags")),
"virDomainMigrateFinish2" : (False, ("flags")),
"virDomainMigrateFinish3" : (False, ("flags")),
"virDomainMigratePeer2Peer" : (False, ("flags", "bandwidth")),
"virDomainMigratePerform" : (False, ("flags", "bandwidth")),
"virDomainMigratePerform3" : (False, ("flags", "bandwidth")),
"virDomainMigratePrepare" : (False, ("flags", "bandwidth")),
"virDomainMigratePrepare2" : (False, ("flags", "bandwidth")),
"virDomainMigratePrepare3" : (False, ("flags", "bandwidth")),
"virDomainMigratePrepareTunnel" : (False, ("flags", "bandwidth")),
"virDomainMigratePrepareTunnel3" : (False, ("flags", "bandwidth")),
"virDomainMigrateToURI" : (False, ("flags", "bandwidth")),
"virDomainMigrateToURI2" : (False, ("flags", "bandwidth")),
"virDomainMigrateVersion1" : (False, ("flags", "bandwidth")),
"virDomainMigrateVersion2" : (False, ("flags", "bandwidth")),
"virDomainMigrateVersion3" : (False, ("flags", "bandwidth")),
"virDomainMigrateSetMaxSpeed" : (False, ("bandwidth")),
"virDomainSetMaxMemory" : (False, ("memory")),
"virDomainSetMemory" : (False, ("memory")),
"virDomainSetMemoryFlags" : (False, ("memory")),
"virDomainBlockCommit" : (False, ("bandwidth")),
"virDomainBlockJobSetSpeed" : (False, ("bandwidth")),
"virDomainBlockPull" : (False, ("bandwidth")),
"virDomainBlockRebase" : (False, ("bandwidth")),
"virDomainMigrateGetMaxSpeed" : (False, ("bandwidth")) }
long_legacy_functions = {
"virGetVersion": (False, ("libVer", "typeVer")),
"virConnectGetLibVersion": (False, ("libVer")),
"virConnectGetVersion": (False, ("hvVer")),
"virDomainGetMaxMemory": (True, ()),
"virDomainMigrate": (False, ("flags", "bandwidth")),
"virDomainMigrate2": (False, ("flags", "bandwidth")),
"virDomainMigrateBegin3": (False, ("flags", "bandwidth")),
"virDomainMigrateConfirm3": (False, ("flags", "bandwidth")),
"virDomainMigrateDirect": (False, ("flags", "bandwidth")),
"virDomainMigrateFinish": (False, ("flags")),
"virDomainMigrateFinish2": (False, ("flags")),
"virDomainMigrateFinish3": (False, ("flags")),
"virDomainMigratePeer2Peer": (False, ("flags", "bandwidth")),
"virDomainMigratePerform": (False, ("flags", "bandwidth")),
"virDomainMigratePerform3": (False, ("flags", "bandwidth")),
"virDomainMigratePrepare": (False, ("flags", "bandwidth")),
"virDomainMigratePrepare2": (False, ("flags", "bandwidth")),
"virDomainMigratePrepare3": (False, ("flags", "bandwidth")),
"virDomainMigratePrepareTunnel": (False, ("flags", "bandwidth")),
"virDomainMigratePrepareTunnel3": (False, ("flags", "bandwidth")),
"virDomainMigrateToURI": (False, ("flags", "bandwidth")),
"virDomainMigrateToURI2": (False, ("flags", "bandwidth")),
"virDomainMigrateVersion1": (False, ("flags", "bandwidth")),
"virDomainMigrateVersion2": (False, ("flags", "bandwidth")),
"virDomainMigrateVersion3": (False, ("flags", "bandwidth")),
"virDomainMigrateSetMaxSpeed": (False, ("bandwidth")),
"virDomainSetMaxMemory": (False, ("memory")),
"virDomainSetMemory": (False, ("memory")),
"virDomainSetMemoryFlags": (False, ("memory")),
"virDomainBlockCommit": (False, ("bandwidth")),
"virDomainBlockJobSetSpeed": (False, ("bandwidth")),
"virDomainBlockPull": (False, ("bandwidth")),
"virDomainBlockRebase": (False, ("bandwidth")),
"virDomainMigrateGetMaxSpeed": (False, ("bandwidth"))
}
def checkLongLegacyFunction(self, name, return_type, signature):
if "long" in return_type and "long long" not in return_type:
......@@ -1883,10 +1884,11 @@ class CParser:
# this dict contains the structs that are allowed to use [unsigned]
# long for legacy reasons. this list is fixed. new structs have to use
# [unsigned] long long
long_legacy_struct_fields = \
{ "_virDomainInfo" : ("maxMem", "memory"),
"_virNodeInfo" : ("memory"),
"_virDomainBlockJobInfo" : ("bandwidth") }
long_legacy_struct_fields = {
"_virDomainInfo": ("maxMem", "memory"),
"_virNodeInfo": ("memory"),
"_virDomainBlockJobInfo": ("bandwidth")
}
def checkLongLegacyStruct(self, name, fields):
for field in fields:
......@@ -2205,7 +2207,7 @@ class docBuilder:
output.write(" </macro>\n")
def serialize_union(self, output, field, desc):
output.write(" <field name='%s' type='union' info='%s'>\n" % (field[1] , desc))
output.write(" <field name='%s' type='union' info='%s'>\n" % (field[1], desc))
output.write(" <union>\n")
for f in field[3]:
desc = f[2]
......@@ -2213,7 +2215,7 @@ class docBuilder:
desc = ''
else:
desc = escape(desc)
output.write(" <field name='%s' type='%s' info='%s'/>\n" % (f[1] , f[0], desc))
output.write(" <field name='%s' type='%s' info='%s'/>\n" % (f[1], f[0], desc))
output.write(" </union>\n")
output.write(" </field>\n")
......@@ -2238,13 +2240,13 @@ class docBuilder:
if field[0] == "union":
self.serialize_union(output, field, desc)
else:
output.write(" <field name='%s' type='%s' info='%s'/>\n" % (field[1] , field[0], desc))
output.write(" <field name='%s' type='%s' info='%s'/>\n" % (field[1], field[0], desc))
except:
self.warning("Failed to serialize struct %s" % (name))
output.write(" </struct>\n")
else:
output.write("/>\n")
else :
else:
output.write(" <typedef name='%s' file='%s' type='%s'" % (
name, self.modulename_file(id.header), id.info))
try:
......@@ -2401,7 +2403,7 @@ class docBuilder:
typ = sorted(funcs.keys())
for type in typ:
if type == '' or type == 'void' or type == "int" or \
type == "char *" or type == "const char *" :
type == "char *" or type == "const char *":
continue
output.write(" <type name='%s'>\n" % (type))
ids = funcs[type]
......@@ -2430,7 +2432,7 @@ class docBuilder:
typ = sorted(funcs.keys())
for type in typ:
if type == '' or type == 'void' or type == "int" or \
type == "char *" or type == "const char *" :
type == "char *" or type == "const char *":
continue
output.write(" <type name='%s'>\n" % (type))
ids = sorted(funcs[type])
......@@ -2589,7 +2591,7 @@ class app:
builddir = os.path.abspath((os.environ["builddir"]))
if srcdir == builddir:
builddir = None
if glob.glob(srcdir + "/../src/libvirt.c") != [] :
if glob.glob(srcdir + "/../src/libvirt.c") != []:
if not quiet:
print("Rebuilding API description for %s" % name)
dirs = [srcdir + "/../src",
......@@ -2599,7 +2601,7 @@ class app:
not os.path.exists(srcdir + "/../include/libvirt/libvirt-common.h")):
dirs.append(builddir + "/../include/libvirt")
builder = docBuilder(name, srcdir, dirs, [])
elif glob.glob("src/libvirt.c") != [] :
elif glob.glob("src/libvirt.c") != []:
if not quiet:
print("Rebuilding API description for %s" % name)
builder = docBuilder(name, srcdir,
......
......@@ -59,21 +59,21 @@ libxml2.registerErrorHandler(callback, None)
# to create them
#
TABLES={
"symbols" : """CREATE TABLE symbols (
"symbols": """CREATE TABLE symbols (
name varchar(255) BINARY NOT NULL,
module varchar(255) BINARY NOT NULL,
type varchar(25) NOT NULL,
descr varchar(255),
UNIQUE KEY name (name),
KEY module (module))""",
"words" : """CREATE TABLE words (
"words": """CREATE TABLE words (
name varchar(50) BINARY NOT NULL,
symbol varchar(255) BINARY NOT NULL,
relevance int,
KEY name (name),
KEY symbol (symbol),
UNIQUE KEY ID (name, symbol))""",
"wordsHTML" : """CREATE TABLE wordsHTML (
"wordsHTML": """CREATE TABLE wordsHTML (
name varchar(50) BINARY NOT NULL,
resource varchar(255) BINARY NOT NULL,
section varchar(255),
......@@ -82,30 +82,30 @@ TABLES={
KEY name (name),
KEY resource (resource),
UNIQUE KEY ref (name, resource))""",
"wordsArchive" : """CREATE TABLE wordsArchive (
"wordsArchive": """CREATE TABLE wordsArchive (
name varchar(50) BINARY NOT NULL,
ID int(11) NOT NULL,
relevance int,
KEY name (name),
UNIQUE KEY ref (name, ID))""",
"pages" : """CREATE TABLE pages (
"pages": """CREATE TABLE pages (
resource varchar(255) BINARY NOT NULL,
title varchar(255) BINARY NOT NULL,
UNIQUE KEY name (resource))""",
"archives" : """CREATE TABLE archives (
"archives": """CREATE TABLE archives (
ID int(11) NOT NULL auto_increment,
resource varchar(255) BINARY NOT NULL,
title varchar(255) BINARY NOT NULL,
UNIQUE KEY id (ID,resource(255)),
INDEX (ID),
INDEX (resource))""",
"Queries" : """CREATE TABLE Queries (
"Queries": """CREATE TABLE Queries (
ID int(11) NOT NULL auto_increment,
Value varchar(50) NOT NULL,
Count int(11) NOT NULL,
UNIQUE KEY id (ID,Value(35)),
INDEX (ID))""",
"AllQueries" : """CREATE TABLE AllQueries (
"AllQueries": """CREATE TABLE AllQueries (
ID int(11) NOT NULL auto_increment,
Value varchar(50) NOT NULL,
Count int(11) NOT NULL,
......@@ -171,7 +171,7 @@ def checkTables(db, verbose = 1):
if verbose:
print "Table %s contains %d records" % (table, row[0])
except:
print "Troubles with table %s : repairing" % (table)
print "Troubles with table %s: repairing" % (table)
ret = c.execute("repair table %s" % table)
print "repairing returned %d" % (ret)
ret = c.execute("SELECT count(*) from %s" % table)
......@@ -1041,7 +1041,7 @@ def analyzeHTMLPages():
doc = libxml2.htmlParseFile(html, None)
try:
res = analyzeHTML(doc, html)
print "Parsed %s : %d paragraphs" % (html, res)
print "Parsed %s: %d paragraphs" % (html, res)
ret = ret + 1
except:
print "could not parse %s" % (html)
......@@ -1230,7 +1230,7 @@ def main():
elif args[i] == '--archive-year':
i = i + 1
year = args[i]
months = ["January" , "February", "March", "April", "May",
months = ["January", "February", "March", "April", "May",
"June", "July", "August", "September", "October",
"November", "December"]
for month in months:
......
......@@ -1342,61 +1342,53 @@ predefined_objects = ["AnyType",
"MethodFault",
"ManagedObjectReference"]
additional_enum_features = { "ManagedEntityStatus" : Enum.FEATURE__ANY_TYPE,
"TaskInfoState" : Enum.FEATURE__ANY_TYPE,
"VirtualMachinePowerState" : Enum.FEATURE__ANY_TYPE }
additional_object_features = { "AutoStartDefaults" : Object.FEATURE__ANY_TYPE,
"AutoStartPowerInfo" : Object.FEATURE__ANY_TYPE,
"DatastoreHostMount" : Object.FEATURE__DEEP_COPY |
Object.FEATURE__LIST |
Object.FEATURE__ANY_TYPE,
"DatastoreInfo" : Object.FEATURE__ANY_TYPE |
Object.FEATURE__DYNAMIC_CAST,
"HostConfigManager" : Object.FEATURE__ANY_TYPE,
"HostCpuIdInfo" : Object.FEATURE__LIST |
Object.FEATURE__ANY_TYPE,
"HostDatastoreBrowserSearchResults" : Object.FEATURE__LIST |
Object.FEATURE__ANY_TYPE,
"HostHostBusAdapter" : Object.FEATURE__LIST |
Object.FEATURE__ANY_TYPE,
"HostInternetScsiHba" : Object.FEATURE__DYNAMIC_CAST |
Object.FEATURE__DEEP_COPY,
"HostInternetScsiTargetTransport" : Object.FEATURE__DYNAMIC_CAST,
"HostScsiDisk" : Object.FEATURE__LIST |
Object.FEATURE__ANY_TYPE |
Object.FEATURE__DYNAMIC_CAST,
"HostScsiTopologyInterface" : Object.FEATURE__LIST |
Object.FEATURE__ANY_TYPE,
"HostScsiTopologyLun" : Object.FEATURE__ANY_TYPE |
Object.FEATURE__LIST |
Object.FEATURE__DEEP_COPY,
"HostScsiTopologyTarget" : Object.FEATURE__ANY_TYPE |
Object.FEATURE__LIST,
"HostPortGroup" : Object.FEATURE__LIST |
Object.FEATURE__ANY_TYPE,
"HostVirtualSwitch" : Object.FEATURE__DEEP_COPY |
Object.FEATURE__LIST |
Object.FEATURE__ANY_TYPE,
"ManagedObjectReference" : Object.FEATURE__ANY_TYPE,
"ObjectContent" : Object.FEATURE__DEEP_COPY,
"PhysicalNic" : Object.FEATURE__DEEP_COPY |
Object.FEATURE__LIST |
Object.FEATURE__ANY_TYPE,
"ResourcePoolResourceUsage" : Object.FEATURE__ANY_TYPE,
"ScsiLun" : Object.FEATURE__LIST |
Object.FEATURE__ANY_TYPE |
Object.FEATURE__DEEP_COPY,
"ScsiLunDurableName" : Object.FEATURE__LIST,
"ServiceContent" : Object.FEATURE__DESERIALIZE,
"SharesInfo" : Object.FEATURE__ANY_TYPE,
"TaskInfo" : Object.FEATURE__LIST |
Object.FEATURE__ANY_TYPE,
"UserSession" : Object.FEATURE__ANY_TYPE,
"VirtualMachineQuestionInfo" : Object.FEATURE__ANY_TYPE,
"VirtualMachineSnapshotTree" : Object.FEATURE__DEEP_COPY |
Object.FEATURE__ANY_TYPE,
"VmEventArgument" : Object.FEATURE__DESERIALIZE }
additional_enum_features = {
"ManagedEntityStatus": Enum.FEATURE__ANY_TYPE,
"TaskInfoState": Enum.FEATURE__ANY_TYPE,
"VirtualMachinePowerState": Enum.FEATURE__ANY_TYPE
}
additional_object_features = {
"AutoStartDefaults": Object.FEATURE__ANY_TYPE,
"AutoStartPowerInfo": Object.FEATURE__ANY_TYPE,
"DatastoreHostMount": (Object.FEATURE__DEEP_COPY | Object.FEATURE__LIST |
Object.FEATURE__ANY_TYPE),
"DatastoreInfo": Object.FEATURE__ANY_TYPE | Object.FEATURE__DYNAMIC_CAST,
"HostConfigManager": Object.FEATURE__ANY_TYPE,
"HostCpuIdInfo": Object.FEATURE__LIST | Object.FEATURE__ANY_TYPE,
"HostDatastoreBrowserSearchResults": (Object.FEATURE__LIST |
Object.FEATURE__ANY_TYPE),
"HostHostBusAdapter": Object.FEATURE__LIST | Object.FEATURE__ANY_TYPE,
"HostInternetScsiHba": (Object.FEATURE__DYNAMIC_CAST |
Object.FEATURE__DEEP_COPY),
"HostInternetScsiTargetTransport": Object.FEATURE__DYNAMIC_CAST,
"HostScsiDisk": (Object.FEATURE__LIST | Object.FEATURE__ANY_TYPE |
Object.FEATURE__DYNAMIC_CAST),
"HostScsiTopologyInterface": (Object.FEATURE__LIST |
Object.FEATURE__ANY_TYPE),
"HostScsiTopologyLun": (Object.FEATURE__ANY_TYPE | Object.FEATURE__LIST |
Object.FEATURE__DEEP_COPY),
"HostScsiTopologyTarget": Object.FEATURE__ANY_TYPE | Object.FEATURE__LIST,
"HostPortGroup": Object.FEATURE__LIST | Object.FEATURE__ANY_TYPE,
"HostVirtualSwitch": (Object.FEATURE__DEEP_COPY | Object.FEATURE__LIST |
Object.FEATURE__ANY_TYPE),
"ManagedObjectReference": Object.FEATURE__ANY_TYPE,
"ObjectContent": Object.FEATURE__DEEP_COPY,
"PhysicalNic": (Object.FEATURE__DEEP_COPY | Object.FEATURE__LIST |
Object.FEATURE__ANY_TYPE),
"ResourcePoolResourceUsage": Object.FEATURE__ANY_TYPE,
"ScsiLun": (Object.FEATURE__LIST | Object.FEATURE__ANY_TYPE |
Object.FEATURE__DEEP_COPY),
"ScsiLunDurableName": Object.FEATURE__LIST,
"ServiceContent": Object.FEATURE__DESERIALIZE,
"SharesInfo": Object.FEATURE__ANY_TYPE,
"TaskInfo": Object.FEATURE__LIST | Object.FEATURE__ANY_TYPE,
"UserSession": Object.FEATURE__ANY_TYPE,
"VirtualMachineQuestionInfo": Object.FEATURE__ANY_TYPE,
"VirtualMachineSnapshotTree": (Object.FEATURE__DEEP_COPY |
Object.FEATURE__ANY_TYPE),
"VmEventArgument": Object.FEATURE__DESERIALIZE
}
removed_object_features = {}
......
......@@ -342,21 +342,23 @@ class WmiClassVersion:
class Property:
typemap = {"boolean" : "BOOL",
"string" : "STR",
"datetime" : "STR",
"int8" : "INT8",
"sint8" : "INT8",
"int16" : "INT16",
"sint16" : "INT16",
"int32" : "INT32",
"sint32" : "INT32",
"int64" : "INT64",
"sint64" : "INT64",
"uint8" : "UINT8",
"uint16" : "UINT16",
"uint32" : "UINT32",
"uint64" : "UINT64"}
typemap = {
"boolean": "BOOL",
"string": "STR",
"datetime": "STR",
"int8": "INT8",
"sint8": "INT8",
"int16": "INT16",
"sint16": "INT16",
"int32": "INT32",
"sint32": "INT32",
"int64": "INT64",
"sint64": "INT64",
"uint8": "UINT8",
"uint16": "UINT16",
"uint32": "UINT32",
"uint64": "UINT64"
}
def __init__(self, type, name, is_array):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册