Skip to content

Commit

Permalink
🎨 improve command line interface close #83
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianazioti committed Oct 18, 2024
1 parent 7687b1f commit 9ec9ed9
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion examples/describe_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from wlts import WLTS

# Specify the URL of the WLTS instance to be used
service = WLTS('https://brazildatacube.dpi.inpe.br/wlts/')
service = WLTS('https://data.inpe.br/bdc/wlts/v1')

# Get collection metadata
print(service['prodes_amazonia_legal'])
2 changes: 1 addition & 1 deletion examples/list_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# You should create a wlts object attached to a given service
# Specify the URL of the WLTS instance to be used
service = WLTS('https://brazildatacube.dpi.inpe.br/wlts/')
service = WLTS('https://data.inpe.br/bdc/wlts/v1/')

# Returns the list of collections available on the service
print(service.collections)
2 changes: 1 addition & 1 deletion examples/text-repr.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from wlts import *

service = WLTS('https://brazildatacube.dpi.inpe.br/wlts/')
service = WLTS('https://data.inpe.br/bdc/wlts/v1/')

print(service)
print(str(service))
Expand Down
3 changes: 2 additions & 1 deletion examples/trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from wlts import WLTS

# Specify the URL of the WLTS instance to be used
service = WLTS(url='https://brazildatacube.dpi.inpe.br/wlts/', access_token='change-me')
service = WLTS(url='https://data.inpe.br/bdc/wlts/v1/')

# Example of trajectory operation
# Make sure the collection is available in service
Expand All @@ -31,6 +31,7 @@
collections='prodes_amazonia_legal,mapbiomas-v8',
start_date='2010'
)
print (tj_m)
for tj in tj_m['trajectories']:
print(tj.trajectory)

Expand Down
2 changes: 1 addition & 1 deletion run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
pydocstyle wlts examples tests setup.py && \
isort wlts examples tests setup.py --check-only --diff && \
check-manifest --ignore ".drone.yml,.readthedocs.yml" && \
sphinx-build -qnW --color -b doctest docs/sphinx/ docs/sphinx/_build/doctest && \
sphinx-build -qn --color -b doctest docs/sphinx/ docs/sphinx/_build/doctest && \
pytest
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
'pandas>=1.1',
'geopandas>=0.8.2',
'plotly==5.5.0',
'rich>=13.9.2',
'lccs @ git+https://github.com/brazil-data-cube/[email protected]',
]

Expand Down
2 changes: 1 addition & 1 deletion tests/test_trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def test_trajectory(self, wlts_objects, requests_mock, runner, config_obj):
], obj=config_obj)

assert result.exit_code == 0
assert 'trajectory:' in result.output
assert 'Processing trajectory request...' in result.output


if __name__ == '__main__':
Expand Down
7 changes: 4 additions & 3 deletions wlts/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
#

"""Command line interface for the WLTS client."""
from time import time

import click
from rich.console import Console
from rich.progress import Progress, TextColumn, BarColumn, TimeElapsedColumn
from rich.table import Table
from time import time
from rich.progress import BarColumn, Progress, TextColumn, TimeElapsedColumn
from rich.syntax import Syntax
from rich.table import Table

from .wlts import WLTS

Expand Down
4 changes: 3 additions & 1 deletion wlts/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
# along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>.
#
"""A class that represents a Collection in WLTS."""
from .utils import Utils
from typing import Any, Dict, Union

from .utils import Utils


class Collections(dict):
"""A class that describes a collection in WLTS.
Expand Down
6 changes: 4 additions & 2 deletions wlts/trajectories.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
# along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>.
#
"""A class that represents Trajectories in WLTS."""
from .utils import Utils
from typing import Any, Dict

import pandas as pd
from typing import Dict, Any

from .utils import Utils


class Trajectories(dict):
Expand Down
6 changes: 4 additions & 2 deletions wlts/trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
# along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>.
#
"""A class that represents Trajectory in WLTS."""
from .utils import Utils
from typing import Any, Dict, List
import pandas as pd

import geopandas as gpd
import pandas as pd
from shapely.geometry import shape

from .utils import Utils


class Trajectory(dict):
"""A class that represents a trajectory in WLTS.
Expand Down
3 changes: 2 additions & 1 deletion wlts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
# along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>.
#
"""Utility functions for WLTS client library."""
from typing import Any

import jinja2
from pkg_resources import resource_filename
from typing import Any

templateLoader = jinja2.FileSystemLoader(searchpath=resource_filename(__name__, 'templates/'))
templateEnv = jinja2.Environment(loader=templateLoader)
Expand Down

0 comments on commit 9ec9ed9

Please sign in to comment.