Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2023-06-01 v01.00.004-001-Alpha: Edit Mode Feature Testing (Sourcery refactored) #42

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 25 additions & 32 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,13 @@ def checkmode(edits: str, index: int) -> str | None:
return None

@staticmethod
def checkcommand(mode: str) \
-> str | None: # noqa # Pep8 E125
def checkcommand(mode: str) -> str | None: # noqa # Pep8 E125
"""Check the mode, translate to edit comand tyoe."""
allowed = {App.values.Edit.ADD,
App.values.Edit.UPDATE,
App.values.Edit.DELETE,
App.values.Edit.ToDo.TOGGLE}

if mode in allowed:
if mode == App.values.Edit.ADD:
return App.values.Edit.INSERT
Expand All @@ -210,14 +209,12 @@ def checkcommand(mode: str) \
return App.values.Edit.CLEAR
elif mode == App.values.Edit.ToDo.TOGGLE:
return App.values.Edit.ToDo.SELECT
return None
else:
return None
return None

@staticmethod
def isinrange(index) -> bool:
"""Check if index is in range."""
return True if 1 <= index <= App.get_range else False
return 1 <= index <= App.get_range


class Window:
Expand Down Expand Up @@ -274,12 +271,10 @@ def showrecord(data: pd.Series | pd.DataFrame,
individual = Record(series=data, source=data)
individual.editmode = command
# Debug and Inspect
if debug is True:
if debug:
rprint("Debug Mode: Show Record")
inspector(individual)
# Display Show Record or Supress
if displayon:
# If sendtolayout is True, builds the layout | Not None.
if individual.card(consolecard=Webconsole.console,
sendtoterminal=sendtolayout) is not None:
# Print Panels
Expand Down Expand Up @@ -865,21 +860,20 @@ def todo(ctx, selects: str) -> None:
"""
# Get Data
dataframe: pd.DataFrame = App.get_data()

# Guard Clause Checks Choice
def checkchoice(choice: str) -> str | None:
"""Guard Clause."""
if choice is not None and isinstance(choice, str):
return choice
else:
click.secho(message="Your selected option is not possible.\n "
"Try the commanď with one of these options: \n"
"Help: --help\n"
"Choices: All, Simple, Done, Grade, Review",
fg=styles.invalidfg,
bold=styles.invalidbold) # noqa
return None

click.secho(message="Your selected option is not possible.\n "
"Try the commanď with one of these options: \n"
"Help: --help\n"
"Choices: All, Simple, Done, Grade, Review",
fg=styles.invalidfg,
bold=styles.invalidbold) # noqa
return None

# Display
try:
App.command_todo(dataframe=dataframe,
Expand Down Expand Up @@ -914,7 +908,7 @@ def views(ctx, selects) -> None:
"""
# Get Data
dataframe: pd.DataFrame = App.get_data()

# Guard Clause Checks Choice
def checks(choice: str) -> str | None:
"""Guard Clause for View Choice
Expand All @@ -924,16 +918,15 @@ def checks(choice: str) -> str | None:
"""
if choice is not None and isinstance(choice, str):
return choice
else:
click.secho(message="Your selected option is not possible.\n "
"Try the commanď with one of these options: \n"
"Help: --help\n"
"Choices: All, Project, Criteria, "
"ToDo, Reference",
fg=styles.invalidfg,
bg=styles.invalidbg) # noqa
return None

click.secho(message="Your selected option is not possible.\n "
"Try the commanď with one of these options: \n"
"Help: --help\n"
"Choices: All, Project, Criteria, "
"ToDo, Reference",
fg=styles.invalidfg,
bg=styles.invalidbg) # noqa
return None

# Select the General Views
def chooseviews(data: pd.DataFrame, choice: str) -> None:
"""Select the General Views.
Expand Down Expand Up @@ -967,7 +960,7 @@ def chooseviews(data: pd.DataFrame, choice: str) -> None:
f"for the chosen option: {selects}",
fg=styles.warnfg,
bold=styles.warnbg)

# Display The View Choice
chooseviews(data=dataframe, choice=selects)
# Update Global Data
Expand Down