X-Git-Url: http://git.maemo.org/git/?p=gonvert;a=blobdiff_plain;f=src%2Funit_data.py;h=5c75c57242d0390559ad7e0b31766cedc493e0a6;hp=01565ce5682b9c5d61ec9dc09aded362dfffbb0d;hb=e62498c9c596588836ea7e08c83b6b5c21a43fbb;hpb=ff4682cab2c8cb71bae34cfb2cbd832f7aced00b diff --git a/src/unit_data.py b/src/unit_data.py index 01565ce..5c75c57 100644 --- a/src/unit_data.py +++ b/src/unit_data.py @@ -100,13 +100,13 @@ UNIT_DESCRIPTIONS = { _(u"Area"): { ".base_unit": _(u"square meter"), _(u"meter diameter circle"): - [(converters.f, ('pi*(x/2.0)**2', '2.0*(x/pi)**(0.5)')), "m dia.", _(u"Type the diameter of the circle in meters to find its area displayed in other fields.")], + [(converters.f, ('math.pi*(x/2.0)**2', '2.0*(x/math.pi)**(0.5)')), "m dia.", _(u"Type the diameter of the circle in meters to find its area displayed in other fields.")], _(u"centimeter diameter circle"): - [(converters.f, ('pi*(x/200.0)**2', '200.0*(x/pi)**(0.5)')), "cm dia.", _(u"Type the diameter of the circle in centimeters to find its area displayed in other fields.")], + [(converters.f, ('math.pi*(x/200.0)**2', '200.0*(x/math.pi)**(0.5)')), "cm dia.", _(u"Type the diameter of the circle in centimeters to find its area displayed in other fields.")], _(u"inch diameter circle"): - [(converters.f, ('pi*(((x*(25.4/1000))/2.0) )**2', '1000/25.4 * 2.0*(x/pi)**(0.5)')), "in dia.", _(u"Type the diameter of the circle in inches to find its area displayed in other fields.")], + [(converters.f, ('math.pi*(((x*(25.4/1000))/2.0) )**2', '1000/25.4 * 2.0*(x/math.pi)**(0.5)')), "in dia.", _(u"Type the diameter of the circle in inches to find its area displayed in other fields.")], _(u"foot diameter circle"): - [(converters.f, ('pi*(((x*((12*25.4)/1000))/2.0) )**2', '1000/(12*25.4) * 2.0*(x/pi)**(0.5)')), "ft dia.", _(u"Type the diameter of the circle in feet to find its area displayed in other fields.")], + [(converters.f, ('math.pi*(((x*((12*25.4)/1000))/2.0) )**2', '1000/(12*25.4) * 2.0*(x/math.pi)**(0.5)')), "ft dia.", _(u"Type the diameter of the circle in feet to find its area displayed in other fields.")], _(u"are"): [(converters.m, 100.0), '', _(u"The unit of superficial measure, being a square of which each side is ten meters in length; 100 square meters, or about 119.6 square yards.")], _(u"acre"): @@ -2190,6 +2190,32 @@ _(u"Electrical Voltage"): {".base_unit": _(u"volt"), UNIT_CATEGORIES = sorted(UNIT_DESCRIPTIONS.iterkeys()) +def get_units(categoryName): + units = sorted(UNIT_DESCRIPTIONS[categoryName].iterkeys()) + + # do not display .base_unit description key + del units[0] + + return units + + +def get_units_from_category(category): + units = sorted(category.iterkeys()) + + # do not display .base_unit description key + del units[0] + + return units + + +def get_base_unit(categoryName): + return UNIT_DESCRIPTIONS[categoryName][".base_unit"] + + +def get_base_unit_from_category(category): + return category[".base_unit"] + + future_dic = { _(u"Wire Gauge"): { ".base_unit": "circular mils",