Please add idltest.py to the gitignore.
+def print_python_module(schema_file):
+ schema = ovs.db.schema.DbSchema.from_json(ovs.json.from_file(schema_file))
+ print """\
+# Generated automatically -- do not modify! -*- buffer-read-only: t -*-
+
+import ovs.db.schema
+import ovs.json
+
+__schema_json = \"\"\"
+%s
+\"\"\"
+
+schema = ovs.db.schema.DbSchema.from_json(ovs.json.from_string(__schema_json))
+""" % ovs.json.to_string(schema.to_json(), pretty=True)
+
Offline we discussed that it might be simpler to just read the schema based on
its path according to the dirs module.
@@ -373,6 +397,87 @@ class Datum(object):
else:
return None
+ 'uuid_to_row' must be a function that takes a value and an
+ ovs.db.types.BaseType and translates UUIDs into row objects."""
Is there a reason to pass this function in instead of calling it directly from
idl.py? Will people be wanting to write their own implementations? Does it
make sense to allow a None uuid_to_row which defaults to the idl
implementations? Same question goes for from_python().
+ @staticmethod
+ def from_python(type_, value, row_to_uuid):
This function could use a comment too.
+ The IDL uses and modifies 'schema' directly."""
Can't 'schema' simply be cloned?
+ def destroy(self):
This one could use a comment. In particular, it's not obviously clear to me
why you would call this instead of letting the GC handle it.
+ if self._comments:
+ operations.append({"op": "comment",
+ "comment": "\n".join(self._comments)})
+
+
Redundant newline.
+def update_iface(row):
This definition needs to be deleted.
def keep_table_columns(schema, table_name, column_types):
This function is very similar in ovs-monitor-ipsec and ovs-xapi-sync. I think
something like it should be pulled into the idl as a helper. I expect to be
adding another user fairly shortly as well.
-def monitor_uuid_schema_cb(schema):
+def prune_schema(schema):
string_type = types.Type(types.BaseType(types.StringType))
string_map_type = types.Type(types.BaseType(types.StringType),
types.BaseType(types.StringType),
I wonder if it would make sense to add a helper function to the idl for
generating these things from python. It would take a tuple analogous to the
init function of Type (key, value, n_min, n_max). The key or value could be
standard python types, or another tuple in which case the type would be
recursively generated. Does something like that sound possible/useful?
Ethan
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev