aboutsummaryrefslogtreecommitdiffstats
path: root/pyGHDL/cli
diff options
context:
space:
mode:
authorPatrick Lehmann <Patrick.Lehmann@plc2.de>2022-11-28 00:32:17 +0100
committerPatrick Lehmann <Patrick.Lehmann@plc2.de>2022-11-30 23:32:47 +0100
commit51f0ead16d60c63d1b069f807e3513bba11d8947 (patch)
tree50094f57aeb7f9562341908864624199f4d7bc4a /pyGHDL/cli
parent473ed87bb505916e74441f01508c109bf39b30a7 (diff)
downloadghdl-51f0ead16d60c63d1b069f807e3513bba11d8947.tar.gz
ghdl-51f0ead16d60c63d1b069f807e3513bba11d8947.tar.bz2
ghdl-51f0ead16d60c63d1b069f807e3513bba11d8947.zip
Converted string formatting to f-strings.
Diffstat (limited to 'pyGHDL/cli')
-rwxr-xr-xpyGHDL/cli/dom.py32
-rw-r--r--pyGHDL/cli/lsp.py14
2 files changed, 23 insertions, 23 deletions
diff --git a/pyGHDL/cli/dom.py b/pyGHDL/cli/dom.py
index 816baafba..68bd33c34 100755
--- a/pyGHDL/cli/dom.py
+++ b/pyGHDL/cli/dom.py
@@ -224,7 +224,7 @@ class Application(LineTerminal, ArgParseMixin):
try:
self.SubParsers[args.Command].print_help()
except KeyError:
- self.WriteError("Command {0} is unknown.".format(args.Command))
+ self.WriteError(f"Command {args.Command} is unknown.")
self.WriteNormal("")
self.exit()
@@ -237,15 +237,15 @@ class Application(LineTerminal, ArgParseMixin):
self.PrintHeadline()
copyrights = __copyright__.split("\n", 1)
- self.WriteNormal("Copyright: {0}".format(copyrights[0]))
+ self.WriteNormal(f"Copyright: {copyrights[0]}")
for copyright in copyrights[1:]:
- self.WriteNormal(" {0}".format(copyright))
- self.WriteNormal("License: {0}".format(__license__))
+ self.WriteNormal(f" {copyright}")
+ self.WriteNormal(f"License: {__license__}")
authors = __author__.split(", ")
- self.WriteNormal("Authors: {0}".format(authors[0]))
+ self.WriteNormal(f"Authors: {authors[0]}")
for author in authors[1:]:
- self.WriteNormal(" {0}".format(author))
- self.WriteNormal("Version: {0}".format(__version__))
+ self.WriteNormal(f" {author}")
+ self.WriteNormal(f"Version: {__version__}")
self.exit()
# ----------------------------------------------------------------------------
@@ -263,10 +263,10 @@ class Application(LineTerminal, ArgParseMixin):
if args.Files is not None:
for file in args.Files:
if not file.exists():
- self.WriteError("File '{0!s}' does not exist.".format(file))
+ self.WriteError(f"File '{file!s}' does not exist.")
continue
- self.WriteNormal("Parsing file '{!s}'".format(file))
+ self.WriteNormal(f"Parsing file '{file!s}'")
document = self.addFile(file, "pretty")
self.WriteInfo(
dedent(
@@ -282,10 +282,10 @@ class Application(LineTerminal, ArgParseMixin):
elif args.Directory is not None:
d: Path = args.Directory
if not d.exists():
- self.WriteError("Directory '{0!s}' does not exist.".format(d))
+ self.WriteError(f"Directory '{d!s}' does not exist.")
for file in d.glob("**/*.vhd?"):
- self.WriteNormal("Parsing file '{!s}'".format(file))
+ self.WriteNormal(f"Parsing file '{file!s}'")
document = self.addFile(file, "pretty")
self.WriteInfo(
dedent(
@@ -349,23 +349,23 @@ def main(): # mccabe:disable=MC0001
app.Run()
app.exit()
except PrettyPrintException as ex:
- print("PP: {!s}".format(ex))
+ print(f"PP: {ex!s}")
LineTerminal.exit()
except DOMException as ex:
- print("DOM: {!s}".format(ex))
+ print(f"DOM: {ex!s}")
ex2: LibGHDLException = ex.__cause__
if ex2 is not None:
for message in ex2.InternalErrors:
- print("libghdl: {message}".format(message=message))
+ print(f"libghdl: {message}")
LineTerminal.exit(0)
LineTerminal.exit(6)
except LibGHDLException as ex:
- print("LIB: {!s}".format(ex))
+ print(f"LIB: {ex!s}")
for message in ex.InternalErrors:
- print(" {message}".format(message=message))
+ print(f" {message}")
LineTerminal.exit(5)
except GHDLBaseException as ex:
diff --git a/pyGHDL/cli/lsp.py b/pyGHDL/cli/lsp.py
index 694988153..5d09d7cc7 100644
--- a/pyGHDL/cli/lsp.py
+++ b/pyGHDL/cli/lsp.py
@@ -67,18 +67,18 @@ def __rotate_log_files(basename: str, num: int):
# one.
# Note: Path.with_suffix cannot be used as there might be multiple
# suffixes (like in trace.out.0).
- oldfile = Path("{}.{}".format(basename, num))
+ oldfile = Path(f"{basename}.{num}")
if oldfile.is_file():
oldfile.unlink()
# Rotate old files
for i in range(num, 0, -1):
- oldfile = Path("{}.{}".format(basename, i - 1))
+ oldfile = Path(f"{basename}.{i-1}")
if oldfile.is_file():
- oldfile.rename(Path("{}.{}".format(basename, i)))
+ oldfile.rename(Path(f"{basename}.{i}"))
# Rotate the newest log file.
bname = Path(basename)
if bname.is_file():
- bname.rename(Path("{}.{}".format(basename, 0)))
+ bname.rename(Path(f"{basename}.0"))
def _generateCLIParser() -> ArgumentParser:
@@ -115,7 +115,7 @@ def main():
errorout_console.Install_Handler()
libghdl.disp_config()
print("python:")
- print("sys.platform: {}, os.name: {}".format(sys.platform, os.name))
+ print(f"sys.platform: {sys.platform}, os.name: {os.name}")
print(sys.version)
return
@@ -140,8 +140,8 @@ def main():
)
if args.verbose != 0:
- sys_stderr.write("Args: {}\n".format(sys_argv))
- sys_stderr.write("Current directory: {}\n".format(os_getcwd()))
+ sys_stderr.write(f"Args: {sys_argv}\n")
+ sys_stderr.write(f"Current directory: {os_getcwd()}\n")
logger.info("Args: %s", sys_argv)
logger.info("Current directory is %s", os_getcwd())