Exemplo n.º 1
0
    def __call__(self, jarvis, s):
        while True:
            amount = get_float('Enter an amount: ')
            from_unit = self.get_units('Enter from which unit: ')
            to_unit = self.get_units('Enter to which unit: ')

            if (from_unit != to_unit):
                break
            else:
                jarvis.say('Please enter different units')

        convamount = self.length_convert(jarvis, amount, from_unit, to_unit)

        if (convamount.is_integer() is False):
            precision = 0
            precision = get_float("Please enter precision (max:12): ")
            presicion = float(precision)
            while True:
                if (precision.is_integer() and precision <= 12):
                    break
                else:
                    precision = get_float("Please enter an integer (max:12): ")

        convamount = round(convamount, int(precision))

        outputText = self.txt_build(amount, convamount, from_unit, to_unit)

        jarvis.say(outputText)
Exemplo n.º 2
0
    def do_currencyconv(self, s=None):
        """Show the convert from a currency to another"""
        currencies = find_currencies()

        amount = get_float('Enter an amount: ')
        from_currency = get_currency('Enter from which currency: ', currencies)
        to_currency = get_currency('Enter to which currency: ', currencies)

        currencyconv(self, amount, from_currency, to_currency)
Exemplo n.º 3
0
    def run(self, jarvis, s):
        currencies = self.find_currencies()

        amount = get_float('Enter an amount: ')
        from_currency = self.get_currency('Enter from which currency: ',
                                          currencies)
        to_currency = self.get_currency('Enter to which currency: ',
                                        currencies)

        self.currencyconv(jarvis, amount, from_currency, to_currency)
Exemplo n.º 4
0
 def test_get_float_comma(self, geet_mock):
     # change comma with dot
     self.assertEqual(get_float('Enter a number: '), 12.6)
Exemplo n.º 5
0
 def test_get_float_int(self, get_mock):
     # normal case
     print("Testing get_float_int checked")
     self.assertEqual(get_float(""), 1)