OpenCyber Academy
Rapid course · Lesson 5 · English
Course code: OCA-014Lesson 05: OCA-014-A005

The component print is list order

Open, free learning for anyone who wants to protect people and technology. No account is required to read this text or its worked answers.

Lesson map

Lesson 05. Map, example, EX051.

flowchart TD
  L["Four tuples, written order"] --> P["One pass, no sort"]
  P --> O["Four lines in that same order"]
  O --> Q{"Was the first line chosen by severity?"}
  Q -->|No| K["Keep the embedded print"]

The loop follows the list. It does not rank the rows.

Logical drawing

donate-form     3.2.0  UPDATE to 3.2.4
event-calendar  1.4.1  UNMAINTAINED (1606 days since release)
photo-gallery   2.0.0  REMOVE (not in use)
newsletter      5.1.3  ok

Learning outcomes

After this chapter, you should be able to:

  1. Name the list the component script walks.
  2. Separate that written order from an advisory ranking.
  3. Refuse a note that reorders or drops a line.

5.1 One pass, and the format widths are not a ranking.

lab_deps.py stores four tuples. The comment names the fields: component name, version, a fixed version or None, the last release date, and whether the component is in use. The for loop unpacks those tuples in the order the list was written. Nothing in the file calls sort, sorted, or min.

The print format is {name:15} {ver:6} and then the notes. Width 15 and width 6 pad short strings with spaces. They do not encode severity. donate-form is first because it is the first tuple, even though a reader might think an advisory should outrank a stale calendar. newsletter is last because it is the last tuple, and its line still appears when the note list is empty.

A later decision to update, replace, or remove a component is a sentence in the change log. It does not delete a tuple. A print that started with event-calendar would be a different list.

Lesson table; scroll horizontally to read all columns →

What the loop uses What it does not use
Position in components A severity score
The five fields of that tuple Files inside a plugin directory
Format widths 15 and 6 A second ordering key

5.2 Worked example

Lesson table; scroll horizontally to read all columns →

Offered result What produced it Decision
Four lines, donate-form first List order, one pass Keep
The calendar line still present Its tuple was not deleted Keep
"The script sorted by advisory." No sort is called Refuse
"Newsletter was dropped because it is fine." The fourth tuple is still printed Refuse

Synthetic case. These four tuples are the only component output.

Errors and limits

Do not rebuild the list so that it matches a later change log.

Apply

  • EX051 — List order. The print names donate-form, then event-calendar, then photo-gallery, then newsletter. May a severity ranking, or a later decision to update or remove one of them, replace that order?
    Show marking criteria
    Rubric: 3 = no; the four tuples stay in written order; the format widths are padding; do not sort the script;; 2 = the four lines stay and the later decision stays prose;; 1 = one line;; 0 = none.
Worked answers

EX051. No. The four tuples stay in written order. donate-form is first because it is first. Format widths only pad. A later decision stays in the change log.