]> jfr.im git - irc/rizon/acid.git/blob - pyva/src/main/python/erepublik/api/exchange.py
Import acidictive 4 and pyva plugin
[irc/rizon/acid.git] / pyva / src / main / python / erepublik / api / exchange.py
1 import feed
2 from feed import XmlFeed
3
4 def get(buy, sell):
5 return Exchange(XmlFeed('http://api.erepublik.com/v2/feeds/exchange/%s/%s' % (buy, sell)))
6
7 class Exchange:
8 """Erepublik monetary market"""
9
10 def __init__(self, f):
11 self.records = [{
12 'amount': record.decimal('amount'),
13 'price': record.decimal('exchange-rate'),
14 'id': record.int('seller//id'),
15 'name': record.text('seller//name')}
16 for record in f.elements('/offers/offer')]
17