Skip to content

Commit

Permalink
yapf everything for new rule
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenhillier committed Feb 4, 2025
1 parent 68fd43c commit 844e209
Show file tree
Hide file tree
Showing 37 changed files with 628 additions and 1,021 deletions.
15 changes: 3 additions & 12 deletions planet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,7 @@
from .sync import Planet

__all__ = [
'Auth',
'collect',
'DataClient',
'data_filter',
'FeaturesClient',
'OrdersClient',
'order_request',
'Planet',
'reporting',
'Session',
'SubscriptionsClient',
'subscription_request'
'Auth', 'collect', 'DataClient', 'data_filter', 'FeaturesClient',
'OrdersClient', 'order_request', 'Planet', 'reporting', 'Session',
'SubscriptionsClient', 'subscription_request'
]
83 changes: 26 additions & 57 deletions planet/cli/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,13 @@

from planet.reporting import AssetStatusBar
from planet import data_filter, DataClient, exceptions
from planet.clients.data import (SEARCH_SORT,
LIST_SEARCH_TYPE,
LIST_SEARCH_TYPE_DEFAULT,
LIST_SORT_ORDER,
LIST_SORT_DEFAULT,
SEARCH_SORT_DEFAULT,
from planet.clients.data import (SEARCH_SORT, LIST_SEARCH_TYPE,
LIST_SEARCH_TYPE_DEFAULT, LIST_SORT_ORDER,
LIST_SORT_DEFAULT, SEARCH_SORT_DEFAULT,
STATS_INTERVAL)

from planet.specs import (FetchBundlesSpecError,
get_item_types,
SpecificationException,
validate_data_item_type)
from planet.specs import (FetchBundlesSpecError, get_item_types,
SpecificationException, validate_data_item_type)

from . import types
from .cmds import coro, translate_exceptions
Expand Down Expand Up @@ -163,7 +158,9 @@ def _func(obj):
When multiple entries are specified, an implicit 'or' logic is applied.""")
@click.option('--date-range',
type=click.Tuple(
[types.Field(), types.Comparison(), types.DateTime()]),
[types.Field(),
types.Comparison(),
types.DateTime()]),
callback=date_range_to_filter,
multiple=True,
help="""Filter by date range in field.
Expand All @@ -176,7 +173,8 @@ def _func(obj):
help="""Filter to items that overlap a given geometry. Can be a
json string, filename, or '-' for stdin.""")
@click.option('--number-in',
type=click.Tuple([types.Field(), types.CommaSeparatedFloat()]),
type=click.Tuple([types.Field(),
types.CommaSeparatedFloat()]),
multiple=True,
callback=number_in_to_filter,
help="""Filter field by numeric in.
Expand All @@ -190,7 +188,8 @@ def _func(obj):
help='Filter to assets with download permissions.')
@click.option('--range',
'nrange',
type=click.Tuple([types.Field(), types.Comparison(), float]),
type=click.Tuple([types.Field(),
types.Comparison(), float]),
callback=range_to_filter,
multiple=True,
help="""Filter by number range in field.
Expand All @@ -202,7 +201,8 @@ def _func(obj):
show_default=True,
help='Filter to standard quality.')
@click.option('--string-in',
type=click.Tuple([types.Field(), types.CommaSeparatedString()]),
type=click.Tuple([types.Field(),
types.CommaSeparatedString()]),
multiple=True,
callback=string_in_to_filter,
help="""Filter field by numeric in.
Expand All @@ -211,7 +211,9 @@ def _func(obj):
When multiple entries are specified, an implicit 'or' logic is applied.""")
@click.option(
'--update',
type=click.Tuple([types.Field(), types.GTComparison(), types.DateTime()]),
type=click.Tuple([types.Field(),
types.GTComparison(),
types.DateTime()]),
callback=update_to_filter,
multiple=True,
help="""Filter to items with changes to a specified field value made after
Expand All @@ -220,17 +222,8 @@ def _func(obj):
COMP can be gt or gte.
DATETIME can be an RFC3339 or ISO 8601 string.""")
@pretty
def filter(ctx,
asset,
date_range,
geom,
number_in,
nrange,
string_in,
update,
permission,
pretty,
std_quality):
def filter(ctx, asset, date_range, geom, number_in, nrange, string_in, update,
permission, pretty, std_quality):
"""Create a structured item search filter.
This command provides basic functionality for specifying a filter by
Expand All @@ -245,15 +238,8 @@ def filter(ctx,
permission = data_filter.permission_filter() if permission else None
std_quality = data_filter.std_quality_filter() if std_quality else None

filter_options = (asset,
date_range,
geom,
number_in,
nrange,
string_in,
update,
permission,
std_quality)
filter_options = (asset, date_range, geom, number_in, nrange, string_in,
update, permission, std_quality)

# options allowing multiples are broken up so one filter is created for
# each time the option is specified
Expand Down Expand Up @@ -344,12 +330,7 @@ async def search(ctx, item_types, geom, filter, limit, name, sort, pretty):
is_flag=True,
help='Send a daily email when new results are added.')
@pretty
async def search_create(ctx,
item_types,
geom,
filter,
name,
daily_email,
async def search_create(ctx, item_types, geom, filter, name, daily_email,
pretty):
"""Create a new saved structured item search.
Expand Down Expand Up @@ -505,14 +486,8 @@ async def search_delete(ctx, search_id):
is_flag=True,
help='Send a daily email when new results are added.')
@pretty
async def search_update(ctx,
search_id,
item_types,
filter,
geom,
name,
daily_email,
pretty):
async def search_update(ctx, search_id, item_types, filter, geom, name,
daily_email, pretty):
"""Update a saved search with the given search request.
This function outputs a full JSON description of the updated search,
Expand Down Expand Up @@ -554,14 +529,8 @@ async def search_update(ctx,
is_flag=True,
default=None,
help=('Verify that checksums match.'))
async def asset_download(ctx,
item_type,
item_id,
asset_type,
directory,
filename,
overwrite,
checksum):
async def asset_download(ctx, item_type, item_id, asset_type, directory,
filename, overwrite, checksum):
"""Download an activated asset.
This function will fail if the asset state is not activated. Consider
Expand Down
40 changes: 7 additions & 33 deletions planet/cli/orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@
from .io import echo_json
from .options import limit, pretty
from .session import CliSession
from ..specs import (FetchBundlesSpecError,
get_bundle_names,
get_item_types,
SpecificationException,
validate_bundle,
from ..specs import (FetchBundlesSpecError, get_bundle_names, get_item_types,
SpecificationException, validate_bundle,
validate_data_item_type)

LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -129,17 +126,8 @@ def orders(ctx, base_url):
Example: 'name ASC,created_on DESC'""")
@limit
@pretty
async def list(ctx,
state,
source_type,
name,
name_contains,
created_on,
last_modified,
hosting,
sort_by,
limit,
pretty):
async def list(ctx, state, source_type, name, name_contains, created_on,
last_modified, hosting, sort_by, limit, pretty):
"""List orders
This command prints a sequence of the returned order descriptions,
Expand Down Expand Up @@ -417,23 +405,9 @@ async def create(ctx, request, pretty, **kwargs):
help='Automatically create a layer configuration for your collection. '
'If omitted, no configuration will be created.')
@pretty
async def request(ctx,
item_type,
bundle,
name,
ids,
clip,
tools,
email,
archive_type,
archive_filename,
single_archive,
delivery,
stac,
hosting,
collection_id,
create_configuration,
pretty):
async def request(ctx, item_type, bundle, name, ids, clip, tools, email,
archive_type, archive_filename, single_archive, delivery,
stac, hosting, collection_id, create_configuration, pretty):
"""Generate an order request.
This command provides support for building an order description used
Expand Down
57 changes: 11 additions & 46 deletions planet/cli/subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,8 @@ def subscriptions(ctx, base_url):
@click.option(
'--status',
type=click.Choice([
"running",
"cancelled",
"preparing",
"pending",
"completed",
"suspended",
"failed"
"running", "cancelled", "preparing", "pending", "completed",
"suspended", "failed"
]),
multiple=True,
help="Select subscriptions in one or more states. Default is all.")
Expand All @@ -112,19 +107,9 @@ def subscriptions(ctx, base_url):
@click.pass_context
@translate_exceptions
@coro
async def list_subscriptions_cmd(ctx,
created,
end_time,
hosting,
name_contains,
name,
source_type,
start_time,
status,
sort_by,
updated,
limit,
page_size,
async def list_subscriptions_cmd(ctx, created, end_time, hosting,
name_contains, name, source_type, start_time,
status, sort_by, updated, limit, page_size,
pretty):
"""Prints a sequence of JSON-encoded Subscription descriptions."""
async with subscriptions_client(ctx) as client:
Expand Down Expand Up @@ -290,12 +275,8 @@ async def get_subscription_cmd(ctx, subscription_id, pretty):
@click.pass_context
@translate_exceptions
@coro
async def list_subscription_results_cmd(ctx,
subscription_id,
pretty,
status,
csv_flag,
limit):
async def list_subscription_results_cmd(ctx, subscription_id, pretty, status,
csv_flag, limit):
"""Print the results of a subscription to stdout.
The output of this command is a sequence of JSON objects (the
Expand Down Expand Up @@ -375,16 +356,8 @@ async def list_subscription_results_cmd(ctx,
help='Automatically create a layer configuration for your collection. '
'If omitted, no configuration will be created.')
@pretty
def request(name,
source,
delivery,
notifications,
tools,
hosting,
collection_id,
create_configuration,
clip_to_source,
pretty):
def request(name, source, delivery, notifications, tools, hosting,
collection_id, create_configuration, clip_to_source, pretty):
"""Generate a subscriptions request.
Note: the next version of the Subscription API will remove the clip
Expand Down Expand Up @@ -449,16 +422,8 @@ def request(name,
type=click.Choice(["acquired", "published"]),
help="Subscribe by acquisition time or time of publication.")
@pretty
def request_catalog(item_types,
asset_types,
geometry,
start_time,
end_time,
rrule,
filter,
publishing_stages,
time_range_type,
pretty):
def request_catalog(item_types, asset_types, geometry, start_time, end_time,
rrule, filter, publishing_stages, time_range_type, pretty):
"""Generate a subscriptions request catalog source description."""

res = subscription_request.catalog_source(
Expand Down
3 changes: 1 addition & 2 deletions planet/cli/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ class Comparison(click.ParamType):
def convert(self, value, param, ctx) -> str:
if value not in self.valid:
self.fail(f'COMP ({value}) must be one of {",".join(self.valid)}',
param,
ctx)
param, ctx)
return value


Expand Down
12 changes: 3 additions & 9 deletions planet/clients/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
LIST_SORT_DEFAULT = 'created desc'
LIST_SEARCH_TYPE_DEFAULT = 'any'

SEARCH_SORT = ('published desc',
'published asc',
'acquired desc',
SEARCH_SORT = ('published desc', 'published asc', 'acquired desc',
'acquired asc')
SEARCH_SORT_DEFAULT = 'published desc'
STATS_INTERVAL = ('hour', 'day', 'week', 'month', 'year')
Expand Down Expand Up @@ -396,9 +394,7 @@ async def run_search(self,
async for i in Items(response, self._session.request, limit=limit):
yield i

async def get_stats(self,
item_types: List[str],
search_filter: dict,
async def get_stats(self, item_types: List[str], search_filter: dict,
interval: str) -> dict:
"""Get item search statistics.
Expand Down Expand Up @@ -457,9 +453,7 @@ async def list_item_assets(self, item_type_id: str, item_id: str) -> dict:
response = await self._session.request(method='GET', url=url)
return response.json()

async def get_asset(self,
item_type_id: str,
item_id: str,
async def get_asset(self, item_type_id: str, item_id: str,
asset_type_id: str) -> dict:
"""Get an item asset description.
Expand Down
6 changes: 1 addition & 5 deletions planet/clients/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,7 @@ async def add_items(self,

# convert a geojson geometry into geojson feature
if feature.get("type", "").lower() in [
"point",
"multipoint",
"polygon",
"multipolygon",
"linestring",
"point", "multipoint", "polygon", "multipolygon", "linestring",
"multilinestring"
]:
feature = {"type": "Feature", "geometry": feature}
Expand Down
Loading

0 comments on commit 844e209

Please sign in to comment.