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

Package renovation #12

Merged
merged 6 commits into from
May 16, 2022
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
40 changes: 40 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
python -m pip install -e .
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --config=setup.cfg --count --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --config=setup.cfg --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,4 @@ crashlytics.properties
crashlytics-build.properties
fabric.properties

.idea/
.idea/
38 changes: 38 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
default_stages: [commit]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml

- repo: https://github.com/asottile/pyupgrade
rev: v2.32.1
hooks:
- id: pyupgrade
args: [--py39-plus]

- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort

- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
args: ["--config=setup.cfg"]
additional_dependencies: [flake8-isort]

# sets up .pre-commit-ci.yaml to ensure pre-commit dependencies stay up to date
ci:
autoupdate_schedule: weekly
skip: []
submodules: false
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

10 changes: 8 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@ Changes


#### ver.: 0.4.5 (15.08.2019)
* Travis repo path update
* Travis repo path update

#### ver.: 0.4.6 (15.08.2019)
* Update long_description_content_type

#### ver.: 0.4.7 (15.08.2019)
* i hate pypi
* i hate pypi

#### ver.: 0.5.0 (16.05.2022)
* add debug logging
* data structures optimizing
* add pre-commit hooks
* replace Travis with GitHub Actions
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include README.md
include README.md
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.DEFAULT_GOAL := check
.PHONY: help test lint

check: lint test ## Run linting and tests

lint: ## Run pre-commit hooks
pre-commit run -a

test: ## Run tests
pytest


## Help

help: ## Show help message
@IFS=$$'\n' ; \
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##/:/'`); \
printf "%s\n\n" "Usage: make [task]"; \
printf "%-20s %s\n" "task" "help" ; \
printf "%-20s %s\n" "------" "----" ; \
for help_line in $${help_lines[@]}; do \
IFS=$$':' ; \
help_split=($$help_line) ; \
help_command=`echo $${help_split[0]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
help_info=`echo $${help_split[2]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
printf '\033[36m'; \
printf "%-20s %s" $$help_command ; \
printf '\033[0m'; \
printf "%s\n" $$help_info; \
done
42 changes: 25 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
# cbrf


_Обертка для работы с API Центробанка_

_Wrapper for The Central Bank of the Russian Federation site API_

[![Build Status](https://travis-ci.org/Egregors/cbrf.svg?branch=master)](https://travis-ci.org/Egregors/cbrf)
[![Build Status](https://github.com/egregors/cbrf/actions/workflows/python-package.yml/badge.svg)](https://github.com/egregors/cbrf/actions)
[![PyPI version](https://badge.fury.io/py/cbrf.svg)](https://badge.fury.io/py/cbrf)

[Site](http://www.cbr.ru/) and [API](http://www.cbr.ru/scripts/Root.asp?PrtId=SXML)
of The Central Bank of the Russian Federation.
[Site](https://www.cbr.ru/) and [API](https://www.cbr.ru/scripts/Root.asp?PrtId=SXML)
of The Central Bank of the Russian Federation.

## Installation

Stable version:
Expand All @@ -20,20 +17,22 @@ Stable version:
```

Dev version:

```
git clone https://github.com/Egregors/cbrf.git
cd cbrf
pip install -e .
```

## Settings
For using with your own hostname set environment variables, for example

For using with your own hostname set environment variables, for example

```
export CBRF_URL_SCHEME=http
export CBRF_URL_SCHEME=https
export CBRF_URL_HOST=www.my-own-cbr.ru
```

## How to use

### API
Expand All @@ -57,7 +56,7 @@ To get raw XML answers you should use `cbrf.api` methods:

### Models

Also you can user base models for work with API (see examples in the tests).
You can use base models for work with API (see examples in the tests).

`CurrenciesInfo`

Expand Down Expand Up @@ -98,16 +97,25 @@ Decimal('72.0143')
Decimal('28.6200')
```

### Tests

To run tests:
Also, you can show `DEBUG` info, by setting logger level to DEBUG in your code:
```python
import logging

logging.basicConfig(level=logging.DEBUG)
```
pytest cbrf/tests.py

### Linting & Tests

To run lint & tests:

```shell
make lint
make tests
```

> You should install `pytest` first

## Contributing

Bug reports, bug fixes, and new features are always welcome.
Please open issues, and submit pull requests for any new code.
Bug reports, bug fixes, and new features are always welcome.
Please open issues, and submit pull requests for any new code.
21 changes: 10 additions & 11 deletions cbrf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
# -*- coding: utf-8 -*-

# ___ ___ __ __
# / / /__ /__ ) (__/__)
# /__/ /___) / /
# )

"""
cbrf.py
~~~~~~~
Wrapper for The Central Bank of the Russian Federation site API.

CBRF site: http://www.cbr.ru/eng/
Source: https://github.com/Egregors/cbr
CBRF site: https://www.cbr.ru/eng/
Source: https://github.com/egregors/cbr

:copyright: (c) 2017 by Vadim Iskuchekov (@egregors)
:license: MIT
"""

__title__ = 'cbrf'
__version__ = '0.4.7'
__title__ = "cbrf"
__version__ = "0.5.0"

from .api import get_currencies_info, get_daily_rates, get_dynamic_rates

__all__ = [
"get_currencies_info",
"get_daily_rates",
"get_dynamic_rates",
]
Loading