Ejemplo n.º 1
0
    def get_item_href(self, item: "Item_Type", parent_dir: str) -> str:
        parsed_parent_dir = safe_urlparse(parent_dir)
        join_type = JoinType.from_parsed_uri(parsed_parent_dir)

        item_root = join_path_or_url(join_type, parent_dir,
                                     "{}".format(item.id))

        return join_path_or_url(join_type, item_root,
                                "{}.json".format(item.id))
Ejemplo n.º 2
0
    def get_catalog_href(self, cat: "Catalog_Type", parent_dir: str,
                         is_root: bool) -> str:
        parsed_parent_dir = safe_urlparse(parent_dir)
        join_type = JoinType.from_parsed_uri(parsed_parent_dir)

        if is_root:
            cat_root = parent_dir
        else:
            cat_root = join_path_or_url(join_type, parent_dir,
                                        "{}".format(cat.id))

        return join_path_or_url(join_type, cat_root, cat.DEFAULT_FILE_NAME)
Ejemplo n.º 3
0
    def get_collection_href(self, col: "Collection_Type", parent_dir: str,
                            is_root: bool) -> str:
        parsed_parent_dir = safe_urlparse(parent_dir)
        join_type = JoinType.from_parsed_uri(parsed_parent_dir)

        if is_root:
            col_root = parent_dir
        else:
            col_root = join_path_or_url(join_type, parent_dir,
                                        "{}".format(col.id))

        return join_path_or_url(join_type, col_root, col.DEFAULT_FILE_NAME)
Ejemplo n.º 4
0
    def get_item_href(self, item: "Item_Type", parent_dir: str) -> str:
        parsed_parent_dir = safe_urlparse(parent_dir)
        join_type = JoinType.from_parsed_uri(parsed_parent_dir)

        if self.item_template is None:
            return self.fallback_strategy.get_item_href(item, parent_dir)
        else:
            template_path = self.item_template.substitute(item)
            if not template_path.endswith(".json"):
                template_path = join_path_or_url(join_type, template_path,
                                                 "{}.json".format(item.id))

            return join_path_or_url(join_type, parent_dir, template_path)
Ejemplo n.º 5
0
    def get_collection_href(self, col: "Collection_Type", parent_dir: str,
                            is_root: bool) -> str:
        parsed_parent_dir = safe_urlparse(parent_dir)
        join_type = JoinType.from_parsed_uri(parsed_parent_dir)

        if is_root or self.collection_template is None:
            return self.fallback_strategy.get_collection_href(
                col, parent_dir, is_root)
        else:
            template_path = self.collection_template.substitute(col)
            if not template_path.endswith(".json"):
                template_path = join_path_or_url(join_type, template_path,
                                                 col.DEFAULT_FILE_NAME)

            return join_path_or_url(join_type, parent_dir, template_path)
Ejemplo n.º 6
0
 def fn(item: pystac.Item, parent_dir: str) -> str:
     # Use JoinType.URL since we always use this in cases where we are using
     # URLs
     return join_path_or_url(JoinType.URL, parent_dir,
                             "item/{}.json".format(item.id))
Ejemplo n.º 7
0
 def fn(col: pystac.Collection, parent_dir: str, is_root: bool) -> str:
     # Use JoinType.URL since we always use this in cases where we are using
     # URLs
     return join_path_or_url(JoinType.URL, parent_dir,
                             "col/{}/{}.json".format(is_root, col.id))
Ejemplo n.º 8
0
 def fn(cat: pystac.Catalog, parent_dir: str, is_root: bool) -> str:
     # Use JoinType.URL since we always use this in cases where we are using
     # URLs
     return join_path_or_url(JoinType.URL, parent_dir,
                             "cat/{}/{}.json".format(is_root, cat.id))