|
1 | 1 | from copy import deepcopy
|
2 | 2 | from datetime import datetime
|
3 |
| -from enum import Enum |
4 | 3 | from pystac.errors import STACTypeError
|
5 | 4 | from typing import (
|
6 | 5 | Any,
|
|
34 | 33 |
|
35 | 34 | if TYPE_CHECKING:
|
36 | 35 | from pystac.item import Item as Item_Type
|
| 36 | + from pystac.provider import Provider as Provider_Type |
37 | 37 |
|
38 | 38 | T = TypeVar("T")
|
39 | 39 |
|
@@ -409,108 +409,6 @@ def from_items(
|
409 | 409 | return Extent(spatial=spatial, temporal=temporal, extra_fields=extra_fields)
|
410 | 410 |
|
411 | 411 |
|
412 |
| -class ProviderRole(str, Enum): |
413 |
| - """Enumerates the allows values of the Provider "role" field.""" |
414 |
| - |
415 |
| - LICENSOR = "licensor" |
416 |
| - PRODUCER = "producer" |
417 |
| - PROCESSOR = "processor" |
418 |
| - HOST = "host" |
419 |
| - |
420 |
| - |
421 |
| -class Provider: |
422 |
| - """Provides information about a provider of STAC data. A provider is any of the |
423 |
| - organizations that captured or processed the content of the collection and therefore |
424 |
| - influenced the data offered by this collection. May also include information about |
425 |
| - the final storage provider hosting the data. |
426 |
| -
|
427 |
| - Args: |
428 |
| - name : The name of the organization or the individual. |
429 |
| - description : Optional multi-line description to add further provider |
430 |
| - information such as processing details for processors and producers, |
431 |
| - hosting details for hosts or basic contact information. |
432 |
| - roles : Optional roles of the provider. Any of |
433 |
| - licensor, producer, processor or host. |
434 |
| - url : Optional homepage on which the provider describes the dataset |
435 |
| - and publishes contact information. |
436 |
| - extra_fields : Optional dictionary containing additional top-level fields |
437 |
| - defined on the Provider object. |
438 |
| - """ |
439 |
| - |
440 |
| - name: str |
441 |
| - """The name of the organization or the individual.""" |
442 |
| - |
443 |
| - description: Optional[str] |
444 |
| - """Optional multi-line description to add further provider |
445 |
| - information such as processing details for processors and producers, |
446 |
| - hosting details for hosts or basic contact information.""" |
447 |
| - |
448 |
| - roles: Optional[List[ProviderRole]] |
449 |
| - """Optional roles of the provider. Any of |
450 |
| - licensor, producer, processor or host.""" |
451 |
| - |
452 |
| - url: Optional[str] |
453 |
| - """Optional homepage on which the provider describes the dataset |
454 |
| - and publishes contact information.""" |
455 |
| - |
456 |
| - extra_fields: Dict[str, Any] |
457 |
| - """Dictionary containing additional top-level fields defined on the Provider |
458 |
| - object.""" |
459 |
| - |
460 |
| - def __init__( |
461 |
| - self, |
462 |
| - name: str, |
463 |
| - description: Optional[str] = None, |
464 |
| - roles: Optional[List[ProviderRole]] = None, |
465 |
| - url: Optional[str] = None, |
466 |
| - extra_fields: Optional[Dict[str, Any]] = None, |
467 |
| - ): |
468 |
| - self.name = name |
469 |
| - self.description = description |
470 |
| - self.roles = roles |
471 |
| - self.url = url |
472 |
| - self.extra_fields = extra_fields or {} |
473 |
| - |
474 |
| - def to_dict(self) -> Dict[str, Any]: |
475 |
| - """Generate a dictionary representing the JSON of this Provider. |
476 |
| -
|
477 |
| - Returns: |
478 |
| - dict: A serialization of the Provider that can be written out as JSON. |
479 |
| - """ |
480 |
| - d: Dict[str, Any] = {"name": self.name} |
481 |
| - if self.description is not None: |
482 |
| - d["description"] = self.description |
483 |
| - if self.roles is not None: |
484 |
| - d["roles"] = self.roles |
485 |
| - if self.url is not None: |
486 |
| - d["url"] = self.url |
487 |
| - |
488 |
| - d.update(self.extra_fields) |
489 |
| - |
490 |
| - return d |
491 |
| - |
492 |
| - @staticmethod |
493 |
| - def from_dict(d: Dict[str, Any]) -> "Provider": |
494 |
| - """Constructs an Provider from a dict. |
495 |
| -
|
496 |
| - Returns: |
497 |
| - Provider: The Provider deserialized from the JSON dict. |
498 |
| - """ |
499 |
| - return Provider( |
500 |
| - name=d["name"], |
501 |
| - description=d.get("description"), |
502 |
| - roles=d.get( |
503 |
| - "roles", |
504 |
| - ), |
505 |
| - url=d.get("url"), |
506 |
| - extra_fields={ |
507 |
| - k: v |
508 |
| - for k, v in d.items() |
509 |
| - if k not in {"name", "description", "roles", "url"} |
510 |
| - }, |
511 |
| - ) |
512 |
| - |
513 |
| - |
514 | 412 | class Collection(Catalog):
|
515 | 413 | """A Collection extends the Catalog spec with additional metadata that helps
|
516 | 414 | enable discovery.
|
@@ -583,7 +481,7 @@ def __init__(
|
583 | 481 | catalog_type: Optional[CatalogType] = None,
|
584 | 482 | license: str = "proprietary",
|
585 | 483 | keywords: Optional[List[str]] = None,
|
586 |
| - providers: Optional[List[Provider]] = None, |
| 484 | + providers: Optional[List["Provider_Type"]] = None, |
587 | 485 | summaries: Optional[Summaries] = None,
|
588 | 486 | ):
|
589 | 487 | super().__init__(
|
@@ -695,7 +593,7 @@ def from_dict(
|
695 | 593 | keywords = d.get("keywords")
|
696 | 594 | providers = d.get("providers")
|
697 | 595 | if providers is not None:
|
698 |
| - providers = list(map(lambda x: Provider.from_dict(x), providers)) |
| 596 | + providers = list(map(lambda x: pystac.Provider.from_dict(x), providers)) |
699 | 597 | summaries = d.get("summaries")
|
700 | 598 | if summaries is not None:
|
701 | 599 | summaries = Summaries(summaries)
|
|
0 commit comments