Skip to content

Commit

Permalink
'Refactored by Sourcery'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sourcery AI committed Jun 3, 2023
1 parent 3a0708e commit adba1a0
Showing 1 changed file with 27 additions and 34 deletions.
61 changes: 27 additions & 34 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 @@ -870,21 +865,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 @@ -919,7 +913,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 @@ -929,16 +923,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 @@ -972,7 +965,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 Expand Up @@ -1366,7 +1359,7 @@ def progress(ctx: click.Context,
# Debugging Flags
dataframe: pd.DataFrame = App.get_data()
editmode = App.values.Edit.ToDo.SELECT

validindex = 1
if not Valid.isinrange(index):
click.secho(message="Row does not exit. Try again",
Expand Down Expand Up @@ -1402,7 +1395,7 @@ def progress(ctx: click.Context,
editor.editmode = editmode if \
Valid.checkmode(edits='toggle', index=index) \
is not None else ''
editor.editdisplay = f'Edit: > Progress in report mode'
editor.editdisplay = 'Edit: > Progress in report mode'
editor.command = Valid.checkcommand(mode='select')
# - Edit note field of the record
if index is not None and Valid.isinrange(index):
Expand Down

0 comments on commit adba1a0

Please sign in to comment.