Ejemplo n.º 1
0
import re
import typing

import attr

# from perry_bot.class_helpers import EditExistingEntry
import peewee
import arrow
from rich.markup import escape
from rich.prompt import IntPrompt, Prompt
from rich.table import Table

from perry_bot.console import Console, main_console
from perry_bot.db_models import HabitDB, db

console: Console = main_console()


@attr.s(kw_only=True, auto_attribs=True)
class Habit:
    """Habit dataclass."""

    id: typing.Any
    habit_name: typing.Any
    completion: typing.List[bool]
    start_date: typing.Any
    completed_on: typing.List[str]
    frequency: typing.List[str]
    next_due: typing.List[str]

    # query all habits = HabitDB.select()
Ejemplo n.º 2
0
"""Console script for perry_bot."""

import click
from click.exceptions import BadOptionUsage
import arrow
import re
import typing
from perry_bot.console import main_console
from perry_bot.tracker_classes import water, mood, habit

console = main_console()


def validate_date(value: str) -> str:
    """Check date is in the correct format.

    :param value:
    :return:
    """
    valid_strings = ["today"]
    view_year = re.match(r"\d{4}", value)
    view_month = re.match(r"\d{4}-\d{2}", value)
    view_day = re.match(r"\d{4}-\d{2}-\d{2}", value)

    if view_year:
        return value
    if view_month:
        return value
    if view_day:
        return value
    if value.lower() == valid_strings[0]: