Skip to content
v0.1.3latest release121 skills4 categories6 sub-categories247 tested scripts397 reference docsContact us
scripts/psw_check.py
#!/usr/bin/env python3
"""Check a Part Submission Warrant (PSW) and its initial process study results before signing.

PSW JSON keys: part_number, part_name, drawing_rev, eng_change_level, weight_kg, po_number, submission_level,
reason, results {dimensional, material, appearance, statistical: true/false}, imds, signed_by, signed_date,
studies: [{characteristic, special (true/false), ppk, cpk, n, stable (true/false)}]

Initial process study acceptance (AIAG PPAP 4th ed. 2.2.11): stable process with index > 1.67 meets acceptance;
1.33 to 1.67 may be acceptable - contact the customer; < 1.33 does not meet acceptance. At least 100 readings
from 25 or more subgroups; unstable processes need customer agreement before submission.

Checks:
  PS001 high    identification incomplete (part number, drawing revision, engineering change level, PO)
  PS002 high    part weight missing (kg, to four decimals)
  PS003 high    a results box is not 'meets requirements' - do not sign without customer-approved deviation
  PS004 high    special characteristic index < 1.33
  PS005 medium  special characteristic index 1.33-1.67, or process unstable - customer approval needed
  PS006 medium  study has fewer than 100 readings
  PS007 medium  reason for submission or submission level missing
  PS008 medium  material reporting (IMDS or customer system) not stated
  PS009 low     not signed or not dated

Usage:
    python psw_check.py psw.json

Exit codes: 0 ready to sign, 1 high findings, 2 read or JSON error.
"""

import argparse
import json
import sys


def check(p):
    f = []
    missing = [k for k in ("part_number", "drawing_rev", "eng_change_level", "po_number") if not p.get(k)]
    if missing:
        f.append(("PS001", "high", f"identification missing: {', '.join(missing)}"))
    w = p.get("weight_kg")
    if not isinstance(w, (int, float)) or w <= 0:
        f.append(("PS002", "high", "part weight in kg (four decimals) is required on the PSW"))
    for k, v in (p.get("results") or {}).items():
        if v is not True:
            f.append(("PS003", "high", f"{k} results do not meet requirements: resolve or obtain a deviation before signing"))
    if not p.get("results"):
        f.append(("PS003", "high", "no results declaration (dimensional, material, appearance, statistical)"))
    for s in p.get("studies") or []:
        name = s.get("characteristic", "?")
        idx = s.get("ppk") if s.get("ppk") is not None else s.get("cpk")
        if idx is None:
            f.append(("PS004", "high", f"{name}: no Ppk/Cpk reported"))
            continue
        special = s.get("special", False)
        if not s.get("stable", True):
            f.append(("PS005", "medium", f"{name}: process not stable - agree the approach with the customer before submitting"))
        if idx < 1.33:
            sev = "high" if special else "medium"
            f.append(("PS004", sev, f"{name}: index {idx:.2f} < 1.33 does not meet acceptance; 100% inspection and an action plan"))
        elif idx < 1.67:
            f.append(("PS005", "medium", f"{name}: index {idx:.2f} between 1.33 and 1.67 - contact the customer for approval"))
        if (s.get("n") or 0) < 100:
            f.append(("PS006", "medium", f"{name}: {s.get('n') or 0} readings; initial studies need >= 100 from >= 25 subgroups"))
    if not (p.get("reason") and p.get("submission_level")):
        f.append(("PS007", "medium", "state the reason for submission and the submission level"))
    if not p.get("imds"):
        f.append(("PS008", "medium", "state the IMDS (or customer system) submission ID and date"))
    if not (p.get("signed_by") and p.get("signed_date")):
        f.append(("PS009", "low", "authorized signature, title and date required"))
    return f


def main():
    ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
    ap.add_argument("psw", help="PSW JSON, or - for stdin")
    a = ap.parse_args()
    try:
        p = json.load(sys.stdin if a.psw == "-" else open(a.psw, encoding="utf-8"))
        if not isinstance(p, dict):
            raise ValueError("PSW JSON must be an object")
    except (OSError, ValueError) as e:
        print(f"error: {e}", file=sys.stderr)
        return 2
    f = check(p)
    print(f"PSW {p.get('part_number', '?')} rev {p.get('drawing_rev', '?')} level {p.get('submission_level', '?')}")
    for s in p.get("studies") or []:
        idx = s.get("ppk") if s.get("ppk") is not None else s.get("cpk")
        print(f"  {'SC ' if s.get('special') else '   '}{s.get('characteristic', '?'):<28}index {idx if idx is not None else '-':<6} n={s.get('n', 0)}")
    print()
    for code, sev, msg in f:
        print(f"{code} [{sev}] {msg}")
    if any(x[1] == "high" for x in f):
        print("\nDo not sign yet.")
    elif any(x[1] == "medium" for x in f):
        print("\nReady to sign once the medium items are agreed with the customer.")
    else:
        print("\nReady to sign.")
    return 1 if any(x[1] == "high" for x in f) else 0


