-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,259 additions
and
1,082 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,53 @@ | ||
.PHONY: help clean docs install-dev lint lint-check test publish notebook book publish-book | ||
|
||
.PHONY: help | ||
help: | ||
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' | ||
|
||
clean: ## remove python cache files | ||
.PHONY: clean | ||
clean: ## Remove python cache files | ||
find . -name '__pycache__' | xargs rm -rf | ||
find . -name '*.pyc' -delete | ||
rm -rf build | ||
rm -rf dist | ||
rm -rf .pytest_cache | ||
rm -rf .coverage | ||
|
||
|
||
docs: ## build docs | ||
.PHONY: docs | ||
docs: ## Build docs | ||
cd docs && make docs | ||
|
||
install-dev: ## install packages for development | ||
.PHONY: install-dev | ||
install-dev: ## Install packages for development | ||
@./dev/install | ||
|
||
.PHONY: lint | ||
lint: ## Run linters | ||
@poetry run ./dev/lint fix | ||
|
||
|
||
.PHONY: lint-check | ||
lint-check: ## Run linters in check mode | ||
@poetry run ./dev/lint | ||
|
||
|
||
test: ## test with python 3.8 with coverage | ||
.PHONY: test | ||
test: ## Test with python 3.8 with coverage | ||
@poetry run pytest -x -v --cov --cov-report xml | ||
|
||
publish: ## release to pypi and github tag | ||
.PHONY: publish | ||
publish: ## Release to pypi and github tag | ||
@poetry publish --build -u lsbardel -p $(PYPI_PASSWORD) | ||
|
||
.PHONY: notebook | ||
notebook: ## Run Jupyter notebook server | ||
@poetry run ./dev/start-jupyter 9095 | ||
|
||
.PHONY: book | ||
book: ## Build static jupyter {book} | ||
poetry run jupyter-book build docs --all | ||
|
||
publish-book: ## publish the book to github pages | ||
.PHONY: publish-book | ||
publish-book: ## Publish the book to github pages | ||
poetry run ghp-import -n -p -f docs/_build/html | ||
|
||
.PHONY: outdated | ||
outdated: ## Show outdated packages | ||
poetry show -o -a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import click | ||
import pandas as pd | ||
from rich.console import Console | ||
|
||
import ccy | ||
|
||
from .console import df_to_rich | ||
|
||
|
||
@click.group() | ||
def ccys() -> None: | ||
"""Currency commands.""" | ||
|
||
|
||
@ccys.command() | ||
def show() -> None: | ||
"""Show table with all currencies.""" | ||
df = pd.DataFrame(ccy.dump_currency_table()) | ||
console = Console() | ||
console.print(df_to_rich(df, exclude=("symbol_raw",))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import pandas as pd | ||
from rich.table import Table | ||
|
||
set_alike = set[str] | frozenset[str] | tuple[str] | list[str] | None | ||
|
||
|
||
def df_to_rich( | ||
df: pd.DataFrame, *, exclude: set_alike = None, **columns: dict | ||
) -> Table: | ||
table = Table() | ||
if exclude_columns := set(exclude or ()): | ||
df = df.drop(columns=exclude_columns) | ||
for column in df.columns: | ||
config = dict(justify="right", style="cyan", no_wrap=True) | ||
config.update(columns.get(column) or {}) | ||
table.add_column(column, **config) # type: ignore[arg-type] | ||
for row in df.values: | ||
table.add_row(*[str(item) for item in row]) | ||
return table |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
* 30 / 360 | ||
* Actual Actual | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
from copy import copy | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.