Skip to content

Commit

Permalink
Replace one if statement w/ if expr (#129)
Browse files Browse the repository at this point in the history
* (feat): f-string formatting

* (feat) replace if stat. w/ if expr.
  • Loading branch information
ThibFrgsGmz committed Apr 24, 2023
1 parent 6ea2611 commit 53ccc63
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/fprime/fpp/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class FppMissingSupportFiles(FprimeException):

def __init__(self, file):
super().__init__(
f"Current directory does not define any FPP files. Did you intend to run in the topology directory?"
"Current directory does not define any FPP files. Did you intend to run in the topology directory?"
)


Expand Down
5 changes: 1 addition & 4 deletions src/fprime/util/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ def utility_entry(args):
parsed, cmake_args, make_args, parser, runners = parse_args(args)

try:
if skip_build_loading(parsed):
build = None
else:
build = load_build(parsed)
build = None if skip_build_loading(parsed) else load_build(parsed)

# runners is a Dict[str, Callable] of {command_name: handler_functions} pairs
return runners[parsed.command](
Expand Down
2 changes: 1 addition & 1 deletion src/fprime/util/code_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def execute(
# Backup files unless --no-backup is requested
if self.backup:
for file in self._files_to_format:
shutil.copy2(file, file.parent / (file.stem + ".bak" + file.suffix))
shutil.copy2(file, file.parent / f"{file.stem}.bak{file.suffix}")
pass_through = args[1]
self._preprocess_files()
clang_args = [
Expand Down
6 changes: 3 additions & 3 deletions src/fprime/util/cookiecutter_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def run_impl(build: Build, source_path: Path):
hpp_dest = hpp_files[0]
cpp_dest = common[0] if common else cpp_files[0]

if not confirm(f"Generate implementation files (yes/no)? "):
if not confirm("Generate implementation files (yes/no)? "):
return False
print(
"Refreshing cache and generating implementation files (ignore 'Stop' CMake warning)..."
Expand Down Expand Up @@ -320,7 +320,7 @@ def get_valid_input(prompt):
name = input(prompt)
char = is_valid_name(name)
if char != "valid":
print("'" + char + "' is not a valid character")
print(f"'{char}' is not a valid character")
else:
valid_name = True
return name
Expand Down Expand Up @@ -467,7 +467,7 @@ def new_deployment(parsed_args):
os.path.dirname(__file__)
+ "/../cookiecutter_templates/cookiecutter-fprime-deployment"
)
print(f"[INFO] Cookiecutter: using builtin template for new deployment")
print("[INFO] Cookiecutter: using builtin template for new deployment")
try:
gen_path = cookiecutter(source, overwrite_if_exists=parsed_args.overwrite)
except OutputDirExistsException as out_directory_error:
Expand Down

0 comments on commit 53ccc63

Please sign in to comment.