Exemple #1
0
    def show_table(self):
        maxname = self.max_name_len()
        if maxname < 17:  #For empty tables totals
            maxname = 17
        maxlength = maxname + 2 + 7 + 2 + 7 + 2 + 7 + 2 + 7 + 2 + 7 + 2 + 7

        print(Style.BRIGHT + "=" * (maxlength) + Style.RESET_ALL)
        print(Style.BRIGHT +
              self.tr("ELABORATED PRODUCT '{}' NUTRICIONAL REPORT").format(
                  self.elaboratedproduct.name.upper()).center(maxlength, ' ') +
              Style.RESET_ALL)
        print(Style.BRIGHT + "=" * (maxlength) + Style.RESET_ALL)

        print(Style.BRIGHT + "{}  {}  {}  {}  {}  {}  {}".format(
            self.tr("NAME").ljust(maxname, " "),
            self.tr("GRAMS").rjust(7, ' '),
            self.tr("CALORIE").rjust(7, ' '),
            self.tr("CARBOHY").rjust(7, ' '),
            self.tr("PROTEIN").rjust(7, ' '),
            self.tr("FAT").rjust(7, ' '),
            self.tr("FIBER").rjust(7, ' ')) + Style.RESET_ALL)
        for product_in in self.arr:
            print("{}  {}  {}  {}  {}  {}  {}".format(
                product_in.fullName().ljust(maxname), a2s(product_in.amount),
                a2s(product_in.calories()), a2s(product_in.carbohydrate()),
                a2s(product_in.protein()), a2s(product_in.fat()),
                a2s(product_in.fiber())) + Style.RESET_ALL)

        print(Style.BRIGHT + "-" * (maxlength) + Style.RESET_ALL)
        total = self.tr("ELABORATED WITH {} PRODUCTS").format(self.length())
        print(Style.BRIGHT + "{}  {}  {}  {}  {}  {}  {}".format(
            total.ljust(maxname), a2s(self.grams()), a2s(self.calories()),
            a2s(self.carbohydrate()), a2s(self.protein()), a2s(self.fat()),
            a2s(self.fiber())) + Style.RESET_ALL)
        recomendations = self.tr("FINAL PRODUCT")
        product = self.mem.data.products.find_by_elaboratedproducts_id(
            self.elaboratedproduct.id)
        print(Style.BRIGHT + "{}  {}  {}  {}  {}  {}  {}".format(
            recomendations.ljust(maxname), a2s(product.amount),
            a2s(product.calories), a2s(product.carbohydrate),
            a2s(product.protein), a2s(product.fat), a2s(product.fiber)) +
              Style.RESET_ALL)
        print(Style.BRIGHT + "{}  {}  {}  {}  {}  {}  {}".format(
            self.tr("FINAL PRODUCT (100G)").ljust(maxname), a2s(100),
            a2s(product.component_in_100g(eProductComponent.Calories)),
            a2s(product.component_in_100g(eProductComponent.Carbohydrate)),
            a2s(product.component_in_100g(eProductComponent.Protein)),
            a2s(product.component_in_100g(eProductComponent.Fat)),
            a2s(product.component_in_100g(eProductComponent.Fiber))) +
              Style.RESET_ALL)
        print(Style.BRIGHT + "=" * (maxlength) + Style.RESET_ALL)
Exemple #2
0
    def show_table(self, date):
        maxname = self.max_name_len()
        if maxname < 17:  #For empty tables totals
            maxname = 17
        maxlength = 5 + 2 + maxname + 2 + 7 + 2 + 7 + 2 + 7 + 2 + 7 + 2 + 7 + 2 + 7

        print(Style.BRIGHT + "=" * (maxlength) + Style.RESET_ALL)
        print(Style.BRIGHT + "{} NUTRICIONAL REPORT AT {}".format(
            self.mem.user.name.upper(), date).center(maxlength, " ") +
              Style.RESET_ALL)
        print(Style.BRIGHT + Fore.YELLOW + "{} Kg. {} cm. {} years".format(
            self.mem.user.biometrics.last().weight,
            self.mem.user.biometrics.last().height,
            self.mem.user.age()).center(maxlength, " ") + Style.RESET_ALL)
        print(Style.BRIGHT + Fore.BLUE + "IMC: {} ==> {}".format(
            round(self.mem.user.biometrics.last().imc(), 2),
            self.mem.user.biometrics.last().imc_comment()).center(
                maxlength, " ") + Style.RESET_ALL)
        print(Style.BRIGHT + "=" * (maxlength) + Style.RESET_ALL)

        print(Style.BRIGHT + "{}  {}  {}  {}  {}  {}  {}  {}".format(
            "HOUR ", "NAME".ljust(maxname, " "), "GRAMS".rjust(7, ' '),
            "CALORIE".rjust(7, ' '), "CARBOHY".rjust(7, ' '), "PROTEIN".rjust(
                7, ' '), "FAT".rjust(7, ' '), "FIBER".rjust(7, ' ')) +
              Style.RESET_ALL)
        for meal in self.arr:
            print("{}  {}  {}  {}  {}  {}  {}  {}".format(
                meal.meal_hour(),
                meal.fullName().ljust(maxname), a2s(meal.amount),
                a2s(meal.calories()), a2s(meal.carbohydrate()),
                a2s(meal.protein()), a2s(meal.fat()), a2s(meal.fiber())) +
                  Style.RESET_ALL)

        print(Style.BRIGHT + "-" * (maxlength) + Style.RESET_ALL)
        total = "{} MEALS WITH THIS TOTALS".format(self.length())
        print(Style.BRIGHT + "{}  {}  {}  {}  {}  {}  {}".format(
            total.ljust(maxname + 7), a2s(self.grams()),
            ca2s(self.calories(),
                 self.mem.user.biometrics.last().bmr()),
            ca2s(self.carbohydrate(),
                 self.mem.user.biometrics.last().carbohydrate()),
            ca2s(self.protein(),
                 self.mem.user.biometrics.last().protein()),
            ca2s(self.fat(),
                 self.mem.user.biometrics.last().fat()),
            rca2s(self.fiber(),
                  self.mem.user.biometrics.last().fiber())) + Style.RESET_ALL)
        recomendations = "RECOMMENDATIONS"
        print(Style.BRIGHT + "{}  {}  {}  {}  {}  {}  {}".format(
            recomendations.ljust(maxname + 7), n2s(),
            a2s(self.mem.user.biometrics.last().bmr()),
            a2s(self.mem.user.biometrics.last().carbohydrate()),
            a2s(self.mem.user.biometrics.last().protein()),
            a2s(self.mem.user.biometrics.last().fat()),
            a2s(self.mem.user.biometrics.last().fiber())) + Style.RESET_ALL)
        print(Style.BRIGHT + "=" * (maxlength) + Style.RESET_ALL)