Skip to content

Commit d3144a5

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 4178fe6 commit d3144a5

File tree

1 file changed

+69
-69
lines changed

1 file changed

+69
-69
lines changed

scheduling/cpuschedulingalgos.py

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,12 @@ def setup_ui(self) -> None:
299299
self.algo_cb = ttk.Combobox(
300300
algo_frame,
301301
values=[
302-
"FCFS",
303-
"SJF (Non-Preemptive)",
304-
"SJF (Preemptive)",
305-
"Priority (Non-Preemptive)",
306-
"Priority (Preemptive)",
307-
"Round Robin",
302+
"FCFS",
303+
"SJF (Non-Preemptive)",
304+
"SJF (Preemptive)",
305+
"Priority (Non-Preemptive)",
306+
"Priority (Preemptive)",
307+
"Round Robin",
308308
],
309309
)
310310
self.algo_cb.current(0)
@@ -342,20 +342,20 @@ def setup_ui(self) -> None:
342342

343343
def add_process(self) -> None:
344344
"""
345-
Adds a new process entry to the table.
346-
347-
>>> import tkinter as tk
348-
>>> root = tk.Tk()
349-
>>> gui = CPUSchedulerGUI(root)
350-
>>> gui.pid_e.insert(0, 'P1')
351-
>>> gui.arrival_e.insert(0, '0')
352-
>>> gui.burst_e.insert(0, '3')
353-
>>> gui.priority_e.insert(0, '1')
354-
>>> gui.add_process()
355-
>>> len(gui.processes) > 0
356-
True
357-
>>> root.destroy()
358-
"""
345+
Adds a new process entry to the table.
346+
347+
>>> import tkinter as tk
348+
>>> root = tk.Tk()
349+
>>> gui = CPUSchedulerGUI(root)
350+
>>> gui.pid_e.insert(0, 'P1')
351+
>>> gui.arrival_e.insert(0, '0')
352+
>>> gui.burst_e.insert(0, '3')
353+
>>> gui.priority_e.insert(0, '1')
354+
>>> gui.add_process()
355+
>>> len(gui.processes) > 0
356+
True
357+
>>> root.destroy()
358+
"""
359359
try:
360360
pid = self.pid_e.get()
361361
arrival = int(self.arrival_e.get())
@@ -370,39 +370,39 @@ def add_process(self) -> None:
370370

371371
def delete_process(self) -> None:
372372
"""
373-
Deletes a selected process.
374-
375-
>>> import tkinter as tk
376-
>>> root = tk.Tk()
377-
>>> gui = CPUSchedulerGUI(root)
378-
>>> gui.processes = [{"pid": "P1", "arrival": 0, "burst": 2, "priority": 1}]
379-
>>> gui.tree.insert("", "end", values=("P1", 0, 2, 1))
380-
>>> sel = gui.tree.get_children()[0]
381-
>>> gui.tree.selection_set(sel)
382-
>>> gui.delete_process()
383-
>>> gui.processes
384-
[]
385-
>>> root.destroy()
386-
"""
373+
Deletes a selected process.
374+
375+
>>> import tkinter as tk
376+
>>> root = tk.Tk()
377+
>>> gui = CPUSchedulerGUI(root)
378+
>>> gui.processes = [{"pid": "P1", "arrival": 0, "burst": 2, "priority": 1}]
379+
>>> gui.tree.insert("", "end", values=("P1", 0, 2, 1))
380+
>>> sel = gui.tree.get_children()[0]
381+
>>> gui.tree.selection_set(sel)
382+
>>> gui.delete_process()
383+
>>> gui.processes
384+
[]
385+
>>> root.destroy()
386+
"""
387387
if sel := self.tree.selection():
388388
pid = self.tree.item(sel[0])["values"][0]
389389
self.processes = [p for p in self.processes if p["pid"] != pid]
390390
self.tree.delete(sel[0])
391391

