Skip to content

Commit aa57019

Browse files
committed
Reformat with black
1 parent 501e98e commit aa57019

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+4607
-3115
lines changed

pystac/__init__.py

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,33 @@
33
"""
44

55
# flake8: noqa
6-
from pystac.errors import (STACError, STACTypeError, RequiredPropertyMissing) # type:ignore
6+
from pystac.errors import (
7+
STACError, # type:ignore
8+
STACTypeError, # type:ignore
9+
RequiredPropertyMissing, # type:ignore
10+
)
711

812
from typing import Any, Dict, Optional
9-
from pystac.version import (__version__, get_stac_version, set_stac_version) # type:ignore
13+
from pystac.version import (
14+
__version__,
15+
get_stac_version, # type:ignore
16+
set_stac_version, # type:ignore
17+
)
1018
from pystac.stac_io import StacIO # type:ignore
11-
from pystac.stac_object import (STACObject, STACObjectType) # type:ignore
19+
from pystac.stac_object import STACObject, STACObjectType # type:ignore
1220
from pystac.media_type import MediaType # type:ignore
13-
from pystac.link import (Link, HIERARCHICAL_LINKS) # type:ignore
14-
from pystac.catalog import (Catalog, CatalogType) # type:ignore
21+
from pystac.link import Link, HIERARCHICAL_LINKS # type:ignore
22+
from pystac.catalog import Catalog, CatalogType # type:ignore
1523
from pystac.collection import (
1624
Collection, # type:ignore
1725
Extent, # type:ignore
1826
SpatialExtent, # type:ignore
1927
TemporalExtent, # type:ignore
2028
Provider, # type:ignore
2129
Summaries, # type:ignore
22-
RangeSummary) # type:ignore
23-
from pystac.item import (Item, Asset, CommonMetadata) # type:ignore
30+
RangeSummary, # type:ignore
31+
)
32+
from pystac.item import Item, Asset, CommonMetadata # type:ignore
2433

2534
import pystac.validation
2635
from pystac.validation import STACValidationError # type:ignore
@@ -40,18 +49,23 @@
4049
import pystac.extensions.version
4150
import pystac.extensions.view
4251

43-
EXTENSION_HOOKS = pystac.extensions.hooks.RegisteredExtensionHooks([
44-
pystac.extensions.datacube.DATACUBE_EXTENSION_HOOKS, pystac.extensions.eo.EO_EXTENSION_HOOKS,
45-
pystac.extensions.file.FILE_EXTENSION_HOOKS,
46-
pystac.extensions.item_assets.ITEM_ASSETS_EXTENSION_HOOKS,
47-
pystac.extensions.label.LABEL_EXTENSION_HOOKS,
48-
pystac.extensions.pointcloud.POINTCLOUD_EXTENSION_HOOKS,
49-
pystac.extensions.projection.PROJECTION_EXTENSION_HOOKS,
50-
pystac.extensions.sar.SAR_EXTENSION_HOOKS, pystac.extensions.sat.SAT_EXTENSION_HOOKS,
51-
pystac.extensions.scientific.SCIENTIFIC_EXTENSION_HOOKS,
52-
pystac.extensions.timestamps.TIMESTAMPS_EXTENSION_HOOKS,
53-
pystac.extensions.version.VERSION_EXTENSION_HOOKS, pystac.extensions.view.VIEW_EXTENSION_HOOKS
54-
])
52+
EXTENSION_HOOKS = pystac.extensions.hooks.RegisteredExtensionHooks(
53+
[
54+
pystac.extensions.datacube.DATACUBE_EXTENSION_HOOKS,
55+
pystac.extensions.eo.EO_EXTENSION_HOOKS,
56+
pystac.extensions.file.FILE_EXTENSION_HOOKS,
57+
pystac.extensions.item_assets.ITEM_ASSETS_EXTENSION_HOOKS,
58+
pystac.extensions.label.LABEL_EXTENSION_HOOKS,
59+
pystac.extensions.pointcloud.POINTCLOUD_EXTENSION_HOOKS,
60+
pystac.extensions.projection.PROJECTION_EXTENSION_HOOKS,
61+
pystac.extensions.sar.SAR_EXTENSION_HOOKS,
62+
pystac.extensions.sat.SAT_EXTENSION_HOOKS,
63+
pystac.extensions.scientific.SCIENTIFIC_EXTENSION_HOOKS,
64+
pystac.extensions.timestamps.TIMESTAMPS_EXTENSION_HOOKS,
65+
pystac.extensions.version.VERSION_EXTENSION_HOOKS,
66+
pystac.extensions.view.VIEW_EXTENSION_HOOKS,
67+
]
68+
)
5569

5670

5771
def read_file(href: str) -> STACObject:
@@ -72,9 +86,9 @@ def read_file(href: str) -> STACObject:
7286
return STACObject.from_file(href)
7387

7488

75-
def write_file(obj: STACObject,
76-
include_self_link: bool = True,
77-
dest_href: Optional[str] = None) -> None:
89+
def write_file(
90+
obj: STACObject, include_self_link: bool = True, dest_href: Optional[str] = None
91+
) -> None:
7892
"""Writes a STACObject to a file.
7993
8094
This will write only the Catalog, Collection or Item ``obj``. It will not attempt
@@ -97,10 +111,12 @@ def write_file(obj: STACObject,
97111
obj.save_object(include_self_link=include_self_link, dest_href=dest_href)
98112

99113

100-
def read_dict(d: Dict[str, Any],
101-
href: Optional[str] = None,
102-
root: Optional[Catalog] = None,
103-
stac_io: Optional[StacIO] = None) -> STACObject:
114+
def read_dict(
115+
d: Dict[str, Any],
116+
href: Optional[str] = None,
117+
root: Optional[Catalog] = None,
118+
stac_io: Optional[StacIO] = None,
119+
) -> STACObject:
104120
"""Reads a STAC object from a dict representing the serialized JSON version of the
105121
STAC object.
106122

pystac/asset.py

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,16 @@ class Asset:
4040
object JSON.
4141
owner: The Item or Collection this asset belongs to, or None if it has no owner.
4242
"""
43-
def __init__(self,
44-
href: str,
45-
title: Optional[str] = None,
46-
description: Optional[str] = None,
47-
media_type: Optional[str] = None,
48-
roles: Optional[List[str]] = None,
49-
properties: Optional[Dict[str, Any]] = None) -> None:
43+
44+
def __init__(
45+
self,
46+
href: str,
47+
title: Optional[str] = None,
48+
description: Optional[str] = None,
49+
media_type: Optional[str] = None,
50+
roles: Optional[List[str]] = None,
51+
properties: Optional[Dict[str, Any]] = None,
52+
) -> None:
5053
self.href = href
5154
self.title = title
5255
self.description = description
@@ -95,23 +98,23 @@ def to_dict(self) -> Dict[str, Any]:
9598
dict: A serialization of the Asset that can be written out as JSON.
9699
"""
97100

98-
d: Dict[str, Any] = {'href': self.href}
101+
d: Dict[str, Any] = {"href": self.href}
99102

100103
if self.media_type is not None:
101-
d['type'] = self.media_type
104+
d["type"] = self.media_type
102105

103106
if self.title is not None:
104-
d['title'] = self.title
107+
d["title"] = self.title
105108

106109
if self.description is not None:
107-
d['description'] = self.description
110+
d["description"] = self.description
108111

109112
if self.properties is not None and len(self.properties) > 0:
110113
for k, v in self.properties.items():
111114
d[k] = v
112115

113116
if self.roles is not None:
114-
d['roles'] = self.roles
117+
d["roles"] = self.roles
115118

116119
return d
117120

@@ -121,15 +124,17 @@ def clone(self) -> "Asset":
121124
Returns:
122125
Asset: The clone of this asset.
123126
"""
124-
return Asset(href=self.href,
125-
title=self.title,
126-
description=self.description,
127-
media_type=self.media_type,
128-
roles=self.roles,
129-
properties=self.properties)
127+
return Asset(
128+
href=self.href,
129+
title=self.title,
130+
description=self.description,
131+
media_type=self.media_type,
132+
roles=self.roles,
133+
properties=self.properties,
134+
)
130135

131136
def __repr__(self) -> str:
132-
return '<Asset href={}>'.format(self.href)
137+
return "<Asset href={}>".format(self.href)
133138

134139
@staticmethod
135140
def from_dict(d: Dict[str, Any]) -> "Asset":
@@ -139,18 +144,20 @@ def from_dict(d: Dict[str, Any]) -> "Asset":
139144
Asset: The Asset deserialized from the JSON dict.
140145
"""
141146
d = copy(d)
142-
href = d.pop('href')
143-
media_type = d.pop('type', None)
144-
title = d.pop('title', None)
145-
description = d.pop('description', None)
146-
roles = d.pop('roles', None)
147+
href = d.pop("href")
148+
media_type = d.pop("type", None)
149+
title = d.pop("title", None)
150+
description = d.pop("description", None)
151+
roles = d.pop("roles", None)
147152
properties = None
148153
if any(d):
149154
properties = d
150155

151-
return Asset(href=href,
152-
media_type=media_type,
153-
title=title,
154-
description=description,
155-
roles=roles,
156-
properties=properties)
156+
return Asset(
157+
href=href,
158+
media_type=media_type,
159+
title=title,
160+
description=description,
161+
roles=roles,
162+
properties=properties,
163+
)

0 commit comments

Comments
 (0)