{"id":22438980,"url":"https://github.com/strictdoc-project/reqif","last_synced_at":"2026-04-09T21:21:44.043Z","repository":{"id":42028381,"uuid":"437313468","full_name":"strictdoc-project/reqif","owner":"strictdoc-project","description":"Python library for ReqIF format. ReqIF parsing and unparsing.","archived":false,"fork":false,"pushed_at":"2024-11-08T22:49:59.000Z","size":824,"stargazers_count":33,"open_issues_count":8,"forks_count":19,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-03-30T00:05:18.919Z","etag":null,"topics":["reqif"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/strictdoc-project.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-11T15:07:18.000Z","updated_at":"2025-03-18T08:35:16.000Z","dependencies_parsed_at":"2023-10-15T13:23:33.136Z","dependency_job_id":"8f86760b-d8c8-47dc-9882-ad8cf8c954bb","html_url":"https://github.com/strictdoc-project/reqif","commit_stats":{"total_commits":171,"total_committers":5,"mean_commits":34.2,"dds":0.03508771929824561,"last_synced_commit":"44ca50873a5c95857456c04077c55430a61944f3"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strictdoc-project%2Freqif","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strictdoc-project%2Freqif/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strictdoc-project%2Freqif/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strictdoc-project%2Freqif/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/strictdoc-project","download_url":"https://codeload.github.com/strictdoc-project/reqif/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247419859,"owners_count":20936012,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["reqif"],"created_at":"2024-12-06T01:12:20.464Z","updated_at":"2026-04-09T21:21:39.018Z","avatar_url":"https://github.com/strictdoc-project.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ReqIF\n\nReqIF is a Python library for working with ReqIF format.\n\n## Supported features\n\n- Parsing/unparsing ReqIF\n- Formatting (pretty-printing) ReqIF\n- Basic validation of ReqIF\n- Anonymizing ReqIF files to safely exchange the problematic ReqIF files.\n\n## Getting started\n\n```bash\npip install reqif\n```\n\n## Using ReqIF as a library\n\n### Parsing ReqIF\n\n```py\nfrom reqif.parser import ReqIFParser\n\ninput_file_path = \"input.reqif\"\n\nreqif_bundle = ReqIFParser.parse(input_file_path)\nfor specification in reqif_bundle.core_content.req_if_content.specifications:\n    print(specification.long_name)\n\n    for current_hierarchy in reqif_bundle.iterate_specification_hierarchy(specification):\n        print(current_hierarchy)\n```\n\nor for ReqIFz files:\n\n```py\nfrom reqif.parser import ReqIFZParser\n\ninput_file_path = \"input.reqifz\"\n\nreqifz_bundle = ReqIFZParser.parse(input_file_path)\nfor reqif_bundle_file, reqif_bundle in reqifz_bundle.reqif_bundles.items():\n    print(f\"Bundle: {reqif_bundle_file} {reqif_bundle}\")\n    for specification in reqif_bundle.core_content.req_if_content.specifications:\n        print(specification)\n\nfor attachment in reqifz_bundle.attachments:\n    print(f\"Attachment: {attachment}\")\n```\n\n### Unparsing ReqIF\n\n```py\nfrom reqif.parser import ReqIFParser\nfrom reqif.unparser import ReqIFUnparser\n\ninput_file_path = \"input.sdoc\"\noutput_file_path = \"output.sdoc\"\n\nreqif_bundle = ReqIFParser.parse(input_file_path)\nreqif_xml_output = ReqIFUnparser.unparse(reqif_bundle)\nwith open(output_file_path, \"w\", encoding=\"UTF-8\") as output_file:\n    output_file.write(reqif_xml_output)\n```\n\nThe contents of `reqif_xml_output` should be the same as the contents of the \n`input_file`.\n\n## Using ReqIF as a command-line tool\n\nAfter installing the `reqif` Pip package, the `reqif` command becomes available\nand can be executed from the command line.\n\n```commandline\nreqif\nusage: reqif [-h] {passthrough,anonymize,dump,format,validate,version} ...\nreqif: error: the following arguments are required: command\n```\n\n### Validate command\n\nThe `validate` command is the first command to run against a ReqIF file. The\n`reqif` library contains two sets of checks: \n\n1. reqif-internal checks of a ReqIF file's schema and semantics.\n2. a check of a ReqIF file against the\n   [ReqIF's official schema](https://www.omg.org/spec/ReqIF/20110401/reqif.xsd)\n   maintained by the Object Management Group (OMG).\n\nThe first set of checks is always enabled. To enable the second set of the \nofficial ReqIF schema checks, use `--use-reqif-schema`:\n\n```commandline\nreqif validate --use-reqif-schema sample.reqif \n```\n\nIf an error is found, the `reqif validate` command exits with 1. If no errors\nare found, the exit code is `0`.\n\n### Passthrough command\n\nThe `reqif passthrough` command is a useful tool for verifying whether the reqif\ntool correctly parses a given ReqIF file format that the user has at hand.\nThe `passthrough` command first parses the ReqIF XML into in-memory Python \nobjects and then unparses these Python objects back to an output ReqIF file.\n\nIf everything goes fine, the output of the passthrough command should be\nidentical to the contents of the input file.\n\n`tests/integration/examples` contains samples of ReqIF files found on the \ninternet. The integration tests ensure that for these samples, the passthrough\ncommand always produces outputs that are identical to inputs. \n\n### Formatting ReqIF\n\nThe `format` command is similar to `clang-format` for C/C++ files or \n`cmake-format` for CMake files. The input file is parsed and then pretty-printed\nback to an output file.\n\nThis command is useful when dealing with the ReqIF files that are hand-written\nor the ReqIF files produced by the ReqIF tools that do not generate well-formed\nXML with consistent indentation.  \n\nThe `tests/integration/commands/format` contains typical examples of\nincorrectly formatted ReqIF files. The integration tests ensure that the\n`format` command fixes these issues.\n\n### Anonymizing ReqIF\n\nThe anonymization helps when exchanging ReqIF documents between different ReqIF\ntools including this `reqif` library. If a particular file is not recognized\ncorrectly by a tool, a user can send their anonymized file to a developer for\nfurther inspection.\n\nThe anonymize command accepts an input `.reqif` file and produces an anonymized\nversion of that file to the output `.reqif` file.\n\n```\nusage: reqif anonymize [-h] input_file output_file\nmain.py anonymize: error: the following arguments are required: input_file, output_file\n```\n\nExamples of anonymization:\n\n```xml\n...\n\u003cATTRIBUTE-VALUE-STRING THE-VALUE=\"...Anonymized-2644691225...\"\u003e\n...\n\u003cATTRIBUTE-VALUE-XHTML\u003e\n  \u003cDEFINITION\u003e\n    \u003cATTRIBUTE-DEFINITION-XHTML-REF\u003ermf-7d0ed062-e964-424c-8305-45067118d959\u003c/ATTRIBUTE-DEFINITION-XHTML-REF\u003e\n  \u003c/DEFINITION\u003e\n  \u003cTHE-VALUE\u003e...Anonymized-141441514...\u003c/THE-VALUE\u003e\n...\n```\n\nThe anonymization algorithm preserves the uniqueness of the anonymized strings\nin the document. This way, if the requirement UID identifiers are anonymized,\nthey will still be unique strings in an anonymized document.\n\n## How-to examples\n\nThe `tests/integration/examples` folder contains various examples of how the\nReqIF library can be used. Some examples could be and will be made more\nadvanced over time. The examples are stored in the integration tests folder, so\nthat they don't regress over time. The feedback and other example requests are\nwelcome.\n\n## Implementation details\n\nThe core of the library is a **ReqIF first-stage parser** that only transforms\nthe contents of a ReqIF XML file into a ReqIF in-memory representation. The\nin-memory representation is a tree of Python objects that map directly to the \nobjects of the ReqIF XML file structure (e.g, Spec Objects, Spec Types, Data\nTypes, Specifications, etc.).\n\n### Parsing: Converting from ReqIF to other formats\n\nThe first-stage parser (implemented by the class `ReqIFParser`) can be used by\nuser's second-stage parser/converter scripts that convert the ReqIF in-memory\nstructure into a desired format such as Excel, HTML or other formats. The\ntwo-stage process allows the first stage parsing to focus solely on creating an\nin-memory ReqIF object tree, while the second stage parsing can further parse\nthe ReqIF object tree according to the logical structure of user's documents as\nencoded in the ReqIF XML file that was produced by user's requirements\nmanagement tool.\n\n### Unparsing: Converting from other formats to ReqIF\n\nThe reverse process is also possible. A user's script converts another format's\ncontents into a ReqIF in-memory representation. The ReqIF un-parser\n(implemented by the class `ReqIFUnparser`) can be used to render the in-memory\nobjects to the ReqIF XML file.\n\n### Tolerance\n\nThe first-stage parser is made tolerant against possible issues in ReqIF.\nIt should be possible to parse a ReqIF file even if it is missing important\ninformation.\n\nA minimum ReqIF parsed by the `reqif`:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cREQ-IF xmlns=\"http://www.omg.org/spec/ReqIF/20110401/reqif.xsd\" xmlns:configuration=\"http://eclipse.org/rmf/pror/toolextensions/1.0\"\u003e\n\u003c/REQ-IF\u003e\n```\n\nA separate validation command shall be used to confirm the validity\nof the ReqIF contents.\n\n### Printing of the attributes\n\nThe `reqif` library uses a simple convention for printing the XML attributes: the\nattributes are always printed in the alphabetic order of their attribute names.\n\n```xml\n\u003cDATATYPE-DEFINITION-REAL ACCURACY=\"10\" IDENTIFIER=\"ID_TC1000_DatatypeDefinitionReal\" LAST-CHANGE=\"2012-04-07T01:51:37.112+02:00\" LONG-NAME=\"TC1000 DatatypeDefinitionReal\" MAX=\"1234.5678\" MIN=\"-1234.5678\"/\u003e\n```\n\nSome tools do not respect this rule: for example some tools will print\nthe attribute `ACCURACY=\"10\"` after the `LONG-NAME` attribute but the `reqif`\nlibrary does not provide support for preserving a non-alphabetic order of the\nattributes.\n\n### A bottom-up overview of the ReqIF format\n\n- ReqIF is a standard. See reference document [RD01](#rd01-reqif-standard).\n- ReqIF has a fixed structure (see \"What is common for all ReqIF documents\" \nbelow)\n- ReqIF standard does not define a document structure for every documents so\na ReqIF tool implementor is free to choose between several implementation \napproaches. There is a\n[ReqIF Implementation Guide](#rd02-reqif-implementation-guide)\nthat attempts to harmonize ReqIF tool developments. See also\n\"What is left open by the ReqIF standard\" below.\n- ReqIF files produced by various tool often have incomplete schemas. \n\n### What is common for all ReqIF documents\n\n- All documents have ReqIF tags:\n  - Document metadata is stored inside tags of `REQ-IF-HEADER` tag.\n  - Requirements are stored as `\u003cSPEC-OBJECT\u003e`s\n  - Requirements types are stored as `\u003cSPEC-TYPE\u003e`s\n  - Supported data types are stored as `\u003cDATATYPE\u003e`\n  - Relationships such as 'Parent-Child' as stored as `\u003cSPEC-RELATIONS\u003e`\n\n### What is left open by the ReqIF standard\n \n- How to distinguish requirements from headers/sections?\n  - One way: create separate `SPEC-TYPES`: one or more for requirements and\n    one for sections.\n  - Another way: have one spec type but have it provide a `TYPE` field that can\n    be used to distinguish between `REQUIREMENT` or `SECTION`.\n  - Yet another way: Check if the \"ReqIF.ChapterName\" is present on the spec object.\n    When present, it is a section. When not, it is a requirement.\n\n## Reference documents\n\n### [RD01] ReqIF standard\n\nThe latest version is 1.2:\n[Requirements Interchange Format](https://www.omg.org/spec/ReqIF)\n\n### [RD02] ReqIF Implementation Guide \n\n[ReqIF Implementation Guide v1.8](https://www.prostep.org/fileadmin/downloads/prostep-ivip_ImplementationGuide_ReqIF_V1-8.pdf)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrictdoc-project%2Freqif","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstrictdoc-project%2Freqif","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrictdoc-project%2Freqif/lists"}