392392
def run_scheduling(self) -> None:
393393
"""
394-
Runs the selected scheduling algorithm.
395-
396-
>>> import tkinter as tk
397-
>>> root = tk.Tk()
398-
>>> gui = CPUSchedulerGUI(root)
399-
>>> gui.processes = [{"pid": "P1", "arrival": 0, "burst": 2, "priority": 1}]
400-
>>> gui.algo_cb.set("FCFS")
401-
>>> gui.run_scheduling()
402-
>>> hasattr(gui, "engine")
403-
True
404-
>>> root.destroy()
405-
"""
394+
Runs the selected scheduling algorithm.
395+
396+
>>> import tkinter as tk
397+
>>> root = tk.Tk()
398+
>>> gui = CPUSchedulerGUI(root)
399+
>>> gui.processes = [{"pid": "P1", "arrival": 0, "burst": 2, "priority": 1}]
400+
>>> gui.algo_cb.set("FCFS")
401+
>>> gui.run_scheduling()
402+
>>> hasattr(gui, "engine")
403+
True
404+
>>> root.destroy()
405+
"""
406406
algo = self.algo_cb.get()
407407
quantum = int(self.quantum_e.get() or 2)
408408
if algo.lower() == "round robin":
@@ -417,17 +417,17 @@ def run_scheduling(self) -> None:
417417

418418
def animate(self) -> None:
419419
"""
420-
Animates the scheduling visualization.
421-
422-
>>> import tkinter as tk
423-
>>> root = tk.Tk()
424-
>>> gui = CPUSchedulerGUI(root)
425-
>>> gui.processes = [{"pid": "P1", "arrival": 0, "burst": 1, "priority": 1}]
426-
>>> gui.engine = SchedulerEngine(gui.processes, "FCFS")
427-
>>> hasattr(gui, "animate")
428-
True
429-
>>> root.destroy()
430-
"""
420+
Animates the scheduling visualization.
421+
422+
>>> import tkinter as tk
423+
>>> root = tk.Tk()
424+
>>> gui = CPUSchedulerGUI(root)
425+
>>> gui.processes = [{"pid": "P1", "arrival": 0, "burst": 1, "priority": 1}]
426+
>>> gui.engine = SchedulerEngine(gui.processes, "FCFS")
427+
>>> hasattr(gui, "animate")
428+
True
429+
>>> root.destroy()
430+
"""
431431
self.ax.clear()
432432
x: int = 0
433433
colors: dict[str, any] = {}
@@ -463,18 +463,18 @@ def animate(self) -> None:
463463

464464
def show_results(self) -> None:
465465
"""
466-
Displays scheduling results.
467-
468-
>>> import tkinter as tk
469-
>>> root = tk.Tk()
470-
>>> gui = CPUSchedulerGUI(root)
471-
>>> gui.engine = SchedulerEngine([{"pid": "P1", "arrival": 0, "burst": 1, "priority": 1}], "FCFS")
472-
>>> gui.engine.stats = [("P1", 0, 1, 1, 1, 0, 0)]
473-
>>> gui.show_results()
474-
>>> "AVG" in gui.avg_label.cget("text")
475-
True
476-
>>> root.destroy()
477-
"""
466+
Displays scheduling results.
467+
468+
>>> import tkinter as tk
469+
>>> root = tk.Tk()
470+
>>> gui = CPUSchedulerGUI(root)
471+
>>> gui.engine = SchedulerEngine([{"pid": "P1", "arrival": 0, "burst": 1, "priority": 1}], "FCFS")
472+
>>> gui.engine.stats = [("P1", 0, 1, 1, 1, 0, 0)]
473+
>>> gui.show_results()
474+
>>> "AVG" in gui.avg_label.cget("text")
475+
True
476+
>>> root.destroy()
477+
"""
478478
for item in self.result_box.get_children():
479479
self.result_box.delete(item)
480480
total_wt = total_tat = total_rt = 0

0 commit comments

Comments
 (0)