2010-02-25 17:53:28 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
#This file is part of Tryton. The COPYRIGHT file at the top level of
|
|
|
|
|
#this repository contains the full copyright notices and license terms.
|
|
|
|
|
|
2013-02-23 17:29:03 +01:00
|
|
|
import sys
|
2010-02-25 17:53:28 +01:00
|
|
|
import pycountry
|
|
|
|
|
|
|
|
|
|
symbols = {
|
2013-02-23 17:29:03 +01:00
|
|
|
'AFN': u'؋',
|
|
|
|
|
'ARS': u'$',
|
|
|
|
|
'AWG': u'ƒ',
|
|
|
|
|
'AZN': u'ман',
|
|
|
|
|
'BSD': u'$',
|
|
|
|
|
'THB': u'฿',
|
|
|
|
|
'PAB': u'B/.',
|
|
|
|
|
'BBD': u'$',
|
|
|
|
|
'BYR': u'p.',
|
|
|
|
|
'BZD': u'BZ$',
|
|
|
|
|
'BMD': u'$',
|
|
|
|
|
'VEF': u'Bs',
|
|
|
|
|
'BOB': u'$b',
|
|
|
|
|
'BRL': u'R$',
|
|
|
|
|
'BGN': u'лв',
|
|
|
|
|
'CAD': u'$',
|
|
|
|
|
'KYD': u'$',
|
|
|
|
|
'CLP': u'$',
|
|
|
|
|
'COP': u'$',
|
|
|
|
|
'BAM': u'KM',
|
|
|
|
|
'NIO': u'C$',
|
|
|
|
|
'CRC': u'₡',
|
|
|
|
|
'HRK': u'kn',
|
|
|
|
|
'CUP': u'₱',
|
|
|
|
|
'CZK': u'Kč',
|
|
|
|
|
'DKK': u'kr',
|
|
|
|
|
'MKD': u'ден',
|
|
|
|
|
'DOP': u'RD$',
|
|
|
|
|
'VND': u'₫',
|
|
|
|
|
'XCD': u'$',
|
|
|
|
|
'EGP': u'£',
|
|
|
|
|
'EUR': u'€',
|
|
|
|
|
'FJD': u'$',
|
|
|
|
|
'HUF': u'Ft',
|
|
|
|
|
'GBP': u'£',
|
|
|
|
|
'GIP': u'£',
|
|
|
|
|
'PYG': u'Gs',
|
|
|
|
|
'GYD': u'$',
|
|
|
|
|
'HKD': u'HK$',
|
|
|
|
|
'UAH': u'₴',
|
|
|
|
|
'ISK': u'kr',
|
|
|
|
|
'INR': u'₨',
|
|
|
|
|
'IRR': u'﷼',
|
|
|
|
|
'JMD': u'J$',
|
|
|
|
|
'LAK': u'₭',
|
|
|
|
|
'EEK': u'kr',
|
|
|
|
|
'LBP': u'£',
|
|
|
|
|
'ALL': u'Lek',
|
|
|
|
|
'HNL': u'L',
|
|
|
|
|
'LRD': u'$',
|
|
|
|
|
'LTL': u'Lt',
|
|
|
|
|
'MYR': u'RM',
|
|
|
|
|
'MUR': u'₨',
|
|
|
|
|
'MZN': u'MT',
|
|
|
|
|
'NGN': u'₦',
|
|
|
|
|
'NAD': u'$',
|
|
|
|
|
'NPR': u'₨',
|
|
|
|
|
'ANG': u'ƒ',
|
|
|
|
|
'ILS': u'₪',
|
|
|
|
|
'RON': u'lei',
|
|
|
|
|
'TWD': u'NT$',
|
|
|
|
|
'TRY': u'YTL',
|
|
|
|
|
'NZD': u'$',
|
|
|
|
|
'KPW': u'₩',
|
|
|
|
|
'NOK': u'kr',
|
|
|
|
|
'PEN': u'S/.',
|
|
|
|
|
'PKR': u'₨',
|
|
|
|
|
'UYU': u'$U',
|
|
|
|
|
'PHP': u'Php',
|
|
|
|
|
'BWP': u'P',
|
|
|
|
|
'QAR': u'﷼',
|
|
|
|
|
'GTQ': u'Q',
|
|
|
|
|
'ZAR': u'R',
|
|
|
|
|
'OMR': u'﷼',
|
|
|
|
|
'KHR': u'៛',
|
|
|
|
|
'IDR': u'Rp',
|
|
|
|
|
'RUB': u'руб',
|
|
|
|
|
'SHP': u'£',
|
|
|
|
|
'SAR': u'﷼',
|
|
|
|
|
'RSD': u'Дин.',
|
|
|
|
|
'SCR': u'₨',
|
|
|
|
|
'SGD': u'$',
|
|
|
|
|
'SBD': u'$',
|
|
|
|
|
'KGS': u'лв',
|
|
|
|
|
'SOS': u'S',
|
|
|
|
|
'LKR': u'₨',
|
|
|
|
|
'SRD': u'$',
|
|
|
|
|
'SEK': u'kr',
|
|
|
|
|
'CHF': u'CHF',
|
|
|
|
|
'KZT': u'лв',
|
|
|
|
|
'TTD': u'TT$',
|
|
|
|
|
'MNT': u'₮',
|
|
|
|
|
'USD': u'$',
|
|
|
|
|
'UZS': u'лв',
|
|
|
|
|
'YER': u'﷼',
|
|
|
|
|
'JPY': u'¥',
|
|
|
|
|
'CNY': u'元',
|
|
|
|
|
'ZWD': u'Z$',
|
|
|
|
|
'PLN': u'zł',
|
2010-02-25 17:53:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
currencies = {
|
|
|
|
|
'EUR': {
|
2010-06-16 19:20:07 +02:00
|
|
|
'rounding': "Decimal('0.01')",
|
2010-02-25 17:53:28 +01:00
|
|
|
'digits': '2',
|
|
|
|
|
'p_cs_precedes': 'False',
|
|
|
|
|
'n_cs_precedes': 'False',
|
|
|
|
|
'p_sep_by_space': 'True',
|
|
|
|
|
'n_sep_by_space': 'True',
|
|
|
|
|
'mon_grouping': '[3, 3, 0]',
|
|
|
|
|
'mon_decimal_point': ',',
|
|
|
|
|
'mon_thousands_sep': ' ',
|
|
|
|
|
'p_sign_posn': '1',
|
|
|
|
|
'n_sign_posn': '1',
|
|
|
|
|
'negative_sign': '-',
|
|
|
|
|
'positive_sign': '',
|
|
|
|
|
},
|
|
|
|
|
'GBP': {
|
2010-06-16 19:20:07 +02:00
|
|
|
'rounding': "Decimal('0.01')",
|
2010-02-25 17:53:28 +01:00
|
|
|
'digits': '2',
|
|
|
|
|
'p_cs_precedes': 'True',
|
|
|
|
|
'n_cs_precedes': 'True',
|
|
|
|
|
'p_sep_by_space': 'False',
|
|
|
|
|
'n_sep_by_space': 'False',
|
|
|
|
|
'mon_grouping': '[]',
|
|
|
|
|
'mon_decimal_point': '.',
|
|
|
|
|
'mon_thousands_sep': ',',
|
|
|
|
|
'p_sign_posn': '1',
|
|
|
|
|
'n_sign_posn': '1',
|
|
|
|
|
'negative_sign': '-',
|
|
|
|
|
'positive_sign': '',
|
|
|
|
|
},
|
|
|
|
|
'CHF': {
|
2010-06-16 19:20:07 +02:00
|
|
|
'rounding': "Decimal('0.01')",
|
2010-02-25 17:53:28 +01:00
|
|
|
'digits': '2',
|
|
|
|
|
'p_cs_precedes': 'False',
|
|
|
|
|
'n_cs_precedes': 'False',
|
|
|
|
|
'p_sep_by_space': 'True',
|
|
|
|
|
'n_sep_by_space': 'True',
|
|
|
|
|
'mon_grouping': '[3, 3, 0]',
|
|
|
|
|
'mon_decimal_point': ',',
|
|
|
|
|
'mon_thousands_sep': ' ',
|
|
|
|
|
'p_sign_posn': '1',
|
|
|
|
|
'n_sign_posn': '1',
|
|
|
|
|
'negative_sign': '-',
|
|
|
|
|
'positive_sign': '',
|
|
|
|
|
},
|
|
|
|
|
'USD': {
|
2010-06-16 19:20:07 +02:00
|
|
|
'rounding': "Decimal('0.01')",
|
2010-02-25 17:53:28 +01:00
|
|
|
'digits': '2',
|
|
|
|
|
'p_cs_precedes': 'True',
|
|
|
|
|
'n_cs_precedes': 'True',
|
|
|
|
|
'p_sep_by_space': 'False',
|
|
|
|
|
'n_sep_by_space': 'False',
|
2013-03-06 17:19:14 +01:00
|
|
|
'mon_grouping': '[3, 3, 0]',
|
2010-02-25 17:53:28 +01:00
|
|
|
'mon_decimal_point': '.',
|
|
|
|
|
'mon_thousands_sep': ',',
|
|
|
|
|
'p_sign_posn': '1',
|
|
|
|
|
'n_sign_posn': '1',
|
|
|
|
|
'negative_sign': '-',
|
|
|
|
|
'positive_sign': '',
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for currency in pycountry.currencies:
|
|
|
|
|
extend = ''
|
|
|
|
|
if currency.letter in currencies:
|
2013-02-23 17:29:03 +01:00
|
|
|
extend = u'''
|
2010-02-25 17:53:28 +01:00
|
|
|
<field name="rounding" eval="%(rounding)s"/>
|
|
|
|
|
<field name="digits" eval="%(digits)s"/>
|
|
|
|
|
<field name="p_cs_precedes" eval="%(p_cs_precedes)s"/>
|
|
|
|
|
<field name="n_cs_precedes" eval="%(n_cs_precedes)s"/>
|
|
|
|
|
<field name="p_sep_by_space" eval="%(p_sep_by_space)s"/>
|
|
|
|
|
<field name="n_sep_by_space" eval="%(n_sep_by_space)s"/>
|
|
|
|
|
<field name="mon_grouping">%(mon_grouping)s</field>
|
|
|
|
|
<field name="mon_decimal_point">%(mon_decimal_point)s</field>
|
|
|
|
|
<field name="mon_thousands_sep">%(mon_thousands_sep)s</field>
|
|
|
|
|
<field name="p_sign_posn" eval="%(p_sign_posn)s"/>
|
|
|
|
|
<field name="n_sign_posn" eval="%(n_sign_posn)s"/>
|
|
|
|
|
<field name="negative_sign">%(negative_sign)s</field>
|
2013-02-23 17:29:03 +01:00
|
|
|
<field name="positive_sign">%(positive_sign)s</field>''' % (
|
|
|
|
|
currencies[currency.letter])
|
|
|
|
|
record = u'''
|
2010-02-25 17:53:28 +01:00
|
|
|
<record model="currency.currency" id="%s">
|
|
|
|
|
<field name="name">%s</field>
|
|
|
|
|
<field name="code">%s</field>
|
|
|
|
|
<field name="numeric_code">%s</field>
|
|
|
|
|
<field name="symbol">%s</field>%s
|
2013-02-23 17:29:03 +01:00
|
|
|
</record>\n''' % (currency.letter.lower(), currency.name,
|
2010-02-25 17:53:28 +01:00
|
|
|
currency.letter, getattr(currency, 'numeric', ''),
|
|
|
|
|
symbols.get(currency.letter, currency.letter), extend)
|
2013-02-23 17:29:03 +01:00
|
|
|
sys.stdout.write(record.encode('utf-8'))
|