Skip to content

Commit

Permalink
fix: apply pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
gadomski committed Apr 6, 2022
1 parent 43b51c7 commit e3b41f8
Show file tree
Hide file tree
Showing 45 changed files with 137 additions and 118 deletions.
1 change: 1 addition & 0 deletions .codespellignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
alos
ned
3 changes: 2 additions & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Core

The ``stactools.core`` package contains utility methods for dealing with STACs.

Functions are organized into subpackages but can be imported directly from ``stactools.core``, e.g.:
Functions are organized into subpackages but can be imported directly from
``stactools.core``, e.g.:

.. code-block:: python
Expand Down
57 changes: 32 additions & 25 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
import os
import sys

sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath('..'))
from stactools.core import __version__ # noqa
sys.path.insert(0, os.path.abspath("."))
sys.path.insert(0, os.path.abspath(".."))
from stactools.core import __version__ # noqa

# -- Project information -----------------------------------------------------

project = 'stactools'
copyright = '2020, stac-utils'
author = 'stac-utils'
project = "stactools"
copyright = "2020, stac-utils"
author = "stac-utils"

# The short X.Y version
version = __version__
Expand All @@ -40,22 +40,27 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'sphinx.ext.napoleon',
'sphinx.ext.githubpages', 'sphinx.ext.extlinks', 'sphinxcontrib.fulltoc',
'sphinx_click', 'nbsphinx'
"sphinx.ext.autodoc",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
"sphinx.ext.githubpages",
"sphinx.ext.extlinks",
"sphinxcontrib.fulltoc",
"sphinx_click",
"nbsphinx",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -67,7 +72,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '**.ipynb_checkpoints']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "**.ipynb_checkpoints"]

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = None
Expand All @@ -77,7 +82,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
html_theme = "alabaster"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down Expand Up @@ -110,23 +115,20 @@
# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'stactoolsdoc'
htmlhelp_basename = "stactoolsdoc"

# -- Options for LaTeX output ------------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -136,25 +138,30 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'stactools.tex', 'stactools Documentation', 'stac-utils',
'manual'),
(master_doc, "stactools.tex", "stactools Documentation", "stac-utils", "manual"),
]

# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, 'stactools', 'stactools Documentation', [author], 1)]
man_pages = [(master_doc, "stactools", "stactools Documentation", [author], 1)]

# -- Options for Texinfo output ----------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'stactools', 'stactools Documentation', author, 'stactools',
'Command line utility and library for SpatioTemporal Asset Catalogs (STAC).',
'Miscellaneous'),
(
master_doc,
"stactools",
"stactools Documentation",
author,
"stactools",
"Command line utility and library for SpatioTemporal Asset Catalogs (STAC).",
"Miscellaneous",
),
]

# -- Options for Epub output -------------------------------------------------
Expand All @@ -172,6 +179,6 @@
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
epub_exclude_files = ["search.html"]

# -- Extension configuration -------------------------------------------------
5 changes: 3 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ Use ``stac --help`` to navigate the varios commands.
* ``stac info`` and ``stac describe`` display information about STACs
* ``stac layout`` will modify the layout of a STAC based on item properties

One of the focuses of ``stactools`` is to provide an easy way to plug in functionality for different data sources. For example:
One of the focuses of ``stactools`` is to provide an easy way to plug in
functionality for different data sources. For example:

* ``stac planet convert-order`` will convert a Planet order into a STAC.

Expand All @@ -53,4 +54,4 @@ Table of Contents
:maxdepth: 2

api
cli
cli
23 changes: 14 additions & 9 deletions scripts/check_minimum_requirements
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,35 @@

import os.path
import sys

from importlib_metadata import requires
from packaging.requirements import Requirement

package_requirements = [
Requirement(requirement) for requirement in requires("stactools")
]
requirements_min = os.path.join(os.path.dirname(os.path.dirname(__file__)),
"requirements-min.txt")
requirements_min = os.path.join(
os.path.dirname(os.path.dirname(__file__)), "requirements-min.txt"
)
with open(requirements_min) as file:
min_requirements = [Requirement(line) for line in file]
min_requirements = dict(
(requirement.name, requirement) for requirement in min_requirements)
(requirement.name, requirement) for requirement in min_requirements
)

incorrect_requirements = list()
for package_requirement in package_requirements:
if package_requirement.marker is not None:
continue
min_requirement = min_requirements[package_requirement.name]
for (package_specifier,
min_specifier) in zip(package_requirement.specifier,
min_requirement.specifier):
if package_specifier.operator == ">=" and package_specifier.version != min_specifier.version:
incorrect_requirements.append(
(package_requirement, min_requirement))
for (package_specifier, min_specifier) in zip(
package_requirement.specifier, min_requirement.specifier
):
if (
package_specifier.operator == ">="
and package_specifier.version != min_specifier.version
):
incorrect_requirements.append((package_requirement, min_requirement))

