@@ -107,18 +107,19 @@ class Catalog(STACObject):
107
107
representation.
108
108
title (str or None): Optional short descriptive one-line title for the catalog.
109
109
stac_extensions (List[str]): Optional list of extensions the Catalog implements.
110
- href (str or None): Optional HREF for this catalog, which be set as the catalog's
111
- self link's HREF.
110
+ href (str or None): Optional HREF for this catalog, which be set as the
111
+ catalog's self link's HREF.
112
112
catalog_type (str or None): Optional catalog type for this catalog. Must
113
113
be one of the values in :class`~pystac.CatalogType`.
114
114
115
115
Attributes:
116
116
id (str): Identifier for the catalog.
117
117
description (str): Detailed multi-line description to fully explain the catalog.
118
118
title (str or None): Optional short descriptive one-line title for the catalog.
119
- stac_extensions (List[str] or None): Optional list of extensions the Catalog implements.
120
- extra_fields (dict or None): Extra fields that are part of the top-level JSON properties
121
- of the Catalog.
119
+ stac_extensions (List[str] or None): Optional list of extensions the Catalog
120
+ implements.
121
+ extra_fields (dict or None): Extra fields that are part of the top-level JSON
122
+ properties of the Catalog.
122
123
links (List[Link]): A list of :class:`~pystac.Link` objects representing
123
124
all links associated with this Catalog.
124
125
catalog_type (str): The catalog type. Defaults to ABSOLUTE_PUBLISHED
@@ -133,7 +134,9 @@ class Catalog(STACObject):
133
134
is read by a StacIO instance."""
134
135
135
136
DEFAULT_FILE_NAME = "catalog.json"
136
- """Default file name that will be given to this STAC object in a canonical format."""
137
+ """Default file name that will be given to this STAC object in
138
+ a canonical format.
139
+ """
137
140
138
141
def __init__ (
139
142
self ,
@@ -195,8 +198,8 @@ def add_child(
195
198
Args:
196
199
child (Catalog or Collection): The child to add.
197
200
title (str): Optional title to give to the :class:`~pystac.Link`
198
- strategy (HrefLayoutStrategy): The layout strategy to use for setting the self
199
- href of the child.
201
+ strategy (HrefLayoutStrategy): The layout strategy to use for setting the
202
+ self href of the child.
200
203
"""
201
204
202
205
# Prevent typo confusion
@@ -277,8 +280,9 @@ def get_child(self, id: str, recursive: bool = False) -> Optional["Catalog"]:
277
280
278
281
Args:
279
282
id (str): The ID of the child to find.
280
- recursive (bool): If True, search this catalog and all children for the item;
281
- otherwise, only search the children of this catalog. Defaults to False.
283
+ recursive (bool): If True, search this catalog and all children for the
284
+ item; otherwise, only search the children of this catalog. Defaults
285
+ to False.
282
286
283
287
Return:
284
288
Item or None: The item with the given ID, or None if not found.
@@ -345,8 +349,9 @@ def get_item(self, id: str, recursive: bool = False) -> Optional["Item_Type"]:
345
349
346
350
Args:
347
351
id (str): The ID of the item to find.
348
- recursive (bool): If True, search this catalog and all children for the item;
349
- otherwise, only search the items of this catalog. Defaults to False.
352
+ recursive (bool): If True, search this catalog and all children for the
353
+ item; otherwise, only search the items of this catalog. Defaults
354
+ to False.
350
355
351
356
Return:
352
357
Item or None: The item with the given ID, or None if not found.
@@ -501,13 +506,15 @@ def normalize_and_save(
501
506
in sequence.
502
507
503
508
Args:
504
- root_href (str): The absolute HREF that all links will be normalized against.
509
+ root_href (str): The absolute HREF that all links will be normalized
510
+ against.
505
511
catalog_type (str): The catalog type that dictates the structure of
506
512
the catalog to save. Use a member of :class:`~pystac.CatalogType`.
507
- Defaults to the root catalog.catalog_type or the current catalog catalog_type
508
- if there is no root catalog.
509
- strategy (HrefLayoutStrategy): The layout strategy to use in setting the HREFS
510
- for this catalog. Defaults to :class:`~pystac.layout.BestPracticesLayoutStrategy`
513
+ Defaults to the root catalog.catalog_type or the current catalog
514
+ catalog_type if there is no root catalog.
515
+ strategy (HrefLayoutStrategy): The layout strategy to use in setting the
516
+ HREFS for this catalog. Defaults to
517
+ :class:`~pystac.layout.BestPracticesLayoutStrategy`
511
518
"""
512
519
self .normalize_hrefs (root_href , strategy = strategy )
513
520
self .save (catalog_type )
@@ -587,7 +594,9 @@ def generate_subcatalogs(
587
594
** kwargs : Any ,
588
595
) -> List ["Catalog" ]:
589
596
"""Walks through the catalog and generates subcatalogs
590
- for items based on the template string. See :class:`~pystac.layout.LayoutTemplate`
597
+ for items based on the template string.
598
+
599
+ See :class:`~pystac.layout.LayoutTemplate`
591
600
for details on the construction of template strings. This template string
592
601
will be applied to the items, and subcatalogs will be created that separate
593
602
and organize the items based on template values.
@@ -673,11 +682,11 @@ def save(self, catalog_type: Optional[CatalogType] = None) -> None:
673
682
Note:
674
683
If the catalog type is ``CatalogType.ABSOLUTE_PUBLISHED``,
675
684
all self links will be included, and hierarchical links be absolute URLs.
676
- If the catalog type is ``CatalogType.RELATIVE_PUBLISHED``, this catalog's self
677
- link will be included, but no child catalog will have self links, and
685
+ If the catalog type is ``CatalogType.RELATIVE_PUBLISHED``, this catalog's
686
+ self link will be included, but no child catalog will have self links, and
678
687
hierarchical links will be relative URLs
679
- If the catalog type is ``CatalogType.SELF_CONTAINED``, no self links will be
680
- included and hierarchical links will be relative URLs.
688
+ If the catalog type is ``CatalogType.SELF_CONTAINED``, no self links will
689
+ be included and hierarchical links will be relative URLs.
681
690
"""
682
691
root = self .get_root ()
683
692
if root is None :
@@ -699,7 +708,8 @@ def save(self, catalog_type: Optional[CatalogType] = None) -> None:
699
708
)
700
709
701
710
include_self_link = False
702
- # include a self link if this is the root catalog or if ABSOLUTE_PUBLISHED catalog
711
+ # include a self link if this is the root catalog
712
+ # or if ABSOLUTE_PUBLISHED catalog
703
713
if root .catalog_type == CatalogType .ABSOLUTE_PUBLISHED :
704
714
include_self_link = True
705
715
elif root .catalog_type != CatalogType .SELF_CONTAINED :
@@ -716,9 +726,9 @@ def walk(
716
726
) -> Iterable [Tuple ["Catalog" , Iterable ["Catalog" ], Iterable ["Item_Type" ]]]:
717
727
"""Walks through children and items of catalogs.
718
728
719
- For each catalog in the STAC's tree rooted at this catalog (including this catalog
720
- itself), it yields a 3-tuple (root, subcatalogs, items). The root in that
721
- 3-tuple refers to the current catalog being walked, the subcatalogs are any
729
+ For each catalog in the STAC's tree rooted at this catalog (including this
730
+ catalog itself), it yields a 3-tuple (root, subcatalogs, items). The root in
731
+ that 3-tuple refers to the current catalog being walked, the subcatalogs are any
722
732
catalogs or collections for which the root is a parent, and items represents
723
733
any items that have the root as a parent.
724
734
@@ -764,9 +774,9 @@ def map_items(
764
774
item_mapper function.
765
775
766
776
Args:
767
- item_mapper (Callable): A function that takes in an item, and returns either
768
- an item or list of items. The item that is passed into the item_mapper
769
- is a copy, so the method can mutate it safely.
777
+ item_mapper (Callable): A function that takes in an item, and returns
778
+ either an item or list of items. The item that is passed into the
779
+ item_mapper is a copy, so the method can mutate it safely.
770
780
771
781
Returns:
772
782
Catalog: A full copy of this catalog, with items manipulated according
@@ -810,10 +820,10 @@ def map_assets(
810
820
through the asset_mapper function.
811
821
812
822
Args:
813
- asset_mapper (Callable): A function that takes in an key and an Asset, and returns
814
- either an Asset, a (key, Asset), or a dictionary of Assets with unique keys.
815
- The Asset that is passed into the item_mapper is a copy, so the method can
816
- mutate it safely.
823
+ asset_mapper (Callable): A function that takes in an key and an Asset, and
824
+ returns either an Asset, a (key, Asset), or a dictionary of Assets with
825
+ unique keys. The Asset that is passed into the item_mapper is a copy,
826
+ so the method can mutate it safely.
817
827
818
828
Returns:
819
829
Catalog: A full copy of this catalog, with assets manipulated according
0 commit comments