Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show available IIASA platforms using ixmp4 CLI #835

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 4 additions & 18 deletions pyam/iiasa.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
import pandas as pd
import requests
import yaml
from ixmp4.cli import utils
from ixmp4.cli.platforms import tabulate_manager_platforms
from ixmp4.conf import settings
from ixmp4.conf.auth import ManagerAuth
from requests.auth import AuthBase

from pyam.core import IamDataFrame
from pyam.logging import deprecation_warning
from pyam.str import is_str, shorten
from pyam.str import is_str
from pyam.utils import (
IAMC_IDX,
META_IDX,
Expand All @@ -36,9 +36,7 @@
You are connected to the {} scenario explorer hosted by IIASA.
If you use this data in any published format, please cite the
data as provided in the explorer guidelines: {}
""".replace(
"\n", ""
)
""".replace("\n", "")
IXMP4_LOGIN = "Please run `ixmp4 login <username>` in a console"

# path to local configuration settings
Expand All @@ -52,19 +50,7 @@ def platforms() -> None:
--------
ixmp4.conf.settings.manager.list_platforms
"""

_platforms = ixmp4.conf.settings.manager.list_platforms()
utils.echo("IIASA platform".ljust(20) + "Access".ljust(10) + "Notice\n")

for p in _platforms:
utils.important(shorten(p.name, 20), nl=False)
utils.echo(str(p.accessibility.value.lower()).ljust(10), nl=False)

if p.notice is not None:
utils.echo(shorten(p.notice, 55), nl=False)
utils.echo()

utils.info("\n" + str(len(_platforms)) + " total \n")
tabulate_manager_platforms(ixmp4.conf.settings.manager.list_platforms())


def set_config(user, password, file=None):
Expand Down
7 changes: 0 additions & 7 deletions pyam/str.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,3 @@ def escape_regexp(s):
def is_str(x):
"""Returns True if x is a string"""
return isinstance(x, six.string_types)


def shorten(value: str, length: int):
"""Shorten a string to a given length adding `...`"""
if len(value) > length - 4:
value = value[: length - 4] + "..."
return value.ljust(length)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ classifiers = [
[tool.poetry.dependencies]
python = ">=3.10, <3.13"
iam-units = ">=2020.4.21"
ixmp4 = ">=0.7.1"
ixmp4 = ">=0.7.3"
matplotlib = ">=3.6.0"
numpy = ">=1.26.0"
openpyxl = ">=3.1.2"
Expand Down
1 change: 1 addition & 0 deletions tests/test_data_worldbank.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

try:
import wbdata # noqa: F401

WB_UNAVAILABLE = False
except ImportError:
WB_UNAVAILABLE = True
Expand Down