Skip to content

Commit

Permalink
update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
tammoippen committed Nov 6, 2024
1 parent 09d4e8b commit 2e9e41e
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 193 deletions.
178 changes: 0 additions & 178 deletions .circleci/config.yml

This file was deleted.

79 changes: 79 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: CI

on:
push:
branches:
- "master"
pull_request:
branches:
- "master"

jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['pypy-3.9', 3.9, '3.10', 'pypy-3.10', '3.11', '3.12', '3.13']
include:
- os: ubuntu-latest
path: ~/.cache/pip
- os: macos-latest
path: ~/Library/Caches/pip
- os: windows-latest
path: ~\AppData\Local\pip\Cache
exclude:
- os: macos-latest
python-version: 'pypy-3.9'
- os: macos-latest
python-version: 'pypy-3.10'
- os: windows-latest
python-version: 'pypy-3.9'
- os: windows-latest
python-version: 'pypy-3.10'
defaults:
run:
shell: bash

runs-on: ${{ matrix.os }}
env:
PYTHONIOENCODING: UTF-8
steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Set Up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Cache Install
id: restore-cache
uses: actions/cache@v4
with:
path: |
${{ matrix.path }}
poetry.lock
key: ${{ matrix.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('tests/requirements.txt') }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: '1.8.3' # ${{ startsWith(matrix.python-version, 'pypy') && '1.2.2' || '1.8.3' }}
virtualenvs-create: false

- name: Install
run: poetry install

- name: Style
if: ${{ ! startsWith(matrix.python-version, 'pypy-') }}
run: make check

- name: Tests
run: make test

- uses: codecov/codecov-action@v4
with:
flags: unittests
name: coverage-${{ matrix.os }}-${{ matrix.python-version }}
verbose: true
37 changes: 22 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![CircleCI](https://circleci.com/gh/tammoippen/iso4217parse.svg?style=svg)](https://circleci.com/gh/tammoippen/iso4217parse)
[![Coverage Status](https://coveralls.io/repos/github/tammoippen/iso4217parse/badge.svg?branch=master)](https://coveralls.io/github/tammoippen/iso4217parse?branch=master)
[![Tested CPython Versions](https://img.shields.io/badge/cpython-2.7%2C%203.5%2C%203.6%2C%203.7-brightgreen.svg)](https://img.shields.io/badge/cpython-2.7%2C%203.5%2C%203.6%2C%203.7-brightgreen.svg)
[![Tested PyPy Versions](https://img.shields.io/badge/pypy-2.7--6.0.0%2C%203.5--6.0.0-brightgreen.svg)](https://img.shields.io/badge/pypy-2.7--6.0.0%2C%203.5--6.0.0-brightgreen.svg)
[![Tested CPython Versions](https://img.shields.io/badge/cpython-3.9%2C%203.10%2C%203.11%2C%203.12%2C%203.13-brightgreen.svg)](https://img.shields.io/badge/cpython-3.9%2C%203.10%2C%203.11%2C%203.12%2C%203.13-brightgreen.svg)
[![Tested PyPy Versions](https://img.shields.io/badge/pypy-3.9%2C%203.10-brightgreen.svg)](https://img.shields.io/badge/pypy-3.9%2C%203.10%2C%203.10-brightgreen.svg)
[![PyPi version](https://img.shields.io/pypi/v/iso4217parse.svg)](https://pypi.python.org/pypi/iso4217parse)
[![PyPi license](https://img.shields.io/pypi/l/iso4217parse.svg)](https://pypi.python.org/pypi/iso4217parse)

Expand All @@ -11,21 +11,23 @@ Parse currencies (symbols and codes) from and to [ISO4217](https://en.wikipedia.

Similar to [iso4217](https://github.com/spoqa/iso4217) package, but

* data is aquired by scraping wikipedia (see [below](#data-aquisition)) - this is repeatable and you stay on the most current data
* currency symbols are currated by hand - this allows some fuzzy currency matching
* no download and parsing during install
* no external dependancies (`enum34`)
- data is aquired by scraping wikipedia (see [below](#data-aquisition)) - this is repeatable and you stay on the most current data
- currency symbols are currated by hand - this allows some fuzzy currency matching
- no download and parsing during install
- no external dependancies (`enum34`)

When you want to *reuse* the [*data.json*](https://github.com/tammoippen/iso4217parse/blob/master/iso4217parse/data.json) file for your projects, please leave a attribution note. I licence the file under (CC BY 4.0).
When you want to _reuse_ the [_data.json_](https://github.com/tammoippen/iso4217parse/blob/master/iso4217parse/data.json) file for your projects, please leave a attribution note. I licence the file under (CC BY 4.0).

Install:
```

```sh
pip install iso4217parse
```

## Documentation

Each currency is modeled as a `collections.namedtuple`:

```python
Currency = namedtuple('Currency', [
'alpha3', # unicode: the ISO4217 alpha3 code
Expand All @@ -38,7 +40,8 @@ Currency = namedtuple('Currency', [
])
```

**parse:** Try to parse the input in a best effort approach by using `by_alpha3()`, `by_code_num()`, ... functions:
**parse:** Try to parse the input in a best effort approach by using `by_alpha3()`, `by_code_num()`, ... functions:

```python
In [1]: import iso4217parse

Expand Down Expand Up @@ -86,6 +89,7 @@ Returns:
```

**by_alpha3:** Get the currency by its iso4217 alpha3 code:

```python
In [1]: import iso4217parse

Expand All @@ -107,6 +111,7 @@ Returns:
```

**by_code_num:** Get the currency by its iso4217 numeric code:

```python
In [1]: import iso4217parse

Expand All @@ -127,6 +132,7 @@ Returns:
```

**by_country:** Get currencies used in a country:

```python
In [1]: import iso4217parse

Expand Down Expand Up @@ -154,6 +160,7 @@ Returns:
```

**by_symbol:** Get currencies that use the given symbol:

```python
In [1]: import iso4217parse

Expand Down Expand Up @@ -202,6 +209,7 @@ Returns:
```

**by_symbol_match:** Look for currency symbol occurence in input string:

```python
In [1]: import iso4217parse

Expand Down Expand Up @@ -254,19 +262,18 @@ Returns:
List[Currency]: Currency objects found in `value`; filter by country_code.
```


## Data aquisition

Basic ISO4217 currency information is gathered from wikipedia: https://en.wikipedia.org/wiki/ISO_4217 . The tables are parsed with `gen_data.py` and stored in `iso4217parse/data.json`. This gives information for `alpha3`, `code_num`, `name`, `minor` and `countries`. The currency symbol information is hand gathered from:

* individuel wikipedia pages, i.e. [EUR](https://en.wikipedia.org/wiki/Euro) has a `Denominations` -> `Symbol` section.
* http://www.iotafinance.com/en/ISO-4217-Currency-Codes.html
* http://www.xe.com/currency/ , i.e. [GBP](http://www.xe.com/currency/gbp-british-pound) has a `Currency Facts` -> `Symbol` section
- individuel wikipedia pages, i.e. [EUR](https://en.wikipedia.org/wiki/Euro) has a `Denominations` -> `Symbol` section.
- http://www.iotafinance.com/en/ISO-4217-Currency-Codes.html
- http://www.xe.com/currency/ , i.e. [GBP](http://www.xe.com/currency/gbp-british-pound) has a `Currency Facts` -> `Symbol` section

and stored in `iso4217parse/symbols.json`. Each currency can have multiple currency symbols - the first symbol in the list is the (opinionated) choice
for the currency.

**Contribution Note**: Possible ways to contribute here:

* hand check symbols for currency code.
* automatic generation of the `iso4217parse/symbols.json` file.
- hand check symbols for currency code.
- automatic generation of the `iso4217parse/symbols.json` file.

0 comments on commit 2e9e41e

Please sign in to comment.