Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
agrouaze committed Nov 28, 2024
1 parent b1f0222 commit cd71f70
Show file tree
Hide file tree
Showing 12 changed files with 1,490 additions and 836 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ jobs:
name: Publish to PyPI
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
contents: "read"
id-token: "write"
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip build twine
Expand All @@ -32,4 +32,4 @@ jobs:
with:
password: ${{ secrets.pypi_token }}
repository_url: https://upload.pypi.org/legacy/
verify_metadata: true
verify_metadata: true
1 change: 0 additions & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ API reference

.. autoclass:: Sentinel1Reader
:members:

24 changes: 12 additions & 12 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autosummary',
'sphinx.ext.autodoc',
"sphinx.ext.autosummary",
"sphinx.ext.autodoc",
"myst_parser",
"sphinx.ext.extlinks",
"sphinx.ext.intersphinx",
"IPython.sphinxext.ipython_directive",
"IPython.sphinxext.ipython_console_highlighting",
'nbsphinx',
'jupyter_sphinx',
'sphinx.ext.napoleon'
"nbsphinx",
"jupyter_sphinx",
"sphinx.ext.napoleon",
]

extlinks = {
Expand All @@ -36,9 +36,9 @@
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

html_static_path = ['_static']
html_static_path = ["_static"]

html_style = 'css/xsar.css'
html_style = "css/xsar.css"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down Expand Up @@ -84,21 +84,21 @@
"dask": ("https://docs.dask.org/en/latest", None),
"xarray": ("https://docs.xarray.dev/en/latest/", None),
"rasterio": ("https://rasterio.readthedocs.io/en/latest/", None),
"datatree": ("https://xarray-datatree.readthedocs.io/en/latest/", None)
"datatree": ("https://xarray-datatree.readthedocs.io/en/latest/", None),
}

html_theme_options = {
'navigation_depth': 4, # FIXME: doesn't work as expeted: should expand side menu
'collapse_navigation': False # FIXME: same as above
"navigation_depth": 4, # FIXME: doesn't work as expeted: should expand side menu
"collapse_navigation": False, # FIXME: same as above
}

# If true, links to the reST sources are added to the pages.
html_show_sourcelink = False

nbsphinx_allow_errors = False

nbsphinx_execute = 'always'
nbsphinx_execute = "always"

nbsphinx_timeout = 300

today_fmt = '%b %d %Y at %H:%M'
today_fmt = "%b %d %Y at %H:%M"
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ Last documentation build: |today|
.. _xarray.Dataset: http://xarray.pydata.org/en/stable/generated/xarray.Dataset.html
.. _`recommended installation`: installing.rst#recommended-packages
.. _SAFE format: https://sentinel.esa.int/web/sentinel/user-guides/sentinel-1-sar/data-formats
.. _jupyter notebook: https://jupyter.readthedocs.io/en/latest/running.html#running
.. _jupyter notebook: https://jupyter.readthedocs.io/en/latest/running.html#running
2 changes: 1 addition & 1 deletion docs/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ Pytest configuration
Pytest uses a default configuration file (`config.yml`) in which we can found products paths to test.
This configuration can be superseded by adding a local config file on the home directory :
(`~/xarray-safe-s1/localconfig.yml`).
In this file, testing files can be listed in the var `product_paths`.
In this file, testing files can be listed in the var `product_paths`.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ known-third-party = ["xarray", "toolz", "construct"]

[tool.ruff.lint.flake8-tidy-imports]
# Disallow all relative imports.
ban-relative-imports = "all"
ban-relative-imports = "all"
9 changes: 4 additions & 5 deletions safe_s1/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import traceback
#import safe_s1
from safe_s1.reader import Sentinel1Reader

try:
from importlib import metadata
except ImportError: # for Python<3.8
except ImportError: # for Python<3.8
import importlib_metadata as metadata
try:
try:
__version__ = metadata.version("xarray-safe-s1")
except Exception:
print('trace',traceback.format_exc())
print("trace", traceback.format_exc())
__version__ = "999"
2 changes: 1 addition & 1 deletion safe_s1/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# default data paths for tests
product_paths:
- 'S1A_IW_GRDH_1SDV_20170907T103020_20170907T103045_018268_01EB76_Z010.SAFE'
- "S1A_IW_GRDH_1SDV_20170907T103020_20170907T103045_018268_01EB76_Z010.SAFE"
27 changes: 17 additions & 10 deletions safe_s1/getconfig.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
import yaml
import os
import logging
import safe_s1
import os
from pathlib import Path

import yaml

import safe_s1


# determine the config file we will use (config.yml by default, and a local config if one is present) and retrieve
# the products names
def get_config():
local_config_pontential_path = os.path.join(os.path.dirname(safe_s1.__file__), 'localconfig.yml')
logging.info('potential local config: %s',local_config_pontential_path)
#local_config_pontential_path = Path(os.path.join('~', 'xarray-safe-s1', 'localconfig.yml')).expanduser()
local_config_pontential_path = os.path.join(
os.path.dirname(safe_s1.__file__), "localconfig.yml"
)
logging.info("potential local config: %s", local_config_pontential_path)
# local_config_pontential_path = Path(os.path.join('~', 'xarray-safe-s1', 'localconfig.yml')).expanduser()
if os.path.exists(local_config_pontential_path):
logging.info('localconfig used')
logging.info("localconfig used")
config_path = local_config_pontential_path
with open(config_path) as config_content:
conf = yaml.load(config_content, Loader=yaml.SafeLoader)
else:
logging.info('default config')
config_path = Path(os.path.join(os.path.dirname(safe_s1.__file__), 'config.yml'))
logging.info("default config")
config_path = Path(
os.path.join(os.path.dirname(safe_s1.__file__), "config.yml")
)
with open(config_path) as config_content:
conf = yaml.load(config_content, Loader=yaml.SafeLoader)
return conf

Loading

0 comments on commit cd71f70

Please sign in to comment.