Drop OrderedDict usage in favor of standard dicts

Python 3.7+ guarantees insertion order is preserved and we (currently)
require 3.10+
This commit is contained in:
2Shirt 2023-05-29 17:25:48 -07:00
parent a253fdc80f
commit 2cce572acf
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
4 changed files with 12 additions and 20 deletions

View file

@ -1,16 +1,14 @@
"""WizardKit: Config - ddrescue""" """WizardKit: Config - ddrescue"""
# vim: sts=2 sw=2 ts=2 # vim: sts=2 sw=2 ts=2
from collections import OrderedDict
# Layout # Layout
TMUX_SIDE_WIDTH = 21 TMUX_SIDE_WIDTH = 21
TMUX_LAYOUT = OrderedDict({ TMUX_LAYOUT = {
'Source': {'height': 2, 'Check': True}, 'Source': {'height': 2, 'Check': True},
'Started': {'width': TMUX_SIDE_WIDTH, 'Check': True}, 'Started': {'width': TMUX_SIDE_WIDTH, 'Check': True},
'Progress': {'width': TMUX_SIDE_WIDTH, 'Check': True}, 'Progress': {'width': TMUX_SIDE_WIDTH, 'Check': True},
}) }
# ddrescue # ddrescue
AUTO_PASS_THRESHOLDS = { AUTO_PASS_THRESHOLDS = {

View file

@ -1,18 +1,16 @@
"""WizardKit: Config - UFD""" """WizardKit: Config - UFD"""
# vim: sts=2 sw=2 ts=2 # vim: sts=2 sw=2 ts=2
from collections import OrderedDict
from wk.cfg.main import KIT_NAME_FULL from wk.cfg.main import KIT_NAME_FULL
# General # General
SOURCES = OrderedDict({ SOURCES = {
'Linux': {'Arg': '--linux', 'Type': 'ISO'}, 'Linux': {'Arg': '--linux', 'Type': 'ISO'},
'WinPE': {'Arg': '--winpe', 'Type': 'ISO'}, 'WinPE': {'Arg': '--winpe', 'Type': 'ISO'},
'Main Kit': {'Arg': '--main-kit', 'Type': 'KIT'}, 'Main Kit': {'Arg': '--main-kit', 'Type': 'KIT'},
'Extra Dir': {'Arg': '--extra-dir', 'Type': 'DIR'}, 'Extra Dir': {'Arg': '--extra-dir', 'Type': 'DIR'},
}) }
# Definitions: Boot entries # Definitions: Boot entries
BOOT_ENTRIES = { BOOT_ENTRIES = {

View file

@ -14,8 +14,6 @@ import shutil
import subprocess import subprocess
import time import time
from collections import OrderedDict
import psutil import psutil
import pytz import pytz
@ -141,12 +139,12 @@ class BlockPair():
self.map_data = {} self.map_data = {}
self.map_path = None self.map_path = None
self.size = source.size self.size = source.size
self.status = OrderedDict({ self.status = {
'read-skip': 'Pending', 'read-skip': 'Pending',
'read-full': 'Pending', 'read-full': 'Pending',
'trim': 'Pending', 'trim': 'Pending',
'scrape': 'Pending', 'scrape': 'Pending',
}) }
self.view_map = 'DISPLAY' in os.environ or 'WAYLAND_DISPLAY' in os.environ self.view_map = 'DISPLAY' in os.environ or 'WAYLAND_DISPLAY' in os.environ
self.view_proc = None self.view_proc = None

View file

@ -1,8 +1,6 @@
"""WizardKit: UFD Functions""" """WizardKit: UFD Functions"""
# vim: sts=2 sw=2 ts=2 # vim: sts=2 sw=2 ts=2
# TODO: Drop OrderedDict use
import logging import logging
import math import math
import os import os
@ -10,7 +8,6 @@ import pathlib
import shutil import shutil
from subprocess import CalledProcessError from subprocess import CalledProcessError
from collections import OrderedDict
from docopt import docopt from docopt import docopt
from wk import io, log from wk import io, log
@ -618,7 +615,7 @@ def update_boot_entries(ufd_dev, images=None) -> None:
def verify_sources(args, ufd_sources) -> dict[str, pathlib.Path]: def verify_sources(args, ufd_sources) -> dict[str, pathlib.Path]:
"""Check all sources and abort if necessary, returns dict.""" """Check all sources and abort if necessary, returns dict."""
sources = OrderedDict() sources = {}
for label, data in ufd_sources.items(): for label, data in ufd_sources.items():
s_path = args[data['Arg']] s_path = args[data['Arg']]
@ -628,10 +625,11 @@ def verify_sources(args, ufd_sources) -> dict[str, pathlib.Path]:
except FileNotFoundError: except FileNotFoundError:
ui.print_error(f'ERROR: {label} not found: {s_path}') ui.print_error(f'ERROR: {label} not found: {s_path}')
ui.abort() ui.abort()
if not is_valid_path(s_path_obj, data['Type']): else:
ui.print_error(f'ERROR: Invalid {label} source: {s_path}') if not is_valid_path(s_path_obj, data['Type']):
ui.abort() ui.print_error(f'ERROR: Invalid {label} source: {s_path}')
sources[label] = s_path_obj ui.abort()
sources[label] = s_path_obj
return sources return sources