def main(): """ Example: UnitXObjectの変数を保存し,取り出し,確認する. """ from simulator import Simulator s = Simulator() UnitXObject.manager = s.get_manager() UnitXObject.scopes = s.get_scopes() # Regist part crr_scope = s.get_scopes().peek() crr_scope['x'] = UnitXObject(value=1.5, varname='x', is_none=False, unit=Unit(ex_numer=u'm', numer=u'cm', ex_denom=None, denom=None)) crr_scope['y'] = UnitXObject(value=1500, varname='y', is_none=False, unit=Unit(ex_numer=u'm', numer=u'km', ex_denom=u'時', denom=u'分')) s.get_scopes().new_scope() # Find & Show part found_scope = s.get_scopes().peek().find_scope_of('x') Util.dump(s.get_scopes()) # Checking equals() tmp_obj = UnitXObject(value=1.5, varname='x', is_none=False, unit=Unit(ex_numer=None, numer=u'cm', ex_denom=None, denom=None)) print tmp_obj print crr_scope['x'] == tmp_obj # Clear part s.get_scopes().del_scope() s.get_scopes().del_scope() return Constants.EXIT_SUCCESS
def main(): """Run an example for a Stdlib class.""" from unitx_object import UnitXObject from unit import Unit from simulator import Simulator s = Simulator() UnitXObject.manager = s.get_manager() UnitXObject.scopes = s.get_scopes() l = UnitXObject(value=1.5, varname='x', is_none=False, unit=Unit(numer=u'cm')) r = UnitXObject(value=1.5, varname='y', is_none=False, unit=Unit(numer=u'cm')) func_obj = None stdlib = Stdlib() stdlib.expect([l,r], func_obj) return Constants.EXIT_SUCCESS
def main(): """Run an example for a Unit class.""" from simulator import Simulator s = Simulator() manager = s.get_manager() minute = manager.get_criterion(u'分') hour = manager.get_criterion(u'時') value = 120 * (hour / minute) Util.dump(manager.unit_dict) print u'kind of unit:', manager.get_unit_id(u'分') print '%s分' % value print '-' * 10 from unit import Unit print manager._trans_original_value(u"10:00 - 17:00", Unit(u'US_Eastern', u'Asia_Tokyo')) return Constants.EXIT_SUCCESS