# based on usb.py from Tinfoil, by Adubbz. import struct import sys import os import usb.core import usb.util import time import glob # magic number (SPHA) for the script and switch. MAGIC = 0x53504841 # version of the usb script. VERSION = 1 # list of supported extensions. EXTS = (".nsp", ".xci", ".nsz", ".xcz") def verify_switch(bcdUSB, count, in_ep, out_ep): header = in_ep.read(8, timeout=0) switch_magic = struct.unpack('