How to use the flattentool.schema.TitleLookup 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
else:
                id_fields = parent_id_fields

            for property_name, property_schema_dict in schema_dict[
                "properties"
            ].items():
                if self.exclude_deprecated_fields and property_schema_dict.get(
                    "deprecated"
                ):
                    continue

                property_type_set = get_property_type_set(property_schema_dict)

                title = property_schema_dict.get("title")
                if title:
                    title_lookup[title] = TitleLookup()
                    title_lookup[title].property_name = property_name

                if "object" in property_type_set:
                    self.flattened[parent_path + property_name] = "object"
                    for field, child_title in self.parse_schema_dict(
                        parent_path + property_name,
                        property_schema_dict,
                        parent_id_fields=id_fields,
                        title_lookup=title_lookup.get(title),
                        parent_title=parent_title + title + ":"
                        if parent_title is not None and title
                        else None,
                    ):
                        yield (
                            property_name + "/" + field,
                            # TODO ambiguous use of "title"
github OpenDataServices / flatten-tool / flattentool / schema.py View on Github external
rollup=False,
        root_id=None,
        use_titles=False,
        disable_local_refs=False,
        truncation_length=3,
        exclude_deprecated_fields=False,
    ):
        self.sub_sheets = {}
        self.main_sheet = Sheet()
        self.sub_sheet_mapping = {}
        self.do_rollup = rollup
        self.rollup = set()
        self.root_id = root_id
        self.use_titles = use_titles
        self.truncation_length = truncation_length
        self.title_lookup = TitleLookup()
        self.flattened = {}
        self.exclude_deprecated_fields = exclude_deprecated_fields

        if root_schema_dict is None and schema_filename is None:
            raise ValueError(
                "One of schema_filename or root_schema_dict must be supplied"
            )
        if root_schema_dict is not None and schema_filename is not None:
            raise ValueError(
                "Only one of schema_filename or root_schema_dict should be supplied"
            )
        if schema_filename:
            if schema_filename.startswith("http"):
                import requests

                r = requests.get(schema_filename)