capnpy icon indicating copy to clipboard operation
capnpy copied to clipboard

Allow load_schema() to accept a str

Open kawing-chiu opened this issue 7 years ago • 1 comments

The current API assumes that schema is saved in a file, but in my case the capnp schema is fetched from some db as a str. Maybe an argument can be add to load_schema() to support this usage?

kawing-chiu avatar Nov 22 '17 09:11 kawing-chiu

That sounds like a good idea.

If it is implemented we can remove a lot of boilerplate code in tests e.g.

        schema = """
        @0xbf5147cbbecf40c1;
        struct Point {
            x @0 :Int64;
            y @1 :Int64;
        }
        """
        mypkg = self.tmpdir.join("mypkg").ensure(dir=True)
        myschema = mypkg.join("myschema.capnp")
        myschema.write(schema)

colinfang avatar Nov 22 '17 10:11 colinfang