if incorrect_requirements:
print("ERROR: Incorrect min-requirements.txt!")
Expand Down
13 changes: 6 additions & 7 deletions scripts/rewrite_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def remap_property(item: Item, before: str, after: str) -> None:
for j, datetime in enumerate(interval):
if datetime:
collection.extent.temporal.intervals[i][
j] = datetime.astimezone(UTC)
j
] = datetime.astimezone(UTC)

if object.STAC_OBJECT_TYPE == "Feature":
item = cast(Item, object)
Expand All @@ -51,17 +52,15 @@ def remap_property(item: Item, before: str, after: str) -> None:
remap_property(item, "eo:sun_azimuth", "view:sun_azimuth")
remap_property(item, "eo:sun_elevation", "view:sun_elevation")

if item.collection_id is None and item.get_single_link(
"collection"):
if item.collection_id is None and item.get_single_link("collection"):
item.collection_id = collection_id

for key, asset in item.assets.items():
bands = asset.extra_fields.pop("eo:bands", None)
if bands:
item.assets[key].extra_fields["eo:bands"] = [{
"name":
str(band)
} for band in bands]
item.assets[key].extra_fields["eo:bands"] = [
{"name": str(band)} for band in bands
]

if file_name not in invalid_file_names:
try:
Expand Down
2 changes: 1 addition & 1 deletion src/stactools/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def register_plugin(registry: "Registry") -> None:
lint,
merge,
migrate,
version,
validate,
version,
)

registry.register_subcommand(add.create_add_command)
Expand Down
3 changes: 2 additions & 1 deletion src/stactools/cli/cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import logging
from typing import Union

import click

from typing import Union
from stactools.cli import registry


Expand Down
3 changes: 1 addition & 2 deletions src/stactools/cli/commands/add.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import click

from typing import Optional

import click
from pystac import Catalog, Item, read_file

from stactools.core import add_item
Expand Down
1 change: 1 addition & 0 deletions src/stactools/cli/commands/addraster.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import click
import pystac

from stactools.core import add_raster_to_item


Expand Down
5 changes: 3 additions & 2 deletions src/stactools/cli/commands/copy.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from typing import Optional

import click
import pystac

from typing import Optional
from pystac.utils import make_absolute_href

from stactools.core.copy import copy_catalog, move_all_assets


Expand Down
3 changes: 2 additions & 1 deletion src/stactools/cli/commands/lint.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import click
import sys

import click
from stac_check.lint import Linter # type: ignore


Expand Down
3 changes: 2 additions & 1 deletion src/stactools/cli/commands/merge.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from typing import Optional

import click
import pystac

from typing import Optional
from stactools.core import merge_all_items


Expand Down
4 changes: 2 additions & 2 deletions src/stactools/cli/commands/validate.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import sys
from typing import Optional, List
from typing import List, Optional

import click
import pystac

from pystac import Catalog, Collection, Item, STACObject, STACValidationError

from stactools.core.utils import href_exists


Expand Down
5 changes: 2 additions & 3 deletions src/stactools/cli/commands/version.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from click import echo

import pystac
from click import echo
from click.core import Command, Group
from pystac.version import get_stac_version

from stactools.core import __version__
from click.core import Command, Group


def create_version_command(cli: Group) -> Command:
Expand Down
2 changes: 2 additions & 0 deletions src/stactools/cli/registry.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pkgutil import ModuleInfo
from types import ModuleType
from typing import Callable, Iterator, List

from click import Command, Group


Expand All @@ -25,6 +26,7 @@ def load_plugins(self) -> None:
"""
import importlib
import pkgutil

import stactools

# From https://packaging.python.org/guides/creating-and-discovering-plugins/#using-namespace-packages # noqa
Expand Down
12 changes: 6 additions & 6 deletions src/stactools/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# flake8: noqa

from stactools.core.io import use_fsspec
from stactools.core.add import add_item
from stactools.core.addraster import add_raster_to_item
from stactools.core.copy import (
copy_catalog,
move_all_assets,
move_asset_file_to_item,
move_assets,
move_all_assets,
copy_catalog,
)
from stactools.core.io import use_fsspec
from stactools.core.layout import layout_catalog
from stactools.core.merge import merge_items, merge_all_items
from stactools.core.add import add_item
from stactools.core.addraster import add_raster_to_item
from stactools.core.merge import merge_all_items, merge_items

__all__ = [
"add_item",
Expand Down
2 changes: 1 addition & 1 deletion src/stactools/core/add.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from pystac import Catalog, Item, Collection
from pystac import Catalog, Collection, Item
from pystac.layout import BestPracticesLayoutStrategy

from stactools.core.copy import move_assets as do_move_assets
Expand Down
Loading

0 comments on commit e3b41f8

Please sign in to comment.