if __name__ == "__main__":
    sys.exit(main())
More in Quality Management & ISO 9001

8d-problem-solving-report-writer

Write and review 8D problem-solving reports for customer complaints and serious nonconformities (automotive and aerospace practice: Ford Global 8D, VDA, GM, Stellantis formats): D0 emergency response, D1 cross-functional team and champion, D2 problem description with 5W2H and is / is-not and no cause in the statement, D3 interim containment within 24 hours with verification and clean point, D4 verified occurrence and escape (non-detection) root causes plus systemic cause, D5 permanent corrective actions for each cause verified before implementation, D6 implementation, validation with production data and removal of containment, D7 PFMEA, control plan and read-across to similar products, D8 closure and recognition. Checks an 8D discipline by discipline for missing content, human-error root causes, missing escape cause or action, late containment and dates out of order.

acceptance-sampling-plan-selector

Select and evaluate acceptance sampling plans for incoming, in-process and final inspection: ANSI/ASQ Z1.4 / ISO 2859-1 single sampling under normal inspection (code letter from lot size and inspection level I, II, III, S-1 to S-4; sample size, Ac and Re from AQL, following the table's arrows to the correct plan; 100% when n reaches the lot size; AQLs above 10 per 100 units), operating characteristic curves (Pa at any quality, producer's quality level, indifference point, LTPD, AOQ and AOQL, binomial or hypergeometric), plans designed from producer and consumer risk, and c = 0 zero-acceptance plans. Covers AQL choice by defect class, switching rules between normal, tightened and reduced inspection, when sampling is not appropriate, and random sampling.

approved-supplier-list-manager

Manage and audit an approved supplier list (ASL) / external provider register for ISO 9001 8.4.1, IATF 16949 8.4 and AS9100 8.4.1: supplier status (approved, conditional, probation, pending, disqualified), scope of approval by commodity and process, risk class, certification and expiry, re-evaluation intervals by risk, conditions with end dates, single-source contingency, approver and customer-directed sources. Audits the list for expired or expiring certificates, overdue re-evaluations, conditional or probation status past its decision date, high-risk suppliers without the required certification, single-source suppliers without backup and missing approvers, and checks purchase orders for suppliers that are off-list, disqualified or pending, or buying outside the approved scope. Covers ERP blocks, PO requirements, off-list and emergency purchases.

apqp-phase-planner

Plan and track Advanced Product Quality Planning (AIAG APQP 3rd edition, IATF 16949) for a new or changed automotive part: back-schedule the five phases (plan and define, product design, process design, product and process validation, launch and feedback) from the start-of-production date by program complexity, with overlap, PPAP lead and safe-launch period; list the deliverables and gate for each phase (DFMEA, DVP&R, feasibility, process flow, PFMEA, control plans, MSA, Ppk, run at rate, PPAP, safe launch, lessons learned); adjust for build-to-print suppliers; flag compressed timelines and late or untracked deliverables against a status list. Covers gate reviews, red/yellow/green status reporting, run at rate and safe-launch exit criteria.

as9100-gap-analyzer

Run an AS9100D / EN 9100:2018 gap analysis for aviation, space and defence suppliers on the requirements added to ISO 9001: on-time delivery and conformity focus, management representative, ethics and human-factors awareness, operational planning and operational risk management, configuration management, product safety, counterfeit-part prevention, special requirements, critical items and key characteristics, external provider register and flow-down, FOD prevention, tooling and NC program control, special process validation, first article inspection (AS9102), traceability, in-service data and nonconforming product control. Generates and scores a worksheet, grades missing core controls as major, and checks invalid n/a claims. Covers AS9101/AS9104, OASIS, AS9102 FAI forms, counterfeit standards (AS5553, AS6174, AS6081), NADCAP and the planned IA9100 transition.

audit-report-writer

Write internal, supplier and pre-certification audit reports with the content ISO 19011:2018 6.5 expects: audit objectives, scope, criteria with revisions, dates, team and auditees, method and sampling statement, specific strengths, findings table and three-part finding details (requirement, evidence, statement), conclusion on the degree of fulfilment of criteria, diverging opinions, follow-up deadlines and distribution. Builds a Markdown report from a JSON audit record, generates the conclusion from the findings (major / minor / none) and flags reports missing required content or findings without clause or evidence. Covers conclusion wording, closing meetings, response expectations and verifying corrective actions.