summaryrefslogtreecommitdiff
path: root/python/ovs/db/schema.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/ovs/db/schema.py')
-rw-r--r--python/ovs/db/schema.py34
1 files changed, 16 insertions, 18 deletions
diff --git a/python/ovs/db/schema.py b/python/ovs/db/schema.py
index 44b030757..3ba844ae5 100644
--- a/python/ovs/db/schema.py
+++ b/python/ovs/db/schema.py
@@ -19,8 +19,6 @@ import ovs.db.parser
import ovs.db.types
from ovs.db import error
-import six
-
def _check_id(name, json):
if name.startswith('_'):
@@ -42,7 +40,7 @@ class DbSchema(object):
# backward compatibility, if the root set is empty then assume that
# every table is in the root set.
if self.__root_set_size() == 0:
- for table in six.itervalues(self.tables):
+ for table in self.tables.values():
table.is_root = True
# Find the "ref_table"s referenced by "ref_table_name"s.
@@ -50,15 +48,15 @@ class DbSchema(object):
# Also force certain columns to be persistent, as explained in
# __check_ref_table(). This requires 'is_root' to be known, so this
# must follow the loop updating 'is_root' above.
- for table in six.itervalues(self.tables):
- for column in six.itervalues(table.columns):
+ for table in self.tables.values():
+ for column in table.columns.values():
self.__follow_ref_table(column, column.type.key, "key")
self.__follow_ref_table(column, column.type.value, "value")
def __root_set_size(self):
"""Returns the number of tables in the schema's root set."""
n_root = 0
- for table in six.itervalues(self.tables):
+ for table in self.tables.values():
if table.is_root:
n_root += 1
return n_root
@@ -67,8 +65,8 @@ class DbSchema(object):
def from_json(json, allow_extensions=False):
parser = ovs.db.parser.Parser(json, "database schema")
name = parser.get("name", ['id'])
- version = parser.get_optional("version", six.string_types)
- parser.get_optional("cksum", six.string_types)
+ version = parser.get_optional("version", (str,))
+ parser.get_optional("cksum", (str,))
tablesJson = parser.get("tables", [dict])
parser.finish()
@@ -78,7 +76,7 @@ class DbSchema(object):
% version)
tables = {}
- for tableName, tableJson in six.iteritems(tablesJson):
+ for tableName, tableJson in tablesJson.items():
_check_id(tableName, json)
tables[tableName] = TableSchema.from_json(tableJson, tableName,
allow_extensions)
@@ -93,7 +91,7 @@ class DbSchema(object):
default_is_root = self.__root_set_size() == len(self.tables)
tables = {}
- for table in six.itervalues(self.tables):
+ for table in self.tables.values():
tables[table.name] = table.to_json(default_is_root)
json = {"name": self.name, "tables": tables}
if self.version:
@@ -137,10 +135,10 @@ class IdlSchema(DbSchema):
@staticmethod
def from_json(json):
parser = ovs.db.parser.Parser(json, "IDL schema")
- idlPrefix = parser.get("idlPrefix", six.string_types)
- idlHeader = parser.get("idlHeader", six.string_types)
- cDecls = parser.get_optional("cDecls", six.string_types, "")
- hDecls = parser.get_optional("hDecls", six.string_types, "")
+ idlPrefix = parser.get("idlPrefix", (str,))
+ idlHeader = parser.get("idlHeader", (str,))
+ cDecls = parser.get_optional("cDecls", (str,), "")
+ hDecls = parser.get_optional("hDecls", (str,), "")
subjson = dict(json)
del subjson["idlPrefix"]
@@ -160,7 +158,7 @@ def column_set_from_json(json, columns):
raise error.Error("array of distinct column names expected", json)
else:
for column_name in json:
- if not isinstance(column_name, six.string_types):
+ if not isinstance(column_name, str):
raise error.Error("array of distinct column names expected",
json)
elif column_name not in columns:
@@ -206,7 +204,7 @@ class TableSchema(object):
raise error.Error("table must have at least one column", json)
columns = {}
- for column_name, column_json in six.iteritems(columns_json):
+ for column_name, column_json in columns_json.items():
_check_id(column_name, json)
columns[column_name] = ColumnSchema.from_json(column_json,
column_name,
@@ -247,7 +245,7 @@ class TableSchema(object):
json["isRoot"] = self.is_root
json["columns"] = columns = {}
- for column in six.itervalues(self.columns):
+ for column in self.columns.values():
if not column.name.startswith("_"):
columns[column.name] = column.to_json()
@@ -276,7 +274,7 @@ class ColumnSchema(object):
parser = ovs.db.parser.Parser(json, "schema for column %s" % name)
mutable = parser.get_optional("mutable", [bool], True)
ephemeral = parser.get_optional("ephemeral", [bool], False)
- _types = list(six.string_types)
+ _types = [str]
_types.extend([dict])
type_ = ovs.db.types.Type.from_json(parser.get("type", _types))
if allow_extensions: