Skip to content

Commit f901334

Browse files
authoredAug 4, 2019
Merge pull request #14 from quantmind/master
1.1.0
2 parents 245cf92 + c86cd9c commit f901334

22 files changed

+948
-480
lines changed
 

‎.circleci/config.yml

+3-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
version: 2
22
jobs:
3-
test35:
4-
docker:
5-
- image: circleci/python:3.5
6-
steps:
7-
- checkout
8-
- run:
9-
name: install
10-
command: sudo ./dev/install.sh
11-
- run:
12-
name: test
13-
command: pytest
143
test36:
154
docker:
165
- image: circleci/python:3.6
@@ -33,6 +22,9 @@ jobs:
3322
- run:
3423
name: flake8
3524
command: flake8
25+
- run:
26+
name: black
27+
command: make black
3628
- run:
3729
name: test
3830
command: pytest --cov
@@ -65,12 +57,10 @@ workflows:
6557
build-deploy:
6658
jobs:
6759
- tests
68-
- test35
6960
- test36
7061
- deploy-release:
7162
requires:
7263
- tests
73-
- test35
7464
- test36
7565
filters:
7666
branches:

‎.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.pythonPath": "venv/bin/python"
3+
}

‎Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ clean: ## remove python cache files
1313

1414
version: ## dipsplay software version
1515
@python3 -c "import ccy; print(ccy.__version__)"
16+
17+
18+
black: ## check black formatting
19+
black --check ccy tests

‎README.rst

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ join and add more.
55

66
:Package: |license| |pyversions| |status| |downloads|
77
:CI: |master-build| |coverage-master|
8-
:Documentation: http://pythonhosted.org/ccy/
9-
:Dowloads: http://pypi.python.org/pypi/ccy
10-
:Source: https://github.com/lsbardel/ccy
8+
:Dowloads: https://pypi.org/project/ccy/
9+
:Source: https://github.com/quantmind/ccy
1110

1211
.. |pyversions| image:: https://img.shields.io/pypi/pyversions/ccy.svg
1312
:target: https://pypi.org/project/ccy/

‎ccy/__init__.py

+62-29
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,74 @@
11
"""Python currencies"""
22

3-
__version__ = '1.0.0'
3+
__version__ = "1.1.0"
44

55

6-
from .core.currency import (
7-
currency, currencydb, ccypair, currency_pair,
8-
dump_currency_table
9-
)
106
from .core.country import (
11-
country, countryccy, set_new_country,
12-
countries, set_country_map, country_map,
13-
CountryError, eurozone, print_eurozone
7+
CountryError,
8+
countries,
9+
country,
10+
country_map,
11+
countryccy,
12+
eurozone,
13+
print_eurozone,
14+
set_country_map,
15+
set_new_country,
1416
)
15-
from .core.daycounter import getdc, ActActYears, alldc
17+
from .core.currency import (
18+
ccypair,
19+
currency,
20+
currency_pair,
21+
currencydb,
22+
dump_currency_table,
23+
)
24+
from .core.daycounter import ActActYears, alldc, getdc
1625
from .dates.converters import (
17-
todate, date2timestamp, timestamp2date, yyyymmdd2date,
18-
date2yyyymmdd, juldate2date, date2juldate, date_from_string,
19-
jstimestamp
26+
date2juldate,
27+
date2timestamp,
28+
date2yyyymmdd,
29+
date_from_string,
30+
jstimestamp,
31+
juldate2date,
32+
timestamp2date,
33+
todate,
34+
yyyymmdd2date,
2035
)
2136
from .dates.futures import future_date_to_code, future_month_dict
22-
from .dates.period import period, Period
23-
37+
from .dates.period import Period, period
2438

2539
__all__ = [
26-
'currency', 'currencydb', 'ccypair', 'currency_pair',
27-
'dump_currency_table',
40+
"currency",
41+
"currencydb",
42+
"ccypair",
43+
"currency_pair",
44+
"dump_currency_table",
2845
#
29-
'getdc', 'ActActYears', 'alldc',
46+
"getdc",
47+
"ActActYears",
48+
"alldc",
3049
#
31-
'country', 'countryccy', 'set_new_country',
32-
'countries', 'set_country_map', 'country_map',
33-
'CountryError', 'eurozone', 'print_eurozone',
34-
'future_date_to_code', 'future_month_dict',
35-
'period', 'Period',
36-
'todate', 'date2timestamp', 'timestamp2date',
37-
'yyyymmdd2date', 'date2yyyymmdd', 'juldate2date',
38-
'date2juldate', 'date_from_string', 'jstimestamp'
50+
"country",
51+
"countryccy",
52+
"set_new_country",
53+
"countries",
54+
"set_country_map",
55+
"country_map",
56+
"CountryError",
57+
"eurozone",
58+
"print_eurozone",
59+
"future_date_to_code",
60+
"future_month_dict",
61+
"period",
62+
"Period",
63+
"todate",
64+
"date2timestamp",
65+
"timestamp2date",
66+
"yyyymmdd2date",
67+
"date2yyyymmdd",
68+
"juldate2date",
69+
"date2juldate",
70+
"date_from_string",
71+
"jstimestamp",
3972
]
4073

