How to use the flattentool.schema.JsonLoaderLocalRefsDisabled function in flattentool

To help you get started, we’ve selected a few flattentool examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpenDataServices / flatten-tool / flattentool / schema.py View on Github external
def __call__(self, uri, **kwargs):
        if self.is_ref_local(uri):
            raise JsonLoaderLocalRefUsedWhenLocalRefsDisabled(
                "Local Ref Used When Local Refs Disabled: " + uri
            )
        else:
            return super(JsonLoaderLocalRefsDisabled, self).__call__(uri, **kwargs)
github OpenDataServices / flatten-tool / flattentool / schema.py View on Github external
)
        if schema_filename:
            if schema_filename.startswith("http"):
                import requests

                r = requests.get(schema_filename)
                self.root_schema_dict = jsonref.loads(
                    r.text, object_pairs_hook=OrderedDict
                )
            else:
                if disable_local_refs:
                    with codecs.open(schema_filename, encoding="utf-8") as schema_file:
                        self.root_schema_dict = jsonref.load(
                            schema_file,
                            object_pairs_hook=OrderedDict,
                            loader=JsonLoaderLocalRefsDisabled(),
                        )
                else:
                    if sys.version_info[:2] > (3, 0):
                        base_uri = pathlib.Path(
                            os.path.realpath(schema_filename)
                        ).as_uri()
                    else:
                        base_uri = urlparse.urljoin(
                            "file:",
                            urllib.pathname2url(os.path.abspath(schema_filename)),
                        )
                    with codecs.open(schema_filename, encoding="utf-8") as schema_file:
                        self.root_schema_dict = jsonref.load(
                            schema_file,
                            object_pairs_hook=OrderedDict,
                            base_uri=base_uri,