Skip to content

Commit bce43c4

Browse files
author
ravi
committed
fix readme syntax
1 parent 68ecb5d commit bce43c4

3 files changed

Lines changed: 42 additions & 48 deletions

File tree

README.md

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,64 +19,58 @@ Installation:
1919
------------
2020

2121
Install using python package
22-
23-
.. code-block:: bash
24-
25-
$ pip install forex-python
22+
```
23+
$ pip install forex-python
24+
```
2625

2726
Or directly cloning the repo:
28-
29-
.. code-block:: bash
30-
31-
$ python setup.py install
27+
```
28+
$ python setup.py install
29+
```
3230

3331
Examples:
3432
------------------
3533

3634
Initialize class
37-
38-
.. code-block:: python
39-
40-
>>> from forex_python.converter import CurrencyRates
41-
>>> c = CurrencyRates()
35+
```python
36+
>>> from forex_python.converter import CurrencyRates
37+
>>> c = CurrencyRates()
38+
```
4239

4340
list all latest currency rates for "USD"
44-
45-
.. code-block:: python
46-
47-
>>> c.get_rates('USD')
48-
{'EUR':19.22}
41+
```python
42+
>>> c.get_rates('USD')
43+
{u'IDR': 13625.0, u'BGN': 1.7433, u'ILS': 3.8794, u'GBP': 0.68641, u'DKK': 6.6289, u'CAD': 1.3106, u'JPY': 110.36, u'HUF': 282.36, u'RON': 4.0162, u'MYR': 4.081, u'SEK': 8.3419, u'SGD': 1.3815, u'HKD': 7.7673, u'AUD': 1.3833, u'CHF': 0.99144, u'KRW': 1187.3, u'CNY': 6.5475, u'TRY': 2.9839, u'HRK': 6.6731, u'NZD': 1.4777, u'THB': 35.73, u'EUR': 0.89135, u'NOK': 8.3212, u'RUB': 66.774, u'INR': 67.473, u'MXN': 18.41, u'CZK': 24.089, u'BRL': 3.5473, u'PLN': 3.94, u'PHP': 46.775, u'ZAR': 15.747}
44+
```
4945

5046
Get Conversion rate from USD to INR
51-
52-
.. code-block:: python
53-
54-
>>> c.get_rate('USD', 'INR')
55-
67.32
47+
```python
48+
>>> c.get_rate('USD', 'INR')
49+
67.473
50+
```
5651

5752
Convert amount from USD to INR:
58-
.. code-block:: python
59-
60-
>>> c.convert('USD', 'INR', 10)
61-
673.25
53+
```python
54+
>>> c.convert('USD', 'INR', 10)
55+
674.73
56+
```
6257

6358
Convert amount from USD to INR based on 2010-03-01 rates
64-
65-
.. code-block:: python
66-
67-
>>> c.convert(100, 'EUR', 'USD', 10, "2010-03-01")
68-
632.60
59+
```python
60+
>>> import datetime
61+
>>> date_obj = datetime.datetime.strptime('2010-05-10', "%Y-%m-%d").date()
62+
>>> c.convert('EUR', 'USD', 10, date_obj)
63+
12.969
64+
```
6965

7066
RatesNotAvailableError for invalid currency codes and missing currency code from source:
71-
72-
.. code-block:: python
73-
67+
```python
7468
>>> c.get_rate('XYZ', 'INR')
7569
Traceback (most recent call last):
7670
RatesNotAvailableError: Currency XYZ => INR rate not available for Date latest.
71+
```
7772

78-
Compleate `documentation`_
73+
Compleate [Documentation](http://forex-python.readthedocs.org/en/latest/?badge=latest)
7974

8075
We welcome your feedback and support. found bug raise github issue.
8176

82-
.. _documentation: http://forex-python.readthedocs.org/en/latest/?badge=latest

forex_python/converter.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ def __init__(self):
1717
def _source_url(self):
1818
return "http://api.fixer.io/"
1919

20-
def _get_date_string(self, date_str):
21-
if date_str is None:
20+
def _get_date_string(self, date_obj):
21+
if date_obj is None:
2222
return 'latest'
2323
try:
24-
datetime.datetime.strptime(date_str, '%Y-%m-%d')
24+
date_str = date_obj.strftime('%Y-%m-%d')
2525
return date_str
2626
except ValueError:
27-
raise ValueError("Incorrect date String, date_str should be YYYY-MM-DD")
27+
raise ValueError("Incorrect date String, date should be YYYY-MM-DD")
2828

2929

3030
class CurrencyRates(Common):
3131

32-
def get_rates(self, base_cur, date_str=None):
33-
date_str = self._get_date_string(date_str)
32+
def get_rates(self, base_cur, date_obj=None):
33+
date_str = self._get_date_string(date_obj)
3434
payload = {'base': base_cur}
3535
source_url = self._source_url() + date_str
3636
response = requests.get(source_url, params=payload)
@@ -39,8 +39,8 @@ def get_rates(self, base_cur, date_str=None):
3939
return rates
4040
raise RatesNotAvailableError("Currency Rates Source Not Ready")
4141

42-
def get_rate(self, base_cur, dest_cur, date_str=None):
43-
date_str = self._get_date_string(date_str)
42+
def get_rate(self, base_cur, dest_cur, date_obj=None):
43+
date_str = self._get_date_string(date_obj)
4444
payload = {'base': base_cur, 'symbols': dest_cur}
4545
source_url = self._source_url() + date_str
4646
response = requests.get(source_url, params=payload)
@@ -52,8 +52,8 @@ def get_rate(self, base_cur, dest_cur, date_str=None):
5252
return rate
5353
raise RatesNotAvailableError("Currency Rates Source Not Ready")
5454

55-
def convert(self, base_cur, dest_cur, amount, date_str=None):
56-
date_str = self._get_date_string(date_str)
55+
def convert(self, base_cur, dest_cur, amount, date_obj=None):
56+
date_str = self._get_date_string(date_obj)
5757
payload = {'base': base_cur, 'symbols': dest_cur}
5858
source_url = self._source_url() + date_str
5959
response = requests.get(source_url, params=payload)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from setuptools import setup, find_packages
22

3-
VERSION = 0.9
3+
VERSION = 0.1
44

55
with open('README.md') as fl:
66
LONG_DESCRIPTION = fl.read()

0 commit comments

Comments
 (0)