Skip to content

tools/update-table.py discards tag, status, description columns from CSV #38

Description

@sumanjeet0012

tools/update-table.py reads all 5 columns from the upstream table.csv but only writes the prefix code to constants.py, discarding tag, status, and description.

Problem

The script reads the full CSV row (line 78):

# tools/update-table.py
for row in multicodec_reader:
    code = padded_hex(row["code"])
    name_const = row["name"].upper().replace("-", "_")
    name_human = row["name"]
    tag = row["tag"]           # ← Read but only used for grouping
    # row["status"]            # ← Never read
    # row["description"]       # ← Never read

But when writing the output (line 82), only the prefix is included:

    value = "{'prefix': {code}, },".format(code=codec["code"])

The tag variable is used for grouping entries into sections (line 68: parsed[tag].append(value)) but is never stored in the output data.

Proposed Solution

Modify the output format to include all available metadata:

value = (
    "{{'prefix': {code}, 'tag': '{tag}', "
    "'status': '{status}', 'description': '{desc}'}},\n"
).format(
    code=codec["code"],
    tag=codec.get("tag", ""),
    status=codec.get("status", ""),
    desc=codec.get("description", "").replace("'", "\\'"),
)

Also update the unique_code() function and the FOOTER derivation to handle the enriched data.

After this change, regenerate constants.py and verify the output.

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions