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 4262ac6 commit f670a64
Showing 1 changed file with 25 additions and 32 deletions.
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

0 comments on commit f670a64

Please sign in to comment.