Updated for f string

Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
Dimitris Zlatanidis 2020-01-20 20:29:18 +01:00
parent 9b6b5dbfff
commit e816763ca6

View file

@ -63,24 +63,23 @@ class Graph:
G = pgv.AGraph(deps_dict) G = pgv.AGraph(deps_dict)
G.layout(prog="fdp") G.layout(prog="fdp")
if self.image == "ascii": if self.image == "ascii":
G.write("{0}.dot".format(self.image)) G.write(f"{self.image}.dot")
self.graph_easy() self.graph_easy()
G.draw(self.image) G.draw(self.image)
except IOError: except IOError:
raise SystemExit() raise SystemExit()
if os.path.isfile(self.image): if os.path.isfile(self.image):
print("Graph image file '{0}' created".format(self.image)) print(f"Graph image file '{self.image}' created")
raise SystemExit() raise SystemExit()
def check_file(self): def check_file(self):
"""Check for file format and type """Check for file format and type
""" """
try: try:
image_type = ".{0}".format(self.image.split(".")[1]) image_type = f".{self.image.split('.')[1]}"
if image_type not in self.file_format: if image_type not in self.file_format:
print("Format: '{0}' not recognized. Use one of " print(f"Format: '{self.image.split('.')[1]}' not recognized. Use one of "
"them:\n{1}".format(self.image.split(".")[1], f"them:\n{', '.join(self.file_format)}")
", ".join(self.file_format)))
raise SystemExit() raise SystemExit()
except IndexError: except IndexError:
print("slpkg: Error: Image file suffix missing") print("slpkg: Error: Image file suffix missing")