4174

@@ -45,22 +78,22 @@ def cross(code):
4578

4679

4780
def crossover(code):
48-
return currency(code).as_cross('/')
81+
return currency(code).as_cross("/")
4982

5083

5184
def all():
5285
return currencydb().keys()
5386

5487

5588
def g7():
56-
return ['EUR', 'GBP', 'USD', 'CAD']
89+
return ["EUR", "GBP", "USD", "CAD"]
5790

5891

5992
def g10():
60-
return g7() + ['CHF', 'SEK', 'JPY']
93+
return g7() + ["CHF", "SEK", "JPY"]
6194

6295

6396
def g10m():
6497
"""modified g10 = G10 + AUD, NZD, NOK
6598
"""
66-
return g10() + ['AUD', 'NZD', 'NOK']
99+
return g10() + ["AUD", "NZD", "NOK"]

‎ccy/core/country.py

+21-19
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
# using ISO 3166-1 alpha-2 country codes
99
# see http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
1010
#
11-
eurozone = tuple(('AT BE CY DE EE ES FI FR GR IE IT LU LV LT MT '
12-
'NL PT SI SK').split(' '))
11+
eurozone = tuple(
12+
("AT BE CY DE EE ES FI FR GR IE IT LU LV LT MT " "NL PT SI SK").split(" ")
13+
)
1314

1415

1516
def print_eurozone():
@@ -29,7 +30,7 @@ class CountryError(Exception):
2930
def country(code):
3031
cdb = countries()
3132
code = country_map(code)
32-
return cdb.get(code, '')
33+
return cdb.get(code, "")
3334

3435

3536
def countryccy(code):
@@ -39,15 +40,16 @@ def countryccy(code):
3940

4041

4142
def countries():
42-
'''
43+
"""
4344
get country dictionar from pytz and add some extra.
44-
'''
45+
"""
4546
global _countries
4647
if not _countries:
4748
v = {}
4849
_countries = v
4950
try:
5051
from pytz import country_names
52+
5153
for k, n in country_names.items():
5254
v[k.upper()] = n
5355
except Exception:
@@ -56,27 +58,27 @@ def countries():
5658

5759

5860
def countryccys():
59-
'''
61+
"""
6062
Create a dictionary with keys given by countries ISO codes and values
6163
given by their currencies
62-
'''
64+
"""
6365
global _country_ccys
6466
if not _country_ccys:
6567
v = {}
6668
_country_ccys = v
6769
ccys = currencydb()
6870
for c in eurozone:
69-
v[c] = 'EUR'
71+
v[c] = "EUR"
7072
for c in ccys.values():
7173
if c.default_country:
7274
v[c.default_country] = c.code
7375
return _country_ccys
7476

7577

7678
def set_country_map(cfrom, cto, name=None, replace=True):
77-
'''
79+
"""
7880
Set a mapping between a country code to another code
79-
'''
81+
"""
8082
global _country_maps
8183
cdb = countries()
8284
cfrom = str(cfrom).upper()
@@ -86,7 +88,7 @@ def set_country_map(cfrom, cto, name=None, replace=True):
8688
c = name
8789
cto = str(cto).upper()
8890
if cto in cdb:
89-
raise CountryError('Country %s already in database' % cto)
91+
raise CountryError("Country %s already in database" % cto)
9092
cdb[cto] = c
9193
_country_maps[cfrom] = cto
9294
ccys = currencydb()
@@ -101,34 +103,34 @@ def set_country_map(cfrom, cto, name=None, replace=True):
101103
cdb.pop(cfrom)
102104
cccys.pop(cfrom)
103105
else:
104-
raise CountryError('Country %s not in database' % c)
106+
raise CountryError("Country %s not in database" % c)
105107

106108

107109
def set_new_country(code, ccy, name):
108-
'''
110+
"""
109111
Add new country code to database
110-
'''
112+
"""
111113
code = str(code).upper()
112114
cdb = countries()
113115
if code in cdb:
114-
raise CountryError('Country %s already in database' % code)
116+
raise CountryError("Country %s already in database" % code)
115117
ccys = currencydb()
116118
ccy = str(ccy).upper()
117119
if ccy not in ccys:
118-
raise CountryError('Currency %s not in database' % ccy)
120+
raise CountryError("Currency %s not in database" % ccy)
119121
cdb[code] = str(name)
120122
cccys = countryccys()
121123
cccys[code] = ccy
122124

123125

124126
def country_map(code):
125-
'''
127+
"""
126128
Country mapping
127-
'''
129+
"""
128130
code = str(code).upper()
129131
global _country_maps
130132
return _country_maps.get(code, code)
131133

132134

133135
# Add eurozone to list of Countries
134-
set_new_country('EU', 'EUR', 'Eurozone')
136+
set_new_country("EU", "EUR", "Eurozone")

0 commit comments

Comments
 (0)