Пример #1
0
def localeconv(space):
    "() -> dict. Returns numeric and monetary locale-specific parameters."
    lp = rlocale.localeconv()

    # Numeric information
    w_result = space.newdict()
    w = space.wrap
    space.setitem(w_result, w("decimal_point"),
                  w(rffi.charp2str(lp.c_decimal_point)))
    space.setitem(w_result, w("thousands_sep"),
                  w(rffi.charp2str(lp.c_thousands_sep)))
    space.setitem(w_result, w("grouping"),
                  _w_copy_grouping(space, rffi.charp2str(lp.c_grouping)))
    space.setitem(w_result, w("int_curr_symbol"),
                  w(rffi.charp2str(lp.c_int_curr_symbol)))
    space.setitem(w_result, w("currency_symbol"),
                  w(rffi.charp2str(lp.c_currency_symbol)))
    space.setitem(w_result, w("mon_decimal_point"),
                  w(rffi.charp2str(lp.c_mon_decimal_point)))
    space.setitem(w_result, w("mon_thousands_sep"),
                  w(rffi.charp2str(lp.c_mon_thousands_sep)))
    space.setitem(w_result, w("mon_grouping"),
                  _w_copy_grouping(space, rffi.charp2str(lp.c_mon_grouping)))
    space.setitem(w_result, w("positive_sign"),
                  w(rffi.charp2str(lp.c_positive_sign)))
    space.setitem(w_result, w("negative_sign"),
                  w(rffi.charp2str(lp.c_negative_sign)))
    space.setitem(w_result, w("int_frac_digits"),
                  w(lp.c_int_frac_digits))
    space.setitem(w_result, w("frac_digits"),
                  w(lp.c_frac_digits))
    space.setitem(w_result, w("p_cs_precedes"),
                  w(lp.c_p_cs_precedes))
    space.setitem(w_result, w("p_sep_by_space"),
                  w(lp.c_p_sep_by_space))
    space.setitem(w_result, w("n_cs_precedes"),
                  w(lp.c_n_cs_precedes))
    space.setitem(w_result, w("n_sep_by_space"),
                  w(lp.c_n_sep_by_space))
    space.setitem(w_result, w("p_sign_posn"),
                  w(lp.c_p_sign_posn))
    space.setitem(w_result, w("n_sign_posn"),
                  w(lp.c_n_sign_posn))

    return w_result
Пример #2
0
def localeconv(space):
    "() -> dict. Returns numeric and monetary locale-specific parameters."
    lp = rlocale.localeconv()

    # Numeric information
    w_result = space.newdict()
    space.setitem(w_result, space.newtext("decimal_point"),
                  space.newtext(rffi.charp2str(lp.c_decimal_point)))
    space.setitem(w_result, space.newtext("thousands_sep"),
                  space.newtext(rffi.charp2str(lp.c_thousands_sep)))
    space.setitem(w_result, space.newtext("grouping"),
                  _w_copy_grouping(space, rffi.charp2str(lp.c_grouping)))
    space.setitem(w_result, space.newtext("int_curr_symbol"),
                  space.newtext(rffi.charp2str(lp.c_int_curr_symbol)))
    space.setitem(w_result, space.newtext("currency_symbol"),
                  space.newtext(rffi.charp2str(lp.c_currency_symbol)))
    space.setitem(w_result, space.newtext("mon_decimal_point"),
                  space.newtext(rffi.charp2str(lp.c_mon_decimal_point)))
    space.setitem(w_result, space.newtext("mon_thousands_sep"),
                  space.newtext(rffi.charp2str(lp.c_mon_thousands_sep)))
    space.setitem(w_result, space.newtext("mon_grouping"),
                  _w_copy_grouping(space, rffi.charp2str(lp.c_mon_grouping)))
    space.setitem(w_result, space.newtext("positive_sign"),
                  space.newtext(rffi.charp2str(lp.c_positive_sign)))
    space.setitem(w_result, space.newtext("negative_sign"),
                  space.newtext(rffi.charp2str(lp.c_negative_sign)))
    space.setitem(w_result, space.newtext("int_frac_digits"),
                  space.newint(lp.c_int_frac_digits))
    space.setitem(w_result, space.newtext("frac_digits"),
                  space.newint(lp.c_frac_digits))
    space.setitem(w_result, space.newtext("p_cs_precedes"),
                  space.newint(lp.c_p_cs_precedes))
    space.setitem(w_result, space.newtext("p_sep_by_space"),
                  space.newint(lp.c_p_sep_by_space))
    space.setitem(w_result, space.newtext("n_cs_precedes"),
                  space.newint(lp.c_n_cs_precedes))
    space.setitem(w_result, space.newtext("n_sep_by_space"),
                  space.newint(lp.c_n_sep_by_space))
    space.setitem(w_result, space.newtext("p_sign_posn"),
                  space.newint(lp.c_p_sign_posn))
    space.setitem(w_result, space.newtext("n_sign_posn"),
                  space.newint(lp.c_n_sign_posn))

    return w_result