X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=python%2Fovs%2Fdb%2Fschema.py;h=29fe986a254c56a0f47aa9057914f21d21903d8b;hb=63b1a5213331cd962be05df57f1375db902216c5;hp=1a12393b69292f05947b6c7cddd564ead69b0115;hpb=d26c5b7422b779c170f360aaae194e5910ef7e16;p=openvswitch diff --git a/python/ovs/db/schema.py b/python/ovs/db/schema.py index 1a12393b..29fe986a 100644 --- a/python/ovs/db/schema.py +++ b/python/ovs/db/schema.py @@ -19,6 +19,12 @@ from ovs.db import error import ovs.db.parser from ovs.db import types +def _check_id(name, json): + if name.startswith('_'): + raise error.Error('names beginning with "_" are reserved', json) + elif not ovs.db.parser.is_identifier(name): + raise error.Error("name must be a valid id", json) + class DbSchema(object): """Schema for an OVSDB database.""" @@ -65,16 +71,12 @@ class DbSchema(object): if (version is not None and not re.match('[0-9]+\.[0-9]+\.[0-9]+$', version)): - raise error.Error("schema version \"%s\" not in format x.y.z" + raise error.Error('schema version "%s" not in format x.y.z' % version) tables = {} for tableName, tableJson in tablesJson.iteritems(): - if tableName.startswith('_'): - raise error.Error("names beginning with \"_\" are reserved", - json) - elif not ovs.db.parser.is_identifier(tableName): - raise error.Error("name must be a valid id", json) + _check_id(tableName, json) tables[tableName] = TableSchema.from_json(tableJson, tableName) return DbSchema(name, version, tables) @@ -182,11 +184,7 @@ class TableSchema(object): columns = {} for column_name, column_json in columns_json.iteritems(): - if column_name.startswith('_'): - raise error.Error("names beginning with \"_\" are reserved", - json) - elif not ovs.db.parser.is_identifier(column_name): - raise error.Error("name must be a valid id", json) + _check_id(column_name, json) columns[column_name] = ColumnSchema.from_json(column_json, column_name) @@ -239,11 +237,11 @@ class TableSchema(object): return json class ColumnSchema(object): - def __init__(self, name, mutable, persistent, type): + def __init__(self, name, mutable, persistent, type_): self.name = name self.mutable = mutable self.persistent = persistent - self.type = type + self.type = type_ self.unique = False @staticmethod