A Python library to parse and edit RFC TXT documents
Project description
RFC Editor Library
A Python library for parsing and editing RFC (Request for Comments) TXT documents.
Features
- Parse RFC TXT documents and extract all sections
- Edit all RFC document sections including:
- Title
- Abstract
- Status of This Memo
- Copyright Notice
- Table of Contents
- Numbered sections (1., 2., etc.)
- Acknowledgements
- Contributors
- Author's Address
- Add, update, and delete sections
- Save modified documents back to TXT format
Installation
pip install rfc-editor
Or install from source:
pip install -e .
Usage
Parse an RFC Document
from rfc_editor import RFCEditor
editor = RFCEditor()
doc = editor.load("rfc1234.txt")
# Or parse from string
doc = editor.parse(rfc_content_string)
Access Document Sections
print(doc.rfc_number) # RFC number
print(doc.category) # e.g., "Standards Track"
print(doc.title) # RFC title
print(doc.abstract) # Abstract content
Edit Sections
# Edit title
editor.set_title("New Title")
# Edit abstract
editor.set_abstract("New abstract content...")
# Edit status
editor.set_status_of_memo("New status content...")
# Edit copyright
editor.set_copyright(2024, "Example Corp")
# Edit TOC
editor.set_toc("1. Introduction\n2. Body")
# Update a numbered section
editor.update_section("1", content="Updated introduction content...")
# Add a new section
editor.add_section("5", "New Section", "Section content...")
# Delete a section
editor.delete_section("1")
# Edit by section title
editor.set_section_by_title("Introduction", "New content...")
Save the Document
editor.save("output.txt")
Convert to Dictionary
data = editor.to_dict()
print(data["title"])
print(data["sections"])
Development
Install Dev Dependencies
pip install -e ".[dev]"
Run Tests
pytest tests/
Run Linting
flake8 src/ tests/
ruff check src/ tests/
black --check src/ tests/
Project Structure
rfc-editor/
├── src/
│ └── rfc_editor/
│ └── __init__.py # Main library code
├── tests/
│ ├── test_author.py
│ ├── test_document.py
│ ├── test_editor.py
│ └── test_section.py
├── pyproject.toml
├── README.md
├── .gitignore
└── SPEC.md
Version
0.1.0.1
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rfc_editor-0.1.0.1.tar.gz.
File metadata
- Download URL: rfc_editor-0.1.0.1.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
372473c637fee4a76a62ab2be7c5a777f3174108c2be7547d3634edee373cbe9
|
|
| MD5 |
e3f30a0e644c7f6d6b5971fa600bfd45
|
|
| BLAKE2b-256 |
8513ed4495268b2f27e79c311c08e6cb1afb14530d95bff1116b9de16a45bf88
|
Provenance
The following attestation bundles were made for rfc_editor-0.1.0.1.tar.gz:
Publisher:
pypi-publish.yml on daedalus/rfc-editor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rfc_editor-0.1.0.1.tar.gz -
Subject digest:
372473c637fee4a76a62ab2be7c5a777f3174108c2be7547d3634edee373cbe9 - Sigstore transparency entry: 1156914241
- Sigstore integration time:
-
Permalink:
daedalus/rfc-editor@1182913c9502617cad2d120f8b04fbb5ebc68e05 -
Branch / Tag:
refs/tags/v0.1.0.1 - Owner: https://github.com/daedalus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@1182913c9502617cad2d120f8b04fbb5ebc68e05 -
Trigger Event:
release
-
Statement type:
File details
Details for the file rfc_editor-0.1.0.1-py3-none-any.whl.
File metadata
- Download URL: rfc_editor-0.1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52ebf2065a8d38947383010c51ce143ef0682ebce09710a4ed61db070b6d5c94
|
|
| MD5 |
117803b718ad5beec1bec931c612737e
|
|
| BLAKE2b-256 |
622e2ce12b1252cd8d2103e3912b9baa6b9d4cf2258d72e608d533dd364d7a4c
|
Provenance
The following attestation bundles were made for rfc_editor-0.1.0.1-py3-none-any.whl:
Publisher:
pypi-publish.yml on daedalus/rfc-editor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rfc_editor-0.1.0.1-py3-none-any.whl -
Subject digest:
52ebf2065a8d38947383010c51ce143ef0682ebce09710a4ed61db070b6d5c94 - Sigstore transparency entry: 1156914381
- Sigstore integration time:
-
Permalink:
daedalus/rfc-editor@1182913c9502617cad2d120f8b04fbb5ebc68e05 -
Branch / Tag:
refs/tags/v0.1.0.1 - Owner: https://github.com/daedalus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@1182913c9502617cad2d120f8b04fbb5ebc68e05 -
Trigger Event:
release
-
Statement type: