Skip to content

Commit

Permalink
Merge pull request #5 from elamandeep/optimize-docstrings
Browse files Browse the repository at this point in the history
Updated the code
  • Loading branch information
elamandeep authored Aug 6, 2023
2 parents 4edf1ad + 8844934 commit 0490aee
Show file tree
Hide file tree
Showing 5 changed files with 314 additions and 96 deletions.
165 changes: 160 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,160 @@
app/taskwise/database.db
app/taskwise/__pycache__
build
dist
taskwise.egg-info
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
1 change: 0 additions & 1 deletion app/readme.md

This file was deleted.

61 changes: 38 additions & 23 deletions app/taskwise/functions.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,68 @@
"""
Required functions for `models.py` and `main.py`
"""
import time
import uuid

from rich.table import Table
from rich.console import Console
from rich.progress import SpinnerColumn, Progress, TextColumn
import uuid
from taskwise.models import *
from questionary import Choice, Style, select
import typer
from questionary import (
Choice,
Style,
select
)

from taskwise.models import Model, List, Task


def generate_options(obj:Model , custom_style:List):
def generate_options(obj: Model, custom_style: List):
"""
This function generates the options for the select function.
Generates the options for the select function.
"""
return select("Select task id", choices=[
Choice(title=[("class:yellow","Go Back")], value="back")]+
list(Choice(title=[("class:display",str(i[0]+" "+i[1]))], value=str(i[0])) for i in obj.list_all_tasks()), style=custom_style).ask()
return select("Select task id", choices=[
Choice(title=[("class:yellow", "Go Back")], value="back")
] + list(Choice(title=[("class:display", str(f'{i[0]} {i[1]}'))],
value=str(i[0])) for i in obj.list_all_tasks()),
style=custom_style).ask()

def loader(desc:str):

def loader(desc: str):
"""
This function is used to display a spinner
Used to display a spinner
"""
with Progress(
SpinnerColumn(),TextColumn("[progress.description]{task.description}"),) as progress:
text = TextColumn("[progress.description]{task.description}")
with Progress(SpinnerColumn(), text) as progress:
progress.add_task(description=desc)
time.sleep(2)

time.sleep(0.5)


def display_all_tasks():
"""
This function displays all the tasks present in the database in a table format.
Displays all the tasks present in the database in a table
format.
"""

model_obj = Model()
table = Table(show_header=True, header_style="Italic yellow", title="Your task list")
table = Table(show_header=True, header_style="Italic yellow",
title="Your task list")
table.add_column("Task ID", style="yellow", width=30)
table.add_column("Task", style="cyan", width=30)
table.add_column("Category", style="green", width=20)
table.add_column("Status", style="magenta", width=10)
table.add_column("Date Added", style="red", width=20)
table.add_column("Date Completed", style="", width=20)
table.add_column("Date Completed", style="", width=20)
for i in model_obj.list_all_tasks():
table.add_row(i[0], i[1], i[2], i[3], i[4], i[5])
console = Console()
console.print(table)

while True:
is_continue = typer.confirm("Do you want to go back?")
if is_continue == True:
if is_continue is True:
loader("going back...")
break



def insert_new_task():
Expand All @@ -65,6 +79,7 @@ def insert_new_task():
loader("Adding task...")
typer.echo("Task added successfully!")


def update_task():
"""
This function updates the task in the database.
Expand All @@ -73,18 +88,18 @@ def update_task():
("display", "fg:#083fc9 italic"),
])
model_obj = Model()
task_id = generate_options(model_obj , custom_style)
task_id = generate_options(model_obj, custom_style)
if task_id == "back":
loader("going back...")
return

is_category = typer.confirm("Do you want to update the category?")
if is_category == True:
if is_category is True:
category = typer.prompt("Enter the category")
model_obj.update_task(task_id, category)

is_task = typer.confirm("Do you want to update the task?")
if is_task == True:
if is_task is True:
task = typer.prompt("Enter the task")
model_obj.update_task(task_id, task)
loader("Updating task...")
Expand All @@ -99,7 +114,7 @@ def delete_task():
custom_style = Style([
("display", "fg:#f44336 italic"),
])
task_id = generate_options(obj , custom_style)
task_id = generate_options(obj, custom_style)
if task_id == "back":
loader("going back...")
return
Expand Down
Loading

0 comments on commit 0490aee

Please sign in to comment.