コード例 #1
0
#!/usr/bin/env python3

# This script displays a list of all owned labels, and how many bottles of each
# are currently in the cellar. Bottle lists are categorized by hold year.

# --------------------------------------------------------------------------------

from colorama import Fore, Back, Style
from datetime import date

from backend.cellar import Cellar
from scripts.styling import stylize
from scripts.options import parseArguments

[showCosts] = parseArguments([('c', 'cost', 'Also show bottle costs')])
cellar = Cellar()

bottlesByYear = cellar.bottlesByYear
for year in sorted(bottlesByYear):
	bottles = bottlesByYear[year]
	count = len(bottles)
	yearCost = 0

	labels = {}
	for bottle in bottles:
		labelDesc = "%s  %s  %s" % (
			stylize(Style.BRIGHT, bottle.label.description),
			stylize(Fore.BLUE, bottle.label.varietalDescription),
			stylize(Style.DIM, bottle.label.winery.region.description))

		if showCosts:
コード例 #2
0
#!/usr/bin/env python3

# This script displays the number of bottles consumed each month.

# --------------------------------------------------------------------------------

from colorama import Fore, Back, Style

from backend.cellar import Cellar
from scripts.styling import stylize
from scripts.options import parseArguments
import calendar

[verbose,
 showCosts] = parseArguments([('v', 'verbose', 'Also show specific bottles'),
                              ('c', 'cost', 'Also show bottle costs')])

cellar = Cellar()

consumption = cellar.consumptionByMonth()
for year in sorted(consumption):
    for month in sorted(consumption[year]):
        count = len(consumption[year][month])

        monthSummary = (
            "%s: %s" %
            (stylize(Fore.BLUE, "%s %d" % (calendar.month_abbr[month], year)),
             stylize(Fore.GREEN, '%d bottle%s' %
                     (count, ' ' if count == 1 else 's'))))

        if showCosts: